@pixelmatters/markup 0.0.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.
package/dist/widget.js ADDED
@@ -0,0 +1,4739 @@
1
+ //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/dist/preact.module.js
2
+ var e, t, n, r, i, a, o, s, c, l, u, d, f, p, m = {}, h = [], g = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, _ = Array.isArray;
3
+ function v(e, t) {
4
+ for (var n in t) e[n] = t[n];
5
+ return e;
6
+ }
7
+ function y(e) {
8
+ e && e.parentNode && e.parentNode.removeChild(e);
9
+ }
10
+ function b(t, n, r) {
11
+ var i, a, o, s = {};
12
+ for (o in n) o == "key" ? i = n[o] : o == "ref" ? a = n[o] : s[o] = n[o];
13
+ if (arguments.length > 2 && (s.children = arguments.length > 3 ? e.call(arguments, 2) : r), typeof t == "function" && t.defaultProps != null) for (o in t.defaultProps) s[o] === void 0 && (s[o] = t.defaultProps[o]);
14
+ return x(t, s, i, a, null);
15
+ }
16
+ function x(e, r, i, a, o) {
17
+ var s = {
18
+ type: e,
19
+ props: r,
20
+ key: i,
21
+ ref: a,
22
+ __k: null,
23
+ __: null,
24
+ __b: 0,
25
+ __e: null,
26
+ __c: null,
27
+ constructor: void 0,
28
+ __v: o ?? ++n,
29
+ __i: -1,
30
+ __u: 0
31
+ };
32
+ return o == null && t.vnode != null && t.vnode(s), s;
33
+ }
34
+ function S(e) {
35
+ return e.children;
36
+ }
37
+ function C(e, t) {
38
+ this.props = e, this.context = t;
39
+ }
40
+ function w(e, t) {
41
+ if (t == null) return e.__ ? w(e.__, e.__i + 1) : null;
42
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
43
+ return typeof e.type == "function" ? w(e) : null;
44
+ }
45
+ function T(e) {
46
+ if (e.__P && e.__d) {
47
+ var n = e.__v, r = n.__e, i = [], a = [], o = v({}, n);
48
+ o.__v = n.__v + 1, t.vnode && t.vnode(o), N(e.__P, o, n, e.__n, e.__P.namespaceURI, 32 & n.__u ? [r] : null, i, r ?? w(n), !!(32 & n.__u), a), o.__v = n.__v, o.__.__k[o.__i] = o, ie(i, o, a), n.__e = n.__ = null, o.__e != r && E(o);
49
+ }
50
+ }
51
+ function E(e) {
52
+ if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
53
+ if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
54
+ }), E(e);
55
+ }
56
+ function D(e) {
57
+ (!e.__d && (e.__d = !0) && r.push(e) && !O.__r++ || i != t.debounceRendering) && ((i = t.debounceRendering) || a)(O);
58
+ }
59
+ function O() {
60
+ try {
61
+ for (var e, t = 1; r.length;) r.length > t && r.sort(o), e = r.shift(), t = r.length, T(e);
62
+ } finally {
63
+ r.length = O.__r = 0;
64
+ }
65
+ }
66
+ function ee(e, t, n, r, i, a, o, s, c, l, u) {
67
+ var d, f, p, g, _, v, y, b = r && r.__k || h, x = t.length;
68
+ for (c = k(n, t, b, c, x), d = 0; d < x; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && b[p.__i] || m, p.__i = d, v = N(e, p, f, i, a, o, s, c, l, u), g = p.__e, p.ref && f.ref != p.ref && (f.ref && P(f.ref, null, p), u.push(p.ref, p.__c || g, p)), _ == null && g != null && (_ = g), (y = !!(4 & p.__u)) || f.__k === p.__k ? (c = A(p, c, e, y), y && f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : g && (c = g.nextSibling), p.__u &= -7);
69
+ return n.__e = _, c;
70
+ }
71
+ function k(e, t, n, r, i) {
72
+ var a, o, s, c, l, u = n.length, d = u, f = 0;
73
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = x(null, o, null, null, null) : _(o) ? o = e.__k[a] = x(S, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = x(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = te(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
74
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = w(s)), se(s, s));
75
+ return r;
76
+ }
77
+ function A(e, t, n, r) {
78
+ var i, a;
79
+ if (typeof e.type == "function") {
80
+ for (i = e.__k, a = 0; i && a < i.length; a++) i[a] && (i[a].__ = e, t = A(i[a], t, n, r));
81
+ return t;
82
+ }
83
+ e.__e != t && (r && (t && e.type && !t.parentNode && (t = w(e)), n.insertBefore(e.__e, t || null)), t = e.__e);
84
+ do
85
+ t &&= t.nextSibling;
86
+ while (t != null && t.nodeType == 8);
87
+ return t;
88
+ }
89
+ function te(e, t, n, r) {
90
+ var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && (2 & l.__u) == 0;
91
+ if (l === null && s == null || u && s == l.key && c == l.type) return n;
92
+ if (r > +!!u) {
93
+ for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o;
94
+ }
95
+ return -1;
96
+ }
97
+ function j(e, t, n) {
98
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || g.test(t) ? n : n + "px";
99
+ }
100
+ function ne(e, t, n, r, i) {
101
+ var a, o;
102
+ n: if (t == "style") if (typeof n == "string") e.style.cssText = n;
103
+ else {
104
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || j(e.style, t, "");
105
+ if (n) for (t in n) r && n[t] == r[t] || j(e.style, t, n[t]);
106
+ }
107
+ else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(u, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[l] = r[l] : (n[l] = d, e.addEventListener(t, a ? p : f, a)) : e.removeEventListener(t, a ? p : f, a);
108
+ else {
109
+ if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
110
+ else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
111
+ e[t] = n ?? "";
112
+ break n;
113
+ } catch {}
114
+ typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
115
+ }
116
+ }
117
+ function M(e) {
118
+ return function(n) {
119
+ if (this.l) {
120
+ var r = this.l[n.type + e];
121
+ if (n[c] == null) n[c] = d++;
122
+ else if (n[c] < r[l]) return;
123
+ return r(t.event ? t.event(n) : n);
124
+ }
125
+ };
126
+ }
127
+ function N(e, n, r, i, a, o, s, c, l, u) {
128
+ var d, f, p, m, g, b, x, w, T, E, D, O, k, A, te, j = n.type;
129
+ if (n.constructor !== void 0) return null;
130
+ 128 & r.__u && (l = !!(32 & r.__u), o = [c = n.__e = r.__e]), (d = t.__b) && d(n);
131
+ n: if (typeof j == "function") try {
132
+ if (w = n.props, T = j.prototype && j.prototype.render, E = (d = j.contextType) && i[d.__c], D = d ? E ? E.props.value : d.__ : i, r.__c ? x = (f = n.__c = r.__c).__ = f.__E : (T ? n.__c = f = new j(w, D) : (n.__c = f = new C(w, D), f.constructor = j, f.render = ce), E && E.sub(f), f.state ||= {}, f.__n = i, p = f.__d = !0, f.__h = [], f._sb = []), T && f.__s == null && (f.__s = f.state), T && j.getDerivedStateFromProps != null && (f.__s == f.state && (f.__s = v({}, f.__s)), v(f.__s, j.getDerivedStateFromProps(w, f.__s))), m = f.props, g = f.state, f.__v = n, p) T && j.getDerivedStateFromProps == null && f.componentWillMount != null && f.componentWillMount(), T && f.componentDidMount != null && f.__h.push(f.componentDidMount);
133
+ else {
134
+ if (T && j.getDerivedStateFromProps == null && w !== m && f.componentWillReceiveProps != null && f.componentWillReceiveProps(w, D), n.__v == r.__v || !f.__e && f.shouldComponentUpdate != null && !1 === f.shouldComponentUpdate(w, f.__s, D)) {
135
+ n.__v != r.__v && (f.props = w, f.state = f.__s, f.__d = !1), n.__e = r.__e, n.__k = r.__k, n.__k.some(function(e) {
136
+ e && (e.__ = n);
137
+ }), h.push.apply(f.__h, f._sb), f._sb = [], f.__h.length && s.push(f);
138
+ break n;
139
+ }
140
+ f.componentWillUpdate != null && f.componentWillUpdate(w, f.__s, D), T && f.componentDidUpdate != null && f.__h.push(function() {
141
+ f.componentDidUpdate(m, g, b);
142
+ });
143
+ }
144
+ if (f.context = D, f.props = w, f.__P = e, f.__e = !1, O = t.__r, k = 0, T) f.state = f.__s, f.__d = !1, O && O(n), d = f.render(f.props, f.state, f.context), h.push.apply(f.__h, f._sb), f._sb = [];
145
+ else do
146
+ f.__d = !1, O && O(n), d = f.render(f.props, f.state, f.context), f.state = f.__s;
147
+ while (f.__d && ++k < 25);
148
+ f.state = f.__s, f.getChildContext != null && (i = v(v({}, i), f.getChildContext())), T && !p && f.getSnapshotBeforeUpdate != null && (b = f.getSnapshotBeforeUpdate(m, g)), A = d != null && d.type === S && d.key == null ? ae(d.props.children) : d, c = ee(e, _(A) ? A : [A], n, r, i, a, o, s, c, l, u), f.base = n.__e, n.__u &= -161, f.__h.length && s.push(f), x && (f.__E = f.__ = null);
149
+ } catch (e) {
150
+ if (n.__v = null, l || o != null) if (e.then) {
151
+ for (n.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
152
+ o[o.indexOf(c)] = null, n.__e = c;
153
+ } else {
154
+ for (te = o.length; te--;) y(o[te]);
155
+ re(n);
156
+ }
157
+ else n.__e = r.__e, n.__k = r.__k, e.then || re(n);
158
+ t.__e(e, n, r);
159
+ }
160
+ else o == null && n.__v == r.__v ? (n.__k = r.__k, n.__e = r.__e) : c = n.__e = oe(r.__e, n, r, i, a, o, s, l, u);
161
+ return (d = t.diffed) && d(n), 128 & n.__u ? void 0 : c;
162
+ }
163
+ function re(e) {
164
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(re));
165
+ }
166
+ function ie(e, n, r) {
167
+ for (var i = 0; i < r.length; i++) P(r[i], r[++i], r[++i]);
168
+ t.__c && t.__c(n, e), e.some(function(n) {
169
+ try {
170
+ e = n.__h, n.__h = [], e.some(function(e) {
171
+ e.call(n);
172
+ });
173
+ } catch (e) {
174
+ t.__e(e, n.__v);
175
+ }
176
+ });
177
+ }
178
+ function ae(e) {
179
+ return typeof e != "object" || !e || e.__b > 0 ? e : _(e) ? e.map(ae) : v({}, e);
180
+ }
181
+ function oe(n, r, i, a, o, s, c, l, u) {
182
+ var d, f, p, h, g, v, b, x = i.props || m, S = r.props, C = r.type;
183
+ if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
184
+ for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
185
+ n = g, s[d] = null;
186
+ break;
187
+ }
188
+ }
189
+ if (n == null) {
190
+ if (C == null) return document.createTextNode(S);
191
+ n = document.createElementNS(o, C, S.is && S), l &&= (t.__m && t.__m(r, s), !1), s = null;
192
+ }
193
+ if (C == null) x === S || l && n.data == S || (n.data = S);
194
+ else {
195
+ if (s &&= e.call(n.childNodes), !l && s != null) for (x = {}, d = 0; d < n.attributes.length; d++) x[(g = n.attributes[d]).name] = g.value;
196
+ for (d in x) g = x[d], d == "dangerouslySetInnerHTML" ? p = g : d == "children" || d in S || d == "value" && "defaultValue" in S || d == "checked" && "defaultChecked" in S || ne(n, d, null, g, o);
197
+ for (d in S) g = S[d], d == "children" ? h = g : d == "dangerouslySetInnerHTML" ? f = g : d == "value" ? v = g : d == "checked" ? b = g : l && typeof g != "function" || x[d] === g || ne(n, d, g, x[d], o);
198
+ if (f) l || p && (f.__html == p.__html || f.__html == n.innerHTML) || (n.innerHTML = f.__html), r.__k = [];
199
+ else if (p && (n.innerHTML = ""), ee(r.type == "template" ? n.content : n, _(h) ? h : [h], r, i, a, C == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : i.__k && w(i, 0), l, u), s != null) for (d = s.length; d--;) y(s[d]);
200
+ l || (d = "value", C == "progress" && v == null ? n.removeAttribute("value") : v != null && (v !== n[d] || C == "progress" && !v || C == "option" && v != x[d]) && ne(n, d, v, x[d], o), d = "checked", b != null && b != n[d] && ne(n, d, b, x[d], o));
201
+ }
202
+ return n;
203
+ }
204
+ function P(e, n, r) {
205
+ try {
206
+ if (typeof e == "function") {
207
+ var i = typeof e.__u == "function";
208
+ i && e.__u(), i && n == null || (e.__u = e(n));
209
+ } else e.current = n;
210
+ } catch (e) {
211
+ t.__e(e, r);
212
+ }
213
+ }
214
+ function se(e, n, r) {
215
+ var i, a;
216
+ if (t.unmount && t.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || P(i, null, n)), (i = e.__c) != null) {
217
+ if (i.componentWillUnmount) try {
218
+ i.componentWillUnmount();
219
+ } catch (e) {
220
+ t.__e(e, n);
221
+ }
222
+ i.base = i.__P = null;
223
+ }
224
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && se(i[a], n, r || typeof e.type != "function");
225
+ r || y(e.__e), e.__c = e.__ = e.__e = void 0;
226
+ }
227
+ function ce(e, t, n) {
228
+ return this.constructor(e, n);
229
+ }
230
+ function le(n, r, i) {
231
+ var a, o, s, c;
232
+ r == document && (r = document.documentElement), t.__ && t.__(n, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], N(r, n = (!a && i || r).__k = b(S, null, [n]), o || m, m, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? e.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ie(s, n, c);
233
+ }
234
+ e = h.slice, t = { __e: function(e, t, n, r) {
235
+ for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
236
+ if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
237
+ } catch (t) {
238
+ e = t;
239
+ }
240
+ throw e;
241
+ } }, n = 0, C.prototype.setState = function(e, t) {
242
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = v({}, this.state);
243
+ typeof e == "function" && (e = e(v({}, n), this.props)), e && v(n, e), e != null && this.__v && (t && this._sb.push(t), D(this));
244
+ }, C.prototype.forceUpdate = function(e) {
245
+ this.__v && (this.__e = !0, e && this.__h.push(e), D(this));
246
+ }, C.prototype.render = S, r = [], a = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, o = function(e, t) {
247
+ return e.__v.__b - t.__v.__b;
248
+ }, O.__r = 0, s = Math.random().toString(8), c = "__d" + s, l = "__a" + s, u = /(PointerCapture)$|Capture$/i, d = 0, f = M(!1), p = M(!0);
249
+ //#endregion
250
+ //#region src/styles.css?inline
251
+ var ue = ":host{--markup-paper:#fdfcfa;--markup-ink:#1a1614;--markup-muted:#6b6661;--markup-border:#1a16141a;--markup-border-strong:#1a16142e;--markup-brand:#e35d2a;--markup-brand-hover:#c84d20;--markup-team:#2a4ac8;--markup-shadow:0 1px 2px #1a16140f, 0 8px 28px #1a16141f;--markup-overlay-tint:#1a16140a;--markup-danger:#dc2626;--markup-radius:6px;--markup-radius-sm:4px;--markup-font:\"Geist Variable\", \"Geist\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", system-ui, sans-serif;--markup-font-mono:\"Geist Mono Variable\", \"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;all:initial;font-family:var(--markup-font);color:var(--markup-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:14px;line-height:1.5}:host([data-theme=dark]){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}@media (prefers-color-scheme:dark){:host(:not([data-theme=light])){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}}.markup-shadow-root{font-family:var(--markup-font)}.markup-shadow-root *,.markup-shadow-root :before,.markup-shadow-root :after{box-sizing:border-box}:where(.markup-shadow-root button,.markup-shadow-root input,.markup-shadow-root textarea){font:inherit;color:inherit}.markup-eyebrow{font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--markup-muted);font-size:10px;font-weight:500}.markup-fab{z-index:10;background:var(--markup-ink);color:var(--markup-paper);cursor:pointer;letter-spacing:-.01em;pointer-events:auto;box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:999px;align-items:center;gap:8px;padding:9px 14px;font-size:13px;font-weight:500;transition:background .15s,box-shadow .15s,transform .15s;display:inline-flex;position:fixed;bottom:24px}.markup-fab:hover{background:var(--markup-brand);box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 0%, transparent), var(--markup-shadow)}.markup-fab:active{transform:translateY(1px)}.markup-fab.is-active{background:var(--markup-brand);box-shadow:var(--markup-shadow)}.markup-fab.is-active:hover{background:var(--markup-brand-hover)}.markup-fab .markup-fab-icon{color:var(--markup-brand);transition:color .15s}.markup-fab:hover .markup-fab-icon,.markup-fab.is-active .markup-fab-icon{color:var(--markup-paper)}.markup-fab-right{right:24px}.markup-fab-left{left:24px}.markup-fab-icon{align-items:center;display:inline-flex}.markup-fab-label{font-family:var(--markup-font)}.markup-hud-hidden-toast{z-index:10;background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;align-items:center;gap:6px;padding:8px 14px;font-size:12px;font-weight:500;animation:.22s ease-out markup-hud-hidden-in,.32s ease-in 4.6s forwards markup-hud-hidden-out;display:inline-flex;position:fixed;bottom:24px}.markup-hud-hidden-toast-right{right:24px}.markup-hud-hidden-toast-left{left:24px}.markup-kbd{background:color-mix(in srgb, var(--markup-paper) 14%, transparent);min-width:18px;height:18px;color:var(--markup-paper);font-family:var(--markup-font);border-radius:4px;justify-content:center;align-items:center;padding:0 5px;font-size:10px;font-weight:600;line-height:1;display:inline-flex}@keyframes markup-hud-hidden-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes markup-hud-hidden-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(4px)}}.markup-pins-layer{pointer-events:none;position:fixed;inset:0}.markup-pin{background:var(--markup-ink);width:28px;height:28px;color:var(--markup-brand);cursor:pointer;pointer-events:auto;box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 3px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:50% 50% 50% 4px;justify-content:center;align-items:center;margin-top:-28px;padding:0;transition:transform .15s,background .15s,color .15s;display:inline-flex;position:absolute}.markup-pin:hover,.markup-pin.is-active{background:var(--markup-brand);color:var(--markup-paper)}.markup-pin.is-anchor{anchor-name:--markup-active-anchor}.markup-pin-ghost{background:var(--markup-brand);color:var(--markup-paper);cursor:default;pointer-events:none;animation:1.2s ease-in-out infinite markup-ghost-pulse}.markup-pin-dot{background:currentColor;border-radius:50%;width:6px;height:6px;display:inline-block}.markup-pin-count{background:var(--markup-brand);min-width:16px;height:16px;color:var(--markup-paper);font-family:var(--markup-font-mono);text-align:center;box-shadow:0 0 0 2px var(--markup-paper);border-radius:999px;padding:0 4px;font-size:9px;font-weight:600;line-height:16px;position:absolute;top:-4px;left:50%;transform:translate(-50%,-50%)}@keyframes markup-ghost-pulse{0%,to{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 0 #e35d2a66}50%{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 10px #e35d2a00}}.markup-placement-overlay{background:var(--markup-overlay-tint);cursor:crosshair;pointer-events:auto;z-index:1;animation:.18s ease-out markup-overlay-in;position:fixed;inset:0}.markup-placement-cursor-help{background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;padding:10px 16px;font-size:12px;font-weight:500;animation:.22s ease-out 60ms backwards markup-help-in;position:fixed;top:24px;left:50%;transform:translate(-50%)}@keyframes markup-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes markup-help-in{0%{opacity:0;transform:translate(-50%,-8px)}to{opacity:1;transform:translate(-50%)}}.markup-popover{width:320px;max-width:calc(100vw - 24px);height:auto;max-height:calc(100dvh - 24px);inset:auto;left:var(--markup-pop-x,0);top:var(--markup-pop-y,0);background:var(--markup-paper);color:var(--markup-ink);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);box-shadow:var(--markup-shadow);pointer-events:auto;flex-direction:column;gap:0;margin:0;padding:0;animation:.16s ease-out markup-popover-in;display:flex;position:fixed;overflow:hidden}@supports (anchor-name:--x){.markup-popover{position-anchor:--markup-active-anchor;left:calc(anchor(right) + 8px);top:calc(anchor(top) - 9px);position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;position-try-order:most-block-size}}@keyframes markup-popover-in{0%{opacity:0;transform:translateY(-4px)scale(.98)}to{opacity:1;transform:translateY(0)scale(1)}}.markup-popover-header{border-bottom:1px solid var(--markup-border);justify-content:space-between;align-items:center;padding:10px 12px;display:flex}.markup-popover-header-actions{align-items:center;gap:4px;display:flex}.markup-thread-menu{display:flex;position:relative}.markup-thread-menu-list{z-index:10;background:var(--markup-paper);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);min-width:160px;box-shadow:var(--markup-shadow);padding:4px;animation:.12s ease-out markup-menu-in;position:absolute;top:calc(100% + 6px);right:0}.markup-thread-menu-item{border-radius:var(--markup-radius-sm);width:100%;color:var(--markup-ink);text-align:left;cursor:pointer;background:0 0;border:none;padding:7px 10px;font-size:13px;transition:background .1s,color .1s;display:block}.markup-thread-menu-item:hover{background:var(--markup-border)}.markup-thread-menu-item.is-danger{color:var(--markup-danger,#dc2626)}.markup-thread-menu-item.is-danger:hover{background:color-mix(in srgb, var(--markup-danger,#dc2626) 10%, transparent)}.markup-thread-menu-item:disabled{opacity:.5;cursor:default}@keyframes markup-menu-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.markup-popover-body{padding:12px}.markup-popover-byline{color:var(--markup-muted);align-items:center;gap:4px;margin:0 0 8px;font-size:12px;display:flex}.markup-popover-name{color:var(--markup-ink);font-weight:500}.markup-icon-btn{border-radius:var(--markup-radius-sm);width:24px;height:24px;color:var(--markup-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;transition:background .12s,color .12s;display:inline-flex}.markup-icon-btn:hover,.markup-icon-btn.is-open{background:var(--markup-border);color:var(--markup-ink)}.markup-comments{border-bottom:1px solid var(--markup-border);background:linear-gradient(var(--markup-paper), transparent) top / 100% 20px no-repeat local, linear-gradient(transparent, var(--markup-paper)) bottom / 100% 20px no-repeat local, radial-gradient(farthest-side at 50% 0%, #1a16141a, transparent) top / 100% 10px no-repeat scroll, radial-gradient(farthest-side at 50% 100%, #1a16141a, transparent) bottom / 100% 10px no-repeat scroll;flex-direction:column;gap:12px;max-height:280px;margin:0;padding:8px 12px 4px;list-style:none;display:flex;overflow-y:auto}.markup-comment{flex-direction:column;gap:4px;display:flex}.markup-comment-meta{align-items:center;gap:6px;font-size:11px;display:flex}.markup-comment-author{color:var(--markup-ink);font-weight:600}.markup-comment.is-team .markup-comment-author{color:var(--markup-team)}.markup-comment-badge{background:color-mix(in srgb, var(--markup-team) 12%, transparent);height:14px;color:var(--markup-team);font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;border-radius:999px;align-items:center;padding:0 5px;font-size:9px;font-weight:500;line-height:1;display:inline-flex}.markup-comment-time{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.04em;font-size:10px}.markup-comment-body{white-space:pre-wrap;word-break:break-word;margin:0;font-size:13px;line-height:1.5}.markup-comment-edited{color:var(--markup-muted);font-size:11px}.markup-thread-actions{align-items:center;gap:4px;display:flex}.markup-comment-meta .markup-reaction-picker-wrap,.markup-thread-actions{margin-left:auto}.markup-comment-meta .markup-reaction-add{width:22px;height:22px;margin-top:-4px;margin-bottom:-4px}.markup-reaction-picker-wrap>.markup-icon-btn,.markup-comment-menu>.markup-icon-btn{margin-top:-4px;margin-bottom:-4px}.markup-comment-menu.is-up .markup-thread-menu-list{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}@keyframes markup-menu-in-up{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.markup-comment{position:relative}.markup-reactions{flex-wrap:wrap;align-items:center;gap:4px;margin-top:2px;display:flex}.markup-reaction-chip{border:1px solid var(--markup-border);height:22px;color:var(--markup-ink);font:inherit;cursor:pointer;background:0 0;border-radius:999px;align-items:center;gap:4px;padding:0 7px 0 6px;font-size:11px;line-height:1;transition:background .12s,border-color .12s;display:inline-flex}.markup-reaction-chip:hover:not(:disabled){background:color-mix(in srgb, var(--markup-ink) 5%, transparent)}.markup-reaction-chip.is-mine{border-color:color-mix(in srgb, var(--markup-brand) 45%, transparent);background:color-mix(in srgb, var(--markup-brand) 10%, transparent)}.markup-reaction-chip.is-mine:hover:not(:disabled){background:color-mix(in srgb, var(--markup-brand) 16%, transparent)}.markup-reaction-chip:disabled{cursor:default;opacity:.6}.markup-reaction-emoji{font-size:13px;line-height:1}.markup-reaction-count{font-family:var(--markup-font-mono);letter-spacing:.04em;color:var(--markup-muted);font-size:10px}.markup-reaction-chip.is-mine .markup-reaction-count{color:var(--markup-brand)}.markup-reaction-picker-wrap{opacity:0;flex:none;transition:opacity .12s;display:inline-flex;position:relative}.markup-comment:hover .markup-reaction-picker-wrap,.markup-comment:focus-within .markup-reaction-picker-wrap,.markup-reaction-picker-wrap.is-open{opacity:1}.markup-reaction-add{border:1px dashed var(--markup-border-strong);width:22px;height:22px;color:var(--markup-muted);font:inherit;cursor:pointer;background:0 0;border-radius:999px;justify-content:center;align-items:center;font-size:13px;line-height:1;transition:background .12s,color .12s,border-color .12s;display:inline-flex}.markup-reaction-add:hover,.markup-reaction-add.is-open{background:color-mix(in srgb, var(--markup-ink) 5%, transparent);color:var(--markup-ink);border-style:solid}.markup-reaction-picker{z-index:1;border:1px solid var(--markup-border-strong);background:var(--markup-paper);border-radius:8px;gap:2px;padding:4px;animation:.12s markup-menu-in;display:flex;position:absolute;top:calc(100% + 6px);right:0;box-shadow:0 1px 2px #1a16140f,0 8px 28px #1a16141a}.markup-reaction-picker-wrap.is-up .markup-reaction-picker{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}.markup-reaction-picker-item{cursor:pointer;background:0 0;border:0;border-radius:6px;justify-content:center;align-items:center;width:28px;height:28px;font-size:16px;line-height:1;transition:background .12s;display:inline-flex}.markup-reaction-picker-item:hover{background:color-mix(in srgb, var(--markup-ink) 8%, transparent)}.markup-reaction-picker-item.is-mine{background:color-mix(in srgb, var(--markup-brand) 14%, transparent)}.markup-comment-edit-form{flex-direction:column;gap:6px;display:flex}.markup-comment-edit-form .markup-textarea{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;color:var(--markup-ink);resize:vertical;font:inherit;outline:none;padding:8px 10px;font-size:13px;line-height:1.5}.markup-comment-edit-form .markup-textarea:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-comment-edit-actions{justify-content:flex-end;gap:6px;display:flex}.markup-composer{flex-direction:column;display:flex;position:relative}.markup-composer-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;min-height:36px;max-height:96px;color:var(--markup-ink);resize:none;font-family:var(--markup-font);outline:none;padding:8px 10px;font-size:13px;line-height:1.5;transition:border-color .12s,box-shadow .12s,border-bottom-left-radius .15s,border-bottom-right-radius .15s}.markup-composer-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-composer-input:disabled{opacity:.6}.markup-composer-input::placeholder{color:var(--markup-muted)}.markup-composer.is-filled .markup-composer-input{border-bottom-right-radius:0;border-bottom-left-radius:0}.markup-composer-footer-wrap{grid-template-rows:0fr;transition:grid-template-rows .15s;display:grid}.markup-composer.is-filled .markup-composer-footer-wrap{grid-template-rows:1fr}.markup-composer-footer{border:1px solid var(--markup-border-strong);border-radius:0 0 var(--markup-radius-sm) var(--markup-radius-sm);opacity:0;border-top:none;justify-content:space-between;align-items:center;gap:8px;padding:2px 2px 2px 10px;transition:opacity .1s;display:flex;overflow:hidden}.markup-composer.is-filled .markup-composer-footer{opacity:1;transition-delay:60ms}.markup-composer-hint{font-family:var(--markup-font-mono);letter-spacing:.06em;color:var(--markup-muted);font-size:10px}.markup-composer-error{color:var(--markup-brand)}.markup-composer-actions{align-items:center;gap:6px;display:flex}.markup-composer-actions-empty{transition:opacity .12s;position:absolute;top:3px;right:3px}.markup-composer.is-filled .markup-composer-actions-empty{opacity:0;pointer-events:none}.markup-author-prompt{flex-direction:column;gap:10px;padding:12px;display:flex}.markup-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;height:36px;color:var(--markup-ink);outline:none;padding:0 10px;font-size:14px;transition:border-color .12s,box-shadow .12s}.markup-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-btn{border-radius:var(--markup-radius-sm);height:30px;color:var(--markup-ink);cursor:pointer;letter-spacing:-.01em;white-space:nowrap;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;gap:6px;padding:0 8px;font-size:12px;font-weight:500;transition:background .12s,border-color .12s,color .12s,opacity .12s;display:inline-flex}.markup-btn:disabled{opacity:.5;cursor:not-allowed}.markup-btn-primary{background:var(--markup-ink);color:var(--markup-paper)}.markup-btn-primary:hover:not(:disabled){background:var(--markup-brand)}.markup-btn-ghost{color:var(--markup-muted)}.markup-btn-ghost:hover:not(:disabled){background:var(--markup-border);color:var(--markup-ink)}.markup-screenshot-row{border-top:1px solid var(--markup-border);margin-top:8px;padding-top:8px}.markup-screenshot-status{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;display:flex}.markup-screenshot-toggle{cursor:pointer;color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;transition:color .12s;display:flex}.markup-screenshot-toggle:hover{color:var(--markup-ink)}.markup-screenshot-checkbox{width:12px;height:12px;accent-color:var(--markup-brand);cursor:pointer;margin:0}.markup-screenshot-thumb{border:1px solid var(--markup-border-strong);object-fit:cover;border-radius:3px;flex-shrink:0;width:auto;height:25px;margin:-5px 0 -5px auto;display:block}.markup-comment-screenshot{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);cursor:pointer;background:0 0;margin-top:8px;padding:0;transition:border-color .12s,opacity .12s;display:block;overflow:hidden}.markup-comment-screenshot:hover{border-color:var(--markup-brand);opacity:.9}.markup-comment-screenshot img{object-fit:cover;object-position:top;width:100%;height:auto;max-height:120px;display:block}.markup-lightbox{background:#1a1614e0;border:none;width:100%;max-width:100%;height:100%;max-height:100%;margin:0;padding:24px;position:fixed;inset:0}.markup-lightbox[open]{justify-content:center;align-items:center;display:flex}.markup-lightbox::backdrop{display:none}.markup-lightbox-img{border-radius:var(--markup-radius);object-fit:contain;max-width:100%;max-height:100%;box-shadow:var(--markup-shadow);animation:.16s ease-out markup-lightbox-in}.markup-lightbox-close{color:#fdfcfa;background:#1a161499;position:absolute;top:16px;right:16px}.markup-lightbox-close:hover{color:#fdfcfa;background:#1a1614d9}@keyframes markup-lightbox-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){.markup-fab,.markup-pin,.markup-icon-btn,.markup-btn,.markup-popover,.markup-pin-ghost,.markup-placement-overlay,.markup-placement-cursor-help,.markup-lightbox-img{transition:none;animation:none}}", de, F, fe, pe, me = 0, he = [], I = t, ge = I.__b, _e = I.__r, ve = I.diffed, ye = I.__c, be = I.unmount, xe = I.__;
252
+ function Se(e, t) {
253
+ I.__h && I.__h(F, e, me || t), me = 0;
254
+ var n = F.__H ||= {
255
+ __: [],
256
+ __h: []
257
+ };
258
+ return e >= n.__.length && n.__.push({}), n.__[e];
259
+ }
260
+ function L(e) {
261
+ return me = 1, Ce(je, e);
262
+ }
263
+ function Ce(e, t, n) {
264
+ var r = Se(de++, 2);
265
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : je(void 0, t), function(e) {
266
+ var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
267
+ t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
268
+ }], r.__c = F, !F.__f)) {
269
+ var i = function(e, t, n) {
270
+ if (!r.__c.__H) return !0;
271
+ var i = r.__c.__H.__.filter(function(e) {
272
+ return e.__c;
273
+ });
274
+ if (i.every(function(e) {
275
+ return !e.__N;
276
+ })) return !a || a.call(this, e, t, n);
277
+ var o = r.__c.props !== e;
278
+ return i.some(function(e) {
279
+ if (e.__N) {
280
+ var t = e.__[0];
281
+ e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0);
282
+ }
283
+ }), a && a.call(this, e, t, n) || o;
284
+ };
285
+ F.__f = !0;
286
+ var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
287
+ F.componentWillUpdate = function(e, t, n) {
288
+ if (this.__e) {
289
+ var r = a;
290
+ a = void 0, i(e, t, n), a = r;
291
+ }
292
+ o && o.call(this, e, t, n);
293
+ }, F.shouldComponentUpdate = i;
294
+ }
295
+ return r.__N || r.__;
296
+ }
297
+ function R(e, t) {
298
+ var n = Se(de++, 3);
299
+ !I.__s && Ae(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
300
+ }
301
+ function z(e) {
302
+ return me = 5, we(function() {
303
+ return { current: e };
304
+ }, []);
305
+ }
306
+ function we(e, t) {
307
+ var n = Se(de++, 7);
308
+ return Ae(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
309
+ }
310
+ function B(e, t) {
311
+ return me = 8, we(function() {
312
+ return e;
313
+ }, t);
314
+ }
315
+ function Te() {
316
+ for (var e; e = he.shift();) {
317
+ var t = e.__H;
318
+ if (e.__P && t) try {
319
+ t.__h.some(Oe), t.__h.some(ke), t.__h = [];
320
+ } catch (n) {
321
+ t.__h = [], I.__e(n, e.__v);
322
+ }
323
+ }
324
+ }
325
+ I.__b = function(e) {
326
+ F = null, ge && ge(e);
327
+ }, I.__ = function(e, t) {
328
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), xe && xe(e, t);
329
+ }, I.__r = function(e) {
330
+ _e && _e(e), de = 0;
331
+ var t = (F = e.__c).__H;
332
+ t && (fe === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
333
+ e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
334
+ })) : (t.__h.some(Oe), t.__h.some(ke), t.__h = [], de = 0)), fe = F;
335
+ }, I.diffed = function(e) {
336
+ ve && ve(e);
337
+ var t = e.__c;
338
+ t && t.__H && (t.__H.__h.length && (he.push(t) !== 1 && pe === I.requestAnimationFrame || ((pe = I.requestAnimationFrame) || De)(Te)), t.__H.__.some(function(e) {
339
+ e.u && (e.__H = e.u), e.u = void 0;
340
+ })), fe = F = null;
341
+ }, I.__c = function(e, t) {
342
+ t.some(function(e) {
343
+ try {
344
+ e.__h.some(Oe), e.__h = e.__h.filter(function(e) {
345
+ return !e.__ || ke(e);
346
+ });
347
+ } catch (n) {
348
+ t.some(function(e) {
349
+ e.__h &&= [];
350
+ }), t = [], I.__e(n, e.__v);
351
+ }
352
+ }), ye && ye(e, t);
353
+ }, I.unmount = function(e) {
354
+ be && be(e);
355
+ var t, n = e.__c;
356
+ n && n.__H && (n.__H.__.some(function(e) {
357
+ try {
358
+ Oe(e);
359
+ } catch (e) {
360
+ t = e;
361
+ }
362
+ }), n.__H = void 0, t && I.__e(t, n.__v));
363
+ };
364
+ var Ee = typeof requestAnimationFrame == "function";
365
+ function De(e) {
366
+ var t, n = function() {
367
+ clearTimeout(r), Ee && cancelAnimationFrame(t), setTimeout(e);
368
+ }, r = setTimeout(n, 35);
369
+ Ee && (t = requestAnimationFrame(n));
370
+ }
371
+ function Oe(e) {
372
+ var t = F, n = e.__c;
373
+ typeof n == "function" && (e.__c = void 0, n()), F = t;
374
+ }
375
+ function ke(e) {
376
+ var t = F;
377
+ e.__c = e.__(), F = t;
378
+ }
379
+ function Ae(e, t) {
380
+ return !e || e.length !== t.length || t.some(function(t, n) {
381
+ return t !== e[n];
382
+ });
383
+ }
384
+ function je(e, t) {
385
+ return typeof t == "function" ? t(e) : t;
386
+ }
387
+ for (var Me = "1.37.0", V = [], H = [], Ne = Uint8Array, Pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Fe = 0, Ie = Pe.length; Fe < Ie; ++Fe) V[Fe] = Pe[Fe], H[Pe.charCodeAt(Fe)] = Fe;
388
+ H[45] = 62, H[95] = 63;
389
+ function Le(e) {
390
+ var t = e.length;
391
+ if (t % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4");
392
+ var n = e.indexOf("=");
393
+ n === -1 && (n = t);
394
+ var r = n === t ? 0 : 4 - n % 4;
395
+ return [n, r];
396
+ }
397
+ function Re(e, t, n) {
398
+ return (t + n) * 3 / 4 - n;
399
+ }
400
+ function ze(e) {
401
+ var t, n = Le(e), r = n[0], i = n[1], a = new Ne(Re(e, r, i)), o = 0, s = i > 0 ? r - 4 : r, c;
402
+ for (c = 0; c < s; c += 4) t = H[e.charCodeAt(c)] << 18 | H[e.charCodeAt(c + 1)] << 12 | H[e.charCodeAt(c + 2)] << 6 | H[e.charCodeAt(c + 3)], a[o++] = t >> 16 & 255, a[o++] = t >> 8 & 255, a[o++] = t & 255;
403
+ return i === 2 && (t = H[e.charCodeAt(c)] << 2 | H[e.charCodeAt(c + 1)] >> 4, a[o++] = t & 255), i === 1 && (t = H[e.charCodeAt(c)] << 10 | H[e.charCodeAt(c + 1)] << 4 | H[e.charCodeAt(c + 2)] >> 2, a[o++] = t >> 8 & 255, a[o++] = t & 255), a;
404
+ }
405
+ function Be(e) {
406
+ return V[e >> 18 & 63] + V[e >> 12 & 63] + V[e >> 6 & 63] + V[e & 63];
407
+ }
408
+ function Ve(e, t, n) {
409
+ for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(Be(r));
410
+ return i.join("");
411
+ }
412
+ function He(e) {
413
+ for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(Ve(e, o, o + a > s ? s : o + a));
414
+ return r === 1 ? (t = e[n - 1], i.push(V[t >> 2] + V[t << 4 & 63] + "==")) : r === 2 && (t = (e[n - 2] << 8) + e[n - 1], i.push(V[t >> 10] + V[t >> 4 & 63] + V[t << 2 & 63] + "=")), i.join("");
415
+ }
416
+ //#endregion
417
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/common/index.js
418
+ function U(e) {
419
+ if (e === void 0) return {};
420
+ if (!We(e)) throw Error(`The arguments to a Convex function must be an object. Received: ${e}`);
421
+ return e;
422
+ }
423
+ function Ue(e) {
424
+ if (e === void 0) throw Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");
425
+ if (typeof e != "string") throw Error(`Invalid deployment address: found ${e}".`);
426
+ if (!(e.startsWith("http:") || e.startsWith("https:"))) throw Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${e}".`);
427
+ try {
428
+ new URL(e);
429
+ } catch {
430
+ throw Error(`Invalid deployment address: "${e}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
431
+ }
432
+ if (e.endsWith(".convex.site")) throw Error(`Invalid deployment address: "${e}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
433
+ }
434
+ function We(e) {
435
+ let t = typeof e == "object", n = Object.getPrototypeOf(e), r = n === null || n === Object.prototype || n?.constructor?.name === "Object";
436
+ return t && r;
437
+ }
438
+ //#endregion
439
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/value.js
440
+ var Ge = !0, Ke = BigInt("-9223372036854775808"), qe = BigInt("9223372036854775807"), Je = BigInt("0"), Ye = BigInt("8"), Xe = BigInt("256");
441
+ function Ze(e) {
442
+ return Number.isNaN(e) || !Number.isFinite(e) || Object.is(e, -0);
443
+ }
444
+ function Qe(e) {
445
+ e < Je && (e -= Ke + Ke);
446
+ let t = e.toString(16);
447
+ t.length % 2 == 1 && (t = "0" + t);
448
+ let n = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(8)), r = 0;
449
+ for (let i of t.match(/.{2}/g).reverse()) n.set([parseInt(i, 16)], r++), e >>= Ye;
450
+ return He(n);
451
+ }
452
+ function $e(e) {
453
+ let t = ze(e);
454
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
455
+ let n = Je, r = Je;
456
+ for (let e of t) n += BigInt(e) * Xe ** r, r++;
457
+ return n > qe && (n += Ke + Ke), n;
458
+ }
459
+ function et(e) {
460
+ if (e < Ke || qe < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
461
+ let t = /* @__PURE__ */ new ArrayBuffer(8);
462
+ return new DataView(t).setBigInt64(0, e, !0), He(new Uint8Array(t));
463
+ }
464
+ function tt(e) {
465
+ let t = ze(e);
466
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
467
+ return new DataView(t.buffer).getBigInt64(0, !0);
468
+ }
469
+ var nt = DataView.prototype.setBigInt64 ? et : Qe, rt = DataView.prototype.getBigInt64 ? tt : $e, it = 1024;
470
+ function at(e) {
471
+ if (e.length > it) throw Error(`Field name ${e} exceeds maximum field name length ${it}.`);
472
+ if (e.startsWith("$")) throw Error(`Field name ${e} starts with a '$', which is reserved.`);
473
+ for (let t = 0; t < e.length; t += 1) {
474
+ let n = e.charCodeAt(t);
475
+ if (n < 32 || n >= 127) throw Error(`Field name ${e} has invalid character '${e[t]}': Field names can only contain non-control ASCII characters`);
476
+ }
477
+ }
478
+ function ot(e) {
479
+ if (e === null || typeof e == "boolean" || typeof e == "number" || typeof e == "string") return e;
480
+ if (Array.isArray(e)) return e.map((e) => ot(e));
481
+ if (typeof e != "object") throw Error(`Unexpected type of ${e}`);
482
+ let t = Object.entries(e);
483
+ if (t.length === 1) {
484
+ let n = t[0][0];
485
+ if (n === "$bytes") {
486
+ if (typeof e.$bytes != "string") throw Error(`Malformed $bytes field on ${e}`);
487
+ return ze(e.$bytes).buffer;
488
+ }
489
+ if (n === "$integer") {
490
+ if (typeof e.$integer != "string") throw Error(`Malformed $integer field on ${e}`);
491
+ return rt(e.$integer);
492
+ }
493
+ if (n === "$float") {
494
+ if (typeof e.$float != "string") throw Error(`Malformed $float field on ${e}`);
495
+ let t = ze(e.$float);
496
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $float`);
497
+ let n = new DataView(t.buffer).getFloat64(0, Ge);
498
+ if (!Ze(n)) throw Error(`Float ${n} should be encoded as a number`);
499
+ return n;
500
+ }
501
+ if (n === "$set") throw Error("Received a Set which is no longer supported as a Convex type.");
502
+ if (n === "$map") throw Error("Received a Map which is no longer supported as a Convex type.");
503
+ }
504
+ let n = {};
505
+ for (let [t, r] of Object.entries(e)) at(t), n[t] = ot(r);
506
+ return n;
507
+ }
508
+ var st = 16384;
509
+ function ct(e) {
510
+ let t = JSON.stringify(e, (e, t) => t === void 0 ? "undefined" : typeof t == "bigint" ? `${t.toString()}n` : t);
511
+ if (t.length > st) {
512
+ let e = st - 14, n = t.codePointAt(e - 1);
513
+ return n !== void 0 && n > 65535 && --e, t.substring(0, e) + "[...truncated]";
514
+ }
515
+ return t;
516
+ }
517
+ function lt(e, t, n, r) {
518
+ if (e === void 0) {
519
+ let e = n && ` (present at path ${n} in original object ${ct(t)})`;
520
+ throw Error(`undefined is not a valid Convex value${e}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
521
+ }
522
+ if (e === null) return e;
523
+ if (typeof e == "bigint") {
524
+ if (e < Ke || qe < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
525
+ return { $integer: nt(e) };
526
+ }
527
+ if (typeof e == "number") if (Ze(e)) {
528
+ let t = /* @__PURE__ */ new ArrayBuffer(8);
529
+ return new DataView(t).setFloat64(0, e, Ge), { $float: He(new Uint8Array(t)) };
530
+ } else return e;
531
+ if (typeof e == "boolean" || typeof e == "string") return e;
532
+ if (e instanceof ArrayBuffer) return { $bytes: He(new Uint8Array(e)) };
533
+ if (Array.isArray(e)) return e.map((e, r) => lt(e, t, n + `[${r}]`, !1));
534
+ if (e instanceof Set) throw Error(ut(n, "Set", [...e], t));
535
+ if (e instanceof Map) throw Error(ut(n, "Map", [...e], t));
536
+ if (!We(e)) {
537
+ let r = e?.constructor?.name, i = r ? `${r} ` : "";
538
+ throw Error(ut(n, i, e, t));
539
+ }
540
+ let i = {}, a = Object.entries(e);
541
+ a.sort(([e, t], [n, r]) => e === n ? 0 : e < n ? -1 : 1);
542
+ for (let [e, o] of a) o === void 0 ? r && (at(e), i[e] = dt(o, t, n + `.${e}`)) : (at(e), i[e] = lt(o, t, n + `.${e}`, !1));
543
+ return i;
544
+ }
545
+ function ut(e, t, n, r) {
546
+ return e ? `${t}${ct(n)} is not a supported Convex type (present at path ${e} in original object ${ct(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.` : `${t}${ct(n)} is not a supported Convex type.`;
547
+ }
548
+ function dt(e, t, n) {
549
+ if (e === void 0) return { $undefined: null };
550
+ if (t === void 0) throw Error(`Programming error. Current value is ${ct(e)} but original value is undefined`);
551
+ return lt(e, t, n, !1);
552
+ }
553
+ function ft(e) {
554
+ return lt(e, e, "", !1);
555
+ }
556
+ //#endregion
557
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/errors.js
558
+ var pt = Object.defineProperty, mt = (e, t, n) => t in e ? pt(e, t, {
559
+ enumerable: !0,
560
+ configurable: !0,
561
+ writable: !0,
562
+ value: n
563
+ }) : e[t] = n, ht = (e, t, n) => mt(e, typeof t == "symbol" ? t : t + "", n), gt, _t, vt = Symbol.for("ConvexError"), yt = class extends (_t = Error, gt = vt, _t) {
564
+ constructor(e) {
565
+ super(typeof e == "string" ? e : ct(e)), ht(this, "name", "ConvexError"), ht(this, "data"), ht(this, gt, !0), this.data = e;
566
+ }
567
+ }, bt = Object.defineProperty, xt = (e, t, n) => t in e ? bt(e, t, {
568
+ enumerable: !0,
569
+ configurable: !0,
570
+ writable: !0,
571
+ value: n
572
+ }) : e[t] = n, St = (e, t, n) => xt(e, typeof t == "symbol" ? t : t + "", n), Ct = "color:rgb(0, 145, 255)";
573
+ function wt(e) {
574
+ switch (e) {
575
+ case "query": return "Q";
576
+ case "mutation": return "M";
577
+ case "action": return "A";
578
+ case "any": return "?";
579
+ }
580
+ }
581
+ var Tt = class {
582
+ constructor(e) {
583
+ St(this, "_onLogLineFuncs"), St(this, "_verbose"), this._onLogLineFuncs = {}, this._verbose = e.verbose;
584
+ }
585
+ addLogLineListener(e) {
586
+ let t = Math.random().toString(36).substring(2, 15);
587
+ for (let e = 0; e < 10 && this._onLogLineFuncs[t] !== void 0; e++) t = Math.random().toString(36).substring(2, 15);
588
+ return this._onLogLineFuncs[t] = e, () => {
589
+ delete this._onLogLineFuncs[t];
590
+ };
591
+ }
592
+ logVerbose(...e) {
593
+ if (this._verbose) for (let t of Object.values(this._onLogLineFuncs)) t("debug", `${(/* @__PURE__ */ new Date()).toISOString()}`, ...e);
594
+ }
595
+ log(...e) {
596
+ for (let t of Object.values(this._onLogLineFuncs)) t("info", ...e);
597
+ }
598
+ warn(...e) {
599
+ for (let t of Object.values(this._onLogLineFuncs)) t("warn", ...e);
600
+ }
601
+ error(...e) {
602
+ for (let t of Object.values(this._onLogLineFuncs)) t("error", ...e);
603
+ }
604
+ };
605
+ function Et(e) {
606
+ let t = new Tt(e);
607
+ return t.addLogLineListener((e, ...t) => {
608
+ switch (e) {
609
+ case "debug":
610
+ console.debug(...t);
611
+ break;
612
+ case "info":
613
+ console.log(...t);
614
+ break;
615
+ case "warn":
616
+ console.warn(...t);
617
+ break;
618
+ case "error":
619
+ console.error(...t);
620
+ break;
621
+ default: console.log(...t);
622
+ }
623
+ }), t;
624
+ }
625
+ function Dt(e) {
626
+ return new Tt(e);
627
+ }
628
+ function Ot(e, t, n, r, i) {
629
+ let a = wt(n);
630
+ if (typeof i == "object" && (i = `ConvexError ${JSON.stringify(i.errorData, null, 2)}`), t === "info") {
631
+ let t = i.match(/^\[.*?\] /);
632
+ if (t === null) {
633
+ e.error(`[CONVEX ${a}(${r})] Could not parse console.log`);
634
+ return;
635
+ }
636
+ let n = i.slice(1, t[0].length - 2), o = i.slice(t[0].length);
637
+ e.log(`%c[CONVEX ${a}(${r})] [${n}]`, Ct, o);
638
+ } else e.error(`[CONVEX ${a}(${r})] ${i}`);
639
+ }
640
+ function kt(e, t) {
641
+ let n = `[CONVEX FATAL ERROR] ${t}`;
642
+ return e.error(n), Error(n);
643
+ }
644
+ function At(e, t, n) {
645
+ return `[CONVEX ${wt(e)}(${t})] ${n.errorMessage}
646
+ Called by client`;
647
+ }
648
+ function jt(e, t) {
649
+ return t.data = e.errorData, t;
650
+ }
651
+ //#endregion
652
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/udf_path_utils.js
653
+ function Mt(e) {
654
+ let t = e.split(":"), n, r;
655
+ return t.length === 1 ? (n = t[0], r = "default") : (n = t.slice(0, t.length - 1).join(":"), r = t[t.length - 1]), n.endsWith(".js") && (n = n.slice(0, -3)), `${n}:${r}`;
656
+ }
657
+ function Nt(e, t) {
658
+ return JSON.stringify({
659
+ udfPath: Mt(e),
660
+ args: ft(t)
661
+ });
662
+ }
663
+ function Pt(e, t, n) {
664
+ let { initialNumItems: r, id: i } = n;
665
+ return JSON.stringify({
666
+ type: "paginated",
667
+ udfPath: Mt(e),
668
+ args: ft(t),
669
+ options: ft({
670
+ initialNumItems: r,
671
+ id: i
672
+ })
673
+ });
674
+ }
675
+ function Ft(e) {
676
+ return JSON.parse(e).type === "paginated";
677
+ }
678
+ //#endregion
679
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/local_state.js
680
+ var It = Object.defineProperty, Lt = (e, t, n) => t in e ? It(e, t, {
681
+ enumerable: !0,
682
+ configurable: !0,
683
+ writable: !0,
684
+ value: n
685
+ }) : e[t] = n, W = (e, t, n) => Lt(e, typeof t == "symbol" ? t : t + "", n), Rt = class {
686
+ constructor() {
687
+ W(this, "nextQueryId"), W(this, "querySetVersion"), W(this, "querySet"), W(this, "queryIdToToken"), W(this, "identityVersion"), W(this, "auth"), W(this, "outstandingQueriesOlderThanRestart"), W(this, "outstandingAuthOlderThanRestart"), W(this, "paused"), W(this, "pendingQuerySetModifications"), this.nextQueryId = 0, this.querySetVersion = 0, this.identityVersion = 0, this.querySet = /* @__PURE__ */ new Map(), this.queryIdToToken = /* @__PURE__ */ new Map(), this.outstandingQueriesOlderThanRestart = /* @__PURE__ */ new Set(), this.outstandingAuthOlderThanRestart = !1, this.paused = !1, this.pendingQuerySetModifications = /* @__PURE__ */ new Map();
688
+ }
689
+ hasSyncedPastLastReconnect() {
690
+ return this.outstandingQueriesOlderThanRestart.size === 0 && !this.outstandingAuthOlderThanRestart;
691
+ }
692
+ markAuthCompletion() {
693
+ this.outstandingAuthOlderThanRestart = !1;
694
+ }
695
+ subscribe(e, t, n, r) {
696
+ let i = Mt(e), a = Nt(i, t), o = this.querySet.get(a);
697
+ if (o !== void 0) return o.numSubscribers += 1, {
698
+ queryToken: a,
699
+ modification: null,
700
+ unsubscribe: () => this.removeSubscriber(a)
701
+ };
702
+ {
703
+ let e = this.nextQueryId++, o = {
704
+ id: e,
705
+ canonicalizedUdfPath: i,
706
+ args: t,
707
+ numSubscribers: 1,
708
+ journal: n,
709
+ componentPath: r
710
+ };
711
+ this.querySet.set(a, o), this.queryIdToToken.set(e, a);
712
+ let s = this.querySetVersion, c = this.querySetVersion + 1, l = {
713
+ type: "Add",
714
+ queryId: e,
715
+ udfPath: i,
716
+ args: [ft(t)],
717
+ journal: n,
718
+ componentPath: r
719
+ };
720
+ return this.paused ? this.pendingQuerySetModifications.set(e, l) : this.querySetVersion = c, {
721
+ queryToken: a,
722
+ modification: {
723
+ type: "ModifyQuerySet",
724
+ baseVersion: s,
725
+ newVersion: c,
726
+ modifications: [l]
727
+ },
728
+ unsubscribe: () => this.removeSubscriber(a)
729
+ };
730
+ }
731
+ }
732
+ transition(e) {
733
+ for (let t of e.modifications) switch (t.type) {
734
+ case "QueryUpdated":
735
+ case "QueryFailed": {
736
+ this.outstandingQueriesOlderThanRestart.delete(t.queryId);
737
+ let e = t.journal;
738
+ if (e !== void 0) {
739
+ let n = this.queryIdToToken.get(t.queryId);
740
+ n !== void 0 && (this.querySet.get(n).journal = e);
741
+ }
742
+ break;
743
+ }
744
+ case "QueryRemoved":
745
+ this.outstandingQueriesOlderThanRestart.delete(t.queryId);
746
+ break;
747
+ default: throw Error(`Invalid modification ${t.type}`);
748
+ }
749
+ }
750
+ queryId(e, t) {
751
+ let n = Nt(Mt(e), t), r = this.querySet.get(n);
752
+ return r === void 0 ? null : r.id;
753
+ }
754
+ isCurrentOrNewerAuthVersion(e) {
755
+ return e >= this.identityVersion;
756
+ }
757
+ getAuth() {
758
+ return this.auth;
759
+ }
760
+ setAuth(e) {
761
+ this.auth = {
762
+ tokenType: "User",
763
+ value: e
764
+ };
765
+ let t = this.identityVersion;
766
+ return this.paused || (this.identityVersion = t + 1), {
767
+ type: "Authenticate",
768
+ baseVersion: t,
769
+ ...this.auth
770
+ };
771
+ }
772
+ setAdminAuth(e, t) {
773
+ let n = {
774
+ tokenType: "Admin",
775
+ value: e,
776
+ impersonating: t
777
+ };
778
+ this.auth = n;
779
+ let r = this.identityVersion;
780
+ return this.paused || (this.identityVersion = r + 1), {
781
+ type: "Authenticate",
782
+ baseVersion: r,
783
+ ...n
784
+ };
785
+ }
786
+ clearAuth() {
787
+ this.auth = void 0, this.markAuthCompletion();
788
+ let e = this.identityVersion;
789
+ return this.paused || (this.identityVersion = e + 1), {
790
+ type: "Authenticate",
791
+ tokenType: "None",
792
+ baseVersion: e
793
+ };
794
+ }
795
+ hasAuth() {
796
+ return !!this.auth;
797
+ }
798
+ isNewAuth(e) {
799
+ return this.auth?.value !== e;
800
+ }
801
+ queryPath(e) {
802
+ let t = this.queryIdToToken.get(e);
803
+ return t ? this.querySet.get(t).canonicalizedUdfPath : null;
804
+ }
805
+ queryArgs(e) {
806
+ let t = this.queryIdToToken.get(e);
807
+ return t ? this.querySet.get(t).args : null;
808
+ }
809
+ queryToken(e) {
810
+ return this.queryIdToToken.get(e) ?? null;
811
+ }
812
+ queryJournal(e) {
813
+ return this.querySet.get(e)?.journal;
814
+ }
815
+ restart() {
816
+ this.unpause(), this.outstandingQueriesOlderThanRestart.clear();
817
+ let e = [];
818
+ for (let t of this.querySet.values()) {
819
+ let n = {
820
+ type: "Add",
821
+ queryId: t.id,
822
+ udfPath: t.canonicalizedUdfPath,
823
+ args: [ft(t.args)],
824
+ journal: t.journal,
825
+ componentPath: t.componentPath
826
+ };
827
+ e.push(n), this.outstandingQueriesOlderThanRestart.add(t.id);
828
+ }
829
+ this.querySetVersion = 1;
830
+ let t = {
831
+ type: "ModifyQuerySet",
832
+ baseVersion: 0,
833
+ newVersion: 1,
834
+ modifications: e
835
+ };
836
+ if (!this.auth) return this.identityVersion = 0, [t, void 0];
837
+ this.outstandingAuthOlderThanRestart = !0;
838
+ let n = {
839
+ type: "Authenticate",
840
+ baseVersion: 0,
841
+ ...this.auth
842
+ };
843
+ return this.identityVersion = 1, [t, n];
844
+ }
845
+ pause() {
846
+ this.paused = !0;
847
+ }
848
+ resume() {
849
+ let e = this.pendingQuerySetModifications.size > 0 ? {
850
+ type: "ModifyQuerySet",
851
+ baseVersion: this.querySetVersion,
852
+ newVersion: ++this.querySetVersion,
853
+ modifications: Array.from(this.pendingQuerySetModifications.values())
854
+ } : void 0, t = this.auth === void 0 ? void 0 : {
855
+ type: "Authenticate",
856
+ baseVersion: this.identityVersion++,
857
+ ...this.auth
858
+ };
859
+ return this.unpause(), [e, t];
860
+ }
861
+ unpause() {
862
+ this.paused = !1, this.pendingQuerySetModifications.clear();
863
+ }
864
+ removeSubscriber(e) {
865
+ let t = this.querySet.get(e);
866
+ if (t.numSubscribers > 1) return --t.numSubscribers, null;
867
+ {
868
+ this.querySet.delete(e), this.queryIdToToken.delete(t.id), this.outstandingQueriesOlderThanRestart.delete(t.id);
869
+ let n = this.querySetVersion, r = this.querySetVersion + 1, i = {
870
+ type: "Remove",
871
+ queryId: t.id
872
+ };
873
+ return this.paused ? this.pendingQuerySetModifications.has(t.id) ? this.pendingQuerySetModifications.delete(t.id) : this.pendingQuerySetModifications.set(t.id, i) : this.querySetVersion = r, {
874
+ type: "ModifyQuerySet",
875
+ baseVersion: n,
876
+ newVersion: r,
877
+ modifications: [i]
878
+ };
879
+ }
880
+ }
881
+ }, zt = Object.defineProperty, Bt = (e, t, n) => t in e ? zt(e, t, {
882
+ enumerable: !0,
883
+ configurable: !0,
884
+ writable: !0,
885
+ value: n
886
+ }) : e[t] = n, Vt = (e, t, n) => Bt(e, typeof t == "symbol" ? t : t + "", n), Ht = class {
887
+ constructor(e, t) {
888
+ this.logger = e, this.markConnectionStateDirty = t, Vt(this, "inflightRequests"), Vt(this, "requestsOlderThanRestart"), Vt(this, "inflightMutationsCount", 0), Vt(this, "inflightActionsCount", 0), this.inflightRequests = /* @__PURE__ */ new Map(), this.requestsOlderThanRestart = /* @__PURE__ */ new Set();
889
+ }
890
+ request(e, t) {
891
+ let n = new Promise((n) => {
892
+ let r = t ? "Requested" : "NotSent";
893
+ this.inflightRequests.set(e.requestId, {
894
+ message: e,
895
+ status: {
896
+ status: r,
897
+ requestedAt: /* @__PURE__ */ new Date(),
898
+ onResult: n
899
+ }
900
+ }), e.type === "Mutation" ? this.inflightMutationsCount++ : e.type === "Action" && this.inflightActionsCount++;
901
+ });
902
+ return this.markConnectionStateDirty(), n;
903
+ }
904
+ onResponse(e) {
905
+ let t = this.inflightRequests.get(e.requestId);
906
+ if (t === void 0 || t.status.status === "Completed") return null;
907
+ let n = t.message.type === "Mutation" ? "mutation" : "action", r = t.message.udfPath;
908
+ for (let t of e.logLines) Ot(this.logger, "info", n, r, t);
909
+ let i = t.status, a, o;
910
+ if (e.success) a = {
911
+ success: !0,
912
+ logLines: e.logLines,
913
+ value: ot(e.result)
914
+ }, o = () => i.onResult(a);
915
+ else {
916
+ let t = e.result, { errorData: s } = e;
917
+ Ot(this.logger, "error", n, r, t), a = {
918
+ success: !1,
919
+ errorMessage: t,
920
+ errorData: s === void 0 ? void 0 : ot(s),
921
+ logLines: e.logLines
922
+ }, o = () => i.onResult(a);
923
+ }
924
+ return e.type === "ActionResponse" || !e.success ? (o(), this.inflightRequests.delete(e.requestId), this.requestsOlderThanRestart.delete(e.requestId), t.message.type === "Action" ? this.inflightActionsCount-- : t.message.type === "Mutation" && this.inflightMutationsCount--, this.markConnectionStateDirty(), {
925
+ requestId: e.requestId,
926
+ result: a
927
+ }) : (t.status = {
928
+ status: "Completed",
929
+ result: a,
930
+ ts: e.ts,
931
+ onResolve: o
932
+ }, null);
933
+ }
934
+ removeCompleted(e) {
935
+ let t = /* @__PURE__ */ new Map();
936
+ for (let [n, r] of this.inflightRequests.entries()) {
937
+ let i = r.status;
938
+ i.status === "Completed" && i.ts.lessThanOrEqual(e) && (i.onResolve(), t.set(n, i.result), r.message.type === "Mutation" ? this.inflightMutationsCount-- : r.message.type === "Action" && this.inflightActionsCount--, this.inflightRequests.delete(n), this.requestsOlderThanRestart.delete(n));
939
+ }
940
+ return t.size > 0 && this.markConnectionStateDirty(), t;
941
+ }
942
+ restart() {
943
+ this.requestsOlderThanRestart = new Set(this.inflightRequests.keys());
944
+ let e = [];
945
+ for (let [t, n] of this.inflightRequests) {
946
+ if (n.status.status === "NotSent") {
947
+ n.status.status = "Requested", e.push(n.message);
948
+ continue;
949
+ }
950
+ if (n.message.type === "Mutation") e.push(n.message);
951
+ else if (n.message.type === "Action") {
952
+ if (this.inflightRequests.delete(t), this.requestsOlderThanRestart.delete(t), this.inflightActionsCount--, n.status.status === "Completed") throw Error("Action should never be in 'Completed' state");
953
+ n.status.onResult({
954
+ success: !1,
955
+ errorMessage: "Connection lost while action was in flight",
956
+ logLines: []
957
+ });
958
+ }
959
+ }
960
+ return this.markConnectionStateDirty(), e;
961
+ }
962
+ resume() {
963
+ let e = [];
964
+ for (let [, t] of this.inflightRequests) if (t.status.status === "NotSent") {
965
+ t.status.status = "Requested", e.push(t.message);
966
+ continue;
967
+ }
968
+ return e;
969
+ }
970
+ hasIncompleteRequests() {
971
+ for (let e of this.inflightRequests.values()) if (e.status.status === "Requested") return !0;
972
+ return !1;
973
+ }
974
+ hasInflightRequests() {
975
+ return this.inflightRequests.size > 0;
976
+ }
977
+ hasSyncedPastLastReconnect() {
978
+ return this.requestsOlderThanRestart.size === 0;
979
+ }
980
+ timeOfOldestInflightRequest() {
981
+ if (this.inflightRequests.size === 0) return null;
982
+ let e = Date.now();
983
+ for (let t of this.inflightRequests.values()) t.status.status !== "Completed" && t.status.requestedAt.getTime() < e && (e = t.status.requestedAt.getTime());
984
+ return new Date(e);
985
+ }
986
+ inflightMutations() {
987
+ return this.inflightMutationsCount;
988
+ }
989
+ inflightActions() {
990
+ return this.inflightActionsCount;
991
+ }
992
+ }, Ut = Symbol.for("functionName"), Wt = Symbol.for("toReferencePath");
993
+ function Gt(e) {
994
+ return e[Wt] ?? null;
995
+ }
996
+ function Kt(e) {
997
+ return e.startsWith("function://");
998
+ }
999
+ function qt(e) {
1000
+ let t;
1001
+ if (typeof e == "string") t = Kt(e) ? { functionHandle: e } : { name: e };
1002
+ else if (e[Ut]) t = { name: e[Ut] };
1003
+ else {
1004
+ let n = Gt(e);
1005
+ if (!n) throw Error(`${e} is not a functionReference`);
1006
+ t = { reference: n };
1007
+ }
1008
+ return t;
1009
+ }
1010
+ //#endregion
1011
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/server/api.js
1012
+ function G(e) {
1013
+ let t = qt(e);
1014
+ if (t.name === void 0) throw t.functionHandle === void 0 ? t.reference === void 0 ? Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(t)}`) : Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${t.reference}`) : Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${t.functionHandle}`);
1015
+ if (typeof e == "string") return e;
1016
+ let n = e[Ut];
1017
+ if (!n) throw Error(`${e} is not a functionReference`);
1018
+ return n;
1019
+ }
1020
+ function Jt(e) {
1021
+ return { [Ut]: e };
1022
+ }
1023
+ function Yt(e = []) {
1024
+ return new Proxy({}, { get(t, n) {
1025
+ if (typeof n == "string") return Yt([...e, n]);
1026
+ if (n === Ut) {
1027
+ if (e.length < 2) {
1028
+ let t = ["api", ...e].join(".");
1029
+ throw Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${t}\``);
1030
+ }
1031
+ let t = e.slice(0, -1).join("/"), n = e[e.length - 1];
1032
+ return n === "default" ? t : t + ":" + n;
1033
+ } else if (n === Symbol.toStringTag) return "FunctionReference";
1034
+ else return;
1035
+ } });
1036
+ }
1037
+ Yt();
1038
+ //#endregion
1039
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/optimistic_updates_impl.js
1040
+ var Xt = Object.defineProperty, Zt = (e, t, n) => t in e ? Xt(e, t, {
1041
+ enumerable: !0,
1042
+ configurable: !0,
1043
+ writable: !0,
1044
+ value: n
1045
+ }) : e[t] = n, Qt = (e, t, n) => Zt(e, typeof t == "symbol" ? t : t + "", n), $t = class e {
1046
+ constructor(e) {
1047
+ Qt(this, "queryResults"), Qt(this, "modifiedQueries"), this.queryResults = e, this.modifiedQueries = [];
1048
+ }
1049
+ getQuery(t, ...n) {
1050
+ let r = U(n[0]), i = G(t), a = this.queryResults.get(Nt(i, r));
1051
+ if (a !== void 0) return e.queryValue(a.result);
1052
+ }
1053
+ getAllQueries(t) {
1054
+ let n = [], r = G(t);
1055
+ for (let t of this.queryResults.values()) t.udfPath === Mt(r) && n.push({
1056
+ args: t.args,
1057
+ value: e.queryValue(t.result)
1058
+ });
1059
+ return n;
1060
+ }
1061
+ setQuery(e, t, n) {
1062
+ let r = U(t), i = G(e), a = Nt(i, r), o;
1063
+ o = n === void 0 ? void 0 : {
1064
+ success: !0,
1065
+ value: n,
1066
+ logLines: []
1067
+ };
1068
+ let s = {
1069
+ udfPath: i,
1070
+ args: r,
1071
+ result: o
1072
+ };
1073
+ this.queryResults.set(a, s), this.modifiedQueries.push(a);
1074
+ }
1075
+ static queryValue(e) {
1076
+ if (e !== void 0 && e.success) return e.value;
1077
+ }
1078
+ }, en = class {
1079
+ constructor() {
1080
+ Qt(this, "queryResults"), Qt(this, "optimisticUpdates"), this.queryResults = /* @__PURE__ */ new Map(), this.optimisticUpdates = [];
1081
+ }
1082
+ ingestQueryResultsFromServer(e, t) {
1083
+ this.optimisticUpdates = this.optimisticUpdates.filter((e) => !t.has(e.mutationId));
1084
+ let n = this.queryResults;
1085
+ this.queryResults = new Map(e);
1086
+ let r = new $t(this.queryResults);
1087
+ for (let e of this.optimisticUpdates) e.update(r);
1088
+ let i = [];
1089
+ for (let [e, t] of this.queryResults) {
1090
+ let r = n.get(e);
1091
+ (r === void 0 || r.result !== t.result) && i.push(e);
1092
+ }
1093
+ return i;
1094
+ }
1095
+ applyOptimisticUpdate(e, t) {
1096
+ this.optimisticUpdates.push({
1097
+ update: e,
1098
+ mutationId: t
1099
+ });
1100
+ let n = new $t(this.queryResults);
1101
+ return e(n), n.modifiedQueries;
1102
+ }
1103
+ rawQueryResult(e) {
1104
+ let t = this.queryResults.get(e);
1105
+ if (t !== void 0) return t.result;
1106
+ }
1107
+ queryResult(e) {
1108
+ let t = this.queryResults.get(e);
1109
+ if (t === void 0) return;
1110
+ let n = t.result;
1111
+ if (n !== void 0) {
1112
+ if (n.success) return n.value;
1113
+ throw n.errorData === void 0 ? Error(At("query", t.udfPath, n)) : jt(n, new yt(At("query", t.udfPath, n)));
1114
+ }
1115
+ }
1116
+ hasQueryResult(e) {
1117
+ return this.queryResults.get(e) !== void 0;
1118
+ }
1119
+ queryLogs(e) {
1120
+ return this.queryResults.get(e)?.result?.logLines;
1121
+ }
1122
+ }, tn = Object.defineProperty, nn = (e, t, n) => t in e ? tn(e, t, {
1123
+ enumerable: !0,
1124
+ configurable: !0,
1125
+ writable: !0,
1126
+ value: n
1127
+ }) : e[t] = n, rn = (e, t, n) => nn(e, typeof t == "symbol" ? t : t + "", n), an = class e {
1128
+ constructor(e, t) {
1129
+ rn(this, "low"), rn(this, "high"), rn(this, "__isUnsignedLong__"), this.low = e | 0, this.high = t | 0, this.__isUnsignedLong__ = !0;
1130
+ }
1131
+ static isLong(e) {
1132
+ return (e && e.__isUnsignedLong__) === !0;
1133
+ }
1134
+ static fromBytesLE(t) {
1135
+ return new e(t[0] | t[1] << 8 | t[2] << 16 | t[3] << 24, t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24);
1136
+ }
1137
+ toBytesLE() {
1138
+ let e = this.high, t = this.low;
1139
+ return [
1140
+ t & 255,
1141
+ t >>> 8 & 255,
1142
+ t >>> 16 & 255,
1143
+ t >>> 24,
1144
+ e & 255,
1145
+ e >>> 8 & 255,
1146
+ e >>> 16 & 255,
1147
+ e >>> 24
1148
+ ];
1149
+ }
1150
+ static fromNumber(t) {
1151
+ return isNaN(t) || t < 0 ? on : t >= ln ? un : new e(t % cn | 0, t / cn | 0);
1152
+ }
1153
+ toString() {
1154
+ return (BigInt(this.high) * BigInt(cn) + BigInt(this.low)).toString();
1155
+ }
1156
+ equals(t) {
1157
+ return e.isLong(t) || (t = e.fromValue(t)), this.high >>> 31 == 1 && t.high >>> 31 == 1 ? !1 : this.high === t.high && this.low === t.low;
1158
+ }
1159
+ notEquals(e) {
1160
+ return !this.equals(e);
1161
+ }
1162
+ comp(t) {
1163
+ return e.isLong(t) || (t = e.fromValue(t)), this.equals(t) ? 0 : t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1;
1164
+ }
1165
+ lessThanOrEqual(e) {
1166
+ return this.comp(e) <= 0;
1167
+ }
1168
+ static fromValue(t) {
1169
+ return typeof t == "number" ? e.fromNumber(t) : new e(t.low, t.high);
1170
+ }
1171
+ }, on = new an(0, 0), sn = 65536, cn = sn * sn, ln = cn * cn, un = new an(-1, -1), dn = Object.defineProperty, fn = (e, t, n) => t in e ? dn(e, t, {
1172
+ enumerable: !0,
1173
+ configurable: !0,
1174
+ writable: !0,
1175
+ value: n
1176
+ }) : e[t] = n, pn = (e, t, n) => fn(e, typeof t == "symbol" ? t : t + "", n), mn = class {
1177
+ constructor(e, t) {
1178
+ pn(this, "version"), pn(this, "remoteQuerySet"), pn(this, "queryPath"), pn(this, "logger"), this.version = {
1179
+ querySet: 0,
1180
+ ts: an.fromNumber(0),
1181
+ identity: 0
1182
+ }, this.remoteQuerySet = /* @__PURE__ */ new Map(), this.queryPath = e, this.logger = t;
1183
+ }
1184
+ transition(e) {
1185
+ let t = e.startVersion;
1186
+ if (this.version.querySet !== t.querySet || this.version.ts.notEquals(t.ts) || this.version.identity !== t.identity) throw Error(`Invalid start version: ${t.ts.toString()}:${t.querySet}:${t.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);
1187
+ for (let t of e.modifications) switch (t.type) {
1188
+ case "QueryUpdated": {
1189
+ let e = this.queryPath(t.queryId);
1190
+ if (e) for (let n of t.logLines) Ot(this.logger, "info", "query", e, n);
1191
+ let n = ot(t.value ?? null);
1192
+ this.remoteQuerySet.set(t.queryId, {
1193
+ success: !0,
1194
+ value: n,
1195
+ logLines: t.logLines
1196
+ });
1197
+ break;
1198
+ }
1199
+ case "QueryFailed": {
1200
+ let e = this.queryPath(t.queryId);
1201
+ if (e) for (let n of t.logLines) Ot(this.logger, "info", "query", e, n);
1202
+ let { errorData: n } = t;
1203
+ this.remoteQuerySet.set(t.queryId, {
1204
+ success: !1,
1205
+ errorMessage: t.errorMessage,
1206
+ errorData: n === void 0 ? void 0 : ot(n),
1207
+ logLines: t.logLines
1208
+ });
1209
+ break;
1210
+ }
1211
+ case "QueryRemoved":
1212
+ this.remoteQuerySet.delete(t.queryId);
1213
+ break;
1214
+ default: throw Error(`Invalid modification ${t.type}`);
1215
+ }
1216
+ this.version = e.endVersion;
1217
+ }
1218
+ remoteQueryResults() {
1219
+ return this.remoteQuerySet;
1220
+ }
1221
+ timestamp() {
1222
+ return this.version.ts;
1223
+ }
1224
+ };
1225
+ //#endregion
1226
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/protocol.js
1227
+ function hn(e) {
1228
+ let t = ze(e);
1229
+ return an.fromBytesLE(Array.from(t));
1230
+ }
1231
+ function gn(e) {
1232
+ return He(new Uint8Array(e.toBytesLE()));
1233
+ }
1234
+ function _n(e) {
1235
+ switch (e.type) {
1236
+ case "FatalError":
1237
+ case "AuthError":
1238
+ case "ActionResponse":
1239
+ case "TransitionChunk":
1240
+ case "Ping": return { ...e };
1241
+ case "MutationResponse": return e.success ? {
1242
+ ...e,
1243
+ ts: hn(e.ts)
1244
+ } : { ...e };
1245
+ case "Transition": return {
1246
+ ...e,
1247
+ startVersion: {
1248
+ ...e.startVersion,
1249
+ ts: hn(e.startVersion.ts)
1250
+ },
1251
+ endVersion: {
1252
+ ...e.endVersion,
1253
+ ts: hn(e.endVersion.ts)
1254
+ }
1255
+ };
1256
+ default:
1257
+ }
1258
+ }
1259
+ function vn(e) {
1260
+ switch (e.type) {
1261
+ case "Authenticate":
1262
+ case "ModifyQuerySet":
1263
+ case "Mutation":
1264
+ case "Action":
1265
+ case "Event": return { ...e };
1266
+ case "Connect": return e.maxObservedTimestamp === void 0 ? {
1267
+ ...e,
1268
+ maxObservedTimestamp: void 0
1269
+ } : {
1270
+ ...e,
1271
+ maxObservedTimestamp: gn(e.maxObservedTimestamp)
1272
+ };
1273
+ default:
1274
+ }
1275
+ }
1276
+ //#endregion
1277
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/web_socket_manager.js
1278
+ var yn = Object.defineProperty, bn = (e, t, n) => t in e ? yn(e, t, {
1279
+ enumerable: !0,
1280
+ configurable: !0,
1281
+ writable: !0,
1282
+ value: n
1283
+ }) : e[t] = n, K = (e, t, n) => bn(e, typeof t == "symbol" ? t : t + "", n), xn = 1e3, Sn = 1001, Cn = 1005, wn = 4040, Tn;
1284
+ function En() {
1285
+ return Tn === void 0 && (Tn = Date.now()), typeof performance > "u" || !performance.now ? Date.now() : Math.round(Tn + performance.now());
1286
+ }
1287
+ function Dn() {
1288
+ return `t=${Math.round((En() - Tn) / 100) / 10}s`;
1289
+ }
1290
+ var On = {
1291
+ InternalServerError: { timeout: 1e3 },
1292
+ SubscriptionsWorkerFullError: { timeout: 3e3 },
1293
+ TooManyConcurrentRequests: { timeout: 3e3 },
1294
+ CommitterFullError: { timeout: 3e3 },
1295
+ AwsTooManyRequestsException: { timeout: 3e3 },
1296
+ ExecuteFullError: { timeout: 3e3 },
1297
+ SystemTimeoutError: { timeout: 3e3 },
1298
+ ExpiredInQueue: { timeout: 3e3 },
1299
+ VectorIndexesUnavailable: { timeout: 1e3 },
1300
+ SearchIndexesUnavailable: { timeout: 1e3 },
1301
+ TableSummariesUnavailable: { timeout: 1e3 },
1302
+ VectorIndexTooLarge: { timeout: 3e3 },
1303
+ SearchIndexTooLarge: { timeout: 3e3 },
1304
+ TooManyWritesInTimePeriod: { timeout: 3e3 }
1305
+ };
1306
+ function kn(e) {
1307
+ if (e === void 0) return "Unknown";
1308
+ for (let t of Object.keys(On)) if (e.startsWith(t)) return t;
1309
+ return "Unknown";
1310
+ }
1311
+ var An = class {
1312
+ constructor(e, t, n, r, i, a) {
1313
+ this.markConnectionStateDirty = i, this.debug = a, K(this, "socket"), K(this, "connectionCount"), K(this, "_hasEverConnected", !1), K(this, "lastCloseReason"), K(this, "transitionChunkBuffer", null), K(this, "defaultInitialBackoff"), K(this, "maxBackoff"), K(this, "retries"), K(this, "serverInactivityThreshold"), K(this, "reconnectDueToServerInactivityTimeout"), K(this, "scheduledReconnect", null), K(this, "networkOnlineHandler", null), K(this, "pendingNetworkRecoveryInfo", null), K(this, "uri"), K(this, "onOpen"), K(this, "onResume"), K(this, "onMessage"), K(this, "webSocketConstructor"), K(this, "logger"), K(this, "onServerDisconnectError"), this.webSocketConstructor = n, this.socket = { state: "disconnected" }, this.connectionCount = 0, this.lastCloseReason = "InitialConnect", this.defaultInitialBackoff = 1e3, this.maxBackoff = 16e3, this.retries = 0, this.serverInactivityThreshold = 6e4, this.reconnectDueToServerInactivityTimeout = null, this.uri = e, this.onOpen = t.onOpen, this.onResume = t.onResume, this.onMessage = t.onMessage, this.onServerDisconnectError = t.onServerDisconnectError, this.logger = r, this.setupNetworkListener(), this.connect();
1314
+ }
1315
+ setSocketState(e) {
1316
+ this.socket = e, this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}`), this.markConnectionStateDirty();
1317
+ }
1318
+ setupNetworkListener() {
1319
+ typeof window > "u" || typeof window.addEventListener != "function" || this.networkOnlineHandler === null && (this.networkOnlineHandler = () => {
1320
+ this._logVerbose("network online event detected"), this.tryReconnectImmediately();
1321
+ }, window.addEventListener("online", this.networkOnlineHandler), this._logVerbose("network online event listener registered"));
1322
+ }
1323
+ cleanupNetworkListener() {
1324
+ this.networkOnlineHandler && typeof window < "u" && typeof window.removeEventListener == "function" && (window.removeEventListener("online", this.networkOnlineHandler), this.networkOnlineHandler = null, this._logVerbose("network online event listener removed"));
1325
+ }
1326
+ assembleTransition(e) {
1327
+ if (e.partNumber < 0 || e.partNumber >= e.totalParts || e.totalParts === 0 || this.transitionChunkBuffer && (this.transitionChunkBuffer.totalParts !== e.totalParts || this.transitionChunkBuffer.transitionId !== e.transitionId)) throw this.transitionChunkBuffer = null, Error("Invalid TransitionChunk");
1328
+ if (this.transitionChunkBuffer === null && (this.transitionChunkBuffer = {
1329
+ chunks: [],
1330
+ totalParts: e.totalParts,
1331
+ transitionId: e.transitionId
1332
+ }), e.partNumber !== this.transitionChunkBuffer.chunks.length) {
1333
+ let t = this.transitionChunkBuffer.chunks.length;
1334
+ throw this.transitionChunkBuffer = null, Error(`TransitionChunk received out of order: expected part ${t}, got ${e.partNumber}`);
1335
+ }
1336
+ if (this.transitionChunkBuffer.chunks.push(e.chunk), this.transitionChunkBuffer.chunks.length === e.totalParts) {
1337
+ let e = this.transitionChunkBuffer.chunks.join("");
1338
+ this.transitionChunkBuffer = null;
1339
+ let t = _n(JSON.parse(e));
1340
+ if (t.type !== "Transition") throw Error(`Expected Transition, got ${t.type} after assembling chunks`);
1341
+ return t;
1342
+ }
1343
+ return null;
1344
+ }
1345
+ connect() {
1346
+ if (this.socket.state === "terminated") return;
1347
+ if (this.socket.state !== "disconnected" && this.socket.state !== "stopped") throw Error("Didn't start connection from disconnected state: " + this.socket.state);
1348
+ let e = new this.webSocketConstructor(this.uri);
1349
+ this._logVerbose("constructed WebSocket"), this.setSocketState({
1350
+ state: "connecting",
1351
+ ws: e,
1352
+ paused: "no"
1353
+ }), this.resetServerInactivityTimeout(), e.onopen = () => {
1354
+ if (this.logger.logVerbose("begin ws.onopen"), this.socket.state !== "connecting") throw Error("onopen called with socket not in connecting state");
1355
+ if (this.setSocketState({
1356
+ state: "ready",
1357
+ ws: e,
1358
+ paused: this.socket.paused === "yes" ? "uninitialized" : "no"
1359
+ }), this.resetServerInactivityTimeout(), this.socket.paused === "no" && (this._hasEverConnected = !0, this.onOpen({
1360
+ connectionCount: this.connectionCount,
1361
+ lastCloseReason: this.lastCloseReason,
1362
+ clientTs: En()
1363
+ })), this.lastCloseReason !== "InitialConnect" && (this.lastCloseReason ? this.logger.log("WebSocket reconnected at", Dn(), "after disconnect due to", this.lastCloseReason) : this.logger.log("WebSocket reconnected at", Dn())), this.connectionCount += 1, this.lastCloseReason = null, this.pendingNetworkRecoveryInfo !== null) {
1364
+ let { timeSavedMs: e } = this.pendingNetworkRecoveryInfo;
1365
+ this.pendingNetworkRecoveryInfo = null, this.sendMessage({
1366
+ type: "Event",
1367
+ eventType: "NetworkRecoveryReconnect",
1368
+ event: { timeSavedMs: e }
1369
+ }), this.logger.log(`Network recovery reconnect saved ~${Math.round(e / 1e3)}s of waiting`);
1370
+ }
1371
+ }, e.onerror = (e) => {
1372
+ this.transitionChunkBuffer = null;
1373
+ let t = e.message;
1374
+ t && this.logger.log(`WebSocket error message: ${t}`);
1375
+ }, e.onmessage = (e) => {
1376
+ this.resetServerInactivityTimeout();
1377
+ let t = e.data.length, n = _n(JSON.parse(e.data));
1378
+ if (this._logVerbose(`received ws message with type ${n.type}`), n.type !== "Ping") {
1379
+ if (n.type === "TransitionChunk") {
1380
+ let e = this.assembleTransition(n);
1381
+ if (!e) return;
1382
+ n = e, this._logVerbose(`assembled full ws message of type ${n.type}`);
1383
+ }
1384
+ this.transitionChunkBuffer !== null && (this.transitionChunkBuffer = null, this.logger.log(`Received unexpected ${n.type} while buffering TransitionChunks`)), n.type === "Transition" && this.reportLargeTransition({
1385
+ messageLength: t,
1386
+ transition: n
1387
+ }), this.onMessage(n).hasSyncedPastLastReconnect && (this.retries = 0, this.markConnectionStateDirty());
1388
+ }
1389
+ }, e.onclose = (e) => {
1390
+ if (this._logVerbose("begin ws.onclose"), this.transitionChunkBuffer = null, this.lastCloseReason === null && (this.lastCloseReason = e.reason || `closed with code ${e.code}`), e.code !== xn && e.code !== Sn && e.code !== Cn && e.code !== wn) {
1391
+ let t = `WebSocket closed with code ${e.code}`;
1392
+ e.reason && (t += `: ${e.reason}`), this.logger.log(t), this.onServerDisconnectError && e.reason && this.onServerDisconnectError(t);
1393
+ }
1394
+ let t = kn(e.reason);
1395
+ this.scheduleReconnect(t);
1396
+ };
1397
+ }
1398
+ socketState() {
1399
+ return this.socket.state;
1400
+ }
1401
+ sendMessage(e) {
1402
+ let t = {
1403
+ type: e.type,
1404
+ ...e.type === "Authenticate" && e.tokenType === "User" ? { value: `...${e.value.slice(-7)}` } : {}
1405
+ };
1406
+ if (this.socket.state === "ready" && this.socket.paused === "no") {
1407
+ let n = vn(e), r = JSON.stringify(n), i = !1;
1408
+ try {
1409
+ this.socket.ws.send(r), i = !0;
1410
+ } catch (e) {
1411
+ this.logger.log(`Failed to send message on WebSocket, reconnecting: ${e}`), this.closeAndReconnect("FailedToSendMessage");
1412
+ }
1413
+ return this._logVerbose(`${i ? "sent" : "failed to send"} message with type ${e.type}: ${JSON.stringify(t)}`), !0;
1414
+ }
1415
+ return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}): ${JSON.stringify(t)}`), !1;
1416
+ }
1417
+ resetServerInactivityTimeout() {
1418
+ this.socket.state !== "terminated" && (this.reconnectDueToServerInactivityTimeout !== null && (clearTimeout(this.reconnectDueToServerInactivityTimeout), this.reconnectDueToServerInactivityTimeout = null), this.reconnectDueToServerInactivityTimeout = setTimeout(() => {
1419
+ this.closeAndReconnect("InactiveServer");
1420
+ }, this.serverInactivityThreshold));
1421
+ }
1422
+ scheduleReconnect(e) {
1423
+ this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.socket = { state: "disconnected" };
1424
+ let t = this.nextBackoff(e);
1425
+ this.markConnectionStateDirty(), this.logger.log(`Attempting reconnect in ${Math.round(t)}ms`);
1426
+ let n = En(), r = setTimeout(() => {
1427
+ this.scheduledReconnect?.timeout === r && (this.scheduledReconnect = null, this.connect());
1428
+ }, t);
1429
+ this.scheduledReconnect = {
1430
+ timeout: r,
1431
+ scheduledAt: n,
1432
+ backoffMs: t
1433
+ };
1434
+ }
1435
+ closeAndReconnect(e) {
1436
+ switch (this._logVerbose(`begin closeAndReconnect with reason ${e}`), this.socket.state) {
1437
+ case "disconnected":
1438
+ case "terminated":
1439
+ case "stopped": return;
1440
+ case "connecting":
1441
+ case "ready":
1442
+ this.lastCloseReason = e, this.close(), this.scheduleReconnect("client");
1443
+ return;
1444
+ default: this.socket;
1445
+ }
1446
+ }
1447
+ close() {
1448
+ switch (this.transitionChunkBuffer = null, this.socket.state) {
1449
+ case "disconnected":
1450
+ case "terminated":
1451
+ case "stopped": return Promise.resolve();
1452
+ case "connecting": {
1453
+ let e = this.socket.ws;
1454
+ return e.onmessage = (e) => {
1455
+ this._logVerbose("Ignoring message received after close");
1456
+ }, new Promise((t) => {
1457
+ e.onclose = () => {
1458
+ this._logVerbose("Closed after connecting"), t();
1459
+ }, e.onopen = () => {
1460
+ this._logVerbose("Opened after connecting"), e.close();
1461
+ };
1462
+ });
1463
+ }
1464
+ case "ready": {
1465
+ this._logVerbose("ws.close called");
1466
+ let e = this.socket.ws;
1467
+ e.onmessage = (e) => {
1468
+ this._logVerbose("Ignoring message received after close");
1469
+ };
1470
+ let t = new Promise((t) => {
1471
+ e.onclose = () => {
1472
+ t();
1473
+ };
1474
+ });
1475
+ return e.close(), t;
1476
+ }
1477
+ default: return this.socket, Promise.resolve();
1478
+ }
1479
+ }
1480
+ terminate() {
1481
+ switch (this.reconnectDueToServerInactivityTimeout && clearTimeout(this.reconnectDueToServerInactivityTimeout), this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.cleanupNetworkListener(), this.socket.state) {
1482
+ case "terminated":
1483
+ case "stopped":
1484
+ case "disconnected":
1485
+ case "connecting":
1486
+ case "ready": {
1487
+ let e = this.close();
1488
+ return this.setSocketState({ state: "terminated" }), e;
1489
+ }
1490
+ default: throw this.socket, Error(`Invalid websocket state: ${this.socket.state}`);
1491
+ }
1492
+ }
1493
+ stop() {
1494
+ switch (this.socket.state) {
1495
+ case "terminated": return Promise.resolve();
1496
+ case "connecting":
1497
+ case "stopped":
1498
+ case "disconnected":
1499
+ case "ready": {
1500
+ this.cleanupNetworkListener();
1501
+ let e = this.close();
1502
+ return this.socket = { state: "stopped" }, e;
1503
+ }
1504
+ default: return this.socket, Promise.resolve();
1505
+ }
1506
+ }
1507
+ tryRestart() {
1508
+ switch (this.socket.state) {
1509
+ case "stopped": break;
1510
+ case "terminated":
1511
+ case "connecting":
1512
+ case "ready":
1513
+ case "disconnected":
1514
+ this.logger.logVerbose("Restart called without stopping first");
1515
+ return;
1516
+ default: this.socket;
1517
+ }
1518
+ this.setupNetworkListener(), this.connect();
1519
+ }
1520
+ pause() {
1521
+ switch (this.socket.state) {
1522
+ case "disconnected":
1523
+ case "stopped":
1524
+ case "terminated": return;
1525
+ case "connecting":
1526
+ case "ready":
1527
+ this.socket = {
1528
+ ...this.socket,
1529
+ paused: "yes"
1530
+ };
1531
+ return;
1532
+ default:
1533
+ this.socket;
1534
+ return;
1535
+ }
1536
+ }
1537
+ tryReconnectImmediately() {
1538
+ if (this._logVerbose("tryReconnectImmediately called"), this.socket.state !== "disconnected") {
1539
+ this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);
1540
+ return;
1541
+ }
1542
+ let e = null;
1543
+ if (this.scheduledReconnect) {
1544
+ let t = En() - this.scheduledReconnect.scheduledAt;
1545
+ e = Math.max(0, this.scheduledReconnect.backoffMs - t), this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(t)}ms)`), clearTimeout(this.scheduledReconnect.timeout), this.scheduledReconnect = null, this._logVerbose("canceled scheduled reconnect");
1546
+ }
1547
+ this.logger.log("Network recovery detected, reconnecting immediately"), this.pendingNetworkRecoveryInfo = e === null ? null : { timeSavedMs: e }, this.connect();
1548
+ }
1549
+ resume() {
1550
+ switch (this.socket.state) {
1551
+ case "connecting":
1552
+ this.socket = {
1553
+ ...this.socket,
1554
+ paused: "no"
1555
+ };
1556
+ return;
1557
+ case "ready":
1558
+ this.socket.paused === "uninitialized" ? (this.socket = {
1559
+ ...this.socket,
1560
+ paused: "no"
1561
+ }, this._hasEverConnected = !0, this.onOpen({
1562
+ connectionCount: this.connectionCount,
1563
+ lastCloseReason: this.lastCloseReason,
1564
+ clientTs: En()
1565
+ })) : this.socket.paused === "yes" && (this.socket = {
1566
+ ...this.socket,
1567
+ paused: "no"
1568
+ }, this.onResume());
1569
+ return;
1570
+ case "terminated":
1571
+ case "stopped":
1572
+ case "disconnected": return;
1573
+ default: this.socket;
1574
+ }
1575
+ this.connect();
1576
+ }
1577
+ connectionState() {
1578
+ return {
1579
+ isConnected: this.socket.state === "ready",
1580
+ hasEverConnected: this._hasEverConnected,
1581
+ connectionCount: this.connectionCount,
1582
+ connectionRetries: this.retries
1583
+ };
1584
+ }
1585
+ _logVerbose(e) {
1586
+ this.logger.logVerbose(e);
1587
+ }
1588
+ nextBackoff(e) {
1589
+ let t = (e === "client" ? 100 : e === "Unknown" ? this.defaultInitialBackoff : On[e].timeout) * 2 ** this.retries;
1590
+ this.retries += 1;
1591
+ let n = Math.min(t, this.maxBackoff);
1592
+ return n + n * (Math.random() - .5);
1593
+ }
1594
+ reportLargeTransition({ transition: e, messageLength: t }) {
1595
+ if (e.clientClockSkew === void 0 || e.serverTs === void 0) return;
1596
+ let n = En() - e.clientClockSkew - e.serverTs / 1e6, r = `${Math.round(n)}ms`, i = `${Math.round(t / 1e4) / 100}MB`, a = t / (n / 1e3), o = `${Math.round(a / 1e4) / 100}MB per second`;
1597
+ this._logVerbose(`received ${i} transition in ${r} at ${o}`), t > 2e7 ? this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`) : n > 2e4 && this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${r})`), this.debug && this.sendMessage({
1598
+ type: "Event",
1599
+ eventType: "ClientReceivedTransition",
1600
+ event: {
1601
+ transitionTransitTime: n,
1602
+ messageLength: t
1603
+ }
1604
+ });
1605
+ }
1606
+ };
1607
+ //#endregion
1608
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/session.js
1609
+ function jn() {
1610
+ return Mn();
1611
+ }
1612
+ function Mn() {
1613
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
1614
+ let t = Math.random() * 16 | 0;
1615
+ return (e === "x" ? t : t & 3 | 8).toString(16);
1616
+ });
1617
+ }
1618
+ //#endregion
1619
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/vendor/jwt-decode/index.js
1620
+ var Nn = class extends Error {};
1621
+ Nn.prototype.name = "InvalidTokenError";
1622
+ function Pn(e) {
1623
+ return decodeURIComponent(atob(e).replace(/(.)/g, (e, t) => {
1624
+ let n = t.charCodeAt(0).toString(16).toUpperCase();
1625
+ return n.length < 2 && (n = "0" + n), "%" + n;
1626
+ }));
1627
+ }
1628
+ function Fn(e) {
1629
+ let t = e.replace(/-/g, "+").replace(/_/g, "/");
1630
+ switch (t.length % 4) {
1631
+ case 0: break;
1632
+ case 2:
1633
+ t += "==";
1634
+ break;
1635
+ case 3:
1636
+ t += "=";
1637
+ break;
1638
+ default: throw Error("base64 string is not of the correct length");
1639
+ }
1640
+ try {
1641
+ return Pn(t);
1642
+ } catch {
1643
+ return atob(t);
1644
+ }
1645
+ }
1646
+ function In(e, t) {
1647
+ if (typeof e != "string") throw new Nn("Invalid token specified: must be a string");
1648
+ t ||= {};
1649
+ let n = t.header === !0 ? 0 : 1, r = e.split(".")[n];
1650
+ if (typeof r != "string") throw new Nn(`Invalid token specified: missing part #${n + 1}`);
1651
+ let i;
1652
+ try {
1653
+ i = Fn(r);
1654
+ } catch (e) {
1655
+ throw new Nn(`Invalid token specified: invalid base64 for part #${n + 1} (${e.message})`);
1656
+ }
1657
+ try {
1658
+ return JSON.parse(i);
1659
+ } catch (e) {
1660
+ throw new Nn(`Invalid token specified: invalid json for part #${n + 1} (${e.message})`);
1661
+ }
1662
+ }
1663
+ //#endregion
1664
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/authentication_manager.js
1665
+ var Ln = Object.defineProperty, Rn = (e, t, n) => t in e ? Ln(e, t, {
1666
+ enumerable: !0,
1667
+ configurable: !0,
1668
+ writable: !0,
1669
+ value: n
1670
+ }) : e[t] = n, q = (e, t, n) => Rn(e, typeof t == "symbol" ? t : t + "", n), zn = 480 * 60 * 60 * 1e3, Bn = 2, Vn = class {
1671
+ constructor(e, t, n) {
1672
+ q(this, "authState", { state: "noAuth" }), q(this, "configVersion", 0), q(this, "syncState"), q(this, "authenticate"), q(this, "stopSocket"), q(this, "tryRestartSocket"), q(this, "pauseSocket"), q(this, "resumeSocket"), q(this, "clearAuth"), q(this, "logger"), q(this, "refreshTokenLeewaySeconds"), q(this, "tokenConfirmationAttempts", 0), this.syncState = e, this.authenticate = t.authenticate, this.stopSocket = t.stopSocket, this.tryRestartSocket = t.tryRestartSocket, this.pauseSocket = t.pauseSocket, this.resumeSocket = t.resumeSocket, this.clearAuth = t.clearAuth, this.logger = n.logger, this.refreshTokenLeewaySeconds = n.refreshTokenLeewaySeconds;
1673
+ }
1674
+ async setConfig(e, t) {
1675
+ this.resetAuthState(), this._logVerbose("pausing WS for auth token fetch"), this.pauseSocket();
1676
+ let n = await this.fetchTokenAndGuardAgainstRace(e, { forceRefreshToken: !1 });
1677
+ n.isFromOutdatedConfig || (n.value ? (this.setAuthState({
1678
+ state: "waitingForServerConfirmationOfCachedToken",
1679
+ config: {
1680
+ fetchToken: e,
1681
+ onAuthChange: t
1682
+ },
1683
+ hasRetried: !1
1684
+ }), this.authenticate(n.value)) : (this.setAuthState({
1685
+ state: "initialRefetch",
1686
+ config: {
1687
+ fetchToken: e,
1688
+ onAuthChange: t
1689
+ }
1690
+ }), await this.refetchToken()), this._logVerbose("resuming WS after auth token fetch"), this.resumeSocket());
1691
+ }
1692
+ onTransition(e) {
1693
+ if (this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity) && !(e.endVersion.identity <= e.startVersion.identity)) {
1694
+ if (this._logVerbose(`auth state is ${this.authState.state} when handling transition`), this.syncState.markAuthCompletion(), this.authState.state === "waitingForServerConfirmationOfCachedToken") {
1695
+ this._logVerbose("server confirmed auth token is valid"), this.refetchToken(), this.authState.config.onAuthChange(!0);
1696
+ return;
1697
+ }
1698
+ this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this._logVerbose("server confirmed new auth token is valid"), this.scheduleTokenRefetch(this.authState.token), this.tokenConfirmationAttempts = 0, this.authState.hadAuth || this.authState.config.onAuthChange(!0));
1699
+ }
1700
+ }
1701
+ onAuthError(e) {
1702
+ if (e.authUpdateAttempted === !1 && (this.authState.state === "waitingForServerConfirmationOfFreshToken" || this.authState.state === "waitingForServerConfirmationOfCachedToken")) {
1703
+ this._logVerbose("ignoring non-auth token expired error");
1704
+ return;
1705
+ }
1706
+ let { baseVersion: t } = e;
1707
+ if (!this.syncState.isCurrentOrNewerAuthVersion(t + 1)) {
1708
+ this._logVerbose("ignoring auth error for previous auth attempt");
1709
+ return;
1710
+ }
1711
+ this.tryToReauthenticate(e);
1712
+ }
1713
+ async tryToReauthenticate(e) {
1714
+ if (this._logVerbose(`attempting to reauthenticate: ${e.error}`), this.authState.state === "noAuth" || this.authState.state === "waitingForServerConfirmationOfFreshToken" && this.tokenConfirmationAttempts >= Bn) {
1715
+ this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`), this.syncState.hasAuth() && this.syncState.clearAuth(), this.authState.state !== "noAuth" && this.setAndReportAuthFailed(this.authState.config.onAuthChange);
1716
+ return;
1717
+ }
1718
+ this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this.tokenConfirmationAttempts++, this._logVerbose(`retrying reauthentication, ${Bn - this.tokenConfirmationAttempts} attempts remaining`)), await this.stopSocket();
1719
+ let t = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1720
+ t.isFromOutdatedConfig || (t.value && this.syncState.isNewAuth(t.value) ? (this.authenticate(t.value), this.setAuthState({
1721
+ state: "waitingForServerConfirmationOfFreshToken",
1722
+ config: this.authState.config,
1723
+ token: t.value,
1724
+ hadAuth: this.authState.state === "notRefetching" || this.authState.state === "waitingForScheduledRefetch"
1725
+ })) : (this._logVerbose("reauthentication failed, could not fetch a new token"), this.syncState.hasAuth() && this.syncState.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this.tryRestartSocket());
1726
+ }
1727
+ async refetchToken() {
1728
+ if (this.authState.state === "noAuth") return;
1729
+ this._logVerbose("refetching auth token");
1730
+ let e = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1731
+ e.isFromOutdatedConfig || (e.value ? this.syncState.isNewAuth(e.value) ? (this.setAuthState({
1732
+ state: "waitingForServerConfirmationOfFreshToken",
1733
+ hadAuth: this.syncState.hasAuth(),
1734
+ token: e.value,
1735
+ config: this.authState.config
1736
+ }), this.authenticate(e.value)) : this.setAuthState({
1737
+ state: "notRefetching",
1738
+ config: this.authState.config
1739
+ }) : (this._logVerbose("refetching token failed"), this.syncState.hasAuth() && this.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this._logVerbose("restarting WS after auth token fetch (if currently stopped)"), this.tryRestartSocket());
1740
+ }
1741
+ scheduleTokenRefetch(e) {
1742
+ if (this.authState.state === "noAuth") return;
1743
+ let t = this.decodeToken(e);
1744
+ if (!t) {
1745
+ this.logger.error("Auth token is not a valid JWT, cannot refetch the token");
1746
+ return;
1747
+ }
1748
+ let { iat: n, exp: r } = t;
1749
+ if (!n || !r) {
1750
+ this.logger.error("Auth token does not have required fields, cannot refetch the token");
1751
+ return;
1752
+ }
1753
+ let i = r - n;
1754
+ if (i <= 2) {
1755
+ this.logger.error("Auth token does not live long enough, cannot refetch the token");
1756
+ return;
1757
+ }
1758
+ let a = Math.min(zn, (i - this.refreshTokenLeewaySeconds) * 1e3);
1759
+ a <= 0 && (this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${i}s`), a = 0);
1760
+ let o = setTimeout(() => {
1761
+ this._logVerbose("running scheduled token refetch"), this.refetchToken();
1762
+ }, a);
1763
+ this.setAuthState({
1764
+ state: "waitingForScheduledRefetch",
1765
+ refetchTokenTimeoutId: o,
1766
+ config: this.authState.config
1767
+ }), this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`);
1768
+ }
1769
+ async fetchTokenAndGuardAgainstRace(e, t) {
1770
+ let n = ++this.configVersion;
1771
+ this._logVerbose(`fetching token with config version ${n}`);
1772
+ let r = await e(t);
1773
+ return this.configVersion === n ? {
1774
+ isFromOutdatedConfig: !1,
1775
+ value: r
1776
+ } : (this._logVerbose(`stale config version, expected ${n}, got ${this.configVersion}`), { isFromOutdatedConfig: !0 });
1777
+ }
1778
+ stop() {
1779
+ this.resetAuthState(), this.configVersion++, this._logVerbose(`config version bumped to ${this.configVersion}`);
1780
+ }
1781
+ setAndReportAuthFailed(e) {
1782
+ e(!1), this.resetAuthState();
1783
+ }
1784
+ resetAuthState() {
1785
+ this.setAuthState({ state: "noAuth" });
1786
+ }
1787
+ setAuthState(e) {
1788
+ let t = e.state === "waitingForServerConfirmationOfFreshToken" ? {
1789
+ hadAuth: e.hadAuth,
1790
+ state: e.state,
1791
+ token: `...${e.token.slice(-7)}`
1792
+ } : { state: e.state };
1793
+ switch (this._logVerbose(`setting auth state to ${JSON.stringify(t)}`), e.state) {
1794
+ case "waitingForScheduledRefetch":
1795
+ case "notRefetching":
1796
+ case "noAuth":
1797
+ this.tokenConfirmationAttempts = 0;
1798
+ break;
1799
+ case "waitingForServerConfirmationOfFreshToken":
1800
+ case "waitingForServerConfirmationOfCachedToken":
1801
+ case "initialRefetch": break;
1802
+ default:
1803
+ }
1804
+ this.authState.state === "waitingForScheduledRefetch" && clearTimeout(this.authState.refetchTokenTimeoutId), this.authState = e;
1805
+ }
1806
+ decodeToken(e) {
1807
+ try {
1808
+ return In(e);
1809
+ } catch (e) {
1810
+ return this._logVerbose(`Error decoding token: ${e instanceof Error ? e.message : "Unknown error"}`), null;
1811
+ }
1812
+ }
1813
+ _logVerbose(e) {
1814
+ this.logger.logVerbose(`${e} [v${this.configVersion}]`);
1815
+ }
1816
+ }, Hn = [
1817
+ "convexClientConstructed",
1818
+ "convexWebSocketOpen",
1819
+ "convexFirstMessageReceived"
1820
+ ];
1821
+ function Un(e, t) {
1822
+ let n = { sessionId: t };
1823
+ typeof performance > "u" || !performance.mark || performance.mark(e, { detail: n });
1824
+ }
1825
+ function Wn(e) {
1826
+ let t = e.name.slice(6);
1827
+ return t = t.charAt(0).toLowerCase() + t.slice(1), {
1828
+ name: t,
1829
+ startTime: e.startTime
1830
+ };
1831
+ }
1832
+ function Gn(e) {
1833
+ if (typeof performance > "u" || !performance.getEntriesByName) return [];
1834
+ let t = [];
1835
+ for (let n of Hn) {
1836
+ let r = performance.getEntriesByName(n).filter((e) => e.entryType === "mark").filter((t) => t.detail.sessionId === e);
1837
+ t.push(...r);
1838
+ }
1839
+ return t.map(Wn);
1840
+ }
1841
+ //#endregion
1842
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/client.js
1843
+ var Kn = Object.defineProperty, qn = (e, t, n) => t in e ? Kn(e, t, {
1844
+ enumerable: !0,
1845
+ configurable: !0,
1846
+ writable: !0,
1847
+ value: n
1848
+ }) : e[t] = n, J = (e, t, n) => qn(e, typeof t == "symbol" ? t : t + "", n), Jn = class {
1849
+ constructor(e, t, n) {
1850
+ if (J(this, "address"), J(this, "state"), J(this, "requestManager"), J(this, "webSocketManager"), J(this, "authenticationManager"), J(this, "remoteQuerySet"), J(this, "optimisticQueryResults"), J(this, "_transitionHandlerCounter", 0), J(this, "_nextRequestId"), J(this, "_onTransitionFns", /* @__PURE__ */ new Map()), J(this, "_sessionId"), J(this, "firstMessageReceived", !1), J(this, "debug"), J(this, "logger"), J(this, "maxObservedTimestamp"), J(this, "connectionStateSubscribers", /* @__PURE__ */ new Map()), J(this, "nextConnectionStateSubscriberId", 0), J(this, "_lastPublishedConnectionState"), J(this, "markConnectionStateDirty", () => {
1851
+ Promise.resolve().then(() => {
1852
+ let e = this.connectionState();
1853
+ if (JSON.stringify(e) !== JSON.stringify(this._lastPublishedConnectionState)) {
1854
+ this._lastPublishedConnectionState = e;
1855
+ for (let t of this.connectionStateSubscribers.values()) t(e);
1856
+ }
1857
+ });
1858
+ }), J(this, "mark", (e) => {
1859
+ this.debug && Un(e, this.sessionId);
1860
+ }), typeof e == "object") throw Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");
1861
+ n?.skipConvexDeploymentUrlCheck !== !0 && Ue(e), n = { ...n };
1862
+ let r = n.authRefreshTokenLeewaySeconds ?? 10, i = n.webSocketConstructor;
1863
+ if (!i && typeof WebSocket > "u") throw Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");
1864
+ i ||= WebSocket, this.debug = n.reportDebugInfoToConvex ?? !1, this.address = e, this.logger = n.logger === !1 ? Dt({ verbose: n.verbose ?? !1 }) : n.logger !== !0 && n.logger ? n.logger : Et({ verbose: n.verbose ?? !1 });
1865
+ let a = e.search("://");
1866
+ if (a === -1) throw Error("Provided address was not an absolute URL.");
1867
+ let o = e.substring(a + 3), s = e.substring(0, a), c;
1868
+ if (s === "http") c = "ws";
1869
+ else if (s === "https") c = "wss";
1870
+ else throw Error(`Unknown parent protocol ${s}`);
1871
+ let l = `${c}://${o}/api/${Me}/sync`;
1872
+ this.state = new Rt(), this.remoteQuerySet = new mn((e) => this.state.queryPath(e), this.logger), this.requestManager = new Ht(this.logger, this.markConnectionStateDirty);
1873
+ let u = () => {
1874
+ this.webSocketManager.pause(), this.state.pause();
1875
+ };
1876
+ this.authenticationManager = new Vn(this.state, {
1877
+ authenticate: (e) => {
1878
+ let t = this.state.setAuth(e);
1879
+ return this.webSocketManager.sendMessage(t), t.baseVersion;
1880
+ },
1881
+ stopSocket: () => this.webSocketManager.stop(),
1882
+ tryRestartSocket: () => this.webSocketManager.tryRestart(),
1883
+ pauseSocket: u,
1884
+ resumeSocket: () => this.webSocketManager.resume(),
1885
+ clearAuth: () => {
1886
+ this.clearAuth();
1887
+ }
1888
+ }, {
1889
+ logger: this.logger,
1890
+ refreshTokenLeewaySeconds: r
1891
+ }), this.optimisticQueryResults = new en(), this.addOnTransitionHandler((e) => {
1892
+ t(e.queries.map((e) => e.token));
1893
+ }), this._nextRequestId = 0, this._sessionId = jn();
1894
+ let { unsavedChangesWarning: d } = n;
1895
+ if (typeof window > "u" || window.addEventListener === void 0) {
1896
+ if (d === !0) throw Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.");
1897
+ } else d !== !1 && window.addEventListener("beforeunload", (e) => {
1898
+ if (this.requestManager.hasIncompleteRequests()) {
1899
+ e.preventDefault();
1900
+ let t = "Are you sure you want to leave? Your changes may not be saved.";
1901
+ return (e || window.event).returnValue = t, t;
1902
+ }
1903
+ });
1904
+ this.webSocketManager = new An(l, {
1905
+ onOpen: (e) => {
1906
+ this.mark("convexWebSocketOpen"), this.webSocketManager.sendMessage({
1907
+ ...e,
1908
+ type: "Connect",
1909
+ sessionId: this._sessionId,
1910
+ maxObservedTimestamp: this.maxObservedTimestamp
1911
+ }), this.remoteQuerySet = new mn((e) => this.state.queryPath(e), this.logger);
1912
+ let [t, n] = this.state.restart();
1913
+ n && this.webSocketManager.sendMessage(n), this.webSocketManager.sendMessage(t);
1914
+ for (let e of this.requestManager.restart()) this.webSocketManager.sendMessage(e);
1915
+ },
1916
+ onResume: () => {
1917
+ let [e, t] = this.state.resume();
1918
+ t && this.webSocketManager.sendMessage(t), e && this.webSocketManager.sendMessage(e);
1919
+ for (let e of this.requestManager.resume()) this.webSocketManager.sendMessage(e);
1920
+ },
1921
+ onMessage: (e) => {
1922
+ switch (this.firstMessageReceived || (this.firstMessageReceived = !0, this.mark("convexFirstMessageReceived"), this.reportMarks()), e.type) {
1923
+ case "Transition": {
1924
+ this.observedTimestamp(e.endVersion.ts), this.authenticationManager.onTransition(e), this.remoteQuerySet.transition(e), this.state.transition(e);
1925
+ let t = this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());
1926
+ this.notifyOnQueryResultChanges(t);
1927
+ break;
1928
+ }
1929
+ case "MutationResponse": {
1930
+ e.success && this.observedTimestamp(e.ts);
1931
+ let t = this.requestManager.onResponse(e);
1932
+ t !== null && this.notifyOnQueryResultChanges(/* @__PURE__ */ new Map([[t.requestId, t.result]]));
1933
+ break;
1934
+ }
1935
+ case "ActionResponse":
1936
+ this.requestManager.onResponse(e);
1937
+ break;
1938
+ case "AuthError":
1939
+ this.authenticationManager.onAuthError(e);
1940
+ break;
1941
+ case "FatalError": {
1942
+ let t = kt(this.logger, e.error);
1943
+ throw this.webSocketManager.terminate(), t;
1944
+ }
1945
+ default:
1946
+ }
1947
+ return { hasSyncedPastLastReconnect: this.hasSyncedPastLastReconnect() };
1948
+ },
1949
+ onServerDisconnectError: n.onServerDisconnectError
1950
+ }, i, this.logger, this.markConnectionStateDirty, this.debug), this.mark("convexClientConstructed"), n.expectAuth && u();
1951
+ }
1952
+ hasSyncedPastLastReconnect() {
1953
+ return this.requestManager.hasSyncedPastLastReconnect() && this.state.hasSyncedPastLastReconnect();
1954
+ }
1955
+ observedTimestamp(e) {
1956
+ (this.maxObservedTimestamp === void 0 || this.maxObservedTimestamp.lessThanOrEqual(e)) && (this.maxObservedTimestamp = e);
1957
+ }
1958
+ getMaxObservedTimestamp() {
1959
+ return this.maxObservedTimestamp;
1960
+ }
1961
+ notifyOnQueryResultChanges(e) {
1962
+ let t = this.remoteQuerySet.remoteQueryResults(), n = /* @__PURE__ */ new Map();
1963
+ for (let [e, r] of t) {
1964
+ let t = this.state.queryToken(e);
1965
+ if (t !== null) {
1966
+ let i = {
1967
+ result: r,
1968
+ udfPath: this.state.queryPath(e),
1969
+ args: this.state.queryArgs(e)
1970
+ };
1971
+ n.set(t, i);
1972
+ }
1973
+ }
1974
+ let r = this.optimisticQueryResults.ingestQueryResultsFromServer(n, new Set(e.keys()));
1975
+ this.handleTransition({
1976
+ queries: r.map((e) => ({
1977
+ token: e,
1978
+ modification: {
1979
+ kind: "Updated",
1980
+ result: this.optimisticQueryResults.rawQueryResult(e)
1981
+ }
1982
+ })),
1983
+ reflectedMutations: Array.from(e).map(([e, t]) => ({
1984
+ requestId: e,
1985
+ result: t
1986
+ })),
1987
+ timestamp: this.remoteQuerySet.timestamp()
1988
+ });
1989
+ }
1990
+ handleTransition(e) {
1991
+ for (let t of this._onTransitionFns.values()) t(e);
1992
+ }
1993
+ addOnTransitionHandler(e) {
1994
+ let t = this._transitionHandlerCounter++;
1995
+ return this._onTransitionFns.set(t, e), () => this._onTransitionFns.delete(t);
1996
+ }
1997
+ getCurrentAuthClaims() {
1998
+ let e = this.state.getAuth(), t = {};
1999
+ if (e && e.tokenType === "User") try {
2000
+ t = e ? In(e.value) : {};
2001
+ } catch {
2002
+ t = {};
2003
+ }
2004
+ else return;
2005
+ return {
2006
+ token: e.value,
2007
+ decoded: t
2008
+ };
2009
+ }
2010
+ setAuth(e, t) {
2011
+ this.authenticationManager.setConfig(e, t);
2012
+ }
2013
+ hasAuth() {
2014
+ return this.state.hasAuth();
2015
+ }
2016
+ setAdminAuth(e, t) {
2017
+ let n = this.state.setAdminAuth(e, t);
2018
+ this.webSocketManager.sendMessage(n);
2019
+ }
2020
+ clearAuth() {
2021
+ let e = this.state.clearAuth();
2022
+ this.webSocketManager.sendMessage(e);
2023
+ }
2024
+ subscribe(e, t, n) {
2025
+ let r = U(t), { modification: i, queryToken: a, unsubscribe: o } = this.state.subscribe(e, r, n?.journal, n?.componentPath);
2026
+ return i !== null && this.webSocketManager.sendMessage(i), {
2027
+ queryToken: a,
2028
+ unsubscribe: () => {
2029
+ let e = o();
2030
+ e && this.webSocketManager.sendMessage(e);
2031
+ }
2032
+ };
2033
+ }
2034
+ localQueryResult(e, t) {
2035
+ let n = Nt(e, U(t));
2036
+ return this.optimisticQueryResults.queryResult(n);
2037
+ }
2038
+ localQueryResultByToken(e) {
2039
+ return this.optimisticQueryResults.queryResult(e);
2040
+ }
2041
+ hasLocalQueryResultByToken(e) {
2042
+ return this.optimisticQueryResults.hasQueryResult(e);
2043
+ }
2044
+ localQueryLogs(e, t) {
2045
+ let n = Nt(e, U(t));
2046
+ return this.optimisticQueryResults.queryLogs(n);
2047
+ }
2048
+ queryJournal(e, t) {
2049
+ let n = Nt(e, U(t));
2050
+ return this.state.queryJournal(n);
2051
+ }
2052
+ connectionState() {
2053
+ let e = this.webSocketManager.connectionState();
2054
+ return {
2055
+ hasInflightRequests: this.requestManager.hasInflightRequests(),
2056
+ isWebSocketConnected: e.isConnected,
2057
+ hasEverConnected: e.hasEverConnected,
2058
+ connectionCount: e.connectionCount,
2059
+ connectionRetries: e.connectionRetries,
2060
+ timeOfOldestInflightRequest: this.requestManager.timeOfOldestInflightRequest(),
2061
+ inflightMutations: this.requestManager.inflightMutations(),
2062
+ inflightActions: this.requestManager.inflightActions()
2063
+ };
2064
+ }
2065
+ subscribeToConnectionState(e) {
2066
+ let t = this.nextConnectionStateSubscriberId++;
2067
+ return this.connectionStateSubscribers.set(t, e), () => {
2068
+ this.connectionStateSubscribers.delete(t);
2069
+ };
2070
+ }
2071
+ async mutation(e, t, n) {
2072
+ let r = await this.mutationInternal(e, t, n);
2073
+ if (!r.success) throw r.errorData === void 0 ? Error(At("mutation", e, r)) : jt(r, new yt(At("mutation", e, r)));
2074
+ return r.value;
2075
+ }
2076
+ async mutationInternal(e, t, n, r) {
2077
+ let { mutationPromise: i } = this.enqueueMutation(e, t, n, r);
2078
+ return i;
2079
+ }
2080
+ enqueueMutation(e, t, n, r) {
2081
+ let i = U(t);
2082
+ this.tryReportLongDisconnect();
2083
+ let a = this.nextRequestId;
2084
+ if (this._nextRequestId++, n !== void 0) {
2085
+ let e = n.optimisticUpdate;
2086
+ if (e !== void 0) {
2087
+ let t = this.optimisticQueryResults.applyOptimisticUpdate((t) => {
2088
+ e(t, i) instanceof Promise && this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.");
2089
+ }, a).map((e) => {
2090
+ let t = this.localQueryResultByToken(e);
2091
+ return {
2092
+ token: e,
2093
+ modification: {
2094
+ kind: "Updated",
2095
+ result: t === void 0 ? void 0 : {
2096
+ success: !0,
2097
+ value: t,
2098
+ logLines: []
2099
+ }
2100
+ }
2101
+ };
2102
+ });
2103
+ this.handleTransition({
2104
+ queries: t,
2105
+ reflectedMutations: [],
2106
+ timestamp: this.remoteQuerySet.timestamp()
2107
+ });
2108
+ }
2109
+ }
2110
+ let o = {
2111
+ type: "Mutation",
2112
+ requestId: a,
2113
+ udfPath: e,
2114
+ componentPath: r,
2115
+ args: [ft(i)]
2116
+ }, s = this.webSocketManager.sendMessage(o);
2117
+ return {
2118
+ requestId: a,
2119
+ mutationPromise: this.requestManager.request(o, s)
2120
+ };
2121
+ }
2122
+ async action(e, t) {
2123
+ let n = await this.actionInternal(e, t);
2124
+ if (!n.success) throw n.errorData === void 0 ? Error(At("action", e, n)) : jt(n, new yt(At("action", e, n)));
2125
+ return n.value;
2126
+ }
2127
+ async actionInternal(e, t, n) {
2128
+ let r = U(t), i = this.nextRequestId;
2129
+ this._nextRequestId++, this.tryReportLongDisconnect();
2130
+ let a = {
2131
+ type: "Action",
2132
+ requestId: i,
2133
+ udfPath: e,
2134
+ componentPath: n,
2135
+ args: [ft(r)]
2136
+ }, o = this.webSocketManager.sendMessage(a);
2137
+ return this.requestManager.request(a, o);
2138
+ }
2139
+ async close() {
2140
+ return this.authenticationManager.stop(), this.webSocketManager.terminate();
2141
+ }
2142
+ get url() {
2143
+ return this.address;
2144
+ }
2145
+ get nextRequestId() {
2146
+ return this._nextRequestId;
2147
+ }
2148
+ get sessionId() {
2149
+ return this._sessionId;
2150
+ }
2151
+ reportMarks() {
2152
+ if (this.debug) {
2153
+ let e = Gn(this.sessionId);
2154
+ this.webSocketManager.sendMessage({
2155
+ type: "Event",
2156
+ eventType: "ClientConnect",
2157
+ event: e
2158
+ });
2159
+ }
2160
+ }
2161
+ tryReportLongDisconnect() {
2162
+ if (!this.debug) return;
2163
+ let e = this.connectionState().timeOfOldestInflightRequest;
2164
+ if (e === null || Date.now() - e.getTime() <= 60 * 1e3) return;
2165
+ let t = `${this.address}/api/debug_event`;
2166
+ fetch(t, {
2167
+ method: "POST",
2168
+ headers: {
2169
+ "Content-Type": "application/json",
2170
+ "Convex-Client": `npm-${Me}`
2171
+ },
2172
+ body: JSON.stringify({ event: "LongWebsocketDisconnect" })
2173
+ }).then((e) => {
2174
+ e.ok || this.logger.warn("Analytics request failed with response:", e.body);
2175
+ }).catch((e) => {
2176
+ this.logger.warn("Analytics response failed with error:", e);
2177
+ });
2178
+ }
2179
+ };
2180
+ //#endregion
2181
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/pagination.js
2182
+ function Yn(e) {
2183
+ if (typeof e != "object" || !e || !Array.isArray(e.page) || typeof e.isDone != "boolean" || typeof e.continueCursor != "string") throw Error(`Not a valid paginated query result: ${e?.toString()}`);
2184
+ return e;
2185
+ }
2186
+ //#endregion
2187
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/paginated_query_client.js
2188
+ var Xn = Object.defineProperty, Zn = (e, t, n) => t in e ? Xn(e, t, {
2189
+ enumerable: !0,
2190
+ configurable: !0,
2191
+ writable: !0,
2192
+ value: n
2193
+ }) : e[t] = n, Qn = (e, t, n) => Zn(e, typeof t == "symbol" ? t : t + "", n), $n = class {
2194
+ constructor(e, t) {
2195
+ this.client = e, this.onTransition = t, Qn(this, "paginatedQuerySet", /* @__PURE__ */ new Map()), Qn(this, "lastTransitionTs"), this.lastTransitionTs = an.fromNumber(0), this.client.addOnTransitionHandler((e) => this.onBaseTransition(e));
2196
+ }
2197
+ subscribe(e, t, n) {
2198
+ let r = Mt(e), i = Pt(r, t, n), a = () => this.removePaginatedQuerySubscriber(i), o = this.paginatedQuerySet.get(i);
2199
+ return o ? (o.numSubscribers += 1, {
2200
+ paginatedQueryToken: i,
2201
+ unsubscribe: a
2202
+ }) : (this.paginatedQuerySet.set(i, {
2203
+ token: i,
2204
+ canonicalizedUdfPath: r,
2205
+ args: t,
2206
+ numSubscribers: 1,
2207
+ options: { initialNumItems: n.initialNumItems },
2208
+ nextPageKey: 0,
2209
+ pageKeys: [],
2210
+ pageKeyToQuery: /* @__PURE__ */ new Map(),
2211
+ ongoingSplits: /* @__PURE__ */ new Map(),
2212
+ skip: !1,
2213
+ id: n.id
2214
+ }), this.addPageToPaginatedQuery(i, null, n.initialNumItems), {
2215
+ paginatedQueryToken: i,
2216
+ unsubscribe: a
2217
+ });
2218
+ }
2219
+ localQueryResult(e, t, n) {
2220
+ let r = Pt(Mt(e), t, n);
2221
+ return this.localQueryResultByToken(r);
2222
+ }
2223
+ localQueryResultByToken(e) {
2224
+ let t = this.paginatedQuerySet.get(e);
2225
+ if (!t) return;
2226
+ let n = this.activePageQueryTokens(t);
2227
+ if (n.length === 0) return {
2228
+ results: [],
2229
+ status: "LoadingFirstPage",
2230
+ loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2231
+ };
2232
+ let r = [], i = !1, a = !1;
2233
+ for (let e of n) {
2234
+ let t = this.client.localQueryResultByToken(e);
2235
+ if (t === void 0) {
2236
+ i = !0, a = !1;
2237
+ continue;
2238
+ }
2239
+ let n = Yn(t);
2240
+ r = r.concat(n.page), a = !!n.isDone;
2241
+ }
2242
+ let o;
2243
+ return o = i ? r.length === 0 ? "LoadingFirstPage" : "LoadingMore" : a ? "Exhausted" : "CanLoadMore", {
2244
+ results: r,
2245
+ status: o,
2246
+ loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2247
+ };
2248
+ }
2249
+ onBaseTransition(e) {
2250
+ let t = e.queries.map((e) => e.token), n = this.queriesContainingTokens(t), r = [];
2251
+ n.length > 0 && (this.processPaginatedQuerySplits(n, (e) => this.client.localQueryResultByToken(e)), r = n.map((e) => ({
2252
+ token: e,
2253
+ modification: {
2254
+ kind: "Updated",
2255
+ result: this.localQueryResultByToken(e)
2256
+ }
2257
+ })));
2258
+ let i = {
2259
+ ...e,
2260
+ paginatedQueries: r
2261
+ };
2262
+ this.onTransition(i);
2263
+ }
2264
+ loadMoreOfPaginatedQuery(e, t) {
2265
+ this.mustGetPaginatedQuery(e);
2266
+ let n = this.queryTokenForLastPageOfPaginatedQuery(e), r = this.client.localQueryResultByToken(n);
2267
+ if (!r) return !1;
2268
+ let i = Yn(r);
2269
+ if (i.isDone) return !1;
2270
+ this.addPageToPaginatedQuery(e, i.continueCursor, t);
2271
+ let a = {
2272
+ timestamp: this.lastTransitionTs,
2273
+ reflectedMutations: [],
2274
+ queries: [],
2275
+ paginatedQueries: [{
2276
+ token: e,
2277
+ modification: {
2278
+ kind: "Updated",
2279
+ result: this.localQueryResultByToken(e)
2280
+ }
2281
+ }]
2282
+ };
2283
+ return this.onTransition(a), !0;
2284
+ }
2285
+ queriesContainingTokens(e) {
2286
+ if (e.length === 0) return [];
2287
+ let t = [], n = new Set(e);
2288
+ for (let [e, r] of this.paginatedQuerySet) for (let i of this.allQueryTokens(r)) if (n.has(i)) {
2289
+ t.push(e);
2290
+ break;
2291
+ }
2292
+ return t;
2293
+ }
2294
+ processPaginatedQuerySplits(e, t) {
2295
+ for (let n of e) {
2296
+ let e = this.mustGetPaginatedQuery(n), { ongoingSplits: r, pageKeyToQuery: i, pageKeys: a } = e;
2297
+ for (let [n, [a, o]] of r) t(i.get(a).queryToken) !== void 0 && t(i.get(o).queryToken) !== void 0 && this.completePaginatedQuerySplit(e, n, a, o);
2298
+ for (let n of a) {
2299
+ if (r.has(n)) continue;
2300
+ let a = i.get(n).queryToken, o = t(a);
2301
+ if (!o) continue;
2302
+ let s = Yn(o);
2303
+ s.splitCursor && (s.pageStatus === "SplitRecommended" || s.pageStatus === "SplitRequired" || s.page.length > e.options.initialNumItems * 2) && this.splitPaginatedQueryPage(e, n, s.splitCursor, s.continueCursor);
2304
+ }
2305
+ }
2306
+ }
2307
+ splitPaginatedQueryPage(e, t, n, r) {
2308
+ let i = e.nextPageKey++, a = e.nextPageKey++, o = {
2309
+ cursor: r,
2310
+ numItems: e.options.initialNumItems,
2311
+ id: e.id
2312
+ }, s = this.client.subscribe(e.canonicalizedUdfPath, {
2313
+ ...e.args,
2314
+ paginationOpts: {
2315
+ ...o,
2316
+ cursor: null,
2317
+ endCursor: n
2318
+ }
2319
+ });
2320
+ e.pageKeyToQuery.set(i, s);
2321
+ let c = this.client.subscribe(e.canonicalizedUdfPath, {
2322
+ ...e.args,
2323
+ paginationOpts: {
2324
+ ...o,
2325
+ cursor: n,
2326
+ endCursor: r
2327
+ }
2328
+ });
2329
+ e.pageKeyToQuery.set(a, c), e.ongoingSplits.set(t, [i, a]);
2330
+ }
2331
+ addPageToPaginatedQuery(e, t, n) {
2332
+ let r = this.mustGetPaginatedQuery(e), i = r.nextPageKey++, a = {
2333
+ cursor: t,
2334
+ numItems: n,
2335
+ id: r.id
2336
+ }, o = {
2337
+ ...r.args,
2338
+ paginationOpts: a
2339
+ }, s = this.client.subscribe(r.canonicalizedUdfPath, o);
2340
+ return r.pageKeys.push(i), r.pageKeyToQuery.set(i, s), s;
2341
+ }
2342
+ removePaginatedQuerySubscriber(e) {
2343
+ let t = this.paginatedQuerySet.get(e);
2344
+ if (t && (--t.numSubscribers, !(t.numSubscribers > 0))) {
2345
+ for (let e of t.pageKeyToQuery.values()) e.unsubscribe();
2346
+ this.paginatedQuerySet.delete(e);
2347
+ }
2348
+ }
2349
+ completePaginatedQuerySplit(e, t, n, r) {
2350
+ let i = e.pageKeyToQuery.get(t);
2351
+ e.pageKeyToQuery.delete(t);
2352
+ let a = e.pageKeys.indexOf(t);
2353
+ e.pageKeys.splice(a, 1, n, r), e.ongoingSplits.delete(t), i.unsubscribe();
2354
+ }
2355
+ activePageQueryTokens(e) {
2356
+ return e.pageKeys.map((t) => e.pageKeyToQuery.get(t).queryToken);
2357
+ }
2358
+ allQueryTokens(e) {
2359
+ return Array.from(e.pageKeyToQuery.values()).map((e) => e.queryToken);
2360
+ }
2361
+ queryTokenForLastPageOfPaginatedQuery(e) {
2362
+ let t = this.mustGetPaginatedQuery(e), n = t.pageKeys[t.pageKeys.length - 1];
2363
+ if (n === void 0) throw Error(`No pages for paginated query ${e}`);
2364
+ return t.pageKeyToQuery.get(n).queryToken;
2365
+ }
2366
+ mustGetPaginatedQuery(e) {
2367
+ let t = this.paginatedQuerySet.get(e);
2368
+ if (!t) throw Error("paginated query no longer exists for token " + e);
2369
+ return t;
2370
+ }
2371
+ }, er = Object.defineProperty, tr = (e, t, n) => t in e ? er(e, t, {
2372
+ enumerable: !0,
2373
+ configurable: !0,
2374
+ writable: !0,
2375
+ value: n
2376
+ }) : e[t] = n, nr = (e, t, n) => tr(e, typeof t == "symbol" ? t : t + "", n), rr, ir = class {
2377
+ constructor(e, t = {}) {
2378
+ nr(this, "listeners"), nr(this, "_client"), nr(this, "_paginatedClient"), nr(this, "callNewListenersWithCurrentValuesTimer"), nr(this, "_closed"), nr(this, "_disabled"), t.skipConvexDeploymentUrlCheck !== !0 && Ue(e);
2379
+ let { disabled: n, ...r } = t;
2380
+ this._closed = !1, this._disabled = !!n, rr && !("webSocketConstructor" in r) && typeof WebSocket > "u" && (r.webSocketConstructor = rr), typeof window > "u" && !("unsavedChangesWarning" in r) && (r.unsavedChangesWarning = !1), this.disabled || (this._client = new Jn(e, () => {}, r), this._paginatedClient = new $n(this._client, (e) => this._transition(e))), this.listeners = /* @__PURE__ */ new Set();
2381
+ }
2382
+ get closed() {
2383
+ return this._closed;
2384
+ }
2385
+ get client() {
2386
+ if (this._client) return this._client;
2387
+ throw Error("ConvexClient is disabled");
2388
+ }
2389
+ get paginatedClient() {
2390
+ if (this._paginatedClient) return this._paginatedClient;
2391
+ throw Error("ConvexClient is disabled");
2392
+ }
2393
+ get disabled() {
2394
+ return this._disabled;
2395
+ }
2396
+ onUpdate(e, t, n, r) {
2397
+ if (this.disabled) return this.createDisabledUnsubscribe();
2398
+ let { queryToken: i, unsubscribe: a } = this.client.subscribe(G(e), t), o = {
2399
+ queryToken: i,
2400
+ callback: n,
2401
+ onError: r,
2402
+ unsubscribe: a,
2403
+ hasEverRun: !1,
2404
+ query: e,
2405
+ args: t,
2406
+ paginationOptions: void 0
2407
+ };
2408
+ this.listeners.add(o), this.queryResultReady(i) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2409
+ let s = {
2410
+ unsubscribe: () => {
2411
+ this.closed || (this.listeners.delete(o), a());
2412
+ },
2413
+ getCurrentValue: () => this.client.localQueryResultByToken(i),
2414
+ getQueryLogs: () => this.client.localQueryLogs(i)
2415
+ }, c = s.unsubscribe;
2416
+ return Object.assign(c, s), c;
2417
+ }
2418
+ onPaginatedUpdate_experimental(e, t, n, r, i) {
2419
+ if (this.disabled) return this.createDisabledUnsubscribe();
2420
+ let a = {
2421
+ initialNumItems: n.initialNumItems,
2422
+ id: -1
2423
+ }, { paginatedQueryToken: o, unsubscribe: s } = this.paginatedClient.subscribe(G(e), t, a), c = {
2424
+ queryToken: o,
2425
+ callback: r,
2426
+ onError: i,
2427
+ unsubscribe: s,
2428
+ hasEverRun: !1,
2429
+ query: e,
2430
+ args: t,
2431
+ paginationOptions: a
2432
+ };
2433
+ this.listeners.add(c), this.paginatedClient.localQueryResultByToken(o) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2434
+ let l = {
2435
+ unsubscribe: () => {
2436
+ this.closed || (this.listeners.delete(c), s());
2437
+ },
2438
+ getCurrentValue: () => this.paginatedClient.localQueryResult(G(e), t, a),
2439
+ getQueryLogs: () => []
2440
+ }, u = l.unsubscribe;
2441
+ return Object.assign(u, l), u;
2442
+ }
2443
+ callNewListenersWithCurrentValues() {
2444
+ this.callNewListenersWithCurrentValuesTimer = void 0, this._transition({
2445
+ queries: [],
2446
+ paginatedQueries: []
2447
+ }, !0);
2448
+ }
2449
+ queryResultReady(e) {
2450
+ return this.client.hasLocalQueryResultByToken(e);
2451
+ }
2452
+ createDisabledUnsubscribe() {
2453
+ let e = (() => {});
2454
+ return Object.assign(e, {
2455
+ unsubscribe: e,
2456
+ getCurrentValue: () => void 0,
2457
+ getQueryLogs: () => void 0
2458
+ }), e;
2459
+ }
2460
+ async close() {
2461
+ if (!this.disabled) return this.listeners.clear(), this._closed = !0, this._paginatedClient &&= void 0, this.client.close();
2462
+ }
2463
+ getAuth() {
2464
+ if (!this.disabled) return this.client.getCurrentAuthClaims();
2465
+ }
2466
+ setAuth(e, t) {
2467
+ this.disabled || this.client.setAuth(e, t ?? (() => {}));
2468
+ }
2469
+ setAdminAuth(e, t) {
2470
+ if (this.closed) throw Error("ConvexClient has already been closed.");
2471
+ this.disabled || this.client.setAdminAuth(e, t);
2472
+ }
2473
+ _transition({ queries: e, paginatedQueries: t }, n = !1) {
2474
+ let r = [...e.map((e) => e.token), ...t.map((e) => e.token)];
2475
+ for (let e of this.listeners) {
2476
+ let { callback: t, queryToken: i, onError: a, hasEverRun: o } = e, s = Ft(i), c = s ? !!this.paginatedClient.localQueryResultByToken(i) : this.client.hasLocalQueryResultByToken(i);
2477
+ if (r.includes(i) || n && !o && c) {
2478
+ e.hasEverRun = !0;
2479
+ let n;
2480
+ try {
2481
+ n = s ? this.paginatedClient.localQueryResultByToken(i) : this.client.localQueryResultByToken(i);
2482
+ } catch (e) {
2483
+ if (!(e instanceof Error)) throw e;
2484
+ a ? a(e, "Second argument to onUpdate onError is reserved for later use") : Promise.reject(e);
2485
+ continue;
2486
+ }
2487
+ t(n, "Second argument to onUpdate callback is reserved for later use");
2488
+ }
2489
+ }
2490
+ }
2491
+ async mutation(e, t, n) {
2492
+ if (this.disabled) throw Error("ConvexClient is disabled");
2493
+ return await this.client.mutation(G(e), t, n);
2494
+ }
2495
+ async action(e, t) {
2496
+ if (this.disabled) throw Error("ConvexClient is disabled");
2497
+ return await this.client.action(G(e), t);
2498
+ }
2499
+ async query(e, t) {
2500
+ if (this.disabled) throw Error("ConvexClient is disabled");
2501
+ let n = this.client.localQueryResult(G(e), t);
2502
+ return n === void 0 ? new Promise((n, r) => {
2503
+ let { unsubscribe: i } = this.onUpdate(e, t, (e) => {
2504
+ i(), n(e);
2505
+ }, (e) => {
2506
+ i(), r(e);
2507
+ });
2508
+ }) : Promise.resolve(n);
2509
+ }
2510
+ connectionState() {
2511
+ if (this.disabled) throw Error("ConvexClient is disabled");
2512
+ return this.client.connectionState();
2513
+ }
2514
+ subscribeToConnectionState(e) {
2515
+ return this.disabled ? () => {} : this.client.subscribeToConnectionState(e);
2516
+ }
2517
+ }, ar = new Set([
2518
+ "role",
2519
+ "name",
2520
+ "aria-label",
2521
+ "rel",
2522
+ "href"
2523
+ ]);
2524
+ function or(e, t) {
2525
+ let n = ar.has(e);
2526
+ n ||= e.startsWith("data-") && fr(e);
2527
+ let r = fr(t) && t.length < 100;
2528
+ return r ||= t.startsWith("#") && fr(t.slice(1)), n && r;
2529
+ }
2530
+ function sr(e) {
2531
+ return fr(e);
2532
+ }
2533
+ function cr(e) {
2534
+ return fr(e);
2535
+ }
2536
+ function lr(e) {
2537
+ return !0;
2538
+ }
2539
+ function ur(e, t) {
2540
+ if (e.nodeType !== Node.ELEMENT_NODE) throw Error("Can't generate CSS selector for non-element node type.");
2541
+ if (e.tagName.toLowerCase() === "html") return "html";
2542
+ let n = {
2543
+ root: document.body,
2544
+ idName: sr,
2545
+ className: cr,
2546
+ tagName: lr,
2547
+ attr: or,
2548
+ timeoutMs: 1e3,
2549
+ seedMinLength: 3,
2550
+ optimizedMinLength: 2,
2551
+ maxNumberOfPathChecks: Infinity
2552
+ }, r = /* @__PURE__ */ new Date(), i = {
2553
+ ...n,
2554
+ ...t
2555
+ }, a = Sr(i.root, n), o, s = 0;
2556
+ for (let t of dr(e, i, a)) {
2557
+ if ((/* @__PURE__ */ new Date()).getTime() - r.getTime() > i.timeoutMs || s >= i.maxNumberOfPathChecks) {
2558
+ let t = vr(e, a);
2559
+ if (!t) throw Error(`Timeout: Can't find a unique selector after ${i.timeoutMs}ms`);
2560
+ return mr(t);
2561
+ }
2562
+ if (s++, Cr(t, a)) {
2563
+ o = t;
2564
+ break;
2565
+ }
2566
+ }
2567
+ if (!o) throw Error("Selector was not found.");
2568
+ let c = [...wr(o, e, i, a, r)];
2569
+ return c.sort(gr), c.length > 0 ? mr(c[0]) : mr(o);
2570
+ }
2571
+ function* dr(e, t, n) {
2572
+ let r = [], i = [], a = e, o = 0;
2573
+ for (; a && a !== n;) {
2574
+ let e = pr(a, t);
2575
+ for (let t of e) t.level = o;
2576
+ if (r.push(e), a = a.parentElement, o++, i.push(...xr(r)), o >= t.seedMinLength) {
2577
+ i.sort(gr);
2578
+ for (let e of i) yield e;
2579
+ i = [];
2580
+ }
2581
+ }
2582
+ i.sort(gr);
2583
+ for (let e of i) yield e;
2584
+ }
2585
+ function fr(e) {
2586
+ if (/^[a-z\-]{3,}$/i.test(e)) {
2587
+ let t = e.split(/-|[A-Z]/);
2588
+ for (let e of t) if (e.length <= 2 || /[^aeiou]{4,}/i.test(e)) return !1;
2589
+ return !0;
2590
+ }
2591
+ return !1;
2592
+ }
2593
+ function pr(e, t) {
2594
+ let n = [], r = e.getAttribute("id");
2595
+ r && t.idName(r) && n.push({
2596
+ name: "#" + CSS.escape(r),
2597
+ penalty: 0
2598
+ });
2599
+ for (let r = 0; r < e.classList.length; r++) {
2600
+ let i = e.classList[r];
2601
+ t.className(i) && n.push({
2602
+ name: "." + CSS.escape(i),
2603
+ penalty: 1
2604
+ });
2605
+ }
2606
+ for (let r = 0; r < e.attributes.length; r++) {
2607
+ let i = e.attributes[r];
2608
+ t.attr(i.name, i.value) && n.push({
2609
+ name: `[${CSS.escape(i.name)}="${CSS.escape(i.value)}"]`,
2610
+ penalty: 2
2611
+ });
2612
+ }
2613
+ let i = e.tagName.toLowerCase();
2614
+ if (t.tagName(i)) {
2615
+ n.push({
2616
+ name: i,
2617
+ penalty: 5
2618
+ });
2619
+ let t = _r(e, i);
2620
+ t !== void 0 && n.push({
2621
+ name: br(i, t),
2622
+ penalty: 10
2623
+ });
2624
+ }
2625
+ let a = _r(e);
2626
+ return a !== void 0 && n.push({
2627
+ name: yr(i, a),
2628
+ penalty: 50
2629
+ }), n;
2630
+ }
2631
+ function mr(e) {
2632
+ let t = e[0], n = t.name;
2633
+ for (let r = 1; r < e.length; r++) {
2634
+ let i = e[r].level || 0;
2635
+ n = t.level === i - 1 ? `${e[r].name} > ${n}` : `${e[r].name} ${n}`, t = e[r];
2636
+ }
2637
+ return n;
2638
+ }
2639
+ function hr(e) {
2640
+ return e.map((e) => e.penalty).reduce((e, t) => e + t, 0);
2641
+ }
2642
+ function gr(e, t) {
2643
+ return hr(e) - hr(t);
2644
+ }
2645
+ function _r(e, t) {
2646
+ let n = e.parentNode;
2647
+ if (!n) return;
2648
+ let r = n.firstChild;
2649
+ if (!r) return;
2650
+ let i = 0;
2651
+ for (; r && (r.nodeType === Node.ELEMENT_NODE && (t === void 0 || r.tagName.toLowerCase() === t) && i++, r !== e);) r = r.nextSibling;
2652
+ return i;
2653
+ }
2654
+ function vr(e, t) {
2655
+ let n = 0, r = e, i = [];
2656
+ for (; r && r !== t;) {
2657
+ let e = r.tagName.toLowerCase(), t = _r(r, e);
2658
+ if (t === void 0) return;
2659
+ i.push({
2660
+ name: br(e, t),
2661
+ penalty: NaN,
2662
+ level: n
2663
+ }), r = r.parentElement, n++;
2664
+ }
2665
+ if (Cr(i, t)) return i;
2666
+ }
2667
+ function yr(e, t) {
2668
+ return e === "html" ? "html" : `${e}:nth-child(${t})`;
2669
+ }
2670
+ function br(e, t) {
2671
+ return e === "html" ? "html" : `${e}:nth-of-type(${t})`;
2672
+ }
2673
+ function* xr(e, t = []) {
2674
+ if (e.length > 0) for (let n of e[0]) yield* xr(e.slice(1, e.length), t.concat(n));
2675
+ else yield t;
2676
+ }
2677
+ function Sr(e, t) {
2678
+ return e.nodeType === Node.DOCUMENT_NODE ? e : e === t.root ? e.ownerDocument : e;
2679
+ }
2680
+ function Cr(e, t) {
2681
+ let n = mr(e);
2682
+ switch (t.querySelectorAll(n).length) {
2683
+ case 0: throw Error(`Can't select any node with this selector: ${n}`);
2684
+ case 1: return !0;
2685
+ default: return !1;
2686
+ }
2687
+ }
2688
+ function* wr(e, t, n, r, i) {
2689
+ if (e.length > 2 && e.length > n.optimizedMinLength) for (let a = 1; a < e.length - 1; a++) {
2690
+ if ((/* @__PURE__ */ new Date()).getTime() - i.getTime() > n.timeoutMs) return;
2691
+ let o = [...e];
2692
+ o.splice(a, 1), Cr(o, r) && r.querySelector(mr(o)) === t && (yield o, yield* wr(o, t, n, r, i));
2693
+ }
2694
+ }
2695
+ //#endregion
2696
+ //#region src/runtime/anchor.ts
2697
+ function Tr(e, t) {
2698
+ let n = document.documentElement, r = Math.max(n.scrollWidth, n.clientWidth), i = Math.max(n.scrollHeight, n.clientHeight), a = e.clientX + window.scrollX, o = e.clientY + window.scrollY, s = t === void 0 ? e.target instanceof Element ? e.target : null : t, c = s ? Dr(s) : void 0, l, u;
2699
+ if (s) {
2700
+ let t = s.getBoundingClientRect();
2701
+ t.width > 0 && t.height > 0 && (l = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)), u = Math.max(0, Math.min(1, (e.clientY - t.top) / t.height)));
2702
+ }
2703
+ return {
2704
+ anchorX: r > 0 ? a / r : 0,
2705
+ anchorY: i > 0 ? o / i : 0,
2706
+ viewportW: window.innerWidth,
2707
+ viewportY: window.scrollY,
2708
+ anchorSelector: c,
2709
+ anchorOffsetX: l,
2710
+ anchorOffsetY: u
2711
+ };
2712
+ }
2713
+ function Er(e) {
2714
+ if (e.anchorSelector) try {
2715
+ let t = document.querySelector(e.anchorSelector);
2716
+ if (t) {
2717
+ let n = t.getBoundingClientRect();
2718
+ return {
2719
+ pageX: n.left + window.scrollX + (e.anchorOffsetX ?? .5) * n.width,
2720
+ pageY: n.top + window.scrollY + (e.anchorOffsetY ?? .5) * n.height
2721
+ };
2722
+ }
2723
+ } catch {}
2724
+ let t = document.documentElement, n = Math.max(t.scrollWidth, t.clientWidth), r = Math.max(t.scrollHeight, t.clientHeight);
2725
+ return {
2726
+ pageX: e.anchorX * n,
2727
+ pageY: e.anchorY * r
2728
+ };
2729
+ }
2730
+ function Dr(e) {
2731
+ try {
2732
+ return ur(e, { timeoutMs: 1e3 });
2733
+ } catch {
2734
+ return;
2735
+ }
2736
+ }
2737
+ //#endregion
2738
+ //#region src/runtime/api.ts
2739
+ var Or = class extends Error {
2740
+ status;
2741
+ constructor(e, t) {
2742
+ super(e), this.name = "WidgetApiError", this.status = t;
2743
+ }
2744
+ };
2745
+ function kr(e) {
2746
+ let t = e.apiUrl.replace(/\/+$/, "");
2747
+ async function n(n, r = {}) {
2748
+ let i = {
2749
+ "content-type": "application/json",
2750
+ "x-markup-api-key": e.apiKey,
2751
+ ...r.headers ?? {}
2752
+ }, a = e.getToken?.() ?? null, o = a != null && a.token.length > 0 && a.expiresAt > Date.now();
2753
+ o && a && (i.authorization = `Bearer ${a.token}`);
2754
+ let s = await fetch(`${t}${n}`, {
2755
+ ...r,
2756
+ headers: i
2757
+ }), c = await s.text(), l = c ? Ar(c) : null;
2758
+ if (!s.ok) throw s.status === 401 && o && e.onUnauthorized?.(), new Or((l && typeof l == "object" && "error" in l && typeof l.error == "string" ? l.error : null) ?? `Request failed with ${s.status}`, s.status);
2759
+ return l;
2760
+ }
2761
+ return {
2762
+ getScreenshotUploadUrl() {
2763
+ return n("/widget/screenshots/upload-url", { method: "POST" });
2764
+ },
2765
+ listThreads(e) {
2766
+ return n(`/widget/threads?route=${encodeURIComponent(e)}`, { method: "GET" });
2767
+ },
2768
+ createThread(e) {
2769
+ return n("/widget/threads", {
2770
+ method: "POST",
2771
+ body: JSON.stringify(e)
2772
+ });
2773
+ },
2774
+ deleteThread(e) {
2775
+ return n(`/widget/threads/${encodeURIComponent(e)}`, { method: "DELETE" });
2776
+ },
2777
+ resolveThread(e, t) {
2778
+ return n(`/widget/threads/${encodeURIComponent(e)}`, {
2779
+ method: "PATCH",
2780
+ body: JSON.stringify({ resolvedBy: t })
2781
+ });
2782
+ },
2783
+ addComment(e, t) {
2784
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments`, {
2785
+ method: "POST",
2786
+ body: JSON.stringify(t)
2787
+ });
2788
+ },
2789
+ editComment(e, t, r) {
2790
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2791
+ method: "PATCH",
2792
+ body: JSON.stringify(r)
2793
+ });
2794
+ },
2795
+ deleteComment(e, t, r = {}) {
2796
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2797
+ method: "DELETE",
2798
+ body: JSON.stringify(r)
2799
+ });
2800
+ },
2801
+ toggleReaction(e, t) {
2802
+ return n(`/widget/comments/${encodeURIComponent(e)}/reactions`, {
2803
+ method: "POST",
2804
+ body: JSON.stringify(t)
2805
+ });
2806
+ }
2807
+ };
2808
+ }
2809
+ function Ar(e) {
2810
+ try {
2811
+ return JSON.parse(e);
2812
+ } catch {
2813
+ return null;
2814
+ }
2815
+ }
2816
+ //#endregion
2817
+ //#region src/runtime/identity-store.ts
2818
+ var jr = "markup.identity";
2819
+ function Mr() {
2820
+ try {
2821
+ let e = localStorage.getItem(jr);
2822
+ if (!e) return null;
2823
+ let t = JSON.parse(e);
2824
+ return typeof t?.clientId == "string" ? t : null;
2825
+ } catch {
2826
+ return null;
2827
+ }
2828
+ }
2829
+ function Nr(e) {
2830
+ try {
2831
+ localStorage.setItem(jr, JSON.stringify(e));
2832
+ } catch {}
2833
+ }
2834
+ function Pr() {
2835
+ let e = crypto;
2836
+ if ("randomUUID" in e && typeof e.randomUUID == "function") return e.randomUUID();
2837
+ let t = new Uint8Array(16);
2838
+ e.getRandomValues(t), t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
2839
+ let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
2840
+ return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
2841
+ }
2842
+ //#endregion
2843
+ //#region src/runtime/popup-auth.ts
2844
+ function Fr(e, t) {
2845
+ let n = new URL(e).origin, r = new URL("/widget/auth", e);
2846
+ r.searchParams.set("apiKey", t), r.searchParams.set("origin", window.location.origin);
2847
+ let i = Math.max(0, window.screenX + (window.outerWidth - 420) / 2), a = Math.max(0, window.screenY + (window.outerHeight - 560) / 2), o = window.open(r.toString(), "markup-auth", `width=420,height=560,left=${i},top=${a}`);
2848
+ return o ? new Promise((e, t) => {
2849
+ function r() {
2850
+ window.removeEventListener("message", i), clearInterval(a);
2851
+ }
2852
+ function i(i) {
2853
+ if (i.origin !== n) return;
2854
+ let a = i.data;
2855
+ a?.type === "MARKUP_AUTH_RESULT" && (r(), a.identity?.id && a.identity?.name ? e({
2856
+ identity: a.identity,
2857
+ token: typeof a.token == "string" ? a.token : null,
2858
+ tokenExpiresAt: typeof a.tokenExpiresAt == "number" ? a.tokenExpiresAt : null
2859
+ }) : t(/* @__PURE__ */ Error("Sign-in cancelled")));
2860
+ }
2861
+ let a = window.setInterval(() => {
2862
+ o.closed && (r(), t(/* @__PURE__ */ Error("Sign-in cancelled")));
2863
+ }, 500);
2864
+ window.addEventListener("message", i);
2865
+ }) : Promise.reject(/* @__PURE__ */ Error("Popup blocked — allow popups for this site to sign in"));
2866
+ }
2867
+ //#endregion
2868
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/util.js
2869
+ function Ir(e, t) {
2870
+ if (e.match(/^[a-z]+:\/\//i)) return e;
2871
+ if (e.match(/^\/\//)) return window.location.protocol + e;
2872
+ if (e.match(/^[a-z]+:/i)) return e;
2873
+ let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
2874
+ return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
2875
+ }
2876
+ var Lr = (() => {
2877
+ let e = 0, t = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
2878
+ return () => (e += 1, `u${t()}${e}`);
2879
+ })();
2880
+ function Y(e) {
2881
+ let t = [];
2882
+ for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
2883
+ return t;
2884
+ }
2885
+ var Rr = null;
2886
+ function zr(e = {}) {
2887
+ return Rr || (e.includeStyleProperties ? (Rr = e.includeStyleProperties, Rr) : (Rr = Y(window.getComputedStyle(document.documentElement)), Rr));
2888
+ }
2889
+ function Br(e, t) {
2890
+ let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
2891
+ return n ? parseFloat(n.replace("px", "")) : 0;
2892
+ }
2893
+ function Vr(e) {
2894
+ let t = Br(e, "border-left-width"), n = Br(e, "border-right-width");
2895
+ return e.clientWidth + t + n;
2896
+ }
2897
+ function Hr(e) {
2898
+ let t = Br(e, "border-top-width"), n = Br(e, "border-bottom-width");
2899
+ return e.clientHeight + t + n;
2900
+ }
2901
+ function Ur(e, t = {}) {
2902
+ return {
2903
+ width: t.width || Vr(e),
2904
+ height: t.height || Hr(e)
2905
+ };
2906
+ }
2907
+ function Wr() {
2908
+ let e, t;
2909
+ try {
2910
+ t = process;
2911
+ } catch {}
2912
+ let n = t && t.env ? t.env.devicePixelRatio : null;
2913
+ return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
2914
+ }
2915
+ var X = 16384;
2916
+ function Gr(e) {
2917
+ (e.width > X || e.height > X) && (e.width > X && e.height > X ? e.width > e.height ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X) : e.width > X ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X));
2918
+ }
2919
+ function Kr(e) {
2920
+ return new Promise((t, n) => {
2921
+ let r = new Image();
2922
+ r.onload = () => {
2923
+ r.decode().then(() => {
2924
+ requestAnimationFrame(() => t(r));
2925
+ });
2926
+ }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
2927
+ });
2928
+ }
2929
+ async function qr(e) {
2930
+ return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
2931
+ }
2932
+ async function Jr(e, t, n) {
2933
+ let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
2934
+ return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), qr(i);
2935
+ }
2936
+ var Z = (e, t) => {
2937
+ if (e instanceof t) return !0;
2938
+ let n = Object.getPrototypeOf(e);
2939
+ return n === null ? !1 : n.constructor.name === t.name || Z(n, t);
2940
+ };
2941
+ //#endregion
2942
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-pseudos.js
2943
+ function Yr(e) {
2944
+ let t = e.getPropertyValue("content");
2945
+ return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
2946
+ }
2947
+ function Xr(e, t) {
2948
+ return zr(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
2949
+ }
2950
+ function Zr(e, t, n, r) {
2951
+ let i = `.${e}:${t}`, a = n.cssText ? Yr(n) : Xr(n, r);
2952
+ return document.createTextNode(`${i}{${a}}`);
2953
+ }
2954
+ function Qr(e, t, n, r) {
2955
+ let i = window.getComputedStyle(e, n), a = i.getPropertyValue("content");
2956
+ if (a === "" || a === "none") return;
2957
+ let o = Lr();
2958
+ try {
2959
+ t.className = `${t.className} ${o}`;
2960
+ } catch {
2961
+ return;
2962
+ }
2963
+ let s = document.createElement("style");
2964
+ s.appendChild(Zr(o, n, i, r)), t.appendChild(s);
2965
+ }
2966
+ function $r(e, t, n) {
2967
+ Qr(e, t, ":before", n), Qr(e, t, ":after", n);
2968
+ }
2969
+ //#endregion
2970
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/mimes.js
2971
+ var ei = "application/font-woff", ti = "image/jpeg", ni = {
2972
+ woff: ei,
2973
+ woff2: ei,
2974
+ ttf: "application/font-truetype",
2975
+ eot: "application/vnd.ms-fontobject",
2976
+ png: "image/png",
2977
+ jpg: ti,
2978
+ jpeg: ti,
2979
+ gif: "image/gif",
2980
+ tiff: "image/tiff",
2981
+ svg: "image/svg+xml",
2982
+ webp: "image/webp"
2983
+ };
2984
+ function ri(e) {
2985
+ let t = /\.([^./]*?)$/g.exec(e);
2986
+ return t ? t[1] : "";
2987
+ }
2988
+ function ii(e) {
2989
+ return ni[ri(e).toLowerCase()] || "";
2990
+ }
2991
+ //#endregion
2992
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/dataurl.js
2993
+ function ai(e) {
2994
+ return e.split(/,/)[1];
2995
+ }
2996
+ function oi(e) {
2997
+ return e.search(/^(data:)/) !== -1;
2998
+ }
2999
+ function si(e, t) {
3000
+ return `data:${t};base64,${e}`;
3001
+ }
3002
+ async function ci(e, t, n) {
3003
+ let r = await fetch(e, t);
3004
+ if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
3005
+ let i = await r.blob();
3006
+ return new Promise((e, t) => {
3007
+ let a = new FileReader();
3008
+ a.onerror = t, a.onloadend = () => {
3009
+ try {
3010
+ e(n({
3011
+ res: r,
3012
+ result: a.result
3013
+ }));
3014
+ } catch (e) {
3015
+ t(e);
3016
+ }
3017
+ }, a.readAsDataURL(i);
3018
+ });
3019
+ }
3020
+ var li = {};
3021
+ function ui(e, t, n) {
3022
+ let r = e.replace(/\?.*/, "");
3023
+ return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
3024
+ }
3025
+ async function di(e, t, n) {
3026
+ let r = ui(e, t, n.includeQueryParams);
3027
+ if (li[r] != null) return li[r];
3028
+ n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
3029
+ let i;
3030
+ try {
3031
+ i = si(await ci(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", ai(n))), t);
3032
+ } catch (t) {
3033
+ i = n.imagePlaceholder || "";
3034
+ let r = `Failed to fetch resource: ${e}`;
3035
+ t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
3036
+ }
3037
+ return li[r] = i, i;
3038
+ }
3039
+ //#endregion
3040
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-node.js
3041
+ async function fi(e) {
3042
+ let t = e.toDataURL();
3043
+ return t === "data:," ? e.cloneNode(!1) : Kr(t);
3044
+ }
3045
+ async function pi(e, t) {
3046
+ if (e.currentSrc) {
3047
+ let t = document.createElement("canvas"), n = t.getContext("2d");
3048
+ return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), Kr(t.toDataURL());
3049
+ }
3050
+ let n = e.poster;
3051
+ return Kr(await di(n, ii(n), t));
3052
+ }
3053
+ async function mi(e, t) {
3054
+ try {
3055
+ if (e?.contentDocument?.body) return await wi(e.contentDocument.body, t, !0);
3056
+ } catch {}
3057
+ return e.cloneNode(!1);
3058
+ }
3059
+ async function hi(e, t) {
3060
+ return Z(e, HTMLCanvasElement) ? fi(e) : Z(e, HTMLVideoElement) ? pi(e, t) : Z(e, HTMLIFrameElement) ? mi(e, t) : e.cloneNode(_i(e));
3061
+ }
3062
+ var gi = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", _i = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
3063
+ async function vi(e, t, n) {
3064
+ if (_i(t)) return t;
3065
+ let r = [];
3066
+ return r = gi(e) && e.assignedNodes ? Y(e.assignedNodes()) : Z(e, HTMLIFrameElement) && e.contentDocument?.body ? Y(e.contentDocument.body.childNodes) : Y((e.shadowRoot ?? e).childNodes), r.length === 0 || Z(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => wi(r, n)).then((e) => {
3067
+ e && t.appendChild(e);
3068
+ }), Promise.resolve()), t;
3069
+ }
3070
+ function yi(e, t, n) {
3071
+ let r = t.style;
3072
+ if (!r) return;
3073
+ let i = window.getComputedStyle(e);
3074
+ i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : zr(n).forEach((n) => {
3075
+ let a = i.getPropertyValue(n);
3076
+ n === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), Z(e, HTMLIFrameElement) && n === "display" && a === "inline" && (a = "block"), n === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), r.setProperty(n, a, i.getPropertyPriority(n));
3077
+ });
3078
+ }
3079
+ function bi(e, t) {
3080
+ Z(e, HTMLTextAreaElement) && (t.innerHTML = e.value), Z(e, HTMLInputElement) && t.setAttribute("value", e.value);
3081
+ }
3082
+ function xi(e, t) {
3083
+ if (Z(e, HTMLSelectElement)) {
3084
+ let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
3085
+ r && r.setAttribute("selected", "");
3086
+ }
3087
+ }
3088
+ function Si(e, t, n) {
3089
+ return Z(t, Element) && (yi(e, t, n), $r(e, t, n), bi(e, t), xi(e, t)), t;
3090
+ }
3091
+ async function Ci(e, t) {
3092
+ let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
3093
+ if (n.length === 0) return e;
3094
+ let r = {};
3095
+ for (let i = 0; i < n.length; i++) {
3096
+ let a = n[i].getAttribute("xlink:href");
3097
+ if (a) {
3098
+ let n = e.querySelector(a), i = document.querySelector(a);
3099
+ !n && i && !r[a] && (r[a] = await wi(i, t, !0));
3100
+ }
3101
+ }
3102
+ let i = Object.values(r);
3103
+ if (i.length) {
3104
+ let t = "http://www.w3.org/1999/xhtml", n = document.createElementNS(t, "svg");
3105
+ n.setAttribute("xmlns", t), n.style.position = "absolute", n.style.width = "0", n.style.height = "0", n.style.overflow = "hidden", n.style.display = "none";
3106
+ let r = document.createElementNS(t, "defs");
3107
+ n.appendChild(r);
3108
+ for (let e = 0; e < i.length; e++) r.appendChild(i[e]);
3109
+ e.appendChild(n);
3110
+ }
3111
+ return e;
3112
+ }
3113
+ async function wi(e, t, n) {
3114
+ return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => hi(e, t)).then((n) => vi(e, n, t)).then((n) => Si(e, n, t)).then((e) => Ci(e, t));
3115
+ }
3116
+ //#endregion
3117
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-resources.js
3118
+ var Ti = /url\((['"]?)([^'"]+?)\1\)/g, Ei = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Di = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
3119
+ function Oi(e) {
3120
+ let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
3121
+ return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
3122
+ }
3123
+ function ki(e) {
3124
+ let t = [];
3125
+ return e.replace(Ti, (e, n, r) => (t.push(r), e)), t.filter((e) => !oi(e));
3126
+ }
3127
+ async function Ai(e, t, n, r, i) {
3128
+ try {
3129
+ let a = n ? Ir(t, n) : t, o = ii(t), s;
3130
+ return s = i ? si(await i(a), o) : await di(a, o, r), e.replace(Oi(t), `$1${s}$3`);
3131
+ } catch {}
3132
+ return e;
3133
+ }
3134
+ function ji(e, { preferredFontFormat: t }) {
3135
+ return t ? e.replace(Di, (e) => {
3136
+ for (;;) {
3137
+ let [n, , r] = Ei.exec(e) || [];
3138
+ if (!r) return "";
3139
+ if (r === t) return `src: ${n};`;
3140
+ }
3141
+ }) : e;
3142
+ }
3143
+ function Mi(e) {
3144
+ return e.search(Ti) !== -1;
3145
+ }
3146
+ async function Ni(e, t, n) {
3147
+ if (!Mi(e)) return e;
3148
+ let r = ji(e, n);
3149
+ return ki(r).reduce((e, r) => e.then((e) => Ai(e, r, t, n)), Promise.resolve(r));
3150
+ }
3151
+ //#endregion
3152
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-images.js
3153
+ async function Pi(e, t, n) {
3154
+ let r = t.style?.getPropertyValue(e);
3155
+ if (r) {
3156
+ let i = await Ni(r, null, n);
3157
+ return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
3158
+ }
3159
+ return !1;
3160
+ }
3161
+ async function Fi(e, t) {
3162
+ await Pi("background", e, t) || await Pi("background-image", e, t), await Pi("mask", e, t) || await Pi("-webkit-mask", e, t) || await Pi("mask-image", e, t) || await Pi("-webkit-mask-image", e, t);
3163
+ }
3164
+ async function Ii(e, t) {
3165
+ let n = Z(e, HTMLImageElement);
3166
+ if (!(n && !oi(e.src)) && !(Z(e, SVGImageElement) && !oi(e.href.baseVal))) return;
3167
+ let r = n ? e.src : e.href.baseVal, i = await di(r, ii(r), t);
3168
+ await new Promise((r, a) => {
3169
+ e.onload = r, e.onerror = t.onImageErrorHandler ? (...e) => {
3170
+ try {
3171
+ r(t.onImageErrorHandler(...e));
3172
+ } catch (e) {
3173
+ a(e);
3174
+ }
3175
+ } : a;
3176
+ let o = e;
3177
+ o.decode &&= r, o.loading === "lazy" && (o.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
3178
+ });
3179
+ }
3180
+ async function Li(e, t) {
3181
+ let n = Y(e.childNodes).map((e) => Ri(e, t));
3182
+ await Promise.all(n).then(() => e);
3183
+ }
3184
+ async function Ri(e, t) {
3185
+ Z(e, Element) && (await Fi(e, t), await Ii(e, t), await Li(e, t));
3186
+ }
3187
+ //#endregion
3188
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/apply-style.js
3189
+ function zi(e, t) {
3190
+ let { style: n } = e;
3191
+ t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
3192
+ let r = t.style;
3193
+ return r != null && Object.keys(r).forEach((e) => {
3194
+ n[e] = r[e];
3195
+ }), e;
3196
+ }
3197
+ //#endregion
3198
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-webfonts.js
3199
+ var Bi = {};
3200
+ async function Vi(e) {
3201
+ let t = Bi[e];
3202
+ return t ?? (t = {
3203
+ url: e,
3204
+ cssText: await (await fetch(e)).text()
3205
+ }, Bi[e] = t, t);
3206
+ }
3207
+ async function Hi(e, t) {
3208
+ let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
3209
+ let a = i.replace(r, "$1");
3210
+ return a.startsWith("https://") || (a = new URL(a, e.url).href), ci(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
3211
+ });
3212
+ return Promise.all(i).then(() => n);
3213
+ }
3214
+ function Ui(e) {
3215
+ if (e == null) return [];
3216
+ let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
3217
+ for (;;) {
3218
+ let e = r.exec(n);
3219
+ if (e === null) break;
3220
+ t.push(e[0]);
3221
+ }
3222
+ n = n.replace(r, "");
3223
+ let i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
3224
+ for (;;) {
3225
+ let e = i.exec(n);
3226
+ if (e === null) {
3227
+ if (e = a.exec(n), e === null) break;
3228
+ i.lastIndex = a.lastIndex;
3229
+ } else a.lastIndex = i.lastIndex;
3230
+ t.push(e[0]);
3231
+ }
3232
+ return t;
3233
+ }
3234
+ async function Wi(e, t) {
3235
+ let n = [], r = [];
3236
+ return e.forEach((n) => {
3237
+ if ("cssRules" in n) try {
3238
+ Y(n.cssRules || []).forEach((e, i) => {
3239
+ if (e.type === CSSRule.IMPORT_RULE) {
3240
+ let a = i + 1, o = e.href, s = Vi(o).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3241
+ try {
3242
+ n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
3243
+ } catch (t) {
3244
+ console.error("Error inserting rule from remote css", {
3245
+ rule: e,
3246
+ error: t
3247
+ });
3248
+ }
3249
+ })).catch((e) => {
3250
+ console.error("Error loading remote css", e.toString());
3251
+ });
3252
+ r.push(s);
3253
+ }
3254
+ });
3255
+ } catch (i) {
3256
+ let a = e.find((e) => e.href == null) || document.styleSheets[0];
3257
+ n.href != null && r.push(Vi(n.href).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3258
+ a.insertRule(e, a.cssRules.length);
3259
+ })).catch((e) => {
3260
+ console.error("Error loading remote stylesheet", e);
3261
+ })), console.error("Error inlining remote css file", i);
3262
+ }
3263
+ }), Promise.all(r).then(() => (e.forEach((e) => {
3264
+ if ("cssRules" in e) try {
3265
+ Y(e.cssRules || []).forEach((e) => {
3266
+ n.push(e);
3267
+ });
3268
+ } catch (t) {
3269
+ console.error(`Error while reading CSS rules from ${e.href}`, t);
3270
+ }
3271
+ }), n));
3272
+ }
3273
+ function Gi(e) {
3274
+ return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => Mi(e.style.getPropertyValue("src")));
3275
+ }
3276
+ async function Ki(e, t) {
3277
+ if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
3278
+ return Gi(await Wi(Y(e.ownerDocument.styleSheets), t));
3279
+ }
3280
+ function qi(e) {
3281
+ return e.trim().replace(/["']/g, "");
3282
+ }
3283
+ function Ji(e) {
3284
+ let t = /* @__PURE__ */ new Set();
3285
+ function n(e) {
3286
+ (e.style.fontFamily || getComputedStyle(e).fontFamily).split(",").forEach((e) => {
3287
+ t.add(qi(e));
3288
+ }), Array.from(e.children).forEach((e) => {
3289
+ e instanceof HTMLElement && n(e);
3290
+ });
3291
+ }
3292
+ return n(e), t;
3293
+ }
3294
+ async function Yi(e, t) {
3295
+ let n = await Ki(e, t), r = Ji(e);
3296
+ return (await Promise.all(n.filter((e) => r.has(qi(e.style.fontFamily))).map((e) => {
3297
+ let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
3298
+ return Ni(e.cssText, n, t);
3299
+ }))).join("\n");
3300
+ }
3301
+ async function Xi(e, t) {
3302
+ let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await Yi(e, t) : t.fontEmbedCSS;
3303
+ if (n) {
3304
+ let t = document.createElement("style"), r = document.createTextNode(n);
3305
+ t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
3306
+ }
3307
+ }
3308
+ //#endregion
3309
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/index.js
3310
+ async function Zi(e, t = {}) {
3311
+ let { width: n, height: r } = Ur(e, t), i = await wi(e, t, !0);
3312
+ return await Xi(i, t), await Ri(i, t), zi(i, t), await Jr(i, n, r);
3313
+ }
3314
+ async function Qi(e, t = {}) {
3315
+ let { width: n, height: r } = Ur(e, t), i = await Kr(await Zi(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || Wr(), c = t.canvasWidth || n, l = t.canvasHeight || r;
3316
+ return a.width = c * s, a.height = l * s, t.skipAutoScale || Gr(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
3317
+ }
3318
+ //#endregion
3319
+ //#region src/runtime/screenshot.ts
3320
+ var $i = 2 * 1024 * 1024;
3321
+ async function ea(e, t) {
3322
+ try {
3323
+ function n(t) {
3324
+ return !(e && (t === e || e.contains(t)));
3325
+ }
3326
+ let r = window.innerWidth, i = window.innerHeight, a = Math.min(window.devicePixelRatio, 2), o = await Qi(document.documentElement, {
3327
+ width: r,
3328
+ height: i,
3329
+ cacheBust: !0,
3330
+ backgroundColor: "#ffffff",
3331
+ pixelRatio: a,
3332
+ filter: n,
3333
+ style: {
3334
+ transform: `translateY(-${window.scrollY}px)`,
3335
+ transformOrigin: "top left"
3336
+ }
3337
+ });
3338
+ if (t) {
3339
+ let e = o.getContext("2d");
3340
+ e && na(e, t.x, t.y, a);
3341
+ }
3342
+ let s = await ta(o, .85);
3343
+ if (!s) return null;
3344
+ if (s.size <= $i) return s;
3345
+ let c = await ta(o, .5);
3346
+ return !c || c.size > $i ? null : c;
3347
+ } catch {
3348
+ return null;
3349
+ }
3350
+ }
3351
+ function ta(e, t) {
3352
+ return new Promise((n) => e.toBlob(n, "image/jpeg", t));
3353
+ }
3354
+ function na(e, t, n, r) {
3355
+ let i = r, a = 28 * i, o = a / 2, s = t * i, c = n * i;
3356
+ e.save(), e.translate(s, c), e.rotate(-Math.PI / 4);
3357
+ let l = 2 * i;
3358
+ e.beginPath(), e.roundRect(-o - l, -o - l, a + l * 2, a + l * 2, [
3359
+ 14 * i + l,
3360
+ 14 * i + l,
3361
+ 14 * i + l,
3362
+ 4 * i + l
3363
+ ]), e.fillStyle = "#ffffff", e.fill(), e.beginPath(), e.roundRect(-o, -o, a, a, [
3364
+ 14 * i,
3365
+ 14 * i,
3366
+ 14 * i,
3367
+ 4 * i
3368
+ ]), e.fillStyle = "#1a1614", e.fill(), e.rotate(Math.PI / 4), e.beginPath(), e.arc(0, 0, 3 * i, 0, Math.PI * 2), e.fillStyle = "rgba(255, 255, 255, 0.85)", e.fill(), e.restore();
3369
+ }
3370
+ //#endregion
3371
+ //#region src/runtime/utils.ts
3372
+ function Q(...e) {
3373
+ return e.filter(Boolean).join(" ");
3374
+ }
3375
+ //#endregion
3376
+ //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
3377
+ var ra = 0;
3378
+ Array.isArray;
3379
+ function $(e, n, r, i, a, o) {
3380
+ n ||= {};
3381
+ var s, c, l = n;
3382
+ if ("ref" in l) for (c in l = {}, n) c == "ref" ? s = n[c] : l[c] = n[c];
3383
+ var u = {
3384
+ type: e,
3385
+ props: l,
3386
+ key: r,
3387
+ ref: s,
3388
+ __k: null,
3389
+ __: null,
3390
+ __b: 0,
3391
+ __e: null,
3392
+ __c: null,
3393
+ constructor: void 0,
3394
+ __v: --ra,
3395
+ __i: -1,
3396
+ __u: 0,
3397
+ __source: a,
3398
+ __self: o
3399
+ };
3400
+ if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
3401
+ return t.vnode && t.vnode(u), u;
3402
+ }
3403
+ //#endregion
3404
+ //#region src/runtime/ui/icons.tsx
3405
+ function ia({ size: e = 16 }) {
3406
+ return /* @__PURE__ */ $("svg", {
3407
+ width: e,
3408
+ height: e,
3409
+ viewBox: "0 0 126 126",
3410
+ fill: "currentColor",
3411
+ "aria-hidden": !0,
3412
+ children: /* @__PURE__ */ $("path", { d: "M63.4561 0.00557731C70.6277 -0.0175584 76.9025 1.04088 83.5898 3.71066C97.7952 9.43043 109.186 20.5001 115.311 34.5359C119.708 44.8002 120.746 54.7869 119.156 65.8171C116.857 82.7956 105.129 98.8382 90.0566 106.846C83.4394 110.362 74.7336 113.029 67.2051 113.271C62.4204 113.425 61.1274 113.32 56.6807 115.204C50.2035 117.858 43.6874 120.417 37.1348 122.879C34.8442 123.763 32.3203 124.902 29.9404 125.51C29.4023 125.648 28.1978 125.009 27.7598 124.646C26.9046 123.951 27.0582 122.505 27.0264 121.484C26.8123 114.646 27.3302 107.458 26.8604 100.656C25.1578 98.6714 22.4026 96.603 20.3086 94.1989C12.1853 84.8731 7.05334 73.9949 6.18164 61.6101C4.95583 46.292 9.97176 31.1285 20.0908 19.5632C29.989 8.13202 44.0369 1.11921 59.1221 0.0788195C60.2694 -0.0356049 62.2637 0.00944821 63.4561 0.00557731ZM92.2676 55.7497C91.5754 39.5314 77.8207 26.9725 61.6064 27.7536C45.5175 28.5287 33.0758 42.1537 33.7627 58.2468C34.4496 74.3398 48.007 86.8553 64.1035 86.2566C80.3254 85.6533 92.9599 71.968 92.2676 55.7497Z" })
3413
+ });
3414
+ }
3415
+ function aa({ size: e = 16 }) {
3416
+ return /* @__PURE__ */ $("svg", {
3417
+ width: e,
3418
+ height: e,
3419
+ viewBox: "0 0 20 20",
3420
+ fill: "currentColor",
3421
+ children: /* @__PURE__ */ $("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
3422
+ });
3423
+ }
3424
+ function oa({ size: e = 16 }) {
3425
+ return /* @__PURE__ */ $("svg", {
3426
+ width: e,
3427
+ height: e,
3428
+ viewBox: "0 0 20 20",
3429
+ fill: "currentColor",
3430
+ children: /* @__PURE__ */ $("path", { d: "M3 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM8.5 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM15.5 8.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z" })
3431
+ });
3432
+ }
3433
+ function sa({ size: e = 16 }) {
3434
+ return /* @__PURE__ */ $("svg", {
3435
+ width: e,
3436
+ height: e,
3437
+ viewBox: "0 0 16 16",
3438
+ fill: "currentColor",
3439
+ children: /* @__PURE__ */ $("path", {
3440
+ fillRule: "evenodd",
3441
+ d: "M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z",
3442
+ clipRule: "evenodd"
3443
+ })
3444
+ });
3445
+ }
3446
+ function ca({ size: e = 16 }) {
3447
+ return /* @__PURE__ */ $("svg", {
3448
+ width: e,
3449
+ height: e,
3450
+ viewBox: "0 0 20 20",
3451
+ fill: "currentColor",
3452
+ "aria-hidden": !0,
3453
+ children: /* @__PURE__ */ $("path", {
3454
+ "fill-rule": "evenodd",
3455
+ d: "M1 8a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 8.07 3h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 16.07 6H17a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8Zm13.5 3a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM10 14a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",
3456
+ "clip-rule": "evenodd"
3457
+ })
3458
+ });
3459
+ }
3460
+ function la({ size: e = 16 }) {
3461
+ return /* @__PURE__ */ $("svg", {
3462
+ width: e,
3463
+ height: e,
3464
+ viewBox: "0 0 16 16",
3465
+ fill: "currentColor",
3466
+ children: /* @__PURE__ */ $("path", { d: "M2.87 2.298a.75.75 0 0 0-.812 1.021L3.39 6.624a1 1 0 0 0 .928.626H8.25a.75.75 0 0 1 0 1.5H4.318a1 1 0 0 0-.927.626l-1.333 3.305a.75.75 0 0 0 .811 1.022 24.89 24.89 0 0 0 11.668-5.115.75.75 0 0 0 0-1.175A24.89 24.89 0 0 0 2.869 2.298Z" })
3467
+ });
3468
+ }
3469
+ function ua({ size: e = 16 }) {
3470
+ return /* @__PURE__ */ $("svg", {
3471
+ width: e,
3472
+ height: e,
3473
+ viewBox: "0 0 256 256",
3474
+ fill: "currentColor",
3475
+ "aria-hidden": !0,
3476
+ children: /* @__PURE__ */ $("path", { d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM80,108a12,12,0,1,1,12,12A12,12,0,0,1,80,108Zm96,0a12,12,0,1,1-12-12A12,12,0,0,1,176,108Zm-1.07,48c-10.29,17.79-27.4,28-46.93,28s-36.63-10.2-46.92-28a8,8,0,1,1,13.84-8c7.47,12.91,19.21,20,33.08,20s25.61-7.1,33.07-20a8,8,0,0,1,13.86,8Z" })
3477
+ });
3478
+ }
3479
+ //#endregion
3480
+ //#region src/runtime/ui/fab.tsx
3481
+ function da({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" }) {
3482
+ return /* @__PURE__ */ $("button", {
3483
+ type: "button",
3484
+ class: Q("markup-fab", r === "bottom-left" ? "markup-fab-left" : "markup-fab-right", e && "is-active"),
3485
+ onClick: (e) => {
3486
+ if (e.preventDefault(), e.stopPropagation(), (e.metaKey || e.ctrlKey) && n) {
3487
+ n();
3488
+ return;
3489
+ }
3490
+ t();
3491
+ },
3492
+ onPointerDown: (e) => {
3493
+ e.preventDefault(), e.stopPropagation();
3494
+ },
3495
+ "aria-label": e ? "Cancel placing markup" : "Leave a markup",
3496
+ "aria-pressed": e,
3497
+ children: [/* @__PURE__ */ $("span", {
3498
+ class: "markup-fab-icon",
3499
+ children: $(e ? aa : ia, { size: 16 })
3500
+ }), /* @__PURE__ */ $("span", {
3501
+ class: "markup-fab-label",
3502
+ children: e ? "Cancel" : "Markup"
3503
+ })]
3504
+ });
3505
+ }
3506
+ //#endregion
3507
+ //#region src/runtime/use-focus-trap.ts
3508
+ var fa = [
3509
+ "a[href]",
3510
+ "button:not([disabled])",
3511
+ "input:not([disabled])",
3512
+ "select:not([disabled])",
3513
+ "textarea:not([disabled])",
3514
+ "[tabindex]:not([tabindex=\"-1\"])"
3515
+ ].join(",");
3516
+ function pa(e, t) {
3517
+ R(() => {
3518
+ if (!t) return;
3519
+ let n = e.current;
3520
+ if (!n) return;
3521
+ function r(e) {
3522
+ if (e.key !== "Tab") return;
3523
+ let t = Array.from(n.querySelectorAll(fa)), r = t[0], i = t[t.length - 1];
3524
+ if (!r || !i) return;
3525
+ let a = n.getRootNode(), o = a instanceof ShadowRoot ? a.activeElement : document.activeElement;
3526
+ (e.shiftKey ? o === r : o === i) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
3527
+ }
3528
+ return n.addEventListener("keydown", r), () => n.removeEventListener("keydown", r);
3529
+ }, [e, t]);
3530
+ }
3531
+ //#endregion
3532
+ //#region src/runtime/ui/author-prompt.tsx
3533
+ function ma({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3534
+ let [i, a] = L(""), [o, s] = L(""), c = z(null);
3535
+ R(() => {
3536
+ c.current?.focus();
3537
+ }, []);
3538
+ function l(n) {
3539
+ n?.preventDefault();
3540
+ let r = i.trim();
3541
+ !r || e || t(r, o.trim() || void 0);
3542
+ }
3543
+ return /* @__PURE__ */ $("form", {
3544
+ class: "markup-author-prompt",
3545
+ onSubmit: l,
3546
+ children: [
3547
+ r ? /* @__PURE__ */ $(S, { children: [/* @__PURE__ */ $("button", {
3548
+ type: "button",
3549
+ class: "markup-btn markup-btn-primary",
3550
+ onClick: r,
3551
+ disabled: e,
3552
+ children: "Sign in with Markup"
3553
+ }), /* @__PURE__ */ $("p", {
3554
+ class: "markup-author-divider",
3555
+ children: "or continue as a guest"
3556
+ })] }) : /* @__PURE__ */ $("p", {
3557
+ class: "markup-eyebrow",
3558
+ children: "who's leaving feedback?"
3559
+ }),
3560
+ /* @__PURE__ */ $("input", {
3561
+ ref: c,
3562
+ class: "markup-input",
3563
+ type: "text",
3564
+ name: "name",
3565
+ placeholder: "Your name",
3566
+ value: i,
3567
+ maxLength: 80,
3568
+ autoComplete: "name",
3569
+ onInput: (e) => a(e.currentTarget.value),
3570
+ disabled: e,
3571
+ "data-1p-ignore": !0
3572
+ }),
3573
+ /* @__PURE__ */ $("input", {
3574
+ class: "markup-input",
3575
+ type: "email",
3576
+ name: "email",
3577
+ placeholder: "Email (optional)",
3578
+ value: o,
3579
+ maxLength: 254,
3580
+ autoComplete: "email",
3581
+ onInput: (e) => s(e.currentTarget.value),
3582
+ disabled: e,
3583
+ "data-1p-ignore": !0
3584
+ }),
3585
+ /* @__PURE__ */ $("div", {
3586
+ class: "markup-composer-actions",
3587
+ children: [/* @__PURE__ */ $("button", {
3588
+ type: "button",
3589
+ class: "markup-btn markup-btn-ghost",
3590
+ onClick: n,
3591
+ disabled: e,
3592
+ children: "Cancel"
3593
+ }), /* @__PURE__ */ $("button", {
3594
+ type: "submit",
3595
+ class: "markup-btn markup-btn-primary",
3596
+ disabled: !i.trim() || e,
3597
+ children: "Continue"
3598
+ })]
3599
+ })
3600
+ ]
3601
+ });
3602
+ }
3603
+ //#endregion
3604
+ //#region src/runtime/ui/composer.tsx
3605
+ var ha = 4e3;
3606
+ function ga({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "Post", initialFocus: r = !0, pending: i, error: a, onSubmit: o }) {
3607
+ let [s, c] = L(""), l = z(null), u = z(!1);
3608
+ R(() => {
3609
+ r && l.current?.focus();
3610
+ }, [r]), R(() => {
3611
+ let e = l.current;
3612
+ e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 160)}px`);
3613
+ }, [s]), R(() => {
3614
+ u.current && !i && !a && (c(""), l.current?.focus()), u.current = i;
3615
+ }, [i, a]);
3616
+ function d(e) {
3617
+ e?.preventDefault();
3618
+ let t = s.trim();
3619
+ !t || i || o(t);
3620
+ }
3621
+ function f(e) {
3622
+ (e.metaKey || e.ctrlKey) && e.key === "Enter" && d(e);
3623
+ }
3624
+ let p = ha - s.length, m = p < 0, h = s.length > 0;
3625
+ function g(e) {
3626
+ return /* @__PURE__ */ $("button", {
3627
+ type: "submit",
3628
+ class: "markup-btn markup-btn-primary",
3629
+ disabled: i || !s.trim() || m,
3630
+ "aria-label": i ? "Sending…" : n,
3631
+ title: i ? "Sending…" : n,
3632
+ tabIndex: e,
3633
+ children: /* @__PURE__ */ $(la, { size: 14 })
3634
+ });
3635
+ }
3636
+ return /* @__PURE__ */ $("form", {
3637
+ class: Q("markup-composer", h && "is-filled"),
3638
+ onSubmit: d,
3639
+ children: [
3640
+ /* @__PURE__ */ $("textarea", {
3641
+ ref: l,
3642
+ name: "reply",
3643
+ class: "markup-composer-input",
3644
+ placeholder: t,
3645
+ rows: h ? 2 : 1,
3646
+ maxLength: ha + 100,
3647
+ value: s,
3648
+ onInput: (e) => c(e.currentTarget.value),
3649
+ onKeyDown: f,
3650
+ disabled: i,
3651
+ "aria-label": e
3652
+ }),
3653
+ /* @__PURE__ */ $("div", {
3654
+ class: "markup-composer-footer-wrap",
3655
+ children: /* @__PURE__ */ $("div", {
3656
+ class: "markup-composer-footer",
3657
+ children: [/* @__PURE__ */ $("span", {
3658
+ class: "markup-composer-hint",
3659
+ children: a ? /* @__PURE__ */ $("span", {
3660
+ class: "markup-composer-error",
3661
+ children: a
3662
+ }) : m ? /* @__PURE__ */ $("span", {
3663
+ class: "markup-composer-error",
3664
+ children: [Math.abs(p), " too long"]
3665
+ }) : /* @__PURE__ */ $("span", { children: "⌘↵ to send" })
3666
+ }), /* @__PURE__ */ $("div", {
3667
+ class: "markup-composer-actions",
3668
+ children: g(h ? void 0 : -1)
3669
+ })]
3670
+ })
3671
+ }),
3672
+ /* @__PURE__ */ $("span", {
3673
+ class: "markup-composer-actions-empty",
3674
+ "aria-hidden": h || void 0,
3675
+ children: g(h ? -1 : void 0)
3676
+ })
3677
+ ]
3678
+ });
3679
+ }
3680
+ //#endregion
3681
+ //#region src/runtime/ui/new-thread-popover.tsx
3682
+ function _a({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, error: a, screenshot: o, screenshotCapturing: s, onAuthor: c, onSignIn: l, onSubmit: u, onClose: d }) {
3683
+ let f = z(null);
3684
+ pa(f, !0);
3685
+ let [p, m] = L(!1), [h, g] = L(null);
3686
+ R(() => {
3687
+ if (!o) return;
3688
+ let e = URL.createObjectURL(o);
3689
+ return g(e), () => URL.revokeObjectURL(e);
3690
+ }, [o]), R(() => {
3691
+ let e = f.current;
3692
+ if (!e) return;
3693
+ if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3694
+ e.showPopover();
3695
+ } catch {}
3696
+ function t(e) {
3697
+ e.newState === "closed" && d();
3698
+ }
3699
+ return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3700
+ }, [d]);
3701
+ let _ = va(e - window.scrollX + 16, 12, window.innerWidth - 320 - 12), v = va(t - window.scrollY - 16, 12, window.innerHeight - 220), y = o != null, b = s || y;
3702
+ return /* @__PURE__ */ $("div", {
3703
+ ref: f,
3704
+ class: "markup-popover",
3705
+ popover: "auto",
3706
+ style: {
3707
+ "--markup-pop-x": `${_}px`,
3708
+ "--markup-pop-y": `${v}px`
3709
+ },
3710
+ role: "dialog",
3711
+ "aria-label": "New markup",
3712
+ children: [/* @__PURE__ */ $("header", {
3713
+ class: "markup-popover-header",
3714
+ children: [/* @__PURE__ */ $("span", {
3715
+ class: "markup-eyebrow",
3716
+ children: "new · markup"
3717
+ }), /* @__PURE__ */ $("button", {
3718
+ type: "button",
3719
+ class: "markup-icon-btn",
3720
+ "aria-label": "Discard pin",
3721
+ onClick: d,
3722
+ children: /* @__PURE__ */ $(aa, { size: 16 })
3723
+ })]
3724
+ }), n == null ? /* @__PURE__ */ $(ma, {
3725
+ pending: i,
3726
+ onSubmit: c,
3727
+ onCancel: d,
3728
+ onSignIn: l
3729
+ }) : /* @__PURE__ */ $("div", {
3730
+ class: "markup-popover-body",
3731
+ children: [
3732
+ /* @__PURE__ */ $("p", {
3733
+ class: "markup-popover-byline",
3734
+ children: [
3735
+ "posting as ",
3736
+ /* @__PURE__ */ $("span", {
3737
+ class: "markup-popover-name",
3738
+ children: n
3739
+ }),
3740
+ r ? /* @__PURE__ */ $("span", {
3741
+ class: "markup-comment-badge",
3742
+ children: "team"
3743
+ }) : null
3744
+ ]
3745
+ }),
3746
+ /* @__PURE__ */ $(ga, {
3747
+ label: "Feedback",
3748
+ placeholder: "What's wrong, missing, or worth noting?",
3749
+ submitLabel: "Post markup",
3750
+ pending: i,
3751
+ error: a,
3752
+ onSubmit: (e) => u(e, p && y)
3753
+ }),
3754
+ b ? /* @__PURE__ */ $("div", {
3755
+ class: "markup-screenshot-row",
3756
+ children: s ? /* @__PURE__ */ $("span", {
3757
+ class: "markup-screenshot-status",
3758
+ children: [
3759
+ /* @__PURE__ */ $("input", {
3760
+ type: "checkbox",
3761
+ class: "markup-screenshot-checkbox",
3762
+ disabled: !0
3763
+ }),
3764
+ /* @__PURE__ */ $(ca, { size: 12 }),
3765
+ /* @__PURE__ */ $("span", { children: "Capturing…" })
3766
+ ]
3767
+ }) : /* @__PURE__ */ $("label", {
3768
+ class: "markup-screenshot-toggle",
3769
+ children: [
3770
+ /* @__PURE__ */ $("input", {
3771
+ type: "checkbox",
3772
+ class: "markup-screenshot-checkbox",
3773
+ checked: p,
3774
+ onChange: (e) => m(e.currentTarget.checked)
3775
+ }),
3776
+ /* @__PURE__ */ $(ca, { size: 12 }),
3777
+ /* @__PURE__ */ $("span", { children: "Attach screenshot" }),
3778
+ h && p ? /* @__PURE__ */ $("img", {
3779
+ class: "markup-screenshot-thumb",
3780
+ src: h,
3781
+ alt: "Screenshot preview"
3782
+ }) : null
3783
+ ]
3784
+ })
3785
+ }) : null
3786
+ ]
3787
+ })]
3788
+ });
3789
+ }
3790
+ function va(e, t, n) {
3791
+ return Math.max(t, Math.min(n, e));
3792
+ }
3793
+ //#endregion
3794
+ //#region src/runtime/ui/pin.tsx
3795
+ function ya({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3796
+ let a = t - window.scrollY, o = e - window.scrollX;
3797
+ return /* @__PURE__ */ $("button", {
3798
+ type: "button",
3799
+ class: Q("markup-pin", r && "is-active is-anchor"),
3800
+ style: {
3801
+ top: `${a}px`,
3802
+ left: `${o}px`
3803
+ },
3804
+ popovertarget: "markup-thread-popover",
3805
+ popovertargetaction: "show",
3806
+ onClick: i,
3807
+ "aria-label": `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3808
+ title: `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3809
+ children: [/* @__PURE__ */ $("span", {
3810
+ class: "markup-pin-dot",
3811
+ "aria-hidden": !0
3812
+ }), n > 1 ? /* @__PURE__ */ $("span", {
3813
+ class: "markup-pin-count",
3814
+ children: n
3815
+ }) : null]
3816
+ });
3817
+ }
3818
+ function ba({ pageX: e, pageY: t }) {
3819
+ let n = t - window.scrollY, r = e - window.scrollX;
3820
+ return /* @__PURE__ */ $("div", {
3821
+ class: "markup-pin markup-pin-ghost is-anchor",
3822
+ style: {
3823
+ top: `${n}px`,
3824
+ left: `${r}px`
3825
+ },
3826
+ children: /* @__PURE__ */ $("span", {
3827
+ class: "markup-pin-dot",
3828
+ "aria-hidden": !0
3829
+ })
3830
+ });
3831
+ }
3832
+ //#endregion
3833
+ //#region src/runtime/ui/placement-overlay.tsx
3834
+ function xa({ onPlace: e, onCancel: t }) {
3835
+ R(() => {
3836
+ function e(e) {
3837
+ e.key === "Escape" && t();
3838
+ }
3839
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3840
+ }, [t]);
3841
+ function n(t) {
3842
+ t.stopPropagation(), t.preventDefault(), e(Tr(t, document.elementsFromPoint(t.clientX, t.clientY).find((e) => !e.shadowRoot) ?? null), t.clientX, t.clientY);
3843
+ }
3844
+ function r(e) {
3845
+ e.preventDefault(), e.stopPropagation();
3846
+ }
3847
+ return /* @__PURE__ */ $("div", {
3848
+ class: "markup-placement-overlay",
3849
+ onPointerDown: r,
3850
+ onClick: n,
3851
+ role: "presentation",
3852
+ children: /* @__PURE__ */ $("div", {
3853
+ class: "markup-placement-cursor-help",
3854
+ children: /* @__PURE__ */ $("span", { children: "Click anywhere to drop a pin · ESC to cancel" })
3855
+ })
3856
+ });
3857
+ }
3858
+ //#endregion
3859
+ //#region src/runtime/ui/thread-popover.tsx
3860
+ var Sa = [
3861
+ "👍",
3862
+ "❤️",
3863
+ "🎉",
3864
+ "😮",
3865
+ "😄",
3866
+ "❓"
3867
+ ];
3868
+ function Ca({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDelete: i, pending: a, error: o, onAuthor: s, onSignIn: c, onClose: l, onReply: u, onEditComment: d, onDeleteComment: f, onToggleReaction: p, onResolve: m, onDelete: h }) {
3869
+ let g = z(null), _ = z(null), v = z(null), y = z(null), b = z(null), [x, S] = L(!1), [C, w] = L(!1), [T, E] = L(null), [D, O] = L(""), [ee, k] = L(null), [A, te] = L("down"), [j, ne] = L(null), [M, N] = L(null), [re, ie] = L("down"), ae = z(null);
3870
+ pa(g, !0);
3871
+ let oe = e.resolvedAt != null, P = we(() => e.comments.filter((e) => !e.deleted), [e.comments]);
3872
+ function se(e, t) {
3873
+ E(e), O(t);
3874
+ }
3875
+ function ce() {
3876
+ E(null), O("");
3877
+ }
3878
+ R(() => {
3879
+ if (!T) return;
3880
+ let t = e.comments.find((e) => e._id === T);
3881
+ (!t || t.deleted) && ce();
3882
+ }, [e.comments, T]);
3883
+ let le = z(!0);
3884
+ R(() => {
3885
+ let e = y.current;
3886
+ if (e) {
3887
+ if (le.current) {
3888
+ le.current = !1, e.scrollTop = e.scrollHeight;
3889
+ return;
3890
+ }
3891
+ e.scrollHeight - e.scrollTop - e.clientHeight < 80 && (e.scrollTop = e.scrollHeight);
3892
+ }
3893
+ }, [P.length]), R(() => {
3894
+ if (!x) {
3895
+ w(!1);
3896
+ return;
3897
+ }
3898
+ function e(e) {
3899
+ _.current && !e.composedPath().includes(_.current) && S(!1);
3900
+ }
3901
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3902
+ }, [x]), R(() => {
3903
+ if (!ee) {
3904
+ ne(null);
3905
+ return;
3906
+ }
3907
+ function e(e) {
3908
+ v.current && !e.composedPath().includes(v.current) && k(null);
3909
+ }
3910
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3911
+ }, [ee]), R(() => {
3912
+ if (!M) return;
3913
+ function e(e) {
3914
+ ae.current && !e.composedPath().includes(ae.current) && N(null);
3915
+ }
3916
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3917
+ }, [M]), R(() => {
3918
+ let e = g.current;
3919
+ if (!e) return;
3920
+ if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3921
+ e.showPopover();
3922
+ } catch {}
3923
+ function t(e) {
3924
+ e.newState === "closed" && l();
3925
+ }
3926
+ return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3927
+ }, [l]);
3928
+ let ue = we(() => {
3929
+ let t = Er({
3930
+ anchorX: e.anchorX,
3931
+ anchorY: e.anchorY,
3932
+ anchorSelector: e.anchorSelector
3933
+ });
3934
+ return {
3935
+ left: Da(t.pageX - window.scrollX + 16, 12, window.innerWidth - 320 - 12),
3936
+ top: Da(t.pageY - window.scrollY - 16, 12, window.innerHeight - 200)
3937
+ };
3938
+ }, [
3939
+ e.anchorX,
3940
+ e.anchorY,
3941
+ e.anchorSelector
3942
+ ]);
3943
+ return /* @__PURE__ */ $("div", {
3944
+ ref: g,
3945
+ id: "markup-thread-popover",
3946
+ class: "markup-popover",
3947
+ popover: "auto",
3948
+ style: {
3949
+ "--markup-pop-x": `${ue.left}px`,
3950
+ "--markup-pop-y": `${ue.top}px`
3951
+ },
3952
+ role: "dialog",
3953
+ "aria-label": "Markup thread",
3954
+ children: [
3955
+ /* @__PURE__ */ $("header", {
3956
+ class: "markup-popover-header",
3957
+ children: [/* @__PURE__ */ $("span", {
3958
+ class: "markup-eyebrow",
3959
+ children: [
3960
+ "thread · ",
3961
+ P.length,
3962
+ " ",
3963
+ P.length === 1 ? "comment" : "comments"
3964
+ ]
3965
+ }), /* @__PURE__ */ $("div", {
3966
+ class: "markup-popover-header-actions",
3967
+ children: [
3968
+ /* @__PURE__ */ $("div", {
3969
+ class: "markup-thread-menu",
3970
+ ref: _,
3971
+ children: [/* @__PURE__ */ $("button", {
3972
+ type: "button",
3973
+ class: Q("markup-icon-btn", x && "is-open"),
3974
+ title: "More options",
3975
+ onClick: () => S((e) => !e),
3976
+ children: /* @__PURE__ */ $(oa, { size: 16 })
3977
+ }), x ? /* @__PURE__ */ $("div", {
3978
+ class: "markup-thread-menu-list",
3979
+ children: [/* @__PURE__ */ $("button", {
3980
+ type: "button",
3981
+ class: "markup-thread-menu-item",
3982
+ onClick: () => {
3983
+ let t = new URL(e.url);
3984
+ t.hash = `markup-thread=${e._id}`, navigator.clipboard.writeText(t.toString()).catch(() => {}), S(!1);
3985
+ },
3986
+ children: "Copy link"
3987
+ }), i ? /* @__PURE__ */ $("button", {
3988
+ type: "button",
3989
+ class: Q("markup-thread-menu-item", C && "is-danger"),
3990
+ disabled: a,
3991
+ onClick: () => {
3992
+ C ? (S(!1), h()) : w(!0);
3993
+ },
3994
+ children: C ? "Confirm delete" : "Delete thread…"
3995
+ }) : null]
3996
+ }) : null]
3997
+ }),
3998
+ r ? /* @__PURE__ */ $("button", {
3999
+ type: "button",
4000
+ class: "markup-icon-btn",
4001
+ title: "Mark as resolved",
4002
+ disabled: a,
4003
+ onClick: m,
4004
+ children: /* @__PURE__ */ $(sa, { size: 16 })
4005
+ }) : null,
4006
+ /* @__PURE__ */ $("button", {
4007
+ type: "button",
4008
+ class: "markup-icon-btn",
4009
+ title: "Close thread",
4010
+ onClick: l,
4011
+ children: /* @__PURE__ */ $(aa, { size: 16 })
4012
+ })
4013
+ ]
4014
+ })]
4015
+ }),
4016
+ /* @__PURE__ */ $("ol", {
4017
+ ref: y,
4018
+ class: "markup-comments",
4019
+ children: P.map((t, r) => {
4020
+ let i = !t.fromDashboard && n != null && t.authorClientId === n, o = r === 0, s = i && !oe && !t.deleted, c = i && !oe && !t.deleted && !o, l = T === t._id, u = (s || c) && !l && !t.deleted, m = ee === t._id, h = j === t._id;
4021
+ return /* @__PURE__ */ $("li", {
4022
+ class: Q("markup-comment", t.fromDashboard && "is-team"),
4023
+ children: [
4024
+ /* @__PURE__ */ $("div", {
4025
+ class: "markup-comment-meta",
4026
+ children: [
4027
+ /* @__PURE__ */ $("span", {
4028
+ class: "markup-comment-author",
4029
+ children: t.authorName
4030
+ }),
4031
+ t.fromDashboard ? /* @__PURE__ */ $("span", {
4032
+ class: "markup-comment-badge",
4033
+ children: "team"
4034
+ }) : null,
4035
+ /* @__PURE__ */ $("time", {
4036
+ class: "markup-comment-time",
4037
+ datetime: new Date(t.createdAt).toISOString(),
4038
+ title: ka(t.createdAt),
4039
+ children: Oa(t.createdAt)
4040
+ }),
4041
+ /* @__PURE__ */ $("div", {
4042
+ class: "markup-thread-actions",
4043
+ children: [!oe && !l ? /* @__PURE__ */ $(wa, {
4044
+ comment: t,
4045
+ pickerOpen: M === t._id,
4046
+ pickerDirection: re,
4047
+ pickerRef: (e) => {
4048
+ M === t._id && (ae.current = e);
4049
+ },
4050
+ onPickerClick: (e) => {
4051
+ if (M === t._id) {
4052
+ N(null);
4053
+ return;
4054
+ }
4055
+ let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect();
4056
+ ie((r ? r.bottom - n.bottom : Infinity) < 44 ? "up" : "down"), N(t._id);
4057
+ },
4058
+ onPickerSelect: (e) => {
4059
+ N(null), p(t._id, e);
4060
+ }
4061
+ }) : null, u ? /* @__PURE__ */ $("div", {
4062
+ class: Q("markup-thread-menu markup-comment-menu", m && "is-open", m && A === "up" && "is-up"),
4063
+ ref: (e) => {
4064
+ m && (v.current = e);
4065
+ },
4066
+ children: [/* @__PURE__ */ $("button", {
4067
+ type: "button",
4068
+ class: Q("markup-icon-btn", m && "is-open"),
4069
+ title: "More options",
4070
+ onClick: (e) => {
4071
+ if (ee === t._id) {
4072
+ k(null);
4073
+ return;
4074
+ }
4075
+ let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect(), i = (+!!s + +!!c) * 32 + 8 + 6;
4076
+ te((r ? r.bottom - n.bottom : Infinity) < i ? "up" : "down"), k(t._id);
4077
+ },
4078
+ children: /* @__PURE__ */ $(oa, { size: 16 })
4079
+ }), m ? /* @__PURE__ */ $("div", {
4080
+ class: "markup-thread-menu-list",
4081
+ children: [s ? /* @__PURE__ */ $("button", {
4082
+ type: "button",
4083
+ class: "markup-thread-menu-item",
4084
+ onClick: () => {
4085
+ k(null), se(t._id, t.body);
4086
+ },
4087
+ children: "Edit"
4088
+ }) : null, c ? /* @__PURE__ */ $("button", {
4089
+ type: "button",
4090
+ class: Q("markup-thread-menu-item", h && "is-danger"),
4091
+ onClick: () => {
4092
+ h ? (k(null), f(t._id)) : ne(t._id);
4093
+ },
4094
+ children: h ? "Confirm delete" : "Delete…"
4095
+ }) : null]
4096
+ }) : null]
4097
+ }) : null]
4098
+ })
4099
+ ]
4100
+ }),
4101
+ l ? /* @__PURE__ */ $("form", {
4102
+ class: "markup-comment-edit-form",
4103
+ onSubmit: async (e) => {
4104
+ e.preventDefault();
4105
+ let n = D.trim();
4106
+ if (!n || n === t.body) {
4107
+ ce();
4108
+ return;
4109
+ }
4110
+ try {
4111
+ await d(t._id, n), ce();
4112
+ } catch {}
4113
+ },
4114
+ children: [/* @__PURE__ */ $("textarea", {
4115
+ class: "markup-textarea",
4116
+ value: D,
4117
+ onInput: (e) => O(e.currentTarget.value),
4118
+ rows: 3,
4119
+ autoFocus: !0,
4120
+ disabled: a
4121
+ }), /* @__PURE__ */ $("div", {
4122
+ class: "markup-comment-edit-actions",
4123
+ children: [/* @__PURE__ */ $("button", {
4124
+ type: "button",
4125
+ class: "markup-btn markup-btn-ghost",
4126
+ onClick: ce,
4127
+ disabled: a,
4128
+ children: "Cancel"
4129
+ }), /* @__PURE__ */ $("button", {
4130
+ type: "submit",
4131
+ class: "markup-btn markup-btn-primary",
4132
+ disabled: a || D.trim().length === 0,
4133
+ children: "Save"
4134
+ })]
4135
+ })]
4136
+ }) : /* @__PURE__ */ $("p", {
4137
+ class: "markup-comment-body",
4138
+ children: [t.body, t.editedAt == null ? null : /* @__PURE__ */ $("time", {
4139
+ class: "markup-comment-edited",
4140
+ datetime: new Date(t.editedAt).toISOString(),
4141
+ title: ka(t.editedAt),
4142
+ children: [" ", "(edited)"]
4143
+ })]
4144
+ }),
4145
+ !l && t.reactions.length > 0 ? /* @__PURE__ */ $(Ta, {
4146
+ comment: t,
4147
+ isResolved: oe,
4148
+ onToggle: (e) => p(t._id, e)
4149
+ }) : null,
4150
+ r === 0 && e.screenshotUrl ? /* @__PURE__ */ $("button", {
4151
+ type: "button",
4152
+ class: "markup-comment-screenshot",
4153
+ onClick: () => b.current?.showModal(),
4154
+ children: /* @__PURE__ */ $("img", {
4155
+ src: e.screenshotUrl,
4156
+ alt: "Screenshot"
4157
+ })
4158
+ }) : null
4159
+ ]
4160
+ }, t._id);
4161
+ })
4162
+ }),
4163
+ e.screenshotUrl ? /* @__PURE__ */ $("dialog", {
4164
+ ref: b,
4165
+ class: "markup-lightbox",
4166
+ onClick: () => b.current?.close(),
4167
+ children: [/* @__PURE__ */ $("button", {
4168
+ type: "button",
4169
+ class: "markup-lightbox-close markup-icon-btn",
4170
+ "aria-label": "Close screenshot",
4171
+ onClick: (e) => {
4172
+ e.stopPropagation(), b.current?.close();
4173
+ },
4174
+ children: /* @__PURE__ */ $(aa, { size: 16 })
4175
+ }), /* @__PURE__ */ $("img", {
4176
+ class: "markup-lightbox-img",
4177
+ src: e.screenshotUrl,
4178
+ alt: "Screenshot",
4179
+ onClick: (e) => e.stopPropagation()
4180
+ })]
4181
+ }) : null,
4182
+ t == null ? /* @__PURE__ */ $(ma, {
4183
+ pending: a,
4184
+ onSubmit: s,
4185
+ onCancel: l,
4186
+ onSignIn: c
4187
+ }) : /* @__PURE__ */ $("div", {
4188
+ class: "markup-popover-body",
4189
+ children: [/* @__PURE__ */ $("p", {
4190
+ class: "markup-popover-byline",
4191
+ children: [
4192
+ "replying as ",
4193
+ /* @__PURE__ */ $("span", {
4194
+ class: "markup-popover-name",
4195
+ children: t
4196
+ }),
4197
+ r ? /* @__PURE__ */ $("span", {
4198
+ class: "markup-comment-badge",
4199
+ children: "team"
4200
+ }) : null
4201
+ ]
4202
+ }), /* @__PURE__ */ $(ga, {
4203
+ label: "Reply",
4204
+ placeholder: "Write a reply…",
4205
+ submitLabel: "Reply",
4206
+ initialFocus: !1,
4207
+ pending: a,
4208
+ error: o,
4209
+ onSubmit: u
4210
+ })]
4211
+ })
4212
+ ]
4213
+ });
4214
+ }
4215
+ function wa({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPickerClick: i, onPickerSelect: a }) {
4216
+ return /* @__PURE__ */ $("div", {
4217
+ class: Q("markup-reaction-picker-wrap", t && "is-open", t && n === "up" && "is-up"),
4218
+ ref: r,
4219
+ children: [/* @__PURE__ */ $("button", {
4220
+ type: "button",
4221
+ class: Q("markup-icon-btn", t && "is-open"),
4222
+ title: "Add reaction",
4223
+ "aria-label": "Add reaction",
4224
+ onClick: i,
4225
+ children: /* @__PURE__ */ $(ua, { size: 16 })
4226
+ }), t ? /* @__PURE__ */ $("div", {
4227
+ class: "markup-reaction-picker",
4228
+ role: "menu",
4229
+ children: Sa.map((t) => /* @__PURE__ */ $("button", {
4230
+ type: "button",
4231
+ role: "menuitem",
4232
+ class: Q("markup-reaction-picker-item", (e.reactions.find((e) => e.emoji === t)?.mine ?? !1) && "is-mine"),
4233
+ onClick: () => a(t),
4234
+ children: t
4235
+ }, t))
4236
+ }) : null]
4237
+ });
4238
+ }
4239
+ function Ta({ comment: e, isResolved: t, onToggle: n }) {
4240
+ return /* @__PURE__ */ $("div", {
4241
+ class: "markup-reactions",
4242
+ children: e.reactions.map((e) => {
4243
+ let r = Ea(e.reactors, e.mine, e.count, e.emoji);
4244
+ return /* @__PURE__ */ $("button", {
4245
+ type: "button",
4246
+ class: Q("markup-reaction-chip", e.mine && "is-mine"),
4247
+ disabled: t,
4248
+ onClick: () => n(e.emoji),
4249
+ "aria-pressed": e.mine,
4250
+ "aria-label": r,
4251
+ title: r,
4252
+ children: [/* @__PURE__ */ $("span", {
4253
+ class: "markup-reaction-emoji",
4254
+ "aria-hidden": !0,
4255
+ children: e.emoji
4256
+ }), /* @__PURE__ */ $("span", {
4257
+ class: "markup-reaction-count",
4258
+ children: e.count
4259
+ })]
4260
+ }, e.emoji);
4261
+ })
4262
+ });
4263
+ }
4264
+ function Ea(e, t, n, r) {
4265
+ let i = e.slice(), a = i.length + +!!t, o = Math.max(0, n - a);
4266
+ return o > 0 && i.push(`${o} other${o === 1 ? "" : "s"}`), t && i.push("you"), i.length === 0 ? `${n} reacted with ${r}` : `${i.length === 1 ? i[0] : `${i.slice(0, -1).join(", ")} and ${i[i.length - 1]}`} reacted with ${r}`;
4267
+ }
4268
+ function Da(e, t, n) {
4269
+ return Math.max(t, Math.min(n, e));
4270
+ }
4271
+ function Oa(e) {
4272
+ let t = Date.now() - e, n = Math.floor(t / 1e3);
4273
+ if (n < 60) return "just now";
4274
+ let r = Math.floor(n / 60);
4275
+ if (r < 60) return `${r} minute${r === 1 ? "" : "s"} ago`;
4276
+ let i = Math.floor(r / 60);
4277
+ if (i < 24) return `${i} hour${i === 1 ? "" : "s"} ago`;
4278
+ let a = Math.floor(i / 24);
4279
+ return a < 30 ? `${a} day${a === 1 ? "" : "s"} ago` : new Date(e).getFullYear() === (/* @__PURE__ */ new Date()).getFullYear() ? new Date(e).toLocaleDateString([], {
4280
+ month: "long",
4281
+ day: "numeric"
4282
+ }) : new Date(e).toLocaleDateString([], {
4283
+ month: "long",
4284
+ day: "numeric",
4285
+ year: "numeric"
4286
+ });
4287
+ }
4288
+ function ka(e) {
4289
+ return new Date(e).toLocaleDateString([], {
4290
+ month: "long",
4291
+ day: "numeric",
4292
+ year: "numeric",
4293
+ hour: "numeric",
4294
+ minute: "numeric"
4295
+ });
4296
+ }
4297
+ //#endregion
4298
+ //#region src/runtime/ui/app.tsx
4299
+ function Aa(e) {
4300
+ return {
4301
+ clientId: `markup_user_${e.identity.id}`,
4302
+ name: e.identity.name,
4303
+ email: e.identity.email,
4304
+ isVerified: !0,
4305
+ token: e.token ?? void 0,
4306
+ tokenExpiresAt: e.tokenExpiresAt ?? void 0
4307
+ };
4308
+ }
4309
+ function ja({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4310
+ let [r, i] = L(() => window.location.pathname), [a, o] = L([]), [s, c] = L(null), l = z(null);
4311
+ l.current = s;
4312
+ let u = we(() => kr({
4313
+ apiUrl: e,
4314
+ apiKey: t,
4315
+ getToken: () => {
4316
+ let e = l.current;
4317
+ return e?.token && e.tokenExpiresAt ? {
4318
+ token: e.token,
4319
+ expiresAt: e.tokenExpiresAt
4320
+ } : null;
4321
+ },
4322
+ onUnauthorized: () => {
4323
+ let e = l.current;
4324
+ if (!e) return;
4325
+ let t = {
4326
+ clientId: e.clientId,
4327
+ name: e.name,
4328
+ email: e.email
4329
+ };
4330
+ l.current = t, c(t), Nr(t);
4331
+ }
4332
+ }), [e, t]), [d, f] = L({ kind: "idle" }), [p, m] = L(!1), [h, g] = L(null), [_, v] = L(!1), [y, b] = L(!1), [, x] = L(0), S = z(null), C = s?.name ?? null, w = s?.isVerified ?? !1;
4333
+ R(() => {
4334
+ let e = Mr();
4335
+ if (e) {
4336
+ c(e);
4337
+ return;
4338
+ }
4339
+ let t = { clientId: Pr() };
4340
+ Nr(t), c(t);
4341
+ }, []);
4342
+ let [T, E] = L(null);
4343
+ R(() => {
4344
+ Na(t).then(E).catch(() => {});
4345
+ }, [t]);
4346
+ let D = z(null);
4347
+ R(() => {
4348
+ let t = new ir(e.replace(/\.convex\.site(\/.*)?$/, ".convex.cloud"));
4349
+ return D.current = t, () => {
4350
+ t.close(), D.current = null;
4351
+ };
4352
+ }, [e]);
4353
+ let O = z(!1);
4354
+ R(() => {
4355
+ let e = D.current;
4356
+ if (!(!e || !T)) return O.current = !1, g(null), e.onUpdate(Jt("widget/queries:subscribeThreadsForRoute"), {
4357
+ apiKeyHash: T,
4358
+ route: r,
4359
+ viewerClientId: s?.clientId ?? void 0
4360
+ }, (e) => {
4361
+ e !== void 0 && o(e);
4362
+ });
4363
+ }, [
4364
+ T,
4365
+ r,
4366
+ s?.clientId
4367
+ ]), R(() => {
4368
+ if (O.current) return;
4369
+ let e = window.location.hash.match(/^#markup-thread=(.+)$/);
4370
+ if (!e) {
4371
+ O.current = !0;
4372
+ return;
4373
+ }
4374
+ let t = decodeURIComponent(e[1] ?? "");
4375
+ a.find((e) => e._id === t) && (O.current = !0, f({
4376
+ kind: "thread",
4377
+ threadId: t
4378
+ }), history.replaceState(null, "", window.location.pathname + window.location.search));
4379
+ }, [a]), R(() => {
4380
+ function e() {
4381
+ i(window.location.pathname);
4382
+ }
4383
+ window.addEventListener("popstate", e);
4384
+ let t = history.pushState, n = history.replaceState;
4385
+ return history.pushState = function(...n) {
4386
+ t.apply(this, n), e();
4387
+ }, history.replaceState = function(...t) {
4388
+ n.apply(this, t), e();
4389
+ }, () => {
4390
+ window.removeEventListener("popstate", e), history.pushState = t, history.replaceState = n;
4391
+ };
4392
+ }, []), R(() => {
4393
+ function e(e) {
4394
+ e.key === "." && (e.metaKey || e.ctrlKey) && (e.altKey || e.shiftKey || (e.preventDefault(), v((e) => !e)));
4395
+ }
4396
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
4397
+ }, []), R(() => {
4398
+ if (!y) return;
4399
+ if (!_) {
4400
+ b(!1);
4401
+ return;
4402
+ }
4403
+ let e = window.setTimeout(() => b(!1), 5e3);
4404
+ return () => window.clearTimeout(e);
4405
+ }, [y, _]), R(() => {
4406
+ function e() {
4407
+ x((e) => e + 1);
4408
+ }
4409
+ window.addEventListener("scroll", e, { passive: !0 }), window.addEventListener("resize", e);
4410
+ let t = new ResizeObserver(e);
4411
+ return t.observe(document.body), () => {
4412
+ window.removeEventListener("scroll", e), window.removeEventListener("resize", e), t.disconnect();
4413
+ };
4414
+ }, []);
4415
+ let ee = B(() => {
4416
+ g(null), f({ kind: "placing" });
4417
+ }, []), k = B(() => {
4418
+ f({ kind: "idle" }), g(null);
4419
+ }, []), A = B((e, t, n) => {
4420
+ f({
4421
+ kind: "composing-new",
4422
+ coords: e,
4423
+ pageX: t + window.scrollX,
4424
+ pageY: n + window.scrollY,
4425
+ screenshot: null,
4426
+ screenshotCapturing: !0
4427
+ }), ea(S.current != null && S.current.getRootNode() instanceof ShadowRoot ? S.current.getRootNode().host : null, {
4428
+ x: t,
4429
+ y: n
4430
+ }).then((e) => {
4431
+ f((t) => t.kind === "composing-new" ? {
4432
+ ...t,
4433
+ screenshot: e,
4434
+ screenshotCapturing: !1
4435
+ } : t);
4436
+ });
4437
+ }, []), te = B((e, t) => {
4438
+ let n = {
4439
+ clientId: s?.clientId ?? Pr(),
4440
+ name: e,
4441
+ email: t
4442
+ };
4443
+ Nr(n), c(n);
4444
+ }, [s]), j = B(async () => {
4445
+ g(null);
4446
+ try {
4447
+ let n = Aa(await Fr(e, t));
4448
+ Nr(n), c(n);
4449
+ } catch (e) {
4450
+ g(e instanceof Error ? e.message : "Sign-in failed");
4451
+ }
4452
+ }, [e, t]), ne = B(async (e, t) => {
4453
+ if (!(d.kind !== "composing-new" || !s?.name)) {
4454
+ m(!0), g(null);
4455
+ try {
4456
+ let n;
4457
+ if (t && d.screenshot) {
4458
+ let { uploadUrl: e } = await u.getScreenshotUploadUrl(), t = await fetch(e, {
4459
+ method: "POST",
4460
+ headers: { "Content-Type": d.screenshot.type || "image/png" },
4461
+ body: d.screenshot
4462
+ });
4463
+ if (t.ok) {
4464
+ let { storageId: e } = await t.json();
4465
+ n = e;
4466
+ }
4467
+ }
4468
+ let i = await u.createThread({
4469
+ url: window.location.href,
4470
+ route: r,
4471
+ anchorSelector: d.coords.anchorSelector,
4472
+ anchorX: d.coords.anchorX,
4473
+ anchorY: d.coords.anchorY,
4474
+ anchorOffsetX: d.coords.anchorOffsetX,
4475
+ anchorOffsetY: d.coords.anchorOffsetY,
4476
+ viewportW: d.coords.viewportW,
4477
+ viewportY: d.coords.viewportY,
4478
+ userAgent: navigator.userAgent,
4479
+ authorName: s.name,
4480
+ authorEmail: s.email,
4481
+ authorClientId: s.clientId,
4482
+ body: e,
4483
+ screenshotStorageId: n
4484
+ });
4485
+ o((e) => [...e, i.thread]), f({
4486
+ kind: "thread",
4487
+ threadId: i.thread._id
4488
+ });
4489
+ } catch (e) {
4490
+ g(e instanceof Error ? e.message : "Failed to post");
4491
+ } finally {
4492
+ m(!1);
4493
+ }
4494
+ }
4495
+ }, [
4496
+ u,
4497
+ s,
4498
+ d,
4499
+ r
4500
+ ]), M = B(async () => {
4501
+ if (d.kind !== "thread") return;
4502
+ let e = d.threadId;
4503
+ m(!0), g(null);
4504
+ try {
4505
+ await u.deleteThread(e), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4506
+ } catch (e) {
4507
+ g(e instanceof Error ? e.message : "Failed to delete");
4508
+ } finally {
4509
+ m(!1);
4510
+ }
4511
+ }, [u, d]), N = B(async () => {
4512
+ if (d.kind !== "thread") return;
4513
+ let e = d.threadId;
4514
+ m(!0), g(null);
4515
+ try {
4516
+ await u.resolveThread(e, s?.clientId), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4517
+ } catch (e) {
4518
+ g(e instanceof Error ? e.message : "Failed to resolve");
4519
+ } finally {
4520
+ m(!1);
4521
+ }
4522
+ }, [
4523
+ u,
4524
+ d,
4525
+ s?.clientId
4526
+ ]), re = B(async (e) => {
4527
+ if (d.kind !== "thread" || !s?.name) return;
4528
+ let t = d.threadId;
4529
+ m(!0), g(null);
4530
+ try {
4531
+ let n = await u.addComment(t, {
4532
+ body: e,
4533
+ authorName: s.name,
4534
+ authorEmail: s.email,
4535
+ authorClientId: s.clientId
4536
+ });
4537
+ o((e) => e.map((e) => e._id === t ? n.thread : e));
4538
+ } catch (e) {
4539
+ g(e instanceof Error ? e.message : "Failed to reply");
4540
+ } finally {
4541
+ m(!1);
4542
+ }
4543
+ }, [
4544
+ u,
4545
+ s,
4546
+ d
4547
+ ]), ie = B(async (e, t) => {
4548
+ if (d.kind !== "thread" || !s) return;
4549
+ let n = d.threadId;
4550
+ m(!0), g(null);
4551
+ try {
4552
+ let r = await u.editComment(n, e, {
4553
+ body: t,
4554
+ authorClientId: s.clientId
4555
+ });
4556
+ o((e) => e.map((e) => e._id === n ? r.thread : e));
4557
+ } catch (e) {
4558
+ throw g(e instanceof Error ? e.message : "Failed to edit"), e;
4559
+ } finally {
4560
+ m(!1);
4561
+ }
4562
+ }, [
4563
+ u,
4564
+ s,
4565
+ d
4566
+ ]), ae = B(async (e) => {
4567
+ if (d.kind !== "thread" || !s) return;
4568
+ let t = d.threadId;
4569
+ m(!0), g(null);
4570
+ try {
4571
+ let n = await u.deleteComment(t, e, { authorClientId: s.clientId });
4572
+ o((e) => e.map((e) => e._id === t ? n.thread : e));
4573
+ } catch (e) {
4574
+ g(e instanceof Error ? e.message : "Failed to delete");
4575
+ } finally {
4576
+ m(!1);
4577
+ }
4578
+ }, [
4579
+ u,
4580
+ s,
4581
+ d
4582
+ ]), oe = B(async (e, t) => {
4583
+ if (d.kind !== "thread" || !s) return;
4584
+ let n = d.threadId;
4585
+ g(null);
4586
+ try {
4587
+ let r = await u.toggleReaction(e, {
4588
+ emoji: t,
4589
+ authorClientId: s.clientId,
4590
+ authorName: s.name
4591
+ });
4592
+ o((e) => e.map((e) => e._id === n ? r.thread : e));
4593
+ } catch (e) {
4594
+ g(e instanceof Error ? e.message : "Failed to react");
4595
+ }
4596
+ }, [
4597
+ u,
4598
+ s,
4599
+ d
4600
+ ]), P = d.kind === "thread" ? a.find((e) => e._id === d.threadId) ?? null : null, se = w || s?.clientId != null && s.clientId === P?.authorClientId;
4601
+ return /* @__PURE__ */ $("div", {
4602
+ class: "markup-root",
4603
+ ref: S,
4604
+ children: [
4605
+ d.kind === "placing" ? null : /* @__PURE__ */ $("div", {
4606
+ class: "markup-pins-layer",
4607
+ children: [_ ? null : a.map((e) => {
4608
+ let t = d.kind === "thread" && d.threadId === e._id, n = Er({
4609
+ anchorX: e.anchorX,
4610
+ anchorY: e.anchorY,
4611
+ anchorSelector: e.anchorSelector,
4612
+ anchorOffsetX: e.anchorOffsetX,
4613
+ anchorOffsetY: e.anchorOffsetY
4614
+ }), r = e.comments.reduce((e, t) => e + +!t.deleted, 0);
4615
+ return /* @__PURE__ */ $(ya, {
4616
+ pageX: n.pageX,
4617
+ pageY: n.pageY,
4618
+ count: r,
4619
+ active: t,
4620
+ onClick: () => f({
4621
+ kind: "thread",
4622
+ threadId: e._id
4623
+ })
4624
+ }, e._id);
4625
+ }), d.kind === "composing-new" ? /* @__PURE__ */ $(ba, {
4626
+ pageX: d.pageX,
4627
+ pageY: d.pageY
4628
+ }) : null]
4629
+ }),
4630
+ d.kind === "placing" ? /* @__PURE__ */ $(xa, {
4631
+ onPlace: A,
4632
+ onCancel: k
4633
+ }) : null,
4634
+ d.kind === "thread" && P && !_ ? /* @__PURE__ */ $(Ca, {
4635
+ thread: P,
4636
+ authorName: C,
4637
+ currentClientId: s?.clientId ?? null,
4638
+ isVerified: w,
4639
+ canDelete: se,
4640
+ pending: p,
4641
+ error: h,
4642
+ onAuthor: te,
4643
+ onSignIn: j,
4644
+ onClose: k,
4645
+ onReply: re,
4646
+ onEditComment: ie,
4647
+ onDeleteComment: ae,
4648
+ onToggleReaction: oe,
4649
+ onDelete: M,
4650
+ onResolve: N
4651
+ }) : null,
4652
+ d.kind === "composing-new" ? /* @__PURE__ */ $(_a, {
4653
+ pageX: d.pageX,
4654
+ pageY: d.pageY,
4655
+ authorName: C,
4656
+ isVerified: w,
4657
+ pending: p,
4658
+ error: h,
4659
+ screenshot: d.screenshot,
4660
+ screenshotCapturing: d.screenshotCapturing,
4661
+ onAuthor: te,
4662
+ onSignIn: j,
4663
+ onSubmit: ne,
4664
+ onClose: k
4665
+ }) : null,
4666
+ !_ || d.kind === "placing" || d.kind === "composing-new" ? /* @__PURE__ */ $(da, {
4667
+ active: d.kind === "placing",
4668
+ onToggle: () => d.kind === "placing" ? k() : ee(),
4669
+ onHide: () => {
4670
+ v(!0), b(!0);
4671
+ },
4672
+ position: n
4673
+ }) : null,
4674
+ _ && y ? /* @__PURE__ */ $(Ma, { position: n }) : null
4675
+ ]
4676
+ });
4677
+ }
4678
+ function Ma({ position: e }) {
4679
+ let t = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
4680
+ return /* @__PURE__ */ $("div", {
4681
+ class: Q("markup-hud-hidden-toast", e === "bottom-left" ? "markup-hud-hidden-toast-left" : "markup-hud-hidden-toast-right"),
4682
+ role: "status",
4683
+ "aria-live": "polite",
4684
+ children: [
4685
+ "Markup hidden — press ",
4686
+ /* @__PURE__ */ $("kbd", {
4687
+ class: "markup-kbd",
4688
+ children: t
4689
+ }),
4690
+ /* @__PURE__ */ $("kbd", {
4691
+ class: "markup-kbd",
4692
+ children: "."
4693
+ }),
4694
+ " or refresh to bring it back."
4695
+ ]
4696
+ });
4697
+ }
4698
+ async function Na(e) {
4699
+ let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
4700
+ return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
4701
+ }
4702
+ //#endregion
4703
+ //#region src/runtime/mount.tsx
4704
+ function Pa(e, t) {
4705
+ e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "2147483647", e.style.pointerEvents = "none";
4706
+ let n = t.theme ?? "auto";
4707
+ n !== "auto" && (e.dataset.theme = n);
4708
+ let r = e.attachShadow({ mode: "open" }), i = document.createElement("style");
4709
+ i.textContent = ue, r.appendChild(i);
4710
+ let a = document.createElement("div");
4711
+ a.className = "markup-shadow-root", r.appendChild(a);
4712
+ let { theme: o, ...s } = t;
4713
+ return le(/* @__PURE__ */ $(ja, { ...s }), a), () => le(null, a);
4714
+ }
4715
+ //#endregion
4716
+ //#region src/widget.ts
4717
+ var Fa = null, Ia = null;
4718
+ function La(e) {
4719
+ Ra();
4720
+ let t = document.createElement("div");
4721
+ return t.id = "markup-widget", document.body.appendChild(t), Ia = t, Fa = Pa(t, e), Ra;
4722
+ }
4723
+ function Ra() {
4724
+ Fa &&= (Fa(), null), Ia?.parentNode && Ia.parentNode.removeChild(Ia), Ia = null;
4725
+ }
4726
+ if (typeof document < "u") {
4727
+ let e = document.currentScript ?? document.querySelector("script[data-markup-widget=\"true\"]"), t = e?.dataset.apiUrl, n = e?.dataset.apiKey;
4728
+ if (t && n) {
4729
+ let r = e?.dataset.position, i = e?.dataset.theme, a = () => La({
4730
+ apiUrl: t,
4731
+ apiKey: n,
4732
+ position: r,
4733
+ theme: i
4734
+ });
4735
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a, { once: !0 }) : a();
4736
+ }
4737
+ }
4738
+ //#endregion
4739
+ export { Ra as destroy, La as init };