@heypointerhq/sdk 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +131 -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,896 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, m as a, n as o, o as s, p as c, r as l, t as u, u as d } from "./chunk-theme.js";
|
|
2
|
+
// src/validate.ts
|
|
3
|
+
var f = [
|
|
4
|
+
"click",
|
|
5
|
+
"type",
|
|
6
|
+
"select",
|
|
7
|
+
"navigate",
|
|
8
|
+
"observe"
|
|
9
|
+
], p = (e) => typeof e == "object" && !!e, m = (e) => typeof e == "string";
|
|
10
|
+
function h(e, t) {
|
|
11
|
+
if (!p(e)) throw Error(`step ${t} is not an object`);
|
|
12
|
+
let { id: n, title: r, instruction: i, target: a, action: o, requiresConfirmation: s, evidence: c } = e;
|
|
13
|
+
if (!m(n) || !m(r) || !m(i)) throw Error(`step ${t} missing id/title/instruction`);
|
|
14
|
+
if (!m(o) || !f.includes(o)) throw Error(`step ${t} has invalid action`);
|
|
15
|
+
if (!p(a) || !Array.isArray(a.selectors) || !a.selectors.every(m)) throw Error(`step ${t} has invalid target`);
|
|
16
|
+
if (typeof s != "boolean") throw Error(`step ${t} missing requiresConfirmation`);
|
|
17
|
+
if (!Array.isArray(c) || c.length === 0) throw Error(`step ${t} has no evidence`);
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
function g(e) {
|
|
21
|
+
if (!Array.isArray(e)) return [];
|
|
22
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
23
|
+
for (let r of e) {
|
|
24
|
+
if (!p(r) || !m(r.workflowId) || !m(r.title)) continue;
|
|
25
|
+
let e = r.title.trim();
|
|
26
|
+
if (!(!r.workflowId || !e || e.length > 200 || t.has(e)) && (t.add(e), n.push({
|
|
27
|
+
workflowId: r.workflowId,
|
|
28
|
+
title: e
|
|
29
|
+
}), n.length === 5)) break;
|
|
30
|
+
}
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
function _(e) {
|
|
34
|
+
if (!p(e)) throw Error("walkthrough is not an object");
|
|
35
|
+
if (e.status !== "ok" && e.status !== "insufficient_evidence") throw Error("invalid walkthrough status");
|
|
36
|
+
if (!m(e.id) || !m(e.goal) || !Array.isArray(e.steps)) throw Error("walkthrough missing id/goal/steps");
|
|
37
|
+
let t = e.steps.map(h);
|
|
38
|
+
if (e.status === "ok" && t.length === 0) throw Error("ok walkthrough has no steps");
|
|
39
|
+
if (e.status === "insufficient_evidence" && t.length > 0) throw Error("insufficient_evidence walkthrough must have no steps");
|
|
40
|
+
let n = {
|
|
41
|
+
...e,
|
|
42
|
+
steps: t
|
|
43
|
+
}, r = e.status === "insufficient_evidence" ? g(e.suggestions) : [];
|
|
44
|
+
return r.length ? n.suggestions = r : delete n.suggestions, n;
|
|
45
|
+
}
|
|
46
|
+
// src/client.ts
|
|
47
|
+
var v = /^(?:hpc|gfc)_[0-9a-f]{24}$/, y = "X-HeyPointer-Client";
|
|
48
|
+
n.clientRequired;
|
|
49
|
+
async function b(e, t) {
|
|
50
|
+
let n;
|
|
51
|
+
try {
|
|
52
|
+
n = (await e.json()).error;
|
|
53
|
+
} catch {}
|
|
54
|
+
return e.status === 401 && n === "client_required" ? t("clientRequired") : e.status === 401 && n === "client_invalid" ? t("clientInvalid") : e.status === 403 && n === "client_origin_not_allowed" ? t("clientOrigin") : e.status === 429 ? t("rateLimited") : t("requestFailed", { status: e.status });
|
|
55
|
+
}
|
|
56
|
+
var x = class extends Error {}, S = class extends Error {}, C = class {
|
|
57
|
+
constructor(e) {
|
|
58
|
+
d(this, "base", void 0), d(this, "fetchImpl", void 0), d(this, "clientId", void 0), d(this, "t", void 0), this.base = e.baseUrl.replace(/\/$/, ""), this.clientId = e.clientId?.trim() || void 0, this.fetchImpl = e.fetch ?? ((...e) => globalThis.fetch(...e)), this.t = e.text ?? ((e, t) => r(n[e], t));
|
|
59
|
+
}
|
|
60
|
+
async send(e, t) {
|
|
61
|
+
try {
|
|
62
|
+
return await this.fetchImpl(`${this.base}${e}`, t);
|
|
63
|
+
} catch {
|
|
64
|
+
let e = this.base;
|
|
65
|
+
try {
|
|
66
|
+
e = new URL(this.base).host;
|
|
67
|
+
} catch {}
|
|
68
|
+
throw Error(this.t("serverUnreachable", { host: e }));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async requestWalkthrough(e, t) {
|
|
72
|
+
if (this.clientId !== void 0 && !v.test(this.clientId)) throw Error(this.t("clientMalformed"));
|
|
73
|
+
let n = await this.send("/api/walkthrough", {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: {
|
|
76
|
+
"content-type": "application/json",
|
|
77
|
+
...this.clientId ? { [y]: this.clientId } : {}
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
goal: e,
|
|
81
|
+
context: t
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
if (!n.ok) throw Error(await b(n, this.t));
|
|
85
|
+
return _(await n.json());
|
|
86
|
+
}
|
|
87
|
+
async transcribe(e) {
|
|
88
|
+
let t = await this.send("/api/transcribe", {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: { "content-type": e.type || "audio/webm" },
|
|
91
|
+
body: e
|
|
92
|
+
});
|
|
93
|
+
if (t.status === 400) throw new S("No speech detected");
|
|
94
|
+
if (!t.ok) throw new x(`Transcription unavailable (${t.status})`);
|
|
95
|
+
let n = await t.json();
|
|
96
|
+
if (typeof n.text != "string" || !n.text.trim()) throw new S("Empty transcript");
|
|
97
|
+
return n.text.trim();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
// src/highlight.ts
|
|
101
|
+
function w(e) {
|
|
102
|
+
let t = 0, n = 0, r = e.ownerDocument?.defaultView ?? null;
|
|
103
|
+
for (; r && r !== r.top;) {
|
|
104
|
+
let e = r.frameElement;
|
|
105
|
+
if (!e) break;
|
|
106
|
+
let i = e.getBoundingClientRect();
|
|
107
|
+
t += i.left, n += i.top, r = r.parent;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
x: t,
|
|
111
|
+
y: n
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
var T = class {
|
|
115
|
+
constructor(e) {
|
|
116
|
+
d(this, "host", void 0), d(this, "box", void 0), d(this, "target", null), d(this, "offset", {
|
|
117
|
+
x: 0,
|
|
118
|
+
y: 0
|
|
119
|
+
}), d(this, "onMove", () => this.position()), d(this, "frame", 0), d(this, "observer", void 0), this.host = e, this.box = document.createElement("div"), this.box.className = "hp-highlight", this.box.setAttribute("part", "highlight"), this.box.setAttribute("aria-hidden", "true"), this.box.hidden = !0, e.appendChild(this.box);
|
|
120
|
+
}
|
|
121
|
+
show(e) {
|
|
122
|
+
this.target = e, this.offset = w(e);
|
|
123
|
+
let t = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
124
|
+
e.scrollIntoView?.({
|
|
125
|
+
block: "center",
|
|
126
|
+
behavior: t ? "auto" : "smooth"
|
|
127
|
+
}), this.box.hidden = !1, cancelAnimationFrame(this.frame), this.frame = requestAnimationFrame(() => this.position()), this.position(), addEventListener("scroll", this.onMove, !0), addEventListener("resize", this.onMove), this.observer?.disconnect(), typeof ResizeObserver < "u" && (this.observer = new ResizeObserver(this.onMove), this.observer.observe(document.documentElement), this.observer.observe(e));
|
|
128
|
+
}
|
|
129
|
+
hide() {
|
|
130
|
+
this.target = null, cancelAnimationFrame(this.frame), this.box.hidden = !0, this.observer?.disconnect(), removeEventListener("scroll", this.onMove, !0), removeEventListener("resize", this.onMove);
|
|
131
|
+
}
|
|
132
|
+
current() {
|
|
133
|
+
return this.target;
|
|
134
|
+
}
|
|
135
|
+
position() {
|
|
136
|
+
if (this.target) {
|
|
137
|
+
if (!this.target.isConnected) return this.hide();
|
|
138
|
+
cancelAnimationFrame(this.frame), this.frame = requestAnimationFrame(() => this.place()), this.place();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
place() {
|
|
142
|
+
if (!this.target?.isConnected) return;
|
|
143
|
+
let e = this.target.getBoundingClientRect();
|
|
144
|
+
Object.assign(this.box.style, {
|
|
145
|
+
top: `${e.top + this.offset.y - 4}px`,
|
|
146
|
+
left: `${e.left + this.offset.x - 4}px`,
|
|
147
|
+
width: `${e.width + 8}px`,
|
|
148
|
+
height: `${e.height + 8}px`
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
// src/recorder.ts
|
|
153
|
+
function E() {
|
|
154
|
+
return typeof navigator < "u" && !!navigator.mediaDevices?.getUserMedia && typeof MediaRecorder < "u";
|
|
155
|
+
}
|
|
156
|
+
var D = class {
|
|
157
|
+
constructor() {
|
|
158
|
+
d(this, "rec", null), d(this, "chunks", []), d(this, "stream", null);
|
|
159
|
+
}
|
|
160
|
+
async start() {
|
|
161
|
+
this.stream = await navigator.mediaDevices.getUserMedia({ audio: !0 }), this.chunks = [], this.rec = new MediaRecorder(this.stream), this.rec.ondataavailable = (e) => e.data.size && this.chunks.push(e.data), this.rec.start();
|
|
162
|
+
}
|
|
163
|
+
stop() {
|
|
164
|
+
return new Promise((e, t) => {
|
|
165
|
+
let n = this.rec;
|
|
166
|
+
if (!n) return t(/* @__PURE__ */ Error("not recording"));
|
|
167
|
+
n.onstop = () => {
|
|
168
|
+
this.stream?.getTracks().forEach((e) => e.stop()), e(new Blob(this.chunks, { type: n.mimeType || "audio/webm" }));
|
|
169
|
+
}, n.stop();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, O = [
|
|
173
|
+
"style",
|
|
174
|
+
"class",
|
|
175
|
+
"hidden",
|
|
176
|
+
"open",
|
|
177
|
+
"inert",
|
|
178
|
+
"aria-hidden"
|
|
179
|
+
], k = [
|
|
180
|
+
"transitionend",
|
|
181
|
+
"transitioncancel",
|
|
182
|
+
"animationend",
|
|
183
|
+
"animationcancel"
|
|
184
|
+
], A = ["transitionrun", "animationstart"], j = 1e3;
|
|
185
|
+
function M(t, n) {
|
|
186
|
+
let r = !0, i = !1, a = 0, o = 0, s = () => {
|
|
187
|
+
if (a = 0, i) return;
|
|
188
|
+
let s = e(t);
|
|
189
|
+
s !== r && (r = s, n(s)), !i && performance.now() < o && c();
|
|
190
|
+
}, c = () => {
|
|
191
|
+
!a && !i && (a = requestAnimationFrame(s));
|
|
192
|
+
}, l = (e) => {
|
|
193
|
+
e.target instanceof Node && e.target.contains(t) && c();
|
|
194
|
+
}, u = (e) => {
|
|
195
|
+
e.target instanceof Node && e.target.contains(t) && (o = performance.now() + j, c());
|
|
196
|
+
}, d = new MutationObserver(c);
|
|
197
|
+
d.observe(document, {
|
|
198
|
+
subtree: !0,
|
|
199
|
+
childList: !0,
|
|
200
|
+
attributes: !0,
|
|
201
|
+
attributeFilter: O
|
|
202
|
+
});
|
|
203
|
+
for (let e of k) document.addEventListener(e, l, !0);
|
|
204
|
+
for (let e of A) document.addEventListener(e, u, !0);
|
|
205
|
+
return c(), () => {
|
|
206
|
+
i = !0, cancelAnimationFrame(a), d.disconnect();
|
|
207
|
+
for (let e of k) document.removeEventListener(e, l, !0);
|
|
208
|
+
for (let e of A) document.removeEventListener(e, u, !0);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// src/spotlight.ts
|
|
212
|
+
function N(e, t, n, r = n.width <= 600, i = !1) {
|
|
213
|
+
if (r) return {
|
|
214
|
+
left: 12,
|
|
215
|
+
top: e.bottom + 16 + t.height <= n.height - 12 ? e.bottom + 16 : e.top - t.height - 16 >= 12 ? e.top - t.height - 16 : 16,
|
|
216
|
+
placement: "floating",
|
|
217
|
+
arrowLeft: 0
|
|
218
|
+
};
|
|
219
|
+
let a = (e, r) => e >= 12 && r >= 12 && e + t.width <= n.width - 12 && r + t.height <= n.height - 12, o = e.left + (e.right - e.left - t.width) / 2, s = e.top + (e.bottom - e.top - t.height) / 2, c = [
|
|
220
|
+
{
|
|
221
|
+
placement: "below",
|
|
222
|
+
left: o,
|
|
223
|
+
top: e.bottom + 16
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
placement: "above",
|
|
227
|
+
left: o,
|
|
228
|
+
top: e.top - t.height - 16
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
placement: "right",
|
|
232
|
+
left: e.right + 16,
|
|
233
|
+
top: s
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
placement: "left",
|
|
237
|
+
left: e.left - t.width - 16,
|
|
238
|
+
top: s
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
i && ([c[2], c[3]] = [c[3], c[2]]);
|
|
242
|
+
let l = c.find((e) => a(e.left, e.top)) ?? c.map((e) => ({
|
|
243
|
+
...e,
|
|
244
|
+
left: Math.max(12, Math.min(e.left, n.width - t.width - 12)),
|
|
245
|
+
top: Math.max(12, Math.min(e.top, n.height - t.height - 12))
|
|
246
|
+
})).sort((n, r) => {
|
|
247
|
+
let i = (n) => Math.max(0, Math.min(e.right, n.left + t.width) - Math.max(e.left, n.left)) * Math.max(0, Math.min(e.bottom, n.top + t.height) - Math.max(e.top, n.top));
|
|
248
|
+
return i(n) - i(r);
|
|
249
|
+
})[0], u = Math.max(24, Math.min((e.left + e.right) / 2 - l.left, t.width - 24));
|
|
250
|
+
return {
|
|
251
|
+
...l,
|
|
252
|
+
arrowLeft: u
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var P = class {
|
|
256
|
+
constructor(e) {
|
|
257
|
+
d(this, "overlay", void 0), d(this, "target", null), d(this, "offset", {
|
|
258
|
+
x: 0,
|
|
259
|
+
y: 0
|
|
260
|
+
}), d(this, "enabled", !1), d(this, "onReposition", void 0), d(this, "frame", 0), d(this, "observer", void 0), d(this, "onMove", () => this.position()), this.overlay = document.createElement("div"), this.overlay.className = "hp-spotlight", this.overlay.setAttribute("part", "spotlight"), this.overlay.setAttribute("aria-hidden", "true"), this.overlay.hidden = !0, e.appendChild(this.overlay);
|
|
261
|
+
}
|
|
262
|
+
show(e, t) {
|
|
263
|
+
this.hide(), this.target = e, this.onReposition = t, this.enabled = !0, this.overlay.hidden = !1, e && (this.offset = w(e)), this.position(), cancelAnimationFrame(this.frame), this.frame = requestAnimationFrame(() => this.position()), addEventListener("scroll", this.onMove, !0), addEventListener("resize", this.onMove), typeof ResizeObserver < "u" && (this.observer = new ResizeObserver(this.onMove), this.observer.observe(document.documentElement), this.observer.observe(this.overlay), e && this.observer.observe(e));
|
|
264
|
+
}
|
|
265
|
+
hide() {
|
|
266
|
+
this.target = null, this.enabled = !1, cancelAnimationFrame(this.frame), this.overlay.hidden = !0, this.overlay.style.clipPath = "", this.observer?.disconnect(), removeEventListener("scroll", this.onMove, !0), removeEventListener("resize", this.onMove);
|
|
267
|
+
}
|
|
268
|
+
position() {
|
|
269
|
+
this.enabled && (!this.target || this.target.isConnected) && (cancelAnimationFrame(this.frame), this.frame = requestAnimationFrame(() => {
|
|
270
|
+
this.enabled && this.update();
|
|
271
|
+
}), this.update());
|
|
272
|
+
}
|
|
273
|
+
update() {
|
|
274
|
+
if (!this.enabled) return;
|
|
275
|
+
let e = this.target?.getBoundingClientRect() ?? {
|
|
276
|
+
top: 0,
|
|
277
|
+
left: 0,
|
|
278
|
+
width: 0,
|
|
279
|
+
height: 0
|
|
280
|
+
}, t = e.left + this.offset.x - 5, n = e.top + this.offset.y - 5, r = e.width + 10, i = e.height + 10;
|
|
281
|
+
this.overlay.style.clipPath = this.target ? `polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, ${t}px ${n}px, ${t}px ${n + i}px, ${t + r}px ${n + i}px, ${t + r}px ${n}px, ${t}px ${n}px)` : "", this.onReposition?.();
|
|
282
|
+
}
|
|
283
|
+
}, F = () => import("./author.js"), I = "heypointer:author:active:v1";
|
|
284
|
+
function L(e) {
|
|
285
|
+
if (e.author) return !0;
|
|
286
|
+
if (!e.allowAuthorParam) return !1;
|
|
287
|
+
try {
|
|
288
|
+
return new URLSearchParams(location.search).has("heypointer-author") || sessionStorage.getItem(I) === "1";
|
|
289
|
+
} catch {
|
|
290
|
+
return !1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
async function R() {
|
|
294
|
+
let e = window;
|
|
295
|
+
return e.HeyPointerAuthor ? e.HeyPointerAuthor : await F() || null;
|
|
296
|
+
}
|
|
297
|
+
// src/styles.css?inline
|
|
298
|
+
var z = "/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-leading:initial;--tw-font-weight:initial}}}@layer theme{:root,:host{--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-semibold:600;--leading-snug:1.375;--radius-lg:.5rem;--color-hp-accent:var(--hp-accent,#087ea4);--color-hp-accent-fg:var(--hp-accent-fg,#fff);--color-hp-bg:var(--hp-bg,#fff);--color-hp-fg:var(--hp-fg,#172b3a);--color-hp-muted:var(--hp-muted,#334155);--color-hp-border:var(--hp-border,#64748b);--color-hp-warn-bg:var(--hp-warn-bg,#fef3c7);--color-hp-warn-bd:var(--hp-warn-border,#92400e);--color-hp-err-bg:var(--hp-err-bg,#fee2e2);--color-hp-err-bd:var(--hp-err-border,#b91c1c);--color-hp-focus:var(--hp-focus,#1e3a8a);--color-hp-halo:var(--hp-halo,#fff);--color-hp-ring:var(--hp-ring,#f59e0b);--color-hp-dim:var(--hp-dim,#09141e8c);--radius-hp:var(--hp-radius,12px)}}@layer utilities;:host{all:revert;pointer-events:none;font-family:var(--hp-font,system-ui, sans-serif);font-size:var(--hp-font-size,14px);color:var(--color-hp-fg);--tw-border-style:solid;--tw-outline-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-inset-shadow:0 0 #0000;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;line-height:1.45}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])){--color-hp-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--color-hp-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--color-hp-bg:var(--hp-dark-bg,#0f172a);--color-hp-fg:var(--hp-dark-fg,#f1f5f9);--color-hp-muted:var(--hp-dark-muted,#cbd5e1);--color-hp-border:var(--hp-dark-border,#94a3b8);--color-hp-warn-bg:var(--hp-dark-warn-bg,#422006);--color-hp-warn-bd:var(--hp-dark-warn-border,#fbbf24);--color-hp-err-bg:var(--hp-dark-err-bg,#450a0a);--color-hp-err-bd:var(--hp-dark-err-border,#f87171);--color-hp-focus:var(--hp-dark-focus,#fff);--color-hp-halo:var(--hp-dark-halo,#1e3a8a);--color-hp-ring:var(--hp-dark-ring,var(--hp-ring,#f59e0b));--color-hp-dim:var(--hp-dark-dim,var(--hp-dim,#09141e8c))}}:host([data-scheme=dark]){--color-hp-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--color-hp-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--color-hp-bg:var(--hp-dark-bg,#0f172a);--color-hp-fg:var(--hp-dark-fg,#f1f5f9);--color-hp-muted:var(--hp-dark-muted,#cbd5e1);--color-hp-border:var(--hp-dark-border,#94a3b8);--color-hp-warn-bg:var(--hp-dark-warn-bg,#422006);--color-hp-warn-bd:var(--hp-dark-warn-border,#fbbf24);--color-hp-err-bg:var(--hp-dark-err-bg,#450a0a);--color-hp-err-bd:var(--hp-dark-err-border,#f87171);--color-hp-focus:var(--hp-dark-focus,#fff);--color-hp-halo:var(--hp-dark-halo,#1e3a8a);--color-hp-ring:var(--hp-dark-ring,var(--hp-ring,#f59e0b));--color-hp-dim:var(--hp-dark-dim,var(--hp-dim,#09141e8c))}@layer base{*,:before,:after{box-sizing:border-box}}@layer components{.hp-launcher{z-index:2147483646;bottom:calc(var(--spacing) * 4);min-height:calc(var(--spacing) * 10);cursor:pointer;border-style:var(--tw-border-style);background-color:var(--color-hp-accent);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2.5);color:var(--color-hp-accent-fg);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);pointer-events:auto;font:inherit;border-width:0;border-radius:2147483647px;position:fixed;inset-inline-end:16px}.hp-launcher[hidden]{display:none}.hp-panel{z-index:2147483646;bottom:calc(var(--spacing) * 18);border-radius:var(--radius-hp);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-border);background-color:var(--color-hp-bg);padding:calc(var(--spacing) * 4);color:var(--color-hp-fg);text-align:start;pointer-events:auto;width:min(360px,100vw - 32px);max-height:min(70dvh,32rem);position:fixed;inset-inline-end:16px;overflow:auto;box-shadow:0 8px 30px #0004}.hp-panel[hidden],.hp-spotlight[hidden],.hp-tour-arrow[hidden]{display:none}:host([data-launcher-side=start]) .hp-launcher{inset-inline:16px auto}@media (min-width:601px){:host([data-launcher-side=start]) .hp-panel:not(.hp-tour){inset-inline:16px auto}}.hp-spotlight{z-index:2147483644;background-color:var(--color-hp-dim);pointer-events:none;width:100vw;height:100dvh;position:fixed;top:0;left:0}.hp-highlight{z-index:2147483645;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:3px;border-color:var(--color-hp-ring);outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-hp-focus);pointer-events:none;transition:all .2s;position:fixed}.hp-panel.hp-tour{border-style:var(--tw-border-style);width:auto;padding:calc(var(--spacing) * 5);inset-inline-end:auto;border-width:0;border-radius:14px;width:min(400px,100vw - 24px);max-height:calc(100dvh - 24px);bottom:auto;box-shadow:0 10px 36px #0005}.hp-tour-head{justify-content:space-between;align-items:flex-start;gap:calc(var(--spacing) * 3);display:flex}.hp-tour h2{margin:0;margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.hp-tour p{margin:0;margin-bottom:calc(var(--spacing) * 4.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.hp-tour .hp-progress,.hp-tour-count{margin:0;margin-bottom:calc(var(--spacing) * 1.75);white-space:nowrap;font-size:13px}.hp-tour .hp-close{margin-top:calc(var(--spacing) * -2);min-height:calc(var(--spacing) * 9);min-width:calc(var(--spacing) * 9);font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height));margin-inline-end:-8px}.hp-tour .hp-row{margin-top:calc(var(--spacing) * 4);flex-wrap:nowrap;justify-content:space-between;align-items:center}.hp-tour .hp-primary{min-height:calc(var(--spacing) * 10);padding-inline:calc(var(--spacing) * 5);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);border-radius:2147483647px}.hp-tour .hp-skip{cursor:pointer;border-style:var(--tw-border-style);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-hp-accent);background-color:#0000;border-width:0}.hp-tour .hp-back{cursor:pointer;border-style:var(--tw-border-style);padding-inline:0;padding-block:calc(var(--spacing) * 2);color:var(--color-hp-fg);background-color:#0000;border-width:0}.hp-tour .hp-evidence{margin-top:calc(var(--spacing) * 3)}.hp-tour .hp-warn{margin-block:calc(var(--spacing) * 3);font-size:13px}.hp-released h2,.hp-released>p:not(.hp-released-note){color:var(--color-hp-muted)}.hp-released .hp-released-note{margin:0;margin-bottom:calc(var(--spacing) * 3);--tw-font-weight:var(--font-weight-semibold);font-size:13px;font-weight:var(--font-weight-semibold);color:var(--color-hp-fg)}.hp-tour-tools{margin-bottom:calc(var(--spacing) * 3);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-tour-tools summary{cursor:pointer;padding-block:var(--spacing)}.hp-goal-compact{margin-top:calc(var(--spacing) * 2);margin-bottom:0}.hp-goal-compact .hp-row{flex-wrap:nowrap;margin-top:0}.hp-goal-compact input[type=text]{height:calc(var(--spacing) * 8);min-height:calc(var(--spacing) * 8);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.hp-goal-compact button{min-height:calc(var(--spacing) * 8);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.hp-tour.hp-floating{width:auto;inset:auto 12px 12px!important}.hp-tour-arrow{z-index:2147483645;width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4);background-color:var(--color-hp-bg);pointer-events:none;position:fixed;rotate:45deg}.hp-tour[data-placement=below]+.hp-tour-arrow{clip-path:polygon(0 0,100% 0,0 100%)}.hp-tour[data-placement=above]+.hp-tour-arrow{clip-path:polygon(100% 0,100% 100%,0 100%)}.hp-tour[data-placement=left]+.hp-tour-arrow,.hp-tour[data-placement=right]+.hp-tour-arrow{display:none}.hp-row{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.hp-row>input[type=text]{flex:1;min-width:0}button,input[type=text]{min-height:calc(var(--spacing) * 9);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-border);background-color:var(--color-hp-bg);padding-inline:calc(var(--spacing) * 2.5);padding-block:calc(var(--spacing) * 1.5);color:var(--color-hp-fg);font:inherit}button.hp-primary{border-color:var(--color-hp-accent);background-color:var(--color-hp-accent);color:var(--color-hp-accent-fg)}button[aria-disabled=true],button:disabled{cursor:not-allowed;opacity:.55}button:focus-visible,input:focus-visible,.hp-launcher:focus-visible,h2:focus-visible,summary:focus-visible{outline-style:var(--tw-outline-style);outline-offset:2px;outline-width:2px;outline-color:var(--color-hp-focus);box-shadow:0 0 0 4px var(--color-hp-halo)}h2:focus{outline:none}h2{margin:0;margin-bottom:var(--spacing);font-size:15px}.hp-assist{margin-top:calc(var(--spacing) * 2);cursor:pointer;align-items:center;gap:calc(var(--spacing) * 2.5);color:var(--color-hp-fg);min-height:44px;font-size:13px;display:flex}.hp-assist input{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5);cursor:pointer;accent-color:var(--color-hp-accent);flex-shrink:0;min-height:0;margin:0}.hp-assist-note{margin:0;margin-bottom:calc(var(--spacing) * 2);color:var(--color-hp-muted);font-size:13px}.hp-assist-note.hp-alert{color:var(--color-hp-fg)}.hp-assist-hint{margin:0;margin-bottom:calc(var(--spacing) * 3);color:var(--color-hp-muted);font-size:13px}.hp-assist-hint[hidden]{display:none}.hp-warn{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-warn-bd);background-color:var(--color-hp-warn-bg);padding:calc(var(--spacing) * 2)}.hp-alert{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-err-bd);background-color:var(--color-hp-err-bg);padding:calc(var(--spacing) * 2)}.hp-suggest{margin-top:calc(var(--spacing) * 3);align-items:stretch;gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.hp-suggest-label{--tw-font-weight:var(--font-weight-semibold);font-size:13px;font-weight:var(--font-weight-semibold);color:var(--color-hp-muted);margin:0}.hp-suggestion{cursor:pointer;text-align:start;overflow-wrap:anywhere}.hp-evidence{margin-top:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-evidence summary{cursor:pointer}.hp-head{justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);display:flex}.hp-close{cursor:pointer;border-style:var(--tw-border-style);padding-inline:calc(var(--spacing) * 2.5);padding-block:var(--spacing);--tw-leading:1;color:var(--color-hp-fg);background-color:#0000;border-width:0;font-size:22px;line-height:1}.hp-progress{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-sr-only{white-space:nowrap;clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}@media (pointer:coarse){button,input[type=text],.hp-launcher{min-height:44px}}@media (max-width:600px){.hp-panel:not(.hp-tour){border-radius:var(--radius-hp) var(--radius-hp) 0 0;width:100%;max-height:75dvh;bottom:0;left:0;right:0}.hp-tour h2{font-size:15px}.hp-tour{padding:calc(var(--spacing) * 4)}}@media (prefers-reduced-motion:reduce){.hp-highlight{transition:none}}}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-font-weight{syntax:\"*\";inherits:false}", B = /\b(send|submit|delete|remove|pay|purchase|buy|transfer|publish|revoke|deploy)\b/i, V = (e) => e.requiresConfirmation || e.action === "click" && [
|
|
299
|
+
e.target.text,
|
|
300
|
+
e.target.label,
|
|
301
|
+
e.title,
|
|
302
|
+
e.instruction
|
|
303
|
+
].some((e) => B.test(e ?? "")), H = "button, a, label, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"menuitem\"], [role=\"tab\"]", U = "heypointer:assist", W = "heypointer:open", G = "heypointer:close";
|
|
304
|
+
function K(e = 80, t = 600) {
|
|
305
|
+
return new Promise((n) => {
|
|
306
|
+
let r, i = () => {
|
|
307
|
+
a.disconnect(), clearTimeout(r), clearTimeout(o), n();
|
|
308
|
+
}, a = new MutationObserver(() => {
|
|
309
|
+
clearTimeout(r), r = setTimeout(i, e);
|
|
310
|
+
});
|
|
311
|
+
a.observe(document, {
|
|
312
|
+
childList: !0,
|
|
313
|
+
subtree: !0
|
|
314
|
+
}), r = setTimeout(i, e);
|
|
315
|
+
let o = setTimeout(i, t);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
var q = (e, t) => (e.setAttribute("part", t), e), J = class {
|
|
319
|
+
constructor(e) {
|
|
320
|
+
d(this, "opts", void 0), d(this, "host", void 0), d(this, "root", void 0), d(this, "client", void 0), d(this, "hl", void 0), d(this, "spotlight", void 0), d(this, "arrow", void 0), d(this, "panel", void 0), d(this, "launcher", void 0), d(this, "live", void 0), d(this, "view", { kind: "idle" }), d(this, "wt", null), d(this, "index", 0), d(this, "confirmed", /* @__PURE__ */ new Set()), d(this, "missing", !1), d(this, "ambiguous", !1), d(this, "recorder", null), d(this, "recording", !1), d(this, "notice", ""), d(this, "noticeAlert", !1), d(this, "goalToolsOpen", !1), d(this, "lastGoal", ""), d(this, "focusTitle", !1), d(this, "target", null), d(this, "targetOffset", {
|
|
321
|
+
x: 0,
|
|
322
|
+
y: 0
|
|
323
|
+
}), d(this, "renderToken", 0), d(this, "micOk", void 0), d(this, "assist", void 0), d(this, "userActed", !1), d(this, "assisting", !1), d(this, "assisted", /* @__PURE__ */ new Set()), d(this, "assistNote", null), d(this, "hintEl", null), d(this, "released", !1), d(this, "stopWatch", void 0), d(this, "anchor", null), d(this, "onDocClick", (e) => this.noteClick(e)), d(this, "L", void 0), d(this, "theme", {}), d(this, "themeProps", []), d(this, "cfg", void 0), d(this, "opener", null), this.opts = e;
|
|
324
|
+
let t = a(e.labels);
|
|
325
|
+
t.problems, this.L = t.labels, this.cfg = {
|
|
326
|
+
dir: e.dir === "ltr" || e.dir === "rtl" ? e.dir : "auto",
|
|
327
|
+
lang: typeof e.lang == "string" ? e.lang.trim().slice(0, 35) : "",
|
|
328
|
+
scheme: u.includes(e.colorScheme) ? e.colorScheme : "auto",
|
|
329
|
+
launcher: e.launcher === "none" ? "none" : "default",
|
|
330
|
+
side: e.launcherSide === "start" ? "start" : "end"
|
|
331
|
+
}, this.client = new C({
|
|
332
|
+
baseUrl: e.baseUrl,
|
|
333
|
+
clientId: e.clientId,
|
|
334
|
+
fetch: e.fetch,
|
|
335
|
+
text: (e, t) => this.t(e, t)
|
|
336
|
+
}), this.micOk = e.speechSupported ?? E(), this.assist = !!e.assist, document.addEventListener("click", this.onDocClick, !0), this.host = document.createElement("div"), this.host.setAttribute("data-heypointer-root", ""), this.host.style.pointerEvents = "none", this.root = this.host.attachShadow({ mode: "open" });
|
|
337
|
+
let n = document.createElement("style");
|
|
338
|
+
n.textContent = z, this.root.appendChild(n), this.hl = new T(this.root), this.spotlight = new P(this.root), this.arrow = document.createElement("div"), this.arrow.className = "hp-tour-arrow", this.arrow.setAttribute("part", "arrow"), this.arrow.hidden = !0, this.arrow.setAttribute("aria-hidden", "true"), this.launcher = document.createElement("button"), this.launcher.className = "hp-launcher", this.launcher.textContent = this.t("launcher"), this.launcher.setAttribute("part", "launcher"), this.launcher.setAttribute("aria-expanded", "false"), this.launcher.addEventListener("click", () => this.panel.hidden ? this.open() : this.close()), this.panel = document.createElement("section"), this.panel.className = "hp-panel", this.panel.setAttribute("role", "dialog"), this.panel.setAttribute("aria-label", this.t("dialogName")), this.panel.setAttribute("part", "panel"), this.panel.hidden = !0, this.panel.addEventListener("keydown", (e) => {
|
|
339
|
+
e.key === "Escape" && this.close();
|
|
340
|
+
}), this.live = document.createElement("div"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("role", "status"), Object.assign(this.live.style, {
|
|
341
|
+
position: "absolute",
|
|
342
|
+
width: "1px",
|
|
343
|
+
height: "1px",
|
|
344
|
+
overflow: "hidden",
|
|
345
|
+
clip: "rect(0 0 0 0)"
|
|
346
|
+
}), this.root.append(this.launcher, this.panel, this.arrow, this.live), this.applyLayout(), e.theme !== void 0 && this.setTheme(e.theme), (e.mountTo ?? document.body).appendChild(this.host), this.render(), L(e) && this.startAuthor();
|
|
347
|
+
}
|
|
348
|
+
async startAuthor() {
|
|
349
|
+
try {
|
|
350
|
+
(await R())?.startAuthoring({
|
|
351
|
+
labels: this.opts.labels,
|
|
352
|
+
theme: this.opts.theme,
|
|
353
|
+
colorScheme: this.cfg.scheme,
|
|
354
|
+
dir: this.cfg.dir,
|
|
355
|
+
lang: this.cfg.lang
|
|
356
|
+
});
|
|
357
|
+
} catch {}
|
|
358
|
+
}
|
|
359
|
+
t(e, t) {
|
|
360
|
+
return r(this.L[e], t);
|
|
361
|
+
}
|
|
362
|
+
setLabels(e) {
|
|
363
|
+
let t = a(e);
|
|
364
|
+
t.problems, this.L = t.labels, this.launcher.textContent = this.t("launcher"), this.panel.setAttribute("aria-label", this.t("dialogName")), this.render();
|
|
365
|
+
}
|
|
366
|
+
setTheme(e) {
|
|
367
|
+
let t = o(e);
|
|
368
|
+
this.theme = t.theme;
|
|
369
|
+
for (let e of this.themeProps) this.host.style.removeProperty(e);
|
|
370
|
+
let n = l(t.theme);
|
|
371
|
+
for (let [e, t] of Object.entries(n)) this.host.style.setProperty(e, t);
|
|
372
|
+
this.themeProps = Object.keys(n);
|
|
373
|
+
}
|
|
374
|
+
setColorScheme(e) {
|
|
375
|
+
this.cfg.scheme = u.includes(e) ? e : "auto", this.applyLayout(), this.setTheme(this.theme);
|
|
376
|
+
}
|
|
377
|
+
setLayout(e) {
|
|
378
|
+
e.dir !== void 0 && (this.cfg.dir = e.dir === "ltr" || e.dir === "rtl" ? e.dir : "auto"), e.lang !== void 0 && (this.cfg.lang = e.lang.trim().slice(0, 35)), e.launcher !== void 0 && (this.cfg.launcher = e.launcher === "none" ? "none" : "default"), e.launcherSide !== void 0 && (this.cfg.side = e.launcherSide === "start" ? "start" : "end"), this.applyLayout(), this.syncTour();
|
|
379
|
+
}
|
|
380
|
+
applyLayout() {
|
|
381
|
+
let e = (e, t) => t === null ? this.host.removeAttribute(e) : this.host.setAttribute(e, t);
|
|
382
|
+
e("dir", this.cfg.dir === "auto" ? null : this.cfg.dir), e("lang", this.cfg.lang || null), e("data-scheme", this.cfg.scheme === "auto" ? null : this.cfg.scheme), e("data-launcher", this.cfg.launcher === "none" ? "none" : null), e("data-launcher-side", this.cfg.side === "start" ? "start" : null), this.launcher.hidden = this.cfg.launcher === "none";
|
|
383
|
+
}
|
|
384
|
+
isRtl() {
|
|
385
|
+
try {
|
|
386
|
+
return getComputedStyle(this.host).direction === "rtl";
|
|
387
|
+
} catch {
|
|
388
|
+
return !1;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
emit(e) {
|
|
392
|
+
this.host.dispatchEvent(new CustomEvent(e, {
|
|
393
|
+
bubbles: !0,
|
|
394
|
+
composed: !0
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
currentOpener() {
|
|
398
|
+
let e = document.activeElement;
|
|
399
|
+
return e instanceof HTMLElement && e !== document.body && e !== this.host && !this.host.contains(e) ? e : null;
|
|
400
|
+
}
|
|
401
|
+
open() {
|
|
402
|
+
let e = !this.panel.hidden;
|
|
403
|
+
e || (this.opener = this.currentOpener()), this.panel.hidden = !1, this.launcher.setAttribute("aria-expanded", "true"), this.syncTour(), this.focusFirst(), e || this.emit(W);
|
|
404
|
+
}
|
|
405
|
+
close() {
|
|
406
|
+
let e = !this.panel.hidden;
|
|
407
|
+
this.panel.hidden = !0, this.launcher.setAttribute("aria-expanded", "false"), this.hl.hide(), this.spotlight.hide(), this.arrow.hidden = !0, this.stopWatching();
|
|
408
|
+
let t = this.opener?.isConnected ? this.opener : null;
|
|
409
|
+
this.opener = null, t ? t.focus() : this.launcher.hidden || this.launcher.focus(), e && this.emit(G);
|
|
410
|
+
}
|
|
411
|
+
destroy() {
|
|
412
|
+
document.removeEventListener("click", this.onDocClick, !0), this.stopWatching(), this.hl.hide(), this.spotlight.hide(), this.host.remove();
|
|
413
|
+
}
|
|
414
|
+
async ask(e) {
|
|
415
|
+
let t = e.trim();
|
|
416
|
+
if (!t) return this.notice = this.t("emptyGoal"), this.render();
|
|
417
|
+
this.notice = "", this.noticeAlert = !1, this.lastGoal = t, this.focusTitle = !0, this.hl.hide(), this.view = { kind: "loading" }, this.render();
|
|
418
|
+
try {
|
|
419
|
+
let e = await this.client.requestWalkthrough(t, { url: location.href });
|
|
420
|
+
this.wt = e, this.index = 0, this.confirmed.clear(), this.assisted.clear(), this.userActed = !1, this.assistNote = null, this.view = e.status === "ok" ? { kind: "step" } : {
|
|
421
|
+
kind: "insufficient",
|
|
422
|
+
wt: e
|
|
423
|
+
};
|
|
424
|
+
} catch (e) {
|
|
425
|
+
this.view = {
|
|
426
|
+
kind: "error",
|
|
427
|
+
message: e instanceof Error ? e.message : this.t("genericError")
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
await this.render();
|
|
431
|
+
}
|
|
432
|
+
async next() {
|
|
433
|
+
let e = this.step();
|
|
434
|
+
if (!this.wt || !e || V(e) && !this.confirmed.has(e.id)) return;
|
|
435
|
+
let t = this.attemptAssist(e);
|
|
436
|
+
this.assistNote = null, t && "failed" in t ? (this.assistNote = {
|
|
437
|
+
text: this.t("assistFailed", { label: t.failed }),
|
|
438
|
+
alert: !0
|
|
439
|
+
}, await this.render()) : (t && await K(), this.index >= this.wt.steps.length - 1 ? (this.hl.hide(), this.view = { kind: "done" }) : this.index++, this.userActed = !1, t && (this.assistNote = {
|
|
440
|
+
text: this.t("assistClicked", { label: t.label }),
|
|
441
|
+
alert: !1
|
|
442
|
+
}), this.focusTitle = !0, await this.render());
|
|
443
|
+
}
|
|
444
|
+
async prev() {
|
|
445
|
+
this.index > 0 && (this.index--, this.userActed = !1, this.assistNote = null, this.view = { kind: "step" }, this.focusTitle = !0, await this.render());
|
|
446
|
+
}
|
|
447
|
+
async skip() {
|
|
448
|
+
this.wt && this.step() && (this.userActed = !1, this.assistNote = null, this.index >= this.wt.steps.length - 1 ? (this.hl.hide(), this.view = { kind: "done" }) : this.index++, this.focusTitle = !0, await this.render());
|
|
449
|
+
}
|
|
450
|
+
async confirm() {
|
|
451
|
+
let e = this.step();
|
|
452
|
+
e && this.confirmed.add(e.id), await this.render();
|
|
453
|
+
}
|
|
454
|
+
async retry() {
|
|
455
|
+
await this.render();
|
|
456
|
+
}
|
|
457
|
+
state() {
|
|
458
|
+
return {
|
|
459
|
+
view: this.view.kind,
|
|
460
|
+
index: this.index,
|
|
461
|
+
missing: this.missing,
|
|
462
|
+
ambiguous: this.ambiguous,
|
|
463
|
+
wt: this.wt
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
assistBlock(e) {
|
|
467
|
+
if (this.host.contains(e) || e.getRootNode() === this.root) return "guide";
|
|
468
|
+
if (e.closest("[inert]")) return "inert";
|
|
469
|
+
if (e.getAttribute("aria-disabled") === "true" || e.closest("[aria-disabled=\"true\"]")) return "disabled";
|
|
470
|
+
try {
|
|
471
|
+
if (e.matches(":disabled")) return "disabled";
|
|
472
|
+
} catch {}
|
|
473
|
+
if (e instanceof HTMLInputElement && e.type === "file") return "file";
|
|
474
|
+
let t = e.closest("a");
|
|
475
|
+
if (t) {
|
|
476
|
+
if (t.hasAttribute("download") || t.target && t.target !== "_self") return "link";
|
|
477
|
+
let e = t.getAttribute("href");
|
|
478
|
+
if (e !== null) try {
|
|
479
|
+
let t = new URL(e, location.href);
|
|
480
|
+
if (t.protocol !== "http:" && t.protocol !== "https:" || t.origin !== location.origin) return "link";
|
|
481
|
+
} catch {
|
|
482
|
+
return "link";
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
attemptAssist(e) {
|
|
488
|
+
if (!this.assist || this.released || this.userActed || this.assisted.has(this.index) || e.action !== "click" || V(e)) return null;
|
|
489
|
+
let t = e.target;
|
|
490
|
+
if (!t.selectors.length && !t.text && !t.label) return null;
|
|
491
|
+
let n = s(t, document);
|
|
492
|
+
if (n.status !== "found") return null;
|
|
493
|
+
let r = n.element;
|
|
494
|
+
if (this.target?.isConnected && r !== this.target || this.assistBlock(r)) return null;
|
|
495
|
+
let a = (i(r).replace(/\s+/g, " ").trim() || t.text || t.label || e.title).slice(0, 80);
|
|
496
|
+
this.assisted.add(this.index), this.assisting = !0;
|
|
497
|
+
try {
|
|
498
|
+
r.click();
|
|
499
|
+
} catch {
|
|
500
|
+
return { failed: a };
|
|
501
|
+
} finally {
|
|
502
|
+
this.assisting = !1;
|
|
503
|
+
}
|
|
504
|
+
let o = {
|
|
505
|
+
stepIndex: this.index,
|
|
506
|
+
action: "click",
|
|
507
|
+
label: a
|
|
508
|
+
};
|
|
509
|
+
try {
|
|
510
|
+
this.opts.onAssist?.(o);
|
|
511
|
+
} catch {}
|
|
512
|
+
return this.host.dispatchEvent(new CustomEvent(U, {
|
|
513
|
+
detail: o,
|
|
514
|
+
bubbles: !0,
|
|
515
|
+
composed: !0
|
|
516
|
+
})), { label: a };
|
|
517
|
+
}
|
|
518
|
+
noteClick(e) {
|
|
519
|
+
if (this.assisting || !this.target || this.view.kind !== "step") return;
|
|
520
|
+
let t = e.composedPath();
|
|
521
|
+
if (t.includes(this.host)) return;
|
|
522
|
+
if (t.includes(this.target)) {
|
|
523
|
+
this.userActed = !0;
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
let n = t[0];
|
|
527
|
+
n instanceof Element && n.contains(this.target) && n.matches(H) && (this.userActed = !0);
|
|
528
|
+
}
|
|
529
|
+
step() {
|
|
530
|
+
return this.view.kind === "step" ? this.wt?.steps[this.index] : void 0;
|
|
531
|
+
}
|
|
532
|
+
async toggleRecording() {
|
|
533
|
+
if (!this.recording) {
|
|
534
|
+
try {
|
|
535
|
+
this.recorder ?? (this.recorder = (this.opts.recorderFactory ?? (() => new D()))()), await this.recorder.start(), this.recording = !0, this.notice = this.t("recording");
|
|
536
|
+
} catch {
|
|
537
|
+
this.recorder = null, this.notice = this.t("voiceUnavailable");
|
|
538
|
+
}
|
|
539
|
+
return this.render();
|
|
540
|
+
}
|
|
541
|
+
this.recording = !1, this.noticeAlert = !1;
|
|
542
|
+
try {
|
|
543
|
+
let e = await this.recorder.stop();
|
|
544
|
+
this.notice = this.t("transcribing"), await this.render();
|
|
545
|
+
let t = await this.client.transcribe(e);
|
|
546
|
+
this.notice = "", await this.ask(t);
|
|
547
|
+
} catch (e) {
|
|
548
|
+
if (e instanceof S) {
|
|
549
|
+
this.notice = this.t("noSpeech"), this.noticeAlert = !0, await this.render(), this.panel.querySelector("[data-autofocus]")?.focus();
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.notice = e instanceof x ? this.t("voiceUnavailable") : this.t("audioFailed"), await this.render();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
focusFirst() {
|
|
556
|
+
(this.panel.querySelector("[data-autofocus]") ?? this.panel.querySelector("button, input"))?.focus();
|
|
557
|
+
}
|
|
558
|
+
el(e, t = {}, n) {
|
|
559
|
+
let r = document.createElement(e);
|
|
560
|
+
return Object.assign(r, t), n !== void 0 && (r.textContent = n), r;
|
|
561
|
+
}
|
|
562
|
+
async render() {
|
|
563
|
+
let e = ++this.renderToken;
|
|
564
|
+
this.stopWatching(), this.released = !1;
|
|
565
|
+
let t = this.root.activeElement?.getAttribute("data-key"), n = this.panel, r = this.view.kind === "step";
|
|
566
|
+
this.spotlight.hide(), n.className = r ? "hp-panel hp-tour" : "hp-panel", n.setAttribute("part", r ? "panel card" : "panel"), n.removeAttribute("data-placement"), n.style.left = "", n.style.top = "", n.replaceChildren(), this.target = null, this.arrow.hidden = !0, this.missing = !1, this.ambiguous = !1;
|
|
567
|
+
let i = this.el("div", { className: r ? "hp-tour-head" : "hp-head" });
|
|
568
|
+
r || i.append(q(this.el("h2", {}, this.t("heading")), "title")), r && i.append(q(this.el("div", { className: "hp-tour-count" }, this.t("tourCount", {
|
|
569
|
+
current: this.index + 1,
|
|
570
|
+
total: this.wt.steps.length
|
|
571
|
+
})), "progress"));
|
|
572
|
+
let a = q(this.el("button", {
|
|
573
|
+
type: "button",
|
|
574
|
+
className: "hp-close"
|
|
575
|
+
}, "×"), "button close");
|
|
576
|
+
if (a.setAttribute("aria-label", this.t("closeLabel")), a.setAttribute("data-key", "close"), a.addEventListener("click", () => this.close()), i.append(a), n.append(i), n.append(this.goalForm(r)), r) {
|
|
577
|
+
let e = this.el("details", {
|
|
578
|
+
className: "hp-tour-tools",
|
|
579
|
+
open: this.goalToolsOpen || this.recording || !!this.notice
|
|
580
|
+
});
|
|
581
|
+
q(e, "tools"), e.append(this.el("summary", {}, this.t("changeGoal"))), e.addEventListener("toggle", () => {
|
|
582
|
+
this.goalToolsOpen = e.open;
|
|
583
|
+
}), e.append(n.querySelector("form")), n.append(e);
|
|
584
|
+
}
|
|
585
|
+
this.notice && n.append(q(this.el("p", { role: this.noticeAlert ? "alert" : "status" }, this.notice), this.noticeAlert ? "alert" : "text")), this.assistNote && n.append(this.assistNote.alert ? q(this.el("p", {
|
|
586
|
+
className: "hp-assist-note hp-alert",
|
|
587
|
+
role: "alert"
|
|
588
|
+
}, this.assistNote.text), "alert") : q(this.el("p", { className: "hp-assist-note" }, this.assistNote.text), "hint"));
|
|
589
|
+
let o = this.view;
|
|
590
|
+
if (o.kind === "loading" && n.append(q(this.el("p", {}, this.t("loading")), "text")), o.kind === "error") {
|
|
591
|
+
let e = this.alert(o.message), t = q(this.el("button", { type: "button" }, this.t("tryAgain")), "button button-secondary");
|
|
592
|
+
t.addEventListener("click", () => void this.ask(this.lastGoal)), e.append(t), n.append(e);
|
|
593
|
+
}
|
|
594
|
+
if (o.kind === "insufficient" && this.renderInsufficient(o.wt), o.kind === "done") {
|
|
595
|
+
let e = this.wt?.goal ?? this.lastGoal, t = q(this.el("p", {}, this.t("done", { goal: e })), "text");
|
|
596
|
+
t.tabIndex = -1;
|
|
597
|
+
let r = q(this.el("button", { type: "button" }, this.t("startAnother")), "button button-secondary");
|
|
598
|
+
r.addEventListener("click", () => {
|
|
599
|
+
this.view = { kind: "idle" }, this.wt = null, this.render().then(() => this.focusFirst());
|
|
600
|
+
}), n.append(t, r), this.announce(this.t("done", { goal: e })), this.focusTitle && t.focus(), this.focusTitle = !1;
|
|
601
|
+
}
|
|
602
|
+
if (o.kind === "step") {
|
|
603
|
+
let t = this.step();
|
|
604
|
+
this.renderStep(t), await this.locate(t, e);
|
|
605
|
+
}
|
|
606
|
+
r && !this.panel.hidden ? this.spotlight.show(this.target, () => this.positionTour()) : this.spotlight.hide(), o.kind === "step" && this.watch(), t && this.panel.querySelector(`[data-key="${t}"]`)?.focus({ preventScroll: !0 });
|
|
607
|
+
}
|
|
608
|
+
syncTour() {
|
|
609
|
+
if (this.view.kind !== "step") return this.spotlight.hide();
|
|
610
|
+
this.released ? this.reengage() : this.spotlight.show(this.target, () => this.positionTour()), this.watch();
|
|
611
|
+
}
|
|
612
|
+
stopWatching() {
|
|
613
|
+
this.stopWatch?.(), this.stopWatch = void 0;
|
|
614
|
+
}
|
|
615
|
+
watch() {
|
|
616
|
+
this.stopWatching();
|
|
617
|
+
let e = this.target;
|
|
618
|
+
e && this.view.kind === "step" && (this.stopWatch = M(e, (e) => e ? this.reengage() : this.release()));
|
|
619
|
+
}
|
|
620
|
+
release() {
|
|
621
|
+
let e = this.step(), t = this.target;
|
|
622
|
+
if (!e || !t || this.released) return;
|
|
623
|
+
let n = s(e.target, document);
|
|
624
|
+
if (n.status === "found" && n.element !== t && this.anchor?.isConnected && this.anchor.contains(n.element)) return this.rebind(n.element);
|
|
625
|
+
this.released = !0, this.hl.hide(), this.spotlight.hide(), this.arrow.hidden = !0, this.panel.classList.add("hp-released", "hp-floating"), this.panel.removeAttribute("data-placement");
|
|
626
|
+
let r = q(this.el("p", { className: "hp-released-note" }, this.t("releasedNote")), "hint");
|
|
627
|
+
this.hintEl ? this.hintEl.after(r) : this.panel.append(r), this.announce(this.t("releasedNote"));
|
|
628
|
+
}
|
|
629
|
+
reengage() {
|
|
630
|
+
if (!this.released || !this.target) return;
|
|
631
|
+
this.released = !1, this.panel.classList.remove("hp-released"), this.panel.querySelector(".hp-released-note")?.remove();
|
|
632
|
+
let e = this.step();
|
|
633
|
+
e && (!V(e) || this.confirmed.has(e.id)) && this.hl.show(this.target), this.spotlight.show(this.target, () => this.positionTour());
|
|
634
|
+
}
|
|
635
|
+
rebind(e) {
|
|
636
|
+
this.target = e, this.targetOffset = w(e), this.anchor = e.parentElement;
|
|
637
|
+
let t = this.step();
|
|
638
|
+
t && (!V(t) || this.confirmed.has(t.id)) && this.hl.show(e), this.spotlight.show(e, () => this.positionTour()), this.watch();
|
|
639
|
+
}
|
|
640
|
+
positionTour() {
|
|
641
|
+
if (this.panel.hidden || this.view.kind !== "step") return;
|
|
642
|
+
if (!this.target) {
|
|
643
|
+
this.panel.classList.add("hp-floating"), this.panel.removeAttribute("data-placement"), this.arrow.hidden = !0;
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
let e = this.target.getBoundingClientRect(), t = {
|
|
647
|
+
left: e.left + this.targetOffset.x,
|
|
648
|
+
top: e.top + this.targetOffset.y,
|
|
649
|
+
right: e.right + this.targetOffset.x,
|
|
650
|
+
bottom: e.bottom + this.targetOffset.y
|
|
651
|
+
};
|
|
652
|
+
this.panel.classList.remove("hp-floating"), this.panel.style.left = "12px", this.panel.style.top = "12px";
|
|
653
|
+
let n = this.panel.getBoundingClientRect(), r = N(t, n, {
|
|
654
|
+
width: innerWidth,
|
|
655
|
+
height: innerHeight
|
|
656
|
+
}, void 0, this.isRtl());
|
|
657
|
+
this.panel.style.left = `${r.left}px`, this.panel.style.top = `${r.top}px`, this.panel.dataset.placement = r.placement, this.arrow.hidden = r.placement === "floating" || r.placement === "left" || r.placement === "right", this.arrow.hidden || (this.arrow.style.left = `${r.left + r.arrowLeft - 8}px`, this.arrow.style.top = `${r.placement === "below" ? r.top - 8 : r.top + n.height - 8}px`);
|
|
658
|
+
}
|
|
659
|
+
goalForm(e = !1) {
|
|
660
|
+
let t = this.el("form");
|
|
661
|
+
e && (t.className = "hp-goal-compact");
|
|
662
|
+
let n = this.el("label", { className: e ? "hp-sr-only" : "" }, this.t("goalQuestion")), r = this.el("input", {
|
|
663
|
+
type: "text",
|
|
664
|
+
name: "goal",
|
|
665
|
+
autocomplete: "off"
|
|
666
|
+
});
|
|
667
|
+
r.setAttribute("data-autofocus", ""), r.setAttribute("data-key", "goal"), r.setAttribute("aria-label", this.t("goalAria")), r.setAttribute("part", "goal-input"), r.placeholder = this.t("goalPlaceholder"), (this.view.kind === "step" || this.view.kind === "done") && (r.value = this.wt?.goal ?? "");
|
|
668
|
+
let i = q(this.el("button", {
|
|
669
|
+
type: "submit",
|
|
670
|
+
className: "hp-primary"
|
|
671
|
+
}, this.t("submit")), "button button-primary"), a = this.el("div", { className: "hp-row" });
|
|
672
|
+
if (a.append(r, i), this.micOk) {
|
|
673
|
+
let e = q(this.el("button", { type: "button" }, this.recording ? this.t("stop") : this.t("speak")), "button button-secondary");
|
|
674
|
+
e.setAttribute("aria-pressed", String(this.recording)), e.setAttribute("data-key", "mic"), e.addEventListener("click", () => void this.toggleRecording()), a.append(e);
|
|
675
|
+
}
|
|
676
|
+
let o = q(this.el("label", { className: "hp-assist" }), "toggle"), s = this.el("input", {
|
|
677
|
+
type: "checkbox",
|
|
678
|
+
checked: this.assist
|
|
679
|
+
});
|
|
680
|
+
return s.setAttribute("data-key", "assist"), s.addEventListener("change", () => {
|
|
681
|
+
this.assist = s.checked, this.render();
|
|
682
|
+
}), o.append(s, this.el("span", {}, this.t("assistToggle"))), t.append(n, a, o), t.addEventListener("submit", (e) => {
|
|
683
|
+
e.preventDefault(), this.ask(r.value);
|
|
684
|
+
}), t;
|
|
685
|
+
}
|
|
686
|
+
alert(e) {
|
|
687
|
+
return q(this.el("div", {
|
|
688
|
+
className: "hp-alert",
|
|
689
|
+
role: "alert"
|
|
690
|
+
}, e), "alert");
|
|
691
|
+
}
|
|
692
|
+
renderInsufficient(e) {
|
|
693
|
+
let t = this.alert(e.message ?? this.t("insufficient"));
|
|
694
|
+
if (e.missingEvidence?.length) {
|
|
695
|
+
let n = this.el("ul");
|
|
696
|
+
e.missingEvidence.forEach((e) => n.append(this.el("li", {}, e))), t.append(n);
|
|
697
|
+
}
|
|
698
|
+
this.panel.append(t);
|
|
699
|
+
let n = e.suggestions ?? [];
|
|
700
|
+
if (!n.length) return;
|
|
701
|
+
let r = q(this.el("div", { className: "hp-suggest" }), "suggestions");
|
|
702
|
+
r.setAttribute("role", "group"), r.setAttribute("aria-labelledby", "hp-suggest-label"), r.append(this.el("p", {
|
|
703
|
+
id: "hp-suggest-label",
|
|
704
|
+
className: "hp-suggest-label"
|
|
705
|
+
}, this.t("suggestLabel"))), n.forEach((e, t) => {
|
|
706
|
+
let n = q(this.el("button", {
|
|
707
|
+
type: "button",
|
|
708
|
+
className: "hp-suggestion"
|
|
709
|
+
}, e.title), "button button-secondary suggestion");
|
|
710
|
+
n.setAttribute("data-key", `suggest-${t}`), n.addEventListener("click", () => void this.ask(e.title)), r.append(n);
|
|
711
|
+
}), this.panel.append(r), this.announce(this.t("suggestAnnounce", { list: n.map((e) => e.title).join("; ") }));
|
|
712
|
+
}
|
|
713
|
+
renderStep(e) {
|
|
714
|
+
let t = this.wt.steps.length, n = this.panel;
|
|
715
|
+
n.append(q(this.el("span", { className: "hp-progress hp-sr-only" }, this.t("stepProgress", {
|
|
716
|
+
current: this.index + 1,
|
|
717
|
+
total: t
|
|
718
|
+
})), "progress"));
|
|
719
|
+
let r = q(this.el("h2", {}, e.title), "title");
|
|
720
|
+
r.setAttribute("data-key", "title"), r.tabIndex = -1, this.focusTitle && queueMicrotask(() => r.focus({ preventScroll: !0 })), this.focusTitle = !1, n.append(r, q(this.el("p", {}, e.instruction), "text")), e.value && n.append(q(this.el("p", {}, this.t("suggestedValue", { value: e.value })), "text")), this.hintEl = q(this.el("p", { className: "hp-assist-hint" }, this.t("assistHint")), "hint"), this.hintEl.hidden = !this.assist || !!V(e) || e.action !== "type" && e.action !== "select" && e.action !== "navigate", n.append(this.hintEl);
|
|
721
|
+
let i = V(e), a = this.confirmed.has(e.id);
|
|
722
|
+
if (i) {
|
|
723
|
+
let e = q(this.el("div", { className: "hp-warn" }), "warning");
|
|
724
|
+
e.append(this.el("strong", {}, this.t("gateWarning")));
|
|
725
|
+
let t = this.el("label"), r = this.el("input", {
|
|
726
|
+
type: "checkbox",
|
|
727
|
+
checked: a
|
|
728
|
+
});
|
|
729
|
+
r.setAttribute("data-key", "confirm"), r.addEventListener("change", () => void this.confirm()), t.append(r, ` ${this.t("gateCheckbox")}`), e.append(this.el("br"), t), n.append(e);
|
|
730
|
+
}
|
|
731
|
+
let o = this.el("div", { className: "hp-row" }), s = q(this.el("button", {
|
|
732
|
+
type: "button",
|
|
733
|
+
className: "hp-back",
|
|
734
|
+
disabled: this.index === 0
|
|
735
|
+
}, this.t("back")), "button button-secondary");
|
|
736
|
+
s.addEventListener("click", () => void this.prev());
|
|
737
|
+
let c = q(this.el("button", {
|
|
738
|
+
type: "button",
|
|
739
|
+
className: "hp-skip"
|
|
740
|
+
}, this.t("skip")), "button button-secondary");
|
|
741
|
+
c.setAttribute("data-key", "skip"), c.addEventListener("click", () => void this.skip());
|
|
742
|
+
let l = this.index === t - 1, u = i && !a, d = q(this.el("button", {
|
|
743
|
+
type: "button",
|
|
744
|
+
className: "hp-primary"
|
|
745
|
+
}, l ? this.t("finish") : this.t("next")), "button button-primary");
|
|
746
|
+
d.setAttribute("data-key", "next"), u && (d.setAttribute("aria-disabled", "true"), d.setAttribute("aria-describedby", "hp-why"), o.append(this.el("span", {
|
|
747
|
+
id: "hp-why",
|
|
748
|
+
hidden: !0
|
|
749
|
+
}, this.t("gateWhy")))), d.addEventListener("click", () => void this.next());
|
|
750
|
+
let f = q(this.el("div", { className: "hp-row" }), "actions");
|
|
751
|
+
if (f.append(c, d), o.append(s, f), n.append(o), e.evidence.length) {
|
|
752
|
+
let t = q(this.el("details", { className: "hp-evidence" }), "evidence");
|
|
753
|
+
t.append(this.el("summary", {}, this.t("evidenceSummary", { count: e.evidence.length }))), e.evidence.forEach((e) => t.append(this.el("div", {}, `${e.sourceType} · ${e.path}:${e.lineStart}${e.lineEnd === e.lineStart ? "" : "-" + e.lineEnd} — ${e.excerpt}`))), n.append(t);
|
|
754
|
+
}
|
|
755
|
+
this.announce(this.t("stepAnnounce", {
|
|
756
|
+
current: this.index + 1,
|
|
757
|
+
total: t,
|
|
758
|
+
title: e.title,
|
|
759
|
+
instruction: e.instruction
|
|
760
|
+
}));
|
|
761
|
+
}
|
|
762
|
+
async locate(e, n) {
|
|
763
|
+
this.hl.hide();
|
|
764
|
+
let r = e.target;
|
|
765
|
+
if (!(r.selectors.length > 0 || r.text || r.label)) return;
|
|
766
|
+
let i = await t(r, this.opts.targetTimeoutMs ?? 1500, document);
|
|
767
|
+
if (n !== this.renderToken) return;
|
|
768
|
+
if (i.status === "found") {
|
|
769
|
+
this.target = i.element, this.anchor = i.element.parentElement, this.targetOffset = w(i.element), (!V(e) || this.confirmed.has(e.id)) && this.hl.show(i.element), this.assist && e.action === "click" && !V(e) && this.hintEl && this.assistBlock(i.element) && (this.hintEl.hidden = !1);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
this.missing = !0;
|
|
773
|
+
let a = r.text ?? r.label ?? r.selectors[0], o = i.status === "ambiguous";
|
|
774
|
+
this.ambiguous = o;
|
|
775
|
+
let s = this.alert(o ? this.t("ambiguous", { label: a }) : this.t("notFound", { label: a })), c = this.el("div", { className: "hp-row" }), l = q(this.el("button", { type: "button" }, this.t("tryAgain")), "button button-secondary");
|
|
776
|
+
l.setAttribute("data-key", "retry"), l.addEventListener("click", () => void this.retry());
|
|
777
|
+
let u = q(this.el("button", { type: "button" }, this.t("skipStep")), "button button-secondary");
|
|
778
|
+
u.setAttribute("data-key", "skip"), u.addEventListener("click", () => void this.skip()), c.append(l, u), s.append(c), this.panel.append(s), this.announce(this.t(o ? "ambiguousAnnounce" : "notFoundAnnounce", { title: e.title }));
|
|
779
|
+
}
|
|
780
|
+
announce(e) {
|
|
781
|
+
let t = this.assistNote && !this.assistNote.alert ? `${this.assistNote.text} ${e}` : e;
|
|
782
|
+
this.live.textContent = "", queueMicrotask(() => this.live.textContent = t);
|
|
783
|
+
}
|
|
784
|
+
}, Y = "heypointer-assistant", X = typeof HTMLElement > "u" ? class {} : HTMLElement, Z = [
|
|
785
|
+
"base-url",
|
|
786
|
+
"client-id",
|
|
787
|
+
"target-timeout-ms",
|
|
788
|
+
"assist",
|
|
789
|
+
"author",
|
|
790
|
+
"allow-author-param"
|
|
791
|
+
], Q = [
|
|
792
|
+
"labels",
|
|
793
|
+
"theme",
|
|
794
|
+
"color-scheme",
|
|
795
|
+
"dir",
|
|
796
|
+
"lang",
|
|
797
|
+
"launcher",
|
|
798
|
+
"launcher-side"
|
|
799
|
+
], $ = class extends X {
|
|
800
|
+
constructor(...e) {
|
|
801
|
+
super(...e), d(this, "gf", null), d(this, "labelsProp", void 0), d(this, "themeProp", void 0);
|
|
802
|
+
}
|
|
803
|
+
get player() {
|
|
804
|
+
return this.gf;
|
|
805
|
+
}
|
|
806
|
+
get labels() {
|
|
807
|
+
return this.labelsProp;
|
|
808
|
+
}
|
|
809
|
+
set labels(e) {
|
|
810
|
+
this.labelsProp = typeof e == "string" ? c("labels", e) : e, this.gf?.setLabels(this.currentLabels());
|
|
811
|
+
}
|
|
812
|
+
get theme() {
|
|
813
|
+
return this.themeProp;
|
|
814
|
+
}
|
|
815
|
+
set theme(e) {
|
|
816
|
+
this.themeProp = typeof e == "string" ? c("theme", e) : e, this.gf?.setTheme(this.currentTheme());
|
|
817
|
+
}
|
|
818
|
+
setLabels(e) {
|
|
819
|
+
this.labels = e;
|
|
820
|
+
}
|
|
821
|
+
open() {
|
|
822
|
+
this.gf?.open();
|
|
823
|
+
}
|
|
824
|
+
close() {
|
|
825
|
+
this.gf?.close();
|
|
826
|
+
}
|
|
827
|
+
ask(e) {
|
|
828
|
+
return this.gf ? this.gf.ask(e) : Promise.resolve();
|
|
829
|
+
}
|
|
830
|
+
connectedCallback() {
|
|
831
|
+
this.style.display = "contents", this.mount();
|
|
832
|
+
}
|
|
833
|
+
disconnectedCallback() {
|
|
834
|
+
this.gf?.destroy(), this.gf = null;
|
|
835
|
+
}
|
|
836
|
+
attributeChangedCallback(e, t, n) {
|
|
837
|
+
if (this.isConnected && t !== n) {
|
|
838
|
+
if (Z.includes(e) || !this.gf) return void this.mount();
|
|
839
|
+
switch (e) {
|
|
840
|
+
case "labels":
|
|
841
|
+
this.gf.setLabels(this.currentLabels());
|
|
842
|
+
break;
|
|
843
|
+
case "theme":
|
|
844
|
+
this.gf.setTheme(this.currentTheme());
|
|
845
|
+
break;
|
|
846
|
+
case "color-scheme":
|
|
847
|
+
this.gf.setColorScheme(this.scheme());
|
|
848
|
+
break;
|
|
849
|
+
default: this.gf.setLayout(this.layout());
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
currentLabels() {
|
|
854
|
+
return this.labelsProp ?? c("labels", this.getAttribute("labels"));
|
|
855
|
+
}
|
|
856
|
+
currentTheme() {
|
|
857
|
+
return this.themeProp ?? c("theme", this.getAttribute("theme"));
|
|
858
|
+
}
|
|
859
|
+
scheme() {
|
|
860
|
+
return this.getAttribute("color-scheme") ?? void 0;
|
|
861
|
+
}
|
|
862
|
+
layout() {
|
|
863
|
+
return {
|
|
864
|
+
dir: this.getAttribute("dir") ?? "auto",
|
|
865
|
+
lang: this.getAttribute("lang") ?? "",
|
|
866
|
+
launcher: this.getAttribute("launcher") === "none" ? "none" : "default",
|
|
867
|
+
launcherSide: this.getAttribute("launcher-side") === "start" ? "start" : "end"
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
mount() {
|
|
871
|
+
let e = this.getAttribute("base-url");
|
|
872
|
+
if (this.gf?.destroy(), this.gf = null, !e) return;
|
|
873
|
+
let t = Number(this.getAttribute("target-timeout-ms")), n = this.getAttribute("client-id")?.trim(), r = this.hasAttribute("assist") && this.getAttribute("assist") !== "false", i = (e) => this.hasAttribute(e) && this.getAttribute(e) !== "false", a = this.layout(), o = this.currentLabels(), s = this.currentTheme(), c = {
|
|
874
|
+
baseUrl: e,
|
|
875
|
+
...r ? { assist: r } : {},
|
|
876
|
+
...i("author") ? { author: !0 } : {},
|
|
877
|
+
...i("allow-author-param") ? { allowAuthorParam: !0 } : {},
|
|
878
|
+
...n ? { clientId: n } : {},
|
|
879
|
+
mountTo: this,
|
|
880
|
+
...Number.isFinite(t) && t > 0 ? { targetTimeoutMs: t } : {},
|
|
881
|
+
...o === void 0 ? {} : { labels: o },
|
|
882
|
+
...s === void 0 ? {} : { theme: s },
|
|
883
|
+
colorScheme: this.scheme(),
|
|
884
|
+
dir: a.dir,
|
|
885
|
+
lang: a.lang,
|
|
886
|
+
launcher: a.launcher,
|
|
887
|
+
launcherSide: a.launcherSide
|
|
888
|
+
};
|
|
889
|
+
this.gf = new J(c);
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
d($, "observedAttributes", [...Z, ...Q]);
|
|
893
|
+
function ee(e = Y) {
|
|
894
|
+
typeof customElements < "u" && !customElements.get(e) && customElements.define(e, $);
|
|
895
|
+
}
|
|
896
|
+
export { G as a, v as c, x as d, _ as f, U as i, C as l, $ as n, J as o, ee as r, W as s, Y as t, S as u };
|