@heypointerhq/sdk 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +127 -2
- package/dist/author/capture.d.ts +53 -0
- package/dist/author/draft.d.ts +81 -0
- package/dist/author/flow.d.ts +31 -0
- package/dist/author/global.d.ts +1 -0
- package/dist/author/index.d.ts +49 -0
- package/dist/author/labels.d.ts +73 -0
- package/dist/author/panel.d.ts +61 -0
- package/dist/author/policy.d.ts +21 -0
- package/dist/author-import.d.ts +1 -0
- package/dist/author-import.iife.d.ts +1 -0
- package/dist/author-loader.d.ts +17 -0
- package/dist/author.js +750 -0
- package/dist/chunk-element.js +896 -0
- package/dist/chunk-theme.js +319 -0
- package/dist/client.d.ts +32 -0
- package/dist/contrast.d.ts +5 -0
- package/dist/element.d.ts +43 -0
- package/dist/element.js +1 -0
- package/dist/global.d.ts +2 -0
- package/dist/heypointer.author.js +2 -0
- package/dist/heypointer.global.js +2 -0
- package/dist/highlight.d.ts +21 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3 -0
- package/dist/labels.d.ts +81 -0
- package/dist/player.d.ts +193 -0
- package/dist/recorder.d.ts +12 -0
- package/dist/spotlight.d.ts +28 -0
- package/dist/targeting/index.d.ts +26 -0
- package/dist/targeting/watch.d.ts +6 -0
- package/dist/theme.d.ts +32 -0
- package/dist/types.d.ts +5 -0
- package/dist/validate.d.ts +6 -0
- package/package.json +58 -4
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// src/labels.ts
|
|
2
|
+
var e = {
|
|
3
|
+
launcher: "Guide me",
|
|
4
|
+
dialogName: "HeyPointer assistant",
|
|
5
|
+
heading: "HeyPointer",
|
|
6
|
+
closeLabel: "Close guide",
|
|
7
|
+
goalQuestion: "What do you want to do?",
|
|
8
|
+
goalAria: "Your goal",
|
|
9
|
+
goalPlaceholder: "e.g. invite a teammate",
|
|
10
|
+
submit: "Show me",
|
|
11
|
+
speak: "Speak",
|
|
12
|
+
stop: "Stop",
|
|
13
|
+
changeGoal: "Change goal or use voice",
|
|
14
|
+
assistToggle: "Assist: do safe clicks for me when I press Next",
|
|
15
|
+
assistHint: "You need to do this one yourself.",
|
|
16
|
+
assistClicked: "Clicked \"{label}\" for you.",
|
|
17
|
+
assistFailed: "I couldn't click \"{label}\" for you. Do this step yourself, then press Next.",
|
|
18
|
+
releasedNote: "It looks like you did that. Press Next to continue.",
|
|
19
|
+
next: "Next",
|
|
20
|
+
finish: "Finish",
|
|
21
|
+
back: "Back",
|
|
22
|
+
skip: "Skip",
|
|
23
|
+
stepProgress: "Step {current} of {total}",
|
|
24
|
+
tourCount: "{current} / {total}",
|
|
25
|
+
stepAnnounce: "Step {current} of {total}: {title}. {instruction}",
|
|
26
|
+
suggestedValue: "Suggested value: {value}",
|
|
27
|
+
gateWarning: "This changes data. Confirm before continuing.",
|
|
28
|
+
gateCheckbox: "I understand and want to do this myself.",
|
|
29
|
+
gateWhy: "Tick the confirmation box to continue.",
|
|
30
|
+
evidenceSummary: "Source ({count})",
|
|
31
|
+
loading: "Finding the steps…",
|
|
32
|
+
tryAgain: "Try again",
|
|
33
|
+
skipStep: "Skip step",
|
|
34
|
+
done: "Done. You finished: {goal}",
|
|
35
|
+
startAnother: "Start another",
|
|
36
|
+
suggestLabel: "Did you mean:",
|
|
37
|
+
suggestAnnounce: "Did you mean: {list}?",
|
|
38
|
+
notFound: "I can't find \"{label}\" on this page. The screen may differ from the docs.",
|
|
39
|
+
ambiguous: "I found more than one match for this step, so I won't guess. Look for: {label}.",
|
|
40
|
+
notFoundAnnounce: "Cannot find the target for: {title}. You can try again or skip this step.",
|
|
41
|
+
ambiguousAnnounce: "Several matches for: {title}. You can try again or skip this step.",
|
|
42
|
+
emptyGoal: "Type what you want to do first.",
|
|
43
|
+
recording: "Recording… press Stop when done.",
|
|
44
|
+
transcribing: "Transcribing…",
|
|
45
|
+
voiceUnavailable: "Voice isn't available. Type your goal instead.",
|
|
46
|
+
noSpeech: "I didn't hear anything. Try again or type your goal.",
|
|
47
|
+
audioFailed: "Could not process audio. Type your goal instead.",
|
|
48
|
+
insufficient: "I don't have enough documented steps to guide this safely.",
|
|
49
|
+
genericError: "Something went wrong.",
|
|
50
|
+
clientRequired: "HeyPointer needs a client ID. Run heypointer init or pass data-client-id.",
|
|
51
|
+
clientInvalid: "HeyPointer does not recognise this client ID. Check that it matches the one heypointer init gave you.",
|
|
52
|
+
clientOrigin: "This site's address is not allowed for this HeyPointer client ID. Ask the HeyPointer admin to add it to the client's allowed origins.",
|
|
53
|
+
clientMalformed: "The HeyPointer client ID looks wrong (it should start with gfc_). Check data-client-id against what heypointer init printed.",
|
|
54
|
+
rateLimited: "HeyPointer is getting too many requests right now. Wait a moment and try again.",
|
|
55
|
+
serverUnreachable: "Cannot reach the HeyPointer server at {host}. Check that it is running and the address is right.",
|
|
56
|
+
requestFailed: "Walkthrough request failed ({status})"
|
|
57
|
+
}, t = /\{(\w+)\}/g, n = {
|
|
58
|
+
done: ["goal"],
|
|
59
|
+
stepAnnounce: ["instruction"]
|
|
60
|
+
}, r = (e) => [...e.matchAll(t)].map((e) => e[1]), i = (t) => [...new Set(r(e[t]))].filter((e) => !n[t]?.includes(e));
|
|
61
|
+
function a(e, n = {}) {
|
|
62
|
+
return e.replace(t, (e, t) => Object.prototype.hasOwnProperty.call(n, t) ? String(n[t]) : e);
|
|
63
|
+
}
|
|
64
|
+
function o(e, t) {}
|
|
65
|
+
function s(t) {
|
|
66
|
+
let n = { ...e }, a = [];
|
|
67
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return {
|
|
68
|
+
labels: n,
|
|
69
|
+
problems: a
|
|
70
|
+
};
|
|
71
|
+
for (let [a, o] of Object.entries(t)) {
|
|
72
|
+
if (a.startsWith("author") || !Object.prototype.hasOwnProperty.call(e, a)) continue;
|
|
73
|
+
let t = a;
|
|
74
|
+
if (typeof o != "string" || !o.trim() || o.length > 300) continue;
|
|
75
|
+
let s = r(o);
|
|
76
|
+
i(t).filter((e) => !s.includes(e)).length || (n[t] = o);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
labels: n,
|
|
80
|
+
problems: a
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function c(e, t) {
|
|
84
|
+
if (t != null && t.trim()) try {
|
|
85
|
+
return JSON.parse(t);
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
91
|
+
function l(e) {
|
|
92
|
+
"@babel/helpers - typeof";
|
|
93
|
+
return l = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
94
|
+
return typeof e;
|
|
95
|
+
} : function(e) {
|
|
96
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
97
|
+
}, l(e);
|
|
98
|
+
}
|
|
99
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
100
|
+
function u(e, t) {
|
|
101
|
+
if (l(e) != "object" || !e) return e;
|
|
102
|
+
var n = e[Symbol.toPrimitive];
|
|
103
|
+
if (n !== void 0) {
|
|
104
|
+
var r = n.call(e, t || "default");
|
|
105
|
+
if (l(r) != "object") return r;
|
|
106
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
107
|
+
}
|
|
108
|
+
return (t === "string" ? String : Number)(e);
|
|
109
|
+
}
|
|
110
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
111
|
+
function d(e) {
|
|
112
|
+
var t = u(e, "string");
|
|
113
|
+
return l(t) == "symbol" ? t : t + "";
|
|
114
|
+
}
|
|
115
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
116
|
+
function f(e, t, n) {
|
|
117
|
+
return (t = d(t)) in e ? Object.defineProperty(e, t, {
|
|
118
|
+
value: n,
|
|
119
|
+
enumerable: !0,
|
|
120
|
+
configurable: !0,
|
|
121
|
+
writable: !0
|
|
122
|
+
}) : e[t] = n, e;
|
|
123
|
+
}
|
|
124
|
+
// src/targeting/index.ts
|
|
125
|
+
var p = {
|
|
126
|
+
button: "button, [role=\"button\"], input[type=\"button\"], input[type=\"submit\"]",
|
|
127
|
+
link: "a[href], [role=\"link\"]",
|
|
128
|
+
textbox: "input:not([type]), input[type=\"text\"], input[type=\"email\"], input[type=\"search\"], textarea, [role=\"textbox\"]",
|
|
129
|
+
combobox: "select, [role=\"combobox\"]",
|
|
130
|
+
checkbox: "input[type=\"checkbox\"], [role=\"checkbox\"]"
|
|
131
|
+
};
|
|
132
|
+
function m(e) {
|
|
133
|
+
for (let t = e; t; t = t.parentElement) {
|
|
134
|
+
if (t.hidden || t.getAttribute("aria-hidden") === "true" || t.hasAttribute("inert")) return !1;
|
|
135
|
+
let e = getComputedStyle(t);
|
|
136
|
+
if (e.display === "none" || e.visibility === "hidden") return !1;
|
|
137
|
+
}
|
|
138
|
+
return !0;
|
|
139
|
+
}
|
|
140
|
+
function h(e) {
|
|
141
|
+
if (!e.isConnected || !m(e)) return !1;
|
|
142
|
+
if (typeof e.checkVisibility != "function") return !0;
|
|
143
|
+
if (!e.checkVisibility({
|
|
144
|
+
checkVisibilityCSS: !0,
|
|
145
|
+
contentVisibilityAuto: !0
|
|
146
|
+
}) || !e.getClientRects().length) return !1;
|
|
147
|
+
let t = e.getBoundingClientRect();
|
|
148
|
+
return t.width > 0 || t.height > 0;
|
|
149
|
+
}
|
|
150
|
+
function g(e) {
|
|
151
|
+
let t = e.getAttribute("aria-label");
|
|
152
|
+
if (t) return t;
|
|
153
|
+
let n = e.labels;
|
|
154
|
+
return n && n.length ? Array.from(n).map((e) => e.textContent ?? "").join(" ") : e.textContent ?? "";
|
|
155
|
+
}
|
|
156
|
+
var _ = (e) => e.replace(/\s+/g, " ").trim().toLowerCase(), v = "a[href], button, input, select, textarea, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"switch\"], [role=\"tab\"], [role=\"menuitem\"], [role=\"option\"], [role=\"combobox\"], [role=\"textbox\"]";
|
|
157
|
+
function y(e) {
|
|
158
|
+
if (e.length < 2) return e;
|
|
159
|
+
let t = (e, t) => {
|
|
160
|
+
let n = e.matches(v);
|
|
161
|
+
return n === t.matches(v) ? t.contains(e) : n;
|
|
162
|
+
};
|
|
163
|
+
return e.filter((n) => !e.some((e) => e !== n && (n.contains(e) || e.contains(n)) && t(e, n)));
|
|
164
|
+
}
|
|
165
|
+
function b(e, t) {
|
|
166
|
+
try {
|
|
167
|
+
return Array.from(e.querySelectorAll(t));
|
|
168
|
+
} catch {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function x(e) {
|
|
173
|
+
try {
|
|
174
|
+
let t = e.contentDocument;
|
|
175
|
+
return !!t && !!t.defaultView;
|
|
176
|
+
} catch {
|
|
177
|
+
return !1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function S(e) {
|
|
181
|
+
let t = [], n = (e) => {
|
|
182
|
+
e instanceof HTMLElement && e.shadowRoot && !e.hasAttribute("data-heypointer-author") && (t.push(e.shadowRoot), n(e.shadowRoot));
|
|
183
|
+
for (let t of Array.from(e.childNodes)) n(t);
|
|
184
|
+
};
|
|
185
|
+
return n(e), t;
|
|
186
|
+
}
|
|
187
|
+
function C(e) {
|
|
188
|
+
let t = [], n = Array.from(e.querySelectorAll("iframe"));
|
|
189
|
+
for (let e of n) x(e) && e.contentDocument && t.push(e.contentDocument);
|
|
190
|
+
return t;
|
|
191
|
+
}
|
|
192
|
+
function w(e) {
|
|
193
|
+
let t = [e];
|
|
194
|
+
return t.push(...S(e)), t.push(...C(e)), t;
|
|
195
|
+
}
|
|
196
|
+
function T(e, t) {
|
|
197
|
+
let n = [];
|
|
198
|
+
for (let r of e) n.push(...t(r));
|
|
199
|
+
return { hits: n };
|
|
200
|
+
}
|
|
201
|
+
function E(e, t = document) {
|
|
202
|
+
let n = w(t), r = 0, i = (e, t) => e.length === 1 ? {
|
|
203
|
+
status: "found",
|
|
204
|
+
element: e[0],
|
|
205
|
+
strategy: t
|
|
206
|
+
} : (e.length > 1 && (r = Math.max(r, e.length)), null);
|
|
207
|
+
for (let t of e.selectors) {
|
|
208
|
+
let { hits: e } = T(n, (e) => b(e, t).filter(h)), r = i(e, "selector");
|
|
209
|
+
if (r) return r;
|
|
210
|
+
}
|
|
211
|
+
let a = e.text ? _(e.text) : "";
|
|
212
|
+
if (e.role && a) {
|
|
213
|
+
let t = p[e.role] ?? `[role="${CSS.escape(e.role)}"]`, { hits: r } = T(n, (e) => b(e, t).filter((e) => h(e) && _(g(e)) === a)), o = i(r, "role-text");
|
|
214
|
+
if (o) return o;
|
|
215
|
+
}
|
|
216
|
+
let o = e.label ? _(e.label) : "";
|
|
217
|
+
if (o) {
|
|
218
|
+
let { hits: e } = T(n, (e) => b(e, "input, select, textarea, [role=\"textbox\"], [role=\"combobox\"]").filter((e) => h(e) && _(g(e)) === o)), t = i(e, "label");
|
|
219
|
+
if (t) return t;
|
|
220
|
+
}
|
|
221
|
+
if (a) {
|
|
222
|
+
let { hits: e } = T(n, (e) => b(e, "button, a, label, [role], input, select, textarea, h1, h2, h3, li, p, span").filter((e) => h(e) && _(g(e)) === a)), t = i(y(e.filter((t) => !(t instanceof HTMLLabelElement && t.control instanceof HTMLElement && e.includes(t.control)))), "text");
|
|
223
|
+
if (t) return t;
|
|
224
|
+
}
|
|
225
|
+
return r ? {
|
|
226
|
+
status: "ambiguous",
|
|
227
|
+
count: r
|
|
228
|
+
} : { status: "missing" };
|
|
229
|
+
}
|
|
230
|
+
function D(e, t = document) {
|
|
231
|
+
let n = E(e, t);
|
|
232
|
+
return n.status === "found" ? {
|
|
233
|
+
element: n.element,
|
|
234
|
+
strategy: n.strategy
|
|
235
|
+
} : null;
|
|
236
|
+
}
|
|
237
|
+
function O(e, t = 1500, n = document) {
|
|
238
|
+
let r = E(e, n);
|
|
239
|
+
return r.status === "found" || t <= 0 ? Promise.resolve(r) : new Promise((r) => {
|
|
240
|
+
let i = (e) => {
|
|
241
|
+
a.disconnect(), clearTimeout(o), r(e);
|
|
242
|
+
}, a = new MutationObserver(() => {
|
|
243
|
+
let t = E(e, n);
|
|
244
|
+
t.status === "found" && i(t);
|
|
245
|
+
});
|
|
246
|
+
a.observe(n, {
|
|
247
|
+
childList: !0,
|
|
248
|
+
subtree: !0,
|
|
249
|
+
attributes: !0
|
|
250
|
+
});
|
|
251
|
+
let o = setTimeout(() => i(E(e, n)), t);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
async function k(e, t = 1500, n = document) {
|
|
255
|
+
let r = await O(e, t, n);
|
|
256
|
+
return r.status === "found" ? {
|
|
257
|
+
element: r.element,
|
|
258
|
+
strategy: r.strategy
|
|
259
|
+
} : null;
|
|
260
|
+
}
|
|
261
|
+
// src/theme.ts
|
|
262
|
+
var A = [
|
|
263
|
+
"auto",
|
|
264
|
+
"light",
|
|
265
|
+
"dark"
|
|
266
|
+
], j = [
|
|
267
|
+
"accent",
|
|
268
|
+
"accentFg",
|
|
269
|
+
"bg",
|
|
270
|
+
"fg",
|
|
271
|
+
"muted",
|
|
272
|
+
"border",
|
|
273
|
+
"warnBg",
|
|
274
|
+
"warnBorder",
|
|
275
|
+
"errBg",
|
|
276
|
+
"errBorder",
|
|
277
|
+
"focus",
|
|
278
|
+
"halo",
|
|
279
|
+
"ring",
|
|
280
|
+
"dim"
|
|
281
|
+
], M = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), N = /[;{}@\\<>"'`\u0000-\u001f]|url\(|expression\(|\/\*|javascript:|image\(|image-set\(/i, P = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, F = /^[a-z]{3,30}$/i, I = /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\([0-9a-z%.,/\s+-]{1,120}\)$/i, L = /^var\(--[a-z0-9_-]{1,60}\)$/i, R = /^\d{1,3}(?:\.\d{1,3})?(?:px|rem|em)$/, z = /^[A-Za-z0-9 ,_'"-]{1,200}$/;
|
|
282
|
+
function B(e) {
|
|
283
|
+
if (typeof e != "string") return !1;
|
|
284
|
+
let t = e.trim();
|
|
285
|
+
return !t || t.length > 140 || N.test(t) ? !1 : P.test(t) || F.test(t) || I.test(t) || L.test(t);
|
|
286
|
+
}
|
|
287
|
+
var V = (e) => typeof e == "string" && R.test(e.trim()), H = (e) => typeof e == "string" && z.test(e.trim()) && !/url|expression/i.test(e);
|
|
288
|
+
function U(e, t, n) {
|
|
289
|
+
let r = {};
|
|
290
|
+
if (e === void 0 || !e || typeof e != "object" || Array.isArray(e)) return r;
|
|
291
|
+
for (let [t, n] of Object.entries(e)) t !== "dark" && t !== "radius" && t !== "font" && t !== "fontSize" && j.includes(t) && B(n) && (r[t] = n.trim());
|
|
292
|
+
return r;
|
|
293
|
+
}
|
|
294
|
+
function W(e) {
|
|
295
|
+
let t = [];
|
|
296
|
+
if (e == null) return {
|
|
297
|
+
theme: {},
|
|
298
|
+
problems: t
|
|
299
|
+
};
|
|
300
|
+
if (typeof e != "object" || Array.isArray(e)) return {
|
|
301
|
+
theme: {},
|
|
302
|
+
problems: []
|
|
303
|
+
};
|
|
304
|
+
let n = e, r = U(n, "theme", t);
|
|
305
|
+
if (n.radius !== void 0 && V(n.radius) && (r.radius = n.radius.trim()), n.fontSize !== void 0 && V(n.fontSize) && (r.fontSize = n.fontSize.trim()), n.font !== void 0 && H(n.font) && (r.font = n.font.trim()), n.dark !== void 0) {
|
|
306
|
+
let e = U(n.dark, "theme.dark", t);
|
|
307
|
+
Object.keys(e).length && (r.dark = e);
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
theme: r,
|
|
311
|
+
problems: t
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function G(e) {
|
|
315
|
+
let t = {};
|
|
316
|
+
for (let n of j) e[n] && (t[`--hp-${M(n)}`] = e[n]), e.dark?.[n] && (t[`--hp-dark-${M(n)}`] = e.dark[n]);
|
|
317
|
+
return e.radius && (t["--hp-radius"] = e.radius), e.font && (t["--hp-font"] = e.font), e.fontSize && (t["--hp-font-size"] = e.fontSize), t;
|
|
318
|
+
}
|
|
319
|
+
export { h as a, O as c, e as d, a as f, o as h, g as i, k as l, s as m, W as n, E as o, c as p, G as r, D as s, A as t, f as u };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type LabelKey } from './labels';
|
|
2
|
+
import type { Walkthrough } from './types';
|
|
3
|
+
export interface ClientOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Publishable client id from `heypointer init` (`gfc_` + 24 hex). Not a secret; sent as X-HeyPointer-Client. */
|
|
6
|
+
clientId?: string;
|
|
7
|
+
fetch?: typeof fetch;
|
|
8
|
+
/** Looks up a user-visible message by label key (host overrides, translations). Defaults to the English labels. */
|
|
9
|
+
text?: (key: LabelKey, vars?: Record<string, string | number>) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare const CLIENT_ID_PATTERN: RegExp;
|
|
12
|
+
export declare const CLIENT_HEADER = "X-HeyPointer-Client";
|
|
13
|
+
export declare const MSG_CLIENT_REQUIRED: "HeyPointer needs a client ID. Run heypointer init or pass data-client-id.";
|
|
14
|
+
export declare class SpeechUnavailableError extends Error {
|
|
15
|
+
}
|
|
16
|
+
/** Server heard no speech (HTTP 400): the user can record again or type. */
|
|
17
|
+
export declare class NoSpeechError extends Error {
|
|
18
|
+
}
|
|
19
|
+
export declare class HeyPointerClient {
|
|
20
|
+
private readonly base;
|
|
21
|
+
private readonly fetchImpl;
|
|
22
|
+
private readonly clientId;
|
|
23
|
+
private readonly t;
|
|
24
|
+
constructor(opts: ClientOptions);
|
|
25
|
+
/** A bare "Failed to fetch" tells the user nothing. Say which server and what to check. */
|
|
26
|
+
private send;
|
|
27
|
+
requestWalkthrough(goal: string, context?: {
|
|
28
|
+
url?: string;
|
|
29
|
+
}): Promise<Walkthrough>;
|
|
30
|
+
/** Throws SpeechUnavailableError when the server has no transcription provider. */
|
|
31
|
+
transcribe(audio: Blob): Promise<string>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ColorScheme, HeyPointerTheme } from './theme';
|
|
2
|
+
/** WCAG contrast ratio of two opaque hex or rgb() colors; null when either cannot be parsed (named colors, hsl, var()). */
|
|
3
|
+
export declare function contrastRatio(a: string, b: string): number | null;
|
|
4
|
+
/** Messages for pairs a theme makes unreadable (below 4.5:1). Advice only: nothing is blocked or changed. */
|
|
5
|
+
export declare function contrastProblems(theme: HeyPointerTheme, scheme: ColorScheme): string[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { HeyPointer } from './player';
|
|
2
|
+
import { type HeyPointerLabels } from './labels';
|
|
3
|
+
import type { HeyPointerTheme } from './theme';
|
|
4
|
+
export declare const HEYPOINTER_TAG = "heypointer-assistant";
|
|
5
|
+
/**
|
|
6
|
+
* `<heypointer-assistant base-url="https://api.example.com" client-id="gfc_...">`: the one integration surface
|
|
7
|
+
* every web framework shares. React, Vue, Angular and Svelte render this element; none of
|
|
8
|
+
* them re-implement the player.
|
|
9
|
+
*
|
|
10
|
+
* Customizing (all optional): `labels` and `theme` (JSON), `color-scheme`, `dir`, `lang`, `launcher="none"`,
|
|
11
|
+
* `launcher-side="start"`. Labels, theme and layout change in place; the other attributes remount the guide.
|
|
12
|
+
*/
|
|
13
|
+
declare const ElementBase: typeof HTMLElement;
|
|
14
|
+
export declare class HeyPointerElement extends ElementBase {
|
|
15
|
+
static observedAttributes: string[];
|
|
16
|
+
private gf;
|
|
17
|
+
/** Set from code (`el.labels = {...}`): wins over the attribute and survives a remount. */
|
|
18
|
+
private labelsProp;
|
|
19
|
+
private themeProp;
|
|
20
|
+
/** The live player, once connected. For host-app code that needs `open()` or `ask()`. */
|
|
21
|
+
get player(): HeyPointer | null;
|
|
22
|
+
/** An object, or a JSON string (what a framework that assigns properties from attribute-style props passes). */
|
|
23
|
+
get labels(): HeyPointerLabels | undefined;
|
|
24
|
+
set labels(v: HeyPointerLabels | string | undefined);
|
|
25
|
+
get theme(): HeyPointerTheme | undefined;
|
|
26
|
+
set theme(v: HeyPointerTheme | string | undefined);
|
|
27
|
+
/** Replace the labels at runtime (a language switch). Same as assigning `el.labels`. */
|
|
28
|
+
setLabels(labels: HeyPointerLabels | undefined): void;
|
|
29
|
+
open(): void;
|
|
30
|
+
close(): void;
|
|
31
|
+
ask(goal: string): Promise<void>;
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
disconnectedCallback(): void;
|
|
34
|
+
attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
|
|
35
|
+
private currentLabels;
|
|
36
|
+
private currentTheme;
|
|
37
|
+
private scheme;
|
|
38
|
+
private layout;
|
|
39
|
+
private mount;
|
|
40
|
+
}
|
|
41
|
+
/** Register the element once. Safe to call repeatedly and from several bundles. */
|
|
42
|
+
export declare function defineHeyPointerElement(tag?: string): void;
|
|
43
|
+
export {};
|
package/dist/element.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as HEYPOINTER_TAG, n as HeyPointerElement, r as defineHeyPointerElement } from "./chunk-element.js";
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){var e={button:`button, [role="button"], input[type="button"], input[type="submit"]`,link:`a[href], [role="link"]`,textbox:`input:not([type]), input[type="text"], input[type="email"], input[type="search"], textarea, [role="textbox"]`,combobox:`select, [role="combobox"]`,checkbox:`input[type="checkbox"], [role="checkbox"]`};function t(e){for(let t=e;t;t=t.parentElement){if(t.hidden||t.getAttribute(`aria-hidden`)===`true`||t.hasAttribute(`inert`))return!1;let e=getComputedStyle(t);if(e.display===`none`||e.visibility===`hidden`)return!1}return!0}function n(e){if(!e.isConnected||!t(e))return!1;if(typeof e.checkVisibility!=`function`)return!0;if(!e.checkVisibility({checkVisibilityCSS:!0,contentVisibilityAuto:!0})||!e.getClientRects().length)return!1;let n=e.getBoundingClientRect();return n.width>0||n.height>0}function r(e){let t=e.getAttribute(`aria-label`);if(t)return t;let n=e.labels;return n&&n.length?Array.from(n).map(e=>e.textContent??``).join(` `):e.textContent??``}var i=e=>e.replace(/\s+/g,` `).trim().toLowerCase(),a=`a[href], button, input, select, textarea, summary, [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="tab"], [role="menuitem"], [role="option"], [role="combobox"], [role="textbox"]`;function o(e){if(e.length<2)return e;let t=(e,t)=>{let n=e.matches(a);return n===t.matches(a)?t.contains(e):n};return e.filter(n=>!e.some(e=>e!==n&&(n.contains(e)||e.contains(n))&&t(e,n)))}function s(e,t){try{return Array.from(e.querySelectorAll(t))}catch{return[]}}function c(e){try{let t=e.contentDocument;return!!t&&!!t.defaultView}catch{return!1}}function l(e){let t=[],n=e=>{e instanceof HTMLElement&&e.shadowRoot&&!e.hasAttribute(`data-heypointer-author`)&&(t.push(e.shadowRoot),n(e.shadowRoot));for(let t of Array.from(e.childNodes))n(t)};return n(e),t}function u(e){let t=[],n=Array.from(e.querySelectorAll(`iframe`));for(let e of n)c(e)&&e.contentDocument&&t.push(e.contentDocument);return t}function d(e){let t=[e];return t.push(...l(e)),t.push(...u(e)),t}function f(e,t){let n=[];for(let r of e)n.push(...t(r));return{hits:n}}function p(t,a=document){let c=d(a),l=0,u=(e,t)=>e.length===1?{status:`found`,element:e[0],strategy:t}:(e.length>1&&(l=Math.max(l,e.length)),null);for(let e of t.selectors){let{hits:t}=f(c,t=>s(t,e).filter(n)),r=u(t,`selector`);if(r)return r}let p=t.text?i(t.text):``;if(t.role&&p){let a=e[t.role]??`[role="${CSS.escape(t.role)}"]`,{hits:o}=f(c,e=>s(e,a).filter(e=>n(e)&&i(r(e))===p)),l=u(o,`role-text`);if(l)return l}let m=t.label?i(t.label):``;if(m){let{hits:e}=f(c,e=>s(e,`input, select, textarea, [role="textbox"], [role="combobox"]`).filter(e=>n(e)&&i(r(e))===m)),t=u(e,`label`);if(t)return t}if(p){let{hits:e}=f(c,e=>s(e,`button, a, label, [role], input, select, textarea, h1, h2, h3, li, p, span`).filter(e=>n(e)&&i(r(e))===p)),t=u(o(e.filter(t=>!(t instanceof HTMLLabelElement&&t.control instanceof HTMLElement&&e.includes(t.control)))),`text`);if(t)return t}return l?{status:`ambiguous`,count:l}:{status:`missing`}}var m=/\{(\w+)\}/g;function ee(e,t={}){return e.replace(m,(e,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):e)}function h(e,t){if(t!=null&&t.trim())try{return JSON.parse(t)}catch{return}}var te=[`auto`,`light`,`dark`],g=[`accent`,`accentFg`,`bg`,`fg`,`muted`,`border`,`warnBg`,`warnBorder`,`errBg`,`errBorder`,`focus`,`halo`,`ring`,`dim`],_=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ne=/[;{}@\\<>"'`\u0000-\u001f]|url\(|expression\(|\/\*|javascript:|image\(|image-set\(/i,re=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ie=/^[a-z]{3,30}$/i,ae=/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\([0-9a-z%.,/\s+-]{1,120}\)$/i,oe=/^var\(--[a-z0-9_-]{1,60}\)$/i,se=/^\d{1,3}(?:\.\d{1,3})?(?:px|rem|em)$/,ce=/^[A-Za-z0-9 ,_'"-]{1,200}$/;function le(e){if(typeof e!=`string`)return!1;let t=e.trim();return!t||t.length>140||ne.test(t)?!1:re.test(t)||ie.test(t)||ae.test(t)||oe.test(t)}var v=e=>typeof e==`string`&&se.test(e.trim()),ue=e=>typeof e==`string`&&ce.test(e.trim())&&!/url|expression/i.test(e);function y(e,t,n){let r={};if(e===void 0||!e||typeof e!=`object`||Array.isArray(e))return r;for(let[t,n]of Object.entries(e))t!==`dark`&&t!==`radius`&&t!==`font`&&t!==`fontSize`&&g.includes(t)&&le(n)&&(r[t]=n.trim());return r}function de(e){let t=[];if(e==null)return{theme:{},problems:t};if(typeof e!=`object`||Array.isArray(e))return{theme:{},problems:[]};let n=e,r=y(n,`theme`,t);if(n.radius!==void 0&&v(n.radius)&&(r.radius=n.radius.trim()),n.fontSize!==void 0&&v(n.fontSize)&&(r.fontSize=n.fontSize.trim()),n.font!==void 0&&ue(n.font)&&(r.font=n.font.trim()),n.dark!==void 0){let e=y(n.dark,`theme.dark`,t);Object.keys(e).length&&(r.dark=e)}return{theme:r,problems:t}}function fe(e){let t={};for(let n of g)e[n]&&(t[`--hp-${_(n)}`]=e[n]),e.dark?.[n]&&(t[`--hp-dark-${_(n)}`]=e.dark[n]);return e.radius&&(t[`--hp-radius`]=e.radius),e.font&&(t[`--hp-font`]=e.font),e.fontSize&&(t[`--hp-font-size`]=e.fontSize),t}var pe=/^(send|submit|delete|remove|pay|purchase|buy|publish|transfer|confirm|deploy|cancel)\b/i,b=e=>!!e&&pe.test(e.trim()),x=e=>e.replace(/[\u0000-\u001f\u007f-\u009f]+/g,` `).replace(/\s+/g,` `).trim(),S=e=>x(e).replace(/["“”]/g,`'`),me=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`flow`,he=e=>[...e.matchAll(/["“]([^"”]+)["”]/g)].map(e=>e[1]),C=e=>[...e.matchAll(/"([^"]+)"|“([^”]+)”/g)].map(e=>(e[1]??e[2]??``).trim()).filter(Boolean)[0]??``,ge=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;function _e(e,t=!1){let n=ge(e),r=he(n).some(e=>b(e));return(t||r)&&!/\bconsequential\b/i.test(n)?`${n} This is a consequential action.`:n}function ve(e,t={}){let n=[`# PRD: ${e.title}`,``];return t.note&&n.push(t.note,``),e.steps.forEach((e,r)=>n.push(`${r+1}. ${_e(e,t.consequential?.has(r))}`)),`${n.join(`
|
|
2
|
+
`)}\n`}function ye(e,t){let n=[];return x(e.title)||n.push(t),e.steps.length===0&&n.push(`a flow needs at least one step`),e.steps.forEach((e,t)=>{C(e)||n.push(`step ${t+1} names no control: put the visible label in quotes, e.g. Click "Change plan"`)}),n}function w(e){let t=e.split(`/`).map(e=>{let t=e;try{t=decodeURIComponent(e)}catch{}return/^\d{4,}$/.test(t)||/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(t)||/^[0-9a-f]{16,}$/i.test(t)||t.length>40?`:id`:x(t).replace(/[^\w.~:-]/g,`_`)}).join(`/`)||`/`;return t.startsWith(`/`)?t:`/${t}`}var T=/pass|token|secret|otp|card|cvv|cvc|iban|ssn|pin\b/i,be=/^(cc-|one-time-code|current-password|new-password)/i,E=e=>e&&e.nodeType===1?e.tagName.toLowerCase():``,D=e=>(e.getAttribute(`type`)??``).toLowerCase();function O(e){let t=E(e);return t!==`input`&&t!==`textarea`&&t!==`select`?!1:t===`input`&&D(e)===`password`||(e.getAttribute(`autocomplete`)??``).split(/\s+/).some(e=>be.test(e))?!0:T.test(e.getAttribute(`name`)??``)||T.test(e.id)}var xe=`input, select, textarea`;function k(e){return S((e.matches(xe)?e.getAttribute(`aria-label`)||Array.from(e.labels??[]).map(e=>e.textContent??``).join(` `):r(e))??``).slice(0,144)}var Se=/[^\s@]+@[^\s@]+\.[a-z]{2,}/i,Ce=/\d[\d\s().-]{4,}\d/,we=/[$€£¥]\s?\d|\d[.,]\d{2}\b/,Te=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i,Ee=/^(?:[A-Z][\p{L}'’-]+)(?:\s+[A-Z][\p{L}'’-]+){1,3}$/u,De=`tr, td, th, li, [role="row"], [role="gridcell"], [role="cell"], [role="listitem"], [role="option"], article, [role="article"]`;function A(e,t){return!!(Se.test(e)||Ce.test(e)||we.test(e)||Te.test(e)||t?.closest(De)&&(Ee.test(e)||/\d/.test(e)))}var Oe=`button, a[href], summary, input[type="button"], input[type="submit"], input[type="reset"], input[type="image"], input[type="checkbox"], input[type="radio"], [role="button"], [role="link"], [role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="tab"], [role="switch"], [role="checkbox"], [role="radio"], [role="option"]`,j=e=>e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`||!!e.closest(`fieldset:disabled`),M=e=>n(e)&&!j(e),ke=new Set([`text`,`search`,`email`,`tel`,`url`,`number`,`password`,`date`,`datetime-local`,`month`,`week`,`time`,``]),Ae=e=>E(e)===`textarea`||E(e)===`input`&&ke.has(D(e));function N(e){for(let t=e.parentElement;t;t=t.parentElement){let e=t.getAttribute(`role`);if(!t.matches(`dialog, form, nav, section, aside, [role="dialog"], [role="alertdialog"], [role="region"], [role="form"], [role="navigation"], [role="menu"], [role="toolbar"]`)&&!t.hasAttribute(`aria-label`))continue;let n=t.getAttribute(`aria-label`)??``,r=t.getAttribute(`aria-labelledby`);if(!n&&r&&(n=r.split(/\s+/).map(e=>t.ownerDocument.getElementById(e)?.textContent??``).join(` `)),n||e!==`dialog`&&t.tagName!==`DIALOG`||(n=t.querySelector(`h1, h2, h3`)?.textContent??``),n=S(n).slice(0,40),n)return n}return``}function P(e){"@babel/helpers - typeof";return P=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},P(e)}function je(e,t){if(P(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(P(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Me(e){var t=je(e,`string`);return P(t)==`symbol`?t:t+``}function F(e,t,n){return(t=Me(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ne=`tr, td, th, li, [role="row"], [role="gridcell"], [role="cell"], [role="listitem"]`,Pe=400,I=e=>{if(e.parentElement)return e.parentElement;let t=e.getRootNode();return t.nodeType===11&&t.host?t.host:null},Fe=class{constructor(e){F(this,`o`,void 0),F(this,`docs`,new Set),F(this,`lastKey`,``),F(this,`lastAt`,0),F(this,`lastTyped`,null),F(this,`lastPath`,``),F(this,`timer`,void 0),F(this,`observer`,void 0),F(this,`frameLoads`,new Map),F(this,`onClick`,e=>{let t=this.accept(e);if(!t)return;let n=this.control(t.target),r=!1;if(!n&&this.o.recordRows()&&(n=t.target.closest(Ne),r=!!n),!n||j(n)||!M(n))return;let i=r?k(n).slice(0,72):k(n);this.emit({kind:`click`,label:i,sensitive:!1,pageData:r||A(i,n),context:N(n),el:n},`click:${i}`)}),F(this,`onInput`,e=>{let t=this.accept(e);if(!t||!Ae(t.target))return;let n=t.target;if(this.lastTyped===n||!M(n))return;let r=k(n);this.emit({kind:`type`,label:r,sensitive:O(n),pageData:!1,context:N(n),el:n},`type:${r}`),this.lastTyped=n}),F(this,`onChange`,e=>{let t=this.accept(e);if(!t)return;let n=t.target;if(!(E(n)===`select`||E(n)===`input`&&D(n)===`file`)||!M(n))return;let r=k(n);this.emit({kind:`select`,label:r,sensitive:O(n),pageData:!1,context:N(n),el:n},`select:${r}`)}),F(this,`onSubmit`,e=>{let t=this.accept(e);if(!t||e.submitter)return;let n=t.target.closest(`form`)?.querySelector(`button[type="submit"], button:not([type]), input[type="submit"]`);if(!n||!M(n))return;let r=k(n);this.emit({kind:`click`,label:r,sensitive:!1,pageData:A(r,n),context:N(n),el:n},`click:${r}`)}),this.o=e}start(){this.attach(document),this.scanFrames(document),this.lastPath=w(location.pathname),this.observer=new MutationObserver(e=>{for(let t of e)for(let e of Array.from(t.addedNodes))e instanceof Element&&this.scanFrames(e.tagName===`IFRAME`?e.ownerDocument:e)}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0}),this.timer=setInterval(()=>this.checkRoute(),500)}stop(){this.observer?.disconnect(),this.timer&&clearInterval(this.timer);for(let[e,t]of this.frameLoads)e.removeEventListener(`load`,t);this.frameLoads.clear();for(let e of this.docs)this.detach(e);this.docs.clear()}checkRoute(){if(!this.o.isRecording())return;let e=w(location.pathname);e!==this.lastPath&&(this.lastPath=e,this.o.onPage(e))}syncRoute(){this.lastPath=w(location.pathname)}scanFrames(e){let t=E(e)===`iframe`?[e]:Array.from(e.querySelectorAll(`iframe`));for(let e of t){if(!this.frameLoads.has(e)){let t=()=>this.attachFrame(e);e.addEventListener(`load`,t),this.frameLoads.set(e,t)}this.attachFrame(e)}}attachFrame(e){try{let t=e.contentDocument;t&&t.defaultView&&!this.docs.has(t)&&this.attach(t)}catch{}}attach(e){e.addEventListener(`click`,this.onClick,!0),e.addEventListener(`input`,this.onInput,!0),e.addEventListener(`change`,this.onChange,!0),e.addEventListener(`submit`,this.onSubmit,!0),this.docs.add(e)}detach(e){e.removeEventListener(`click`,this.onClick,!0),e.removeEventListener(`input`,this.onInput,!0),e.removeEventListener(`change`,this.onChange,!0),e.removeEventListener(`submit`,this.onSubmit,!0)}accept(e){if(!this.o.isRecording()||!e.isTrusted&&!this.o.acceptUntrusted)return null;let t=e.composedPath();if(this.o.isOwn(t))return null;let n=t[0],r=n?.nodeType===1?n:n?.nodeType===3?n.parentElement:null;return r?{path:t,target:r}:null}emit(e,t){let n=Date.now();t===this.lastKey&&n-this.lastAt<Pe||(this.lastKey=t,this.lastAt=n,e.kind!==`type`&&(this.lastTyped=null),this.o.onStep(e))}control(e){for(let t=e,n=0;t&&n<10;t=I(t),n++)if(E(t)===`label`){if(t.control)return null}else if(t.matches(Oe))return t;let t=null,n=e;for(let e=0;n&&e<4;n=I(n),e++)if(n.nodeType===1&&n.ownerDocument.defaultView?.getComputedStyle(n).cursor===`pointer`)t=n;else if(t)break;return t&&k(t).length<=72?t:null}},Ie={click:e=>`Click "${e}".`,type:e=>`Enter your ${e.toLowerCase().slice(0,30).trim()} in "${e}".`,select:e=>`Choose an option in "${e}".`};function Le(e,t){let n=S(t).slice(0,72).trim();return n?Ie[e](n):e===`click`?`Click the control.`:e===`type`?`Enter a value.`:`Choose an option.`}var L=e=>e.entries.filter(e=>e.t===`step`),R=e=>e.consequential||b(C(e.text));function z(e){let t=L(e),n=e.entries.filter(e=>e.t===`note`).map(e=>e.text),r=[`Recorded with HeyPointer author mode. Review every step before publishing.`,n.length?`Pages visited while recording: ${[...new Set(n)].join(`, `)}.`:``].filter(Boolean).join(` `),i=new Set;return t.forEach((e,t)=>e.consequential&&i.add(t)),ve({title:x(e.title),steps:t.map(e=>e.text)},{consequential:i,note:r})}var Re=(e,t)=>ye({title:e.title,steps:L(e).map(e=>e.text)},t),ze=e=>`${me(e.title)}.md`,Be=class{constructor(e){F(this,`draft`,void 0),F(this,`nextId`,1),F(this,`listeners`,new Set),this.draft=e??{title:``,entries:[]},this.nextId=this.draft.entries.reduce((e,t)=>Math.max(e,t.id),0)+1}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(){for(let e of this.listeners)e()}get stepCount(){return L(this.draft).length}get full(){return this.stepCount>=100}setTitle(e){this.draft.title=x(e).slice(0,80),this.emit()}addStep(e){if(this.full)return null;let t={...e,t:`step`,id:this.nextId++,text:e.text.slice(0,120)};return this.draft.entries.push(t),this.emit(),t}addNote(e){let t=this.draft.entries[this.draft.entries.length-1];(t?.t!==`note`||t.text!==e)&&(this.draft.entries.push({t:`note`,id:this.nextId++,text:e}),this.emit())}find(e){return this.draft.entries.find(t=>t.id===e)}editText(e,t,n=!1){let r=this.find(e);return r?.t===`step`?(r.text=x(t).slice(0,120),n||this.emit(),r):null}setStatus(e,t,n){let r=this.find(e);r?.t===`step`&&(r.status=t,n!==void 0&&(r.pageData=n),this.emit())}toggleConsequential(e){let t=this.find(e);t?.t===`step`&&(t.consequential=!t.consequential,this.emit())}move(e,t){let n=this.draft.entries,r=n.filter(e=>e.t===`step`),i=r.findIndex(t=>t.id===e),a=i+t;if(i<0||a<0||a>=r.length)return;let o=n.indexOf(r[i]),s=n.indexOf(r[a]);[n[o],n[s]]=[n[s],n[o]],this.emit()}remove(e){this.draft.entries=this.draft.entries.filter(t=>t.id!==e),this.emit()}undo(){let e=this.draft.entries,t=e.length-1;for(;t>=0&&e[t].t===`note`;)t--;return t<0?!1:(e.length=t,this.emit(),!0)}clear(){this.draft={title:``,entries:[]},this.emit()}},B=`heypointer:author:draft:v1`,V=`heypointer:author:active:v1`,Ve=e=>!!e&&typeof e==`object`&&[`unique`,`ambiguous`,`noname`,`notfound`,`unchecked`].includes(e.kind);function He(e){try{let t=e?.getItem(B);if(!t)return null;let n=JSON.parse(t);if(!n.draft||typeof n.draft.title!=`string`||!Array.isArray(n.draft.entries))return null;let r=[];for(let e of n.draft.entries.slice(0,300))e?.t===`note`&&typeof e.text==`string`?r.push({t:`note`,id:Number(e.id)||r.length+1,text:x(e.text).slice(0,120)}):e?.t===`step`&&typeof e.text==`string`&&[`click`,`type`,`select`].includes(e.kind)&&Ve(e.status)&&r.push({t:`step`,id:Number(e.id)||r.length+1,kind:e.kind,text:x(e.text).slice(0,120),consequential:e.consequential===!0,status:e.status,pageData:e.pageData===!0,sensitive:e.sensitive===!0,context:typeof e.context==`string`?x(e.context).slice(0,40):``});return{draft:{title:x(n.draft.title).slice(0,80),entries:r},recording:n.recording===!0}}catch{return null}}function Ue(e,t){try{e?.setItem(B,JSON.stringify(t)),e?.setItem(V,`1`)}catch{}}function H(e){try{e?.removeItem(B),e?.removeItem(V)}catch{}}function U(){try{return typeof sessionStorage>`u`?null:sessionStorage}catch{return null}}var W={authorDialogName:`HeyPointer author mode`,authorTitle:`Record steps`,authorMinimize:`Minimize`,authorClose:`Close author mode`,authorMove:`Move the panel to the other side`,authorSteps:`Steps ({count})`,authorAbout:`Privacy and shortcuts`,authorExpand:`Expand`,authorFlowTitle:`Flow title`,authorFlowTitlePlaceholder:`e.g. Add a product to the cart`,authorRecord:`Record`,authorPause:`Pause`,authorResume:`Resume`,authorStop:`Stop and review`,authorUndo:`Undo last step`,authorRows:`Record clicks on table rows and cells (they usually contain page data)`,authorStatusIdle:`Not recording. Press Record, then use your app the way a person would.`,authorStatusRecording:`Recording. {count} steps so far.`,authorStatusPaused:`Paused. {count} steps so far.`,authorStatusReview:`Review the draft. Nothing is sent anywhere.`,authorEmpty:`No steps yet. Click, type or choose something in your app.`,authorStepText:`Step {n} text`,authorMoveUp:`Move step {n} up`,authorMoveDown:`Move step {n} down`,authorDelete:`Delete step {n}`,authorDeleteNote:`Delete note`,authorConsequential:`Needs confirmation`,authorConsequentialAuto:`Needs confirmation (added automatically because of the label)`,authorChipUnique:`Unique control`,authorChipAmbiguous:`Ambiguous: {count} matches`,authorChipNoName:`No accessible name`,authorChipPageData:`Contains page data`,authorChipNotFound:`Not found by the guide`,authorChipUnchecked:`Not on this page`,authorChipSensitive:`Sensitive field`,authorHintAmbiguous:`The guide will not guess between {count} controls. Give this one an aria-label or visible text that is unique.`,authorHintNoName:`Add an aria-label or visible text so the guide can find this control.`,authorHintPageData:`This text looks like data from the page (a name, an email or a number). Change it so it names the control, not the data.`,authorHintNotFound:`The guide would not find a control with this exact text. Check the text, or give the control a role and a label.`,authorHintUnchecked:`This control is not on the current page, so it was not checked.`,authorHintSensitive:`Only the field label is recorded. What is typed here is never captured.`,authorAddContext:`Add context ({context})`,authorRecheck:`Re-check all`,authorNote:`Now on {path}`,authorPreview:`Preview`,authorProblems:`Fix these before copying:`,authorTitleRequired:`Give the flow a title.`,authorCopy:`Copy Markdown`,authorCopied:`Copied to the clipboard.`,authorCopyFailed:`Could not copy. Select the text and copy it yourself.`,authorDownload:`Download {file}`,authorKeepRecording:`Keep recording`,authorDiscard:`Discard draft`,authorDiscardConfirm:`Discard this draft? The recorded steps are lost.`,authorNextHeading:`Then, from your project folder:`,authorPrivacy:`Nothing leaves this page. Typed values are never recorded, but control labels can contain page data, so read every step before you share it.`,authorLimit:`You reached {max} steps, the most one flow can have. Stop and review.`,authorShortcut:`Alt+Shift+G moves focus to this panel.`},We=/\{(\w+)\}/g,G=e=>[...new Set([...e.matchAll(We)].map(e=>e[1]))];function K(e){let t={...W};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){if(!n.startsWith(`author`)||!Object.prototype.hasOwnProperty.call(W,n))continue;let e=n;if(typeof r!=`string`||!r.trim()||r.length>300)continue;let i=G(r);G(W[e]).filter(e=>!i.includes(e)).length||(t[e]=r)}return t}var Ge=(e,t,n)=>ee(e[t],n),q=`:host{all:initial;pointer-events:none;--a-accent:var(--hp-accent,#087ea4);--a-accent-fg:var(--hp-accent-fg,#fff);--a-bg:var(--hp-bg,#fff);--a-fg:var(--hp-fg,#172b3a);--a-muted:var(--hp-muted,#334155);--a-border:var(--hp-border,#64748b);--a-warn-bg:var(--hp-warn-bg,#fef3c7);--a-warn-bd:var(--hp-warn-border,#92400e);--a-err-bg:var(--hp-err-bg,#fee2e2);--a-err-bd:var(--hp-err-border,#b91c1c);--a-ok-bg:#dcfce7;--a-ok-fg:#14532d;--a-focus:var(--hp-focus,#1e3a8a);--a-halo:var(--hp-halo,#fff);--a-radius:var(--hp-radius,12px);--a-rec:#b91c1c;font-family:var(--hp-font,system-ui, sans-serif);font-size:var(--hp-font-size,14px);color:var(--a-fg);line-height:1.45}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])){--a-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--a-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--a-bg:var(--hp-dark-bg,#0f172a);--a-fg:var(--hp-dark-fg,#f1f5f9);--a-muted:var(--hp-dark-muted,#cbd5e1);--a-border:var(--hp-dark-border,#94a3b8);--a-warn-bg:var(--hp-dark-warn-bg,#422006);--a-warn-bd:var(--hp-dark-warn-border,#fbbf24);--a-err-bg:var(--hp-dark-err-bg,#450a0a);--a-err-bd:var(--hp-dark-err-border,#f87171);--a-ok-bg:#14532d;--a-ok-fg:#bbf7d0;--a-focus:var(--hp-dark-focus,#fff);--a-halo:var(--hp-dark-halo,#1e3a8a);--a-rec:#f87171}}:host([data-scheme=dark]){--a-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--a-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--a-bg:var(--hp-dark-bg,#0f172a);--a-fg:var(--hp-dark-fg,#f1f5f9);--a-muted:var(--hp-dark-muted,#cbd5e1);--a-border:var(--hp-dark-border,#94a3b8);--a-warn-bg:var(--hp-dark-warn-bg,#422006);--a-warn-bd:var(--hp-dark-warn-border,#fbbf24);--a-err-bg:var(--hp-dark-err-bg,#450a0a);--a-err-bd:var(--hp-dark-err-border,#f87171);--a-ok-bg:#14532d;--a-ok-fg:#bbf7d0;--a-focus:var(--hp-dark-focus,#fff);--a-halo:var(--hp-dark-halo,#1e3a8a);--a-rec:#f87171}*,:before,:after{box-sizing:border-box}.panel{pointer-events:auto;z-index:2147483647;background:var(--a-bg);max-block-size:min(82dvh,44rem);inline-size:min(400px,100vw - 32px);color:var(--a-fg);border:1px solid var(--a-border);border-radius:var(--a-radius);flex-direction:column;display:flex;position:fixed;bottom:16px;overflow:hidden;box-shadow:0 8px 30px #0005}.panel:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:16px}.panel:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:16px}.panel:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:16px}.panel:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:16px}.head{border-block-end:1px solid var(--a-border);justify-content:space-between;align-items:center;gap:8px;padding:10px 12px;display:flex}.panel[data-min] .head{border-block-end:0}.panel[data-min] .body{display:none}h2{align-items:center;gap:8px;margin:0;font-size:15px;display:flex}.dot{background:var(--a-border);border-radius:50%;flex:none;block-size:10px;inline-size:10px}.panel[data-mode=recording] .dot{background:var(--a-rec);animation:1.4s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.panel[data-mode=recording] .dot{animation:none}}.body{flex-direction:column;gap:10px;padding:12px;display:flex;overflow:auto}.status{color:var(--a-muted);margin:0}.row{flex-wrap:wrap;gap:8px;display:flex}.field{flex-direction:column;gap:4px;display:flex}.field>span{font-weight:600}.check{color:var(--a-muted);align-items:flex-start;gap:8px;display:flex}.check input{flex:none;block-size:16px;inline-size:16px;margin-block-start:3px}button,input[type=text]{font:inherit;color:var(--a-fg);background:var(--a-bg);border:1px solid var(--a-border);border-radius:8px;min-block-size:36px;padding:6px 10px}input[type=text]{inline-size:100%}button{cursor:pointer}button.primary{background:var(--a-accent);color:var(--a-accent-fg);border-color:var(--a-accent);font-weight:600}button.rec{background:var(--a-rec);color:#fff;border-color:var(--a-rec);font-weight:600}:host([data-scheme=dark]) button.rec{color:#450a0a}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])) button.rec{color:#450a0a}}button.icon{min-inline-size:36px;padding:4px 8px}button:disabled{opacity:.55;cursor:not-allowed}button:focus-visible{outline:2px solid var(--a-focus);outline-offset:2px;box-shadow:0 0 0 4px var(--a-halo)}input:focus-visible{outline:2px solid var(--a-focus);outline-offset:2px;box-shadow:0 0 0 4px var(--a-halo)}summary:focus-visible{outline:2px solid var(--a-focus);outline-offset:2px;box-shadow:0 0 0 4px var(--a-halo)}@media (pointer:coarse){button,input[type=text]{min-block-size:44px}button.icon{min-inline-size:44px}}ol.steps{flex-direction:column;gap:8px;margin:0;padding:0;list-style:none;display:flex}li.step,li.note{border:1px solid var(--a-border);border-radius:10px;flex-direction:column;gap:6px;padding:8px;display:flex}li.note{color:var(--a-muted);border-style:dashed;flex-direction:row;justify-content:space-between;align-items:center}.chips{flex-wrap:wrap;gap:6px;display:flex}.chip{border:1px solid #0000;border-radius:999px;padding:1px 8px;font-size:12px;font-weight:600}.chip.ok{background:var(--a-ok-bg);color:var(--a-ok-fg);border-color:var(--a-ok-fg)}.chip.warn{background:var(--a-warn-bg);color:var(--a-fg);border-color:var(--a-warn-bd)}.chip.err{background:var(--a-err-bg);color:var(--a-fg);border-color:var(--a-err-bd)}.chip.info{color:var(--a-muted);border-color:var(--a-border);background:0 0}.hint{color:var(--a-muted);margin:0;font-size:13px}.acts{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.acts .check{flex:auto;font-size:13px}.problems{background:var(--a-err-bg);border:1px solid var(--a-err-bd);border-radius:8px;margin:0;padding:8px 8px 8px 24px}pre{background:color-mix(in srgb, var(--a-fg) 7%, var(--a-bg));border:1px solid var(--a-border);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;max-block-size:14rem;margin:0;padding:8px;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;overflow:auto}code{font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.cmds{flex-direction:column;gap:4px;display:flex}.cmds code{background:color-mix(in srgb, var(--a-fg) 7%, var(--a-bg));overflow-wrap:anywhere;border-radius:6px;padding:4px 6px;display:block}.small{color:var(--a-muted);margin:0;font-size:12px}.sr{clip:rect(0 0 0 0);white-space:nowrap;block-size:1px;inline-size:1px;position:absolute;overflow:hidden}[hidden]{display:none!important}.flush{padding:0;overflow:visible}.h3{margin:0;font-size:14px}:host([data-side=end]) .panel:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:auto;right:16px}:host([data-side=end]) .panel:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:auto;right:16px}:host([data-side=end]) .panel:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:16px;right:auto}:host([data-side=end]) .panel:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:16px;right:auto}details{border:1px solid var(--a-border);border-radius:10px;padding:0 8px}details>summary{cursor:pointer;padding:8px 0;font-weight:600}details[open]>summary{border-block-end:1px solid var(--a-border);margin-block-end:8px}details>ol.steps{max-block-size:34dvh;padding-block-end:8px;overflow:auto}details .small{padding-block-end:8px}.panel[data-mode=recording] .body{gap:8px;padding-block-start:8px;padding-block-end:8px}`;function J(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!==!1&&r.setAttribute(e,n===!0?``:n);for(let e of n)e&&r.append(e);return r}function Ke(e){try{let t=new CSSStyleSheet;t.replaceSync(q),e.adoptedStyleSheets=[t]}catch{let t=document.createElement(`style`);t.textContent=q,e.prepend(t)}}var qe=class{constructor(e,t,n){F(this,`api`,void 0),F(this,`labels`,void 0),F(this,`host`,void 0),F(this,`root`,void 0),F(this,`panel`,void 0),F(this,`live`,void 0),F(this,`minimized`,!1),F(this,`side`,`start`),F(this,`stepsOpen`,!1),F(this,`copiedNote`,``),F(this,`unsub`,void 0),F(this,`pendingFocus`,``),F(this,`onKey`,e=>{e.altKey&&e.shiftKey&&e.code===`KeyG`&&(e.preventDefault(),this.minimized=!1,this.render(),this.focus(`rec`))}),this.api=e,this.labels=t,this.host=document.createElement(`div`),this.host.setAttribute(`data-heypointer-author`,``),this.host.style.pointerEvents=`none`,(n.dir===`ltr`||n.dir===`rtl`)&&this.host.setAttribute(`dir`,n.dir),n.lang&&this.host.setAttribute(`lang`,n.lang),(n.scheme===`light`||n.scheme===`dark`)&&this.host.setAttribute(`data-scheme`,n.scheme);for(let[e,t]of Object.entries(n.themeVars??{}))this.host.style.setProperty(e,t);this.root=this.host.attachShadow({mode:`open`}),this.panel=J(`section`,{class:`panel`,role:`dialog`,part:`author-panel`}),this.live=J(`div`,{class:`sr`,role:`status`,"aria-live":`polite`}),this.root.append(this.panel,this.live),Ke(this.root),(n.mountTo??document.body).appendChild(this.host),this.unsub=e.store.subscribe(()=>this.render()),document.addEventListener(`keydown`,this.onKey,!0),this.render()}setLabels(e){this.labels=e,this.render()}destroy(){this.unsub(),document.removeEventListener(`keydown`,this.onKey,!0),this.host.remove()}focus(e){this.pendingFocus=e,this.applyFocus()}t(e,t){return Ge(this.labels,e,t)}applyFocus(){if(!this.pendingFocus)return;let e=this.root.querySelector(`[data-k="${this.pendingFocus}"]`);e&&(e.focus(),this.pendingFocus=``)}announce(e){this.live.textContent=e}render(){let e=this.api.mode(),t=this.root.activeElement,n=t?.getAttribute(`data-k`)??``,r=t instanceof HTMLInputElement&&t.type===`text`?[t.selectionStart,t.selectionEnd]:null,i=this.api.store,a=i.stepCount;this.panel.setAttribute(`aria-label`,this.t(`authorDialogName`)),this.panel.setAttribute(`data-mode`,e),this.minimized?this.panel.setAttribute(`data-min`,``):this.panel.removeAttribute(`data-min`);let o=e===`recording`?this.t(`authorStatusRecording`,{count:a}):e===`paused`?this.t(`authorStatusPaused`,{count:a}):e===`review`?this.t(`authorStatusReview`):this.t(`authorStatusIdle`),s=i.full?` ${this.t(`authorLimit`,{max:100})}`:``;this.announce(o+s);let c=J(`div`,{class:`head`},J(`h2`,{},J(`span`,{class:`dot`,"aria-hidden":`true`}),this.t(`authorTitle`)),J(`div`,{class:`acts`},this.button(this.minimized?`▢`:`–`,`min`,()=>{this.minimized=!this.minimized,this.render()},`icon`,{"aria-label":this.minimized?this.t(`authorExpand`):this.t(`authorMinimize`),"aria-expanded":String(!this.minimized)}),this.button(`⇄`,`side`,()=>{this.side=this.side===`start`?`end`:`start`,this.render()},`icon`,{"aria-label":this.t(`authorMove`)}),this.button(`✕`,`close`,()=>this.api.close(),`icon`,{"aria-label":this.t(`authorClose`)}))),l=J(`div`,{class:`body`});l.append(J(`p`,{class:`status`},o+s)),e!==`recording`&&l.append(this.titleField()),l.append(e===`review`?this.reviewView():this.editView(e)),e!==`recording`&&(l.append(J(`p`,{class:`small`},this.t(`authorPrivacy`))),l.append(J(`details`,{},J(`summary`,{},this.t(`authorAbout`)),J(`p`,{class:`small`},this.t(`authorShortcut`))))),this.side===`end`?this.host.setAttribute(`data-side`,`end`):this.host.removeAttribute(`data-side`),this.panel.replaceChildren(c,l),n&&(this.pendingFocus=n),this.applyFocus();let u=this.root.activeElement;if(r&&u instanceof HTMLInputElement&&u.type===`text`)try{u.setSelectionRange(r[0]??0,r[1]??0)}catch{}}button(e,t,n,r=``,i={}){let a=J(`button`,{type:`button`,"data-k":t,...r?{class:r}:{},...i},e);return a.addEventListener(`click`,n),a}titleField(){let e=J(`input`,{type:`text`,"data-k":`title`,maxlength:`80`,placeholder:this.t(`authorFlowTitlePlaceholder`),autocomplete:`off`,part:`author-title`});return e.value=this.api.store.draft.title,e.addEventListener(`input`,()=>this.api.store.draft.title=e.value),e.addEventListener(`change`,()=>{this.api.store.setTitle(e.value)}),J(`label`,{class:`field`},J(`span`,{},this.t(`authorFlowTitle`)),e)}editView(e){let t=this.api.store,n=J(`div`,{class:`body flush`}),r=J(`div`,{class:`row`});e===`recording`?r.append(this.button(this.t(`authorPause`),`rec`,()=>this.api.pause())):r.append(this.button(e===`paused`?this.t(`authorResume`):this.t(`authorRecord`),`rec`,()=>this.api.record(),`rec`)),r.append(this.button(this.t(`authorStop`),`stop`,()=>this.api.stop(),`primary`,t.stepCount===0?{disabled:!0}:{}),this.button(this.t(`authorUndo`),`undo`,()=>t.undo(),``,t.draft.entries.length===0?{disabled:!0}:{})),n.append(r);let i=J(`input`,{type:`checkbox`,"data-k":`rows`});if(i.checked=this.api.recordRows(),i.addEventListener(`change`,()=>this.api.setRecordRows(i.checked)),n.append(J(`label`,{class:`check`},i,J(`span`,{},this.t(`authorRows`)))),t.draft.entries.length===0)n.append(J(`p`,{class:`hint`},this.t(`authorEmpty`)));else{let r=J(`details`,{"data-k":`steps`,...e!==`recording`||this.stepsOpen?{open:!0}:{}},J(`summary`,{},this.t(`authorSteps`,{count:t.stepCount})),this.list());r.addEventListener(`toggle`,()=>{e===`recording`&&(this.stepsOpen=r.open)}),n.append(r)}return t.stepCount>0&&n.append(J(`div`,{class:`row`},this.button(this.t(`authorRecheck`),`recheck`,()=>this.api.recheckAll()))),n}list(){let e=J(`ol`,{class:`steps`,"aria-label":this.t(`authorTitle`)}),t=0;for(let n of this.api.store.draft.entries)e.append(n.t===`note`?this.noteItem(n):this.stepItem(n,++t));return e}noteItem(e){return J(`li`,{class:`note`},J(`span`,{},this.t(`authorNote`,{path:e.text})),this.button(`✕`,`note-${e.id}`,()=>this.api.store.remove(e.id),`icon`,{"aria-label":this.t(`authorDeleteNote`)}))}chips(e){let t=J(`div`,{class:`chips`}),n=[],r=(e,r,i)=>{t.append(J(`span`,{class:`chip ${e}`,part:`author-chip`},r)),i&&n.push(J(`p`,{class:`hint`},i))},i=e.status;return i.kind===`unique`?r(`ok`,this.t(`authorChipUnique`)):i.kind===`ambiguous`?r(`err`,this.t(`authorChipAmbiguous`,{count:i.count}),this.t(`authorHintAmbiguous`,{count:i.count})):i.kind===`noname`?r(`err`,this.t(`authorChipNoName`),this.t(`authorHintNoName`)):i.kind===`notfound`?r(`warn`,this.t(`authorChipNotFound`),this.t(`authorHintNotFound`)):r(`info`,this.t(`authorChipUnchecked`),this.t(`authorHintUnchecked`)),e.pageData&&r(`warn`,this.t(`authorChipPageData`),this.t(`authorHintPageData`)),e.sensitive&&r(`info`,this.t(`authorChipSensitive`),this.t(`authorHintSensitive`)),{chips:t,hints:n}}stepItem(e,t){let{chips:n,hints:r}=this.chips(e),i=J(`input`,{type:`text`,"data-k":`s${e.id}-text`,maxlength:`120`,"aria-label":this.t(`authorStepText`,{n:t}),autocomplete:`off`,part:`author-step`});i.value=e.text,i.addEventListener(`input`,()=>this.api.store.editText(e.id,i.value,!0)),i.addEventListener(`change`,()=>this.api.edited(e.id));let a=R(e)&&!e.consequential,o=J(`input`,{type:`checkbox`,"data-k":`s${e.id}-gate`});o.checked=R(e),o.disabled=a,o.addEventListener(`change`,()=>this.api.store.toggleConsequential(e.id));let s=J(`div`,{class:`acts`},J(`label`,{class:`check`},o,J(`span`,{},a?this.t(`authorConsequentialAuto`):this.t(`authorConsequential`))),this.button(`▲`,`s${e.id}-up`,()=>{this.pendingFocus=`s${e.id}-up`,this.api.store.move(e.id,-1)},`icon`,{"aria-label":this.t(`authorMoveUp`,{n:t})}),this.button(`▼`,`s${e.id}-down`,()=>{this.pendingFocus=`s${e.id}-down`,this.api.store.move(e.id,1)},`icon`,{"aria-label":this.t(`authorMoveDown`,{n:t})}),this.button(`✕`,`s${e.id}-del`,()=>this.api.store.remove(e.id),`icon`,{"aria-label":this.t(`authorDelete`,{n:t})})),c=[];return e.status.kind===`ambiguous`&&e.context&&c.push(this.button(this.t(`authorAddContext`,{context:e.context}),`s${e.id}-ctx`,()=>this.api.addContext(e.id))),J(`li`,{class:`step`,part:`author-item`},n,i,...r,s,...c)}reviewView(){let e=this.api.store,t=J(`div`,{class:`body flush`}),n=Re(e.draft,this.t(`authorTitleRequired`)),r=z(e.draft),i=ze(e.draft);if(t.append(J(`h3`,{class:`h3`},this.t(`authorPreview`))),n.length){let e=J(`ul`,{class:`problems`,role:`alert`});for(let t of n)e.append(J(`li`,{},t));t.append(J(`p`,{class:`hint`},this.t(`authorProblems`)),e)}let a=J(`pre`,{tabindex:`0`,"aria-label":this.t(`authorPreview`),part:`author-preview`});a.append(J(`code`,{},r)),t.append(a);let o=J(`div`,{class:`row`},this.button(this.t(`authorCopy`),`copy`,()=>void this.copy(r),`primary`,n.length?{disabled:!0}:{}),this.button(this.t(`authorDownload`,{file:i}),`download`,()=>this.download(i,r),``,n.length?{disabled:!0}:{}));return t.append(o),this.copiedNote&&t.append(J(`p`,{class:`hint`,role:`status`},this.copiedNote)),t.append(J(`p`,{class:`hint`},this.t(`authorNextHeading`)),J(`div`,{class:`cmds`},J(`code`,{},`heypointer flows import ${i} --publish`),J(`code`,{},`heypointer scan .`))),t.append(J(`div`,{class:`row`},this.button(this.t(`authorKeepRecording`),`keep`,()=>{this.copiedNote=``,this.api.keepRecording()}),this.button(this.t(`authorDiscard`),`discard`,()=>{confirm(this.t(`authorDiscardConfirm`))&&this.api.discard()}))),t}async copy(e){try{await navigator.clipboard.writeText(e),this.copiedNote=this.t(`authorCopied`)}catch{this.copiedNote=this.t(`authorCopyFailed`)}this.pendingFocus=`copy`,this.render()}download(e,t){let n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),r=J(`a`,{href:n,download:e});this.root.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}},Y=null;function X(e,t){if(!e)return{kind:`noname`};if(e.length>72)return{kind:`notfound`};let n=p({selectors:[],text:e});return n.status===`ambiguous`?{kind:`ambiguous`,count:n.count}:n.status===`missing`?t?{kind:`notfound`}:{kind:`unchecked`}:t&&!(n.element===t||t.contains(n.element)||n.element.contains(t))?{kind:`notfound`}:{kind:`unique`}}function Z(e={}){if(Y&&!Y.destroyed)return Y;let t=K(e.labels),n=e.persist===!1?null:e.storage===void 0?U():e.storage,r=He(n),i=new Be(r?.draft);e.title&&!i.draft.title&&(i.draft.title=x(e.title).slice(0,80));let a=r?r.recording?`recording`:`paused`:`idle`,o=!!e.recordRows,s=()=>{a===`review`||a===`idle`&&i.draft.entries.length===0||Ue(n,{draft:i.draft,recording:a===`recording`})},c=e=>{a=e,s(),p.render()},l=new Fe({isRecording:()=>a===`recording`,isOwn:e=>e.includes(p.host),recordRows:()=>o,acceptUntrusted:!!e.acceptUntrusted,onPage:e=>i.addNote(e),onStep:e=>{let t=X(e.label,e.el);(!i.addStep({kind:e.kind,text:Le(e.kind,e.label),consequential:!1,status:t,pageData:e.pageData,sensitive:e.sensitive,context:e.context})||i.full)&&c(`paused`)}}),u=e=>{let t=i.find(e);if(t?.t!==`step`)return;let n=C(t.text);i.setStatus(e,X(n),A(n))},d={store:i,mode:()=>a,recordRows:()=>o,setRecordRows:e=>{o=e},record:()=>{i.full||(i.draft.entries.length===0&&i.addNote(w(location.pathname)),l.syncRoute(),c(`recording`))},pause:()=>c(`paused`),stop:()=>c(`review`),keepRecording:()=>{l.syncRoute(),c(`recording`)},close:()=>{(!i.draft.entries.length||confirm(t.authorDiscardConfirm))&&Y?.stop()},discard:()=>{i.clear(),H(n),a=`idle`,p.render()},edited:e=>u(e),recheckAll:()=>{for(let e of i.draft.entries)e.t===`step`&&u(e.id)},addContext:e=>{let t=i.find(e);if(t?.t!==`step`||!t.context)return;let n=`${t.text.replace(/[.!?]$/,``)} in the ${t.context} area.`;n.length>120||(i.editText(e,n),u(e))}},f=te.includes(e.colorScheme)?e.colorScheme:`auto`,p=new qe(d,t,{mountTo:e.mountTo,dir:e.dir,lang:e.lang,scheme:f,themeVars:fe(de(e.theme).theme)});if(i.subscribe(()=>{s(),e.onChange?.(i.draft)}),l.start(),r?.recording){let e=w(location.pathname);i.addNote(e),l.syncRoute()}e.autoRecord&&a===`idle`&&d.record(),s(),p.render();let m={destroyed:!1,get mode(){return a},stop(){m.destroyed||(m.destroyed=!0,l.stop(),p.destroy(),H(n),Y=null)},getDraft:()=>JSON.parse(JSON.stringify(i.draft)),toMarkdown:()=>z(i.draft),pause:()=>d.pause(),resume:()=>d.record()};return Y=m,m}function Q(e=U()){try{return e?.getItem(V)===`1`}catch{return!1}}window.HeyPointerAuthor={startAuthoring:Z,authorWasActive:Q};var $=document.currentScript?.dataset;if($){let e=e=>e!==void 0&&e!==`false`,t=e($.allowAuthorParam)&&(new URLSearchParams(location.search).has(`heypointer-author`)||Q());if(e($.author)||t){let e=()=>Z({labels:h(`data-labels`,$.labels),theme:h(`data-theme`,$.theme),colorScheme:$.colorScheme,dir:$.dir,lang:$.lang});document.body?e():document.addEventListener(`DOMContentLoaded`,e,{once:!0})}}})();
|