@journeeze/sdk 0.1.0 → 0.3.0-rc.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/AGENTS.md +2 -2
- package/CHANGELOG.md +25 -1
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +22 -20
- package/dist/anchor-bnZCZtbG.js +1 -0
- package/dist/attach-EfetX0Vi.js +21 -0
- package/dist/chat-Coze4aH0.js +64 -0
- package/dist/claims-VKhPNjA7.js +1 -0
- package/dist/consent-bPengyOI.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-DeMvbZnh.js +1 -0
- package/dist/help-phTc32Gg.js +105 -0
- package/dist/highlight-pU9nE3Qj.js +2 -0
- package/dist/{hook-DGWypoEO.js → hook-M34sajh9.js} +1 -1
- package/dist/index.js +6 -8
- package/dist/loader-DHgG5Y7t.js +127 -0
- package/dist/mask-audit-KFvSiJU0.js +5 -0
- package/dist/react.js +1 -1
- package/dist/resolve-CRDmtd4b.js +1 -0
- package/dist/script.js +1 -1
- package/dist/{signals-amjMQyOy.js → signals-C_WxFykA.js} +1 -1
- package/dist/telemetry-CdwMjZZZ.js +1 -0
- package/dist/{transport-B64CfIcF.js → transport-Wrkorx6z.js} +1 -1
- package/dist/types/chat/capture/attach.d.ts +2 -0
- package/dist/types/chat/shell/chat.d.ts +4 -2
- package/dist/types/chat/shell/converse.d.ts +2 -0
- package/dist/types/chat/shell/guide.d.ts +12 -0
- package/dist/types/chat/shell/session.d.ts +6 -0
- package/dist/types/chat/shell/walk.d.ts +49 -0
- package/dist/types/chat/transport.d.ts +1 -1
- package/dist/types/claims.d.ts +37 -0
- package/dist/types/help/core/client.d.ts +3 -0
- package/dist/types/help/core/events.d.ts +1 -1
- package/dist/types/help/core/routing.d.ts +2 -0
- package/dist/types/loader.d.ts +3 -0
- package/dist/types/preview/mask-audit.d.ts +3 -1
- package/dist/types/telemetry/telemetry.d.ts +4 -0
- package/dist/types/types.d.ts +34 -0
- package/dist/types/widget/feedback.d.ts +7 -1
- package/dist/types/widget/upload.d.ts +3 -2
- package/dist/{upload-Fu2qvSJV.js → upload-KvsGqMEV.js} +6 -6
- package/dist/walk-BEGYyGG3.js +1 -0
- package/dist/widget-BA2WH0yi.js +118 -0
- package/package.json +4 -3
- package/LICENSE.md +0 -27
- package/dist/anchor-cPvFFTOS.js +0 -1
- package/dist/attach-DpioALxW.js +0 -21
- package/dist/chat-BgmB0rnW.js +0 -64
- package/dist/consent-DckCUvYR.js +0 -1
- package/dist/context-UnG6_X61.js +0 -17
- package/dist/feedback-CtH1a_kQ.js +0 -1
- package/dist/help-w0O5Qu-4.js +0 -105
- package/dist/index-CwG2LrhO.js +0 -20
- package/dist/loader-BZiIDD1D.js +0 -96
- package/dist/mask-audit-Du3NPoG_.js +0 -5
- package/dist/resolve-BfWByuTp.js +0 -1
- package/dist/telemetry-CyRJDaVs.js +0 -1
- package/dist/widget-B6mR1J3P.js +0 -118
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** `base64url(payload) "." base64url(mac)`, unpadded; the mac is an HMAC-SHA256 tag (43). */
|
|
2
|
+
export declare const CLAIMS_TOKEN_PATTERN: RegExp;
|
|
3
|
+
/** Largest token the SDK sends (the collector's bound). */
|
|
4
|
+
export declare const CLAIMS_TOKEN_MAX_LEN = 4096;
|
|
5
|
+
/** A token this close to its end (seconds) is refreshed before it is sent. */
|
|
6
|
+
export declare const CLAIMS_REFRESH_MARGIN_S = 60;
|
|
7
|
+
/** At most one `getToken()` call per this many milliseconds while a usable token is held. */
|
|
8
|
+
export declare const CLAIMS_MIN_REFRESH_INTERVAL_MS = 15000;
|
|
9
|
+
/** The options a claims source reads and writes (the chunks' shared mount options). */
|
|
10
|
+
export interface ClaimsOptions {
|
|
11
|
+
claims?: string | undefined;
|
|
12
|
+
getToken?: (() => Promise<string>) | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Whether `token` has the v2 token shape. */
|
|
15
|
+
export declare function wellFormedClaims(token: unknown): token is string;
|
|
16
|
+
/** The token's `exp` (Unix seconds), read from its payload; `undefined` when it cannot be read. */
|
|
17
|
+
export declare function claimsExp(token: string): number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The page-clock time (ms) the token stops being usable: first seen + (`exp − iat`). `undefined`
|
|
20
|
+
* when its payload has no integer `exp` and `iat`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function claimsEnd(token: string, now?: number): number | undefined;
|
|
23
|
+
/** `token` when it is well formed and more than `margin` seconds from its end, else `undefined`. */
|
|
24
|
+
export declare function usableClaims(token: unknown, margin?: number, now?: number): string | undefined;
|
|
25
|
+
export interface ClaimsSource {
|
|
26
|
+
/** The token to send now, refreshed through `getToken()` when needed; `undefined`: send none. */
|
|
27
|
+
token(): Promise<string | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* The token to send now without waiting (unload and keepalive sends): the current one while
|
|
30
|
+
* it is usable, else none. It may start a refresh in the background for the next send.
|
|
31
|
+
*/
|
|
32
|
+
current(): string | undefined;
|
|
33
|
+
/** The chunk unmounted: a `getToken()` still in flight is discarded, never stored. */
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
36
|
+
/** One chunk's view of the host's claims (one `getToken()` call at a time). */
|
|
37
|
+
export declare function claimsSource(options: ClaimsOptions, now?: () => number): ClaimsSource;
|
|
@@ -4,6 +4,8 @@ export interface HelpClientOptions {
|
|
|
4
4
|
siteKey: string;
|
|
5
5
|
/** Sent on help reads when set: reviewers sites require it, public sites validate it (ADR 0013 §1). */
|
|
6
6
|
reviewerToken?: string | undefined;
|
|
7
|
+
/** Signed claims v2 (contract §15): the token to send now, if any. */
|
|
8
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
7
9
|
fetchImpl?: typeof fetch;
|
|
8
10
|
now?: () => number;
|
|
9
11
|
/** How long a value is used without asking the collector again. */
|
|
@@ -23,4 +25,5 @@ export declare class HelpClient {
|
|
|
23
25
|
guide(journeyId: string): Promise<GetGuideResponse>;
|
|
24
26
|
private body;
|
|
25
27
|
private read;
|
|
28
|
+
private readWith;
|
|
26
29
|
}
|
|
@@ -29,4 +29,4 @@ export interface TelemetryHook {
|
|
|
29
29
|
/** `discard` (a logout): drop queued events instead of sending them. */
|
|
30
30
|
stop(discard?: boolean): void;
|
|
31
31
|
}
|
|
32
|
-
export declare function telemetryHook(endpoint: string, siteKey: string, controller: HelpController): TelemetryHook;
|
|
32
|
+
export declare function telemetryHook(endpoint: string, siteKey: string, controller: HelpController, claims?: () => string | undefined): TelemetryHook;
|
|
@@ -6,6 +6,8 @@ export interface RouteDeps {
|
|
|
6
6
|
endpoint: string;
|
|
7
7
|
siteKey: string;
|
|
8
8
|
reviewerToken?: string | undefined;
|
|
9
|
+
/** Signed claims v2 (contract §15): the token to send, if any (gated guides route only with it). */
|
|
10
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
9
11
|
/** The site's consent, read on every call. */
|
|
10
12
|
hasConsent(): boolean;
|
|
11
13
|
/** Whether this reader may send requests at all. */
|
package/dist/types/loader.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export interface MountOptions extends JourneezeOptions {
|
|
|
31
31
|
userIdExp?: number | undefined;
|
|
32
32
|
/** The signature last given to `setUser` (it wins over the config's). */
|
|
33
33
|
signature?: JourneezeUserIdSignature | "" | undefined;
|
|
34
|
+
/** Signed claims v2 (contract §15): read and refreshed by the chunks (`claims.ts`). */
|
|
35
|
+
claims?: string | undefined;
|
|
36
|
+
getToken?: (() => Promise<string>) | undefined;
|
|
34
37
|
maskSelectors?: readonly string[];
|
|
35
38
|
maskAllText?: boolean;
|
|
36
39
|
nonce?: string;
|
|
@@ -18,11 +18,13 @@ export interface MaskAuditOptions {
|
|
|
18
18
|
reviewerToken: string;
|
|
19
19
|
/** Host and journey-configuration selectors: elements they cover are already masked. */
|
|
20
20
|
maskSelectors?: readonly string[];
|
|
21
|
+
/** The host's `pagePath` option: `"none"` sends no page path. */
|
|
22
|
+
pagePath?: "redacted" | "none";
|
|
21
23
|
fetchImpl?: typeof fetch;
|
|
22
24
|
now?: () => Date;
|
|
23
25
|
}
|
|
24
26
|
/** The page's findings, value-free. Pure apart from reading the DOM. */
|
|
25
|
-
export declare function auditPage(scan: Scan, root: Element, href: string, selectors: readonly string[], now: Date): MaskFindingWire[];
|
|
27
|
+
export declare function auditPage(scan: Scan, root: Element, href: string, selectors: readonly string[], now: Date, pagePathMode?: "redacted" | "none"): MaskFindingWire[];
|
|
26
28
|
/** Audits the current page and submits what is new for this tab. Never throws into the host. */
|
|
27
29
|
export declare function runMaskAudit(opts: MaskAuditOptions): Promise<number>;
|
|
28
30
|
/** Test helper: forget what this tab sent. */
|
|
@@ -26,6 +26,8 @@ export interface RecordHelpEventsRequest {
|
|
|
26
26
|
events: WireHelpEvent[];
|
|
27
27
|
/** C0b v1.1 §4: events this page load dropped at an earlier page end (aggregate, no ids). */
|
|
28
28
|
droppedAtUnload?: number;
|
|
29
|
+
/** Signed claims v2 (contract §15): events about entitlement-gated guides count only with it. */
|
|
30
|
+
claims?: string;
|
|
29
31
|
}
|
|
30
32
|
export interface TelemetryOptions {
|
|
31
33
|
endpoint: string;
|
|
@@ -45,6 +47,8 @@ export interface TelemetryOptions {
|
|
|
45
47
|
* Do Not Track is ignored (C0a §7).
|
|
46
48
|
*/
|
|
47
49
|
respectGlobalPrivacyControl?: boolean;
|
|
50
|
+
/** The current usable claims token, never awaited (page-end sends included). */
|
|
51
|
+
claims?: (() => string | undefined) | undefined;
|
|
48
52
|
}
|
|
49
53
|
/** Whether Global Privacy Control turns telemetry off for these options. */
|
|
50
54
|
export declare function gpcRefusesTelemetry(opts: Pick<TelemetryOptions, "respectGlobalPrivacyControl">, nav?: object | undefined): boolean;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -155,6 +155,25 @@ export interface JourneezeConfigV1 extends Omit<JourneezeOptions, "endpoint">, J
|
|
|
155
155
|
userIdSig?: string;
|
|
156
156
|
/** Expiry of {@link userIdSig}, Unix seconds (at most 24 h ahead). */
|
|
157
157
|
userIdExp?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Signed claims v2 (contract §15, v1.4 additive; needs Allumata sign-off): a token from the
|
|
160
|
+
* host's server, `base64url(payload) "." base64url(mac)` unpadded, where `payload` is the
|
|
161
|
+
* RFC 8785 canonical JSON of the claims and `mac` is HMAC-SHA256(site identity secret named by
|
|
162
|
+
* `kid`, `"jz-claims-v2\n" + payload`). A bearer token until its `exp` (at most 900 s after
|
|
163
|
+
* `iat`); deliver it like `userId` (authenticated, `no-store`). The SDK never computes it and
|
|
164
|
+
* never sends one that is malformed or expired. When it verifies, the collector takes the user,
|
|
165
|
+
* profile and entitlements from it (entitlement-gated guides are served only with it).
|
|
166
|
+
*/
|
|
167
|
+
claims?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Refresh callback for {@link claims} (contract §15): the SDK calls it for a fresh token when the
|
|
170
|
+
* current one is missing or has 60 s or less left, and after {@link JourneezeHandleV1.reset}
|
|
171
|
+
* (a token for one profile is never used after a switch). A token's life is `exp − iat` from when
|
|
172
|
+
* the page first saw it (the page's clock may be wrong). One call at a time, at most one per 15 s
|
|
173
|
+
* while the current token still works; feedback and telemetry sends never wait for it. A
|
|
174
|
+
* rejection or a malformed result warns once and is never sent.
|
|
175
|
+
*/
|
|
176
|
+
getToken?: () => Promise<string>;
|
|
158
177
|
/**
|
|
159
178
|
* A CSP nonce set on every `<style>` the SDK injects (in its shadow roots), so hosts with
|
|
160
179
|
* `style-src 'nonce-…'` need no `'unsafe-inline'`.
|
|
@@ -290,6 +309,8 @@ export interface SubmitFeedbackRequest {
|
|
|
290
309
|
* the optional "so you can…" answer and the job it follows ("Not possible here").
|
|
291
310
|
*/
|
|
292
311
|
jobRequest?: WireJobRequest;
|
|
312
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
313
|
+
claims?: string;
|
|
293
314
|
}
|
|
294
315
|
/** `JobRequest` (engagement.proto): never telemetry, only ever inside a consented request. */
|
|
295
316
|
export interface WireJobRequest {
|
|
@@ -345,10 +366,14 @@ export interface CreateScreenshotUploadRequest {
|
|
|
345
366
|
userIdExp?: number;
|
|
346
367
|
/** Signed host identity (C0a §4 v1.3, collector.proto `user_id_sig = 8`). */
|
|
347
368
|
userIdSig?: string;
|
|
369
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
370
|
+
claims?: string;
|
|
348
371
|
}
|
|
349
372
|
/** `GetHelpIndex` (collector.proto): the site's published guides. Read-only, no consent needed. */
|
|
350
373
|
export interface GetHelpIndexRequest {
|
|
351
374
|
siteKey: string;
|
|
375
|
+
/** Signed claims v2 (contract §15): entitlement-gated guides are listed only with it. */
|
|
376
|
+
claims?: string;
|
|
352
377
|
}
|
|
353
378
|
export interface HelpIndexEntry {
|
|
354
379
|
journeyId?: string;
|
|
@@ -386,6 +411,11 @@ export interface GetHelpIndexResponse {
|
|
|
386
411
|
version?: string;
|
|
387
412
|
/** The project's approved jobs, in catalog order (P4e1). */
|
|
388
413
|
jobs?: HelpJobEntry[];
|
|
414
|
+
/**
|
|
415
|
+
* Signed claims v2 (contract §15): the verified `profile.kind`, empty without a verified token.
|
|
416
|
+
* Help picks persona guides for it over the page's unsigned `context.persona`.
|
|
417
|
+
*/
|
|
418
|
+
persona?: string;
|
|
389
419
|
}
|
|
390
420
|
/**
|
|
391
421
|
* `RouteIntent` (collector.proto, P6d): the reader's words in help's "Something else", matched to
|
|
@@ -397,6 +427,8 @@ export interface RouteIntentRequest {
|
|
|
397
427
|
/** Trimmed, 1..=500 characters. */
|
|
398
428
|
text: string;
|
|
399
429
|
reviewerToken?: string;
|
|
430
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
431
|
+
claims?: string;
|
|
400
432
|
}
|
|
401
433
|
/** A routed job and its guide for any persona, or empty fields: nothing routed. Never text. */
|
|
402
434
|
export interface RouteIntentResponse {
|
|
@@ -407,6 +439,8 @@ export interface RouteIntentResponse {
|
|
|
407
439
|
export interface GetGuideRequest {
|
|
408
440
|
siteKey: string;
|
|
409
441
|
journeyId: string;
|
|
442
|
+
/** Signed claims v2 (contract §15): an entitlement-gated guide is served only with it. */
|
|
443
|
+
claims?: string;
|
|
410
444
|
}
|
|
411
445
|
export interface GuideStep {
|
|
412
446
|
index?: number;
|
|
@@ -16,8 +16,14 @@ export interface FeedbackChannelHooks {
|
|
|
16
16
|
* help (ADR 0013 §3). Unsent items are then lost when the page goes away.
|
|
17
17
|
*/
|
|
18
18
|
memoryOnly?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Signed claims v2 (contract §15): refreshes the token for later sends. A send never waits for
|
|
21
|
+
* it (sends are keepalive and may run while the page unloads): it carries the current token
|
|
22
|
+
* while it is usable, else none. The token is never stored.
|
|
23
|
+
*/
|
|
24
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
19
25
|
}
|
|
20
|
-
type ChannelOptions = JourneezeOptions & Partial<Pick<MountOptions, "userId" | "pagePath" | "apiHost" | "apiPath">>;
|
|
26
|
+
type ChannelOptions = JourneezeOptions & Partial<Pick<MountOptions, "userId" | "pagePath" | "apiHost" | "apiPath" | "claims">>;
|
|
21
27
|
/**
|
|
22
28
|
* Whose outbox items these are (contract §9, v1.1): the reviewer token on reviewer sites, else the
|
|
23
29
|
* signed-in user, else anonymous. A page claims only its own owner's items.
|
|
@@ -9,6 +9,7 @@ export declare function uploadTarget(uploadUrl: string, endpoint: string): strin
|
|
|
9
9
|
/**
|
|
10
10
|
* Reserves and PUTs one masked image; resolves its `screenshotId`, or `undefined` when the bytes
|
|
11
11
|
* were refused. A failed reservation rejects with the collector's error (the caller decides
|
|
12
|
-
* whether uploads are unavailable). Call only after consent.
|
|
12
|
+
* whether uploads are unavailable). Call only after consent. `claims`: the signed claims v2 token
|
|
13
|
+
* to send (contract §15), already checked by the caller's claims source.
|
|
13
14
|
*/
|
|
14
|
-
export declare function putScreenshot(endpoint: string, options: MountOptions, blob: Blob, fetchImpl?: typeof fetch): Promise<string | undefined>;
|
|
15
|
+
export declare function putScreenshot(endpoint: string, options: MountOptions, blob: Blob, fetchImpl?: typeof fetch, claims?: string): Promise<string | undefined>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as Te}from"./loader-DHgG5Y7t.js";import{k as Ae,c as Ne,w as ke}from"./consent-bPengyOI.js";const xe=new Set(["cc-number","cc-csc","cc-exp","cc-exp-month","cc-exp-year"]),Re=new Set(["current-password","new-password"]),_e=/\b(?:password|passcode|ssn|social security(?: number)?|card number|cvc|cvv|iban|api key|secret|token)\b/,F=512,De=/(?:^|[^A-Za-z0-9_-])(?:sk-[A-Za-z0-9_-]{16,}|sk_(?:live|test)_[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{36}|xox[bp]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+)/,Ie=/(?:\d[ -]?){12,18}\d/g,Pe=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/;function Fe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[_.\-:[\]]+/g," ").toLowerCase()}const U=e=>!!e&&_e.test(Fe(e));function Le(e){const t=e.getAttribute("autocomplete");if(t)for(const r of t.trim().toLowerCase().split(/\s+/)){if(xe.has(r))return"autocomplete_cc";if(r==="one-time-code")return"autocomplete_otp";if(Re.has(r))return"autocomplete_password"}}function $e(e){const t=[],r=e.getAttribute("aria-label");r&&t.push(r);const n=e.ownerDocument;for(const o of(e.getAttribute("aria-labelledby")??"").split(/\s+/)){const a=o?n?.getElementById(o)?.textContent:void 0;a&&t.push(a.slice(0,F))}const s=e.labels;if(s)for(const o of Array.from(s))t.push((o.textContent??"").slice(0,F));return t}function Me(e){let t="";for(const r of Array.from(e.childNodes))if(r.nodeType===3&&(t+=r.data),t.length>=F)break;return t.slice(0,F)}function Oe(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(e.length-1-r)-48;r%2===1&&(n*=2,n>9&&(n-=9)),t+=n}return t%10===0}function Ue(e){for(const t of e.matchAll(Ie)){const r=t[0].replace(/[ -]/g,"");if(r.length>=13&&r.length<=19&&Oe(r))return true}return false}function B(e){if(/^(?:style|script)$/i.test(e.tagName))return;const t=Le(e);if(t)return t;if(e.tagName==="INPUT"&&(e.getAttribute("type")??"").trim().toLowerCase()==="password")return"input_password";if(U(e.getAttribute("name"))||U(e.id))return"name_sensitive";if($e(e).some(U))return"label_sensitive";const r=Me(e);if(r.trim()!==""){if(De.test(r))return"value_key_shaped";if(Ue(r))return"value_card_shaped";if(Pe.test(r))return"value_email_shaped"}}function Be(e){const t=e.getAttribute("data-tflow-id");if(t)return`[data-tflow-id="${X(t)}"]`;const r=e.getAttribute("data-testid");if(r)return`[data-testid="${X(r)}"]`;const n=[];for(let s=e;s&&n.length<6;s=s.parentElement){const o=s.tagName.toLowerCase();if(o==="html"||o==="body")break;const a=s.parentElement,i=a?Array.from(a.children).filter(l=>l.tagName===s.tagName).indexOf(s)+1:1;n.unshift(`${o}:nth-of-type(${i})`)}return n.join(" > ")||e.tagName.toLowerCase()}function X(e){return e.replace(/["\\]/g,"\\$&").slice(0,96)}function gr(e,t=()=>false){const r=[],n=s=>{if(t(s))return;const o=B(s);if(o){r.push({rule:o,selector:Be(s)});return}for(const a of Array.from(s.children))n(a)};for(const s of Array.from(e.children))n(s);return r}const ne="[modern-screenshot]",N=typeof window<"u",ze=N&&"Worker"in window,j=N?window.navigator?.userAgent:"",oe=j.includes("Chrome"),L=j.includes("AppleWebKit")&&!oe,V=j.includes("Firefox"),We=e=>e&&"__CONTEXT__"in e,je=e=>e.constructor.name==="CSSFontFaceRule",Ve=e=>e.constructor.name==="CSSImportRule",qe=e=>e.constructor.name==="CSSLayerBlockRule",E=e=>e.nodeType===1,I=e=>typeof e.className=="object",se=e=>e.tagName==="image",He=e=>e.tagName==="use",R=e=>E(e)&&typeof e.style<"u"&&!I(e),Xe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,k=e=>e.tagName==="IMG",$=e=>e.tagName==="VIDEO",Ge=e=>e.tagName==="CANVAS",Ke=e=>e.tagName==="TEXTAREA",Ye=e=>e.tagName==="INPUT",Je=e=>e.tagName==="STYLE",Qe=e=>e.tagName==="SCRIPT",et=e=>e.tagName==="SELECT",tt=e=>e.tagName==="SLOT",rt=e=>e.tagName==="IFRAME",nt=(...e)=>console.warn(ne,...e);function ot(e){const t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}const z=e=>e.startsWith("data:");function ie(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;const r=M().implementation.createHTMLDocument(),n=r.createElement("base"),s=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(s),t&&(n.href=t),s.href=e,s.href}function M(e){return(e&&E(e)?e?.ownerDocument:e)??window.document}const O="http://www.w3.org/2000/svg";function st(e,t,r){const n=M(r).createElementNS(O,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function it(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function at(e,t){return new Promise((r,n)=>{const s=new FileReader;s.onload=()=>r(s.result),s.onerror=()=>n(s.error),s.onabort=()=>n(new Error(`Failed read blob to ${t}`)),s.readAsDataURL(e)})}const ct=e=>at(e,"dataUrl");function A(e,t){const r=M(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function _(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:s,onError:o,onWarn:a}=t??{},i=typeof e=="string"?A(e,M(s)):e;let l=null,m=null;function c(){r(i),l&&clearTimeout(l),m?.()}if(n&&(l=setTimeout(c,n)),$(i)){const g=i.currentSrc||i.src;if(!g)return i.poster?_(i.poster,t).then(r):c();if(i.readyState>=2)return c();const h=c,f=d=>{a?.("Failed video load",g,d),o?.(d),c()};m=()=>{i.removeEventListener("loadeddata",h),i.removeEventListener("error",f)},i.addEventListener("loadeddata",h,{once:true}),i.addEventListener("error",f,{once:true})}else{const g=se(i)?i.href.baseVal:i.currentSrc||i.src;if(!g)return c();const h=async()=>{if(k(i)&&"decode"in i)try{await i.decode()}catch(d){a?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||g,d)}c()},f=d=>{a?.("Failed image load",i.dataset.originalSrc||g,d),c()};if(k(i)&&i.complete)return h();m=()=>{i.removeEventListener("load",h),i.removeEventListener("error",f)},i.addEventListener("load",h,{once:true}),i.addEventListener("error",f,{once:true})}})}async function lt(e,t){R(e)&&(k(e)||$(e)?await _(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>_(n,t)))))}const ae=(function(){let t=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)})();function ce(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Z=0;function ut(e){const t=`${ne}[#${Z}]`;return Z++,{time:r=>e&&console.time(`${t} ${r}`),timeEnd:r=>e&&console.timeEnd(`${t} ${r}`),warn:(...r)=>e&&nt(...r)}}function ft(e){return{cache:e?"no-cache":"force-cache"}}async function le(e,t){return We(e)?e:dt(e,{...t,autoDestruct:true})}async function dt(e,t){const{scale:r=1,workerUrl:n,workerNumber:s=1}=t||{},o=!!t?.debug,a=t?.features??true,i=e.ownerDocument??(N?window.document:void 0),l=e.ownerDocument?.defaultView??(N?window:void 0),m=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:ft(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:ut(o),node:e,ownerDocument:i,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ue(i),svgDefsElement:i?.createElementNS(O,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ze&&n&&s?s:0})].map(()=>{try{const f=new Worker(n);return f.onmessage=async d=>{const{url:u,result:p}=d.data;p?m.get(u)?.resolve?.(p):m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f.onmessageerror=d=>{const{url:u}=d.data;m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f}catch(f){return c.log.warn("Failed to new Worker",f),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[ot(i)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:m,drawImageCount:0,tasks:[],features:a,isEnable:f=>f==="restoreScrollPosition"?typeof a=="boolean"?false:a[f]??false:typeof a=="boolean"?a:a[f]??true,shadowRoots:[]};c.log.time("wait until load"),await lt(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");const{width:g,height:h}=mt(e,c);return c.width=g,c.height=h,c}function ue(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
|
|
2
2
|
.______background-clip--text {
|
|
3
3
|
background-clip: text;
|
|
4
4
|
-webkit-background-clip: text;
|
|
5
5
|
}
|
|
6
|
-
`);return t.appendChild(r),t}function mt(e,t){let{width:r,height:n}=t;if(E(e)&&(!r||!n)){const s=e.getBoundingClientRect();r=r||s.width||Number(e.getAttribute("width"))||0,n=n||s.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}async function gt(e,t){const{log:r,timeout:n,drawImageCount:s,drawImageInterval:o}=t;r.time("image to canvas");const a=await _(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:l}=ht(e.ownerDocument,t),m=()=>{try{l?.drawImage(a,0,0,i.width,i.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(m(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<s;c++)await new Promise(
|
|
7
|
-
`);let y=i.get(w);y||(y=[],i.set(w,y)),y.push(`.${f[0]}${c}`)}At.forEach(m),r&&Nt.forEach(m)}const
|
|
8
|
-
`))}else{const l=Array.from(r.styleSheets).filter(f=>{try{return"cssRules"in f&&!!f.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${f.href}`,d),false}}),m=r.implementation.createHTMLDocument(""),c=m.createElement("style");m.head.appendChild(c);const
|
|
6
|
+
`);return t.appendChild(r),t}function mt(e,t){let{width:r,height:n}=t;if(E(e)&&(!r||!n)){const s=e.getBoundingClientRect();r=r||s.width||Number(e.getAttribute("width"))||0,n=n||s.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}async function gt(e,t){const{log:r,timeout:n,drawImageCount:s,drawImageInterval:o}=t;r.time("image to canvas");const a=await _(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:l}=ht(e.ownerDocument,t),m=()=>{try{l?.drawImage(a,0,0,i.width,i.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(m(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<s;c++)await new Promise(g=>{setTimeout(()=>{l?.clearRect(0,0,i.width,i.height),m(),g()},c+o)});return t.drawImageCount=0,r.timeEnd("image to canvas"),i}function ht(e,t){const{width:r,height:n,scale:s,backgroundColor:o,maximumCanvasSize:a}=t,i=e.createElement("canvas");i.width=Math.floor(r*s),i.height=Math.floor(n*s),i.style.width=`${r}px`,i.style.height=`${n}px`,a&&(i.width>a||i.height>a)&&(i.width>a&&i.height>a?i.width>i.height?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a):i.width>a?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a));const l=i.getContext("2d");return l&&o&&(l.fillStyle=o,l.fillRect(0,0,i.width,i.height)),{canvas:i,context2d:l}}function fe(e,t){if(e.ownerDocument)try{const o=e.toDataURL();if(o!=="data:,")return A(o,e.ownerDocument)}catch(o){t.log.warn("Failed to clone canvas",o)}const r=e.cloneNode(false),n=e.getContext("2d"),s=r.getContext("2d");try{return n&&s&&s.putImageData(n.getImageData(0,0,e.width,e.height),0,0),r}catch(o){t.log.warn("Failed to clone canvas",o)}return r}function pt(e,t){try{if(e?.contentDocument?.documentElement)return q(e.contentDocument.documentElement,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(false)}function wt(e){const t=e.cloneNode(false);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function yt(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return A(e.poster,e.ownerDocument);const r=e.cloneNode(false);r.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(r.src=e.currentSrc);const n=r.ownerDocument;if(n){let s=true;if(await _(r,{onError:()=>s=false,onWarn:t.log.warn}),!s)return e.poster?A(e.poster,e.ownerDocument):r;r.currentTime=e.currentTime,await new Promise(a=>{r.addEventListener("seeked",a,{once:true})});const o=n.createElement("canvas");o.width=e.offsetWidth,o.height=e.offsetHeight;try{const a=o.getContext("2d");a&&a.drawImage(r,0,0,o.width,o.height)}catch(a){return t.log.warn("Failed to clone video",a),e.poster?A(e.poster,e.ownerDocument):r}return fe(o,t)}return r}function bt(e,t){return Ge(e)?fe(e,t):rt(e)?pt(e,t):k(e)?wt(e):$(e)?yt(e,t):e.cloneNode(false)}function St(e){let t=e.sandbox;if(!t){const{ownerDocument:r}=e;try{r&&(t=r.createElement("iframe"),t.id=`__SANDBOX__${ae()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(n){e.log.warn("Failed to getSandBox",n)}}return t}const Et=["width","height","-webkit-text-fill-color"],vt=["stroke","fill"];function de(e,t,r){const{defaultComputedStyles:n}=r,s=e.nodeName.toLowerCase(),o=I(e)&&s!=="svg",a=o?vt.map(u=>[u,e.getAttribute(u)]).filter(([,u])=>u!==null):[],i=[o&&"svg",s,a.map((u,p)=>`${u}=${p}`).join(","),t].filter(Boolean).join(":");if(n.has(i))return n.get(i);const m=St(r)?.contentWindow;if(!m)return new Map;const c=m?.document;let g,h;o?(g=c.createElementNS(O,"svg"),h=g.ownerDocument.createElementNS(g.namespaceURI,s),a.forEach(([u,p])=>{h.setAttributeNS(null,u,p)}),g.appendChild(h)):g=h=c.createElement(s),h.textContent=" ",c.body.appendChild(g);const f=m.getComputedStyle(h,t),d=new Map;for(let u=f.length,p=0;p<u;p++){const w=f.item(p);Et.includes(w)||d.set(w,f.getPropertyValue(w))}return c.body.removeChild(g),n.set(i,d),d}function me(e,t,r){const n=new Map,s=[],o=new Map;if(r)for(const i of r)a(i);else for(let i=e.length,l=0;l<i;l++){const m=e.item(l);a(m)}for(let i=s.length,l=0;l<i;l++)o.get(s[l])?.forEach((m,c)=>n.set(c,m));function a(i){const l=e.getPropertyValue(i),m=e.getPropertyPriority(i),c=i.lastIndexOf("-"),g=c>-1?i.substring(0,c):void 0;if(g){let h=o.get(g);h||(h=new Map,o.set(g,h)),h.set(i,[l,m])}t.get(i)===l&&!m||(g?s.push(g):n.set(i,[l,m]))}return n}function Ct(e,t,r,n){const{ownerWindow:s,includeStyleProperties:o,currentParentNodeStyle:a}=n,i=t.style,l=s.getComputedStyle(e),m=de(e,null,n);a?.forEach((g,h)=>{m.delete(h)});const c=me(l,m,o);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),r&&(c.delete("position"),c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),c.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),oe&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(c.get("overflow-x")?.[0]==="hidden"||c.get("overflow-y")?.[0]==="hidden")&&c.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let g=i.length,h=0;h<g;h++)i.removeProperty(i.item(h));return c.forEach(([g,h],f)=>{i.setProperty(f,g,h)}),c}function Tt(e,t){(Ke(e)||Ye(e)||et(e))&&t.setAttribute("value",e.value)}const At=["::before","::after"],Nt=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function kt(e,t,r,n,s){const{ownerWindow:o,svgStyleElement:a,svgStyles:i,currentNodeStyle:l}=n;if(!a||!o)return;function m(c){const g=o.getComputedStyle(e,c);let h=g.getPropertyValue("content");if(!h||h==="none")return;s?.(h),h=h.replace(/(')|(")|(counter\(.+\))/g,"");const f=[ae()],d=de(e,c,n);l?.forEach((b,S)=>{d.delete(S)});const u=me(g,d,n.includeStyleProperties);u.delete("content"),u.delete("-webkit-locale"),u.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");const p=[`content: '${h}';`];if(u.forEach(([b,S],C)=>{p.push(`${C}: ${b}${S?" !important":""};`)}),p.length===1)return;try{t.className=[t.className,...f].join(" ")}catch(b){n.log.warn("Failed to copyPseudoClass",b);return}const w=p.join(`
|
|
7
|
+
`);let y=i.get(w);y||(y=[],i.set(w,y)),y.push(`.${f[0]}${c}`)}At.forEach(m),r&&Nt.forEach(m)}const G=new Set(["symbol"]);async function K(e,t,r,n,s){if(E(r)&&(Je(r)||Qe(r))||n.filter&&!n.filter(r))return;G.has(t.nodeName)||G.has(r.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;const o=await q(r,n,false,s);n.isEnable("restoreScrollPosition")&&xt(e,o),t.appendChild(o)}async function Y(e,t,r,n){let s=e.firstChild;E(e)&&e.shadowRoot&&(s=e.shadowRoot?.firstChild,r.shadowRoots.push(e.shadowRoot));for(let o=s;o;o=o.nextSibling)if(!Xe(o))if(E(o)&&tt(o)&&typeof o.assignedNodes=="function"){const a=o.assignedNodes();for(let i=0;i<a.length;i++)await K(e,t,a[i],r,n)}else await K(e,t,o,r,n)}function xt(e,t){if(!R(e)||!R(t))return;const{scrollTop:r,scrollLeft:n}=e;if(!r&&!n)return;const{transform:s}=t.style,o=new DOMMatrix(s),{a,b:i,c:l,d:m}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-n,-r),o.a=a,o.b=i,o.c=l,o.d=m,t.style.transform=o.toString()}function Rt(e,t){const{backgroundColor:r,width:n,height:s,style:o}=t,a=e.style;if(r&&a.setProperty("background-color",r,"important"),n&&a.setProperty("width",`${n}px`,"important"),s&&a.setProperty("height",`${s}px`,"important"),o)for(const i in o)a[i]=o[i]}const _t=/^[\w-:]+$/;async function q(e,t,r=false,n){const{ownerDocument:s,ownerWindow:o,fontFamilies:a,onCloneEachNode:i}=t;if(s&&Ze(e))return n&&/\S/.test(e.data)&&n(e.data),s.createTextNode(e.data);if(s&&o&&E(e)&&(R(e)||I(e))){const m=await bt(e,t);if(t.isEnable("removeAbnormalAttributes")){const u=m.getAttributeNames();for(let p=u.length,w=0;w<p;w++){const y=u[w];_t.test(y)||m.removeAttribute(y)}}const c=t.currentNodeStyle=Ct(e,m,r,t);r&&Rt(m,t);let g=false;if(t.isEnable("copyScrollbar")){const u=[c.get("overflow-x")?.[0],c.get("overflow-y")?.[0]];g=u.includes("scroll")||(u.includes("auto")||u.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const h=c.get("text-transform")?.[0],f=ce(c.get("font-family")?.[0]),d=f?u=>{h==="uppercase"?u=u.toUpperCase():h==="lowercase"?u=u.toLowerCase():h==="capitalize"&&(u=u[0].toUpperCase()+u.substring(1)),f.forEach(p=>{let w=a.get(p);w||a.set(p,w=new Set),u.split("").forEach(y=>w.add(y))})}:void 0;return kt(e,m,g,t,d),Tt(e,m),$(e)||await Y(e,m,t,d),await i?.(m),m}const l=e.cloneNode(false);return await Y(e,l,t),await i?.(l),l}function Dt(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function It(e){const{url:t,timeout:r,responseType:n,...s}=e,o=new AbortController,a=r?setTimeout(()=>o.abort(),r):void 0;return fetch(t,{signal:o.signal,...s}).then(i=>{if(!i.ok)throw new Error("Failed fetch, not 2xx response",{cause:i});switch(n){case"arrayBuffer":return i.arrayBuffer();case"dataUrl":return i.blob().then(ct);default:return i.text()}}).finally(()=>clearTimeout(a))}function D(e,t){const{url:r,requestType:n="text",responseType:s="text",imageDom:o}=t;let a=r;const{timeout:i,acceptOfImage:l,requests:m,fetchFn:c,fetch:{requestInit:g,bypassingCache:h,placeholderImage:f},font:d,workers:u,fontFamilies:p}=e;n==="image"&&(L||V)&&e.drawImageCount++;let w=m.get(r);if(!w){h&&h instanceof RegExp&&h.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());const y=n.startsWith("font")&&d&&d.minify,b=new Set;y&&n.split(";")[1].split(",").forEach(P=>{p.has(P)&&p.get(P).forEach(H=>b.add(H))});const S=y&&b.size,C={url:a,timeout:i,responseType:S?"arrayBuffer":s,headers:n==="image"?{accept:l}:void 0,...g};w={type:n,resolve:void 0,reject:void 0,response:null},w.response=(async()=>{if(c&&n==="image"){const v=await c(r);if(v)return v}return!L&&r.startsWith("http")&&u.length?new Promise((v,P)=>{u[m.size&u.length-1].postMessage({rawUrl:r,...C}),w.resolve=v,w.reject=P}):It(C)})().catch(v=>{if(m.delete(r),n==="image"&&f)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",a),typeof f=="string"?f:f(o);throw v}),m.set(r,w)}return w.response}async function ge(e,t,r,n){if(!he(e))return e;for(const[s,o]of Pt(e,t))try{const a=await D(r,{url:o,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(Ft(s),`$1${a}$3`)}catch(a){r.log.warn("Failed to fetch css data url",s,a)}return e}function he(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const pe=/url\((['"]?)([^'"]+?)\1\)/g;function Pt(e,t){const r=[];return e.replace(pe,(n,s,o)=>(r.push([o,ie(o,t)]),n)),r.filter(([n])=>!z(n))}function Ft(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const Lt=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function $t(e,t){return Lt.map(r=>{const n=e.getPropertyValue(r);return!n||n==="none"?null:((L||V)&&t.drawImageCount++,ge(n,null,t,true).then(s=>{!s||n===s||e.setProperty(r,s,e.getPropertyPriority(r))}))}).filter(Boolean)}function Mt(e,t){if(k(e)){const r=e.currentSrc||e.src;if(!z(r))return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.srcset="",e.dataset.originalSrc=r,e.src=n||"")})];(L||V)&&t.drawImageCount++}else if(I(e)&&!z(e.href.baseVal)){const r=e.href.baseVal;return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.dataset.originalSrc=r,e.href.baseVal=n||"")})]}return[]}function Ot(e,t){const{ownerDocument:r,svgDefsElement:n}=t,s=e.getAttribute("href")??e.getAttribute("xlink:href");if(!s)return[];const[o,a]=s.split("#");if(a){const i=`#${a}`,l=t.shadowRoots.reduce((m,c)=>m??c.querySelector(`svg ${i}`),r?.querySelector(`svg ${i}`));if(o&&e.setAttribute("href",i),n?.querySelector(i))return[];if(l)return n?.appendChild(l.cloneNode(true)),[];if(o)return[D(t,{url:o,responseType:"text"}).then(m=>{n?.insertAdjacentHTML("beforeend",m)})]}return[]}function we(e,t){const{tasks:r}=t;E(e)&&((k(e)||se(e))&&r.push(...Mt(e,t)),He(e)&&r.push(...Ot(e,t))),R(e)&&r.push(...$t(e.style,t)),e.childNodes.forEach(n=>{we(n,t)})}async function Ut(e,t){const{ownerDocument:r,svgStyleElement:n,fontFamilies:s,fontCssTexts:o,tasks:a,font:i}=t;if(!(!r||!n||!s.size))if(i&&i.cssText){const l=Q(i.cssText,t);n.appendChild(r.createTextNode(`${l}
|
|
8
|
+
`))}else{const l=Array.from(r.styleSheets).filter(f=>{try{return"cssRules"in f&&!!f.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${f.href}`,d),false}}),m=r.implementation.createHTMLDocument(""),c=m.createElement("style");m.head.appendChild(c);const g=c.sheet;await Promise.all(l.flatMap(f=>Array.from(f.cssRules).map(async d=>{if(Ve(d)){const u=d.href;let p="";try{p=await D(t,{url:u,requestType:"text",responseType:"text"})}catch(y){t.log.warn(`Error fetch remote css import from ${u}`,y)}const w=p.replace(pe,(y,b,S)=>y.replace(S,ie(S,u)));for(const y of zt(w))try{g.insertRule(y,g.cssRules.length)}catch(b){t.log.warn("Error inserting rule from remote css import",{rule:y,error:b})}}}))),g.cssRules.length&&l.push(g);const h=[];l.forEach(f=>{W(f.cssRules,h)}),h.filter(f=>je(f)&&he(f.style.getPropertyValue("src"))&&ce(f.style.getPropertyValue("font-family"))?.some(d=>s.has(d))).forEach(f=>{const d=f,u=o.get(d.cssText);u?n.appendChild(r.createTextNode(`${u}
|
|
9
9
|
`)):a.push(ge(d.cssText,d.parentStyleSheet?d.parentStyleSheet.href:null,t).then(p=>{p=Q(p,t),o.set(d.cssText,p),n.appendChild(r.createTextNode(`${p}
|
|
10
|
-
`))}))})}}const Bt=/(\/\*[\s\S]*?\*\/)/g,J=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function zt(e){if(e==null)return[];const t=[];let r=e.replace(Bt,"");for(;;){const o=J.exec(r);if(!o)break;t.push(o[0])}r=r.replace(J,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=n.exec(r);if(o)s.lastIndex=n.lastIndex;else if(o=s.exec(r),o)n.lastIndex=s.lastIndex;else break;t.push(o[0])}return t}const Wt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Q(e,t){const{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(jt,s=>{for(;;){const[o,,a]=Wt.exec(s)||[];if(!a)return"";if(a===n)return`src: ${o};`}}):e}function W(e,t=[]){for(const r of Array.from(e))qe(r)?t.push(...W(r.cssRules)):"cssRules"in r?W(r.cssRules,t):t.push(r);return t}const Vt=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function qt(e){return Vt.test(e.innerHTML)}async function ye(e,t){const r=await le(e,t);if(E(r.node)&&I(r.node)&&!qt(r.node))return r.node;const{ownerDocument:n,log:s,tasks:o,svgStyleElement:a,svgDefsElement:i,svgStyles:l,font:m,progress:c,autoDestruct:
|
|
10
|
+
`))}))})}}const Bt=/(\/\*[\s\S]*?\*\/)/g,J=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function zt(e){if(e==null)return[];const t=[];let r=e.replace(Bt,"");for(;;){const o=J.exec(r);if(!o)break;t.push(o[0])}r=r.replace(J,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=n.exec(r);if(o)s.lastIndex=n.lastIndex;else if(o=s.exec(r),o)n.lastIndex=s.lastIndex;else break;t.push(o[0])}return t}const Wt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Q(e,t){const{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(jt,s=>{for(;;){const[o,,a]=Wt.exec(s)||[];if(!a)return"";if(a===n)return`src: ${o};`}}):e}function W(e,t=[]){for(const r of Array.from(e))qe(r)?t.push(...W(r.cssRules)):"cssRules"in r?W(r.cssRules,t):t.push(r);return t}const Vt=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function qt(e){return Vt.test(e.innerHTML)}async function ye(e,t){const r=await le(e,t);if(E(r.node)&&I(r.node)&&!qt(r.node))return r.node;const{ownerDocument:n,log:s,tasks:o,svgStyleElement:a,svgDefsElement:i,svgStyles:l,font:m,progress:c,autoDestruct:g,onCloneNode:h,onEmbedNode:f,onCreateForeignObjectSvg:d}=r;s.time("clone node");const u=await q(r.node,r,true);if(a&&n){let S="";l.forEach((C,v)=>{S+=`${C.join(`,
|
|
11
11
|
`)} {
|
|
12
12
|
${v}
|
|
13
13
|
}
|
|
14
|
-
`}),a.appendChild(n.createTextNode(S))}s.timeEnd("clone node"),await
|
|
14
|
+
`}),a.appendChild(n.createTextNode(S))}s.timeEnd("clone node"),await h?.(u),m!==false&&E(u)&&(s.time("embed web font"),await Ut(u,r),s.timeEnd("embed web font")),s.time("embed node"),we(u,r);const p=o.length;let w=0;const y=async()=>{for(;;){const S=o.pop();if(!S)break;try{await S}catch(C){r.log.warn("Failed to run task",C)}c?.(++w,p)}};c?.(w,p),await Promise.all([...Array.from({length:4})].map(y)),s.timeEnd("embed node"),await f?.(u);const b=Ht(u,r);return i&&b.insertBefore(i,b.children[0]),a&&b.insertBefore(a,b.children[0]),g&&Dt(r),await d?.(b),b}function Ht(e,t){const{width:r,height:n}=t,s=st(r,n,e.ownerDocument),o=s.ownerDocument.createElementNS(s.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(e),s.appendChild(o),s}async function Xt(e,t){const r=await le(e,t),n=await ye(r),s=it(n,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ue(r.ownerDocument),r.svgDefsElement=r.ownerDocument?.createElementNS(O,"defs"),r.svgStyles.clear());const o=A(s,n.ownerDocument);return await gt(o,r)}const Zt="iframe, frame, object, embed, video, audio, canvas",Gt=e=>Te(e)||e.matches(Zt),Kt="[data-journeeze], [data-journeeze-chat]",Yt="[data-jz-block]",Jt=2*1024*1024,Qt=1600;class be extends Error{}const T=1,x=3,er=8;function Se(e,t={}){const r=[e],n=new Map,s=ir([...t.maskSelectors??[],...t.configMaskSelectors??[]]),o={},a=t.maskAllText===true,i=f=>Gt(f)||s.some(d=>{try{return f.matches(d)}catch{return true}});let l;const m=f=>{if(f.nodeType===T){const d=f;if(d.matches(Kt))return n.set(d,"drop"),false;if(d.matches(Yt))return n.set(d,"empty"),false;if(sr(d)||i(d))return n.set(d,"replace"),false;const u=B(d);if(u)return o[u]=(o[u]??0)+1,n.set(d,"replace"),false}return f.nodeType!==x&&r.push(f),true},c=f=>{const d=r.pop();if(!d||d.nodeName!==f.nodeName){l??(l="clone order mismatch");return}d.nodeType===T&&f.nodeType===T&&g(d,f)};function g(f,d){const u=Array.from(d.childNodes),p=d.ownerDocument??document;let w=0;for(const y of tr(f)){const b=n.get(y);if(b==="drop")continue;if(b==="replace"){d.insertBefore(nr(y,p),u[w]??null);continue}if(b==="empty"){d.insertBefore(or(y,p),u[w]??null);continue}const S=u[w];if(S===void 0){l??(l="missing clone child");return}w++,a&&y.nodeType===x&&S.nodeType===x&&y.data.trim()!==""&&d.replaceChild(ar(y,p),S)}w!==u.length&&(l??(l="unexpected clone child"))}return{filter:m,onCloneEachNode:c,onCloneNode:f=>{if(r.length!==0&&(l??(l="unbalanced clone traversal")),f.nodeType===T){const d=[f,...Array.from(f.querySelectorAll("*"))];d.some(u=>i(u)||B(u)!==void 0)&&(l??(l="maskable element in clone")),a&&d.some(ve)&&(l??(l="text in clone"))}if(l!==void 0)throw new be(l)},failure:()=>l,detectorCounts:()=>({...o})}}function tr(e){const t=[],r=e.shadowRoot?Array.from(e.shadowRoot.childNodes):Array.from(e.childNodes);for(const n of r)if(n.nodeType!==er){if(n.nodeType===T&&n.tagName==="SLOT"&&typeof n.assignedNodes=="function"){for(const s of n.assignedNodes())ee(s)||t.push(s);continue}ee(n)||t.push(n)}return t}function ee(e){return e.nodeType===T&&(e.tagName==="STYLE"||e.tagName==="SCRIPT")}const rr=["position","top","right","bottom","left","float","clear","z-index","margin-top","margin-right","margin-bottom","margin-left","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","grid-row-start","grid-row-end","grid-column-start","grid-column-end","vertical-align","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","transform","visibility"];function nr(e,t){return Ee(e,t,true)}function or(e,t){return Ee(e,t,false)}function Ee(e,t,r){const s=e.ownerDocument.defaultView?.getComputedStyle(e),o=e.getBoundingClientRect(),a=e instanceof HTMLElement?e.offsetWidth:o.width,i=e instanceof HTMLElement?e.offsetHeight:o.height,l=s?.display??"block",m=t.createElement(l.startsWith("inline")?"span":"div"),c=m.style;for(const g of rr){const h=s?.getPropertyValue(g);h&&c.setProperty(g,h)}return c.setProperty("display",l==="none"?"none":l==="inline"||l.startsWith("inline")?"inline-block":"block"),c.setProperty("box-sizing","border-box"),c.setProperty("width",`${a}px`),c.setProperty("height",`${i}px`),c.setProperty("border",r?"1px dashed #8A9099":"0"),c.setProperty("background",r?"repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)":"transparent"),m.setAttribute(r?"data-jz-masked-placeholder":"data-jz-block-placeholder",""),m}function sr(e){if(!e.tagName.toLowerCase().includes("-")||e.shadowRoot)return false;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return false;for(const r of Array.from(e.childNodes))if(r.nodeType===T||r.nodeType===x&&r.data.trim()!=="")return false;return true}function ir(e){for(const t of e??[])try{document.createDocumentFragment().querySelector(t)}catch{throw te||console.warn("[journeeze] invalid maskSelectors entry: screenshots are off"),te=true,new be("invalid maskSelectors")}return[...e??[]]}let te=false;function ve(e){for(const t of Array.from(e.childNodes))if(t.nodeType===x&&t.data.trim()!==""||t.nodeType===T&&ve(t))return true;return false}function ar(e,t){const r=t.createRange();r.selectNodeContents(e);const n=r.getBoundingClientRect(),s=t.createElement("span"),o=s.style;return o.setProperty("display","inline-block"),o.setProperty("width",`${n.width}px`),o.setProperty("height",`${n.height}px`),o.setProperty("background","repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)"),s.setAttribute("data-jz-masked-placeholder",""),s}function re(e,t){const r=parseFloat(e.ownerDocument.defaultView?.getComputedStyle(e).getPropertyValue(t)??"0");return Number.isFinite(r)?r:0}function Ce(e,t,r,n){const s=e.ownerDocument.defaultView??window;return{width:s.innerWidth,height:s.innerHeight,scale:r,quality:n,type:"image/webp",timeout:4e3,style:{marginTop:`${re(e,"margin-top")-s.scrollY}px`,marginLeft:`${re(e,"margin-left")-s.scrollX}px`},filter:t.filter,onCloneEachNode:t.onCloneEachNode,onCloneNode:t.onCloneNode}}async function hr(e=document.body,t={}){return(await cr(e,t)).blob}async function cr(e=document.body,t={}){const r=e.ownerDocument.defaultView??window,n=Math.min(r.devicePixelRatio||1,Qt/Math.max(1,r.innerWidth)),s=Se(e,t);let o=await Xt(e,Ce(e,s,n,1));const a=s.detectorCounts();for(const i of[.8,.6,.45]){const l=await lr(o,i);if(!l||l.type!=="image/webp"&&l.type!=="image/png")return{blob:void 0,detectorCounts:a};if(l.size<=Jt)return{blob:l,detectorCounts:a};o=ur(o,.75)}return{blob:void 0,detectorCounts:a}}function lr(e,t){return new Promise(r=>e.toBlob(r,"image/webp",t))}function ur(e,t){const r=e.ownerDocument.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d")?.drawImage(e,0,0,r.width,r.height),r}async function pr(e=document.body,t={}){const r=Se(e,t),n=await ye(e,{...Ce(e,r,1,1),font:false});return new XMLSerializer().serializeToString(n)}function fr(e,t){try{const r=new URL(t.endsWith("/")?t:`${t}/`),n=new URL(e.replace(/^\/+/,""),r);return n.origin===r.origin?n.href:void 0}catch{return}}async function wr(e,t,r,n=(...o)=>fetch(...o),s){if(r.type!=="image/webp"&&r.type!=="image/png")return;const o={siteKey:t.siteKey,contentType:r.type,byteLength:r.size,...t.reviewerToken?{reviewerToken:t.reviewerToken}:{},...t.userId?{userId:t.userId,consentGiven:true,...Ae(t)}:{},...s?{claims:s,consentGiven:true}:{}},a=await Ne(e,"CreateScreenshotUpload",o,n),i=typeof a.uploadUrl=="string"?fr(a.uploadUrl,e):void 0;if(typeof a.screenshotId!="string"||!i)return;const l={"content-type":r.type};for(const[c,g]of Object.entries(a.headers??{}))typeof g=="string"&&(l[c]=g);return(await n(i,ke({method:"PUT",body:r,headers:l,credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer"}))).ok?a.screenshotId:void 0}export{cr as a,hr as c,pr as m,wr as p,gr as s,fr as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var l=(i,e,t)=>e in i?a(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var r=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);import{H as c,a as p}from"./highlight-pU9nE3Qj.js";const g=/^(tflow|testId|role|css)$/,u=".jz-help-highlight{position:fixed;z-index:2147483645;pointer-events:none;box-sizing:border-box;border:2px solid #3D63C9;border-radius:6px;box-shadow:0 0 0 4px rgb(61 99 201/20%)}";function f(i){return[...i.steps??[]].map((e,t)=>({st:e,at:e.index??t})).sort((e,t)=>e.at-t.at).map(({st:e})=>{const t=(e.targets??[]).filter(s=>g.test(s.strategy??"")&&s.value).map(s=>({by:s.strategy,value:s.value,name:s.name||void 0}));return t.length||!e.tflowId?t:[{by:"tflow",value:e.tflowId}]})}class w{constructor(e){r(this,"deps");r(this,"guides",new Map);r(this,"at");r(this,"seq",0);r(this,"shown");this.deps=e}sync(e){const t=e&&`${e.jobId}/${e.step}/${e.of??""}`,s=this.at&&`${this.at.jobId}/${this.at.step}/${this.at.of??""}`;t!==s&&(this.at=e,this.point(false))}refresh(){this.point(true)}stop(){this.at=void 0,this.seq++,this.shown=void 0,this.deps.clearHighlight()}point(e){const t=++this.seq,s=this.at,o=s&&this.deps.journeyFor(s.jobId);if(!s||!o){this.shown=void 0,this.deps.clearHighlight();return}const n=`${o}/${s.step}`;!e&&n===this.shown||this.guide(o).then(h=>{if(t!==this.seq)return;const d=h?.[s.step-1];if(!h||!d||s.of!==void 0&&s.of!==h.length){this.shown=void 0,this.deps.clearHighlight();return}this.shown=n;try{Promise.resolve(this.deps.highlight(d)).catch(()=>{})}catch{}})}guide(e){let t=this.guides.get(e);return t||(t=this.deps.loadGuide(e).then(s=>f(s),()=>{this.guides.delete(e)}),this.guides.set(e,t)),t}}function y(i){const e=document.createElement("style");e.textContent=u,i.nonce&&(e.nonce=i.nonce),i.root.append(e);const t=new c(i.root),s=new p({endpoint:i.endpoint,siteKey:i.siteKey,reviewerToken:i.reviewerToken,claims:i.claims}),o=new w({journeyFor:i.journeyFor,loadGuide:i.loadGuide??(n=>s.guide(n)),highlight:n=>t.show(n),clearHighlight:()=>t.hide()});return{walker:o,dispose(){o.stop(),t.dispose(),e.remove()}}}export{w as GuideWalker,y as createWalk,f as guideTargets};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var $=Object.defineProperty;var N=(d,t,e)=>t in d?$(d,t,{enumerable:true,configurable:true,writable:true,value:e}):d[t]=e;var n=(d,t,e)=>N(d,typeof t!="symbol"?t+"":t,e);import{f as B,s as W,d as K,h as _,g as O,C as M,D as H,i as q,j as Y,k as G}from"./consent-bPengyOI.js";import{i as R}from"./loader-DHgG5Y7t.js";import{c as J,s as V,p as X}from"./upload-KvsGqMEV.js";import{m as St,u as Ft}from"./upload-KvsGqMEV.js";import{s as Z,R as Q}from"./hook-M34sajh9.js";import{d as tt,i as I,e as et,a as ot}from"./anchor-bnZCZtbG.js";import{feedbackChannel as it,widgetConfig as st}from"./feedback-DeMvbZnh.js";import{claimsSource as nt}from"./claims-VKhPNjA7.js";const S="jz:preview",w="mask-audit";function rt(){try{const d=new URL(location.href),t=d.searchParams.get("jz_preview");return t===null?sessionStorage.getItem(S)===w:(d.searchParams.delete("jz_preview"),history.replaceState(history.state,"",d.href),t===w?sessionStorage.setItem(S,w):sessionStorage.removeItem(S),t===w)}catch{return false}}const U='<path d="M9 9h.01"/><path d="M15 9h.01"/>',at={like:`<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/>${U}`,dislike:`<circle cx="12" cy="12" r="10"/><path d="M16 16s-1.5-2-4-2-4 2-4 2"/>${U}`,understood:'<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',confused:'<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',persona:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',step:'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>'};function x(d,t=20){const e=document.createElement("template");return e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${at[d]}</svg>`,e.content.firstElementChild}const ct=`
|
|
2
|
+
:host { all: initial; }
|
|
3
|
+
.jz {
|
|
4
|
+
--jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
|
|
5
|
+
--jz-faint:#8A9099; --jz-rule:rgb(29 32 36 / 12%); --jz-accent:#3D63C9; --jz-accent-ink:#FFFFFF;
|
|
6
|
+
--jz-accent-soft:rgb(61 99 201 / 10%); --jz-polished:#2F7D4F; --jz-broken:#B42318; --jz-confused:#6E4FC2;
|
|
7
|
+
--jz-shadow:0 1px 3px rgb(0 0 0 / 12%);
|
|
8
|
+
font: 400 13px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
9
|
+
color: var(--jz-ink); -webkit-font-smoothing: antialiased;
|
|
10
|
+
}
|
|
11
|
+
@media (prefers-color-scheme: dark) {
|
|
12
|
+
.jz { --jz-canvas:#111316; --jz-surface:#181B1F; --jz-raised:#20242A; --jz-ink:#E8EAED; --jz-muted:#A3A9B2;
|
|
13
|
+
--jz-faint:#6F7680; --jz-rule:rgb(232 234 237 / 12%); --jz-accent:#7F9CF0; --jz-accent-ink:#111316;
|
|
14
|
+
--jz-accent-soft:rgb(127 156 240 / 14%); --jz-confused:#A48BEA; --jz-polished:#5DBB84; }
|
|
15
|
+
}
|
|
16
|
+
.jz *, .jz *::before, .jz *::after { box-sizing: border-box; }
|
|
17
|
+
/* Zero specificity: a component's own colour (.toggle, .primary, ...) must always win. */
|
|
18
|
+
:where(.jz button) { font: inherit; color: inherit; cursor: pointer; }
|
|
19
|
+
.jz :focus-visible { outline: 2px solid var(--jz-accent); outline-offset: 2px; }
|
|
20
|
+
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
21
|
+
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
|
|
22
|
+
|
|
23
|
+
.toggle { position:fixed; right:32px; bottom:32px; z-index:2147483646; height:44px; padding:0 16px; display:flex; align-items:center;
|
|
24
|
+
gap:8px; border:0; border-radius:999px; background:#1D2024; color:#FFFFFF; box-shadow:var(--jz-shadow); font-weight:500; }
|
|
25
|
+
.toggle .dot { width:8px; height:8px; border-radius:50%; background:var(--jz-polished); }
|
|
26
|
+
.toggle .exit { color:#8A9099; }
|
|
27
|
+
.toggle:hover .exit { color:#FFFFFF; }
|
|
28
|
+
|
|
29
|
+
.layer { position:fixed; inset:0; z-index:2147483640; pointer-events:none; }
|
|
30
|
+
.hl { position:fixed; display:none; outline:1px solid var(--jz-accent); outline-offset:-1px; border-radius:2px; }
|
|
31
|
+
.hl.masked { outline:1px dashed var(--jz-faint);
|
|
32
|
+
background:repeating-linear-gradient(45deg, rgb(138 144 153 / 10%) 0 4px, rgb(138 144 153 / 20%) 4px 8px); }
|
|
33
|
+
.tag { position:absolute; left:0; top:-18px; padding:1px 6px; border-radius:2px; background:var(--jz-accent); color:#FFFFFF;
|
|
34
|
+
font-size:10px; line-height:16px; white-space:nowrap; max-width:280px; overflow:hidden; text-overflow:ellipsis; }
|
|
35
|
+
.hl.masked .tag { background:var(--jz-muted); text-transform:uppercase; letter-spacing:.06em; }
|
|
36
|
+
.pin { position:fixed; width:24px; height:24px; margin:-12px 0 0 -12px; border-radius:50%; display:flex; align-items:center;
|
|
37
|
+
justify-content:center; background:var(--jz-accent); color:#FFFFFF; font-size:12px; font-weight:500; box-shadow:var(--jz-shadow); }
|
|
38
|
+
|
|
39
|
+
.pop, .sheet, .checkin, .toast { position:fixed; z-index:2147483645; background:var(--jz-surface); color:var(--jz-ink);
|
|
40
|
+
border:1px solid var(--jz-rule); box-shadow:var(--jz-shadow); }
|
|
41
|
+
.pop { width:400px; max-width:calc(100vw - 32px); max-height:calc(100vh - 32px); overflow:auto; padding:24px; border-radius:10px;
|
|
42
|
+
animation: jz-in 180ms ease-out; }
|
|
43
|
+
@keyframes jz-in { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
|
|
44
|
+
.pop-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:20px; }
|
|
45
|
+
.pop h2 { margin:0; font-size:14px; font-weight:500; }
|
|
46
|
+
.close { width:32px; height:32px; display:flex; align-items:center; justify-content:center; border:0; border-radius:6px;
|
|
47
|
+
background:transparent; color:var(--jz-faint); }
|
|
48
|
+
.close:hover { color:var(--jz-ink); }
|
|
49
|
+
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:20px; }
|
|
50
|
+
.chip { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:999px; background:var(--jz-raised);
|
|
51
|
+
color:var(--jz-muted); font-size:11px; }
|
|
52
|
+
.reactions { display:flex; border:1px solid var(--jz-rule); border-radius:8px; overflow:hidden; margin-bottom:20px; }
|
|
53
|
+
.reaction { flex:1; min-height:56px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
|
|
54
|
+
padding:12px 4px; border:0; border-right:1px solid var(--jz-rule); background:transparent; color:var(--jz-muted); }
|
|
55
|
+
.reaction:last-child { border-right:0; }
|
|
56
|
+
.reaction:hover { background:var(--jz-canvas); }
|
|
57
|
+
.reaction span { font-size:10px; font-weight:500; }
|
|
58
|
+
.reaction[data-r="confused"] { color:var(--jz-confused); }
|
|
59
|
+
.reaction[aria-checked="true"] { background:var(--jz-accent-soft); color:var(--jz-accent); }
|
|
60
|
+
.reaction[data-r="confused"][aria-checked="true"] { background:rgb(110 79 194 / 10%); color:var(--jz-confused); }
|
|
61
|
+
.comment { display:block; width:100%; height:112px; padding:16px; margin-bottom:20px; resize:none; border:1px solid var(--jz-rule);
|
|
62
|
+
border-radius:8px; background:var(--jz-surface); color:var(--jz-ink); font:inherit; }
|
|
63
|
+
.comment::placeholder { color:var(--jz-faint); }
|
|
64
|
+
.comment:focus { outline:none; box-shadow:0 0 0 1px var(--jz-accent); }
|
|
65
|
+
.foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
|
|
66
|
+
.shot { display:flex; align-items:center; gap:12px; min-width:0; }
|
|
67
|
+
.thumb { flex:none; width:80px; height:48px; border-radius:8px; border:1px solid var(--jz-rule); background:var(--jz-canvas);
|
|
68
|
+
overflow:hidden; display:flex; align-items:center; justify-content:center; color:var(--jz-faint); font-size:8px; }
|
|
69
|
+
.thumb img { width:100%; height:100%; object-fit:cover; }
|
|
70
|
+
.thumb.hatch { background:repeating-linear-gradient(45deg, rgb(138 144 153 / 10%) 0 4px, rgb(138 144 153 / 20%) 4px 8px); }
|
|
71
|
+
.shot-open { display:block; width:100%; height:100%; padding:0; border:0; background:transparent; }
|
|
72
|
+
.optout-row { display:flex; align-items:center; gap:8px; margin-bottom:16px; color:var(--jz-muted); font-size:12px; }
|
|
73
|
+
.optout-row[hidden] { display:none; }
|
|
74
|
+
.note { font-size:11px; color:var(--jz-faint); line-height:1.3; }
|
|
75
|
+
.shot-full { position:fixed; inset:0; z-index:2147483647; display:flex; align-items:center; justify-content:center; padding:24px; background:rgb(0 0 0 / 72%); }
|
|
76
|
+
.shot-full img { max-width:100%; max-height:100%; object-fit:contain; border-radius:6px; background:var(--jz-surface); }
|
|
77
|
+
.shot-full .close { position:absolute; top:16px; right:16px; background:var(--jz-surface); color:var(--jz-ink); }
|
|
78
|
+
.primary { min-height:44px; padding:0 24px; border:0; border-radius:8px; background:var(--jz-accent); color:var(--jz-accent-ink); font-weight:500; }
|
|
79
|
+
.primary:disabled { opacity:.45; cursor:not-allowed; }
|
|
80
|
+
.secondary { min-height:44px; padding:0 16px; border:1px solid var(--jz-rule); border-radius:6px; background:transparent;
|
|
81
|
+
color:var(--jz-muted); font-weight:500; }
|
|
82
|
+
|
|
83
|
+
.sheet { left:32px; bottom:32px; width:340px; max-width:calc(100vw - 32px); padding:24px; border-radius:10px; }
|
|
84
|
+
.sheet h2 { display:flex; align-items:center; gap:8px; margin:0 0 12px; font-size:14px; font-weight:500; }
|
|
85
|
+
.sheet h2 svg { color:var(--jz-accent); }
|
|
86
|
+
.sheet p { margin:0 0 12px; color:var(--jz-muted); line-height:1.6; }
|
|
87
|
+
.sheet ul { margin:0 0 20px; padding-left:18px; color:var(--jz-muted); }
|
|
88
|
+
.row { display:flex; gap:8px; }
|
|
89
|
+
.row > * { flex:1; }
|
|
90
|
+
|
|
91
|
+
.checkin { right:32px; bottom:140px; display:flex; align-items:center; gap:8px; padding:8px 8px 8px 16px; border-radius:10px; }
|
|
92
|
+
.checkin .secondary { min-height:36px; }
|
|
93
|
+
.toast { right:32px; bottom:88px; padding:10px 16px; border-radius:10px; }
|
|
94
|
+
.toast.err { border-color:var(--jz-broken); }
|
|
95
|
+
|
|
96
|
+
@media (max-width: 479px) {
|
|
97
|
+
.toggle { right:24px; bottom:24px; height:48px; padding:0 20px; background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
98
|
+
.toggle .dot { background:var(--jz-accent-ink); }
|
|
99
|
+
.toggle .exit { color:inherit; opacity:.8; }
|
|
100
|
+
.pop { left:0 !important; right:0; top:auto !important; bottom:0; width:auto; max-width:none; max-height:85vh;
|
|
101
|
+
border-radius:16px 16px 0 0; border-width:1px 0 0; padding:12px 24px 34px; }
|
|
102
|
+
.pop::before { content:""; display:block; width:48px; height:4px; margin:0 auto 16px; border-radius:999px; background:var(--jz-raised); }
|
|
103
|
+
.chip { border-radius:4px; border:1px solid var(--jz-rule); }
|
|
104
|
+
.reactions { display:grid; grid-template-columns:repeat(4, 1fr); gap:12px; border:0; overflow:visible; }
|
|
105
|
+
.reaction { border:1px solid var(--jz-rule); border-radius:8px; padding:16px 4px; }
|
|
106
|
+
.reaction:last-child { border-right:1px solid var(--jz-rule); }
|
|
107
|
+
.reaction[aria-checked="true"] { border:2px solid var(--jz-accent); }
|
|
108
|
+
.reaction span { font-size:11px; }
|
|
109
|
+
.foot { flex-direction:column; align-items:stretch; }
|
|
110
|
+
.foot .primary { width:100%; min-height:52px; font-size:15px; }
|
|
111
|
+
.sheet { left:16px; right:16px; bottom:16px; width:auto; }
|
|
112
|
+
.toast { left:16px; right:16px; bottom:84px; }
|
|
113
|
+
.checkin { left:16px; right:16px; bottom:136px; }
|
|
114
|
+
}
|
|
115
|
+
@media (prefers-reduced-motion: reduce) {
|
|
116
|
+
.jz *, .jz *::before, .jz *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
|
|
117
|
+
}
|
|
118
|
+
`,dt=[["like","Like"],["dislike","Dislike"],["understood","Understood"],["confused","Confused"]],ht=5e3;function s(d,t={},...e){const o=document.createElement(d);for(const[i,r]of Object.entries(t))r===void 0||r===false||o.setAttribute(i,r===true?"":r);return o.append(...e),o}function lt(d,t,e,o){const i={pagePath:W(t),device:d.device||tt(e)},r=a=>{const c=d[a];typeof c=="string"&&c.trim()!==""&&(i[a]=c.trim())};return r("persona"),r("journeyId"),r("journeyStep"),r("businessType"),r("state"),o!==void 0&&(i.tflowId=o),i}class pt{constructor(t,e,o){n(this,"options");n(this,"getContext");n(this,"exit");n(this,"host",s("div",{"data-journeeze":""}));n(this,"root");n(this,"shell",s("div",{class:"jz"}));n(this,"layer",s("div",{class:"layer"}));n(this,"highlight",s("div",{class:"hl"}));n(this,"tag",s("div",{class:"tag mono"}));n(this,"live",s("div",{class:"sr","aria-live":"polite"}));n(this,"toggle");n(this,"channel");n(this,"outbox");n(this,"endpoint");n(this,"cleanups",[]);n(this,"phase","consent");n(this,"config",{});n(this,"pinCount",0);n(this,"popover");n(this,"fullShot");n(this,"fullShotOpener");n(this,"consentSheet");n(this,"checkin");n(this,"toastEl");n(this,"toastTimer");n(this,"lastCtx");n(this,"lastWhere");n(this,"askedSteps",new Set);n(this,"objectUrls",[]);n(this,"disposed",false);n(this,"exitTimer");n(this,"screenshotsUnavailable",false);n(this,"uploadNotFound",0);n(this,"pending",new Set);n(this,"signals");n(this,"configReady",Promise.resolve());n(this,"configLoaded",false);n(this,"maskAuditOn");n(this,"claims");this.options=t,this.getContext=e,this.exit=o,this.endpoint=K(t),this.claims=nt(t),this.claims.token(),this.signals=Z(t,this.endpoint,e),this.root=this.host.attachShadow({mode:"closed"}),this.root.append(s("style",t.nonce?{nonce:t.nonce}:{},ct),this.shell),this.toggle=s("button",{type:"button",class:"toggle","aria-pressed":"true","aria-label":"Feedback mode on. Exit feedback mode"},s("span",{class:"dot","aria-hidden":"true"}),s("span",{},"Feedback mode on"),s("span",{class:"exit","aria-hidden":"true"},"· Exit")),this.toggle.addEventListener("click",()=>this.exit());for(const i of["keydown","keyup","keypress"])this.shell.addEventListener(i,r=>this.onWidgetKey(r));this.highlight.append(this.tag),this.layer.append(this.highlight),this.shell.append(this.layer,this.toggle,this.live),this.channel=it(t,this.endpoint,{beforePersist:()=>this.stashPending(),onDropped:i=>this.toast(ut(i),true),claims:()=>this.claims.token()}),this.outbox=this.channel.outbox,document.body.append(this.host),this.listen(window,"keydown",i=>this.onKey(i)),this.lastCtx={...e()},this.lastWhere=j(),this.configReady=this.loadConfig(),this.maskAuditOn=!!t.reviewerToken&&rt(),this.maskAuditOn&&this.configReady.then(()=>this.maskAudit()),_(O(t))?this.startPointing():this.showConsent()}api(){return{unmount:t=>this.dispose(t),contextChanged:()=>this.onContextChanged()}}listen(t,e,o,i=false,r=false){t.addEventListener(e,o,{capture:i,passive:r}),this.cleanups.push(()=>t.removeEventListener(e,o,{capture:i}))}dispose(t){if(!this.disposed){this.disposed=true,this.claims.stop(),this.signals.stop(t);for(const e of this.cleanups.splice(0))e();this.exitTimer!==void 0&&clearTimeout(this.exitTimer),this.stashPending(),this.channel.dispose(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);for(const e of this.objectUrls.splice(0))URL.revokeObjectURL(e);this.host.remove()}}async loadConfig(){try{if(this.config=await st(this.endpoint,this.options.siteKey),this.configLoaded=true,this.config.consentText&&this.consentSheet){const t=this.consentSheet.querySelector("p");t&&(t.textContent=this.config.consentText)}this.config.enabled!==true&&(this.toast("Feedback isn't switched on for this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}catch(t){t instanceof M&&t.status===404&&(this.toast("Feedback isn't set up on this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}}showConsent(){this.phase="consent";const t=s("h2",{id:"jz-consent-title"},x("info",18),"Suggest an improvement"),e=s("button",{type:"button",class:"primary"},"Allow and continue"),o=s("button",{type:"button",class:"secondary"},"Not now"),i=s("div",{class:"sheet",role:"dialog","aria-modal":"false","aria-labelledby":"jz-consent-title"},t,s("p",{},this.config.consentText||(this.screenshotsAllowed()?H:q)),s("div",{class:"row"},e,o));e.addEventListener("click",()=>{Y(O(this.options)),i.remove(),this.consentSheet=void 0,this.startPointing(),this.toggle.focus()}),o.addEventListener("click",()=>this.exit()),this.trapTab(i),this.consentSheet=i,this.shell.append(i),e.focus()}startPointing(){this.phase="pointing",this.signals.start(this.configReady.then(()=>this.config)),this.announce("Feedback mode on. Click any part of the page to comment on it. Press Escape to exit."),this.listen(document,"pointermove",t=>this.onMove(t),true,true);for(const t of["pointerdown","mousedown","mouseup","pointerup"])this.listen(window,t,e=>this.swallow(e),true);for(const t of["touchstart","touchend"])this.listen(window,t,e=>{this.phase==="pointing"&&this.targetOf(e)&&e.stopPropagation()},true,true);this.listen(window,"click",t=>this.onClick(t),true),this.listen(window,"scroll",()=>this.reposition(),true,true),this.listen(window,"resize",()=>this.reposition(),false,true),this.outbox.flush()}targetOf(t){const e=t.composedPath();if(e.includes(this.host))return;const o=e[0];return o instanceof Element?o:void 0}swallow(t){this.phase!=="pointing"||!t.isTrusted||!this.targetOf(t)||(t.preventDefault(),t.stopPropagation())}onMove(t){const e=this.phase==="pointing"?this.targetOf(t):void 0;if(!e){this.highlight.style.display="none";return}const o=e.getBoundingClientRect(),i=R(e)||I(e);Object.assign(this.highlight.style,{display:"block",left:`${o.left}px`,top:`${o.top}px`,width:`${o.width}px`,height:`${o.height}px`}),this.highlight.classList.toggle("masked",i),this.tag.textContent=i?"Masked":et(e),this.tag.style.top=o.top<20?"0":"-18px"}onClick(t){if(this.phase!=="pointing"||!t.isTrusted)return;const e=this.targetOf(t);e&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),this.highlight.style.display="none",!I(e)&&this.openPopover(e,t.clientX,t.clientY))}openPopover(t,e,o){this.phase="composing";const i=this.screenshotsUnavailable||!this.screenshotsAllowed()?Promise.resolve(void 0):this.configReady.then(()=>this.configLoaded?J(document.body,this.maskOptions()):void 0).catch(()=>{}),r=ot(t,e,o),a=s("div",{class:"pin","aria-hidden":"true"},String(++this.pinCount));let c;const h=s("h2",{id:"jz-pop-title"},"How does this feel?"),f=s("button",{type:"button",class:"close","aria-label":"Close without sending"},x("close")),m=s("div",{class:"chips"}),g=this.getContext(),D=j(),F=(l,u,p)=>m.append(s("span",{class:"chip","aria-label":`${u}: ${p}`},x(l,12),p));g.persona&&F("persona","Persona",g.persona),g.journeyStep&&F("step","Journey step",g.journeyStep);const C=s("div",{class:"reactions",role:"radiogroup","aria-label":"Reaction"}),E=dt.map(([l,u])=>{const p=s("button",{type:"button",class:"reaction",role:"radio","aria-checked":"false","data-r":l},x(l),s("span",{},u));return p.addEventListener("click",()=>{c=c===l?void 0:l;for(const L of E)L.setAttribute("aria-checked",String(L.dataset.r===c));z()}),C.append(p),p}),k=s("textarea",{class:"comment","aria-label":"Comment (optional)",placeholder:"What could be improved?",maxlength:"4000"}),v=s("div",{class:"thumb hatch mono"},"CAPTURING"),T=s("span",{class:"note"},"Masked fields are hidden"),P=s("input",{type:"checkbox",class:"optout"}),A=s("label",{class:"optout-row",hidden:true},P,"Don't include screenshot"),b=s("button",{type:"button",class:"primary"},"Send"),y=s("div",{class:"pop",role:"dialog","aria-modal":"false","aria-labelledby":"jz-pop-title"},s("div",{class:"pop-head"},h,f),m,C,k,A,s("div",{class:"foot"},s("div",{class:"shot"},v,T),b)),z=()=>{b.disabled=c===void 0&&k.value.trim()===""};k.addEventListener("input",z),z(),i.then(l=>{if(this.popover?.el===y)if(v.textContent="",l){const u=URL.createObjectURL(l);this.objectUrls.push(u),v.classList.remove("hatch");const p=s("button",{type:"button",class:"shot-open","aria-label":"View screenshot full size"},s("img",{referrerpolicy:"no-referrer",src:u,alt:"Screenshot of this page with masked fields hidden"}));p.addEventListener("click",()=>this.openFullShot(u,p)),v.append(p),A.hidden=false}else v.textContent="No screenshot attached",T.textContent="Screenshot unavailable; your feedback still sends"}),f.addEventListener("click",()=>this.closePopover()),b.addEventListener("click",()=>{if(b.disabled)return;b.disabled=true;const l=k.value.trim(),u=!P.checked;this.closePopover(),this.deliver(r,c,l,u?i:Promise.resolve(void 0),g,D)}),this.trapTab(y),this.popover={el:y,pin:a,target:t,anchor:r},this.layer.append(a),this.shell.append(y),this.reposition(),E[0]?.focus()}closePopover(){if(this.popover){this.closeFullShot(),this.popover.el.remove(),this.popover.pin.remove(),this.popover=void 0;for(const t of this.objectUrls.splice(0))URL.revokeObjectURL(t);this.phase="pointing",this.toggle.focus()}}openFullShot(t,e){if(this.fullShot)return;const o=s("button",{type:"button",class:"close","aria-label":"Close full-size screenshot"},x("close")),i=s("div",{class:"shot-full",role:"dialog","aria-modal":"true","aria-label":"Screenshot"},s("img",{referrerpolicy:"no-referrer",src:t,alt:"Screenshot of this page with masked fields hidden"}),o);o.addEventListener("click",()=>this.closeFullShot()),this.trapTab(i),this.fullShot=i,this.fullShotOpener=e,this.shell.append(i),o.focus()}closeFullShot(){const t=this.fullShot;if(!t)return;this.fullShot=void 0,t.remove();const e=this.fullShotOpener;this.fullShotOpener=void 0,e?.focus()}maskOptions(){const{maskSelectors:t,maskAllText:e}=this.options,o=Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[];return{...t?{maskSelectors:t}:{},...o.length?{configMaskSelectors:o}:{},...e?{maskAllText:e}:{}}}reposition(){const t=this.popover;if(!t||!t.target.isConnected)return;const e=t.target.getBoundingClientRect(),o=e.left+t.anchor.xRatio*e.width,i=e.top+t.anchor.yRatio*e.height;if(Object.assign(t.pin.style,{left:`${o}px`,top:`${i}px`}),window.innerWidth<480)return;const r=t.el.getBoundingClientRect(),a=16;let c=e.right+a;c+r.width>window.innerWidth-a&&(c=e.left-a-r.width),c<a&&(c=Math.min(Math.max(a,o+a),window.innerWidth-r.width-a));const h=Math.min(Math.max(a,i-24),window.innerHeight-r.height-a);Object.assign(t.el.style,{left:`${Math.max(a,c)}px`,top:`${Math.max(a,h)}px`})}maskAudit(){if(this.disposed||!this.configLoaded||this.config.enabled!==true||!this.options.reviewerToken)return;const t=[...this.options.maskSelectors??[],...Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[]],{endpoint:e}=this,{siteKey:o,reviewerToken:i,pagePath:r}=this.options;import("./mask-audit-KFvSiJU0.js").then(a=>this.disposed?0:a.runMaskAudit({scan:V,endpoint:e,siteKey:o,reviewerToken:i,maskSelectors:t,...r?{pagePath:r}:{}})).catch(()=>{})}onContextChanged(){this.signals.contextChanged(),this.maskAuditOn&&this.maskAudit();const t=this.getContext();if(t.journeyStep===this.lastCtx.journeyStep&&t.journeyId===this.lastCtx.journeyId)return;const e=this.lastCtx,o=this.lastWhere;this.lastCtx={...t},this.lastWhere=j(),this.checkin?.remove(),this.checkin=void 0,this.maybeCheckin(e,o)}maybeCheckin(t,e){const o=t,i=o.journeyStep;if(this.phase==="consent"||!i)return;const r=`${o.journeyId??""}/${i}`;if(this.askedSteps.has(r))return;this.askedSteps.add(r),this.checkin?.remove();const a=(f,m)=>{const g=s("button",{type:"button",class:"secondary"},x(f,16),m);return g.addEventListener("click",()=>{h.remove(),this.deliver(void 0,f,"",Promise.resolve(void 0),t,e)}),g},c=s("button",{type:"button",class:"close","aria-label":"Dismiss"},x("close",16)),h=s("div",{class:"checkin",role:"group","aria-label":"Step check-in"},s("span",{},"Did this step make sense?"),a("understood","Understood"),a("confused","Confused"),c);c.addEventListener("click",()=>h.remove()),this.checkin=h,this.shell.append(h)}async deliver(t,e,o,i,r=this.getContext(),a=j()){const c={siteKey:this.options.siteKey,consentGiven:true,context:lt(r,a.href,a.width,t?.tflowId)};this.options.userId!==void 0&&Object.assign(c,{userId:this.options.userId},G(this.options)),t&&(c.anchor=t),e&&(c.reaction=Q[e]),o&&(c.comment=o);const h={request:c,stashed:false};this.pending.add(h);const f=await this.uploadScreenshot(i);if(this.pending.delete(h),h.stashed||this.disposed)return;f&&(c.screenshotId=f);const m=await this.outbox.enqueue(c);this.disposed||(m==="sent"?this.toast("Sent. Thank you."):m==="queued"&&this.toast("Saved. It will send when you're back online."))}stashPending(){for(const t of this.pending)t.stashed=true,this.outbox.stash(t.request);this.pending.clear()}screenshotsAllowed(){return!!(this.options.reviewerToken||this.options.userId||this.options.claims||this.options.getToken)}async uploadScreenshot(t){if(!this.screenshotsUnavailable)try{let e;const o=await Promise.race([t,new Promise(r=>e=setTimeout(()=>r(void 0),ht))]).finally(()=>clearTimeout(e));if(!o)return;const i=await X(this.endpoint,this.options,o,void 0,await this.claims.token());return this.uploadNotFound=0,i}catch(e){e instanceof M&&(this.uploadNotFound=e.status===404?this.uploadNotFound+1:0,(e.code==="unimplemented"||this.uploadNotFound>=3)&&(this.screenshotsUnavailable=true));return}}onKey(t){if(t.key!=="Escape")return;const e=t.composedPath()[0];if(t.defaultPrevented||e instanceof Element&&R(e))return;const o=document.activeElement;o&&o!==document.body&&o!==document.documentElement&&o!==this.host||(this.popover?this.closePopover():this.exit())}onWidgetKey(t){if(t.stopPropagation(),t.type!=="keydown"||t.key!=="Escape")return;if(this.fullShot){this.closeFullShot();return}const e=t.target;if(e instanceof HTMLTextAreaElement&&e.value.trim()!==""&&this.popover){this.popover.el.querySelector(".close")?.focus();return}this.popover?this.closePopover():this.exit()}trapTab(t){t.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const o=Array.from(t.querySelectorAll("button:not([disabled]), textarea")),i=o[0],r=o[o.length-1],a=this.root.activeElement;!i||!r||(e.shiftKey&&a===i?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),i.focus()))})}announce(t){this.live.textContent=t}toast(t,e=false){this.toastEl?.remove(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);const o=s("div",{class:e?"toast err":"toast",role:"status"},t);this.toastEl=o,this.shell.append(o),this.toastTimer=setTimeout(()=>o.remove(),e?6e3:3e3)}}function j(){return{href:location.href,width:window.innerWidth}}function ut(d){return d.code==="unauthenticated"?"Open the review link from your invitation to send feedback.":d.code==="failed_precondition"?"Consent is needed before feedback can be sent.":"This feedback couldn't be sent."}const wt=(d,t,e)=>new pt(d,()=>B(t()),e).api();export{St as maskedSnapshotSvg,wt as mount,G as signedIdentity,Ft as uploadTarget,lt as wireContext};
|