effect-browser 0.3.0-beta.22 → 0.3.0-beta.24
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/README.md +124 -5
- package/dist/ActionPort.d.mts +1 -1
- package/dist/ActionPort.mjs +1 -1
- package/dist/{Browser-Cq2K1FEA.mjs → Browser-CAQFhTkM.mjs} +561 -334
- package/dist/Browser-CAQFhTkM.mjs.map +1 -0
- package/dist/{Browser-wZhwZSlG.d.mts → Browser-DGR6ZEYo.d.mts} +9 -3
- package/dist/Browser.d.mts +1 -1
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserEvent-lLqJ3GJS.d.mts → BrowserEvent-C2p-NwuU.d.mts} +30 -6
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +20 -1
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-Ba7INmay.d.mts → Change-CxT1mp2e.d.mts} +13 -2
- package/dist/Change.d.mts +1 -1
- package/dist/Change.mjs +7 -1
- package/dist/Change.mjs.map +1 -1
- package/dist/Clock-Du5nP-nK.d.mts +57 -0
- package/dist/Clock.d.mts +2 -57
- package/dist/Layout.d.mts +2 -0
- package/dist/Layout.mjs +81 -0
- package/dist/Layout.mjs.map +1 -0
- package/dist/Matching-MtcWZ_hA.d.mts +266 -0
- package/dist/Matching.d.mts +2 -37
- package/dist/Matching.mjs +22 -17
- package/dist/Matching.mjs.map +1 -1
- package/dist/Overlay-CoGw5tL_.d.mts +27 -0
- package/dist/Overlay.d.mts +2 -0
- package/dist/Overlay.mjs +30 -0
- package/dist/Overlay.mjs.map +1 -0
- package/dist/{Page-BF5izr8R.mjs → Page-BaAOshxo.mjs} +3 -1
- package/dist/Page-BaAOshxo.mjs.map +1 -0
- package/dist/{Page-CvsOEorc.d.mts → Page-CLzh5E9w.d.mts} +158 -6
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/PageTime-68UPUZpZ.d.mts +29 -0
- package/dist/PageTime.d.mts +2 -0
- package/dist/PageTime.mjs +7 -0
- package/dist/PageTime.mjs.map +1 -0
- package/dist/Pose-2qqGzPvb.d.mts +32 -0
- package/dist/Pose.d.mts +2 -0
- package/dist/Pose.mjs +44 -0
- package/dist/Pose.mjs.map +1 -0
- package/dist/Site.d.mts +714 -0
- package/dist/Site.mjs +102 -0
- package/dist/Site.mjs.map +1 -0
- package/dist/{Stillness-CNlvayIo.mjs → Stillness-BwP0RdI4.mjs} +27 -6
- package/dist/Stillness-BwP0RdI4.mjs.map +1 -0
- package/dist/{Style-AO4V7Czt.mjs → Style-T3ezDYLI.mjs} +25 -2
- package/dist/{Style-AO4V7Czt.mjs.map → Style-T3ezDYLI.mjs.map} +1 -1
- package/dist/Style.d.mts +15 -2
- package/dist/Style.mjs +2 -2
- package/dist/Url-B7P-TWwL.d.mts +26 -0
- package/dist/Url.d.mts +2 -26
- package/dist/{Window-CMddGMt1.d.mts → Window-BDa8MtNP.d.mts} +4 -4
- package/dist/Window.d.mts +1 -1
- package/dist/{connection-BTeO0Hiz.mjs → connection-C_jWYIwe.mjs} +2 -2
- package/dist/{connection-BTeO0Hiz.mjs.map → connection-C_jWYIwe.mjs.map} +1 -1
- package/dist/{connection-2KHI4_KN.d.mts → connection-Db-YtlbE.d.mts} +2 -2
- package/dist/film/Film.d.mts +265 -0
- package/dist/film/Film.mjs +246 -0
- package/dist/film/Film.mjs.map +1 -0
- package/dist/fold.inpage-CyVZQHZL.d.mts +49 -0
- package/dist/index.d.mts +11 -8
- package/dist/index.mjs +8 -4
- package/dist/moment/Moment.d.mts +5 -5
- package/dist/plan/index.d.mts +2 -2
- package/dist/plan/index.mjs +2 -2
- package/dist/policy/Policy.d.mts +1 -1
- package/dist/policy/Policy.mjs +1 -1
- package/dist/pose.inpage-CLq7Mfdr.mjs +2042 -0
- package/dist/pose.inpage-CLq7Mfdr.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +8 -1
- package/dist/presentation/Presentation.mjs +3 -1
- package/dist/presentation/Presentation.mjs.map +1 -1
- package/dist/presentation/Stage.d.mts +1 -1
- package/dist/providers/Cdp.d.mts +2 -2
- package/dist/providers/Cdp.mjs +1 -1
- package/dist/providers/Chromium.d.mts +1 -1
- package/dist/providers/Chromium.mjs +1 -1
- package/dist/stillness/Stillness.d.mts +1 -1
- package/dist/stillness/Stillness.mjs +1 -1
- package/dist/supervisor/Supervisor.mjs +3 -1
- package/dist/supervisor/Supervisor.mjs.map +1 -1
- package/dist/testing/index.d.mts +4 -30
- package/dist/testing/index.mjs +8 -2
- package/dist/testing/index.mjs.map +1 -1
- package/dist/workerd/Cdp.d.mts +2 -2
- package/dist/workerd/Cdp.mjs +1 -1
- package/package.json +35 -5
- package/src/Browser.ts +11 -6
- package/src/BrowserEvent.ts +19 -0
- package/src/Change.ts +7 -1
- package/src/Layout.ts +116 -0
- package/src/Matching.ts +24 -15
- package/src/Overlay.ts +37 -0
- package/src/Page.ts +45 -0
- package/src/PageTime.ts +47 -0
- package/src/Pose.ts +50 -0
- package/src/Site.ts +124 -0
- package/src/Style.ts +36 -0
- package/src/film/Film.ts +384 -0
- package/src/index.ts +4 -0
- package/src/internal/input/perform.ts +31 -3
- package/src/internal/input/pointer.ts +7 -4
- package/src/internal/input/targets.ts +1 -1
- package/src/internal/page/bridge.ts +65 -33
- package/src/internal/page/clock.inpage.ts +306 -0
- package/src/internal/page/compose.inpage.ts +101 -0
- package/src/internal/page/context.ts +2 -0
- package/src/internal/page/identity.ts +6 -5
- package/src/internal/page/overlay.inpage.ts +96 -0
- package/src/internal/page/overlay.ts +89 -0
- package/src/internal/page/page.ts +12 -0
- package/src/internal/page/pose.inpage.ts +200 -0
- package/src/internal/page/pose.ts +80 -0
- package/src/internal/page/time.inpage.ts +49 -0
- package/src/internal/page/time.ts +122 -0
- package/src/internal/page/viewport.ts +3 -2
- package/src/internal/pictures/pictures.ts +93 -32
- package/src/internal/reading/layout.inpage.ts +193 -0
- package/src/internal/reading/layout.ts +101 -0
- package/src/internal/reading/names.inpage.ts +15 -0
- package/src/internal/reading/outline.inpage.ts +2 -18
- package/src/internal/reading/reading.ts +22 -2
- package/src/internal/reading/ready.inpage.ts +18 -23
- package/src/internal/reading/ready.ts +23 -3
- package/src/internal/reading/text.inpage.ts +1 -14
- package/src/internal/timeline/changes.inpage.ts +7 -15
- package/src/internal/timeline/changes.ts +14 -1
- package/src/internal/timeline/record.inpage.ts +15 -6
- package/src/presentation/Presentation.ts +13 -0
- package/src/stillness/Pixels.ts +26 -0
- package/src/stillness/Stillness.ts +30 -5
- package/src/supervisor/runtime.ts +5 -1
- package/src/testing/page.ts +5 -0
- package/dist/Browser-Cq2K1FEA.mjs.map +0 -1
- package/dist/Page-BF5izr8R.mjs.map +0 -1
- package/dist/Stillness-CNlvayIo.mjs.map +0 -1
|
@@ -2,18 +2,22 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
|
2
2
|
import { Plan, Point, maximumSamples } from "./Geometry.mjs";
|
|
3
3
|
import { parse, redact, redactWithin } from "./Url.mjs";
|
|
4
4
|
import { nameOf, recorded } from "./Action.mjs";
|
|
5
|
-
import { Action, Box, CursorChanged, DialogShown, Disconnected, KeyChanged, Navigated, PageClosed, PageLoaded, PageOpened, PageUntracked, PointerPressed, PointerReleased, RecordedEvent, RequestRefused, SessionEnding, Subject, TextInserted, TrackEvent, TrackPerformed, TrackPlanned, WheelScrolled } from "./BrowserEvent.mjs";
|
|
5
|
+
import { Action, ActionAnnounced, Box, CursorChanged, DialogShown, Disconnected, KeyChanged, Navigated, PageClosed, PageLoaded, PageOpened, PageUntracked, PointerPressed, PointerReleased, RecordedEvent, RequestRefused, SessionEnding, Subject, TextInserted, TrackEvent, TrackPerformed, TrackPlanned, WheelScrolled } from "./BrowserEvent.mjs";
|
|
6
6
|
import { BrowserError, Busy, Closed, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyTimeout, StaleRef, Suspended, Threw, Timeout, call, failWith, reasonOf, refuse, undispatched } from "./BrowserError.mjs";
|
|
7
7
|
import { BrowserPaint, CaptureStats, Frame, Image, Screenshot, sameCapture } from "./Frame.mjs";
|
|
8
|
-
import { _ as PreparedInputResultSchema, c as State, g as make$
|
|
8
|
+
import { _ as PreparedInputResultSchema, c as State, g as make$32, h as FailFast, i as InputRequest, l as Text, m as Correlation, o as Region, p as redacted, r as Found, s as ResolvedTarget, u as Zoom, v as ValidatedInputResultSchema } from "./Page-BaAOshxo.mjs";
|
|
9
9
|
import { Snapshot } from "./Snapshot.mjs";
|
|
10
10
|
import { checked, execute, methods } from "./ActionPort.mjs";
|
|
11
11
|
import { estimate, mapping, monotonicMillis, toBrowserSeconds, toHostTime, uncertaintyAt } from "./Clock.mjs";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { pickRequests, request } from "./Matching.mjs";
|
|
13
|
+
import { n as poseRequest } from "./pose.inpage-CLq7Mfdr.mjs";
|
|
14
|
+
import { d as description, f as parts$1, t as Current$2, u as validated } from "./Style-T3ezDYLI.mjs";
|
|
15
|
+
import { Layout, Place, Word } from "./Layout.mjs";
|
|
14
16
|
import { Change, Changes } from "./Change.mjs";
|
|
15
17
|
import { Window } from "./Window.mjs";
|
|
16
|
-
import {
|
|
18
|
+
import { Pose } from "./Pose.mjs";
|
|
19
|
+
import { Cache, Cause, Clock, Context, Data, DateTime, Deferred, Duration, Effect, Exit, Fiber, FiberSet, MutableRef, Option, Queue, Ref, Result, Schedule, Schema, Scope, Semaphore, Stream, SynchronizedRef } from "effect";
|
|
20
|
+
import { SecureRandom } from "effect/crypto";
|
|
17
21
|
import { Base64 } from "effect/encoding";
|
|
18
22
|
//#region src/internal/input/gate.ts
|
|
19
23
|
/**
|
|
@@ -72,7 +76,7 @@ const step$1 = (state, input, stopped) => {
|
|
|
72
76
|
} : state;
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
|
-
const make$
|
|
79
|
+
const make$31 = (options) => {
|
|
76
80
|
let state = {
|
|
77
81
|
_tag: "Open",
|
|
78
82
|
inputs: /* @__PURE__ */ new Set()
|
|
@@ -148,6 +152,51 @@ const make$27 = (options) => {
|
|
|
148
152
|
})
|
|
149
153
|
};
|
|
150
154
|
};
|
|
155
|
+
const TypeableResultSchema = Schema.Union([Schema.Struct({
|
|
156
|
+
ok: Schema.Literal(true),
|
|
157
|
+
secret: Schema.Boolean,
|
|
158
|
+
subject: Schema.optional(Subject)
|
|
159
|
+
}), Schema.Struct({
|
|
160
|
+
error: Schema.Literals(["stale", "untypeable"]),
|
|
161
|
+
detail: Schema.String
|
|
162
|
+
})]);
|
|
163
|
+
const EditFailure = Schema.Struct({
|
|
164
|
+
error: Schema.String,
|
|
165
|
+
stale: Schema.optional(Schema.Boolean)
|
|
166
|
+
});
|
|
167
|
+
const FocusResultSchema = Schema.Union([Schema.Struct({
|
|
168
|
+
ok: Schema.Literal(true),
|
|
169
|
+
detail: Schema.String,
|
|
170
|
+
secret: Schema.Boolean
|
|
171
|
+
}), EditFailure]);
|
|
172
|
+
const EditResultSchema = Schema.Union([Schema.Struct({
|
|
173
|
+
ok: Schema.Literal(true),
|
|
174
|
+
detail: Schema.String
|
|
175
|
+
}), EditFailure]);
|
|
176
|
+
const ResolvedPointSchema = Schema.Struct({
|
|
177
|
+
...Point.fields,
|
|
178
|
+
...Subject.fields,
|
|
179
|
+
element: Schema.String,
|
|
180
|
+
box: Schema.optional(Box),
|
|
181
|
+
cursor: Schema.String,
|
|
182
|
+
href: Schema.optional(Schema.String)
|
|
183
|
+
});
|
|
184
|
+
const PointResultSchema = Schema.Union([ResolvedPointSchema, Schema.Struct({
|
|
185
|
+
error: Schema.Literals([
|
|
186
|
+
"stale",
|
|
187
|
+
"hidden",
|
|
188
|
+
"offscreen",
|
|
189
|
+
"disabled",
|
|
190
|
+
"covered",
|
|
191
|
+
"outside"
|
|
192
|
+
]),
|
|
193
|
+
detail: Schema.String
|
|
194
|
+
})]);
|
|
195
|
+
const ScrollPlanSchema = Schema.NullOr(Schema.Struct({
|
|
196
|
+
...Point.fields,
|
|
197
|
+
dx: Schema.Finite,
|
|
198
|
+
dy: Schema.Finite
|
|
199
|
+
}));
|
|
151
200
|
//#endregion
|
|
152
201
|
//#region src/internal/page/port.ts
|
|
153
202
|
/** Scoped protocol interception at the owned session boundary; native is the default. */
|
|
@@ -204,7 +253,7 @@ const openCapture = Effect.fnUntraced(function* (page, source, handlers) {
|
|
|
204
253
|
var InputFailure = class extends Data.TaggedError("InputFailure") {};
|
|
205
254
|
/** Native page calls join their operation's reply ownership, including script mutations. */
|
|
206
255
|
const Current = Context.Reference("effect-browser/internal/input/Current", { defaultValue: () => void 0 });
|
|
207
|
-
const make$
|
|
256
|
+
const make$30 = () => {
|
|
208
257
|
const outstanding = /* @__PURE__ */ new Set();
|
|
209
258
|
const idle = Effect.gen(function* () {
|
|
210
259
|
while (outstanding.size > 0) yield* Effect.promise(() => Promise.all(outstanding));
|
|
@@ -338,7 +387,7 @@ const CurrentCost = Context.Reference("effect-browser/internal/page/CurrentCost"
|
|
|
338
387
|
const track = (reply) => Fiber.getCurrent()?.getRef(Current)?.track(reply) ?? reply;
|
|
339
388
|
const sizeOf = (value) => value === void 0 ? 0 : new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
340
389
|
const decodeWith = (operation, schema) => (value) => Schema.decodeUnknownEffect(schema)(value).pipe(Effect.mapError((error) => undispatched(operation, new Failed({ detail: error.message }))));
|
|
341
|
-
const make$
|
|
390
|
+
const make$29 = (options, scope) => {
|
|
342
391
|
const { id, clock } = options;
|
|
343
392
|
const now = () => monotonicMillis(clock);
|
|
344
393
|
const owned = Effect.provideService(Clock.Clock, clock);
|
|
@@ -405,7 +454,7 @@ const make$25 = (options, scope) => {
|
|
|
405
454
|
const noteInput = () => {
|
|
406
455
|
activity.inputAt = Math.max(activity.inputAt, now());
|
|
407
456
|
};
|
|
408
|
-
const lane = make$
|
|
457
|
+
const lane = make$32({
|
|
409
458
|
now,
|
|
410
459
|
actionTimeout: options.settings.actionTimeout,
|
|
411
460
|
documentAt: () => activity.documentAt,
|
|
@@ -432,264 +481,24 @@ const make$25 = (options, scope) => {
|
|
|
432
481
|
noteInput
|
|
433
482
|
};
|
|
434
483
|
};
|
|
435
|
-
|
|
436
|
-
//#region src/internal/page/dialogs.ts
|
|
437
|
-
/** Scoped dialog responses publish their actual outcome and invalidate their page after failed answers. */
|
|
438
|
-
/**
|
|
439
|
-
* What a page's own Playwright events publish, its close and crash aside, while its scope is
|
|
440
|
-
* open. Dialogs are answered: alerts accepted, others dismissed. The page's own session tells its
|
|
441
|
-
* documents' commits and loads.
|
|
442
|
-
*/
|
|
443
|
-
const listen = Effect.fnUntraced(function* (playwright, page, publish, now, answer, on) {
|
|
444
|
-
const dialogs = yield* Queue.bounded(8);
|
|
445
|
-
const dialog = (shown) => {
|
|
446
|
-
if (!Queue.offerUnsafe(dialogs, {
|
|
447
|
-
kind: shown.type(),
|
|
448
|
-
message: shown.message().slice(0, 500)
|
|
449
|
-
})) on.failed();
|
|
450
|
-
};
|
|
451
|
-
yield* Queue.take(dialogs).pipe(Effect.flatMap(({ kind, message }) => {
|
|
452
|
-
const accept = kind === "alert" || kind === "beforeunload";
|
|
453
|
-
const record = (answer) => Effect.sync(() => {
|
|
454
|
-
publish(new DialogShown({
|
|
455
|
-
at: now(),
|
|
456
|
-
page,
|
|
457
|
-
kind,
|
|
458
|
-
message,
|
|
459
|
-
answer
|
|
460
|
-
}));
|
|
461
|
-
});
|
|
462
|
-
return answer(accept).pipe(Effect.tap(() => record(accept ? "accepted" : "dismissed")), Effect.tapError(() => record("failed").pipe(Effect.andThen(Effect.sync(on.failed)))));
|
|
463
|
-
}), Effect.forever, Effect.forkScoped);
|
|
464
|
-
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
465
|
-
playwright.on("close", on.close);
|
|
466
|
-
playwright.on("crash", on.crash);
|
|
467
|
-
playwright.on("dialog", dialog);
|
|
468
|
-
}), () => Effect.sync(() => {
|
|
469
|
-
playwright.off("close", on.close);
|
|
470
|
-
playwright.off("crash", on.crash);
|
|
471
|
-
playwright.off("dialog", dialog);
|
|
472
|
-
}));
|
|
473
|
-
});
|
|
474
|
-
//#endregion
|
|
475
|
-
//#region src/internal/page/identity.ts
|
|
476
|
-
/** Connection identity uses the supplied Crypto service, or the host's Web Crypto on Node/Bun. */
|
|
477
|
-
const failed = () => undispatched("make", new Failed({ detail: "Could not name connection" }));
|
|
478
|
-
const make$24 = Effect.gen(function* () {
|
|
479
|
-
const supplied = yield* Effect.serviceOption(Crypto.Crypto);
|
|
480
|
-
return yield* Option.isSome(supplied) ? supplied.value.randomUUIDv4().pipe(Effect.mapError(failed)) : Effect.try({
|
|
481
|
-
try: () => globalThis.crypto.randomUUID(),
|
|
482
|
-
catch: failed
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region src/internal/page/openings.ts
|
|
487
|
-
/** A page's input waits for the actual tabs it opened to finish the browser's registration. */
|
|
488
|
-
const make$23 = Effect.fnUntraced(function* (playwright, cdp, registrations, closedBy) {
|
|
489
|
-
const failed = (reason) => Exit.fail(undispatched("newPage", reason));
|
|
490
|
-
let active;
|
|
491
|
-
const gone = Deferred.makeUnsafe();
|
|
492
|
-
const windowOpened = () => {
|
|
493
|
-
if (active !== void 0) active.windows += 1;
|
|
494
|
-
};
|
|
495
|
-
const popup = (opened) => {
|
|
496
|
-
if (active === void 0) return;
|
|
497
|
-
const registered = registrations.get(opened);
|
|
498
|
-
active.registrations.push(registered === void 0 ? failed(new Failed({ detail: "the popup has no registration" })) : Deferred.await(registered).pipe(Effect.asVoid));
|
|
499
|
-
Deferred.doneUnsafe(active.changed, Exit.void);
|
|
500
|
-
active.changed = Deferred.makeUnsafe();
|
|
501
|
-
};
|
|
502
|
-
const clear = Effect.sync(() => {
|
|
503
|
-
active = void 0;
|
|
504
|
-
});
|
|
505
|
-
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
506
|
-
cdp.on("Page.windowOpen", windowOpened);
|
|
507
|
-
playwright.on("popup", popup);
|
|
508
|
-
}), () => Effect.sync(() => {
|
|
509
|
-
active = void 0;
|
|
510
|
-
cdp.off("Page.windowOpen", windowOpened);
|
|
511
|
-
playwright.off("popup", popup);
|
|
512
|
-
Deferred.doneUnsafe(gone, failed(new Closed({ cause: closedBy() })));
|
|
513
|
-
}));
|
|
514
|
-
return {
|
|
515
|
-
mark: () => {
|
|
516
|
-
const mark = {
|
|
517
|
-
windows: 0,
|
|
518
|
-
registrations: [],
|
|
519
|
-
changed: Deferred.makeUnsafe()
|
|
520
|
-
};
|
|
521
|
-
active = mark;
|
|
522
|
-
return mark;
|
|
523
|
-
},
|
|
524
|
-
clear,
|
|
525
|
-
settle: (mark) => Effect.gen(function* () {
|
|
526
|
-
while (mark.registrations.length < mark.windows) yield* Deferred.await(mark.changed);
|
|
527
|
-
yield* Effect.forEach(mark.registrations, (registration) => registration);
|
|
528
|
-
}).pipe(Effect.raceFirst(Deferred.await(gone)), Effect.ensuring(clear))
|
|
529
|
-
};
|
|
530
|
-
});
|
|
531
|
-
const TypeableResultSchema = Schema.Union([Schema.Struct({
|
|
532
|
-
ok: Schema.Literal(true),
|
|
533
|
-
secret: Schema.Boolean,
|
|
534
|
-
subject: Schema.optional(Subject)
|
|
535
|
-
}), Schema.Struct({
|
|
536
|
-
error: Schema.Literals(["stale", "untypeable"]),
|
|
537
|
-
detail: Schema.String
|
|
538
|
-
})]);
|
|
539
|
-
const EditFailure = Schema.Struct({
|
|
540
|
-
error: Schema.String,
|
|
541
|
-
stale: Schema.optional(Schema.Boolean)
|
|
542
|
-
});
|
|
543
|
-
const FocusResultSchema = Schema.Union([Schema.Struct({
|
|
544
|
-
ok: Schema.Literal(true),
|
|
545
|
-
detail: Schema.String,
|
|
546
|
-
secret: Schema.Boolean
|
|
547
|
-
}), EditFailure]);
|
|
548
|
-
const EditResultSchema = Schema.Union([Schema.Struct({
|
|
549
|
-
ok: Schema.Literal(true),
|
|
550
|
-
detail: Schema.String
|
|
551
|
-
}), EditFailure]);
|
|
552
|
-
const ResolvedPointSchema = Schema.Struct({
|
|
553
|
-
...Point.fields,
|
|
554
|
-
...Subject.fields,
|
|
555
|
-
element: Schema.String,
|
|
556
|
-
box: Schema.optional(Box),
|
|
557
|
-
cursor: Schema.String,
|
|
558
|
-
href: Schema.optional(Schema.String)
|
|
559
|
-
});
|
|
560
|
-
const PointResultSchema = Schema.Union([ResolvedPointSchema, Schema.Struct({
|
|
561
|
-
error: Schema.Literals([
|
|
562
|
-
"stale",
|
|
563
|
-
"hidden",
|
|
564
|
-
"offscreen",
|
|
565
|
-
"disabled",
|
|
566
|
-
"covered",
|
|
567
|
-
"outside"
|
|
568
|
-
]),
|
|
569
|
-
detail: Schema.String
|
|
570
|
-
})]);
|
|
571
|
-
const ScrollPlanSchema = Schema.NullOr(Schema.Struct({
|
|
572
|
-
...Point.fields,
|
|
573
|
-
dx: Schema.Finite,
|
|
574
|
-
dy: Schema.Finite
|
|
575
|
-
}));
|
|
576
|
-
const SnapshotResultSchema = Schema.Union([Schema.Struct({ snapshot: Snapshot }), Schema.Struct({ invalid: Schema.String })]);
|
|
577
|
-
const ViewportResultSchema = Schema.Struct({
|
|
578
|
-
width: Schema.Finite,
|
|
579
|
-
height: Schema.Finite
|
|
580
|
-
});
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/internal/reading/ready.inpage.ts
|
|
583
|
-
/**
|
|
584
|
-
* In the page: whether it is ready to be shown, checked until it is or until a deadline. Its
|
|
585
|
-
* document is parsed and has painted since, nothing that ends is animating in view, its fonts and
|
|
586
|
-
* the images in view have loaded, nothing in view is marked busy (`aria-busy`), and the viewport
|
|
587
|
-
* shows something: text, a canvas drawn on, a picture or drawing larger than an icon, a video or a
|
|
588
|
-
* frame. So a canvas mounted blank, or a spinner alone, is still loading. A screen that only says
|
|
589
|
-
* "Loading…" in words reads as ready, and a WebGL canvas drawn once, without keeping its drawing,
|
|
590
|
-
* reads as blank. Asked for a quiet spell, where the page's changes are recorded, nothing in view
|
|
591
|
-
* may have changed for that long either. After input, it waits a task and a frame. See `names.inpage.ts` for what a page-side part may use.
|
|
592
|
-
*/
|
|
593
|
-
/** What the page is still waiting for; none when it is ready. */
|
|
594
|
-
const ReadinessSchema = Schema.Array(Schema.Literals([
|
|
595
|
-
"load",
|
|
596
|
-
"paint",
|
|
597
|
-
"animations",
|
|
598
|
-
"images",
|
|
599
|
-
"fonts",
|
|
600
|
-
"busy",
|
|
601
|
-
"content",
|
|
602
|
-
"changing"
|
|
603
|
-
]));
|
|
604
|
-
//#endregion
|
|
605
|
-
//#region src/internal/reading/text.inpage.ts
|
|
606
|
-
/**
|
|
607
|
-
* In the page: the text a page shows, and the one rule for what a field shows. A field's value
|
|
608
|
-
* reads `••••` unless a caller unmasks it, and a secret field's always does, including a field
|
|
609
|
-
* that was secret when the library saw it, such as a password its page now reveals. Text, and the
|
|
610
|
-
* outline, are cut at a line. See `names.inpage.ts` for what a page-side part may use.
|
|
611
|
-
*/
|
|
612
|
-
/** What `read` sends back, or null when its ref no longer names an element. */
|
|
613
|
-
const TextResultSchema = Schema.NullOr(Schema.Struct({
|
|
614
|
-
text: Schema.String,
|
|
615
|
-
truncated: Schema.Boolean,
|
|
616
|
-
url: Schema.String,
|
|
617
|
-
title: Schema.String
|
|
618
|
-
}));
|
|
619
|
-
//#endregion
|
|
620
|
-
//#region src/internal/timeline/changes.inpage.ts
|
|
484
|
+
const encodeString = Schema.encodeSync(Schema.fromJsonString(Schema.String));
|
|
621
485
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
* it stands; then each element's history is folded over the window (`history.inpage.ts`), and only
|
|
625
|
-
* now named: its role, its name when something else names it, its tag, and its context, where it
|
|
626
|
-
* is or, for what was removed, where it was. A field's value reads `••••` unless the read unmasks
|
|
627
|
-
* it, and a secret field's always does. A change names the input it followed only where it was
|
|
628
|
-
* the input's own doing, by `Change.cause`'s rule. See `names.inpage.ts` for what a page-side part
|
|
629
|
-
* may use.
|
|
486
|
+
* The expression of the page clock, a function of its event name, which the page's main world runs
|
|
487
|
+
* before its own scripts; packaging freezes it.
|
|
630
488
|
*/
|
|
489
|
+
const clockSource = "(() => {var pageScript = (function() {\n //#region src/internal/page/clock.inpage.ts\n const timers = (real, now, held, report) => {\n const all = /* @__PURE__ */ new Map();\n let next = 1;\n const arm = (id, timer) => {\n timer.real = real.setTimeout(() => {\n if (all.get(id) === timer && !held()) fire(id, timer);\n }, Math.max(0, timer.at - now()));\n };\n const fire = (id, timer) => {\n if (timer.every > 0) {\n timer.at = Math.max(timer.at + timer.every, now());\n if (!held()) arm(id, timer);\n } else all.delete(id);\n try {\n timer.run();\n } catch (error) {\n report(error);\n }\n };\n const schedule = (every) => (handler, delay, ...args) => {\n const id = next++;\n const millis = Math.max(every ? 1 : 0, Number(delay) || 0);\n const run = () => {\n if (typeof handler === \"function\") Reflect.apply(handler, window, args);\n else (0, eval)(handler);\n };\n const timer = {\n run,\n every: every ? millis : 0,\n at: now() + millis\n };\n all.set(id, timer);\n if (!held()) arm(id, timer);\n return id;\n };\n const clear = (id) => {\n const timer = all.get(Number(id));\n if (timer?.real !== void 0) real.clearTimeout(timer.real);\n all.delete(Number(id));\n };\n const runDue = (target, reach) => {\n let due;\n for (const entry of all) if (entry[1].at <= target && (due === void 0 || entry[1].at < due[1].at)) due = entry;\n if (due === void 0) return false;\n reach(due[1].at);\n fire(...due);\n return true;\n };\n return {\n setTimeout: schedule(false),\n setInterval: schedule(true),\n clear,\n runDue,\n pause: () => {\n for (const timer of all.values()) if (timer.real !== void 0) real.clearTimeout(timer.real);\n },\n resume: () => {\n for (const [id, timer] of all) arm(id, timer);\n }\n };\n };\n const animations = () => {\n let ours = /* @__PURE__ */ new WeakSet();\n const catchUp = () => {\n for (const animation of document.getAnimations()) if (animation.playState === \"running\") {\n animation.pause();\n if (!ours.has(animation)) animation.currentTime = 0;\n ours.add(animation);\n }\n };\n const move = (by) => {\n if (by <= 0) return;\n for (const animation of document.getAnimations()) {\n if (!ours.has(animation) || animation.playState !== \"paused\") continue;\n const at = Number(animation.currentTime) + by * animation.playbackRate;\n const end = Number(animation.effect?.getComputedTiming().endTime ?? Infinity);\n if (animation.playbackRate >= 0 ? at >= end : at <= 0) {\n ours.delete(animation);\n animation.finish();\n } else animation.currentTime = at;\n }\n };\n const play = () => {\n for (const animation of document.getAnimations()) if (ours.has(animation) && animation.playState === \"paused\") animation.play();\n ours = /* @__PURE__ */ new WeakSet();\n };\n return {\n catchUp,\n move,\n play\n };\n };\n const clock = (parts) => (name) => {\n if (window !== window.top) return;\n const real = {\n setTimeout: window.setTimeout.bind(window),\n clearTimeout: window.clearTimeout.bind(window),\n requestAnimationFrame: window.requestAnimationFrame.bind(window),\n cancelAnimationFrame: window.cancelAnimationFrame.bind(window),\n now: performance.now.bind(performance),\n dateNow: Date.now,\n Date\n };\n let held = false;\n let frozen = 0;\n let shift = 0;\n let dated;\n let nextFrame = 1;\n const pageNow = () => held ? frozen : real.now() + shift;\n const dateNow = () => dated === void 0 ? real.dateNow() : Math.floor(pageNow() + dated);\n const report = (error) => {\n real.setTimeout(() => {\n throw error;\n });\n };\n const timed = parts.timers(real, pageNow, () => held, report);\n const animated = parts.animations();\n const frames = /* @__PURE__ */ new Map();\n const request = (id, frame) => {\n frame.real = real.requestAnimationFrame(() => {\n frames.delete(id);\n frame.run(pageNow());\n });\n };\n const reach = (at) => {\n animated.catchUp();\n animated.move(at - frozen);\n frozen = Math.max(frozen, at);\n };\n const hold = () => {\n if (held) return;\n dated ??= real.dateNow() - real.now();\n frozen = pageNow();\n held = true;\n timed.pause();\n for (const frame of frames.values()) if (frame.real !== void 0) real.cancelAnimationFrame(frame.real);\n animated.catchUp();\n };\n const advance = (by) => {\n const target = frozen + by;\n for (let guard = 0; guard < 1e4 && timed.runDue(target, reach); guard++);\n reach(target);\n const callbacks = [...frames.values()];\n frames.clear();\n for (const frame of callbacks) try {\n frame.run(frozen);\n } catch (error) {\n report(error);\n }\n animated.catchUp();\n };\n const release = () => {\n if (!held) return;\n held = false;\n shift = Math.max(shift, frozen - real.now());\n timed.resume();\n for (const [id, frame] of frames) request(id, frame);\n animated.play();\n };\n const define = (target, key, value) => Object.defineProperty(target, key, {\n value,\n writable: true,\n configurable: true\n });\n define(window, \"setTimeout\", timed.setTimeout);\n define(window, \"setInterval\", timed.setInterval);\n define(window, \"clearTimeout\", timed.clear);\n define(window, \"clearInterval\", timed.clear);\n define(window, \"requestAnimationFrame\", (run) => {\n const id = nextFrame++;\n const frame = { run };\n frames.set(id, frame);\n if (!held) request(id, frame);\n return id;\n });\n define(window, \"cancelAnimationFrame\", (id) => {\n const frame = frames.get(id);\n if (frame?.real !== void 0) real.cancelAnimationFrame(frame.real);\n frames.delete(id);\n });\n define(performance, \"now\", pageNow);\n function PageDate(...args) {\n if (new.target === void 0) return new real.Date(dateNow()).toString();\n return Reflect.construct(real.Date, args.length === 0 ? [dateNow()] : args, new.target);\n }\n Object.setPrototypeOf(PageDate, real.Date);\n PageDate.prototype = real.Date.prototype;\n define(PageDate, \"now\", dateNow);\n define(window, \"Date\", PageDate);\n document.addEventListener(name, (event) => {\n const detail = \"detail\" in event ? event.detail : void 0;\n const op = typeof detail === \"object\" && detail !== null && \"op\" in detail ? detail.op : \"\";\n const by = typeof detail === \"object\" && detail !== null && \"by\" in detail ? Number(detail.by) : 0;\n if (op === \"holds\") {\n if (held) event.preventDefault();\n return;\n }\n if (op === \"hold\" || op === \"advance\") hold();\n if (op === \"advance\" && Number.isFinite(by) && by >= 0) advance(by);\n if (op === \"release\") release();\n event.preventDefault();\n }, true);\n };\n //#endregion\n return clock({\n timers,\n animations\n });\n})();\n\nreturn pageScript;})()";
|
|
490
|
+
/** The expression that installs the script and evaluates to its API; packaging freezes it. */
|
|
491
|
+
const installSource = "(() => {var pageScript = (function() {\n //#region src/Matching.ts\n const match = () => {\n /**\n * How names, text and context compare: one Unicode form, without invisible format characters,\n * spaces collapsed, and case folded upper first, so that \"ß\" and \"SS\" read the same.\n */\n const normalize = (value) => value.normalize(\"NFKC\").replace(/\\p{Cf}/gu, \"\").replace(/\\s+/g, \" \").trim().toUpperCase().toLowerCase();\n /** A string that reads the same, or, unless `whole`, appears within; or a pattern found within. */\n const rule = (wanted, whole) => {\n if (typeof wanted !== \"string\") {\n const found = new RegExp(wanted.source, wanted.flags.replace(/[gy]/g, \"\"));\n return (value) => found.test(value.replace(/\\s+/g, \" \").trim());\n }\n const target = normalize(wanted);\n return whole ? (value) => normalize(value) === target : (value) => normalize(value).includes(target);\n };\n /** Whether a value's words appear, whole and in order, among a text's: \"BTC\" not in \"WBTC\". */\n const holds = (text, value) => ` ${normalize(text)} `.includes(` ${normalize(value)} `);\n /** Whether a candidate meets every rule a query gives; a rule left out always holds. */\n const compile = (request) => {\n const role = request.role === null ? null : normalize(request.role);\n const name = request.name === null ? null : rule(request.name, true);\n const text = request.text === null ? null : rule(request.text, false);\n const { near } = request;\n return (candidate) => {\n if (role !== null && normalize(candidate.role ?? \"\") !== role) return false;\n if (text !== null && !text(candidate.text())) return false;\n if (name !== null && !name(candidate.name())) return false;\n if (near === null) return true;\n const { row, column, label, heading } = candidate.context();\n return [\n row,\n column,\n label,\n heading\n ].some((value) => value !== void 0 && holds(value, near));\n };\n };\n /** A comparison token for ordered observations, without retaining their text. */\n const mark = (observations) => {\n let hash = 2166136261;\n for (const shown of observations) for (let index = 0; index < shown.length; index++) hash = Math.imul(hash ^ shown.charCodeAt(index), 16777619);\n return `${observations.length}:${(hash >>> 0).toString(16)}`;\n };\n return {\n compile,\n holds,\n normalize,\n mark\n };\n };\n //#endregion\n //#region src/Url.ts\n const addresses = () => {\n const withheld = \"••••••••\";\n const credential = /token|secret|passw|passcode|passphrase|signature|credential|assertion|verifier|bearer|jwt|hmac|apikey|accesskey|privatekey|sess(?:ion)?id|saml(?:response|art)|(?:sig|otp)$|(?:auth|api|access|private|secret|signing|client|encryption|licen[cs]e|session|master|app|device|verification|verify|confirmation|confirm|activation|activate|reset|recovery|login|security|magic|onetime|mfa|2fa|sms|email|otp|oob)(?:code|key)$|^(?:auth|authorization|pwd|pass)$/;\n const ambiguous = /^(?:code|key|session|sid|ticket)$/;\n const secret = (name, value) => {\n const bare = name.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n return value !== \"\" && (credential.test(bare) || ambiguous.test(bare) && value.length >= 16 && /\\d/.test(value) && /[a-z]/i.test(value));\n };\n const masked = (parameters, separator) => parameters.split(separator).map((parameter) => {\n const [name = \"\", value = \"\"] = [...new URLSearchParams(parameter)][0] ?? [];\n return secret(name, value) ? `${parameter.slice(0, parameter.indexOf(\"=\") + 1)}${withheld}` : parameter;\n }).join(separator);\n /**\n * `url` as the library reports it: without userinfo, and with each credential's value withheld,\n * so the rest keeps its identity, such as a chart's `?ticker=ETH`. An address without a host,\n * such as `data:` or `about:blank`, is content or a fixed name, and stays as it is.\n */\n const redact = (url) => {\n const parsed = URL.parse(url);\n if (parsed === null || parsed.host === \"\") return url;\n parsed.username = \"\";\n parsed.password = \"\";\n parsed.pathname = masked(parsed.pathname, \";\");\n parsed.search = masked(parsed.search.slice(1), \"&\");\n if (parsed.hash.includes(\"=\")) {\n const fragment = parsed.hash.slice(1);\n const question = fragment.indexOf(\"?\");\n const start = question >= 0 && question < fragment.indexOf(\"=\") ? question + 1 : 0;\n parsed.hash = fragment.slice(0, start) + masked(fragment.slice(start), \"&\");\n }\n return parsed.href.replaceAll(encodeURIComponent(withheld), withheld);\n };\n return {\n withheld,\n redact\n };\n };\n //#endregion\n //#region src/internal/input/edit.inpage.ts\n const edit = (names, guard, placing) => {\n const { activeElement, clean, describe, inCurrentDocument, isDisabled, isHtml, isInput, isSecret, isSelect, isTextArea, lookup, nameOf, roleOf } = names;\n const { textEntry, typingRefusal } = guard;\n /** Whether text may be typed into a ref or focus, and, for a `secret`, only into a secret field. */\n const typeable = (ref, secret) => {\n const element = ref === null ? activeElement() : lookup(ref);\n if (element === void 0) return {\n error: \"stale\",\n detail: `${ref ?? \"the focused element\"} is not on the page any more`\n };\n const refusal = element === null ? secret ? \"nothing has focus to type a secret into\" : void 0 : typingRefusal(element, ref !== null) ?? (secret && !isSecret(element) ? `${describe(element)} is not a secret field` : void 0);\n if (refusal !== void 0) return {\n error: \"untypeable\",\n detail: refusal\n };\n if (element === null || ref !== null || !textEntry(element)) return {\n ok: true,\n secret: element !== null && isSecret(element)\n };\n const role = roleOf(element);\n const tag = element.tagName.toLowerCase();\n return {\n ok: true,\n secret: isSecret(element),\n subject: {\n role,\n name: nameOf(element, role),\n tag,\n context: placing.contextOf(element)\n }\n };\n };\n /**\n * The focused field, when it is a text field named `name`: one a page put in place of a field\n * just pressed and gave focus to, as a typeahead does.\n */\n const replacement = (name) => {\n const active = activeElement();\n return active !== null && textEntry(active) && inCurrentDocument(active) && nameOf(active, roleOf(active)) === name ? active : void 0;\n };\n /**\n * Focus a field to type into. `follow` is the field's name when the action pressed it first: a\n * page may answer the press with another field of that name in its place, focused, and the keys\n * follow focus there, as a person's would.\n */\n const focus = (ref, replace, follow) => {\n const element = lookup(ref) ?? (follow === null ? void 0 : replacement(follow));\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (!textEntry(element)) return { error: `${ref} is ${describe(element)}, not a text field` };\n if (isHtml(element)) element.focus();\n if (replace) {\n if (isInput(element) || isTextArea(element)) element.select();\n else element.ownerDocument.getSelection()?.selectAllChildren(element);\n }\n return {\n ok: true,\n detail: describe(element),\n secret: isSecret(element)\n };\n };\n /** Focus any element that takes focus, such as a link or a button, for a key pressed on it. */\n const focusOn = (ref) => {\n const element = lookup(ref);\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (isHtml(element)) element.focus();\n return activeElement() === element ? {\n ok: true,\n detail: describe(element)\n } : { error: `${ref} is ${describe(element)}, which does not take focus` };\n };\n const select = (ref, values) => {\n const element = lookup(ref);\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (!isSelect(element)) return { error: `${ref} is ${describe(element)}, not a <select>; click it and pick an option` };\n const wanted = values.map((value) => value.trim().toLowerCase());\n const options = Array.from(element.options);\n const chosen = options.filter((option) => wanted.includes(option.value.toLowerCase()) || wanted.includes(clean(option.text).toLowerCase()));\n if (chosen.length === 0) return { error: `no option matches; the options are ${options.map((option) => JSON.stringify(clean(option.text, 40))).join(\", \")}` };\n for (const option of options) option.selected = chosen.includes(option);\n element.dispatchEvent(new Event(\"input\", { bubbles: true }));\n element.dispatchEvent(new Event(\"change\", { bubbles: true }));\n return {\n ok: true,\n detail: chosen.map((option) => clean(option.text, 40)).join(\", \")\n };\n };\n return {\n focus,\n focusOn,\n select,\n typeable\n };\n };\n //#endregion\n //#region src/internal/input/evidence.inpage.ts\n const evidence = (names, placing) => {\n const { clean, isDocument, isInput, isSelect, isTextArea, nameOf, parentOf, roleOf, textOf } = names;\n const { groups, headingBefore, textBeside, treeOf } = placing;\n /** A field a submission would send. */\n const isField = (element) => (isInput(element) && ![\n \"button\",\n \"submit\",\n \"reset\",\n \"image\"\n ].includes(element.type) || isSelect(element) || isTextArea(element)) && !element.matches(\":disabled\");\n const isFilled = (field) => isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\") ? field.checked : isInput(field) && field.type === \"file\" ? (field.files?.length ?? 0) > 0 : field.value !== \"\";\n const dialogOf = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) if (node.tagName === \"DIALOG\" || /^(?:alert)?dialog$/.test(node.getAttribute(\"role\") ?? \"\")) return node;\n };\n /** What the page says about an input's first target, for a judge. Never a field's value. */\n const evidenceOf = (element, form, method, action) => {\n const name = nameOf(element, roleOf(element));\n const ids = element.getAttribute(\"aria-describedby\");\n const description = clean(ids === null ? element.getAttribute(\"aria-description\") ?? element.getAttribute(\"title\") : ids.split(/\\s+/).map((id) => element.ownerDocument.getElementById(id)?.textContent ?? \"\").join(\" \"), 120);\n const dialog = dialogOf(element);\n const title = dialog?.querySelector(\"h1,h2,h3,h4,h5,h6,[role=heading]\");\n const dialogName = dialog === void 0 ? \"\" : clean(nameOf(dialog, \"dialog\"), 120) || (title === null || title === void 0 ? \"\" : clean(textOf(title), 120));\n const root = element.getRootNode();\n const top = isDocument(root) ? root.body ?? root : root;\n const inTree = element.closest(\"dialog,[role=dialog],[role=alertdialog]\");\n let nearby = \"\";\n for (const scope of /* @__PURE__ */ new Set([\n element.closest(groups),\n inTree,\n top\n ])) if (scope !== null && nearby === \"\") nearby = textBeside(element, scope, true) || textBeside(element, scope, false);\n const heading = headingBefore(element, treeOf(element));\n const fields = form === null ? [] : Array.from(form.elements).filter(isField).slice(0, 16).map((field) => {\n const autocomplete = clean(field.getAttribute(\"autocomplete\"), 40);\n return {\n type: isInput(field) ? field.type : field.tagName.toLowerCase(),\n name: clean(isInput(field) && field.type === \"hidden\" ? field.getAttribute(\"name\") : nameOf(field, roleOf(field)), 40),\n ...autocomplete === \"\" ? {} : { autocomplete },\n filled: isFilled(field)\n };\n });\n return {\n title: clean(document.title, 120),\n ...description === \"\" || description === name ? {} : { description },\n ...dialogName === \"\" ? {} : { dialog: dialogName },\n ...heading === void 0 ? {} : { heading },\n ...nearby === \"\" ? {} : { nearby },\n ...form === null ? {} : { form: {\n method: method ?? form.method,\n action: action ?? form.action,\n fields\n } }\n };\n };\n return {\n evidenceOf,\n isField,\n isFilled\n };\n };\n //#endregion\n //#region src/internal/input/guard.inpage.ts\n const guard = (names, targets, evidence) => {\n const { activeElement, textEntry, clean, describe, inCurrentDocument, interactiveRoles, isButton, isDisabled, isHtml, isInput, isLabel, isRoot, isSecret, isSelect, isTextArea, lookup, parentOf, refFor, roleOf } = names;\n const { controlOf, details, hitAt, hrefAttribute, linkOf, receives, within } = targets;\n const { evidenceOf, isField, isFilled } = evidence;\n const nativeActivation = (element) => hrefAttribute(element) !== null || element.tagName === \"BUTTON\" || element.tagName === \"SUMMARY\" || isInput(element) && element.type !== \"hidden\";\n /**\n * The element whose activation behaviour a click or key on `element` runs, as the browser\n * resolves it along the composed path: a link, button, input, summary or a label's control.\n */\n const activationTarget = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) {\n if (nativeActivation(node)) return node;\n if (isLabel(node) && node.control !== null) return node.control;\n }\n };\n /**\n * A control between a press's hit and the approved target that is not the target's own\n * activation, such as a link or button a hover handler nested into it. The approval inspected\n * the target, so that control would act unapproved.\n */\n const nestedControl = (element, hit) => {\n if (!within(element, hit)) return void 0;\n const own = activationTarget(element);\n for (let node = hit; node !== null && node !== element; node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null) if (node !== own && (nativeActivation(node) || isSelect(node) || isTextArea(node) || isLabel(node) && node.control !== null && node.control !== own || activatingRoles.has(roleOf(node) ?? \"\"))) return node;\n };\n const activatingRoles = /* @__PURE__ */ new Set([\n \"button\",\n \"link\",\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"tab\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"option\",\n \"treeitem\"\n ]);\n const typingRefusal = (element, explicit) => textEntry(element) ? void 0 : explicit ? `${describe(element)} is not a text field` : activationTarget(element) !== void 0 || isSelect(element) || activatingRoles.has(roleOf(element) ?? \"\") ? `focus is on ${describe(element)}, which typed text could activate or change; type into a text field by ref, or use press for keys` : void 0;\n const isSubmitter = (element) => isButton(element) && element.type === \"submit\" || isInput(element) && (element.type === \"submit\" || element.type === \"image\");\n const defaultSubmitter = (form) => {\n const root = form.getRootNode();\n return isRoot(root) ? Array.from(root.querySelectorAll(\"button,input\")).find((candidate) => isSubmitter(candidate) && candidate.form === form) : void 0;\n };\n const purpose = (control, form) => [\n control.getAttribute(\"id\"),\n control.getAttribute(\"name\"),\n control.getAttribute(\"inputmode\"),\n control.getAttribute(\"autocomplete\"),\n control.getAttribute(\"aria-label\"),\n form?.getAttribute(\"id\"),\n form?.getAttribute(\"name\"),\n form?.getAttribute(\"aria-label\")\n ];\n const boundUrl = (url) => {\n const hash = url.indexOf(\"#\");\n return hash === -1 || /^#[/!]/.test(url.slice(hash)) ? url : url.slice(0, hash);\n };\n const inspectInput = (element, plan) => {\n const metadata = details(element, element, 0, 0);\n const control = activationTarget(element) ?? element;\n const form = isInput(control) || isButton(control) || isTextArea(control) || isSelect(control) ? control.form : null;\n const key = plan.keys === null ? void 0 : /(?:^|\\+)(\\+|[^+]+)$/.exec(plan.keys)?.[1];\n const enter = key === \"Enter\";\n const activation = plan.action === \"click\" || plan.action === \"press\" && (enter || key === \"Space\");\n const fieldEnter = isInput(control) && ![\n \"button\",\n \"reset\",\n \"submit\",\n \"image\",\n \"file\",\n \"color\",\n \"hidden\"\n ].includes(control.type) && (plan.action === \"press\" && enter || plan.action === \"type\" && plan.submit);\n const submits = form !== null && (activation && isSubmitter(control) || fieldEnter);\n const submitter = isSubmitter(control) ? control : form === null ? void 0 : defaultSubmitter(form);\n const formValue = (attribute, property) => form === null ? void 0 : submitter?.hasAttribute(`form${attribute}`) === true ? submitter[property] : form[attribute];\n const formDestination = formValue(\"action\", \"formAction\");\n const formMethod = formValue(\"method\", \"formMethod\");\n const formTarget = formValue(\"target\", \"formTarget\");\n const link = linkOf(element);\n const href = link === void 0 ? null : hrefAttribute(link);\n const sends = submits && formMethod !== \"dialog\";\n const destination = sends ? formDestination : activation ? metadata.href : void 0;\n const acts = plan.action !== \"hover\" && plan.action !== \"scroll\";\n const builtIn = sends || href !== null && !/^\\s*(?:#\\s*|javascript:[^]*)$/i.test(href) || isInput(control) && ![\n \"button\",\n \"submit\",\n \"image\",\n \"reset\"\n ].includes(control.type) || (isInput(control) || isButton(control)) && control.type === \"reset\" && form !== null || control.tagName === \"SUMMARY\" || control.closest(\"select\") !== null || textEntry(control);\n const facts = [];\n if (sends) facts.push(\"form-submit\");\n if (activation && link?.hasAttribute(\"download\") === true) facts.push(\"download\");\n if (activation && isInput(control) && control.type === \"file\") facts.push(\"upload\");\n if (plan.action === \"type\" && isSecret(control) || sends && form !== null && Array.from(form.elements).some((field) => isField(field) && isSecret(field) && isFilled(field))) facts.push(\"secret\");\n if (activation && !builtIn) facts.push(\"scripted\");\n if (acts && (metadata.role === \"canvas\" || metadata.role === \"iframe\" || metadata.name === \"\")) facts.push(\"opaque\");\n const role = metadata.role;\n const boundName = role !== null && (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\") && !(isHtml(element) && element.isContentEditable) ? metadata.name : null;\n const fingerprint = JSON.stringify([\n purpose(control, form),\n element.tagName,\n element.id,\n role,\n boundName,\n metadata.href,\n control === element ? null : refFor(control),\n isInput(control) || isButton(control) ? control.type : control.tagName,\n isDisabled(control),\n control.getAttribute(\"readonly\"),\n control.getAttribute(\"aria-readonly\"),\n isHtml(control) && control.isContentEditable,\n control.getAttribute(\"name\"),\n control.getAttribute(\"accept\"),\n control.hasAttribute(\"multiple\"),\n link?.getAttribute(\"download\"),\n form === null ? null : refFor(form),\n form === null ? null : boundUrl(form.action),\n form?.method,\n form?.target,\n submitter === void 0 ? null : refFor(submitter),\n formDestination === void 0 ? void 0 : boundUrl(formDestination),\n formMethod,\n formTarget,\n submitter?.formNoValidate,\n form?.noValidate\n ]);\n return {\n inspected: {\n ref: refFor(element),\n element: metadata.element,\n role: metadata.role,\n name: metadata.name,\n cursor: metadata.cursor,\n ...metadata.href === void 0 ? {} : { href: metadata.href },\n secret: isSecret(control),\n fingerprint\n },\n facts,\n destination,\n explain: () => evidenceOf(element, form, formMethod, formDestination)\n };\n };\n const inspect = (plan) => {\n const targets = [];\n const facts = /* @__PURE__ */ new Set();\n let destination = plan.destination ?? void 0;\n let explain = () => ({ title: clean(document.title, 120) });\n for (const [index, target] of plan.targets.entries()) {\n let element;\n if (target === null) element = activeElement();\n else if (typeof target === \"string\") {\n element = lookup(target);\n if (element === void 0) return {\n error: \"stale\",\n detail: target + \" is not on the page any more\",\n index\n };\n } else {\n if (!Number.isFinite(target.x) || !Number.isFinite(target.y) || target.x < 0 || target.y < 0 || target.x >= window.innerWidth || target.y >= window.innerHeight) return {\n error: \"outside\",\n detail: \"the point is outside the viewport\"\n };\n const hit = hitAt(document, target.x, target.y);\n element = hit === null ? null : controlOf(hit);\n if (element === null) return {\n error: \"offscreen\",\n detail: \"nothing is painted at the point\"\n };\n }\n if (element === null) {\n targets.push(null);\n continue;\n }\n if (!inCurrentDocument(element)) return {\n error: \"stale\",\n detail: \"the input target belongs to a replaced document\",\n index\n };\n const refusal = plan.action === \"type\" ? typingRefusal(element, target !== null) : void 0;\n if (refusal !== void 0) return {\n error: \"untypeable\",\n detail: refusal\n };\n const inspected = inspectInput(element, plan);\n if (index === 0) explain = inspected.explain;\n targets.push(inspected.inspected);\n for (const fact of inspected.facts) facts.add(fact);\n destination ??= inspected.destination;\n if (inspected.destination !== void 0) try {\n if (new URL(inspected.destination, location.href).origin !== location.origin) facts.add(\"cross-origin\");\n } catch {\n return {\n error: \"outside\",\n detail: \"the input destination is not a valid URL\"\n };\n }\n }\n if (destination !== void 0) try {\n destination = new URL(destination, location.href).href;\n if (new URL(destination).origin !== location.origin) facts.add(\"cross-origin\");\n } catch {\n return {\n error: \"outside\",\n detail: \"the input destination is not a valid URL\"\n };\n }\n return {\n url: boundUrl(location.href),\n targets,\n facts: [...facts],\n ...destination === void 0 ? {} : { destination },\n explain\n };\n };\n const prepareInput = (plan) => {\n const inspected = inspect(plan);\n if (\"error\" in inspected) return inspected;\n const { explain, ...prepared } = inspected;\n return {\n ...prepared,\n evidence: explain()\n };\n };\n const bindings = (targets) => targets.map((target) => target === null ? null : [target.ref, target.fingerprint]);\n const validate = (plan, prepared, options) => {\n const current = inspect(plan);\n if (\"error\" in current) return current.error === \"stale\" ? current : {\n error: \"changed\",\n detail: current.detail\n };\n if (current.url !== prepared.url || (current.destination === void 0 || prepared.destination === void 0 ? current.destination !== prepared.destination : boundUrl(current.destination) !== boundUrl(prepared.destination)) || JSON.stringify(current.facts) !== JSON.stringify(prepared.facts) || JSON.stringify(bindings(current.targets)) !== JSON.stringify(bindings(prepared.targets))) return {\n error: \"changed\",\n detail: \"the page or input target changed while the policy was deciding\"\n };\n if (options.focused === true) {\n const active = activeElement();\n const expected = prepared.targets[0];\n if (active === null || expected === null || expected === void 0 || refFor(active) !== expected.ref) return {\n error: \"changed\",\n detail: \"focus moved away from the approved element\"\n };\n }\n for (const press of options.presses ?? []) {\n const expected = prepared.targets[press.index];\n const element = expected === null || expected === void 0 ? void 0 : lookup(expected.ref);\n const hit = hitAt(document, press.x, press.y);\n if (element === void 0 || hit === null || !receives(element, hit)) return {\n error: \"changed\",\n detail: `the approved target is no longer under the pointer at (${press.x}, ${press.y})`\n };\n const nested = nestedControl(element, hit);\n if (nested !== void 0) return {\n error: \"changed\",\n detail: `${describe(nested)} inside the approved target would receive the press at (${press.x}, ${press.y})`\n };\n }\n return { ok: true };\n };\n const validateInput = (plan, prepared, options = {}) => {\n if ((options.presses ?? []).length === 0) return validate(plan, prepared, options);\n const { promise, resolve } = Promise.withResolvers();\n if (document.visibilityState === \"hidden\") resolve();\n else requestAnimationFrame(() => requestAnimationFrame(() => resolve()));\n return promise.then(() => validate(plan, prepared, options));\n };\n return {\n prepareInput,\n textEntry,\n typingRefusal,\n validateInput\n };\n };\n //#endregion\n //#region src/internal/input/targets.inpage.ts\n const targets = (names, walked, placing) => {\n const { describe, isDisabled, lookup, nameOf, parentOf, roleOf } = names;\n const { boxOf, controlOf, hitAt } = walked;\n const { contextOf } = placing;\n /** Whether `node` is `ancestor` or inside it, across shadow roots and same-origin frames. */\n const within = (ancestor, node) => {\n for (let current = node; current !== null;) {\n if (current === ancestor) return true;\n current = parentOf(current) ?? current.ownerDocument.defaultView?.frameElement ?? null;\n }\n return false;\n };\n const receives = (element, hit) => within(element, hit) || within(hit, element);\n const hrefAttribute = (element) => element.localName === \"a\" || element.localName === \"area\" ? element.getAttribute(\"href\") ?? element.getAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\") : null;\n const linkOf = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) if (hrefAttribute(node) !== null) return node;\n };\n const details = (element, hit, x, y) => {\n const link = linkOf(element);\n let href;\n if (link !== void 0) try {\n href = new URL(hrefAttribute(link) ?? \"\", link.ownerDocument.baseURI).href;\n } catch {\n href = void 0;\n }\n const role = roleOf(element);\n const view = hit.ownerDocument.defaultView ?? window;\n return {\n x,\n y,\n element: describe(element),\n tag: element.tagName.toLowerCase(),\n role,\n name: nameOf(element, role),\n cursor: view.getComputedStyle(hit).cursor,\n ...href === void 0 ? {} : { href }\n };\n };\n const point = (target, scroll = true) => {\n if (typeof target !== \"string\") {\n const { x, y } = target;\n if (!Number.isFinite(x) || !Number.isFinite(y) || x < 0 || y < 0 || x >= window.innerWidth || y >= window.innerHeight) return {\n error: \"outside\",\n detail: `(${x}, ${y}) is outside the viewport`\n };\n const hit = hitAt(document, x, y);\n if (hit === null) return {\n error: \"offscreen\",\n detail: `nothing is painted at (${x}, ${y})`\n };\n const control = controlOf(hit);\n return {\n ...details(control, hit, x, y),\n context: contextOf(control),\n box: boxOf(control)\n };\n }\n const ref = target;\n const element = lookup(ref);\n if (element === void 0) return {\n error: \"stale\",\n detail: `${ref} is not on the page any more`\n };\n if (isDisabled(element)) return {\n error: \"disabled\",\n detail: `${ref} is disabled`\n };\n const rect = element.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) return {\n error: \"hidden\",\n detail: `${ref} has no size on the page`\n };\n let box = {\n left: rect.left,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom\n };\n let visible = { ...box };\n let outside = false;\n for (let inner = element;;) {\n const view = inner.ownerDocument.defaultView ?? window;\n outside ||= box.left < 0 || box.top < 0 || box.right > view.innerWidth || box.bottom > view.innerHeight;\n visible = {\n left: Math.max(visible.left, 0),\n top: Math.max(visible.top, 0),\n right: Math.min(visible.right, view.innerWidth),\n bottom: Math.min(visible.bottom, view.innerHeight)\n };\n for (let ancestor = parentOf(inner); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = view.getComputedStyle(ancestor);\n const clip = ancestor.getBoundingClientRect();\n if (/(auto|scroll|hidden|clip)/.test(style.overflowX)) {\n visible.left = Math.max(visible.left, clip.left + ancestor.clientLeft);\n visible.right = Math.min(visible.right, clip.left + ancestor.clientLeft + ancestor.clientWidth);\n }\n if (/(auto|scroll|hidden|clip)/.test(style.overflowY)) {\n visible.top = Math.max(visible.top, clip.top + ancestor.clientTop);\n visible.bottom = Math.min(visible.bottom, clip.top + ancestor.clientTop + ancestor.clientHeight);\n }\n }\n const frame = view.frameElement;\n if (frame === null) break;\n const frameBox = frame.getBoundingClientRect();\n const dx = frameBox.left + frame.clientLeft;\n const dy = frameBox.top + frame.clientTop;\n box = {\n left: box.left + dx,\n top: box.top + dy,\n right: box.right + dx,\n bottom: box.bottom + dy\n };\n visible = {\n left: Math.max(visible.left + dx, dx),\n top: Math.max(visible.top + dy, dy),\n right: Math.min(visible.right + dx, dx + frame.clientWidth),\n bottom: Math.min(visible.bottom + dy, dy + frame.clientHeight)\n };\n inner = frame;\n }\n if (outside || visible.right <= visible.left || visible.bottom <= visible.top) {\n if (scroll) {\n element.scrollIntoView({\n block: \"center\",\n inline: \"center\",\n behavior: \"instant\"\n });\n return point(target, false);\n }\n return {\n error: \"offscreen\",\n detail: outside ? ref + \" is outside the viewport\" : `${ref} could not be scrolled into view`\n };\n }\n const x = (visible.left + visible.right) / 2;\n const y = (visible.top + visible.bottom) / 2;\n const hit = hitAt(document, x, y);\n if (hit !== null && !receives(element, hit)) return {\n error: \"covered\",\n detail: `${ref} is covered by ${describe(hit)}`\n };\n return {\n ...details(element, hit ?? element, Math.round(x), Math.round(y)),\n context: contextOf(element)\n };\n };\n const scrollPlan = (ref) => {\n const element = lookup(ref);\n if (element === void 0 || element.ownerDocument !== document) return null;\n const target = element.getBoundingClientRect();\n const centerX = (target.left + target.right) / 2;\n const centerY = (target.top + target.bottom) / 2;\n for (let ancestor = parentOf(element); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = window.getComputedStyle(ancestor);\n const horizontal = /^(auto|scroll)$/.test(style.overflowX) && ancestor.scrollWidth > ancestor.clientWidth;\n const vertical = /^(auto|scroll)$/.test(style.overflowY) && ancestor.scrollHeight > ancestor.clientHeight;\n if (!horizontal && !vertical) continue;\n const box = ancestor.getBoundingClientRect();\n const left = Math.max(0, box.left + ancestor.clientLeft);\n const top = Math.max(0, box.top + ancestor.clientTop);\n const right = Math.min(window.innerWidth, box.left + ancestor.clientLeft + ancestor.clientWidth);\n const bottom = Math.min(window.innerHeight, box.top + ancestor.clientTop + ancestor.clientHeight);\n if (right <= left || bottom <= top) continue;\n const x = (left + right) / 2;\n const y = (top + bottom) / 2;\n const dx = horizontal && (target.left < left || target.right > right) ? centerX - x : 0;\n const dy = vertical && (target.top < top || target.bottom > bottom) ? centerY - y : 0;\n if (dx === 0 && dy === 0) continue;\n const hit = hitAt(document, x, y);\n if (hit !== null && (hit === ancestor || ancestor.contains(hit))) return {\n x,\n y,\n dx,\n dy\n };\n }\n const dx = target.left < 0 || target.right > window.innerWidth ? centerX - window.innerWidth / 2 : 0;\n const dy = target.top < 0 || target.bottom > window.innerHeight ? centerY - window.innerHeight / 2 : 0;\n return dx === 0 && dy === 0 ? null : {\n x: window.innerWidth / 2,\n y: window.innerHeight / 2,\n dx,\n dy\n };\n };\n return {\n controlOf,\n details,\n hitAt,\n hrefAttribute,\n linkOf,\n point,\n receives,\n scrollPlan,\n within\n };\n };\n //#endregion\n //#region src/internal/reading/context.inpage.ts\n const context = (names, walked) => {\n const { clean, isButton, isDocument, isHtml, isInput, isRoot } = names;\n const { isSelect, isTextArea, roleOf, textOf } = names;\n const { visible } = walked;\n const known = () => ({\n headers: /* @__PURE__ */ new Map(),\n headings: /* @__PURE__ */ new Map()\n });\n const unspoken = \"button,select,textarea,option,script,style,noscript,template,[role=button],[role=menuitem],[role=option],[role=tab],[role=switch],[role=checkbox],[role=radio],[aria-hidden=true]\";\n const groups = \"tr,li,article,fieldset,form,section,dialog,[role=row],[role=listitem],[role=group],[role=region],[role=dialog],[role=alertdialog]\";\n /** The visible text just before (or after) a target within `scope`, nearest kept, ≤120 characters. */\n const textBeside = (target, scope, backwards) => {\n const walker = target.ownerDocument.createTreeWalker(scope, NodeFilter.SHOW_TEXT);\n const labels = isInput(target) || isTextArea(target) || isSelect(target) || isButton(target) ? Array.from(target.labels ?? []) : [];\n let text = \"\";\n walker.currentNode = target;\n for (let steps = 0; steps < 400 && text.replace(/\\s+/g, \"\").length < 120; steps++) {\n const node = backwards ? walker.previousNode() : walker.nextNode();\n if (node === null) break;\n const parent = node.parentElement;\n if (parent === null || target.contains(parent) || parent.closest(unspoken) !== null || isHtml(parent) && parent.isContentEditable || labels.some((label) => label.contains(parent)) || !visible(parent)) continue;\n text = backwards ? `${node.textContent ?? \"\"} ${text}` : `${text} ${node.textContent ?? \"\"}`;\n }\n const words = text.replace(/\\s+/g, \" \").trim();\n return words.length <= 120 ? words : backwards ? `…${words.slice(-119).trimStart()}` : `${words.slice(0, 119).trimEnd()}…`;\n };\n /** The nearest visible heading before `target` in tree order, within `scope`. */\n const headingBefore = (target, scope, read = known()) => {\n let headings = read.headings.get(scope);\n if (headings === void 0) {\n headings = Array.from(scope.querySelectorAll(\"h1,h2,h3,h4,h5,h6,[role=heading]\")).filter((element) => roleOf(element) === \"heading\");\n read.headings.set(scope, headings);\n }\n for (const heading of headings.toReversed()) {\n if ((heading.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_FOLLOWING) === 0) continue;\n const text = visible(heading) ? clean(textOf(heading), 120) : \"\";\n if (text !== \"\") return text;\n }\n };\n /** Whether an element is pinned to the viewport, where the markup around it says nothing. */\n const pinned = (element) => {\n if (!isHtml(element)) return false;\n let top = element;\n while (top.offsetParent !== null && isHtml(top.offsetParent)) top = top.offsetParent;\n return top !== element.ownerDocument.body && top !== element.ownerDocument.documentElement && getComputedStyle(top).position === \"fixed\";\n };\n const span = (cell) => Math.max(1, Number(cell.getAttribute(\"colspan\")) || 1);\n const tables = \"table,[role=table],[role=grid],[role=treegrid]\";\n /** A cell's row and column names, or nothing when it is not in a table with either. */\n const tableContext = (cell, read) => {\n const row = cell.closest(\"tr,[role=row]\");\n const table = row?.closest(tables);\n if (row === null || row === void 0 || table === null || table === void 0) return {};\n let header = read.headers.get(table);\n if (header === void 0) {\n const first = table.querySelector(\"thead tr, tr:has(> th), [role=row]:has(> [role=columnheader])\");\n header = first?.closest(tables) === table ? first : null;\n read.headers.set(table, header);\n }\n if (row === header) return {};\n const cells = Array.from(row.children);\n const index = cells.indexOf(cell);\n const lettered = (other) => /\\p{L}/u.test(textOf(other));\n const named = cells.find((other) => other.matches(\"th,[role=rowheader]\") && lettered(other)) ?? cells.find((other) => other !== cell && lettered(other));\n let left = cells.slice(0, index).reduce((sum, other) => sum + span(other), 0);\n const over = index === -1 || header === null ? void 0 : Array.from(header.children).find((candidate) => (left -= span(candidate)) < 0);\n return {\n row: named === void 0 || named === cell ? void 0 : clean(textOf(named), 60) || void 0,\n column: over === void 0 ? void 0 : clean(textOf(over), 60) || void 0\n };\n };\n /** Where text around an element is read: its dialog, else its own tree, never across a shadow root. */\n const treeOf = (element) => {\n const root = element.getRootNode();\n return element.closest(\"dialog,[role=dialog],[role=alertdialog]\") ?? (isDocument(root) ? root.body ?? root : isRoot(root) ? root : element.ownerDocument);\n };\n /** The words around an element that say which one it is. */\n const contextOf = (element, read = known()) => {\n const cell = element.closest(\"td,th,[role=cell],[role=gridcell],[role=rowheader],[role=columnheader]\");\n const table = cell === null ? {} : tableContext(cell, read);\n const parent = element.parentElement;\n const scope = element.closest(groups) ?? (parent === null || parent === element.ownerDocument.body || parent.tagName === \"HTML\" ? void 0 : parent);\n const beside = table.row !== void 0 || table.column !== void 0 || scope === void 0 ? \"\" : textBeside(element, scope, true);\n const heading = pinned(element) ? void 0 : headingBefore(element, treeOf(element), read);\n return {\n ...table,\n label: beside.length > 40 ? `…${beside.slice(-39).trimStart()}` : beside || void 0,\n heading: heading === void 0 ? void 0 : clean(heading, 60)\n };\n };\n return {\n contextOf,\n groups,\n headingBefore,\n known,\n textBeside,\n treeOf\n };\n };\n //#endregion\n //#region src/internal/reading/controls.inpage.ts\n const controls = (names, subjects, texts) => {\n const { clean, isInput, isSelect, isTextArea, refFor, textEntry } = names;\n const { stateOf } = subjects;\n const { shown } = texts;\n const states = (element, role) => {\n const { level, ...flags } = stateOf(element, role);\n const held = Object.entries(flags).flatMap(([name, value]) => value === true ? [name] : []);\n return [...level === void 0 ? [] : [`level=${level}`], ...held].map((name) => ` [${name}]`).join(\"\");\n };\n const valueOf = (element) => {\n if (isSelect(element)) {\n const selected = Array.from(element.selectedOptions, (option) => clean(option.text, 40));\n const options = Array.from(element.options).slice(0, 12).map((option) => clean(option.text, 40));\n const more = element.options.length > 12 ? ` +${element.options.length - 12} more` : \"\";\n return ` value=${JSON.stringify(selected.join(\", \"))} options=${JSON.stringify(options.join(\" | \") + more)}`;\n }\n const value = isInput(element) || isTextArea(element) ? shown(element, true) : void 0;\n return value === void 0 || value === \"\" ? \"\" : ` value=${JSON.stringify(clean(value, 80))}`;\n };\n /** A control as a value, as its outline line shows it. */\n const controlOf = (element, role, kind, name) => {\n const { disabled, checked } = stateOf(element, role);\n const select = isSelect(element) ? element : void 0;\n const value = select !== void 0 ? Array.from(select.selectedOptions, (option) => clean(option.text, 80)).join(\", \") : isInput(element) || isTextArea(element) ? clean(shown(element, true), 200) : \"\";\n const editable = textEntry(element);\n return {\n ref: refFor(element),\n kind,\n name,\n value,\n ...select === void 0 ? {} : {\n options: Array.from(select.options).slice(0, 64).map((option) => clean(option.text, 80)),\n optionCount: select.options.length\n },\n ...disabled ? { disabled } : {},\n ...checked === void 0 ? {} : { checked },\n ...editable ? { editable } : {}\n };\n };\n /**\n * The elements a selector matches, each read whole, so one inside another that matched is left\n * to it; or why the selector is not CSS.\n */\n const rootsOf = (selector) => {\n let matched;\n try {\n matched = Array.from(document.querySelectorAll(selector));\n } catch {\n return { invalid: `${JSON.stringify(selector)} is not a CSS selector` };\n }\n return matched.filter((root) => !matched.some((other) => other !== root && other.contains(root)));\n };\n return {\n controlOf,\n rootsOf,\n states,\n valueOf\n };\n };\n //#endregion\n //#region src/internal/reading/expect.inpage.ts\n const expectations = (names, subjected, matching) => {\n const { isInput, isSelect, isTextArea, roleOf, textOf } = names;\n const { elementsOf, stateOf } = subjected;\n const markOf = (elements) => matching.mark(elements.map((element) => {\n const { focused: _focused, ...state } = stateOf(element, roleOf(element));\n const value = isInput(element) || isSelect(element) || isTextArea(element) ? element.value : \"\";\n return `${textOf(element)}\\u0000${value}\\u0000${JSON.stringify(state)}\\u0001`;\n }));\n /**\n * What `find` matches, looked at every 100 ms until `want` holds of it or `millis` have passed,\n * with its mark then. It gives no refs.\n */\n const until = async (request, want, millis) => {\n const deadline = performance.now() + millis;\n for (;;) {\n const elements = elementsOf(request);\n if (\"invalid\" in elements) return elements;\n const mark = markOf(elements);\n const met = want === \"some\" ? elements.length > 0 : want === \"none\" ? elements.length === 0 : mark !== want.other;\n const left = deadline - performance.now();\n if (met || left <= 0) return {\n met,\n mark\n };\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, Math.min(100, left));\n await promise;\n }\n };\n return { until };\n };\n //#endregion\n //#region src/internal/reading/layout.inpage.ts\n const layout = (names, walked, subjected, matching, placing) => {\n const { isDisabled, isOwn, nameOf, refFor, roleOf, textOf } = names;\n const { boxOf, inView, visible } = walked;\n const most = 200;\n const area = (element) => {\n const { width, height } = element.getBoundingClientRect();\n return width * height;\n };\n const chosen = (elements, choose) => choose === \"first\" ? elements[0] : choose === \"last\" ? elements.at(-1) : elements.reduce((best, element) => best === void 0 || (choose === \"smallest\" ? area(element) < area(best) : area(element) > area(best)) ? element : best, void 0);\n const fixed = (element) => {\n for (let at = element; at !== null; at = at.parentElement) if (getComputedStyle(at).position === \"fixed\") return true;\n return false;\n };\n const words = (element, wanted, dx, dy) => {\n const parts = [];\n let text = \"\";\n const walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT);\n for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {\n parts.push({\n node,\n start: text.length\n });\n text += node.nodeValue ?? \"\";\n }\n const pattern = typeof wanted === \"string\" ? new RegExp(wanted.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"giu\") : new RegExp(wanted.source, wanted.flags.replace(/[gy]/g, \"\") + \"g\");\n const at = (index, end) => {\n const part = parts.findLast(({ start }) => end ? start < index : start <= index) ?? parts[0];\n return part === void 0 ? [element, 0] : [part.node, index - part.start];\n };\n const found = [];\n for (const match of text.matchAll(pattern)) {\n if (found.length === most) break;\n if (match[0] === \"\") continue;\n const range = element.ownerDocument.createRange();\n range.setStart(...at(match.index, false));\n range.setEnd(...at(match.index + match[0].length, true));\n const { x, y, width, height } = range.getBoundingClientRect();\n if (width > 0 || height > 0) found.push({\n text: match[0],\n box: {\n x: x + dx,\n y: y + dy,\n width,\n height\n }\n });\n }\n return found;\n };\n const selected = (pick) => {\n let elements;\n try {\n elements = Array.from(document.querySelectorAll(pick.selector));\n } catch {\n return { invalid: `${JSON.stringify(pick.selector)} is not a CSS selector` };\n }\n const rules = matching.compile(pick);\n return elements.filter((element) => {\n const role = roleOf(element, pick.role !== null);\n const box = boxOf(element);\n return !isOwn(element) && box.width * box.height > 0 && visible(element) && (pick.scope === \"document\" || inView(new DOMRect(box.x, box.y, box.width, box.height))) && (pick.state !== \"enabled\" || !isDisabled(element)) && rules({\n role,\n name: () => nameOf(element, role),\n text: () => textOf(element),\n context: () => placing.contextOf(element)\n });\n });\n };\n const read = (picks) => {\n const places = [];\n const missing = [];\n for (const pick of picks) {\n const elements = pick.selector === null ? subjected.elementsOf(pick) : selected({\n ...pick,\n selector: pick.selector\n });\n if (\"invalid\" in elements) return { invalid: `${pick.id}: ${elements.invalid}` };\n const element = chosen(elements, pick.choose);\n if (element === void 0) {\n missing.push(pick.id);\n continue;\n }\n const role = roleOf(element, pick.role !== null);\n const box = boxOf(element);\n const own = element.getBoundingClientRect();\n places.push({\n id: pick.id,\n ref: refFor(element),\n subject: {\n role,\n name: nameOf(element, role),\n tag: element.tagName.toLowerCase(),\n context: placing.contextOf(element)\n },\n box,\n fixed: fixed(element),\n words: pick.words === null ? void 0 : words(element, pick.words, box.x - own.x, box.y - own.y)\n });\n }\n return { layout: {\n url: location.href,\n viewport: {\n width: innerWidth,\n height: innerHeight\n },\n scroll: {\n x: scrollX,\n y: scrollY\n },\n scale: devicePixelRatio,\n places,\n missing\n } };\n };\n return { read };\n };\n //#endregion\n //#region src/internal/reading/names.inpage.ts\n const elements = () => {\n const isInput = (element) => element.tagName === \"INPUT\";\n const isTextArea = (element) => element.tagName === \"TEXTAREA\";\n const isSelect = (element) => element.tagName === \"SELECT\";\n const isFrame = (element) => element.tagName === \"IFRAME\";\n const isHtml = (element) => \"innerText\" in element;\n const isButton = (element) => element.tagName === \"BUTTON\";\n const isLabel = (element) => element.tagName === \"LABEL\";\n const textOf = (element) => isHtml(element) ? element.innerText : element.textContent ?? \"\";\n const isElement = (node) => node.nodeType === Node.ELEMENT_NODE;\n const isDocument = (node) => node.nodeType === Node.DOCUMENT_NODE;\n /** The native fields and editable regions that can receive typed text. */\n const textEntry = (element) => isInput(element) && ![\n \"button\",\n \"reset\",\n \"submit\",\n \"image\",\n \"checkbox\",\n \"radio\",\n \"file\",\n \"range\",\n \"color\",\n \"hidden\"\n ].includes(element.type) || isTextArea(element) || isHtml(element) && element.isContentEditable;\n const own = /* @__PURE__ */ new WeakSet();\n const adopt = (node) => own.add(node);\n /** Whether a node is the library's own, or inside a shadow root of one of its own. */\n const isOwn = (node) => {\n const root = node.getRootNode();\n return own.has(node) || root instanceof ShadowRoot && own.has(root.host);\n };\n const clean = (value, max = 160) => {\n const text = (value ?? \"\").replace(/\\s+/g, \" \").trim();\n return text.length > max ? `${text.slice(0, max - 1)}…` : text;\n };\n return {\n adopt,\n clean,\n isInput,\n isTextArea,\n isSelect,\n isFrame,\n isHtml,\n isButton,\n isLabel,\n textOf,\n isElement,\n isDocument,\n isOwn,\n textEntry\n };\n };\n const names = (native) => {\n const { clean, isInput, isTextArea, isSelect, isFrame, textOf, isElement } = native;\n const byElement = /* @__PURE__ */ new WeakMap();\n const byRef = /* @__PURE__ */ new Map();\n const refs = { next: 1 };\n const interactiveRoles = new Set(\"button link checkbox radio tab menuitem menuitemcheckbox menuitemradio option switch slider combobox listbox textbox searchbox spinbutton treeitem\".split(\" \"));\n const containers = {\n HEADER: \"banner\",\n NAV: \"navigation\",\n MAIN: \"main\",\n ASIDE: \"complementary\",\n FOOTER: \"contentinfo\",\n FORM: \"form\",\n DIALOG: \"dialog\"\n };\n const valueRoles = new Set(\"combobox listbox option textbox searchbox spinbutton slider\".split(\" \"));\n /**\n * A label's own words, without the options or values of the controls inside it, native or\n * scripted, such as the custom select Browserbase puts in place of a native one.\n */\n const labelText = (label) => {\n let text = \"\";\n const collect = (node) => {\n for (const child of Array.from(node.childNodes)) if (child.nodeType === Node.TEXT_NODE) text += child.textContent ?? \"\";\n else if (isElement(child) && ![\n \"SELECT\",\n \"TEXTAREA\",\n \"INPUT\",\n \"SCRIPT\",\n \"STYLE\"\n ].includes(child.tagName) && !valueRoles.has(roleOf(child) ?? \"\")) collect(child);\n };\n collect(label);\n return text;\n };\n const roleOf = (element, structural = false) => {\n const explicit = element.getAttribute(\"role\");\n if (explicit !== null && explicit.trim() !== \"\") return explicit.trim().split(/\\s+/)[0] ?? null;\n const tag = element.tagName;\n if (tag === \"A\") return element.hasAttribute(\"href\") ? \"link\" : null;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return \"button\";\n if (isSelect(element)) return element.multiple ? \"listbox\" : \"combobox\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (isInput(element)) {\n const type = element.type;\n if (type === \"hidden\" || type === \"color\" || type === \"file\") return null;\n if (type === \"checkbox\" || type === \"radio\") return type;\n if (type === \"range\") return \"slider\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"search\") return \"searchbox\";\n if (type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\") return \"button\";\n return \"textbox\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"IMG\") return \"img\";\n if (tag === \"CANVAS\") return \"canvas\";\n if (tag === \"IFRAME\") return \"iframe\";\n if (element.getAttribute(\"contenteditable\") === \"true\") return \"textbox\";\n if (structural) {\n if (tag === \"TH\") return element.getAttribute(\"scope\") === \"row\" ? \"rowheader\" : \"columnheader\";\n const roles = {\n TABLE: \"table\",\n TR: \"row\",\n TD: \"cell\",\n TBODY: \"rowgroup\",\n THEAD: \"rowgroup\",\n TFOOT: \"rowgroup\",\n UL: \"list\",\n OL: \"list\",\n MENU: \"list\",\n LI: \"listitem\"\n };\n if (roles[tag] !== void 0) return roles[tag];\n }\n return containers[tag] ?? null;\n };\n const nameOf = (element, role) => {\n const labelledBy = element.getAttribute(\"aria-labelledby\");\n if (labelledBy !== null) {\n const text = labelledBy.split(/\\s+/).map((id) => {\n const labelling = element.ownerDocument.getElementById(id);\n return labelling === null ? \"\" : labelText(labelling);\n }).join(\" \");\n if (clean(text) !== \"\") return clean(text);\n }\n const label = element.getAttribute(\"aria-label\");\n if (label !== null && clean(label) !== \"\") return clean(label);\n if (isInput(element) || isTextArea(element) || isSelect(element)) {\n const labels = element.labels === null ? \"\" : Array.from(element.labels, labelText).join(\" \");\n if (clean(labels) !== \"\") return clean(labels);\n if (isInput(element) && (element.type === \"button\" || element.type === \"submit\" || element.type === \"reset\")) return clean(element.value);\n return clean(element.getAttribute(\"placeholder\") ?? element.getAttribute(\"title\") ?? element.getAttribute(\"name\"));\n }\n if (role === \"img\") return clean(element.getAttribute(\"alt\") ?? element.getAttribute(\"title\"));\n if (role === \"iframe\") return clean(element.getAttribute(\"title\") ?? element.getAttribute(\"name\"));\n if (role === null || interactiveRoles.has(role) || role === \"heading\") {\n const text = isSecret(element) ? \"\" : clean(textOf(element), 120);\n if (text !== \"\") return text;\n const titled = element.querySelector(\"[title],img[alt],svg title\");\n const fallback = titled === null ? null : titled.tagName === \"IMG\" ? titled.getAttribute(\"alt\") : titled.tagName.toLowerCase() === \"title\" ? titled.textContent : titled.getAttribute(\"title\");\n return clean(element.getAttribute(\"title\") ?? fallback);\n }\n return \"\";\n };\n const isDisabled = (element) => element.matches(\":disabled\") || element.getAttribute(\"aria-disabled\") === \"true\";\n const refFor = (element) => {\n const known = byElement.get(element);\n if (known !== void 0 && byRef.get(known)?.deref() === element) return known;\n const ref = `e${refs.next++}`;\n byElement.set(element, ref);\n byRef.set(ref, new WeakRef(element));\n return ref;\n };\n const lookup = (ref) => {\n const element = byRef.get(ref)?.deref();\n return element !== void 0 && element.isConnected && inCurrentDocument(element) ? element : void 0;\n };\n const describe = (element) => {\n const id = element.id === \"\" ? \"\" : `#${element.id}`;\n const name = clean(nameOf(element, roleOf(element)), 40);\n return `<${element.tagName.toLowerCase()}${id}>${name === \"\" ? \"\" : ` \"${name}\"`}`;\n };\n const isRoot = (node) => node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;\n const parentOf = (element) => {\n const root = element.getRootNode();\n return element.parentElement ?? (isRoot(root) && \"host\" in root ? root.host : null);\n };\n const activeElement = () => {\n let active = document.activeElement;\n while (active !== null) {\n const inner = active.shadowRoot?.activeElement ?? (isFrame(active) ? active.contentDocument?.activeElement : null);\n if (inner === null || inner === void 0 || inner === active) return active;\n active = inner;\n }\n return null;\n };\n const inCurrentDocument = (element) => {\n let owner = element.ownerDocument;\n while (owner !== document) {\n const frame = owner.defaultView?.frameElement;\n if (frame === null || frame === void 0 || !frame.isConnected || isFrame(frame) && frame.contentDocument !== owner) return false;\n owner = frame.ownerDocument;\n }\n return true;\n };\n const secretToken = /(?:^|\\s)(?:current-password|new-password|one-time-code|cc-number|cc-csc|cc-exp(?:-month|-year)?)(?=\\s|$)/i;\n const secrets = /* @__PURE__ */ new WeakSet();\n /**\n * A field the DOM marks as secret, now or before: by its type, its autocomplete tokens, or a\n * style that shows dots for what it holds, as a PIN field may.\n */\n const isSecret = (element) => {\n if (isInput(element) && element.type === \"password\" || secretToken.test(element.getAttribute(\"autocomplete\") ?? \"\") || (isInput(element) || isTextArea(element)) && !/^(none)?$/.test(getComputedStyle(element).getPropertyValue(\"-webkit-text-security\"))) secrets.add(element);\n return secrets.has(element);\n };\n return {\n ...native,\n activeElement,\n containers,\n describe,\n inCurrentDocument,\n interactiveRoles,\n isDisabled,\n isRoot,\n isSecret,\n lookup,\n nameOf,\n parentOf,\n refFor,\n refs,\n roleOf\n };\n };\n //#endregion\n //#region src/internal/reading/outline.inpage.ts\n const outline = (names, walked, subjects, texts, controlling, url) => {\n const { clean, containers, isFrame, nameOf, refFor, roleOf, textOf } = names;\n const { visit } = walked;\n const { isControl } = subjects;\n const { cut } = texts;\n const textBlocks = /^(?:P|LI|TD|TH|DT|DD|LABEL|SPAN|BLOCKQUOTE|FIGCAPTION|CAPTION|PRE|STRONG|EM|B|I|SMALL|TIME|CODE|LEGEND)$/;\n const nested = \"a[href],button,input,select,textarea,summary,[role],[onclick],[tabindex],[contenteditable],canvas,iframe\";\n const noise = /^[\\s|•·\\-–—,.:;()[\\]{}\"'/\\\\]*$/;\n /** Text inside a control's label is already that control's name. */\n const inControlLabel = (element) => {\n const label = element.closest(\"label\");\n return label !== null && label.control !== null;\n };\n const hrefOf = (element) => {\n if (element.tagName !== \"A\") return \"\";\n const raw = element.getAttribute(\"href\") ?? \"\";\n if (raw === \"\" || raw.startsWith(\"javascript:\")) return \"\";\n try {\n const { origin, href } = new URL(raw, element.ownerDocument.baseURI);\n const reported = url.redact(href);\n const own = origin === location.origin && reported.startsWith(origin);\n return ` -> ${clean(own ? reported.slice(origin.length) : reported, 80)}`;\n } catch {\n return \"\";\n }\n };\n const snapshot = (request) => {\n const roots = request.within === null ? [null] : controlling.rootsOf(request.within);\n if (\"invalid\" in roots) return roots;\n const width = window.innerWidth;\n const height = window.innerHeight;\n const query = request.query === null ? null : request.query.toLowerCase();\n const lines = [];\n const controls = [];\n let above = 0;\n let below = 0;\n const placement = (rect) => {\n if (request.full) return \"in\";\n if (rect.bottom <= 0) return \"above\";\n if (rect.top >= height) return \"below\";\n if (rect.right <= 0 || rect.left >= width) return \"aside\";\n return \"in\";\n };\n const count = (rect) => {\n const where = placement(rect);\n if (where === \"above\") above++;\n if (where === \"below\") below++;\n return where;\n };\n const emit = (depth, line, rect) => {\n if (count(rect) !== \"in\") return false;\n if (query !== null && !line.toLowerCase().includes(query)) return false;\n lines.push(`${\" \".repeat(Math.min(depth, 8))}- ${line}`);\n return true;\n };\n const control = (element, rect, role, depth) => {\n const name = nameOf(element, role);\n const kind = role ?? \"clickable\";\n const box = request.boxes || role === \"canvas\" || role === \"iframe\" ? ` ${Math.round(rect.width)}x${Math.round(rect.height)} at (${Math.round(rect.x)},${Math.round(rect.y)})` : \"\";\n const line = placement(rect) === \"in\" ? `${kind}${name === \"\" ? \"\" : ` ${JSON.stringify(name)}`} [ref=${refFor(element)}]${controlling.states(element, role)}${controlling.valueOf(element)}${hrefOf(element)}${box}` : kind;\n if (emit(depth, line, rect)) controls.push(controlling.controlOf(element, role, kind, name));\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n if ((body === null || body === void 0) && placement(rect) === \"in\") lines.push(`${\" \".repeat(Math.min(depth + 1, 8))}- (another site's frame: use a screenshot and coordinates)`);\n return {\n depth: depth + 1,\n insidePointer: false,\n controls: false\n };\n }\n if ([\n \"INPUT\",\n \"SELECT\",\n \"TEXTAREA\",\n \"CANVAS\",\n \"IMG\"\n ].includes(element.tagName)) return void 0;\n return {\n depth: depth + 1,\n insidePointer: true,\n controls: true\n };\n };\n const enter = (element, style, rect, { depth, insidePointer }) => {\n const role = roleOf(element);\n if (isControl(element, role, style, rect, insidePointer)) return control(element, rect, role, depth);\n if (role === \"heading\") {\n emit(depth, `heading ${JSON.stringify(nameOf(element, role))}${controlling.states(element, role)}`, rect);\n return;\n }\n if (role === \"img\") {\n const alt = nameOf(element, role);\n if (alt !== \"\") emit(depth, `img ${JSON.stringify(alt)}`, rect);\n return;\n }\n let inner = depth;\n if (role !== null && (containers[element.tagName] !== void 0 || role === \"dialog\")) {\n const label = element.getAttribute(\"aria-label\");\n if (emit(depth, `${role}${label === null ? \"\" : ` ${JSON.stringify(clean(label))}`}:`, rect)) inner = depth + 1;\n }\n if (textBlocks.test(element.tagName) && element.querySelector(nested) === null) {\n if (inControlLabel(element)) return void 0;\n const text = clean(textOf(element), 300);\n if (text !== \"\" && !noise.test(text)) emit(inner, `text: ${text}`, rect);\n return;\n }\n let own = \"\";\n for (const node of Array.from(element.childNodes)) if (node.nodeType === Node.TEXT_NODE) own += node.textContent ?? \"\";\n own = clean(own, 300);\n if (own !== \"\" && !noise.test(own) && !inControlLabel(element)) emit(inner, `text: ${own}`, rect);\n return {\n depth: inner,\n insidePointer: insidePointer || style.cursor === \"pointer\",\n controls: false\n };\n };\n const visitor = {\n enter,\n admit: (child, place) => !place.controls || child.matches(nested) || child.querySelector(nested) !== null,\n outside: count\n };\n for (const root of roots) visit(root, !request.full, {\n depth: 0,\n insidePointer: false,\n controls: false\n }, visitor);\n const outlined = cut(lines.join(\"\\n\"), request.maxChars);\n return { snapshot: {\n ...outlined,\n url: location.href,\n title: document.title,\n above,\n below,\n viewport: {\n width,\n height\n },\n scroll: {\n y: Math.round(window.scrollY),\n height: Math.round(document.documentElement.scrollHeight)\n },\n controls: controls.filter((control) => outlined.text.includes(`[ref=${control.ref}]`))\n } };\n };\n const viewport = () => ({\n width: window.innerWidth,\n height: window.innerHeight\n });\n return {\n snapshot,\n viewport\n };\n };\n //#endregion\n //#region src/internal/reading/ready.inpage.ts\n const ready = (walked, texts, kept) => {\n const { inView, visible } = walked;\n let copy;\n const boxed = (element) => {\n const rect = element.getBoundingClientRect();\n return rect.width * rect.height > 0 && inView(rect);\n };\n const showing = (elements) => Array.from(elements).filter((element) => boxed(element) && visible(element));\n const drawn = (canvas) => {\n copy ??= new OffscreenCanvas(32, 32).getContext(\"2d\", { willReadFrequently: true });\n if (copy === null) return true;\n try {\n copy.clearRect(0, 0, 32, 32);\n copy.imageSmoothingQuality = \"high\";\n copy.drawImage(canvas, 0, 0, 32, 32);\n return new Uint32Array(copy.getImageData(0, 0, 32, 32).data.buffer).some((pixel) => pixel !== 0);\n } catch {\n return true;\n }\n };\n const content = () => showing(document.querySelectorAll(\"video, iframe, embed, object\")).length > 0 || showing(document.querySelectorAll(\"img, svg\")).some((picture) => {\n const { width, height } = picture.getBoundingClientRect();\n return width > 64 && height > 64;\n }) || (texts.read({\n ref: null,\n maxChars: 1,\n unmask: false\n })?.text ?? \"\") !== \"\" || showing(document.querySelectorAll(\"canvas\")).some(drawn);\n const painted = () => {\n const { promise, resolve } = Promise.withResolvers();\n if (document.visibilityState === \"hidden\") resolve(false);\n else requestAnimationFrame(() => resolve(true));\n return promise;\n };\n const check = (quietMillis, clock) => painted().then((paints) => {\n const waiting = [];\n const held = clock !== null && !document.dispatchEvent(new CustomEvent(clock, {\n detail: { op: \"holds\" },\n cancelable: true\n }));\n if (document.readyState === \"loading\") waiting.push(\"load\");\n if (!paints) waiting.push(\"paint\");\n if (document.getAnimations().some((animation) => {\n const effect = animation.effect;\n return (animation.playState === \"running\" || held && animation.playState === \"paused\") && effect !== null && Number.isFinite(effect.getComputedTiming().endTime) && \"target\" in effect && effect.target instanceof Element && boxed(effect.target);\n })) waiting.push(\"animations\");\n if (Array.from(document.images).some((image) => !image.complete && boxed(image))) waiting.push(\"images\");\n if (document.fonts.status !== \"loaded\") waiting.push(\"fonts\");\n if (showing(document.querySelectorAll(\"[aria-busy=true]\")).length > 0) waiting.push(\"busy\");\n if (!content()) waiting.push(\"content\");\n if (kept.changing() > performance.timeOrigin + performance.now() - quietMillis) waiting.push(\"changing\");\n return waiting;\n });\n /**\n * Check until the page is ready, or for `millis`, and say what it is still waiting for; with\n * `quietMillis`, until nothing the record saw in view has changed for that long, too.\n */\n const wait = async (millis, quietMillis = 0, clock = null) => {\n const until = performance.now() + millis;\n for (;;) {\n const waiting = await check(quietMillis, clock);\n if (waiting.length === 0 || performance.now() >= until) return waiting;\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, Math.min(50, until - performance.now()));\n await promise;\n }\n };\n /**\n * One task, then a frame: what the page's handlers for input did at once has run, a navigation\n * one of them started in a timer has been asked for, and their effect has painted. Says whether\n * the page painted, which a hidden one does not.\n */\n const settle = () => {\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, 0);\n return promise.then(painted);\n };\n return {\n wait,\n settle\n };\n };\n //#endregion\n //#region src/internal/reading/subjects.inpage.ts\n const states = (names) => (element, role) => {\n const { isDisabled, isInput } = names;\n const given = (attribute) => {\n const value = element.getAttribute(attribute);\n return value === \"true\" || (value === \"false\" ? false : void 0);\n };\n const checkable = element.hasAttribute(\"aria-checked\") || [\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"menuitemcheckbox\",\n \"menuitemradio\"\n ].includes(role ?? \"\");\n return {\n disabled: isDisabled(element),\n checked: checkable ? isInput(element) && element.checked || element.getAttribute(\"aria-checked\") === \"true\" : void 0,\n expanded: given(\"aria-expanded\"),\n selected: given(\"aria-selected\"),\n pressed: given(\"aria-pressed\"),\n focused: element.ownerDocument.activeElement === element,\n level: role === \"heading\" ? Number(element.getAttribute(\"aria-level\")) || Number(/^H([1-6])$/.exec(element.tagName)?.[1]) || 2 : void 0\n };\n };\n const subjects = (names, walked, matching, placing, stateOf) => {\n const { isDisabled, nameOf, refFor, roleOf, textOf } = names;\n const { acts, boxOf, controlOf, hitAt, inView } = walked;\n const { contextOf, known } = placing;\n /** What the outline lists as a control, with a ref: something a person would act on. */\n const isControl = (element, role, style, rect, insidePointer) => acts(element, role) || style.cursor === \"pointer\" && !insidePointer && rect.width > 0 && rect.height > 0;\n /**\n * The elements in scope that match a query, in tree order. Without text, an element matches\n * when it has a role or is a control. With text, any element can, but text inside a control or\n * heading is that control's or heading's, and an element is left out when one inside it\n * matches too: the smallest element showing the text is found, not each one around it.\n */\n const matched = (request) => {\n const { at } = request;\n const matches = matching.compile(request);\n const byText = request.text !== null;\n const viewport = request.scope === \"viewport\";\n const read = known();\n if (request.selector !== null) try {\n document.querySelector(request.selector);\n } catch {\n return { invalid: `${JSON.stringify(request.selector)} is not a CSS selector` };\n }\n const eligible = (element) => (request.selector === null || element.matches(request.selector)) && (request.state !== \"enabled\" || !isDisabled(element));\n const entries = [];\n const open = [];\n const named = (entry) => entry.name ??= nameOf(entry.element, entry.role);\n const placed = (entry) => entry.context ??= contextOf(entry.element, read);\n const judge = (entry, text) => matches({\n role: entry.role,\n name: () => named(entry),\n text,\n context: () => placed(entry)\n });\n const hit = at === null ? null : hitAt(document, at.x, at.y);\n if (hit !== null) {\n const element = controlOf(hit);\n const { x, y, width, height } = boxOf(element);\n const entry = {\n element,\n rect: new DOMRect(x, y, width, height),\n role: roleOf(element, request.role !== null),\n matched: false\n };\n entry.matched = eligible(element) && judge(entry, () => textOf(element));\n entries.push(entry);\n }\n if (at === null) walked.visit(null, viewport, {\n pointer: false,\n owned: false\n }, {\n enter: (element, style, rect, state) => {\n const role = roleOf(element, request.role !== null);\n const control = isControl(element, role, style, rect, state.pointer);\n const unit = control || role === \"heading\";\n const entry = eligible(element) && (byText ? unit || !state.owned : request.selector !== null || role !== null || control) && (!viewport || inView(rect)) ? {\n element,\n rect,\n role,\n matched: false\n } : void 0;\n if (entry !== void 0) entries.push(entry);\n open.push({\n entry,\n inline: style.display === \"inline\",\n parts: [],\n inside: false\n });\n return {\n pointer: state.pointer || style.cursor === \"pointer\",\n owned: state.owned || unit\n };\n },\n text: byText ? (node) => open.at(-1)?.parts.push(node.textContent ?? \"\") : void 0,\n leave: () => {\n const closed = open.pop();\n const parent = open.at(-1);\n if (closed === void 0) return;\n const { entry } = closed;\n const text = closed.parts.join(\"\");\n if (parent !== void 0) parent.parts.push(closed.inline ? text : ` ${text} `);\n if (entry !== void 0 && !(byText && closed.inside)) entry.matched = judge(entry, () => text);\n if (parent !== void 0) parent.inside ||= closed.inside || entry?.matched === true;\n }\n });\n return {\n entries: entries.filter((entry) => entry.matched),\n named,\n placed\n };\n };\n const find = (request) => {\n const result = matched(request);\n if (result.invalid !== void 0) return { invalid: result.invalid };\n const { entries, named, placed } = result;\n return { found: entries.map((entry) => ({\n ref: refFor(entry.element),\n subject: {\n role: entry.role,\n name: named(entry),\n tag: entry.element.tagName.toLowerCase(),\n context: placed(entry)\n },\n box: {\n x: Math.round(entry.rect.x),\n y: Math.round(entry.rect.y),\n width: Math.round(entry.rect.width),\n height: Math.round(entry.rect.height)\n },\n inViewport: inView(entry.rect),\n state: stateOf(entry.element, entry.role)\n })) };\n };\n /** The elements `find` would find, in tree order, with no refs given. */\n const elementsOf = (request) => {\n const result = matched(request);\n return result.invalid !== void 0 ? { invalid: result.invalid } : result.entries.map((entry) => entry.element);\n };\n return {\n find,\n elementsOf,\n isControl,\n stateOf\n };\n };\n //#endregion\n //#region src/internal/reading/text.inpage.ts\n const text = (names, walked) => {\n const { isHtml, isInput, isSecret, isSelect, isTextArea, lookup } = names;\n const valueless = [\n \"checkbox\",\n \"radio\",\n \"button\",\n \"submit\",\n \"reset\",\n \"image\",\n \"file\"\n ];\n /** What a field holds, or undefined for an element that holds nothing entered. */\n const valueOf = (element) => {\n if (isInput(element)) return valueless.includes(element.type) ? void 0 : element.value;\n if (isTextArea(element)) return element.value;\n if (isSelect(element)) return Array.from(element.selectedOptions, (option) => option.text).join(\", \");\n const parent = element.parentElement;\n return isHtml(element) && element.isContentEditable && !(parent !== null && isHtml(parent) && parent.isContentEditable) ? element.innerText : void 0;\n };\n /** What a field shows: `••••` unless `unmask`, and always for a secret field; \"\" when empty. */\n const shown = (element, unmask) => {\n const value = valueOf(element);\n if (value === void 0 || value.trim() === \"\") return value === void 0 ? void 0 : \"\";\n return unmask && !isSecret(element) ? value : \"••••\";\n };\n /** Lines cut after the last whole line within `max` characters, or at `max` when none is. */\n const cut = (lines, max) => {\n if (lines.length <= max) return {\n text: lines,\n truncated: false\n };\n const end = lines.lastIndexOf(\"\\n\", max);\n return {\n text: lines.slice(0, end > 0 ? end : max),\n truncated: true\n };\n };\n /**\n * What the viewport, or one element whole, shows as text: a line per block, table cells apart by\n * a tab, and each field as `shown` gives it.\n */\n const lines = (root, unmask) => {\n const lines = [];\n let line = \"\";\n const end = () => {\n const words = line.replace(/[^\\S\\t]+/g, \" \").replace(/ ?\\t ?/g, \" \").trim();\n if (words !== \"\") lines.push(words);\n line = \"\";\n };\n walked.visit(root, root === null, false, {\n enter: (element, style) => {\n const { display } = style;\n const value = shown(element, unmask);\n const block = !display.startsWith(\"inline\") && display !== \"contents\" && display !== \"table-cell\";\n if (display === \"table-cell\") line += \" \";\n if (block || element.tagName === \"BR\") end();\n if (value === void 0 && !(isInput(element) && valueless.includes(element.type))) return block;\n const label = isInput(element) && /^(button|submit|reset)$/.test(element.type);\n line += ` ${value ?? (label ? element.value : \"\")} `;\n if (block) end();\n },\n text: (node) => {\n line += node.textContent ?? \"\";\n },\n leave: (_, block) => {\n if (block) end();\n }\n });\n end();\n return lines.join(\"\\n\");\n };\n const read = (request) => {\n const root = request.ref === null ? null : lookup(request.ref);\n return root === void 0 ? null : {\n ...cut(lines(root, request.unmask), request.maxChars),\n url: location.href,\n title: document.title\n };\n };\n return {\n cut,\n lines,\n read,\n shown\n };\n };\n //#endregion\n //#region src/internal/reading/walk.inpage.ts\n const walk = (names) => {\n const { interactiveRoles, isElement, isFrame, isInput, parentOf, roleOf } = names;\n const skipped = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE HEAD META LINK SVG\".split(\" \"));\n /** Whether a box, in top-document pixels, meets the viewport. */\n const inView = (rect, width = innerWidth, height = innerHeight) => rect.right > 0 && rect.bottom > 0 && rect.left < width && rect.top < height;\n /** Whether an element reached on its own shows, by the walk's rule and its ancestors'. */\n const visible = (element) => {\n if (element.closest(\"[aria-hidden=true]\") !== null) return false;\n if (element.checkVisibility({\n opacityProperty: true,\n visibilityProperty: true\n })) return true;\n if (getComputedStyle(element).display !== \"contents\") return false;\n for (let node = element; node !== null; node = parentOf(node)) {\n const style = getComputedStyle(node);\n if (style.display === \"none\" || style.opacity === \"0\" || node === element && style.visibility !== \"visible\") return false;\n }\n return true;\n };\n const untransformed = (frame, rect) => {\n if (rect.width !== frame.offsetWidth || rect.height !== frame.offsetHeight) return false;\n let ancestor = frame;\n while (ancestor !== null) {\n const style = (ancestor.ownerDocument.defaultView ?? window).getComputedStyle(ancestor);\n if (style.transform !== \"none\" || style.scale !== \"none\" || style.rotate !== \"none\" || style.perspective !== \"none\" || style.zoom !== \"1\") return false;\n ancestor = parentOf(ancestor);\n }\n return true;\n };\n /** The element painted at a point, inside shadow roots and same-origin frames. */\n const hitAt = (root, x, y) => {\n let hit = root.elementFromPoint(x, y);\n while (hit?.shadowRoot !== null && hit?.shadowRoot !== void 0) {\n const inner = hit.shadowRoot.elementFromPoint(x, y);\n if (inner === null || inner === hit) break;\n hit = inner;\n }\n if (hit !== null && isFrame(hit)) {\n const document = hit.contentDocument;\n if (document !== null) {\n const rect = hit.getBoundingClientRect();\n if (untransformed(hit, rect)) return hitAt(document, x - rect.left - hit.clientLeft, y - rect.top - hit.clientTop) ?? hit;\n }\n }\n return hit;\n };\n /** Whether its role or a click handler makes an element a control. */\n const acts = (element, role) => isInput(element) && element.type !== \"hidden\" || role !== null && (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\") || element.hasAttribute(\"onclick\");\n const controlOf = (hit) => {\n let element = hit;\n while (element !== null) {\n if (acts(element, roleOf(element))) return element;\n element = parentOf(element);\n }\n return hit;\n };\n /** An element's box in top-document viewport pixels, through the frames around it. */\n const boxOf = (element) => {\n const { x, y, width, height } = element.getBoundingClientRect();\n const frame = element.ownerDocument.defaultView?.frameElement ?? null;\n if (frame === null) return {\n x,\n y,\n width,\n height\n };\n const outer = boxOf(frame);\n return {\n x: x + outer.x + frame.clientLeft,\n y: y + outer.y + frame.clientTop,\n width,\n height\n };\n };\n /** What is painted where pinned things sit, what is pinned in view, and every element holding it. */\n const painted = (width, height) => {\n const keep = /* @__PURE__ */ new Set();\n const hold = (element) => {\n for (let node = element; node !== null && !keep.has(node); node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null) keep.add(node);\n };\n for (const y of [\n 8,\n 48,\n height / 2,\n height - 48,\n height - 8\n ]) for (const x of [\n 8,\n 48,\n width / 4,\n width / 2,\n width * 3 / 4,\n width - 48,\n width - 8\n ]) if (x >= 0 && y >= 0 && x < width && y < height) {\n hold(hitAt(document, x, y));\n for (const beneath of document.elementsFromPoint(x, y)) hold(beneath);\n }\n for (const element of Array.from(document.querySelectorAll(\":modal, :popover-open\"))) hold(element);\n for (const element of Array.from(document.querySelectorAll(\"[style*=\\\"fixed\\\" i]\"))) if (inView(element.getBoundingClientRect(), width, height)) hold(element);\n return keep;\n };\n /**\n * Visit `root` and what it holds, or the whole document when `root` is null. With `viewport`,\n * a subtree outside the viewport is skipped, as described above.\n */\n const visit = (root, viewport, state, visitor) => {\n const { innerWidth: width, innerHeight: height } = window;\n let keep;\n const children = (parent, inner, dx, dy) => {\n const nodes = visitor.text === void 0 ? parent.children : parent.childNodes;\n for (const node of Array.from(nodes)) if (node.nodeType === Node.TEXT_NODE) visitor.text?.(node, inner);\n else if (isElement(node) && (visitor.admit === void 0 || visitor.admit(node, inner))) one(node, inner, dx, dy);\n };\n const one = (element, outer, dx, dy) => {\n if (skipped.has(element.tagName.toUpperCase())) return;\n const local = element.getBoundingClientRect();\n const rect = new DOMRect(local.x + dx, local.y + dy, local.width, local.height);\n if (viewport && local.width > 0 && local.height > 0 && !inView(rect, width, height) && !(keep ??= painted(width, height)).has(element)) {\n visitor.outside?.(rect);\n return;\n }\n const style = getComputedStyle(element);\n if (style.display === \"none\" || style.opacity === \"0\" || element.getAttribute(\"aria-hidden\") === \"true\") return;\n if (!visible(element)) {\n for (const child of Array.from(element.children)) one(child, outer, dx, dy);\n return;\n }\n const inner = visitor.enter(element, style, rect, outer);\n if (inner === void 0) return;\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n if (body !== null && body !== void 0) children(body, inner, rect.x, rect.y);\n } else {\n if (element.shadowRoot !== null) children(element.shadowRoot, inner, dx, dy);\n children(element, inner, dx, dy);\n }\n visitor.leave?.(element, inner);\n };\n if (root === null) children(document, state, 0, 0);\n else one(root, state, 0, 0);\n };\n return {\n acts,\n boxOf,\n controlOf,\n hitAt,\n inView,\n visible,\n visit\n };\n };\n //#endregion\n //#region src/internal/timeline/changes.inpage.ts\n const changes = (names, walked, placing, kept, seeing, marking, recorder) => {\n const { clean, isInput, roleOf, nameOf } = names;\n const groups = \"tr,[role=row],form,dialog,[role=dialog],[role=alertdialog]\";\n /** Whether `element` lies in what an input on `target` acted on, its group, or what it controls. */\n const local = (target, element) => {\n const controls = target.closest(\"[aria-controls]\")?.getAttribute(\"aria-controls\") ?? \"\";\n const group = target.closest(groups);\n return target.contains(element) || group?.contains(element) === true || controls.split(/\\s+/).some((id) => id !== \"\" && document.getElementById(id)?.contains(element) === true);\n };\n /** What an element sits in, or sat in as it went. */\n const parentOf = (key) => key instanceof Element ? key.isConnected ? key.parentElement : marking.placeOf(key) ?? null : null;\n const fluxMillis = 1e4;\n const stillMillis = 2e3;\n /**\n * Each input a change may follow, with what the page did before it: what changed in the 10 s\n * before, the parents that gained or lost a child then, and whether nothing changed, and nothing\n * was let go, in the 2 s before. What holds the input's target, as a menu holds its item, came\n * with it, so it counts only as changing itself.\n */\n const before = () => {\n const inputs = recorder.inputs();\n if (inputs.length === 0) return [];\n const { tracks, losses } = kept.recent();\n return inputs.map(({ at, target }) => {\n const changed = /* @__PURE__ */ new Set();\n const moved = /* @__PURE__ */ new Set();\n let still = losses.every((lost) => lost >= at || lost < at - stillMillis);\n for (const { key, kind, initial, samples } of tracks) {\n const prior = samples.flatMap(({ at: when, shown }, index) => kind === \"value\" || when >= at || when < at - fluxMillis ? [] : [shown === null || (index === 0 ? initial : samples[index - 1]?.shown) === null]);\n if (prior.length > 0) changed.add(key);\n if (prior.length === 0 || key instanceof Element && key.contains(target)) continue;\n if (prior.includes(true)) moved.add(parentOf(key));\n if (samples.some(({ at: when }) => when < at && when >= at - stillMillis)) still = false;\n }\n return {\n at,\n target,\n changed,\n moved,\n still\n };\n });\n };\n /** The input a change followed, on the page's clock, where `Change.cause`'s rule names one. */\n const causeOf = (one, element, inputs) => {\n const parent = parentOf(one.track.key);\n for (const input of inputs.toReversed()) {\n const after = one.startedAt - input.at;\n if (after < 0) continue;\n if (after > 3e3) break;\n if (!(one.track.known >= input.at - fluxMillis || input.changed.has(one.track.key) || parent !== null && input.moved.has(parent)) && (local(input.target, element) || after <= 500 && input.still)) return input.at;\n }\n };\n const describe = (one, known, unmask, inputs) => {\n const { track, kind, before, after, lowest, highest, ...times } = one;\n const element = track.key instanceof Element ? track.key : null;\n const where = element?.isConnected === true ? element : marking.placeOf(track.key) ?? null;\n const box = where === null ? void 0 : walked.boxOf(where);\n const role = element === null ? null : roleOf(element);\n const field = kind === \"value\";\n const checkable = element !== null && isInput(element) && /^(checkbox|radio)$/.test(element.type);\n const masked = (value) => value === void 0 || !field || unmask || checkable || value === \"\" ? value : \"••••\";\n return {\n ...times,\n kind,\n subject: {\n role,\n name: element === null ? \"\" : field ? nameOf(element, role) : clean(element.getAttribute(\"aria-label\"), 120),\n tag: element === null ? \"title\" : element.tagName.toLowerCase(),\n context: kind === \"title\" || where === null ? {} : placing.contextOf(where, known)\n },\n box: box === void 0 || box.width === 0 && box.height === 0 ? void 0 : box,\n before: masked(before),\n after: masked(after),\n lowest: field ? void 0 : lowest,\n highest: field ? void 0 : highest,\n cause: field || where === null ? void 0 : causeOf(one, where, inputs)\n };\n };\n /** What changed after `since`, up to `until`, and no later than now. */\n const read = (request) => {\n const now = performance.timeOrigin + performance.now();\n recorder.start();\n seeing.settle();\n const until = Math.min(request.until ?? now, now);\n const { from, dropped, folded } = kept.read(request.since ?? Number.NEGATIVE_INFINITY, until, now);\n const known = placing.known();\n const inputs = before();\n return {\n until,\n from,\n dropped,\n records: folded.map((one) => describe(one, known, request.unmask, inputs))\n };\n };\n return { read };\n };\n //#endregion\n //#region src/internal/timeline/fold.inpage.ts\n const fold = () => {\n /** The one number some words show, such as 61240 in \"$61,240\"; none for none or several. */\n const number = (words) => {\n const found = words.match(/[-+−]?\\d[\\d,]*(?:\\.\\d+)?/g);\n const value = Number(found?.length === 1 ? found[0]?.replaceAll(\",\", \"\").replace(\"−\", \"-\") : \"\");\n return found?.length === 1 && Number.isFinite(value) ? [value] : [];\n };\n /** A track's changes after `since`, up to `until`, if one was seen in view. */\n const over = (track, since, until) => {\n const inside = track.samples.filter((sample) => sample.at > since && sample.at <= until);\n const first = inside[0];\n const last = inside.at(-1);\n if (first === void 0 || last === void 0 || !inside.some((sample) => sample.seen === true)) return void 0;\n const prior = track.samples[track.samples.indexOf(first) - 1];\n const lost = track.known <= since ? track.known : void 0;\n const start = prior === void 0 ? lost === void 0 ? void 0 : track.initial : prior.shown;\n const words = [start, ...inside.map((sample) => sample.shown)].filter((each) => typeof each === \"string\");\n const numbers = words.flatMap(number);\n const ranged = inside.length > 1 && numbers.length === words.length;\n const kind = track.kind !== \"content\" ? track.kind : last.shown === null ? start === null ? \"brief\" : \"disappeared\" : start === null ? \"appeared\" : \"text\";\n return {\n track,\n kind,\n startedAt: first.at,\n at: last.at,\n before: kind === \"disappeared\" ? words.at(-1) : start ?? void 0,\n after: kind === \"brief\" ? words.at(-1) : last.shown ?? void 0,\n count: inside.length,\n lowest: ranged ? words[numbers.indexOf(Math.min(...numbers))] : void 0,\n highest: ranged ? words[numbers.indexOf(Math.max(...numbers))] : void 0,\n earlier: prior?.at ?? (lost === Number.NEGATIVE_INFINITY ? void 0 : lost)\n };\n };\n /**\n * How readily a track gives way when the record is full: one that holds no change first, then\n * one that keeps changing, one never seen in view and one that has gone; news never does.\n */\n const rank = ({ samples: [only, ...more] }) => only === void 0 ? 4 : more.length > 0 ? 3 : only.seen === false ? 2 : only.shown === null ? 1 : 0;\n return {\n number,\n over,\n rank\n };\n };\n //#endregion\n //#region src/internal/timeline/history.inpage.ts\n const history = (folding, bounds = {\n tracks: 256,\n samples: 32,\n retention: 6e4\n }) => {\n const { tracks: maxTracks, samples: maxSamples, retention } = bounds;\n const tracks = /* @__PURE__ */ new Map();\n let refused = /* @__PURE__ */ new WeakSet();\n let losses = [];\n let lastLoss = Number.NEGATIVE_INFINITY;\n const gone = [];\n let begun;\n const lose = (at, count) => {\n const last = losses.at(-1);\n if (count <= 0) return;\n lastLoss = Math.max(lastLoss, at);\n if (last?.[0] === at) last[1] += count;\n else losses.push([at, count]);\n if (losses.length > 256) losses.shift();\n };\n const latest = (track) => track.samples.at(-1)?.at ?? Number.NEGATIVE_INFINITY;\n const drop = (track) => {\n tracks.delete(track.key);\n gone.push(track.key);\n };\n let version = 0;\n let barren = -1;\n /** What gives way for a newcomer: one that holds no change, then one that keeps changing. */\n const victim = () => {\n let chosen;\n let rank = 0;\n for (const track of barren === version ? [] : tracks.values()) {\n const next = folding.rank(track);\n if (next > rank) [chosen, rank] = [track, next];\n if (rank === 4) break;\n }\n if (chosen === void 0) barren = version;\n return chosen;\n };\n const evict = (track) => {\n drop(track);\n if (track.samples.length > 0) refused.add(track.key);\n for (const sample of track.samples) lose(sample.at, 1);\n };\n /** A key the record cannot keep: its change is counted. */\n const refuse = (key, at) => {\n refused.add(key);\n lose(at, 1);\n };\n /**\n * A new state for `key` at `at`: its sample, or none when it is no change or finds no room.\n * `initial` says what a key not yet kept showed before.\n */\n const note = (key, kind, at, shown, initial) => {\n let track = tracks.get(key);\n if (track === void 0) {\n const full = !refused.has(key) && tracks.size >= maxTracks;\n const out = full ? victim() : void 0;\n if (refused.has(key) || full && out === void 0) return refuse(key, at);\n const before = initial();\n if (shown !== void 0 && shown === before) return void 0;\n if (out !== void 0) evict(out);\n track = {\n key,\n kind,\n initial: before,\n known: Number.NEGATIVE_INFINITY,\n samples: []\n };\n tracks.set(key, track);\n }\n const { samples } = track;\n version++;\n if (samples.at(-1)?.at === at) samples.pop();\n const previous = samples.length === 0 ? track.initial : samples.at(-1)?.shown;\n if (shown !== void 0 && shown === previous) return void 0;\n const oldest = samples.length >= maxSamples ? samples.shift() : void 0;\n if (oldest !== void 0) {\n track.initial = oldest.shown;\n track.known = oldest.at;\n lose(oldest.at, 1);\n }\n const sample = {\n at,\n shown,\n seen: void 0\n };\n samples.push(sample);\n return sample;\n };\n /** Judge a sample as the page rendered it; a state that repeats the one before is no change. */\n const settle = (key, sample, shown, seen) => {\n const track = tracks.get(key);\n version++;\n if (sample.shown === void 0) sample.shown = shown;\n if (sample.seen === void 0) sample.seen = seen;\n if (track === void 0) return;\n let previous = track.initial;\n const changes = track.samples.filter((each) => {\n const same = each.shown !== void 0 && each.shown === previous;\n if (!same) previous = each.shown;\n return !same;\n });\n track.samples.splice(0, track.samples.length, ...changes);\n };\n /**\n * The window after `since`, up to `until`: where the record is whole, how many changes in it the\n * record let go, and each element's changes, oldest first by when they began.\n */\n const read = (since, until, now) => {\n for (const track of tracks.values()) if (latest(track) < now - retention) drop(track);\n return {\n from: Math.min(until, Math.max(begun ?? now, now - retention, lastLoss)),\n dropped: losses.reduce((sum, [at, count]) => at > since && at <= until ? sum + count : sum, 0),\n folded: [...tracks.values()].flatMap((track) => folding.over(track, since, until) ?? []).toSorted((left, right) => left.startedAt - right.startedAt)\n };\n };\n /** When something in view last changed, or something not yet judged; for a wait for stillness. */\n const changing = () => Math.max(begun ?? Number.NEGATIVE_INFINITY, ...Array.from(tracks.values(), (track) => track.samples.findLast((sample) => sample.seen !== false)?.at ?? Number.NEGATIVE_INFINITY));\n return {\n begin: (at) => {\n begun = at;\n },\n begun: () => begun !== void 0,\n clear: () => {\n for (const track of tracks.values()) drop(track);\n refused = /* @__PURE__ */ new WeakSet();\n losses = [];\n lastLoss = Number.NEGATIVE_INFINITY;\n begun = void 0;\n },\n changing,\n /** Keys whose tracks went since this was last asked, for the recorder to stop watching. */\n forgotten: () => gone.splice(0),\n has: (key) => tracks.has(key),\n /** Whether the record has let `key` go: its later changes are counted, never kept. */\n refuses: (key) => refused.has(key),\n lose,\n note,\n read,\n /** Each element's history, and when the record let changes go, for a read to judge causes. */\n recent: () => ({\n tracks: [...tracks.values()],\n losses: losses.map(([at]) => at)\n }),\n /** A track moves to the element that took its key's place, as a re-rendered price does. */\n rekey: (from, to) => {\n const track = tracks.get(from);\n if (track === void 0 || tracks.has(to)) return false;\n tracks.delete(from);\n track.key = to;\n tracks.set(to, track);\n return true;\n },\n settle\n };\n };\n //#endregion\n //#region src/internal/timeline/marks.inpage.ts\n const marks = (names, kept, seeing) => {\n const { clean, isElement, isHtml } = names;\n const unwritten = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE TITLE\".split(\" \"));\n const hiding = /display\\s*:\\s*none|visibility\\s*:\\s*hidden|opacity\\s*:\\s*0(?![.\\d])/i;\n let places = /* @__PURE__ */ new WeakMap();\n let title = \"\";\n const words = (text) => clean(text, 200) || null;\n const content = (element, at, shown, initial) => {\n const sample = kept.note(element, \"content\", at, shown, initial);\n if (sample !== void 0) seeing.look(element, sample);\n };\n /** What a text-only element said before this batch: its text with the batch undone. */\n const before = (leaf, records) => {\n let nodes = Array.from(leaf.childNodes);\n const old = /* @__PURE__ */ new Map();\n for (const record of records.toReversed()) if (record.type === \"characterData\") old.set(record.target, record.oldValue ?? \"\");\n else {\n const added = new Set(Array.from(record.addedNodes));\n nodes = nodes.filter((node) => !added.has(node));\n const next = record.nextSibling === null ? -1 : nodes.indexOf(record.nextSibling);\n nodes.splice(next === -1 ? nodes.length : next, 0, ...Array.from(record.removedNodes));\n }\n return words(nodes.map((node) => old.get(node) ?? node.textContent).join(\"\"));\n };\n const attribute = (element, { attributeName: name, oldValue: old }, at) => {\n const was = name === \"hidden\" ? old !== null : name === \"aria-hidden\" ? old === \"true\" : name === \"open\" ? element.tagName === \"DIALOG\" && old === null : name === \"style\" && hiding.test(old ?? \"\");\n if (name === \"style\" && !was && !hiding.test(element.getAttribute(\"style\") ?? \"\")) return;\n const state = seeing.state(element);\n if (!kept.has(element) && !was && state === void 0 && name !== \"open\") return seeing.glance(element);\n content(element, at, void 0, () => was || state === false ? null : name === \"open\" && old === null ? words(element.querySelector(\":scope > summary\")?.textContent) : words(element.textContent));\n };\n /** What one mutation added to and removed from `target`. */\n const nodes = (change, target, batch) => {\n const added = Array.from(change.addedNodes).slice(0, 64);\n const removed = Array.from(change.removedNodes).slice(0, 64);\n const text = [...added, ...removed].some((node) => !isElement(node) && /\\S/.test(node.textContent ?? \"\"));\n kept.lose(batch.at, Math.max(change.addedNodes.length, change.removedNodes.length) - 64);\n if (text) batch.owners.add(target);\n removed.forEach((gone, index) => {\n const node = added[index];\n if (!isElement(gone)) return;\n batch.left.add(gone);\n if (node !== void 0 && isElement(node) && kept.rekey(gone, node)) seeing.unwatch(gone);\n else if (kept.has(gone)) {\n places.set(gone, target);\n const sample = kept.note(gone, \"content\", batch.at, null, () => void 0);\n if (sample !== void 0) sample.seen = seeing.viewed(gone);\n seeing.unwatch(gone);\n }\n });\n for (const node of added) if (isElement(node) && isHtml(node) && !unwritten.has(node.tagName) && !node.isContentEditable) {\n if (kept.has(node) || !text && !batch.left.has(node)) {\n batch.arrived.add(node);\n content(node, batch.at, void 0, () => null);\n }\n }\n };\n /** Whether `element` is inside something this batch added, which tells it with its own words. */\n const inside = (element, arrived) => {\n for (let up = element.parentElement; arrived.size > 0 && up !== null; up = up.parentElement) if (arrived.has(up)) return true;\n return false;\n };\n const ownerOf = (change) => change.type === \"characterData\" ? change.target.parentElement : change.target;\n /** Mark what one batch of mutations changed, at `at`. */\n const mark = (records, at) => {\n const batch = {\n at,\n owners: /* @__PURE__ */ new Set(),\n arrived: /* @__PURE__ */ new Set(),\n left: /* @__PURE__ */ new Set()\n };\n let byOwner;\n for (const change of records) {\n const target = ownerOf(change);\n if (target === null || !isElement(target) || inside(target, batch.arrived)) continue;\n const known = kept.has(target) || kept.refuses(target);\n if (change.type !== \"attributes\") if (change.type === \"characterData\" || target.childElementCount === 0 && known) batch.owners.add(target);\n else nodes(change, target, batch);\n else if (isHtml(target) && target !== document.body && target !== document.documentElement) attribute(target, change, at);\n }\n for (const owner of batch.owners) {\n const leaf = owner.childElementCount === 0;\n if (kept.refuses(owner)) kept.lose(at, 1);\n if (kept.refuses(owner) || !isHtml(owner) || unwritten.has(owner.tagName)) continue;\n if (owner === document.body || owner.isContentEditable) continue;\n if (batch.arrived.has(owner) || inside(owner, batch.arrived)) continue;\n content(owner, at, leaf ? words(owner.textContent) : void 0, () => {\n byOwner ??= Map.groupBy(records, ownerOf);\n return leaf ? before(owner, byOwner.get(owner) ?? []) : void 0;\n });\n }\n if (document.title === title) return;\n const previous = words(title);\n const sample = kept.note(document, \"title\", at, words(title = document.title), () => previous);\n if (sample !== void 0) sample.seen = true;\n };\n return {\n mark,\n /** Where a removed element was, which gives its context. */\n placeOf: (key) => places.get(key),\n /** Start afresh, from the document's title now. */\n reset: () => {\n places = /* @__PURE__ */ new WeakMap();\n title = document.title;\n }\n };\n };\n //#endregion\n //#region src/internal/timeline/record.inpage.ts\n const record = (names, texts, kept, seeing, marking) => {\n const { isElement, isInput } = names;\n const epoch = () => performance.timeOrigin + performance.now();\n const declared = \"[role=alert],[role=status],[role=log],[role=dialog],[role=alertdialog],[aria-live],dialog,[popover]\";\n let running = false;\n let lastRead = 0;\n let focused = /* @__PURE__ */ new WeakMap();\n const inputs = [];\n const targetOf = (event) => {\n const target = event.composedPath()[0];\n return target instanceof Node && isElement(target) ? target : void 0;\n };\n /** A field's value as the record keeps it: a secret one's as `••••`, a box's checked or not. */\n const valueOf = (field) => isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\") ? field.checked ? \"checked\" : \"not checked\" : texts.shown(field, true);\n const onFocus = (event) => {\n const field = targetOf(event);\n const value = field === void 0 ? void 0 : valueOf(field);\n if (field !== void 0 && value !== void 0) focused.set(field, value);\n };\n const onValue = (event) => {\n const field = targetOf(event);\n const value = field === void 0 ? void 0 : valueOf(field);\n if (field === void 0 || value === void 0) return;\n const sample = kept.note(field, \"value\", epoch(), value, () => focused.get(field) ?? null);\n if (sample !== void 0) seeing.look(field, sample);\n };\n const note = (target) => {\n inputs.push({\n at: epoch(),\n target\n });\n if (inputs.length > 8) inputs.shift();\n };\n const onInput = (event) => {\n const target = targetOf(event);\n if (event.isTrusted && target !== void 0) note(target);\n };\n const listeners = [\n [\"focusin\", onFocus],\n [\"input\", onValue],\n [\"change\", onValue],\n [\"pointerdown\", onInput],\n [\"keydown\", onInput]\n ];\n const options = {\n capture: true,\n passive: true\n };\n const stop = () => {\n running = false;\n document.removeEventListener(\"DOMContentLoaded\", begin);\n observer.disconnect();\n for (const [type, listener] of listeners) document.removeEventListener(type, listener, options);\n seeing.clear();\n kept.clear();\n kept.forgotten();\n inputs.length = 0;\n focused = /* @__PURE__ */ new WeakMap();\n };\n const observer = new MutationObserver((records) => {\n const at = epoch();\n if (at - lastRead > 12e4) stop();\n else marking.mark(records, at);\n });\n const begin = () => {\n if (!running || kept.begun()) return;\n observer.observe(document, {\n subtree: true,\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributeFilter: [\n \"hidden\",\n \"open\",\n \"aria-hidden\",\n \"class\",\n \"style\"\n ],\n attributeOldValue: true\n });\n for (const [type, listener] of listeners) document.addEventListener(type, listener, options);\n marking.reset();\n for (const element of Array.from(document.querySelectorAll(declared)).slice(0, 64)) seeing.glance(element, true);\n kept.begin(epoch());\n };\n return {\n stop,\n /** Record from now, once the document is parsed; each read keeps the record going. */\n start: () => {\n lastRead = epoch();\n if (running) return;\n running = true;\n if (document.readyState === \"loading\") document.addEventListener(\"DOMContentLoaded\", begin, { once: true });\n else begin();\n },\n /**\n * Keep an input at `target` now, as a trusted one is kept: what a site does through its own\n * app, whose events the page sees as untrusted, so its changes can name their cause.\n */\n note,\n inputs: () => inputs\n };\n };\n //#endregion\n //#region src/internal/timeline/sight.inpage.ts\n const sight = (names, walked, texts, kept) => {\n const { clean } = names;\n const { visible } = walked;\n let viewed = /* @__PURE__ */ new WeakMap();\n let watching = /* @__PURE__ */ new WeakSet();\n let states = /* @__PURE__ */ new WeakMap();\n const waiting = /* @__PURE__ */ new Map();\n /** What an element shows: its words, if its style shows it. */\n const shownBy = (element) => element.isConnected && visible(element) ? clean(texts.lines(element, false), 200) || null : null;\n /** Settle what waited on an element; its words are read once, if one of them needs them. */\n const judge = (element, pending, seen, was) => {\n const shown = pending.some((sample) => sample.shown === void 0) ? shownBy(element) : void 0;\n for (const sample of pending) {\n const now = sample.shown === void 0 ? shown : sample.shown;\n kept.settle(element, sample, now, now === null ? was : seen);\n }\n };\n const observer = new IntersectionObserver((entries) => {\n for (const { target, isIntersecting } of entries) {\n const was = viewed.get(target) ?? false;\n const seen = isIntersecting && visible(target);\n const pending = waiting.get(target);\n viewed.set(target, seen);\n waiting.delete(target);\n if (pending !== void 0) judge(target, pending, seen, was);\n if (!kept.has(target)) {\n states.set(target, visible(target));\n unwatch(target);\n }\n }\n });\n /** Watch an element, asking for a fresh report even if it is watched already. */\n const watch = (element) => {\n watching.add(element);\n observer.unobserve(element);\n observer.observe(element);\n };\n const unwatch = (element) => {\n watching.delete(element);\n observer.unobserve(element);\n };\n return {\n /** Judge a sample at once if what it shows and whether it is in view are known, else on render. */\n look: (element, sample) => {\n const view = viewed.get(element);\n if (sample.shown !== void 0 && view !== void 0 && watching.has(element)) {\n sample.seen = view;\n return;\n }\n waiting.set(element, [...waiting.get(element) ?? [], sample]);\n watch(element);\n },\n /**\n * Look at an element once, for its state when it next changes: as it renders, or `now`, by its\n * style, as for the few the record looks at as it starts.\n */\n glance: (element, now = false) => {\n if (now) states.set(element, visible(element));\n if (!watching.has(element)) watch(element);\n },\n /** Whether the style of an element looked at once showed it, if it was. */\n state: (element) => states.get(element),\n /** Whether a watched element was in view as the page last rendered it. */\n viewed: (element) => viewed.get(element) ?? false,\n unwatch,\n /** Judge now what the page has not rendered since it changed, as a hidden tab never does. */\n settle: () => {\n for (const [element, pending] of waiting) {\n const seen = element.isConnected && walked.inView(element.getBoundingClientRect()) && visible(element);\n judge(element, pending, seen, viewed.get(element) ?? false);\n viewed.set(element, seen);\n }\n waiting.clear();\n for (const key of kept.forgotten()) if (key instanceof Element) unwatch(key);\n },\n clear: () => {\n observer.disconnect();\n waiting.clear();\n viewed = /* @__PURE__ */ new WeakMap();\n watching = /* @__PURE__ */ new WeakSet();\n states = /* @__PURE__ */ new WeakMap();\n }\n };\n };\n //#endregion\n //#region src/internal/page/compose.inpage.ts\n const compose = (parts, next) => {\n const named = parts.names(parts.elements());\n if (next !== void 0) named.refs.next = next;\n const walked = parts.walk(named);\n const placing = parts.context(named, walked);\n const matching = parts.match();\n const subjected = parts.subjects(named, walked, matching, placing, parts.states(named));\n const texts = parts.text(named, walked);\n const controlled = parts.controls(named, subjected, texts);\n const kept = parts.history(parts.fold());\n const seeing = parts.sight(named, walked, texts, kept);\n const marking = parts.marks(named, kept, seeing);\n const recorder = parts.record(named, texts, kept, seeing, marking);\n const url = parts.addresses();\n const read = parts.outline(named, walked, subjected, texts, controlled, url);\n const readiness = parts.ready(walked, texts, kept);\n const overlaid = parts.overlay(named);\n const posing = parts.pose(named);\n return {\n named,\n walked,\n placing,\n overlaid,\n posing,\n recorder,\n url,\n reads: {\n refs: named.refs,\n snapshot: read.snapshot,\n find: subjected.find,\n layout: parts.layout(named, walked, subjected, matching, placing).read,\n overlay: overlaid.draw,\n pose: posing.set,\n unpose: posing.clear,\n until: parts.expectations(named, subjected, matching).until,\n text: texts.read,\n record: recorder.start,\n stopRecord: recorder.stop,\n changes: parts.changes(named, walked, placing, kept, seeing, marking, recorder).read,\n ready: readiness.wait,\n settle: readiness.settle,\n viewport: read.viewport\n }\n };\n };\n //#endregion\n //#region src/internal/page/overlay.inpage.ts\n const overlay = (names) => {\n const svgNamespace = \"http://www.w3.org/2000/svg\";\n let host;\n let root;\n const mount = () => {\n if (host === void 0 || root === void 0) {\n host = document.createElement(\"div\");\n root = host.attachShadow({ mode: \"closed\" });\n names.adopt(host);\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(\"svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible }\");\n root.adoptedStyleSheets = [sheet];\n }\n const zoom = Number(getComputedStyle(document.documentElement).zoom) || 1;\n for (const [name, value] of Object.entries({\n all: \"initial\",\n display: \"block\",\n position: \"fixed\",\n left: \"0\",\n top: \"0\",\n width: \"100vw\",\n height: \"100vh\",\n \"pointer-events\": \"none\",\n \"z-index\": \"2147483647\",\n contain: \"strict\",\n zoom: String(1 / zoom)\n })) host.style.setProperty(name, value, \"important\");\n if (host.parentNode !== document.documentElement) document.documentElement.append(host);\n return root;\n };\n const boxes = (drawing) => Array.from(drawing.children).slice(0, 32).map((part) => {\n const { x, y, width, height } = part.getBoundingClientRect();\n return {\n x,\n y,\n width,\n height\n };\n }).filter((box) => box.width > 0 && box.height > 0);\n /**\n * Draw an SVG document over the viewport, in place of what was drawn, or take the layer away\n * with null. Says where the drawing's parts are. Its scripts and handlers are dropped.\n */\n const draw = (markup) => {\n if (markup === null) {\n host?.remove();\n return [];\n }\n const parsed = new DOMParser().parseFromString(markup, \"image/svg+xml\");\n const drawing = parsed.documentElement;\n if (parsed.getElementsByTagName(\"parsererror\").length > 0 || drawing.namespaceURI !== svgNamespace || drawing.localName !== \"svg\") throw new Error(\"the overlay's markup is not an SVG document\");\n for (const script of Array.from(drawing.getElementsByTagName(\"script\"))) script.remove();\n for (const element of [drawing, ...Array.from(drawing.querySelectorAll(\"*\"))]) for (const attribute of Array.from(element.attributes)) if (/^on/i.test(attribute.name)) element.removeAttribute(attribute.name);\n const shown = document.importNode(drawing, true);\n mount().replaceChildren(shown);\n return boxes(shown);\n };\n return {\n draw,\n mount\n };\n };\n //#endregion\n //#region src/internal/page/pose.inpage.ts\n const pose = (names) => {\n const posed = /* @__PURE__ */ new Map();\n const isHtml = (element) => \"offsetWidth\" in element;\n const laidOut = (element, applied) => {\n const style = getComputedStyle(element);\n const [cx = 0, cy = 0] = style.transformOrigin.split(\" \").map(Number.parseFloat);\n const own = style.transform === \"none\" ? new DOMMatrix() : new DOMMatrix(style.transform);\n const whole = applied === void 0 ? own : new DOMMatrix().translate(applied.x, applied.y).rotate(applied.rotate).scale(applied.sx, applied.sy).multiply(own);\n const drawn = element.getBoundingClientRect();\n const plain = whole.isIdentity;\n const width = plain ? drawn.width : element.offsetWidth;\n const height = plain ? drawn.height : element.offsetHeight;\n let left = Infinity;\n let top = Infinity;\n for (const [x, y] of [\n [0, 0],\n [width, 0],\n [0, height],\n [width, height]\n ]) {\n const corner = whole.transformPoint({\n x: x - cx,\n y: y - cy\n });\n left = Math.min(left, corner.x + cx);\n top = Math.min(top, corner.y + cy);\n }\n const origin = {\n x: drawn.x - left + cx,\n y: drawn.y - top + cy\n };\n const middle = own.transformPoint({\n x: width / 2 - cx,\n y: height / 2 - cy\n });\n return {\n origin,\n middle: {\n x: origin.x + middle.x,\n y: origin.y + middle.y\n }\n };\n };\n const apply = (element, request) => {\n const known = posed.get(element);\n const { origin, middle } = laidOut(element, known?.applied);\n const about = request.origin ?? middle;\n const away = {\n x: about.x - origin.x,\n y: about.y - origin.y\n };\n const turned = new DOMMatrix().rotate(request.rotate).scale(request.sx, request.sy).transformPoint(away);\n const applied = {\n x: request.dx + away.x - turned.x,\n y: request.dy + away.y - turned.y,\n rotate: request.rotate,\n sx: request.sx,\n sy: request.sy\n };\n const frame = {\n translate: `${applied.x}px ${applied.y}px`,\n rotate: `${applied.rotate}deg`,\n scale: `${applied.sx} ${applied.sy}`\n };\n if (known === void 0) {\n const effect = new KeyframeEffect(element, [frame, frame], {\n duration: Infinity,\n fill: \"both\"\n });\n const animation = new Animation(effect, document.timeline);\n animation.play();\n posed.set(element, {\n animation,\n effect,\n applied\n });\n } else {\n known.effect.setKeyframes([frame, frame]);\n known.applied = applied;\n }\n };\n const takeOff = (element) => {\n posed.get(element)?.animation.cancel();\n posed.delete(element);\n };\n /**\n * The elements `requests` name, or the first that names none in the current document, or one\n * that is not an HTML element; then, to apply them, a function that poses them and takes poses\n * off every other element.\n */\n const prepare = (requests) => {\n const elements = [];\n for (const request of requests) {\n const element = names.lookup(request.ref);\n const { dx, dy, sx, sy, rotate, origin } = request;\n if (element === void 0) return { stale: request.ref };\n if (!isHtml(element)) return { invalid: `${request.ref} is not an HTML element` };\n if (![\n dx,\n dy,\n sx,\n sy,\n rotate,\n origin?.x ?? 0,\n origin?.y ?? 0\n ].every(Number.isFinite)) return { invalid: `${request.ref}'s pose is not finite numbers` };\n elements.push(element);\n }\n return { apply: () => {\n for (const element of Array.from(posed.keys())) if (!elements.includes(element)) takeOff(element);\n requests.forEach((request, index) => {\n const element = elements[index];\n if (element !== void 0) apply(element, request);\n });\n } };\n };\n const set = (requests) => {\n const prepared = prepare(requests);\n if (\"apply\" in prepared) {\n prepared.apply();\n return {};\n }\n return prepared;\n };\n const clear = () => {\n for (const element of Array.from(posed.keys())) takeOff(element);\n };\n return {\n prepare,\n set,\n clear\n };\n };\n //#endregion\n //#region src/internal/page/time.inpage.ts\n const time = (overlaid, posing) => {\n const step = (request) => {\n const posed = request.poses === void 0 ? void 0 : posing.prepare(request.poses);\n if (posed !== void 0 && !(\"apply\" in posed)) return {\n told: false,\n drawn: null,\n scroll: {\n x: scrollX,\n y: scrollY\n },\n ...posed\n };\n if (request.scroll !== null) scrollTo({\n left: scrollX,\n top: request.scroll,\n behavior: \"instant\"\n });\n const detail = {\n op: request.op,\n by: request.by\n };\n const told = !document.dispatchEvent(new CustomEvent(request.clock, {\n detail,\n cancelable: true\n }));\n posed?.apply();\n return {\n told,\n drawn: request.markup === void 0 ? null : overlaid.draw(request.markup),\n scroll: {\n x: scrollX,\n y: scrollY\n }\n };\n };\n return { step };\n };\n //#endregion\n //#region src/internal/page/bridge.ts\n const parts = {\n compose,\n elements,\n names,\n walk,\n match,\n context,\n subjects,\n states,\n expectations,\n text,\n layout,\n controls,\n fold,\n history,\n sight,\n marks,\n record,\n changes,\n ready,\n outline,\n targets,\n evidence,\n guard,\n edit,\n overlay,\n pose,\n time,\n addresses\n };\n function install(parts) {\n const source = install.toString() + Object.entries(parts).map(([name, factory]) => name + factory.toString()).join(\"\");\n let version = 2166136261;\n for (let index = 0; index < source.length; index++) version = Math.imul(version ^ source.charCodeAt(index), 16777619);\n version >>>= 0;\n const installed = globalThis.__effectBrowser;\n if (installed !== void 0 && installed.version === version) return installed;\n installed?.dispose?.();\n const { named, walked, placing, overlaid, posing, reads } = parts.compose(parts, installed?.refs?.next);\n const located = parts.targets(named, walked, placing);\n const guarded = parts.guard(named, located, parts.evidence(named, placing));\n const edited = parts.edit(named, guarded, placing);\n const api = {\n ...reads,\n version,\n dispose: reads.stopRecord,\n step: parts.time(overlaid, posing).step,\n point: located.point,\n scrollPlan: located.scrollPlan,\n screenSize: () => ({\n width: screen.width,\n height: screen.height,\n ratio: devicePixelRatio\n }),\n prepareInput: guarded.prepareInput,\n validateInput: guarded.validateInput,\n typeable: edited.typeable,\n focus: edited.focus,\n focusOn: edited.focusOn,\n select: edited.select\n };\n globalThis.__effectBrowser = api;\n return api;\n }\n //#endregion\n return install(parts);\n})();\n\nreturn pageScript;})()";
|
|
631
492
|
/**
|
|
632
|
-
* What
|
|
633
|
-
*
|
|
493
|
+
* What new documents run before their own scripts: the page clock under its event name, first, so
|
|
494
|
+
* a caller's script that keeps a timer keeps the clock's, and then the caller's scripts, each
|
|
495
|
+
* everywhere or as a block where its `match` allows.
|
|
634
496
|
*/
|
|
635
|
-
const
|
|
636
|
-
until: Schema.Finite,
|
|
637
|
-
from: Schema.Finite,
|
|
638
|
-
dropped: Schema.Int,
|
|
639
|
-
records: Schema.Array(Change)
|
|
640
|
-
});
|
|
641
|
-
//#endregion
|
|
642
|
-
//#region src/internal/timeline/fold.inpage.ts
|
|
643
|
-
const fold = () => {
|
|
644
|
-
/** The one number some words show, such as 61240 in "$61,240"; none for none or several. */
|
|
645
|
-
const number = (words) => {
|
|
646
|
-
const found = words.match(/[-+−]?\d[\d,]*(?:\.\d+)?/g);
|
|
647
|
-
const value = Number(found?.length === 1 ? found[0]?.replaceAll(",", "").replace("−", "-") : "");
|
|
648
|
-
return found?.length === 1 && Number.isFinite(value) ? [value] : [];
|
|
649
|
-
};
|
|
650
|
-
/** A track's changes after `since`, up to `until`, if one was seen in view. */
|
|
651
|
-
const over = (track, since, until) => {
|
|
652
|
-
const inside = track.samples.filter((sample) => sample.at > since && sample.at <= until);
|
|
653
|
-
const first = inside[0];
|
|
654
|
-
const last = inside.at(-1);
|
|
655
|
-
if (first === void 0 || last === void 0 || !inside.some((sample) => sample.seen === true)) return void 0;
|
|
656
|
-
const prior = track.samples[track.samples.indexOf(first) - 1];
|
|
657
|
-
const lost = track.known <= since ? track.known : void 0;
|
|
658
|
-
const start = prior === void 0 ? lost === void 0 ? void 0 : track.initial : prior.shown;
|
|
659
|
-
const words = [start, ...inside.map((sample) => sample.shown)].filter((each) => typeof each === "string");
|
|
660
|
-
const numbers = words.flatMap(number);
|
|
661
|
-
const ranged = inside.length > 1 && numbers.length === words.length;
|
|
662
|
-
const kind = track.kind !== "content" ? track.kind : last.shown === null ? start === null ? "brief" : "disappeared" : start === null ? "appeared" : "text";
|
|
663
|
-
return {
|
|
664
|
-
track,
|
|
665
|
-
kind,
|
|
666
|
-
startedAt: first.at,
|
|
667
|
-
at: last.at,
|
|
668
|
-
before: kind === "disappeared" ? words.at(-1) : start ?? void 0,
|
|
669
|
-
after: kind === "brief" ? words.at(-1) : last.shown ?? void 0,
|
|
670
|
-
count: inside.length,
|
|
671
|
-
lowest: ranged ? words[numbers.indexOf(Math.min(...numbers))] : void 0,
|
|
672
|
-
highest: ranged ? words[numbers.indexOf(Math.max(...numbers))] : void 0,
|
|
673
|
-
earlier: prior?.at ?? (lost === Number.NEGATIVE_INFINITY ? void 0 : lost)
|
|
674
|
-
};
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* How readily a track gives way when the record is full: one that holds no change first, then
|
|
678
|
-
* one that keeps changing, one never seen in view and one that has gone; news never does.
|
|
679
|
-
*/
|
|
680
|
-
const rank = ({ samples: [only, ...more] }) => only === void 0 ? 4 : more.length > 0 ? 3 : only.seen === false ? 2 : only.shown === null ? 1 : 0;
|
|
681
|
-
return {
|
|
682
|
-
number,
|
|
683
|
-
over,
|
|
684
|
-
rank
|
|
685
|
-
};
|
|
686
|
-
};
|
|
687
|
-
/** The expression that installs the script and evaluates to its API; packaging freezes it. */
|
|
688
|
-
const installSource = "(() => {var pageScript = (function() {\n //#region src/Matching.ts\n const match = () => {\n /**\n * How names, text and context compare: one Unicode form, without invisible format characters,\n * spaces collapsed, and case folded upper first, so that \"ß\" and \"SS\" read the same.\n */\n const normalize = (value) => value.normalize(\"NFKC\").replace(/\\p{Cf}/gu, \"\").replace(/\\s+/g, \" \").trim().toUpperCase().toLowerCase();\n /** A string that reads the same, or, unless `whole`, appears within; or a pattern found within. */\n const rule = (wanted, whole) => {\n if (typeof wanted !== \"string\") {\n const found = new RegExp(wanted.source, wanted.flags.replace(/[gy]/g, \"\"));\n return (value) => found.test(value.replace(/\\s+/g, \" \").trim());\n }\n const target = normalize(wanted);\n return whole ? (value) => normalize(value) === target : (value) => normalize(value).includes(target);\n };\n /** Whether a value's words appear, whole and in order, among a text's: \"BTC\" not in \"WBTC\". */\n const holds = (text, value) => ` ${normalize(text)} `.includes(` ${normalize(value)} `);\n /** Whether a candidate meets every rule a query gives; a rule left out always holds. */\n const compile = (request) => {\n const role = request.role === null ? null : normalize(request.role);\n const name = request.name === null ? null : rule(request.name, true);\n const text = request.text === null ? null : rule(request.text, false);\n const { near } = request;\n return (candidate) => {\n if (role !== null && normalize(candidate.role ?? \"\") !== role) return false;\n if (text !== null && !text(candidate.text())) return false;\n if (name !== null && !name(candidate.name())) return false;\n if (near === null) return true;\n const { row, column, label, heading } = candidate.context();\n return [\n row,\n column,\n label,\n heading\n ].some((value) => value !== void 0 && holds(value, near));\n };\n };\n /** A comparison token for ordered observations, without retaining their text. */\n const mark = (observations) => {\n let hash = 2166136261;\n for (const shown of observations) for (let index = 0; index < shown.length; index++) hash = Math.imul(hash ^ shown.charCodeAt(index), 16777619);\n return `${observations.length}:${(hash >>> 0).toString(16)}`;\n };\n return {\n compile,\n holds,\n normalize,\n mark\n };\n };\n //#endregion\n //#region src/Url.ts\n const addresses = () => {\n const withheld = \"••••••••\";\n const credential = /token|secret|passw|passcode|passphrase|signature|credential|assertion|verifier|bearer|jwt|hmac|apikey|accesskey|privatekey|sess(?:ion)?id|saml(?:response|art)|(?:sig|otp)$|(?:auth|api|access|private|secret|signing|client|encryption|licen[cs]e|session|master|app|device|verification|verify|confirmation|confirm|activation|activate|reset|recovery|login|security|magic|onetime|mfa|2fa|sms|email|otp|oob)(?:code|key)$|^(?:auth|authorization|pwd|pass)$/;\n const ambiguous = /^(?:code|key|session|sid|ticket)$/;\n const secret = (name, value) => {\n const bare = name.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n return value !== \"\" && (credential.test(bare) || ambiguous.test(bare) && value.length >= 16 && /\\d/.test(value) && /[a-z]/i.test(value));\n };\n const masked = (parameters, separator) => parameters.split(separator).map((parameter) => {\n const [name = \"\", value = \"\"] = [...new URLSearchParams(parameter)][0] ?? [];\n return secret(name, value) ? `${parameter.slice(0, parameter.indexOf(\"=\") + 1)}${withheld}` : parameter;\n }).join(separator);\n /**\n * `url` as the library reports it: without userinfo, and with each credential's value withheld,\n * so the rest keeps its identity, such as a chart's `?ticker=ETH`. An address without a host,\n * such as `data:` or `about:blank`, is content or a fixed name, and stays as it is.\n */\n const redact = (url) => {\n const parsed = URL.parse(url);\n if (parsed === null || parsed.host === \"\") return url;\n parsed.username = \"\";\n parsed.password = \"\";\n parsed.pathname = masked(parsed.pathname, \";\");\n parsed.search = masked(parsed.search.slice(1), \"&\");\n if (parsed.hash.includes(\"=\")) {\n const fragment = parsed.hash.slice(1);\n const question = fragment.indexOf(\"?\");\n const start = question >= 0 && question < fragment.indexOf(\"=\") ? question + 1 : 0;\n parsed.hash = fragment.slice(0, start) + masked(fragment.slice(start), \"&\");\n }\n return parsed.href.replaceAll(encodeURIComponent(withheld), withheld);\n };\n return {\n withheld,\n redact\n };\n };\n //#endregion\n //#region src/internal/input/edit.inpage.ts\n const edit = (names, guard, placing) => {\n const { activeElement, clean, describe, inCurrentDocument, isDisabled, isHtml, isInput, isSecret, isSelect, isTextArea, lookup, nameOf, roleOf } = names;\n const { textEntry, typingRefusal } = guard;\n /** Whether text may be typed into a ref or focus, and, for a `secret`, only into a secret field. */\n const typeable = (ref, secret) => {\n const element = ref === null ? activeElement() : lookup(ref);\n if (element === void 0) return {\n error: \"stale\",\n detail: `${ref ?? \"the focused element\"} is not on the page any more`\n };\n const refusal = element === null ? secret ? \"nothing has focus to type a secret into\" : void 0 : typingRefusal(element, ref !== null) ?? (secret && !isSecret(element) ? `${describe(element)} is not a secret field` : void 0);\n if (refusal !== void 0) return {\n error: \"untypeable\",\n detail: refusal\n };\n if (element === null || ref !== null || !textEntry(element)) return {\n ok: true,\n secret: element !== null && isSecret(element)\n };\n const role = roleOf(element);\n const tag = element.tagName.toLowerCase();\n return {\n ok: true,\n secret: isSecret(element),\n subject: {\n role,\n name: nameOf(element, role),\n tag,\n context: placing.contextOf(element)\n }\n };\n };\n /**\n * The focused field, when it is a text field named `name`: one a page put in place of a field\n * just pressed and gave focus to, as a typeahead does.\n */\n const replacement = (name) => {\n const active = activeElement();\n return active !== null && textEntry(active) && inCurrentDocument(active) && nameOf(active, roleOf(active)) === name ? active : void 0;\n };\n /**\n * Focus a field to type into. `follow` is the field's name when the action pressed it first: a\n * page may answer the press with another field of that name in its place, focused, and the keys\n * follow focus there, as a person's would.\n */\n const focus = (ref, replace, follow) => {\n const element = lookup(ref) ?? (follow === null ? void 0 : replacement(follow));\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (!textEntry(element)) return { error: `${ref} is ${describe(element)}, not a text field` };\n if (isHtml(element)) element.focus();\n if (replace) {\n if (isInput(element) || isTextArea(element)) element.select();\n else element.ownerDocument.getSelection()?.selectAllChildren(element);\n }\n return {\n ok: true,\n detail: describe(element),\n secret: isSecret(element)\n };\n };\n /** Focus any element that takes focus, such as a link or a button, for a key pressed on it. */\n const focusOn = (ref) => {\n const element = lookup(ref);\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (isHtml(element)) element.focus();\n return activeElement() === element ? {\n ok: true,\n detail: describe(element)\n } : { error: `${ref} is ${describe(element)}, which does not take focus` };\n };\n const select = (ref, values) => {\n const element = lookup(ref);\n if (element === void 0) return {\n error: `${ref} is not on the page any more`,\n stale: true\n };\n if (!isSelect(element)) return { error: `${ref} is ${describe(element)}, not a <select>; click it and pick an option` };\n const wanted = values.map((value) => value.trim().toLowerCase());\n const options = Array.from(element.options);\n const chosen = options.filter((option) => wanted.includes(option.value.toLowerCase()) || wanted.includes(clean(option.text).toLowerCase()));\n if (chosen.length === 0) return { error: `no option matches; the options are ${options.map((option) => JSON.stringify(clean(option.text, 40))).join(\", \")}` };\n for (const option of options) option.selected = chosen.includes(option);\n element.dispatchEvent(new Event(\"input\", { bubbles: true }));\n element.dispatchEvent(new Event(\"change\", { bubbles: true }));\n return {\n ok: true,\n detail: chosen.map((option) => clean(option.text, 40)).join(\", \")\n };\n };\n return {\n focus,\n focusOn,\n select,\n typeable\n };\n };\n //#endregion\n //#region src/internal/input/evidence.inpage.ts\n const evidence = (names, placing) => {\n const { clean, isDocument, isInput, isSelect, isTextArea, nameOf, parentOf, roleOf, textOf } = names;\n const { groups, headingBefore, textBeside, treeOf } = placing;\n /** A field a submission would send. */\n const isField = (element) => (isInput(element) && ![\n \"button\",\n \"submit\",\n \"reset\",\n \"image\"\n ].includes(element.type) || isSelect(element) || isTextArea(element)) && !element.matches(\":disabled\");\n const isFilled = (field) => isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\") ? field.checked : isInput(field) && field.type === \"file\" ? (field.files?.length ?? 0) > 0 : field.value !== \"\";\n const dialogOf = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) if (node.tagName === \"DIALOG\" || /^(?:alert)?dialog$/.test(node.getAttribute(\"role\") ?? \"\")) return node;\n };\n /** What the page says about an input's first target, for a judge. Never a field's value. */\n const evidenceOf = (element, form, method, action) => {\n const name = nameOf(element, roleOf(element));\n const ids = element.getAttribute(\"aria-describedby\");\n const description = clean(ids === null ? element.getAttribute(\"aria-description\") ?? element.getAttribute(\"title\") : ids.split(/\\s+/).map((id) => element.ownerDocument.getElementById(id)?.textContent ?? \"\").join(\" \"), 120);\n const dialog = dialogOf(element);\n const title = dialog?.querySelector(\"h1,h2,h3,h4,h5,h6,[role=heading]\");\n const dialogName = dialog === void 0 ? \"\" : clean(nameOf(dialog, \"dialog\"), 120) || (title === null || title === void 0 ? \"\" : clean(textOf(title), 120));\n const root = element.getRootNode();\n const top = isDocument(root) ? root.body ?? root : root;\n const inTree = element.closest(\"dialog,[role=dialog],[role=alertdialog]\");\n let nearby = \"\";\n for (const scope of /* @__PURE__ */ new Set([\n element.closest(groups),\n inTree,\n top\n ])) if (scope !== null && nearby === \"\") nearby = textBeside(element, scope, true) || textBeside(element, scope, false);\n const heading = headingBefore(element, treeOf(element));\n const fields = form === null ? [] : Array.from(form.elements).filter(isField).slice(0, 16).map((field) => {\n const autocomplete = clean(field.getAttribute(\"autocomplete\"), 40);\n return {\n type: isInput(field) ? field.type : field.tagName.toLowerCase(),\n name: clean(isInput(field) && field.type === \"hidden\" ? field.getAttribute(\"name\") : nameOf(field, roleOf(field)), 40),\n ...autocomplete === \"\" ? {} : { autocomplete },\n filled: isFilled(field)\n };\n });\n return {\n title: clean(document.title, 120),\n ...description === \"\" || description === name ? {} : { description },\n ...dialogName === \"\" ? {} : { dialog: dialogName },\n ...heading === void 0 ? {} : { heading },\n ...nearby === \"\" ? {} : { nearby },\n ...form === null ? {} : { form: {\n method: method ?? form.method,\n action: action ?? form.action,\n fields\n } }\n };\n };\n return {\n evidenceOf,\n isField,\n isFilled\n };\n };\n //#endregion\n //#region src/internal/input/guard.inpage.ts\n const guard = (names, targets, evidence) => {\n const { activeElement, textEntry, clean, describe, inCurrentDocument, interactiveRoles, isButton, isDisabled, isHtml, isInput, isLabel, isRoot, isSecret, isSelect, isTextArea, lookup, parentOf, refFor, roleOf } = names;\n const { controlOf, details, hitAt, hrefAttribute, linkOf, receives, within } = targets;\n const { evidenceOf, isField, isFilled } = evidence;\n const nativeActivation = (element) => hrefAttribute(element) !== null || element.tagName === \"BUTTON\" || element.tagName === \"SUMMARY\" || isInput(element) && element.type !== \"hidden\";\n /**\n * The element whose activation behaviour a click or key on `element` runs, as the browser\n * resolves it along the composed path: a link, button, input, summary or a label's control.\n */\n const activationTarget = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) {\n if (nativeActivation(node)) return node;\n if (isLabel(node) && node.control !== null) return node.control;\n }\n };\n /**\n * A control between a press's hit and the approved target that is not the target's own\n * activation, such as a link or button a hover handler nested into it. The approval inspected\n * the target, so that control would act unapproved.\n */\n const nestedControl = (element, hit) => {\n if (!within(element, hit)) return void 0;\n const own = activationTarget(element);\n for (let node = hit; node !== null && node !== element; node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null) if (node !== own && (nativeActivation(node) || isSelect(node) || isTextArea(node) || isLabel(node) && node.control !== null && node.control !== own || activatingRoles.has(roleOf(node) ?? \"\"))) return node;\n };\n const activatingRoles = /* @__PURE__ */ new Set([\n \"button\",\n \"link\",\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"tab\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"option\",\n \"treeitem\"\n ]);\n const typingRefusal = (element, explicit) => textEntry(element) ? void 0 : explicit ? `${describe(element)} is not a text field` : activationTarget(element) !== void 0 || isSelect(element) || activatingRoles.has(roleOf(element) ?? \"\") ? `focus is on ${describe(element)}, which typed text could activate or change; type into a text field by ref, or use press for keys` : void 0;\n const isSubmitter = (element) => isButton(element) && element.type === \"submit\" || isInput(element) && (element.type === \"submit\" || element.type === \"image\");\n const defaultSubmitter = (form) => {\n const root = form.getRootNode();\n return isRoot(root) ? Array.from(root.querySelectorAll(\"button,input\")).find((candidate) => isSubmitter(candidate) && candidate.form === form) : void 0;\n };\n const purpose = (control, form) => [\n control.getAttribute(\"id\"),\n control.getAttribute(\"name\"),\n control.getAttribute(\"inputmode\"),\n control.getAttribute(\"autocomplete\"),\n control.getAttribute(\"aria-label\"),\n form?.getAttribute(\"id\"),\n form?.getAttribute(\"name\"),\n form?.getAttribute(\"aria-label\")\n ];\n const boundUrl = (url) => {\n const hash = url.indexOf(\"#\");\n return hash === -1 || /^#[/!]/.test(url.slice(hash)) ? url : url.slice(0, hash);\n };\n const inspectInput = (element, plan) => {\n const metadata = details(element, element, 0, 0);\n const control = activationTarget(element) ?? element;\n const form = isInput(control) || isButton(control) || isTextArea(control) || isSelect(control) ? control.form : null;\n const key = plan.keys === null ? void 0 : /(?:^|\\+)(\\+|[^+]+)$/.exec(plan.keys)?.[1];\n const enter = key === \"Enter\";\n const activation = plan.action === \"click\" || plan.action === \"press\" && (enter || key === \"Space\");\n const fieldEnter = isInput(control) && ![\n \"button\",\n \"reset\",\n \"submit\",\n \"image\",\n \"file\",\n \"color\",\n \"hidden\"\n ].includes(control.type) && (plan.action === \"press\" && enter || plan.action === \"type\" && plan.submit);\n const submits = form !== null && (activation && isSubmitter(control) || fieldEnter);\n const submitter = isSubmitter(control) ? control : form === null ? void 0 : defaultSubmitter(form);\n const formValue = (attribute, property) => form === null ? void 0 : submitter?.hasAttribute(`form${attribute}`) === true ? submitter[property] : form[attribute];\n const formDestination = formValue(\"action\", \"formAction\");\n const formMethod = formValue(\"method\", \"formMethod\");\n const formTarget = formValue(\"target\", \"formTarget\");\n const link = linkOf(element);\n const href = link === void 0 ? null : hrefAttribute(link);\n const sends = submits && formMethod !== \"dialog\";\n const destination = sends ? formDestination : activation ? metadata.href : void 0;\n const acts = plan.action !== \"hover\" && plan.action !== \"scroll\";\n const builtIn = sends || href !== null && !/^\\s*(?:#\\s*|javascript:[^]*)$/i.test(href) || isInput(control) && ![\n \"button\",\n \"submit\",\n \"image\",\n \"reset\"\n ].includes(control.type) || (isInput(control) || isButton(control)) && control.type === \"reset\" && form !== null || control.tagName === \"SUMMARY\" || control.closest(\"select\") !== null || textEntry(control);\n const facts = [];\n if (sends) facts.push(\"form-submit\");\n if (activation && link?.hasAttribute(\"download\") === true) facts.push(\"download\");\n if (activation && isInput(control) && control.type === \"file\") facts.push(\"upload\");\n if (plan.action === \"type\" && isSecret(control) || sends && form !== null && Array.from(form.elements).some((field) => isField(field) && isSecret(field) && isFilled(field))) facts.push(\"secret\");\n if (activation && !builtIn) facts.push(\"scripted\");\n if (acts && (metadata.role === \"canvas\" || metadata.role === \"iframe\" || metadata.name === \"\")) facts.push(\"opaque\");\n const role = metadata.role;\n const boundName = role !== null && (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\") && !(isHtml(element) && element.isContentEditable) ? metadata.name : null;\n const fingerprint = JSON.stringify([\n purpose(control, form),\n element.tagName,\n element.id,\n role,\n boundName,\n metadata.href,\n control === element ? null : refFor(control),\n isInput(control) || isButton(control) ? control.type : control.tagName,\n isDisabled(control),\n control.getAttribute(\"readonly\"),\n control.getAttribute(\"aria-readonly\"),\n isHtml(control) && control.isContentEditable,\n control.getAttribute(\"name\"),\n control.getAttribute(\"accept\"),\n control.hasAttribute(\"multiple\"),\n link?.getAttribute(\"download\"),\n form === null ? null : refFor(form),\n form === null ? null : boundUrl(form.action),\n form?.method,\n form?.target,\n submitter === void 0 ? null : refFor(submitter),\n formDestination === void 0 ? void 0 : boundUrl(formDestination),\n formMethod,\n formTarget,\n submitter?.formNoValidate,\n form?.noValidate\n ]);\n return {\n inspected: {\n ref: refFor(element),\n element: metadata.element,\n role: metadata.role,\n name: metadata.name,\n cursor: metadata.cursor,\n ...metadata.href === void 0 ? {} : { href: metadata.href },\n secret: isSecret(control),\n fingerprint\n },\n facts,\n destination,\n explain: () => evidenceOf(element, form, formMethod, formDestination)\n };\n };\n const inspect = (plan) => {\n const targets = [];\n const facts = /* @__PURE__ */ new Set();\n let destination = plan.destination ?? void 0;\n let explain = () => ({ title: clean(document.title, 120) });\n for (const [index, target] of plan.targets.entries()) {\n let element;\n if (target === null) element = activeElement();\n else if (typeof target === \"string\") {\n element = lookup(target);\n if (element === void 0) return {\n error: \"stale\",\n detail: target + \" is not on the page any more\",\n index\n };\n } else {\n if (!Number.isFinite(target.x) || !Number.isFinite(target.y) || target.x < 0 || target.y < 0 || target.x >= window.innerWidth || target.y >= window.innerHeight) return {\n error: \"outside\",\n detail: \"the point is outside the viewport\"\n };\n const hit = hitAt(document, target.x, target.y);\n element = hit === null ? null : controlOf(hit);\n if (element === null) return {\n error: \"offscreen\",\n detail: \"nothing is painted at the point\"\n };\n }\n if (element === null) {\n targets.push(null);\n continue;\n }\n if (!inCurrentDocument(element)) return {\n error: \"stale\",\n detail: \"the input target belongs to a replaced document\",\n index\n };\n const refusal = plan.action === \"type\" ? typingRefusal(element, target !== null) : void 0;\n if (refusal !== void 0) return {\n error: \"untypeable\",\n detail: refusal\n };\n const inspected = inspectInput(element, plan);\n if (index === 0) explain = inspected.explain;\n targets.push(inspected.inspected);\n for (const fact of inspected.facts) facts.add(fact);\n destination ??= inspected.destination;\n if (inspected.destination !== void 0) try {\n if (new URL(inspected.destination, location.href).origin !== location.origin) facts.add(\"cross-origin\");\n } catch {\n return {\n error: \"outside\",\n detail: \"the input destination is not a valid URL\"\n };\n }\n }\n if (destination !== void 0) try {\n destination = new URL(destination, location.href).href;\n if (new URL(destination).origin !== location.origin) facts.add(\"cross-origin\");\n } catch {\n return {\n error: \"outside\",\n detail: \"the input destination is not a valid URL\"\n };\n }\n return {\n url: boundUrl(location.href),\n targets,\n facts: [...facts],\n ...destination === void 0 ? {} : { destination },\n explain\n };\n };\n const prepareInput = (plan) => {\n const inspected = inspect(plan);\n if (\"error\" in inspected) return inspected;\n const { explain, ...prepared } = inspected;\n return {\n ...prepared,\n evidence: explain()\n };\n };\n const bindings = (targets) => targets.map((target) => target === null ? null : [target.ref, target.fingerprint]);\n const validate = (plan, prepared, options) => {\n const current = inspect(plan);\n if (\"error\" in current) return current.error === \"stale\" ? current : {\n error: \"changed\",\n detail: current.detail\n };\n if (current.url !== prepared.url || (current.destination === void 0 || prepared.destination === void 0 ? current.destination !== prepared.destination : boundUrl(current.destination) !== boundUrl(prepared.destination)) || JSON.stringify(current.facts) !== JSON.stringify(prepared.facts) || JSON.stringify(bindings(current.targets)) !== JSON.stringify(bindings(prepared.targets))) return {\n error: \"changed\",\n detail: \"the page or input target changed while the policy was deciding\"\n };\n if (options.focused === true) {\n const active = activeElement();\n const expected = prepared.targets[0];\n if (active === null || expected === null || expected === void 0 || refFor(active) !== expected.ref) return {\n error: \"changed\",\n detail: \"focus moved away from the approved element\"\n };\n }\n for (const press of options.presses ?? []) {\n const expected = prepared.targets[press.index];\n const element = expected === null || expected === void 0 ? void 0 : lookup(expected.ref);\n const hit = hitAt(document, press.x, press.y);\n if (element === void 0 || hit === null || !receives(element, hit)) return {\n error: \"changed\",\n detail: `the approved target is no longer under the pointer at (${press.x}, ${press.y})`\n };\n const nested = nestedControl(element, hit);\n if (nested !== void 0) return {\n error: \"changed\",\n detail: `${describe(nested)} inside the approved target would receive the press at (${press.x}, ${press.y})`\n };\n }\n return { ok: true };\n };\n const validateInput = (plan, prepared, options = {}) => {\n if ((options.presses ?? []).length === 0) return validate(plan, prepared, options);\n const { promise, resolve } = Promise.withResolvers();\n if (document.visibilityState === \"hidden\") resolve();\n else requestAnimationFrame(() => requestAnimationFrame(() => resolve()));\n return promise.then(() => validate(plan, prepared, options));\n };\n return {\n prepareInput,\n textEntry,\n typingRefusal,\n validateInput\n };\n };\n //#endregion\n //#region src/internal/input/targets.inpage.ts\n const targets = (names, walked, placing) => {\n const { describe, isDisabled, lookup, nameOf, parentOf, roleOf } = names;\n const { boxOf, controlOf, hitAt } = walked;\n const { contextOf } = placing;\n /** Whether `node` is `ancestor` or inside it, across shadow roots and same-origin frames. */\n const within = (ancestor, node) => {\n for (let current = node; current !== null;) {\n if (current === ancestor) return true;\n current = parentOf(current) ?? current.ownerDocument.defaultView?.frameElement ?? null;\n }\n return false;\n };\n const receives = (element, hit) => within(element, hit) || within(hit, element);\n const hrefAttribute = (element) => element.localName === \"a\" || element.localName === \"area\" ? element.getAttribute(\"href\") ?? element.getAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\") : null;\n const linkOf = (element) => {\n for (let node = element; node !== null; node = parentOf(node)) if (hrefAttribute(node) !== null) return node;\n };\n const details = (element, hit, x, y) => {\n const link = linkOf(element);\n let href;\n if (link !== void 0) try {\n href = new URL(hrefAttribute(link) ?? \"\", link.ownerDocument.baseURI).href;\n } catch {\n href = void 0;\n }\n const role = roleOf(element);\n const view = hit.ownerDocument.defaultView ?? window;\n return {\n x,\n y,\n element: describe(element),\n tag: element.tagName.toLowerCase(),\n role,\n name: nameOf(element, role),\n cursor: view.getComputedStyle(hit).cursor,\n ...href === void 0 ? {} : { href }\n };\n };\n const point = (target, scroll = true) => {\n if (typeof target !== \"string\") {\n const { x, y } = target;\n if (!Number.isFinite(x) || !Number.isFinite(y) || x < 0 || y < 0 || x >= window.innerWidth || y >= window.innerHeight) return {\n error: \"outside\",\n detail: `(${x}, ${y}) is outside the viewport`\n };\n const hit = hitAt(document, x, y);\n if (hit === null) return {\n error: \"offscreen\",\n detail: `nothing is painted at (${x}, ${y})`\n };\n const control = controlOf(hit);\n return {\n ...details(control, hit, x, y),\n context: contextOf(control),\n box: boxOf(control)\n };\n }\n const ref = target;\n const element = lookup(ref);\n if (element === void 0) return {\n error: \"stale\",\n detail: `${ref} is not on the page any more`\n };\n if (isDisabled(element)) return {\n error: \"disabled\",\n detail: `${ref} is disabled`\n };\n const rect = element.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) return {\n error: \"hidden\",\n detail: `${ref} has no size on the page`\n };\n let box = {\n left: rect.left,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom\n };\n let visible = { ...box };\n let outside = false;\n for (let inner = element;;) {\n const view = inner.ownerDocument.defaultView ?? window;\n outside ||= box.left < 0 || box.top < 0 || box.right > view.innerWidth || box.bottom > view.innerHeight;\n visible = {\n left: Math.max(visible.left, 0),\n top: Math.max(visible.top, 0),\n right: Math.min(visible.right, view.innerWidth),\n bottom: Math.min(visible.bottom, view.innerHeight)\n };\n for (let ancestor = parentOf(inner); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = view.getComputedStyle(ancestor);\n const clip = ancestor.getBoundingClientRect();\n if (/(auto|scroll|hidden|clip)/.test(style.overflowX)) {\n visible.left = Math.max(visible.left, clip.left + ancestor.clientLeft);\n visible.right = Math.min(visible.right, clip.left + ancestor.clientLeft + ancestor.clientWidth);\n }\n if (/(auto|scroll|hidden|clip)/.test(style.overflowY)) {\n visible.top = Math.max(visible.top, clip.top + ancestor.clientTop);\n visible.bottom = Math.min(visible.bottom, clip.top + ancestor.clientTop + ancestor.clientHeight);\n }\n }\n const frame = view.frameElement;\n if (frame === null) break;\n const frameBox = frame.getBoundingClientRect();\n const dx = frameBox.left + frame.clientLeft;\n const dy = frameBox.top + frame.clientTop;\n box = {\n left: box.left + dx,\n top: box.top + dy,\n right: box.right + dx,\n bottom: box.bottom + dy\n };\n visible = {\n left: Math.max(visible.left + dx, dx),\n top: Math.max(visible.top + dy, dy),\n right: Math.min(visible.right + dx, dx + frame.clientWidth),\n bottom: Math.min(visible.bottom + dy, dy + frame.clientHeight)\n };\n inner = frame;\n }\n if (outside || visible.right <= visible.left || visible.bottom <= visible.top) {\n if (scroll) {\n element.scrollIntoView({\n block: \"center\",\n inline: \"center\",\n behavior: \"instant\"\n });\n return point(target, false);\n }\n return {\n error: \"offscreen\",\n detail: outside ? ref + \" is outside the viewport\" : `${ref} could not be scrolled into view`\n };\n }\n const x = (visible.left + visible.right) / 2;\n const y = (visible.top + visible.bottom) / 2;\n const hit = hitAt(document, x, y);\n if (hit !== null && !receives(element, hit)) return {\n error: \"covered\",\n detail: `${ref} is covered by ${describe(hit)}`\n };\n return {\n ...details(element, hit ?? element, Math.round(x), Math.round(y)),\n context: contextOf(element)\n };\n };\n const scrollPlan = (ref) => {\n const element = lookup(ref);\n if (element === void 0 || element.ownerDocument !== document) return null;\n const target = element.getBoundingClientRect();\n const centerX = (target.left + target.right) / 2;\n const centerY = (target.top + target.bottom) / 2;\n for (let ancestor = parentOf(element); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = window.getComputedStyle(ancestor);\n const horizontal = /^(auto|scroll)$/.test(style.overflowX) && ancestor.scrollWidth > ancestor.clientWidth;\n const vertical = /^(auto|scroll)$/.test(style.overflowY) && ancestor.scrollHeight > ancestor.clientHeight;\n if (!horizontal && !vertical) continue;\n const box = ancestor.getBoundingClientRect();\n const left = Math.max(0, box.left + ancestor.clientLeft);\n const top = Math.max(0, box.top + ancestor.clientTop);\n const right = Math.min(window.innerWidth, box.left + ancestor.clientLeft + ancestor.clientWidth);\n const bottom = Math.min(window.innerHeight, box.top + ancestor.clientTop + ancestor.clientHeight);\n if (right <= left || bottom <= top) continue;\n const x = (left + right) / 2;\n const y = (top + bottom) / 2;\n const dx = horizontal && (target.left < left || target.right > right) ? centerX - x : 0;\n const dy = vertical && (target.top < top || target.bottom > bottom) ? centerY - y : 0;\n if (dx === 0 && dy === 0) continue;\n const hit = hitAt(document, x, y);\n if (hit !== null && (hit === ancestor || ancestor.contains(hit))) return {\n x,\n y,\n dx,\n dy\n };\n }\n const dx = target.left < 0 || target.right > window.innerWidth ? centerX - window.innerWidth / 2 : 0;\n const dy = target.top < 0 || target.bottom > window.innerHeight ? centerY - window.innerHeight / 2 : 0;\n return dx === 0 && dy === 0 ? null : {\n x: window.innerWidth / 2,\n y: window.innerHeight / 2,\n dx,\n dy\n };\n };\n return {\n controlOf,\n details,\n hitAt,\n hrefAttribute,\n linkOf,\n point,\n receives,\n scrollPlan,\n within\n };\n };\n //#endregion\n //#region src/internal/reading/context.inpage.ts\n const context = (names, walked) => {\n const { clean, isButton, isDocument, isHtml, isInput, isRoot } = names;\n const { isSelect, isTextArea, roleOf, textOf } = names;\n const { visible } = walked;\n const known = () => ({\n headers: /* @__PURE__ */ new Map(),\n headings: /* @__PURE__ */ new Map()\n });\n const unspoken = \"button,select,textarea,option,script,style,noscript,template,[role=button],[role=menuitem],[role=option],[role=tab],[role=switch],[role=checkbox],[role=radio],[aria-hidden=true]\";\n const groups = \"tr,li,article,fieldset,form,section,dialog,[role=row],[role=listitem],[role=group],[role=region],[role=dialog],[role=alertdialog]\";\n /** The visible text just before (or after) a target within `scope`, nearest kept, ≤120 characters. */\n const textBeside = (target, scope, backwards) => {\n const walker = target.ownerDocument.createTreeWalker(scope, NodeFilter.SHOW_TEXT);\n const labels = isInput(target) || isTextArea(target) || isSelect(target) || isButton(target) ? Array.from(target.labels ?? []) : [];\n let text = \"\";\n walker.currentNode = target;\n for (let steps = 0; steps < 400 && text.replace(/\\s+/g, \"\").length < 120; steps++) {\n const node = backwards ? walker.previousNode() : walker.nextNode();\n if (node === null) break;\n const parent = node.parentElement;\n if (parent === null || target.contains(parent) || parent.closest(unspoken) !== null || isHtml(parent) && parent.isContentEditable || labels.some((label) => label.contains(parent)) || !visible(parent)) continue;\n text = backwards ? `${node.textContent ?? \"\"} ${text}` : `${text} ${node.textContent ?? \"\"}`;\n }\n const words = text.replace(/\\s+/g, \" \").trim();\n return words.length <= 120 ? words : backwards ? `…${words.slice(-119).trimStart()}` : `${words.slice(0, 119).trimEnd()}…`;\n };\n /** The nearest visible heading before `target` in tree order, within `scope`. */\n const headingBefore = (target, scope, read = known()) => {\n let headings = read.headings.get(scope);\n if (headings === void 0) {\n headings = Array.from(scope.querySelectorAll(\"h1,h2,h3,h4,h5,h6,[role=heading]\")).filter((element) => roleOf(element) === \"heading\");\n read.headings.set(scope, headings);\n }\n for (const heading of headings.toReversed()) {\n if ((heading.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_FOLLOWING) === 0) continue;\n const text = visible(heading) ? clean(textOf(heading), 120) : \"\";\n if (text !== \"\") return text;\n }\n };\n /** Whether an element is pinned to the viewport, where the markup around it says nothing. */\n const pinned = (element) => {\n if (!isHtml(element)) return false;\n let top = element;\n while (top.offsetParent !== null && isHtml(top.offsetParent)) top = top.offsetParent;\n return top !== element.ownerDocument.body && top !== element.ownerDocument.documentElement && getComputedStyle(top).position === \"fixed\";\n };\n const span = (cell) => Math.max(1, Number(cell.getAttribute(\"colspan\")) || 1);\n const tables = \"table,[role=table],[role=grid],[role=treegrid]\";\n /** A cell's row and column names, or nothing when it is not in a table with either. */\n const tableContext = (cell, read) => {\n const row = cell.closest(\"tr,[role=row]\");\n const table = row?.closest(tables);\n if (row === null || row === void 0 || table === null || table === void 0) return {};\n let header = read.headers.get(table);\n if (header === void 0) {\n const first = table.querySelector(\"thead tr, tr:has(> th), [role=row]:has(> [role=columnheader])\");\n header = first?.closest(tables) === table ? first : null;\n read.headers.set(table, header);\n }\n if (row === header) return {};\n const cells = Array.from(row.children);\n const index = cells.indexOf(cell);\n const lettered = (other) => /\\p{L}/u.test(textOf(other));\n const named = cells.find((other) => other.matches(\"th,[role=rowheader]\") && lettered(other)) ?? cells.find((other) => other !== cell && lettered(other));\n let left = cells.slice(0, index).reduce((sum, other) => sum + span(other), 0);\n const over = index === -1 || header === null ? void 0 : Array.from(header.children).find((candidate) => (left -= span(candidate)) < 0);\n return {\n row: named === void 0 || named === cell ? void 0 : clean(textOf(named), 60) || void 0,\n column: over === void 0 ? void 0 : clean(textOf(over), 60) || void 0\n };\n };\n /** Where text around an element is read: its dialog, else its own tree, never across a shadow root. */\n const treeOf = (element) => {\n const root = element.getRootNode();\n return element.closest(\"dialog,[role=dialog],[role=alertdialog]\") ?? (isDocument(root) ? root.body ?? root : isRoot(root) ? root : element.ownerDocument);\n };\n /** The words around an element that say which one it is. */\n const contextOf = (element, read = known()) => {\n const cell = element.closest(\"td,th,[role=cell],[role=gridcell],[role=rowheader],[role=columnheader]\");\n const table = cell === null ? {} : tableContext(cell, read);\n const parent = element.parentElement;\n const scope = element.closest(groups) ?? (parent === null || parent === element.ownerDocument.body || parent.tagName === \"HTML\" ? void 0 : parent);\n const beside = table.row !== void 0 || table.column !== void 0 || scope === void 0 ? \"\" : textBeside(element, scope, true);\n const heading = pinned(element) ? void 0 : headingBefore(element, treeOf(element), read);\n return {\n ...table,\n label: beside.length > 40 ? `…${beside.slice(-39).trimStart()}` : beside || void 0,\n heading: heading === void 0 ? void 0 : clean(heading, 60)\n };\n };\n return {\n contextOf,\n groups,\n headingBefore,\n known,\n textBeside,\n treeOf\n };\n };\n //#endregion\n //#region src/internal/reading/controls.inpage.ts\n const controls = (names, subjects, texts) => {\n const { clean, isInput, isSelect, isTextArea, refFor, textEntry } = names;\n const { stateOf } = subjects;\n const { shown } = texts;\n const states = (element, role) => {\n const { level, ...flags } = stateOf(element, role);\n const held = Object.entries(flags).flatMap(([name, value]) => value === true ? [name] : []);\n return [...level === void 0 ? [] : [`level=${level}`], ...held].map((name) => ` [${name}]`).join(\"\");\n };\n const valueOf = (element) => {\n if (isSelect(element)) {\n const selected = Array.from(element.selectedOptions, (option) => clean(option.text, 40));\n const options = Array.from(element.options).slice(0, 12).map((option) => clean(option.text, 40));\n const more = element.options.length > 12 ? ` +${element.options.length - 12} more` : \"\";\n return ` value=${JSON.stringify(selected.join(\", \"))} options=${JSON.stringify(options.join(\" | \") + more)}`;\n }\n const value = isInput(element) || isTextArea(element) ? shown(element, true) : void 0;\n return value === void 0 || value === \"\" ? \"\" : ` value=${JSON.stringify(clean(value, 80))}`;\n };\n /** A control as a value, as its outline line shows it. */\n const controlOf = (element, role, kind, name) => {\n const { disabled, checked } = stateOf(element, role);\n const select = isSelect(element) ? element : void 0;\n const value = select !== void 0 ? Array.from(select.selectedOptions, (option) => clean(option.text, 80)).join(\", \") : isInput(element) || isTextArea(element) ? clean(shown(element, true), 200) : \"\";\n const editable = textEntry(element);\n return {\n ref: refFor(element),\n kind,\n name,\n value,\n ...select === void 0 ? {} : {\n options: Array.from(select.options).slice(0, 64).map((option) => clean(option.text, 80)),\n optionCount: select.options.length\n },\n ...disabled ? { disabled } : {},\n ...checked === void 0 ? {} : { checked },\n ...editable ? { editable } : {}\n };\n };\n /**\n * The elements a selector matches, each read whole, so one inside another that matched is left\n * to it; or why the selector is not CSS.\n */\n const rootsOf = (selector) => {\n let matched;\n try {\n matched = Array.from(document.querySelectorAll(selector));\n } catch {\n return { invalid: `${JSON.stringify(selector)} is not a CSS selector` };\n }\n return matched.filter((root) => !matched.some((other) => other !== root && other.contains(root)));\n };\n return {\n controlOf,\n rootsOf,\n states,\n valueOf\n };\n };\n //#endregion\n //#region src/internal/reading/expect.inpage.ts\n const expectations = (names, subjected, matching) => {\n const { isInput, isSelect, isTextArea, roleOf, textOf } = names;\n const { elementsOf, stateOf } = subjected;\n const markOf = (elements) => matching.mark(elements.map((element) => {\n const { focused: _focused, ...state } = stateOf(element, roleOf(element));\n const value = isInput(element) || isSelect(element) || isTextArea(element) ? element.value : \"\";\n return `${textOf(element)}\\u0000${value}\\u0000${JSON.stringify(state)}\\u0001`;\n }));\n /**\n * What `find` matches, looked at every 100 ms until `want` holds of it or `millis` have passed,\n * with its mark then. It gives no refs.\n */\n const until = async (request, want, millis) => {\n const deadline = performance.now() + millis;\n for (;;) {\n const elements = elementsOf(request);\n if (\"invalid\" in elements) return elements;\n const mark = markOf(elements);\n const met = want === \"some\" ? elements.length > 0 : want === \"none\" ? elements.length === 0 : mark !== want.other;\n const left = deadline - performance.now();\n if (met || left <= 0) return {\n met,\n mark\n };\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, Math.min(100, left));\n await promise;\n }\n };\n return { until };\n };\n //#endregion\n //#region src/internal/reading/names.inpage.ts\n const elements = () => {\n const isInput = (element) => element.tagName === \"INPUT\";\n const isTextArea = (element) => element.tagName === \"TEXTAREA\";\n const isSelect = (element) => element.tagName === \"SELECT\";\n const isFrame = (element) => element.tagName === \"IFRAME\";\n const isHtml = (element) => \"innerText\" in element;\n const isButton = (element) => element.tagName === \"BUTTON\";\n const isLabel = (element) => element.tagName === \"LABEL\";\n const textOf = (element) => isHtml(element) ? element.innerText : element.textContent ?? \"\";\n const isElement = (node) => node.nodeType === Node.ELEMENT_NODE;\n const isDocument = (node) => node.nodeType === Node.DOCUMENT_NODE;\n /** The native fields and editable regions that can receive typed text. */\n const textEntry = (element) => isInput(element) && ![\n \"button\",\n \"reset\",\n \"submit\",\n \"image\",\n \"checkbox\",\n \"radio\",\n \"file\",\n \"range\",\n \"color\",\n \"hidden\"\n ].includes(element.type) || isTextArea(element) || isHtml(element) && element.isContentEditable;\n const clean = (value, max = 160) => {\n const text = (value ?? \"\").replace(/\\s+/g, \" \").trim();\n return text.length > max ? `${text.slice(0, max - 1)}…` : text;\n };\n return {\n clean,\n isInput,\n isTextArea,\n isSelect,\n isFrame,\n isHtml,\n isButton,\n isLabel,\n textOf,\n isElement,\n isDocument,\n textEntry\n };\n };\n const names = (native) => {\n const { clean, isInput, isTextArea, isSelect, isFrame, textOf, isElement } = native;\n const byElement = /* @__PURE__ */ new WeakMap();\n const byRef = /* @__PURE__ */ new Map();\n const refs = { next: 1 };\n const interactiveRoles = new Set(\"button link checkbox radio tab menuitem menuitemcheckbox menuitemradio option switch slider combobox listbox textbox searchbox spinbutton treeitem\".split(\" \"));\n const containers = {\n HEADER: \"banner\",\n NAV: \"navigation\",\n MAIN: \"main\",\n ASIDE: \"complementary\",\n FOOTER: \"contentinfo\",\n FORM: \"form\",\n DIALOG: \"dialog\"\n };\n const valueRoles = new Set(\"combobox listbox option textbox searchbox spinbutton slider\".split(\" \"));\n /**\n * A label's own words, without the options or values of the controls inside it, native or\n * scripted, such as the custom select Browserbase puts in place of a native one.\n */\n const labelText = (label) => {\n let text = \"\";\n const collect = (node) => {\n for (const child of Array.from(node.childNodes)) if (child.nodeType === Node.TEXT_NODE) text += child.textContent ?? \"\";\n else if (isElement(child) && ![\n \"SELECT\",\n \"TEXTAREA\",\n \"INPUT\",\n \"SCRIPT\",\n \"STYLE\"\n ].includes(child.tagName) && !valueRoles.has(roleOf(child) ?? \"\")) collect(child);\n };\n collect(label);\n return text;\n };\n const roleOf = (element, structural = false) => {\n const explicit = element.getAttribute(\"role\");\n if (explicit !== null && explicit.trim() !== \"\") return explicit.trim().split(/\\s+/)[0] ?? null;\n const tag = element.tagName;\n if (tag === \"A\") return element.hasAttribute(\"href\") ? \"link\" : null;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return \"button\";\n if (isSelect(element)) return element.multiple ? \"listbox\" : \"combobox\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (isInput(element)) {\n const type = element.type;\n if (type === \"hidden\" || type === \"color\" || type === \"file\") return null;\n if (type === \"checkbox\" || type === \"radio\") return type;\n if (type === \"range\") return \"slider\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"search\") return \"searchbox\";\n if (type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\") return \"button\";\n return \"textbox\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"IMG\") return \"img\";\n if (tag === \"CANVAS\") return \"canvas\";\n if (tag === \"IFRAME\") return \"iframe\";\n if (element.getAttribute(\"contenteditable\") === \"true\") return \"textbox\";\n if (structural) {\n if (tag === \"TH\") return element.getAttribute(\"scope\") === \"row\" ? \"rowheader\" : \"columnheader\";\n const roles = {\n TABLE: \"table\",\n TR: \"row\",\n TD: \"cell\",\n TBODY: \"rowgroup\",\n THEAD: \"rowgroup\",\n TFOOT: \"rowgroup\",\n UL: \"list\",\n OL: \"list\",\n MENU: \"list\",\n LI: \"listitem\"\n };\n if (roles[tag] !== void 0) return roles[tag];\n }\n return containers[tag] ?? null;\n };\n const nameOf = (element, role) => {\n const labelledBy = element.getAttribute(\"aria-labelledby\");\n if (labelledBy !== null) {\n const text = labelledBy.split(/\\s+/).map((id) => {\n const labelling = element.ownerDocument.getElementById(id);\n return labelling === null ? \"\" : labelText(labelling);\n }).join(\" \");\n if (clean(text) !== \"\") return clean(text);\n }\n const label = element.getAttribute(\"aria-label\");\n if (label !== null && clean(label) !== \"\") return clean(label);\n if (isInput(element) || isTextArea(element) || isSelect(element)) {\n const labels = element.labels === null ? \"\" : Array.from(element.labels, labelText).join(\" \");\n if (clean(labels) !== \"\") return clean(labels);\n if (isInput(element) && (element.type === \"button\" || element.type === \"submit\" || element.type === \"reset\")) return clean(element.value);\n return clean(element.getAttribute(\"placeholder\") ?? element.getAttribute(\"title\") ?? element.getAttribute(\"name\"));\n }\n if (role === \"img\") return clean(element.getAttribute(\"alt\") ?? element.getAttribute(\"title\"));\n if (role === \"iframe\") return clean(element.getAttribute(\"title\") ?? element.getAttribute(\"name\"));\n if (role === null || interactiveRoles.has(role) || role === \"heading\") {\n const text = isSecret(element) ? \"\" : clean(textOf(element), 120);\n if (text !== \"\") return text;\n const titled = element.querySelector(\"[title],img[alt],svg title\");\n const fallback = titled === null ? null : titled.tagName === \"IMG\" ? titled.getAttribute(\"alt\") : titled.tagName.toLowerCase() === \"title\" ? titled.textContent : titled.getAttribute(\"title\");\n return clean(element.getAttribute(\"title\") ?? fallback);\n }\n return \"\";\n };\n const isDisabled = (element) => element.matches(\":disabled\") || element.getAttribute(\"aria-disabled\") === \"true\";\n const refFor = (element) => {\n const known = byElement.get(element);\n if (known !== void 0 && byRef.get(known)?.deref() === element) return known;\n const ref = `e${refs.next++}`;\n byElement.set(element, ref);\n byRef.set(ref, new WeakRef(element));\n return ref;\n };\n const lookup = (ref) => {\n const element = byRef.get(ref)?.deref();\n return element !== void 0 && element.isConnected && inCurrentDocument(element) ? element : void 0;\n };\n const describe = (element) => {\n const id = element.id === \"\" ? \"\" : `#${element.id}`;\n const name = clean(nameOf(element, roleOf(element)), 40);\n return `<${element.tagName.toLowerCase()}${id}>${name === \"\" ? \"\" : ` \"${name}\"`}`;\n };\n const isRoot = (node) => node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;\n const parentOf = (element) => {\n const root = element.getRootNode();\n return element.parentElement ?? (isRoot(root) && \"host\" in root ? root.host : null);\n };\n const activeElement = () => {\n let active = document.activeElement;\n while (active !== null) {\n const inner = active.shadowRoot?.activeElement ?? (isFrame(active) ? active.contentDocument?.activeElement : null);\n if (inner === null || inner === void 0 || inner === active) return active;\n active = inner;\n }\n return null;\n };\n const inCurrentDocument = (element) => {\n let owner = element.ownerDocument;\n while (owner !== document) {\n const frame = owner.defaultView?.frameElement;\n if (frame === null || frame === void 0 || !frame.isConnected || isFrame(frame) && frame.contentDocument !== owner) return false;\n owner = frame.ownerDocument;\n }\n return true;\n };\n const secretToken = /(?:^|\\s)(?:current-password|new-password|one-time-code|cc-number|cc-csc|cc-exp(?:-month|-year)?)(?=\\s|$)/i;\n const secrets = /* @__PURE__ */ new WeakSet();\n /**\n * A field the DOM marks as secret, now or before: by its type, its autocomplete tokens, or a\n * style that shows dots for what it holds, as a PIN field may.\n */\n const isSecret = (element) => {\n if (isInput(element) && element.type === \"password\" || secretToken.test(element.getAttribute(\"autocomplete\") ?? \"\") || (isInput(element) || isTextArea(element)) && !/^(none)?$/.test(getComputedStyle(element).getPropertyValue(\"-webkit-text-security\"))) secrets.add(element);\n return secrets.has(element);\n };\n return {\n ...native,\n activeElement,\n containers,\n describe,\n inCurrentDocument,\n interactiveRoles,\n isDisabled,\n isRoot,\n isSecret,\n lookup,\n nameOf,\n parentOf,\n refFor,\n refs,\n roleOf\n };\n };\n //#endregion\n //#region src/internal/reading/outline.inpage.ts\n const outline = (names, walked, subjects, texts, controlling, url) => {\n const { clean, containers, isFrame, nameOf, refFor, roleOf, textOf } = names;\n const { visit } = walked;\n const { isControl } = subjects;\n const { cut } = texts;\n const textBlocks = /^(?:P|LI|TD|TH|DT|DD|LABEL|SPAN|BLOCKQUOTE|FIGCAPTION|CAPTION|PRE|STRONG|EM|B|I|SMALL|TIME|CODE|LEGEND)$/;\n const nested = \"a[href],button,input,select,textarea,summary,[role],[onclick],[tabindex],[contenteditable],canvas,iframe\";\n const noise = /^[\\s|•·\\-–—,.:;()[\\]{}\"'/\\\\]*$/;\n /** Text inside a control's label is already that control's name. */\n const inControlLabel = (element) => {\n const label = element.closest(\"label\");\n return label !== null && label.control !== null;\n };\n const hrefOf = (element) => {\n if (element.tagName !== \"A\") return \"\";\n const raw = element.getAttribute(\"href\") ?? \"\";\n if (raw === \"\" || raw.startsWith(\"javascript:\")) return \"\";\n try {\n const { origin, href } = new URL(raw, element.ownerDocument.baseURI);\n const reported = url.redact(href);\n const own = origin === location.origin && reported.startsWith(origin);\n return ` -> ${clean(own ? reported.slice(origin.length) : reported, 80)}`;\n } catch {\n return \"\";\n }\n };\n const snapshot = (request) => {\n const roots = request.within === null ? [null] : controlling.rootsOf(request.within);\n if (\"invalid\" in roots) return roots;\n const width = window.innerWidth;\n const height = window.innerHeight;\n const query = request.query === null ? null : request.query.toLowerCase();\n const lines = [];\n const controls = [];\n let above = 0;\n let below = 0;\n const placement = (rect) => {\n if (request.full) return \"in\";\n if (rect.bottom <= 0) return \"above\";\n if (rect.top >= height) return \"below\";\n if (rect.right <= 0 || rect.left >= width) return \"aside\";\n return \"in\";\n };\n const count = (rect) => {\n const where = placement(rect);\n if (where === \"above\") above++;\n if (where === \"below\") below++;\n return where;\n };\n const emit = (depth, line, rect) => {\n if (count(rect) !== \"in\") return false;\n if (query !== null && !line.toLowerCase().includes(query)) return false;\n lines.push(`${\" \".repeat(Math.min(depth, 8))}- ${line}`);\n return true;\n };\n const control = (element, rect, role, depth) => {\n const name = nameOf(element, role);\n const kind = role ?? \"clickable\";\n const box = request.boxes || role === \"canvas\" || role === \"iframe\" ? ` ${Math.round(rect.width)}x${Math.round(rect.height)} at (${Math.round(rect.x)},${Math.round(rect.y)})` : \"\";\n const line = placement(rect) === \"in\" ? `${kind}${name === \"\" ? \"\" : ` ${JSON.stringify(name)}`} [ref=${refFor(element)}]${controlling.states(element, role)}${controlling.valueOf(element)}${hrefOf(element)}${box}` : kind;\n if (emit(depth, line, rect)) controls.push(controlling.controlOf(element, role, kind, name));\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n if ((body === null || body === void 0) && placement(rect) === \"in\") lines.push(`${\" \".repeat(Math.min(depth + 1, 8))}- (another site's frame: use a screenshot and coordinates)`);\n return {\n depth: depth + 1,\n insidePointer: false,\n controls: false\n };\n }\n if ([\n \"INPUT\",\n \"SELECT\",\n \"TEXTAREA\",\n \"CANVAS\",\n \"IMG\"\n ].includes(element.tagName)) return void 0;\n return {\n depth: depth + 1,\n insidePointer: true,\n controls: true\n };\n };\n const enter = (element, style, rect, { depth, insidePointer }) => {\n const role = roleOf(element);\n if (isControl(element, role, style, rect, insidePointer)) return control(element, rect, role, depth);\n if (role === \"heading\") {\n emit(depth, `heading ${JSON.stringify(nameOf(element, role))}${controlling.states(element, role)}`, rect);\n return;\n }\n if (role === \"img\") {\n const alt = nameOf(element, role);\n if (alt !== \"\") emit(depth, `img ${JSON.stringify(alt)}`, rect);\n return;\n }\n let inner = depth;\n if (role !== null && (containers[element.tagName] !== void 0 || role === \"dialog\")) {\n const label = element.getAttribute(\"aria-label\");\n if (emit(depth, `${role}${label === null ? \"\" : ` ${JSON.stringify(clean(label))}`}:`, rect)) inner = depth + 1;\n }\n if (textBlocks.test(element.tagName) && element.querySelector(nested) === null) {\n if (inControlLabel(element)) return void 0;\n const text = clean(textOf(element), 300);\n if (text !== \"\" && !noise.test(text)) emit(inner, `text: ${text}`, rect);\n return;\n }\n let own = \"\";\n for (const node of Array.from(element.childNodes)) if (node.nodeType === Node.TEXT_NODE) own += node.textContent ?? \"\";\n own = clean(own, 300);\n if (own !== \"\" && !noise.test(own) && !inControlLabel(element)) emit(inner, `text: ${own}`, rect);\n return {\n depth: inner,\n insidePointer: insidePointer || style.cursor === \"pointer\",\n controls: false\n };\n };\n const visitor = {\n enter,\n admit: (child, place) => !place.controls || child.matches(nested) || child.querySelector(nested) !== null,\n outside: count\n };\n for (const root of roots) visit(root, !request.full, {\n depth: 0,\n insidePointer: false,\n controls: false\n }, visitor);\n const outlined = cut(lines.join(\"\\n\"), request.maxChars);\n return { snapshot: {\n ...outlined,\n url: location.href,\n title: document.title,\n above,\n below,\n viewport: {\n width,\n height\n },\n scroll: {\n y: Math.round(window.scrollY),\n height: Math.round(document.documentElement.scrollHeight)\n },\n controls: controls.filter((control) => outlined.text.includes(`[ref=${control.ref}]`))\n } };\n };\n const viewport = () => ({\n width: window.innerWidth,\n height: window.innerHeight\n });\n return {\n snapshot,\n viewport\n };\n };\n //#endregion\n //#region src/internal/reading/ready.inpage.ts\n const ready = (walked, texts, kept) => {\n const { inView, visible } = walked;\n let copy;\n const boxed = (element) => {\n const rect = element.getBoundingClientRect();\n return rect.width * rect.height > 0 && inView(rect);\n };\n const showing = (elements) => Array.from(elements).filter((element) => boxed(element) && visible(element));\n const drawn = (canvas) => {\n copy ??= new OffscreenCanvas(32, 32).getContext(\"2d\", { willReadFrequently: true });\n if (copy === null) return true;\n try {\n copy.clearRect(0, 0, 32, 32);\n copy.imageSmoothingQuality = \"high\";\n copy.drawImage(canvas, 0, 0, 32, 32);\n return new Uint32Array(copy.getImageData(0, 0, 32, 32).data.buffer).some((pixel) => pixel !== 0);\n } catch {\n return true;\n }\n };\n const content = () => showing(document.querySelectorAll(\"video, iframe, embed, object\")).length > 0 || showing(document.querySelectorAll(\"img, svg\")).some((picture) => {\n const { width, height } = picture.getBoundingClientRect();\n return width > 64 && height > 64;\n }) || (texts.read({\n ref: null,\n maxChars: 1,\n unmask: false\n })?.text ?? \"\") !== \"\" || showing(document.querySelectorAll(\"canvas\")).some(drawn);\n const painted = () => {\n const { promise, resolve } = Promise.withResolvers();\n if (document.visibilityState === \"hidden\") resolve(false);\n else requestAnimationFrame(() => resolve(true));\n return promise;\n };\n const check = (quietMillis) => painted().then((paints) => {\n const waiting = [];\n if (document.readyState === \"loading\") waiting.push(\"load\");\n if (!paints) waiting.push(\"paint\");\n if (document.getAnimations().some((animation) => {\n const effect = animation.effect;\n return animation.playState === \"running\" && effect !== null && Number.isFinite(effect.getComputedTiming().endTime) && \"target\" in effect && effect.target instanceof Element && boxed(effect.target);\n })) waiting.push(\"animations\");\n if (Array.from(document.images).some((image) => !image.complete && boxed(image))) waiting.push(\"images\");\n if (document.fonts.status !== \"loaded\") waiting.push(\"fonts\");\n if (showing(document.querySelectorAll(\"[aria-busy=true]\")).length > 0) waiting.push(\"busy\");\n if (!content()) waiting.push(\"content\");\n if (kept.changing() > performance.timeOrigin + performance.now() - quietMillis) waiting.push(\"changing\");\n return waiting;\n });\n /**\n * Check until the page is ready, or for `millis`, and say what it is still waiting for; with\n * `quietMillis`, until nothing the record saw in view has changed for that long, too.\n */\n const wait = async (millis, quietMillis = 0) => {\n const until = performance.now() + millis;\n for (;;) {\n const waiting = await check(quietMillis);\n if (waiting.length === 0 || performance.now() >= until) return waiting;\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, Math.min(50, until - performance.now()));\n await promise;\n }\n };\n /**\n * One task, then a frame: what the page's handlers for input did at once has run, a navigation\n * one of them started in a timer has been asked for, and their effect has painted. Says whether\n * the page painted, which a hidden one does not.\n */\n const settle = () => {\n const { promise, resolve } = Promise.withResolvers();\n setTimeout(resolve, 0);\n return promise.then(painted);\n };\n return {\n wait,\n settle\n };\n };\n //#endregion\n //#region src/internal/reading/subjects.inpage.ts\n const states = (names) => (element, role) => {\n const { isDisabled, isInput } = names;\n const given = (attribute) => {\n const value = element.getAttribute(attribute);\n return value === \"true\" || (value === \"false\" ? false : void 0);\n };\n const checkable = element.hasAttribute(\"aria-checked\") || [\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"menuitemcheckbox\",\n \"menuitemradio\"\n ].includes(role ?? \"\");\n return {\n disabled: isDisabled(element),\n checked: checkable ? isInput(element) && element.checked || element.getAttribute(\"aria-checked\") === \"true\" : void 0,\n expanded: given(\"aria-expanded\"),\n selected: given(\"aria-selected\"),\n pressed: given(\"aria-pressed\"),\n focused: element.ownerDocument.activeElement === element,\n level: role === \"heading\" ? Number(element.getAttribute(\"aria-level\")) || Number(/^H([1-6])$/.exec(element.tagName)?.[1]) || 2 : void 0\n };\n };\n const subjects = (names, walked, matching, placing, stateOf) => {\n const { isDisabled, nameOf, refFor, roleOf, textOf } = names;\n const { acts, boxOf, controlOf, hitAt, inView } = walked;\n const { contextOf, known } = placing;\n /** What the outline lists as a control, with a ref: something a person would act on. */\n const isControl = (element, role, style, rect, insidePointer) => acts(element, role) || style.cursor === \"pointer\" && !insidePointer && rect.width > 0 && rect.height > 0;\n /**\n * The elements in scope that match a query, in tree order. Without text, an element matches\n * when it has a role or is a control. With text, any element can, but text inside a control or\n * heading is that control's or heading's, and an element is left out when one inside it\n * matches too: the smallest element showing the text is found, not each one around it.\n */\n const matched = (request) => {\n const { at } = request;\n const matches = matching.compile(request);\n const byText = request.text !== null;\n const viewport = request.scope === \"viewport\";\n const read = known();\n if (request.selector !== null) try {\n document.querySelector(request.selector);\n } catch {\n return { invalid: `${JSON.stringify(request.selector)} is not a CSS selector` };\n }\n const eligible = (element) => (request.selector === null || element.matches(request.selector)) && (request.state !== \"enabled\" || !isDisabled(element));\n const entries = [];\n const open = [];\n const named = (entry) => entry.name ??= nameOf(entry.element, entry.role);\n const placed = (entry) => entry.context ??= contextOf(entry.element, read);\n const judge = (entry, text) => matches({\n role: entry.role,\n name: () => named(entry),\n text,\n context: () => placed(entry)\n });\n const hit = at === null ? null : hitAt(document, at.x, at.y);\n if (hit !== null) {\n const element = controlOf(hit);\n const { x, y, width, height } = boxOf(element);\n const entry = {\n element,\n rect: new DOMRect(x, y, width, height),\n role: roleOf(element, request.role !== null),\n matched: false\n };\n entry.matched = eligible(element) && judge(entry, () => textOf(element));\n entries.push(entry);\n }\n if (at === null) walked.visit(null, viewport, {\n pointer: false,\n owned: false\n }, {\n enter: (element, style, rect, state) => {\n const role = roleOf(element, request.role !== null);\n const control = isControl(element, role, style, rect, state.pointer);\n const unit = control || role === \"heading\";\n const entry = eligible(element) && (byText ? unit || !state.owned : request.selector !== null || role !== null || control) && (!viewport || inView(rect)) ? {\n element,\n rect,\n role,\n matched: false\n } : void 0;\n if (entry !== void 0) entries.push(entry);\n open.push({\n entry,\n inline: style.display === \"inline\",\n parts: [],\n inside: false\n });\n return {\n pointer: state.pointer || style.cursor === \"pointer\",\n owned: state.owned || unit\n };\n },\n text: byText ? (node) => open.at(-1)?.parts.push(node.textContent ?? \"\") : void 0,\n leave: () => {\n const closed = open.pop();\n const parent = open.at(-1);\n if (closed === void 0) return;\n const { entry } = closed;\n const text = closed.parts.join(\"\");\n if (parent !== void 0) parent.parts.push(closed.inline ? text : ` ${text} `);\n if (entry !== void 0 && !(byText && closed.inside)) entry.matched = judge(entry, () => text);\n if (parent !== void 0) parent.inside ||= closed.inside || entry?.matched === true;\n }\n });\n return {\n entries: entries.filter((entry) => entry.matched),\n named,\n placed\n };\n };\n const find = (request) => {\n const result = matched(request);\n if (result.invalid !== void 0) return { invalid: result.invalid };\n const { entries, named, placed } = result;\n return { found: entries.map((entry) => ({\n ref: refFor(entry.element),\n subject: {\n role: entry.role,\n name: named(entry),\n tag: entry.element.tagName.toLowerCase(),\n context: placed(entry)\n },\n box: {\n x: Math.round(entry.rect.x),\n y: Math.round(entry.rect.y),\n width: Math.round(entry.rect.width),\n height: Math.round(entry.rect.height)\n },\n inViewport: inView(entry.rect),\n state: stateOf(entry.element, entry.role)\n })) };\n };\n /** The elements `find` would find, in tree order, with no refs given. */\n const elementsOf = (request) => {\n const result = matched(request);\n return result.invalid !== void 0 ? { invalid: result.invalid } : result.entries.map((entry) => entry.element);\n };\n return {\n find,\n elementsOf,\n isControl,\n stateOf\n };\n };\n //#endregion\n //#region src/internal/reading/text.inpage.ts\n const text = (names, walked) => {\n const { isHtml, isInput, isSecret, isSelect, isTextArea, lookup } = names;\n const valueless = [\n \"checkbox\",\n \"radio\",\n \"button\",\n \"submit\",\n \"reset\",\n \"image\",\n \"file\"\n ];\n /** What a field holds, or undefined for an element that holds nothing entered. */\n const valueOf = (element) => {\n if (isInput(element)) return valueless.includes(element.type) ? void 0 : element.value;\n if (isTextArea(element)) return element.value;\n if (isSelect(element)) return Array.from(element.selectedOptions, (option) => option.text).join(\", \");\n const parent = element.parentElement;\n return isHtml(element) && element.isContentEditable && !(parent !== null && isHtml(parent) && parent.isContentEditable) ? element.innerText : void 0;\n };\n /** What a field shows: `••••` unless `unmask`, and always for a secret field; \"\" when empty. */\n const shown = (element, unmask) => {\n const value = valueOf(element);\n if (value === void 0 || value.trim() === \"\") return value === void 0 ? void 0 : \"\";\n return unmask && !isSecret(element) ? value : \"••••\";\n };\n /** Lines cut after the last whole line within `max` characters, or at `max` when none is. */\n const cut = (lines, max) => {\n if (lines.length <= max) return {\n text: lines,\n truncated: false\n };\n const end = lines.lastIndexOf(\"\\n\", max);\n return {\n text: lines.slice(0, end > 0 ? end : max),\n truncated: true\n };\n };\n /**\n * What the viewport, or one element whole, shows as text: a line per block, table cells apart by\n * a tab, and each field as `shown` gives it.\n */\n const lines = (root, unmask) => {\n const lines = [];\n let line = \"\";\n const end = () => {\n const words = line.replace(/[^\\S\\t]+/g, \" \").replace(/ ?\\t ?/g, \" \").trim();\n if (words !== \"\") lines.push(words);\n line = \"\";\n };\n walked.visit(root, root === null, false, {\n enter: (element, style) => {\n const { display } = style;\n const value = shown(element, unmask);\n const block = !display.startsWith(\"inline\") && display !== \"contents\" && display !== \"table-cell\";\n if (display === \"table-cell\") line += \" \";\n if (block || element.tagName === \"BR\") end();\n if (value === void 0 && !(isInput(element) && valueless.includes(element.type))) return block;\n const label = isInput(element) && /^(button|submit|reset)$/.test(element.type);\n line += ` ${value ?? (label ? element.value : \"\")} `;\n if (block) end();\n },\n text: (node) => {\n line += node.textContent ?? \"\";\n },\n leave: (_, block) => {\n if (block) end();\n }\n });\n end();\n return lines.join(\"\\n\");\n };\n const read = (request) => {\n const root = request.ref === null ? null : lookup(request.ref);\n return root === void 0 ? null : {\n ...cut(lines(root, request.unmask), request.maxChars),\n url: location.href,\n title: document.title\n };\n };\n return {\n cut,\n lines,\n read,\n shown\n };\n };\n //#endregion\n //#region src/internal/reading/walk.inpage.ts\n const walk = (names) => {\n const { interactiveRoles, isElement, isFrame, isInput, parentOf, roleOf } = names;\n const skipped = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE HEAD META LINK SVG\".split(\" \"));\n /** Whether a box, in top-document pixels, meets the viewport. */\n const inView = (rect, width = innerWidth, height = innerHeight) => rect.right > 0 && rect.bottom > 0 && rect.left < width && rect.top < height;\n /** Whether an element reached on its own shows, by the walk's rule and its ancestors'. */\n const visible = (element) => {\n if (element.closest(\"[aria-hidden=true]\") !== null) return false;\n if (element.checkVisibility({\n opacityProperty: true,\n visibilityProperty: true\n })) return true;\n if (getComputedStyle(element).display !== \"contents\") return false;\n for (let node = element; node !== null; node = parentOf(node)) {\n const style = getComputedStyle(node);\n if (style.display === \"none\" || style.opacity === \"0\" || node === element && style.visibility !== \"visible\") return false;\n }\n return true;\n };\n const untransformed = (frame, rect) => {\n if (rect.width !== frame.offsetWidth || rect.height !== frame.offsetHeight) return false;\n let ancestor = frame;\n while (ancestor !== null) {\n const style = (ancestor.ownerDocument.defaultView ?? window).getComputedStyle(ancestor);\n if (style.transform !== \"none\" || style.scale !== \"none\" || style.rotate !== \"none\" || style.perspective !== \"none\" || style.zoom !== \"1\") return false;\n ancestor = parentOf(ancestor);\n }\n return true;\n };\n /** The element painted at a point, inside shadow roots and same-origin frames. */\n const hitAt = (root, x, y) => {\n let hit = root.elementFromPoint(x, y);\n while (hit?.shadowRoot !== null && hit?.shadowRoot !== void 0) {\n const inner = hit.shadowRoot.elementFromPoint(x, y);\n if (inner === null || inner === hit) break;\n hit = inner;\n }\n if (hit !== null && isFrame(hit)) {\n const document = hit.contentDocument;\n if (document !== null) {\n const rect = hit.getBoundingClientRect();\n if (untransformed(hit, rect)) return hitAt(document, x - rect.left - hit.clientLeft, y - rect.top - hit.clientTop) ?? hit;\n }\n }\n return hit;\n };\n /** Whether its role or a click handler makes an element a control. */\n const acts = (element, role) => isInput(element) && element.type !== \"hidden\" || role !== null && (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\") || element.hasAttribute(\"onclick\");\n const controlOf = (hit) => {\n let element = hit;\n while (element !== null) {\n if (acts(element, roleOf(element))) return element;\n element = parentOf(element);\n }\n return hit;\n };\n /** An element's box in top-document viewport pixels, through the frames around it. */\n const boxOf = (element) => {\n const { x, y, width, height } = element.getBoundingClientRect();\n const frame = element.ownerDocument.defaultView?.frameElement ?? null;\n if (frame === null) return {\n x,\n y,\n width,\n height\n };\n const outer = boxOf(frame);\n return {\n x: x + outer.x + frame.clientLeft,\n y: y + outer.y + frame.clientTop,\n width,\n height\n };\n };\n /** What is painted where pinned things sit, what is pinned in view, and every element holding it. */\n const painted = (width, height) => {\n const keep = /* @__PURE__ */ new Set();\n const hold = (element) => {\n for (let node = element; node !== null && !keep.has(node); node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null) keep.add(node);\n };\n for (const y of [\n 8,\n 48,\n height / 2,\n height - 48,\n height - 8\n ]) for (const x of [\n 8,\n 48,\n width / 4,\n width / 2,\n width * 3 / 4,\n width - 48,\n width - 8\n ]) if (x >= 0 && y >= 0 && x < width && y < height) {\n hold(hitAt(document, x, y));\n for (const beneath of document.elementsFromPoint(x, y)) hold(beneath);\n }\n for (const element of Array.from(document.querySelectorAll(\":modal, :popover-open\"))) hold(element);\n for (const element of Array.from(document.querySelectorAll(\"[style*=\\\"fixed\\\" i]\"))) if (inView(element.getBoundingClientRect(), width, height)) hold(element);\n return keep;\n };\n /**\n * Visit `root` and what it holds, or the whole document when `root` is null. With `viewport`,\n * a subtree outside the viewport is skipped, as described above.\n */\n const visit = (root, viewport, state, visitor) => {\n const { innerWidth: width, innerHeight: height } = window;\n let keep;\n const children = (parent, inner, dx, dy) => {\n const nodes = visitor.text === void 0 ? parent.children : parent.childNodes;\n for (const node of Array.from(nodes)) if (node.nodeType === Node.TEXT_NODE) visitor.text?.(node, inner);\n else if (isElement(node) && (visitor.admit === void 0 || visitor.admit(node, inner))) one(node, inner, dx, dy);\n };\n const one = (element, outer, dx, dy) => {\n if (skipped.has(element.tagName.toUpperCase())) return;\n const local = element.getBoundingClientRect();\n const rect = new DOMRect(local.x + dx, local.y + dy, local.width, local.height);\n if (viewport && local.width > 0 && local.height > 0 && !inView(rect, width, height) && !(keep ??= painted(width, height)).has(element)) {\n visitor.outside?.(rect);\n return;\n }\n const style = getComputedStyle(element);\n if (style.display === \"none\" || style.opacity === \"0\" || element.getAttribute(\"aria-hidden\") === \"true\") return;\n if (!visible(element)) {\n for (const child of Array.from(element.children)) one(child, outer, dx, dy);\n return;\n }\n const inner = visitor.enter(element, style, rect, outer);\n if (inner === void 0) return;\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n if (body !== null && body !== void 0) children(body, inner, rect.x, rect.y);\n } else {\n if (element.shadowRoot !== null) children(element.shadowRoot, inner, dx, dy);\n children(element, inner, dx, dy);\n }\n visitor.leave?.(element, inner);\n };\n if (root === null) children(document, state, 0, 0);\n else one(root, state, 0, 0);\n };\n return {\n acts,\n boxOf,\n controlOf,\n hitAt,\n inView,\n visible,\n visit\n };\n };\n //#endregion\n //#region src/internal/timeline/changes.inpage.ts\n const changes = (names, placing, kept, seeing, marking, recorder) => {\n const { clean, isInput, roleOf, nameOf } = names;\n const groups = \"tr,[role=row],form,dialog,[role=dialog],[role=alertdialog]\";\n /** Whether `element` lies in what an input on `target` acted on, its group, or what it controls. */\n const local = (target, element) => {\n const controls = target.closest(\"[aria-controls]\")?.getAttribute(\"aria-controls\") ?? \"\";\n const group = target.closest(groups);\n return target.contains(element) || group?.contains(element) === true || controls.split(/\\s+/).some((id) => id !== \"\" && document.getElementById(id)?.contains(element) === true);\n };\n /** What an element sits in, or sat in as it went. */\n const parentOf = (key) => key instanceof Element ? key.isConnected ? key.parentElement : marking.placeOf(key) ?? null : null;\n const fluxMillis = 1e4;\n const stillMillis = 2e3;\n /**\n * Each input a change may follow, with what the page did before it: what changed in the 10 s\n * before, the parents that gained or lost a child then, and whether nothing changed, and nothing\n * was let go, in the 2 s before. What holds the input's target, as a menu holds its item, came\n * with it, so it counts only as changing itself.\n */\n const before = () => {\n const inputs = recorder.inputs();\n if (inputs.length === 0) return [];\n const { tracks, losses } = kept.recent();\n return inputs.map(({ at, target }) => {\n const changed = /* @__PURE__ */ new Set();\n const moved = /* @__PURE__ */ new Set();\n let still = losses.every((lost) => lost >= at || lost < at - stillMillis);\n for (const { key, kind, initial, samples } of tracks) {\n const prior = samples.flatMap(({ at: when, shown }, index) => kind === \"value\" || when >= at || when < at - fluxMillis ? [] : [shown === null || (index === 0 ? initial : samples[index - 1]?.shown) === null]);\n if (prior.length > 0) changed.add(key);\n if (prior.length === 0 || key instanceof Element && key.contains(target)) continue;\n if (prior.includes(true)) moved.add(parentOf(key));\n if (samples.some(({ at: when }) => when < at && when >= at - stillMillis)) still = false;\n }\n return {\n at,\n target,\n changed,\n moved,\n still\n };\n });\n };\n /** The input a change followed, on the page's clock, where `Change.cause`'s rule names one. */\n const causeOf = (one, element, inputs) => {\n const parent = parentOf(one.track.key);\n for (const input of inputs.toReversed()) {\n const after = one.startedAt - input.at;\n if (after < 0) continue;\n if (after > 3e3) break;\n if (!(one.track.known >= input.at - fluxMillis || input.changed.has(one.track.key) || parent !== null && input.moved.has(parent)) && (local(input.target, element) || after <= 500 && input.still)) return input.at;\n }\n };\n const describe = (one, known, unmask, inputs) => {\n const { track, kind, before, after, lowest, highest, ...times } = one;\n const element = track.key instanceof Element ? track.key : null;\n const where = element?.isConnected === true ? element : marking.placeOf(track.key) ?? null;\n const role = element === null ? null : roleOf(element);\n const field = kind === \"value\";\n const checkable = element !== null && isInput(element) && /^(checkbox|radio)$/.test(element.type);\n const masked = (value) => value === void 0 || !field || unmask || checkable || value === \"\" ? value : \"••••\";\n return {\n ...times,\n kind,\n subject: {\n role,\n name: element === null ? \"\" : field ? nameOf(element, role) : clean(element.getAttribute(\"aria-label\"), 120),\n tag: element === null ? \"title\" : element.tagName.toLowerCase(),\n context: kind === \"title\" || where === null ? {} : placing.contextOf(where, known)\n },\n before: masked(before),\n after: masked(after),\n lowest: field ? void 0 : lowest,\n highest: field ? void 0 : highest,\n cause: field || where === null ? void 0 : causeOf(one, where, inputs)\n };\n };\n /** What changed after `since`, up to `until`, and no later than now. */\n const read = (request) => {\n const now = performance.timeOrigin + performance.now();\n recorder.start();\n seeing.settle();\n const until = Math.min(request.until ?? now, now);\n const { from, dropped, folded } = kept.read(request.since ?? Number.NEGATIVE_INFINITY, until, now);\n const known = placing.known();\n const inputs = before();\n return {\n until,\n from,\n dropped,\n records: folded.map((one) => describe(one, known, request.unmask, inputs))\n };\n };\n return { read };\n };\n //#endregion\n //#region src/internal/timeline/fold.inpage.ts\n const fold = () => {\n /** The one number some words show, such as 61240 in \"$61,240\"; none for none or several. */\n const number = (words) => {\n const found = words.match(/[-+−]?\\d[\\d,]*(?:\\.\\d+)?/g);\n const value = Number(found?.length === 1 ? found[0]?.replaceAll(\",\", \"\").replace(\"−\", \"-\") : \"\");\n return found?.length === 1 && Number.isFinite(value) ? [value] : [];\n };\n /** A track's changes after `since`, up to `until`, if one was seen in view. */\n const over = (track, since, until) => {\n const inside = track.samples.filter((sample) => sample.at > since && sample.at <= until);\n const first = inside[0];\n const last = inside.at(-1);\n if (first === void 0 || last === void 0 || !inside.some((sample) => sample.seen === true)) return void 0;\n const prior = track.samples[track.samples.indexOf(first) - 1];\n const lost = track.known <= since ? track.known : void 0;\n const start = prior === void 0 ? lost === void 0 ? void 0 : track.initial : prior.shown;\n const words = [start, ...inside.map((sample) => sample.shown)].filter((each) => typeof each === \"string\");\n const numbers = words.flatMap(number);\n const ranged = inside.length > 1 && numbers.length === words.length;\n const kind = track.kind !== \"content\" ? track.kind : last.shown === null ? start === null ? \"brief\" : \"disappeared\" : start === null ? \"appeared\" : \"text\";\n return {\n track,\n kind,\n startedAt: first.at,\n at: last.at,\n before: kind === \"disappeared\" ? words.at(-1) : start ?? void 0,\n after: kind === \"brief\" ? words.at(-1) : last.shown ?? void 0,\n count: inside.length,\n lowest: ranged ? words[numbers.indexOf(Math.min(...numbers))] : void 0,\n highest: ranged ? words[numbers.indexOf(Math.max(...numbers))] : void 0,\n earlier: prior?.at ?? (lost === Number.NEGATIVE_INFINITY ? void 0 : lost)\n };\n };\n /**\n * How readily a track gives way when the record is full: one that holds no change first, then\n * one that keeps changing, one never seen in view and one that has gone; news never does.\n */\n const rank = ({ samples: [only, ...more] }) => only === void 0 ? 4 : more.length > 0 ? 3 : only.seen === false ? 2 : only.shown === null ? 1 : 0;\n return {\n number,\n over,\n rank\n };\n };\n //#endregion\n //#region src/internal/timeline/history.inpage.ts\n const history = (folding, bounds = {\n tracks: 256,\n samples: 32,\n retention: 6e4\n }) => {\n const { tracks: maxTracks, samples: maxSamples, retention } = bounds;\n const tracks = /* @__PURE__ */ new Map();\n let refused = /* @__PURE__ */ new WeakSet();\n let losses = [];\n let lastLoss = Number.NEGATIVE_INFINITY;\n const gone = [];\n let begun;\n const lose = (at, count) => {\n const last = losses.at(-1);\n if (count <= 0) return;\n lastLoss = Math.max(lastLoss, at);\n if (last?.[0] === at) last[1] += count;\n else losses.push([at, count]);\n if (losses.length > 256) losses.shift();\n };\n const latest = (track) => track.samples.at(-1)?.at ?? Number.NEGATIVE_INFINITY;\n const drop = (track) => {\n tracks.delete(track.key);\n gone.push(track.key);\n };\n let version = 0;\n let barren = -1;\n /** What gives way for a newcomer: one that holds no change, then one that keeps changing. */\n const victim = () => {\n let chosen;\n let rank = 0;\n for (const track of barren === version ? [] : tracks.values()) {\n const next = folding.rank(track);\n if (next > rank) [chosen, rank] = [track, next];\n if (rank === 4) break;\n }\n if (chosen === void 0) barren = version;\n return chosen;\n };\n const evict = (track) => {\n drop(track);\n if (track.samples.length > 0) refused.add(track.key);\n for (const sample of track.samples) lose(sample.at, 1);\n };\n /** A key the record cannot keep: its change is counted. */\n const refuse = (key, at) => {\n refused.add(key);\n lose(at, 1);\n };\n /**\n * A new state for `key` at `at`: its sample, or none when it is no change or finds no room.\n * `initial` says what a key not yet kept showed before.\n */\n const note = (key, kind, at, shown, initial) => {\n let track = tracks.get(key);\n if (track === void 0) {\n const full = !refused.has(key) && tracks.size >= maxTracks;\n const out = full ? victim() : void 0;\n if (refused.has(key) || full && out === void 0) return refuse(key, at);\n const before = initial();\n if (shown !== void 0 && shown === before) return void 0;\n if (out !== void 0) evict(out);\n track = {\n key,\n kind,\n initial: before,\n known: Number.NEGATIVE_INFINITY,\n samples: []\n };\n tracks.set(key, track);\n }\n const { samples } = track;\n version++;\n if (samples.at(-1)?.at === at) samples.pop();\n const previous = samples.length === 0 ? track.initial : samples.at(-1)?.shown;\n if (shown !== void 0 && shown === previous) return void 0;\n const oldest = samples.length >= maxSamples ? samples.shift() : void 0;\n if (oldest !== void 0) {\n track.initial = oldest.shown;\n track.known = oldest.at;\n lose(oldest.at, 1);\n }\n const sample = {\n at,\n shown,\n seen: void 0\n };\n samples.push(sample);\n return sample;\n };\n /** Judge a sample as the page rendered it; a state that repeats the one before is no change. */\n const settle = (key, sample, shown, seen) => {\n const track = tracks.get(key);\n version++;\n if (sample.shown === void 0) sample.shown = shown;\n if (sample.seen === void 0) sample.seen = seen;\n if (track === void 0) return;\n let previous = track.initial;\n const changes = track.samples.filter((each) => {\n const same = each.shown !== void 0 && each.shown === previous;\n if (!same) previous = each.shown;\n return !same;\n });\n track.samples.splice(0, track.samples.length, ...changes);\n };\n /**\n * The window after `since`, up to `until`: where the record is whole, how many changes in it the\n * record let go, and each element's changes, oldest first by when they began.\n */\n const read = (since, until, now) => {\n for (const track of tracks.values()) if (latest(track) < now - retention) drop(track);\n return {\n from: Math.min(until, Math.max(begun ?? now, now - retention, lastLoss)),\n dropped: losses.reduce((sum, [at, count]) => at > since && at <= until ? sum + count : sum, 0),\n folded: [...tracks.values()].flatMap((track) => folding.over(track, since, until) ?? []).toSorted((left, right) => left.startedAt - right.startedAt)\n };\n };\n /** When something in view last changed, or something not yet judged; for a wait for stillness. */\n const changing = () => Math.max(begun ?? Number.NEGATIVE_INFINITY, ...Array.from(tracks.values(), (track) => track.samples.findLast((sample) => sample.seen !== false)?.at ?? Number.NEGATIVE_INFINITY));\n return {\n begin: (at) => {\n begun = at;\n },\n begun: () => begun !== void 0,\n clear: () => {\n for (const track of tracks.values()) drop(track);\n refused = /* @__PURE__ */ new WeakSet();\n losses = [];\n lastLoss = Number.NEGATIVE_INFINITY;\n begun = void 0;\n },\n changing,\n /** Keys whose tracks went since this was last asked, for the recorder to stop watching. */\n forgotten: () => gone.splice(0),\n has: (key) => tracks.has(key),\n /** Whether the record has let `key` go: its later changes are counted, never kept. */\n refuses: (key) => refused.has(key),\n lose,\n note,\n read,\n /** Each element's history, and when the record let changes go, for a read to judge causes. */\n recent: () => ({\n tracks: [...tracks.values()],\n losses: losses.map(([at]) => at)\n }),\n /** A track moves to the element that took its key's place, as a re-rendered price does. */\n rekey: (from, to) => {\n const track = tracks.get(from);\n if (track === void 0 || tracks.has(to)) return false;\n tracks.delete(from);\n track.key = to;\n tracks.set(to, track);\n return true;\n },\n settle\n };\n };\n //#endregion\n //#region src/internal/timeline/marks.inpage.ts\n const marks = (names, kept, seeing) => {\n const { clean, isElement, isHtml } = names;\n const unwritten = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE TITLE\".split(\" \"));\n const hiding = /display\\s*:\\s*none|visibility\\s*:\\s*hidden|opacity\\s*:\\s*0(?![.\\d])/i;\n let places = /* @__PURE__ */ new WeakMap();\n let title = \"\";\n const words = (text) => clean(text, 200) || null;\n const content = (element, at, shown, initial) => {\n const sample = kept.note(element, \"content\", at, shown, initial);\n if (sample !== void 0) seeing.look(element, sample);\n };\n /** What a text-only element said before this batch: its text with the batch undone. */\n const before = (leaf, records) => {\n let nodes = Array.from(leaf.childNodes);\n const old = /* @__PURE__ */ new Map();\n for (const record of records.toReversed()) if (record.type === \"characterData\") old.set(record.target, record.oldValue ?? \"\");\n else {\n const added = new Set(Array.from(record.addedNodes));\n nodes = nodes.filter((node) => !added.has(node));\n const next = record.nextSibling === null ? -1 : nodes.indexOf(record.nextSibling);\n nodes.splice(next === -1 ? nodes.length : next, 0, ...Array.from(record.removedNodes));\n }\n return words(nodes.map((node) => old.get(node) ?? node.textContent).join(\"\"));\n };\n const attribute = (element, { attributeName: name, oldValue: old }, at) => {\n const was = name === \"hidden\" ? old !== null : name === \"aria-hidden\" ? old === \"true\" : name === \"open\" ? element.tagName === \"DIALOG\" && old === null : name === \"style\" && hiding.test(old ?? \"\");\n if (name === \"style\" && !was && !hiding.test(element.getAttribute(\"style\") ?? \"\")) return;\n const state = seeing.state(element);\n if (!kept.has(element) && !was && state === void 0 && name !== \"open\") return seeing.glance(element);\n content(element, at, void 0, () => was || state === false ? null : name === \"open\" && old === null ? words(element.querySelector(\":scope > summary\")?.textContent) : words(element.textContent));\n };\n /** What one mutation added to and removed from `target`. */\n const nodes = (change, target, batch) => {\n const added = Array.from(change.addedNodes).slice(0, 64);\n const removed = Array.from(change.removedNodes).slice(0, 64);\n const text = [...added, ...removed].some((node) => !isElement(node) && /\\S/.test(node.textContent ?? \"\"));\n kept.lose(batch.at, Math.max(change.addedNodes.length, change.removedNodes.length) - 64);\n if (text) batch.owners.add(target);\n removed.forEach((gone, index) => {\n const node = added[index];\n if (!isElement(gone)) return;\n batch.left.add(gone);\n if (node !== void 0 && isElement(node) && kept.rekey(gone, node)) seeing.unwatch(gone);\n else if (kept.has(gone)) {\n places.set(gone, target);\n const sample = kept.note(gone, \"content\", batch.at, null, () => void 0);\n if (sample !== void 0) sample.seen = seeing.viewed(gone);\n seeing.unwatch(gone);\n }\n });\n for (const node of added) if (isElement(node) && isHtml(node) && !unwritten.has(node.tagName) && !node.isContentEditable) {\n if (kept.has(node) || !text && !batch.left.has(node)) {\n batch.arrived.add(node);\n content(node, batch.at, void 0, () => null);\n }\n }\n };\n /** Whether `element` is inside something this batch added, which tells it with its own words. */\n const inside = (element, arrived) => {\n for (let up = element.parentElement; arrived.size > 0 && up !== null; up = up.parentElement) if (arrived.has(up)) return true;\n return false;\n };\n const ownerOf = (change) => change.type === \"characterData\" ? change.target.parentElement : change.target;\n /** Mark what one batch of mutations changed, at `at`. */\n const mark = (records, at) => {\n const batch = {\n at,\n owners: /* @__PURE__ */ new Set(),\n arrived: /* @__PURE__ */ new Set(),\n left: /* @__PURE__ */ new Set()\n };\n let byOwner;\n for (const change of records) {\n const target = ownerOf(change);\n if (target === null || !isElement(target) || inside(target, batch.arrived)) continue;\n const known = kept.has(target) || kept.refuses(target);\n if (change.type !== \"attributes\") if (change.type === \"characterData\" || target.childElementCount === 0 && known) batch.owners.add(target);\n else nodes(change, target, batch);\n else if (isHtml(target) && target !== document.body && target !== document.documentElement) attribute(target, change, at);\n }\n for (const owner of batch.owners) {\n const leaf = owner.childElementCount === 0;\n if (kept.refuses(owner)) kept.lose(at, 1);\n if (kept.refuses(owner) || !isHtml(owner) || unwritten.has(owner.tagName)) continue;\n if (owner === document.body || owner.isContentEditable) continue;\n if (batch.arrived.has(owner) || inside(owner, batch.arrived)) continue;\n content(owner, at, leaf ? words(owner.textContent) : void 0, () => {\n byOwner ??= Map.groupBy(records, ownerOf);\n return leaf ? before(owner, byOwner.get(owner) ?? []) : void 0;\n });\n }\n if (document.title === title) return;\n const previous = words(title);\n const sample = kept.note(document, \"title\", at, words(title = document.title), () => previous);\n if (sample !== void 0) sample.seen = true;\n };\n return {\n mark,\n /** Where a removed element was, which gives its context. */\n placeOf: (key) => places.get(key),\n /** Start afresh, from the document's title now. */\n reset: () => {\n places = /* @__PURE__ */ new WeakMap();\n title = document.title;\n }\n };\n };\n //#endregion\n //#region src/internal/timeline/record.inpage.ts\n const record = (names, texts, kept, seeing, marking) => {\n const { isElement, isInput } = names;\n const epoch = () => performance.timeOrigin + performance.now();\n const declared = \"[role=alert],[role=status],[role=log],[role=dialog],[role=alertdialog],[aria-live],dialog,[popover]\";\n let running = false;\n let lastRead = 0;\n let focused = /* @__PURE__ */ new WeakMap();\n const inputs = [];\n const targetOf = (event) => {\n const target = event.composedPath()[0];\n return target instanceof Node && isElement(target) ? target : void 0;\n };\n /** A field's value as the record keeps it: a secret one's as `••••`, a box's checked or not. */\n const valueOf = (field) => isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\") ? field.checked ? \"checked\" : \"not checked\" : texts.shown(field, true);\n const onFocus = (event) => {\n const field = targetOf(event);\n const value = field === void 0 ? void 0 : valueOf(field);\n if (field !== void 0 && value !== void 0) focused.set(field, value);\n };\n const onValue = (event) => {\n const field = targetOf(event);\n const value = field === void 0 ? void 0 : valueOf(field);\n if (field === void 0 || value === void 0) return;\n const sample = kept.note(field, \"value\", epoch(), value, () => focused.get(field) ?? null);\n if (sample !== void 0) seeing.look(field, sample);\n };\n const onInput = (event) => {\n const target = targetOf(event);\n if (!event.isTrusted || target === void 0) return;\n inputs.push({\n at: epoch(),\n target\n });\n if (inputs.length > 8) inputs.shift();\n };\n const listeners = [\n [\"focusin\", onFocus],\n [\"input\", onValue],\n [\"change\", onValue],\n [\"pointerdown\", onInput],\n [\"keydown\", onInput]\n ];\n const options = {\n capture: true,\n passive: true\n };\n const stop = () => {\n running = false;\n document.removeEventListener(\"DOMContentLoaded\", begin);\n observer.disconnect();\n for (const [type, listener] of listeners) document.removeEventListener(type, listener, options);\n seeing.clear();\n kept.clear();\n kept.forgotten();\n inputs.length = 0;\n focused = /* @__PURE__ */ new WeakMap();\n };\n const observer = new MutationObserver((records) => {\n const at = epoch();\n if (at - lastRead > 12e4) stop();\n else marking.mark(records, at);\n });\n const begin = () => {\n if (!running || kept.begun()) return;\n observer.observe(document, {\n subtree: true,\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributeFilter: [\n \"hidden\",\n \"open\",\n \"aria-hidden\",\n \"class\",\n \"style\"\n ],\n attributeOldValue: true\n });\n for (const [type, listener] of listeners) document.addEventListener(type, listener, options);\n marking.reset();\n for (const element of Array.from(document.querySelectorAll(declared)).slice(0, 64)) seeing.glance(element, true);\n kept.begin(epoch());\n };\n return {\n stop,\n /** Record from now, once the document is parsed; each read keeps the record going. */\n start: () => {\n lastRead = epoch();\n if (running) return;\n running = true;\n if (document.readyState === \"loading\") document.addEventListener(\"DOMContentLoaded\", begin, { once: true });\n else begin();\n },\n inputs: () => inputs\n };\n };\n //#endregion\n //#region src/internal/timeline/sight.inpage.ts\n const sight = (names, walked, texts, kept) => {\n const { clean } = names;\n const { visible } = walked;\n let viewed = /* @__PURE__ */ new WeakMap();\n let watching = /* @__PURE__ */ new WeakSet();\n let states = /* @__PURE__ */ new WeakMap();\n const waiting = /* @__PURE__ */ new Map();\n /** What an element shows: its words, if its style shows it. */\n const shownBy = (element) => element.isConnected && visible(element) ? clean(texts.lines(element, false), 200) || null : null;\n /** Settle what waited on an element; its words are read once, if one of them needs them. */\n const judge = (element, pending, seen, was) => {\n const shown = pending.some((sample) => sample.shown === void 0) ? shownBy(element) : void 0;\n for (const sample of pending) {\n const now = sample.shown === void 0 ? shown : sample.shown;\n kept.settle(element, sample, now, now === null ? was : seen);\n }\n };\n const observer = new IntersectionObserver((entries) => {\n for (const { target, isIntersecting } of entries) {\n const was = viewed.get(target) ?? false;\n const seen = isIntersecting && visible(target);\n const pending = waiting.get(target);\n viewed.set(target, seen);\n waiting.delete(target);\n if (pending !== void 0) judge(target, pending, seen, was);\n if (!kept.has(target)) {\n states.set(target, visible(target));\n unwatch(target);\n }\n }\n });\n /** Watch an element, asking for a fresh report even if it is watched already. */\n const watch = (element) => {\n watching.add(element);\n observer.unobserve(element);\n observer.observe(element);\n };\n const unwatch = (element) => {\n watching.delete(element);\n observer.unobserve(element);\n };\n return {\n /** Judge a sample at once if what it shows and whether it is in view are known, else on render. */\n look: (element, sample) => {\n const view = viewed.get(element);\n if (sample.shown !== void 0 && view !== void 0 && watching.has(element)) {\n sample.seen = view;\n return;\n }\n waiting.set(element, [...waiting.get(element) ?? [], sample]);\n watch(element);\n },\n /**\n * Look at an element once, for its state when it next changes: as it renders, or `now`, by its\n * style, as for the few the record looks at as it starts.\n */\n glance: (element, now = false) => {\n if (now) states.set(element, visible(element));\n if (!watching.has(element)) watch(element);\n },\n /** Whether the style of an element looked at once showed it, if it was. */\n state: (element) => states.get(element),\n /** Whether a watched element was in view as the page last rendered it. */\n viewed: (element) => viewed.get(element) ?? false,\n unwatch,\n /** Judge now what the page has not rendered since it changed, as a hidden tab never does. */\n settle: () => {\n for (const [element, pending] of waiting) {\n const seen = element.isConnected && walked.inView(element.getBoundingClientRect()) && visible(element);\n judge(element, pending, seen, viewed.get(element) ?? false);\n viewed.set(element, seen);\n }\n waiting.clear();\n for (const key of kept.forgotten()) if (key instanceof Element) unwatch(key);\n },\n clear: () => {\n observer.disconnect();\n waiting.clear();\n viewed = /* @__PURE__ */ new WeakMap();\n watching = /* @__PURE__ */ new WeakSet();\n states = /* @__PURE__ */ new WeakMap();\n }\n };\n };\n //#endregion\n //#region src/internal/page/bridge.ts\n const parts = {\n elements,\n names,\n walk,\n match,\n context,\n subjects,\n states,\n expectations,\n text,\n controls,\n fold,\n history,\n sight,\n marks,\n record,\n changes,\n ready,\n outline,\n targets,\n evidence,\n guard,\n edit,\n addresses\n };\n function install(parts) {\n const source = install.toString() + Object.entries(parts).map(([name, factory]) => name + factory.toString()).join(\"\");\n let version = 2166136261;\n for (let index = 0; index < source.length; index++) version = Math.imul(version ^ source.charCodeAt(index), 16777619);\n version >>>= 0;\n const installed = globalThis.__effectBrowser;\n if (installed !== void 0 && installed.version === version) return installed;\n installed?.dispose?.();\n const named = parts.names(parts.elements());\n if (installed?.refs !== void 0) named.refs.next = installed.refs.next;\n const walked = parts.walk(named);\n const placing = parts.context(named, walked);\n const matching = parts.match();\n const subjected = parts.subjects(named, walked, matching, placing, parts.states(named));\n const texts = parts.text(named, walked);\n const controlled = parts.controls(named, subjected, texts);\n const kept = parts.history(parts.fold());\n const seeing = parts.sight(named, walked, texts, kept);\n const marking = parts.marks(named, kept, seeing);\n const recorder = parts.record(named, texts, kept, seeing, marking);\n const read = parts.outline(named, walked, subjected, texts, controlled, parts.addresses());\n const located = parts.targets(named, walked, placing);\n const guarded = parts.guard(named, located, parts.evidence(named, placing));\n const edited = parts.edit(named, guarded, placing);\n const readiness = parts.ready(walked, texts, kept);\n const api = {\n version,\n refs: named.refs,\n dispose: () => recorder.stop(),\n snapshot: read.snapshot,\n find: subjected.find,\n until: parts.expectations(named, subjected, matching).until,\n text: texts.read,\n record: recorder.start,\n stopRecord: recorder.stop,\n changes: parts.changes(named, placing, kept, seeing, marking, recorder).read,\n ready: readiness.wait,\n settle: readiness.settle,\n point: located.point,\n scrollPlan: located.scrollPlan,\n viewport: read.viewport,\n screenSize: () => ({\n width: screen.width,\n height: screen.height\n }),\n prepareInput: guarded.prepareInput,\n validateInput: guarded.validateInput,\n typeable: edited.typeable,\n focus: edited.focus,\n focusOn: edited.focusOn,\n select: edited.select\n };\n globalThis.__effectBrowser = api;\n return api;\n }\n //#endregion\n return install(parts);\n})();\n\nreturn pageScript;})()";
|
|
497
|
+
const documentScripts = (clockName, scripts) => [...clockName === void 0 ? [] : [`${clockSource}(${encodeString(clockName)})`], ...scripts.map(({ match, source }) => match === void 0 ? source : `if (${String(match)}.test(location.href)) {\n${source}\n}`)];
|
|
689
498
|
const worldName = "effect-browser";
|
|
690
499
|
const recorderSource = `if (globalThis === globalThis.top) globalThis.__effectBrowser?.record();`;
|
|
691
500
|
const missing = "effect-browser: no __effectBrowser in this world";
|
|
692
|
-
const missingSource =
|
|
501
|
+
const missingSource = encodeString(missing);
|
|
693
502
|
const isMissing = (error) => error.reason._tag === "Failed" && error.reason.detail === missing;
|
|
694
503
|
const Evaluated = Schema.Struct({
|
|
695
504
|
value: Schema.optionalKey(Schema.Unknown),
|
|
@@ -762,7 +571,7 @@ const registrationFor = Effect.fnUntraced(function* (page) {
|
|
|
762
571
|
removeRecorder
|
|
763
572
|
};
|
|
764
573
|
});
|
|
765
|
-
const make$
|
|
574
|
+
const make$28 = Effect.fnUntraced(function* (page) {
|
|
766
575
|
const { id, cdp, native, span, publish, now } = page;
|
|
767
576
|
const { send } = page.protocol;
|
|
768
577
|
const { ensure, removeRecorder } = yield* registrationFor(page);
|
|
@@ -885,6 +694,102 @@ const make$22 = Effect.fnUntraced(function* (page) {
|
|
|
885
694
|
};
|
|
886
695
|
});
|
|
887
696
|
//#endregion
|
|
697
|
+
//#region src/internal/page/dialogs.ts
|
|
698
|
+
/** Scoped dialog responses publish their actual outcome and invalidate their page after failed answers. */
|
|
699
|
+
/**
|
|
700
|
+
* What a page's own Playwright events publish, its close and crash aside, while its scope is
|
|
701
|
+
* open. Dialogs are answered: alerts accepted, others dismissed. The page's own session tells its
|
|
702
|
+
* documents' commits and loads.
|
|
703
|
+
*/
|
|
704
|
+
const listen = Effect.fnUntraced(function* (playwright, page, publish, now, answer, on) {
|
|
705
|
+
const dialogs = yield* Queue.bounded(8);
|
|
706
|
+
const dialog = (shown) => {
|
|
707
|
+
if (!Queue.offerUnsafe(dialogs, {
|
|
708
|
+
kind: shown.type(),
|
|
709
|
+
message: shown.message().slice(0, 500)
|
|
710
|
+
})) on.failed();
|
|
711
|
+
};
|
|
712
|
+
yield* Queue.take(dialogs).pipe(Effect.flatMap(({ kind, message }) => {
|
|
713
|
+
const accept = kind === "alert" || kind === "beforeunload";
|
|
714
|
+
const record = (answer) => Effect.sync(() => {
|
|
715
|
+
publish(new DialogShown({
|
|
716
|
+
at: now(),
|
|
717
|
+
page,
|
|
718
|
+
kind,
|
|
719
|
+
message,
|
|
720
|
+
answer
|
|
721
|
+
}));
|
|
722
|
+
});
|
|
723
|
+
return answer(accept).pipe(Effect.tap(() => record(accept ? "accepted" : "dismissed")), Effect.tapError(() => record("failed").pipe(Effect.andThen(Effect.sync(on.failed)))));
|
|
724
|
+
}), Effect.forever, Effect.forkScoped);
|
|
725
|
+
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
726
|
+
playwright.on("close", on.close);
|
|
727
|
+
playwright.on("crash", on.crash);
|
|
728
|
+
playwright.on("dialog", dialog);
|
|
729
|
+
}), () => Effect.sync(() => {
|
|
730
|
+
playwright.off("close", on.close);
|
|
731
|
+
playwright.off("crash", on.crash);
|
|
732
|
+
playwright.off("dialog", dialog);
|
|
733
|
+
}));
|
|
734
|
+
});
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/internal/page/identity.ts
|
|
737
|
+
/** Connection identity uses the supplied SecureRandom service, or the host's Web Crypto on Node/Bun. */
|
|
738
|
+
const failed = () => undispatched("make", new Failed({ detail: "Could not name connection" }));
|
|
739
|
+
const make$27 = Effect.gen(function* () {
|
|
740
|
+
const supplied = yield* Effect.serviceOption(SecureRandom.SecureRandom);
|
|
741
|
+
return yield* Option.isSome(supplied) ? supplied.value.uuidV4() : Effect.try({
|
|
742
|
+
try: () => globalThis.crypto.randomUUID(),
|
|
743
|
+
catch: failed
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/internal/page/openings.ts
|
|
748
|
+
/** A page's input waits for the actual tabs it opened to finish the browser's registration. */
|
|
749
|
+
const make$26 = Effect.fnUntraced(function* (playwright, cdp, registrations, closedBy) {
|
|
750
|
+
const failed = (reason) => Exit.fail(undispatched("newPage", reason));
|
|
751
|
+
let active;
|
|
752
|
+
const gone = Deferred.makeUnsafe();
|
|
753
|
+
const windowOpened = () => {
|
|
754
|
+
if (active !== void 0) active.windows += 1;
|
|
755
|
+
};
|
|
756
|
+
const popup = (opened) => {
|
|
757
|
+
if (active === void 0) return;
|
|
758
|
+
const registered = registrations.get(opened);
|
|
759
|
+
active.registrations.push(registered === void 0 ? failed(new Failed({ detail: "the popup has no registration" })) : Deferred.await(registered).pipe(Effect.asVoid));
|
|
760
|
+
Deferred.doneUnsafe(active.changed, Exit.void);
|
|
761
|
+
active.changed = Deferred.makeUnsafe();
|
|
762
|
+
};
|
|
763
|
+
const clear = Effect.sync(() => {
|
|
764
|
+
active = void 0;
|
|
765
|
+
});
|
|
766
|
+
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
767
|
+
cdp.on("Page.windowOpen", windowOpened);
|
|
768
|
+
playwright.on("popup", popup);
|
|
769
|
+
}), () => Effect.sync(() => {
|
|
770
|
+
active = void 0;
|
|
771
|
+
cdp.off("Page.windowOpen", windowOpened);
|
|
772
|
+
playwright.off("popup", popup);
|
|
773
|
+
Deferred.doneUnsafe(gone, failed(new Closed({ cause: closedBy() })));
|
|
774
|
+
}));
|
|
775
|
+
return {
|
|
776
|
+
mark: () => {
|
|
777
|
+
const mark = {
|
|
778
|
+
windows: 0,
|
|
779
|
+
registrations: [],
|
|
780
|
+
changed: Deferred.makeUnsafe()
|
|
781
|
+
};
|
|
782
|
+
active = mark;
|
|
783
|
+
return mark;
|
|
784
|
+
},
|
|
785
|
+
clear,
|
|
786
|
+
settle: (mark) => Effect.gen(function* () {
|
|
787
|
+
while (mark.registrations.length < mark.windows) yield* Deferred.await(mark.changed);
|
|
788
|
+
yield* Effect.forEach(mark.registrations, (registration) => registration);
|
|
789
|
+
}).pipe(Effect.raceFirst(Deferred.await(gone)), Effect.ensuring(clear))
|
|
790
|
+
};
|
|
791
|
+
});
|
|
792
|
+
//#endregion
|
|
888
793
|
//#region src/internal/input/dispatch.ts
|
|
889
794
|
/**
|
|
890
795
|
* Sending input to the browser. Each mouse event, key and inserted text goes out on the page's
|
|
@@ -905,7 +810,7 @@ const buttonAt = (type, point, button = "left", clickCount = 1) => ({
|
|
|
905
810
|
buttons: type === "mousePressed" ? buttonMask[button] : 0,
|
|
906
811
|
clickCount
|
|
907
812
|
});
|
|
908
|
-
const make$
|
|
813
|
+
const make$25 = (page) => {
|
|
909
814
|
const { id, pointer, publish, now, noteInput, closedBy } = page;
|
|
910
815
|
const { send } = page.protocol;
|
|
911
816
|
const inputClocks = /* @__PURE__ */ new WeakMap();
|
|
@@ -1007,7 +912,7 @@ const inputFailure = (operation, targets, failure) => {
|
|
|
1007
912
|
return failWith(operation, failure.error === "outside" ? new InvalidRequest({ detail: failure.detail }) : failure.error === "stale" && typeof target === "string" ? new StaleRef({ ref: target }) : new NotActionable({ detail: failure.detail }));
|
|
1008
913
|
};
|
|
1009
914
|
const editFailure = (operation, ref, failure) => failWith(operation, failure.stale === true ? new StaleRef({ ref }) : new NotActionable({ detail: failure.error }));
|
|
1010
|
-
const make$
|
|
915
|
+
const make$24 = (page, bridge) => {
|
|
1011
916
|
const { id } = page;
|
|
1012
917
|
const { current, evaluateIn, evaluateWithContext } = bridge;
|
|
1013
918
|
const preparePolicy = (asked, info, targets, flags = {}) => Effect.gen(function* () {
|
|
@@ -1075,7 +980,7 @@ const make$20 = (page, bridge) => {
|
|
|
1075
980
|
* Keys and typing: a key chord held and released, each typed event, and the document a run of
|
|
1076
981
|
* keys must stay in.
|
|
1077
982
|
*/
|
|
1078
|
-
const make$
|
|
983
|
+
const make$23 = (page, bridge, dispatch) => {
|
|
1079
984
|
const { playwright } = page;
|
|
1080
985
|
const key = (direction, part) => {
|
|
1081
986
|
const run = () => playwright.keyboard[direction](part);
|
|
@@ -1202,12 +1107,25 @@ const admission = (page, pending, name) => {
|
|
|
1202
1107
|
end: Effect.sync(() => end?.())
|
|
1203
1108
|
};
|
|
1204
1109
|
};
|
|
1110
|
+
/** Announce an action from what it has found, then wait for its style's lead. */
|
|
1111
|
+
const announcing = (page, name, style, acted) => (to) => Effect.gen(function* () {
|
|
1112
|
+
const event = new ActionAnnounced({
|
|
1113
|
+
at: page.now(),
|
|
1114
|
+
page: page.id,
|
|
1115
|
+
name,
|
|
1116
|
+
correlation: yield* Correlation,
|
|
1117
|
+
...yield* Ref.get(acted),
|
|
1118
|
+
...to
|
|
1119
|
+
});
|
|
1120
|
+
page.publish(event);
|
|
1121
|
+
if (style.lead !== void 0) yield* style.lead(event);
|
|
1122
|
+
});
|
|
1205
1123
|
/** Close a run on every exit while preserving its native replies for the page's next input. */
|
|
1206
1124
|
const useRun = (page, sender, name, run, action, canStop) => action.pipe(Effect.tapError((error) => error.reason._tag === "Closed" ? run.close : run.close.pipe(Effect.andThen(sender.flush(name, run)), Effect.ignore)), Effect.tap(() => run.close.pipe(Effect.andThen(sender.flush(name, run)))), Effect.ensuring(run.close.pipe(Effect.andThen(page.openings.clear))), Effect.onError(() => run.recover(page.stopLoading, page.scope).pipe(Effect.when(canStop))), Effect.provideService(Current, run));
|
|
1207
|
-
const make$
|
|
1125
|
+
const make$22 = (page, sender) => {
|
|
1208
1126
|
const { id, settings, mapping, lane, publish, now, noteInput, span, owned } = page;
|
|
1209
1127
|
const { inputClocks } = sender;
|
|
1210
|
-
const input = make$
|
|
1128
|
+
const input = make$30();
|
|
1211
1129
|
const admitted = /* @__PURE__ */ new Set();
|
|
1212
1130
|
const perform = (value, info, timeout, prepare, body) => {
|
|
1213
1131
|
const name = nameOf(value);
|
|
@@ -1237,6 +1155,7 @@ const make$18 = (page, sender) => {
|
|
|
1237
1155
|
touched: touch,
|
|
1238
1156
|
at: (point) => Ref.set(at, Option.some(point)),
|
|
1239
1157
|
on: (subject, to) => Ref.set(acted, actedOn(subject, to)),
|
|
1158
|
+
announce: announcing(page, name, style, acted),
|
|
1240
1159
|
reveal: Effect.sync(() => {
|
|
1241
1160
|
revealed = true;
|
|
1242
1161
|
})
|
|
@@ -1294,8 +1213,13 @@ const make$18 = (page, sender) => {
|
|
|
1294
1213
|
to,
|
|
1295
1214
|
box,
|
|
1296
1215
|
text: info.text === void 0 ? void 0 : revealed ? info.text.slice(0, 200) : redacted,
|
|
1297
|
-
|
|
1298
|
-
|
|
1216
|
+
...Option.match(point, {
|
|
1217
|
+
onNone: () => ({}),
|
|
1218
|
+
onSome: ({ x, y }) => ({
|
|
1219
|
+
x,
|
|
1220
|
+
y
|
|
1221
|
+
})
|
|
1222
|
+
}),
|
|
1299
1223
|
ok: Exit.isSuccess(exit),
|
|
1300
1224
|
dispatched,
|
|
1301
1225
|
error: Option.match(failure, {
|
|
@@ -1322,12 +1246,13 @@ const make$18 = (page, sender) => {
|
|
|
1322
1246
|
* plan, published before its first move, from where viewers last saw the pointer when it is
|
|
1323
1247
|
* shown, and a wheel scroll goes in the style's steps.
|
|
1324
1248
|
*/
|
|
1325
|
-
const make$
|
|
1249
|
+
const make$21 = (page, dispatch, viewport) => {
|
|
1326
1250
|
const { id, pointer, publish, now, span } = page;
|
|
1327
1251
|
const { inputClocks, inputCall, dispatchMouse, sendMouse } = dispatch;
|
|
1328
1252
|
const moveTo = (operation, marks, to, cursor, travel = "approach") => Effect.gen(function* () {
|
|
1329
1253
|
const dragging = travel === "drag";
|
|
1330
1254
|
const { style } = marks;
|
|
1255
|
+
if (travel === "approach" || travel === "hover") yield* marks.announce(to);
|
|
1331
1256
|
const drawn = style.pointer ?? pointer;
|
|
1332
1257
|
const size = yield* viewport.viewportFor(operation);
|
|
1333
1258
|
const previous = Option.getOrElse(MutableRef.get(drawn), () => ({
|
|
@@ -1360,7 +1285,7 @@ const make$17 = (page, dispatch, viewport) => {
|
|
|
1360
1285
|
for (const sample of samples) {
|
|
1361
1286
|
const remaining = at + sample.afterMillis - now();
|
|
1362
1287
|
if (remaining > 0) yield* Effect.sleep(Duration.millis(remaining));
|
|
1363
|
-
yield* travel === "approach" ? marks.touched : marks.sent;
|
|
1288
|
+
yield* travel === "approach" || travel === "reveal" ? marks.touched : marks.sent;
|
|
1364
1289
|
yield* inputCall(operation, run.send(() => dispatchMouse({
|
|
1365
1290
|
type: "mouseMoved",
|
|
1366
1291
|
x: sample.x,
|
|
@@ -1420,7 +1345,7 @@ const make$17 = (page, dispatch, viewport) => {
|
|
|
1420
1345
|
* next look's to see. A tab the input opened waits for the browser's registration too.
|
|
1421
1346
|
*/
|
|
1422
1347
|
const settling = Duration.seconds(5);
|
|
1423
|
-
const make$
|
|
1348
|
+
const make$20 = (page, bridge) => {
|
|
1424
1349
|
const document = () => bridge.frameTag().document;
|
|
1425
1350
|
let parsed = -1;
|
|
1426
1351
|
let changed = Deferred.makeUnsafe();
|
|
@@ -1460,7 +1385,7 @@ const resolvedTarget = ({ x, y, box, ...target }) => new ResolvedTarget({
|
|
|
1460
1385
|
box,
|
|
1461
1386
|
...target
|
|
1462
1387
|
});
|
|
1463
|
-
const make$
|
|
1388
|
+
const make$19 = (viewport, guard, pointer, dispatch, settling) => {
|
|
1464
1389
|
const { evaluate, mutate } = guard;
|
|
1465
1390
|
const { moveTo, wheel } = pointer;
|
|
1466
1391
|
const { flush } = dispatch;
|
|
@@ -1482,7 +1407,7 @@ const make$15 = (viewport, guard, pointer, dispatch, settling) => {
|
|
|
1482
1407
|
y: plan.y
|
|
1483
1408
|
};
|
|
1484
1409
|
yield* marks.at(point);
|
|
1485
|
-
yield* moveTo(operation, marks, point);
|
|
1410
|
+
yield* moveTo(operation, marks, point, void 0, "reveal");
|
|
1486
1411
|
const before = settling.mark();
|
|
1487
1412
|
yield* wheel(operation, marks, point, Math.max(-size.width * .9, Math.min(size.width * .9, plan.dx)), Math.max(-size.height * .9, Math.min(size.height * .9, plan.dy)));
|
|
1488
1413
|
yield* flush(operation, marks.input);
|
|
@@ -1507,19 +1432,19 @@ const make$15 = (viewport, guard, pointer, dispatch, settling) => {
|
|
|
1507
1432
|
* then waits for the page to settle: a task and a frame, and a document if the input asked for one.
|
|
1508
1433
|
*/
|
|
1509
1434
|
const partsOf = (page, bridge, viewport) => {
|
|
1510
|
-
const dispatch = make$
|
|
1511
|
-
const pointer = make$
|
|
1512
|
-
const guard = make$
|
|
1513
|
-
const settling = make$
|
|
1435
|
+
const dispatch = make$25(page);
|
|
1436
|
+
const pointer = make$21(page, dispatch, viewport);
|
|
1437
|
+
const guard = make$24(page, bridge);
|
|
1438
|
+
const settling = make$20(page, bridge);
|
|
1514
1439
|
return {
|
|
1515
1440
|
page,
|
|
1516
1441
|
...settling,
|
|
1517
1442
|
viewportFor: viewport.viewportFor,
|
|
1518
|
-
perform: make$
|
|
1443
|
+
perform: make$22(page, dispatch),
|
|
1519
1444
|
...guard,
|
|
1520
|
-
...make$
|
|
1445
|
+
...make$19(viewport, guard, pointer, dispatch, settling),
|
|
1521
1446
|
...pointer,
|
|
1522
|
-
...make$
|
|
1447
|
+
...make$23(page, bridge, dispatch),
|
|
1523
1448
|
sendMouse: dispatch.sendMouse,
|
|
1524
1449
|
flush: dispatch.flush
|
|
1525
1450
|
};
|
|
@@ -1786,7 +1711,7 @@ const select = (input) => {
|
|
|
1786
1711
|
return result.detail;
|
|
1787
1712
|
}));
|
|
1788
1713
|
};
|
|
1789
|
-
const make$
|
|
1714
|
+
const make$18 = (page, bridge, viewport) => {
|
|
1790
1715
|
const parts = partsOf(page, bridge, viewport);
|
|
1791
1716
|
return {
|
|
1792
1717
|
perform: parts.perform,
|
|
@@ -2036,8 +1961,8 @@ const orderedFrame = (frame, previous) => frame.hostTime < previous && frame.tim
|
|
|
2036
1961
|
//#region src/internal/pictures/quiescence.ts
|
|
2037
1962
|
/** Actual native replies outlive callers; bounded transactions retain them without holding teardown. */
|
|
2038
1963
|
const deadline$1 = Duration.seconds(2);
|
|
2039
|
-
const make$
|
|
2040
|
-
const replies = make$
|
|
1964
|
+
const make$17 = (options) => {
|
|
1965
|
+
const replies = make$30();
|
|
2041
1966
|
const pending = /* @__PURE__ */ new Map();
|
|
2042
1967
|
const late = (kind) => options.error(/* @__PURE__ */ new Error(`${kind} exceeded its deadline`));
|
|
2043
1968
|
const track = (operation, actual, failed) => {
|
|
@@ -2217,7 +2142,7 @@ const reader = (acquire, leave, why, lost) => (settings = {}) => Effect.acquireR
|
|
|
2217
2142
|
current: lease.frame,
|
|
2218
2143
|
stream: frames(lease.subscription, lease.baseline, why, lost)
|
|
2219
2144
|
})));
|
|
2220
|
-
const make$
|
|
2145
|
+
const make$16 = (options) => Effect.gen(function* () {
|
|
2221
2146
|
const lock = yield* Semaphore.make(1);
|
|
2222
2147
|
const replies = /* @__PURE__ */ new Set();
|
|
2223
2148
|
let generation;
|
|
@@ -2279,7 +2204,7 @@ const make$12 = (options) => Effect.gen(function* () {
|
|
|
2279
2204
|
const gone = () => options.error(/* @__PURE__ */ new Error("Target page has been closed"));
|
|
2280
2205
|
const why = told(closed, gone, options.clock);
|
|
2281
2206
|
const awaitStop = (current) => pictures.wait("screencast stop").pipe(Effect.catch((error) => Effect.sync(() => notifyFailure(current, error))));
|
|
2282
|
-
const pictures = make$
|
|
2207
|
+
const pictures = make$17({
|
|
2283
2208
|
clock: options.clock,
|
|
2284
2209
|
error: options.error,
|
|
2285
2210
|
closed: isClosed,
|
|
@@ -2667,26 +2592,66 @@ const calibrator = (page, bridge) => {
|
|
|
2667
2592
|
};
|
|
2668
2593
|
const ScreenSize = Schema.Struct({
|
|
2669
2594
|
width: Schema.Int,
|
|
2670
|
-
height: Schema.Int
|
|
2595
|
+
height: Schema.Int,
|
|
2596
|
+
ratio: Schema.Finite
|
|
2671
2597
|
});
|
|
2672
|
-
const
|
|
2598
|
+
const device = (page, bridge) => {
|
|
2673
2599
|
const { playwright, native, within } = page;
|
|
2674
2600
|
const { send } = page.protocol;
|
|
2675
|
-
let
|
|
2676
|
-
let
|
|
2601
|
+
let screen;
|
|
2602
|
+
let scaled = 0;
|
|
2603
|
+
let painting = false;
|
|
2604
|
+
const metrics = (operation) => native(operation, () => send("Emulation.setDeviceMetricsOverride", {
|
|
2605
|
+
width: 0,
|
|
2606
|
+
height: 0,
|
|
2607
|
+
deviceScaleFactor: scaled,
|
|
2608
|
+
mobile: false,
|
|
2609
|
+
...screen === void 0 ? {} : {
|
|
2610
|
+
screenWidth: screen.width,
|
|
2611
|
+
screenHeight: screen.height
|
|
2612
|
+
}
|
|
2613
|
+
}));
|
|
2614
|
+
const screenOf = (operation) => bridge.evaluate(operation, scriptCall("screenSize")).pipe(Effect.flatMap(decodeWith(operation, ScreenSize)));
|
|
2677
2615
|
const holdScreen = Effect.fnUntraced(function* (operation) {
|
|
2678
|
-
if (
|
|
2679
|
-
const { width, height } = yield*
|
|
2680
|
-
|
|
2681
|
-
width
|
|
2682
|
-
height
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
screenWidth: width,
|
|
2686
|
-
screenHeight: height
|
|
2687
|
-
}));
|
|
2688
|
-
screenHeld = true;
|
|
2616
|
+
if (screen !== void 0) return;
|
|
2617
|
+
const { width, height } = yield* screenOf(operation);
|
|
2618
|
+
screen = {
|
|
2619
|
+
width,
|
|
2620
|
+
height
|
|
2621
|
+
};
|
|
2622
|
+
yield* metrics(operation).pipe(Effect.onError(() => Effect.sync(() => screen = void 0)));
|
|
2689
2623
|
});
|
|
2624
|
+
const scrollbarsHidden = (hidden) => native("paint", () => send("Emulation.setScrollbarsHidden", { hidden }));
|
|
2625
|
+
const paint = (options) => Effect.gen(function* () {
|
|
2626
|
+
const { scale, scrollbars = true } = options;
|
|
2627
|
+
const launched = playwright.viewportSize() !== null;
|
|
2628
|
+
if (scale !== void 0 && !(Number.isFinite(scale) && scale > 0 && scale <= 4)) return yield* refuse("paint", "a page paints at more than 0 and at most 4 device pixels");
|
|
2629
|
+
if (painting) return yield* refuse("paint", "the page is painted for another scope already");
|
|
2630
|
+
if (scale !== void 0 && launched && (yield* screenOf("paint")).ratio !== scale) return yield* refuse("paint", "this browser paints at the scale it was launched with, as Chromium's deviceScaleFactor sets");
|
|
2631
|
+
const rescaled = scale !== void 0 && !launched;
|
|
2632
|
+
painting = true;
|
|
2633
|
+
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
2634
|
+
scaled = 0;
|
|
2635
|
+
if (!scrollbars) yield* scrollbarsHidden(false);
|
|
2636
|
+
if (rescaled) yield* metrics("paint");
|
|
2637
|
+
}).pipe(Effect.ignore, Effect.ensuring(Effect.sync(() => painting = false))));
|
|
2638
|
+
if (!scrollbars) yield* scrollbarsHidden(true);
|
|
2639
|
+
if (rescaled) {
|
|
2640
|
+
scaled = scale;
|
|
2641
|
+
yield* metrics("paint");
|
|
2642
|
+
}
|
|
2643
|
+
}).pipe(within("paint"));
|
|
2644
|
+
return {
|
|
2645
|
+
holdScreen,
|
|
2646
|
+
paint,
|
|
2647
|
+
scaled: () => scaled
|
|
2648
|
+
};
|
|
2649
|
+
};
|
|
2650
|
+
const camera = (page, viewport, capture, { holdScreen, scaled }) => {
|
|
2651
|
+
const { playwright, native, within } = page;
|
|
2652
|
+
const { send } = page.protocol;
|
|
2653
|
+
let ratio = 1;
|
|
2654
|
+
const layoutMetrics = (operation) => native(operation, () => send("Page.getLayoutMetrics")).pipe(Effect.flatMap(decodeWith(operation, LayoutMetrics)));
|
|
2690
2655
|
const decoded = (operation, data, format) => {
|
|
2691
2656
|
const size = format === "png" ? pngSize(data) : jpegSize(data);
|
|
2692
2657
|
return size === void 0 ? failWith(operation, new Failed({ detail: `the browser's picture is not a ${format.toUpperCase()}` })) : Effect.succeed(new Image({
|
|
@@ -2723,9 +2688,9 @@ const camera = (page, bridge, viewport, capture) => {
|
|
|
2723
2688
|
if (whole !== void 0) ratio = whole.width / emulated.width;
|
|
2724
2689
|
return yield* emulatedShot(operation, format, quality, pixels, crop);
|
|
2725
2690
|
}
|
|
2726
|
-
const [
|
|
2727
|
-
const
|
|
2728
|
-
ratio = Number.isFinite(
|
|
2691
|
+
const [measured] = yield* layoutMetrics(operation).pipe(Effect.zip(crop === void 0 ? Effect.void : holdScreen(operation), { concurrent: true }));
|
|
2692
|
+
const measuredRatio = measured.contentSize.width / measured.cssContentSize.width;
|
|
2693
|
+
ratio = scaled() > 0 ? scaled() : Number.isFinite(measuredRatio) && measuredRatio > 0 ? measuredRatio : 1;
|
|
2729
2694
|
if (crop === void 0 && ratio === 1) {
|
|
2730
2695
|
const image = whole ?? (yield* shot(operation, format, quality));
|
|
2731
2696
|
viewport.remember(image);
|
|
@@ -2736,7 +2701,7 @@ const camera = (page, bridge, viewport, capture) => {
|
|
|
2736
2701
|
y: 0,
|
|
2737
2702
|
...known ?? (yield* viewport.viewportFor(operation))
|
|
2738
2703
|
};
|
|
2739
|
-
const { pageX, pageY, scale } =
|
|
2704
|
+
const { pageX, pageY, scale } = measured.cssVisualViewport;
|
|
2740
2705
|
yield* holdScreen(operation);
|
|
2741
2706
|
return yield* shot(operation, format, quality, {
|
|
2742
2707
|
x: pageX + rect.x,
|
|
@@ -2764,11 +2729,11 @@ const reuse = (page, bridge, viewport, capture) => (operation, options) => Effec
|
|
|
2764
2729
|
});
|
|
2765
2730
|
/** Where a picture came from: a frame the screencast had delivered, or a new screenshot. */
|
|
2766
2731
|
const sourceOf = (reused) => Option.isSome(reused) ? "frame" : "screenshot";
|
|
2767
|
-
const make$
|
|
2732
|
+
const make$15 = Effect.fnUntraced(function* (page, bridge, viewport) {
|
|
2768
2733
|
const { id, clock, settings, mapping, now, span, owned, lane, within } = page;
|
|
2769
2734
|
const calibrateClock = calibrator(page, bridge);
|
|
2770
2735
|
const error = (cause) => Schema.is(BrowserError)(cause) ? cause : undispatched("screencast", reasonOf(cause, void 0, page.closedBy()));
|
|
2771
|
-
const capture = yield* make$
|
|
2736
|
+
const capture = yield* make$16({
|
|
2772
2737
|
id,
|
|
2773
2738
|
transport: (page.capture === void 0 ? Effect.succeed(own(page, bridge)) : apart(page, bridge, page.capture, error, yield* Effect.scope)).pipe(Effect.provideService(Current$1, yield* Current$1)),
|
|
2774
2739
|
clock,
|
|
@@ -2786,7 +2751,8 @@ const make$11 = Effect.fnUntraced(function* (page, bridge, viewport) {
|
|
|
2786
2751
|
imageSize: jpegSize,
|
|
2787
2752
|
error
|
|
2788
2753
|
});
|
|
2789
|
-
const
|
|
2754
|
+
const emulated = device(page, bridge);
|
|
2755
|
+
const picture = camera(page, viewport, capture, emulated);
|
|
2790
2756
|
const reusable = reuse(page, bridge, viewport, capture);
|
|
2791
2757
|
const screenshots = lane.shared("screenshot", false);
|
|
2792
2758
|
const frames = lane.shared("frame", false);
|
|
@@ -2854,22 +2820,102 @@ const make$11 = Effect.fnUntraced(function* (page, bridge, viewport) {
|
|
|
2854
2820
|
frame,
|
|
2855
2821
|
zoom,
|
|
2856
2822
|
captureStats,
|
|
2857
|
-
estimate: mapping.current(calibrateClock)
|
|
2823
|
+
estimate: mapping.current(calibrateClock),
|
|
2824
|
+
paint: emulated.paint
|
|
2858
2825
|
};
|
|
2859
2826
|
});
|
|
2860
2827
|
//#endregion
|
|
2828
|
+
//#region src/internal/reading/layout.ts
|
|
2829
|
+
/**
|
|
2830
|
+
* Reading where things are: `Page.layout`, in one call to the page that takes its turn as other
|
|
2831
|
+
* reads do and shares its work with identical ones. The page gives each place's viewport box; the
|
|
2832
|
+
* document box is that box moved by the scroll read with it.
|
|
2833
|
+
*/
|
|
2834
|
+
const LayoutResult = Schema.Union([Schema.Struct({ layout: Schema.Struct({
|
|
2835
|
+
url: Schema.String,
|
|
2836
|
+
viewport: Schema.Struct({
|
|
2837
|
+
width: Schema.Finite,
|
|
2838
|
+
height: Schema.Finite
|
|
2839
|
+
}),
|
|
2840
|
+
scroll: Point,
|
|
2841
|
+
scale: Schema.Finite,
|
|
2842
|
+
missing: Schema.Array(Schema.String),
|
|
2843
|
+
places: Schema.Array(Schema.Struct({
|
|
2844
|
+
id: Schema.String,
|
|
2845
|
+
ref: Schema.String,
|
|
2846
|
+
subject: Subject,
|
|
2847
|
+
box: Box,
|
|
2848
|
+
fixed: Schema.Boolean,
|
|
2849
|
+
words: Schema.optional(Schema.Array(Schema.Struct({
|
|
2850
|
+
text: Schema.String,
|
|
2851
|
+
box: Box
|
|
2852
|
+
})))
|
|
2853
|
+
}))
|
|
2854
|
+
}) }), Schema.Struct({ invalid: Schema.String })]);
|
|
2855
|
+
const make$14 = (page, bridge) => {
|
|
2856
|
+
const { now, span, owned, within, lane } = page;
|
|
2857
|
+
const { evaluate } = bridge;
|
|
2858
|
+
const layouts = lane.shared("layout", true);
|
|
2859
|
+
const layout = (picks) => {
|
|
2860
|
+
const asked = pickRequests(picks);
|
|
2861
|
+
const once = Effect.gen(function* () {
|
|
2862
|
+
const before = bridge.frameTag().document;
|
|
2863
|
+
const result = yield* evaluate("layout", scriptCall("layout", asked)).pipe(Effect.flatMap(decodeWith("layout", LayoutResult)));
|
|
2864
|
+
if ("invalid" in result) return yield* refuse("layout", result.invalid);
|
|
2865
|
+
if (bridge.frameTag().document !== before) return yield* failWith("layout", new NotActionable({ detail: "the page's document changed while it was read" }));
|
|
2866
|
+
const { places, scroll, ...read } = result.layout;
|
|
2867
|
+
const moved = (box) => ({
|
|
2868
|
+
...box,
|
|
2869
|
+
x: box.x + scroll.x,
|
|
2870
|
+
y: box.y + scroll.y
|
|
2871
|
+
});
|
|
2872
|
+
return new Layout({
|
|
2873
|
+
...read,
|
|
2874
|
+
url: redact(read.url),
|
|
2875
|
+
page: page.id,
|
|
2876
|
+
connection: page.connection,
|
|
2877
|
+
document: before,
|
|
2878
|
+
at: now(),
|
|
2879
|
+
scroll,
|
|
2880
|
+
places: places.map(({ words, ...place }) => new Place({
|
|
2881
|
+
...place,
|
|
2882
|
+
page: moved(place.box),
|
|
2883
|
+
words: words?.map((word) => new Word({
|
|
2884
|
+
...word,
|
|
2885
|
+
page: moved(word.box)
|
|
2886
|
+
}))
|
|
2887
|
+
}))
|
|
2888
|
+
});
|
|
2889
|
+
});
|
|
2890
|
+
return layouts(JSON.stringify(asked), once.pipe(Effect.retry({
|
|
2891
|
+
times: 1,
|
|
2892
|
+
while: (error) => contextGone(error) || error.reason._tag === "NotActionable" && error.operation === "layout"
|
|
2893
|
+
}), within("layout"))).pipe(span("Page.layout", { picks: asked.length }), owned);
|
|
2894
|
+
};
|
|
2895
|
+
return layout;
|
|
2896
|
+
};
|
|
2897
|
+
//#endregion
|
|
2861
2898
|
//#region src/internal/reading/reading.ts
|
|
2862
2899
|
/**
|
|
2863
2900
|
* Reading a page: its outline with refs, the elements a query finds and the text it shows. Each
|
|
2864
2901
|
* read takes its turn on the page and shares its work with identical reads, as `lane.ts`
|
|
2865
2902
|
* describes. The viewport's text as it was last read is kept, for `Page.state`.
|
|
2866
2903
|
*/
|
|
2904
|
+
/** The outline as a `Snapshot` reads it, or why `within` is not a selector. */
|
|
2905
|
+
const SnapshotResultSchema = Schema.Union([Schema.Struct({ snapshot: Snapshot }), Schema.Struct({ invalid: Schema.String })]);
|
|
2906
|
+
/** What `text` sends back, or null when its ref no longer names an element. */
|
|
2907
|
+
const TextResultSchema = Schema.NullOr(Schema.Struct({
|
|
2908
|
+
text: Schema.String,
|
|
2909
|
+
truncated: Schema.Boolean,
|
|
2910
|
+
url: Schema.String,
|
|
2911
|
+
title: Schema.String
|
|
2912
|
+
}));
|
|
2867
2913
|
const FindResults = Schema.Union([Schema.Struct({ found: Schema.Array(Found) }), Schema.Struct({ invalid: Schema.String })]);
|
|
2868
2914
|
const UntilResult = Schema.Union([Schema.Struct({
|
|
2869
2915
|
met: Schema.Boolean,
|
|
2870
2916
|
mark: Schema.String
|
|
2871
2917
|
}), Schema.Struct({ invalid: Schema.String })]);
|
|
2872
|
-
const make$
|
|
2918
|
+
const make$13 = (page, bridge) => Effect.sync(() => {
|
|
2873
2919
|
const { now, span, owned, within, lane } = page;
|
|
2874
2920
|
const { evaluate } = bridge;
|
|
2875
2921
|
const snapshots = lane.shared("snapshot", true);
|
|
@@ -2961,11 +3007,22 @@ const make$10 = (page, bridge) => Effect.sync(() => {
|
|
|
2961
3007
|
//#endregion
|
|
2962
3008
|
//#region src/internal/reading/ready.ts
|
|
2963
3009
|
/** Document readiness and content quiet, independent of screen-capture features. */
|
|
2964
|
-
|
|
3010
|
+
/** What the page is still waiting for; none when it is ready. */
|
|
3011
|
+
const ReadinessSchema = Schema.Array(Schema.Literals([
|
|
3012
|
+
"load",
|
|
3013
|
+
"paint",
|
|
3014
|
+
"animations",
|
|
3015
|
+
"images",
|
|
3016
|
+
"fonts",
|
|
3017
|
+
"busy",
|
|
3018
|
+
"content",
|
|
3019
|
+
"changing"
|
|
3020
|
+
]));
|
|
3021
|
+
const make$12 = (page, bridge) => (options = {}) => {
|
|
2965
3022
|
const quietMillis = options.quietMillis ?? 0;
|
|
2966
3023
|
if (!Number.isFinite(quietMillis) || quietMillis < 0) return refuse("ready", "quietMillis must be finite and nonnegative");
|
|
2967
3024
|
const timeout = options.timeout ?? Duration.seconds(15);
|
|
2968
|
-
const settled = (until) => Effect.suspend(() => bridge.evaluate("ready", scriptCall("ready", Math.max(0, Math.round(until - page.now())), quietMillis))).pipe(Effect.retry({
|
|
3025
|
+
const settled = (until) => Effect.suspend(() => bridge.evaluate("ready", scriptCall("ready", Math.max(0, Math.round(until - page.now())), quietMillis, page.settings.pageTime ?? null))).pipe(Effect.retry({
|
|
2969
3026
|
while: contextGone,
|
|
2970
3027
|
schedule: Schedule.spaced(Duration.millis(10))
|
|
2971
3028
|
}), Effect.flatMap(decodeWith("ready", ReadinessSchema)), Effect.tap((waiting) => Effect.annotateCurrentSpan({ waiting: waiting.join(",") })), Effect.filterOrElse((waiting) => waiting.length === 0, () => failWith("ready", new Timeout({ millis: Duration.toMillis(timeout) }))));
|
|
@@ -2983,9 +3040,19 @@ const make$9 = (page, bridge) => (options = {}) => {
|
|
|
2983
3040
|
* identical ones in flight share it; none is kept for a later caller, since its window ends when
|
|
2984
3041
|
* it was read.
|
|
2985
3042
|
*/
|
|
3043
|
+
/**
|
|
3044
|
+
* What a read sends back: its window and the record's state, and each change as `Change` encodes
|
|
3045
|
+
* it, all on the page's clock.
|
|
3046
|
+
*/
|
|
3047
|
+
const ChangesResultSchema = Schema.Struct({
|
|
3048
|
+
until: Schema.Finite,
|
|
3049
|
+
from: Schema.Finite,
|
|
3050
|
+
dropped: Schema.Int,
|
|
3051
|
+
records: Schema.Array(Change)
|
|
3052
|
+
});
|
|
2986
3053
|
const isChanges = Schema.is(Changes);
|
|
2987
3054
|
const markOf = (time) => time === void 0 || typeof time === "number" ? time : isChanges(time) ? `cursor ${time.cursor}` : `frame ${time.timestamp ?? time.hostTime}`;
|
|
2988
|
-
const make$
|
|
3055
|
+
const make$11 = (page, bridge, estimate) => {
|
|
2989
3056
|
const reads = page.lane.shared("changes", false);
|
|
2990
3057
|
const recording = Semaphore.makeUnsafe(1);
|
|
2991
3058
|
const idleMillis = 12e4;
|
|
@@ -3076,7 +3143,7 @@ const within = ({ since, until }, events, frames) => ({
|
|
|
3076
3143
|
events: events.filter((event) => event.at > since && event.at <= until && !isTrackEvent(event)),
|
|
3077
3144
|
frames: frames.filter((frame) => frame.hostTime >= since && frame.hostTime <= until)
|
|
3078
3145
|
});
|
|
3079
|
-
const make$
|
|
3146
|
+
const make$10 = (page, read, frames) => ({ since, until, unmask }) => Effect.gen(function* () {
|
|
3080
3147
|
const asked = boundsOf({
|
|
3081
3148
|
since,
|
|
3082
3149
|
until
|
|
@@ -3103,7 +3170,7 @@ const make$7 = (page, read, frames) => ({ since, until, unmask }) => Effect.gen(
|
|
|
3103
3170
|
* Each move is an action, so it takes the page's turn, goes through the input guard and is
|
|
3104
3171
|
* recorded, but it sends no input.
|
|
3105
3172
|
*/
|
|
3106
|
-
const make$
|
|
3173
|
+
const make$9 = (page, perform, preparePolicy) => {
|
|
3107
3174
|
const { playwright, settings, native } = page;
|
|
3108
3175
|
const { send } = page.protocol;
|
|
3109
3176
|
const navigation = (value, run, address) => {
|
|
@@ -3189,9 +3256,89 @@ const make$6 = (page, perform, preparePolicy) => {
|
|
|
3189
3256
|
};
|
|
3190
3257
|
};
|
|
3191
3258
|
//#endregion
|
|
3259
|
+
//#region src/internal/page/overlay.ts
|
|
3260
|
+
/**
|
|
3261
|
+
* The page's overlay: one lease at a time, each drawing one call to the page, in turn after the
|
|
3262
|
+
* actions asked before it, never two at once. Each new document gets what was last drawn once it
|
|
3263
|
+
* has loaded; the lease's scope takes the layer away.
|
|
3264
|
+
*/
|
|
3265
|
+
const Drawn = Schema.Array(Box);
|
|
3266
|
+
const make$8 = (page, bridge) => {
|
|
3267
|
+
const { lane, owned, span, within } = page;
|
|
3268
|
+
const turns = Semaphore.makeUnsafe(1);
|
|
3269
|
+
let open = false;
|
|
3270
|
+
let shown = null;
|
|
3271
|
+
let drawn = [];
|
|
3272
|
+
const record = (markup, boxes) => {
|
|
3273
|
+
shown = markup;
|
|
3274
|
+
drawn = boxes;
|
|
3275
|
+
page.noteInput();
|
|
3276
|
+
};
|
|
3277
|
+
const send = (markup) => turns.withPermit(lane.read("overlay")(bridge.evaluate("overlay", scriptCall("overlay", markup)).pipe(Effect.flatMap(decodeWith("overlay", Drawn)), Effect.tap((boxes) => Effect.sync(() => record(markup, boxes))), within("overlay"))));
|
|
3278
|
+
const draw = (content) => send(content._tag === "Svg" ? content.markup : null).pipe(span("Overlay.draw"), owned);
|
|
3279
|
+
const redraw = (document) => bridge.waitForDocument(document).pipe(Effect.andThen(Effect.void.pipe(Effect.repeat({
|
|
3280
|
+
schedule: Schedule.spaced(Duration.millis(50)),
|
|
3281
|
+
until: () => bridge.loaded() !== void 0
|
|
3282
|
+
}), within("overlay", page.settings.navigationTimeout))), Effect.andThen(Effect.suspend(() => shown === null ? Effect.void : send(shown))), Effect.ignore);
|
|
3283
|
+
return {
|
|
3284
|
+
lease: Effect.gen(function* () {
|
|
3285
|
+
if (open) return yield* refuse("overlay", "the page has an overlay already");
|
|
3286
|
+
open = true;
|
|
3287
|
+
yield* Effect.addFinalizer(() => Effect.suspend(() => {
|
|
3288
|
+
open = false;
|
|
3289
|
+
return shown === null ? Effect.void : send(null).pipe(Effect.ignore);
|
|
3290
|
+
}));
|
|
3291
|
+
yield* Effect.forkScoped(Effect.suspend(() => redraw(bridge.frameTag().document)).pipe(Effect.forever));
|
|
3292
|
+
return { draw };
|
|
3293
|
+
}),
|
|
3294
|
+
drawn: () => shown === null ? void 0 : drawn,
|
|
3295
|
+
open: () => open,
|
|
3296
|
+
record,
|
|
3297
|
+
/** Run a call that draws in the overlay's turn, so no other drawing overtakes it. */
|
|
3298
|
+
turn: (effect) => turns.withPermit(effect)
|
|
3299
|
+
};
|
|
3300
|
+
};
|
|
3301
|
+
//#endregion
|
|
3302
|
+
//#region src/internal/page/pose.ts
|
|
3303
|
+
/**
|
|
3304
|
+
* The page's poses: one lease at a time, each `set` one call to the page in the page's turn, as an
|
|
3305
|
+
* action takes it, so no action resolves a target that a pose then moves. The lease's scope takes
|
|
3306
|
+
* every pose off. See `Pose`.
|
|
3307
|
+
*/
|
|
3308
|
+
/** What posing answered: nothing, or the ref it could not pose and why. */
|
|
3309
|
+
const Posed = Schema.Struct({
|
|
3310
|
+
stale: Schema.optional(Schema.String),
|
|
3311
|
+
invalid: Schema.optional(Schema.String)
|
|
3312
|
+
});
|
|
3313
|
+
const make$7 = (page, bridge) => {
|
|
3314
|
+
const { lane, owned, span, within } = page;
|
|
3315
|
+
let open = false;
|
|
3316
|
+
/** The page's requests for `poses`, each part left out made the one that changes nothing. */
|
|
3317
|
+
const requests = Effect.fnUntraced(function* (operation, poses) {
|
|
3318
|
+
const decoded = yield* Schema.decodeEffect(Schema.Array(Pose))(poses).pipe(Effect.catch(() => refuse(operation, "each pose is a ref and finite numbers")));
|
|
3319
|
+
if (decoded.length > 256) return yield* refuse(operation, "at most 256 elements are posed at once");
|
|
3320
|
+
return decoded.map(poseRequest);
|
|
3321
|
+
});
|
|
3322
|
+
/** Fail as the page's answer says, if it posed nothing. */
|
|
3323
|
+
const answered = (operation, posed) => posed.stale !== void 0 ? failWith(operation, new StaleRef({ ref: posed.stale })) : posed.invalid !== void 0 ? refuse(operation, posed.invalid) : Effect.void;
|
|
3324
|
+
const send = (operation, script) => lane.write(operation, page.settings.actionTimeout)(bridge.evaluate(operation, script).pipe(Effect.flatMap(decodeWith(operation, Posed)), Effect.flatMap((posed) => answered(operation, posed)), Effect.tap(() => Effect.sync(page.noteInput)), within(operation)));
|
|
3325
|
+
const set = (poses) => requests("pose", poses).pipe(Effect.flatMap((made) => send("pose", scriptCall("pose", made))), span("Poses.set"), owned);
|
|
3326
|
+
return {
|
|
3327
|
+
lease: Effect.gen(function* () {
|
|
3328
|
+
if (open) return yield* refuse("pose", "the page's poses are open already");
|
|
3329
|
+
open = true;
|
|
3330
|
+
yield* Effect.addFinalizer(() => send("pose", scriptCall("unpose")).pipe(Effect.ignore, Effect.ensuring(Effect.sync(() => open = false))));
|
|
3331
|
+
return { set };
|
|
3332
|
+
}),
|
|
3333
|
+
open: () => open,
|
|
3334
|
+
requests,
|
|
3335
|
+
answered
|
|
3336
|
+
};
|
|
3337
|
+
};
|
|
3338
|
+
//#endregion
|
|
3192
3339
|
//#region src/internal/page/scripts.ts
|
|
3193
3340
|
/** Main-world scripts with the page lane, document binding, policy and dispatch accounting. */
|
|
3194
|
-
const make$
|
|
3341
|
+
const make$6 = (page, bridge, input) => {
|
|
3195
3342
|
const document = () => bridge.frameTag().document;
|
|
3196
3343
|
const changed = (operation) => failWith(operation, new NotActionable({ detail: "the script's document changed" }));
|
|
3197
3344
|
const evaluate = (operation, script, arg) => page.native(operation, () => Promise.resolve(Reflect.apply(page.playwright.evaluate.bind(page.playwright), void 0, [script, arg])));
|
|
@@ -3247,6 +3394,75 @@ const make$5 = (page, bridge, input) => {
|
|
|
3247
3394
|
};
|
|
3248
3395
|
};
|
|
3249
3396
|
//#endregion
|
|
3397
|
+
//#region src/internal/page/time.ts
|
|
3398
|
+
/**
|
|
3399
|
+
* Holding a page's time: one hold at a time, each step one call to the page that takes the page
|
|
3400
|
+
* to itself, as an action does, so no read sees a step half made. See `PageTime`.
|
|
3401
|
+
*/
|
|
3402
|
+
const Stepped = Schema.Struct({
|
|
3403
|
+
...Posed.fields,
|
|
3404
|
+
told: Schema.Boolean,
|
|
3405
|
+
drawn: Schema.NullOr(Schema.Array(Box)),
|
|
3406
|
+
scroll: Point
|
|
3407
|
+
});
|
|
3408
|
+
const make$5 = (page, bridge, overlays, posing) => {
|
|
3409
|
+
const { lane, owned, span, within } = page;
|
|
3410
|
+
let holding = false;
|
|
3411
|
+
const step = (operation, request) => {
|
|
3412
|
+
const sent = lane.write(operation, page.settings.actionTimeout)(bridge.evaluate(operation, scriptCall("step", request)).pipe(Effect.flatMap(decodeWith(operation, Stepped)), Effect.tap(({ drawn }) => Effect.sync(() => {
|
|
3413
|
+
if (drawn !== null && request.markup !== void 0) overlays.record(request.markup, drawn);
|
|
3414
|
+
page.noteInput();
|
|
3415
|
+
})), within(operation))).pipe(span(`PageTime.${operation}`), owned);
|
|
3416
|
+
return request.markup === void 0 ? sent : overlays.turn(sent);
|
|
3417
|
+
};
|
|
3418
|
+
const unclocked = (operation) => failWith(operation, new NotActionable({ detail: "the page's document has no page clock" }));
|
|
3419
|
+
return { hold: Effect.gen(function* () {
|
|
3420
|
+
const clock = page.settings.pageTime;
|
|
3421
|
+
if (clock === void 0) return yield* refuse("hold", "holding page time needs the browser's pageTime option");
|
|
3422
|
+
if (holding) return yield* refuse("hold", "the page's time is held already");
|
|
3423
|
+
holding = true;
|
|
3424
|
+
let ended = false;
|
|
3425
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => ended = true).pipe(Effect.andThen(step("release", {
|
|
3426
|
+
clock,
|
|
3427
|
+
op: "release",
|
|
3428
|
+
by: 0,
|
|
3429
|
+
scroll: null
|
|
3430
|
+
})), Effect.ignore, Effect.ensuring(Effect.sync(() => holding = false))));
|
|
3431
|
+
if (!(yield* step("hold", {
|
|
3432
|
+
clock,
|
|
3433
|
+
op: "hold",
|
|
3434
|
+
by: 0,
|
|
3435
|
+
scroll: null
|
|
3436
|
+
})).told) return yield* unclocked("hold");
|
|
3437
|
+
let elapsed = 0;
|
|
3438
|
+
const advance = (by, options = {}) => Effect.gen(function* () {
|
|
3439
|
+
const millis = Option.map(Duration.fromInput(by), Duration.toMillis).pipe(Option.getOrElse(() => NaN));
|
|
3440
|
+
if (ended) return yield* refuse("advance", "the hold has ended");
|
|
3441
|
+
if (!Number.isFinite(millis) || millis < 0) return yield* refuse("advance", "page time moves on by a finite, nonnegative duration");
|
|
3442
|
+
if (options.scroll !== void 0 && !Number.isFinite(options.scroll)) return yield* refuse("advance", "the scroll must be finite");
|
|
3443
|
+
if (options.overlay !== void 0 && !overlays.open()) return yield* refuse("advance", "drawing needs the page's overlay open");
|
|
3444
|
+
if (options.poses !== void 0 && !posing.open()) return yield* refuse("advance", "posing needs the page's poses open");
|
|
3445
|
+
const poses = options.poses === void 0 ? void 0 : yield* posing.requests("advance", options.poses);
|
|
3446
|
+
const stepped = yield* step("advance", {
|
|
3447
|
+
clock,
|
|
3448
|
+
op: "advance",
|
|
3449
|
+
by: millis,
|
|
3450
|
+
scroll: options.scroll ?? null,
|
|
3451
|
+
markup: options.overlay === void 0 ? void 0 : options.overlay._tag === "Svg" ? options.overlay.markup : null,
|
|
3452
|
+
poses
|
|
3453
|
+
});
|
|
3454
|
+
yield* posing.answered("advance", stepped);
|
|
3455
|
+
if (!stepped.told) return yield* unclocked("advance");
|
|
3456
|
+
elapsed += millis;
|
|
3457
|
+
return stepped.scroll;
|
|
3458
|
+
});
|
|
3459
|
+
return {
|
|
3460
|
+
advance,
|
|
3461
|
+
elapsed: Effect.sync(() => Duration.millis(elapsed))
|
|
3462
|
+
};
|
|
3463
|
+
}) };
|
|
3464
|
+
};
|
|
3465
|
+
//#endregion
|
|
3250
3466
|
//#region src/internal/page/viewport.ts
|
|
3251
3467
|
/**
|
|
3252
3468
|
* The viewport's size in CSS pixels. Playwright knows it only for a context it created; over CDP it
|
|
@@ -3254,6 +3470,10 @@ const make$5 = (page, bridge, input) => {
|
|
|
3254
3470
|
* pixel. Pointer bounds, page scrolls, crops, capture size and frame reuse all read this one
|
|
3255
3471
|
* source; the latest answer serves checks that cannot wait for the page.
|
|
3256
3472
|
*/
|
|
3473
|
+
const ViewportResultSchema = Schema.Struct({
|
|
3474
|
+
width: Schema.Finite,
|
|
3475
|
+
height: Schema.Finite
|
|
3476
|
+
});
|
|
3257
3477
|
const make$4 = (page, bridge) => {
|
|
3258
3478
|
const { playwright } = page;
|
|
3259
3479
|
let measuredViewport = null;
|
|
@@ -3287,16 +3507,18 @@ const make$4 = (page, bridge) => {
|
|
|
3287
3507
|
* Features use the same documented Page contract as consumers.
|
|
3288
3508
|
*/
|
|
3289
3509
|
const make$3 = Effect.fnUntraced(function* (options) {
|
|
3290
|
-
const page = make$
|
|
3510
|
+
const page = make$29(options, yield* Effect.scope);
|
|
3291
3511
|
const { id, playwright, native, owned, within, lane, span } = page;
|
|
3292
|
-
const bridge = yield* make$
|
|
3512
|
+
const bridge = yield* make$28(page);
|
|
3293
3513
|
const viewport = make$4(page, bridge);
|
|
3294
|
-
const input = make$
|
|
3295
|
-
const pictures = yield* make$
|
|
3296
|
-
const reading = yield* make$
|
|
3297
|
-
const navigation = make$
|
|
3514
|
+
const input = make$18(page, bridge, viewport);
|
|
3515
|
+
const pictures = yield* make$15(page, bridge, viewport);
|
|
3516
|
+
const reading = yield* make$13(page, bridge);
|
|
3517
|
+
const navigation = make$9(page, input.perform, input.preparePolicy);
|
|
3298
3518
|
const { capture } = pictures;
|
|
3299
|
-
const changes = make$
|
|
3519
|
+
const changes = make$11(page, bridge, pictures.estimate);
|
|
3520
|
+
const overlay = make$8(page, bridge);
|
|
3521
|
+
const poses = make$7(page, bridge);
|
|
3300
3522
|
const titles = lane.shared("title", true);
|
|
3301
3523
|
const viewports = lane.shared("viewport", true);
|
|
3302
3524
|
const state = Effect.map(capture.latest, (latest) => {
|
|
@@ -3311,6 +3533,7 @@ const make$3 = Effect.fnUntraced(function* (options) {
|
|
|
3311
3533
|
committedAt: Number.isFinite(committedAt) ? committedAt : void 0,
|
|
3312
3534
|
load: bridge.loaded(),
|
|
3313
3535
|
frame: Option.getOrUndefined(latest),
|
|
3536
|
+
overlay: overlay.drawn(),
|
|
3314
3537
|
text: reading.viewedSince(committedAt)
|
|
3315
3538
|
});
|
|
3316
3539
|
});
|
|
@@ -3322,7 +3545,7 @@ const make$3 = Effect.fnUntraced(function* (options) {
|
|
|
3322
3545
|
...navigation
|
|
3323
3546
|
}, action));
|
|
3324
3547
|
return {
|
|
3325
|
-
...make$
|
|
3548
|
+
...make$6(page, bridge, input),
|
|
3326
3549
|
...methods(perform),
|
|
3327
3550
|
perform,
|
|
3328
3551
|
clock: page.clock,
|
|
@@ -3344,13 +3567,18 @@ const make$3 = Effect.fnUntraced(function* (options) {
|
|
|
3344
3567
|
screenshot: pictures.screenshot,
|
|
3345
3568
|
frame: pictures.frame,
|
|
3346
3569
|
zoom: pictures.zoom,
|
|
3570
|
+
paint: pictures.paint,
|
|
3347
3571
|
viewport: viewports("", viewport.viewportFor("viewport").pipe(within("viewport"))).pipe(span("Page.viewport"), owned),
|
|
3348
3572
|
find: reading.find,
|
|
3573
|
+
layout: make$14(page, bridge),
|
|
3574
|
+
overlay: overlay.lease,
|
|
3575
|
+
poses: poses.lease,
|
|
3576
|
+
hold: make$5(page, bridge, overlay, poses).hold,
|
|
3349
3577
|
text: reading.text,
|
|
3350
3578
|
changes,
|
|
3351
|
-
window: make$
|
|
3579
|
+
window: make$10(page, changes, capture.recent),
|
|
3352
3580
|
state,
|
|
3353
|
-
ready: make$
|
|
3581
|
+
ready: make$12(page, bridge),
|
|
3354
3582
|
screencast: capture.stream,
|
|
3355
3583
|
captureStats: pictures.captureStats,
|
|
3356
3584
|
recentFrames: capture.recent,
|
|
@@ -3749,7 +3977,8 @@ const settingsOf = Effect.fnUntraced(function* (options) {
|
|
|
3749
3977
|
navigationTimeout: yield* bound("navigationTimeout", options.navigationTimeout, Duration.seconds(30)),
|
|
3750
3978
|
frameHistory: yield* bound("frameHistory", options.frameHistory, Duration.seconds(5)),
|
|
3751
3979
|
guard: options.guard,
|
|
3752
|
-
policyTimeout: yield* bound("policyTimeout", options.policyTimeout, Duration.minutes(5))
|
|
3980
|
+
policyTimeout: yield* bound("policyTimeout", options.policyTimeout, Duration.minutes(5)),
|
|
3981
|
+
pageTime: options.pageTime === true ? `effect-browser-time-${yield* make$27}` : void 0
|
|
3753
3982
|
};
|
|
3754
3983
|
if (options.viewport !== void 0 && ![options.viewport.width, options.viewport.height].every((size) => Number.isSafeInteger(size) && size > 0)) return yield* invalid("viewport dimensions must be positive safe integers");
|
|
3755
3984
|
const eventHistory = options.eventHistory ?? 4096;
|
|
@@ -3841,8 +4070,6 @@ const releaseNative = (clock) => (run) => Effect.tryPromise(run).pipe(Effect.int
|
|
|
3841
4070
|
}), Effect.provideService(Clock.Clock, clock), Effect.ignore);
|
|
3842
4071
|
/** A page's own events among the browser's retained ones, and the openings of tabs it opened. */
|
|
3843
4072
|
const eventsOf = (recent, page) => Effect.map(recent, (records) => records.flatMap(({ event }) => "page" in event && event.page === page || event._tag === "PageOpened" && event.opener === page ? [event] : []));
|
|
3844
|
-
/** A script as its documents run it: everywhere, or as a block where its `match` allows. */
|
|
3845
|
-
const scoped = ({ match, source }) => match === void 0 ? source : `if (${String(match)}.test(location.href)) {\n${source}\n}`;
|
|
3846
4073
|
/**
|
|
3847
4074
|
* At most `maxPages` open pages, those a site opened included, which are never refused: an open
|
|
3848
4075
|
* past it waits for one to close, within `wait` on the owner's clock, then fails `Limit`, or fails
|
|
@@ -3919,7 +4146,7 @@ const tabs = (context, registry, budget, native, register, release, firstPageLoc
|
|
|
3919
4146
|
/** One connection owns clocks, loss, authority and its bounded timeline. */
|
|
3920
4147
|
const runtime = Effect.fnUntraced(function* (context, expiresAt, options) {
|
|
3921
4148
|
const clock = yield* Clock.Clock;
|
|
3922
|
-
const connection = yield* make$
|
|
4149
|
+
const connection = yield* make$27;
|
|
3923
4150
|
const protocol = yield* Current$1;
|
|
3924
4151
|
const releasePort = protocol.browser?.(connection, context);
|
|
3925
4152
|
yield* Effect.addFinalizer(() => Effect.sync(() => releasePort?.()));
|
|
@@ -3953,7 +4180,7 @@ const runtime = Effect.fnUntraced(function* (context, expiresAt, options) {
|
|
|
3953
4180
|
lose,
|
|
3954
4181
|
untilLost,
|
|
3955
4182
|
native,
|
|
3956
|
-
inputGate: make$
|
|
4183
|
+
inputGate: make$31({
|
|
3957
4184
|
now,
|
|
3958
4185
|
sequence: timeline.sequence,
|
|
3959
4186
|
closedBy: lostBy,
|
|
@@ -4008,7 +4235,7 @@ const make = Effect.fn("Browser.make")(function* (context, info, options = {}) {
|
|
|
4008
4235
|
mapping,
|
|
4009
4236
|
publish,
|
|
4010
4237
|
recentEvents: eventsOf(timeline.recent, id),
|
|
4011
|
-
openings: yield* make$
|
|
4238
|
+
openings: yield* make$26(playwright, cdp, registrations, closedBy),
|
|
4012
4239
|
focused: call("focus", () => focusing, closedBy).pipe(Effect.asVoid),
|
|
4013
4240
|
paging: (operation) => call(operation, () => paging, closedBy).pipe(Effect.asVoid),
|
|
4014
4241
|
closedBy,
|
|
@@ -4050,7 +4277,7 @@ const make = Effect.fn("Browser.make")(function* (context, info, options = {}) {
|
|
|
4050
4277
|
return page;
|
|
4051
4278
|
}).pipe(Scope.provide(scope), Effect.onError(() => Scope.close(scope, Exit.void)));
|
|
4052
4279
|
});
|
|
4053
|
-
for (const
|
|
4280
|
+
for (const content of documentScripts(settings.pageTime, options.initScripts ?? [])) yield* native("initScripts", () => context.addInitScript({ content }));
|
|
4054
4281
|
const register = yield* followOpened(context, registrations, registerPage, publish, now);
|
|
4055
4282
|
for (const existing of context.pages()) yield* register(existing);
|
|
4056
4283
|
yield* Effect.addFinalizer(() => Effect.sync(() => lose("released")));
|
|
@@ -4070,6 +4297,6 @@ const make = Effect.fn("Browser.make")(function* (context, info, options = {}) {
|
|
|
4070
4297
|
return Browser.of(service);
|
|
4071
4298
|
});
|
|
4072
4299
|
//#endregion
|
|
4073
|
-
export { make$1 as a, make as i, Browser_exports as n,
|
|
4300
|
+
export { make$1 as a, make as i, Browser_exports as n, make$31 as o, Suspension as r, Browser as t };
|
|
4074
4301
|
|
|
4075
|
-
//# sourceMappingURL=Browser-
|
|
4302
|
+
//# sourceMappingURL=Browser-CAQFhTkM.mjs.map
|