castle-web-cli 0.4.212 → 0.4.214

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.
Files changed (56) hide show
  1. package/dist/agent-prompts.d.ts +1 -0
  2. package/dist/agent-prompts.js +28 -6
  3. package/dist/agent.js +33 -2
  4. package/dist/cloudGit.d.ts +254 -0
  5. package/dist/cloudGit.js +1687 -0
  6. package/dist/cloudGitServe.d.ts +41 -0
  7. package/dist/cloudGitServe.js +318 -0
  8. package/dist/cover-bridge/play-cover-bridge.js +2 -0
  9. package/dist/externalSourcemaps.js +2 -1
  10. package/dist/gitRemote.d.ts +4 -1
  11. package/dist/gitRemote.js +4 -2
  12. package/dist/ide.js +52 -7
  13. package/dist/index.js +149 -2
  14. package/dist/playCover/bridge.d.ts +6 -0
  15. package/dist/playCover/bridge.js +159 -0
  16. package/dist/playCover/builtins.d.ts +29 -0
  17. package/dist/playCover/builtins.js +189 -0
  18. package/dist/playCover/capture.d.ts +53 -0
  19. package/dist/playCover/capture.js +419 -0
  20. package/dist/playCover/clone.d.ts +40 -0
  21. package/dist/playCover/clone.js +317 -0
  22. package/dist/playCover/engine.d.ts +37 -0
  23. package/dist/playCover/engine.js +76 -0
  24. package/dist/playCover/errors.d.ts +6 -0
  25. package/dist/playCover/errors.js +18 -0
  26. package/dist/playCover/images.d.ts +21 -0
  27. package/dist/playCover/images.js +180 -0
  28. package/dist/playCover/instrument.d.ts +49 -0
  29. package/dist/playCover/instrument.js +334 -0
  30. package/dist/playCover/protocol.d.ts +14 -0
  31. package/dist/playCover/protocol.js +139 -0
  32. package/dist/playCover/rasterize.d.ts +21 -0
  33. package/dist/playCover/rasterize.js +408 -0
  34. package/dist/playCover/resources.d.ts +31 -0
  35. package/dist/playCover/resources.js +823 -0
  36. package/dist/playCover/scratchCanvas.d.ts +4 -0
  37. package/dist/playCover/scratchCanvas.js +16 -0
  38. package/dist/playCover/textSamples.d.ts +36 -0
  39. package/dist/playCover/textSamples.js +412 -0
  40. package/dist/playCover/validate.d.ts +79 -0
  41. package/dist/playCover/validate.js +883 -0
  42. package/dist/playCover/verify.d.ts +56 -0
  43. package/dist/playCover/verify.js +578 -0
  44. package/dist/playCover/verifyRecord.d.ts +71 -0
  45. package/dist/playCover/verifyRecord.js +243 -0
  46. package/dist/playCoverGate.d.ts +4 -0
  47. package/dist/playCoverGate.js +57 -0
  48. package/dist/playCoverPlacement.d.ts +11 -0
  49. package/dist/playCoverPlacement.js +110 -0
  50. package/dist/serve.d.ts +1 -0
  51. package/dist/serve.js +35 -17
  52. package/dist/shell/assets/index-BPhS3Ysy.css +1 -0
  53. package/dist/shell/assets/{index-DzLbNBc7.js → index-BcslKMfS.js} +94 -92
  54. package/dist/shell/index.html +2 -2
  55. package/package.json +2 -2
  56. package/dist/shell/assets/index-BCrgYh76.css +0 -1
@@ -0,0 +1,41 @@
1
+ import { type CommitReason } from './cloudGit.js';
2
+ export declare const MERGE_CHECK_MS: number;
3
+ export declare const REASK_MS: number;
4
+ export interface ServeGitHooksOptions {
5
+ deckDir: string;
6
+ env?: NodeJS.ProcessEnv;
7
+ /** Whether no task agent is running or waiting to run. */
8
+ boardIdle: () => boolean;
9
+ /** Whether the router is in a turn. */
10
+ routerBusy?: () => boolean;
11
+ /** A line in the chat. */
12
+ addLog: (text: string) => void;
13
+ /** Queue a router turn with an instruction the user does not see as their own message. */
14
+ enqueueInstruction: (text: string) => void;
15
+ /** Injected by tests; defaults to spawning this CLI. Resolves to its exit code. */
16
+ runCommit?: (reason: CommitReason, message: string | undefined) => Promise<number>;
17
+ pollMs?: number;
18
+ /** How often an idle serve checks for a merge still waiting (MERGE_CHECK_MS). */
19
+ mergeCheckMs?: number;
20
+ now?: () => number;
21
+ }
22
+ export interface ServeGitHooks {
23
+ /** The router's turn (and any follow-up it drained) is over. */
24
+ routerSettled(): void;
25
+ /** A task agent started. */
26
+ taskStarted(): void;
27
+ /** A task agent finished; `done` when it succeeded. */
28
+ taskFinished(title: string, done: boolean): void;
29
+ /** Check for markers now (the poll does this on its own). */
30
+ checkConflict(): void;
31
+ /** Resolves when no commit is running or queued. For tests. */
32
+ idle(): Promise<void>;
33
+ stop(): void;
34
+ }
35
+ /** Run this CLI as a child and collect its exit code and (the tail of) its output. */
36
+ export declare function runCastleWeb(args: string[], cwd: string, env?: NodeJS.ProcessEnv, timeoutMs?: number, graceMs?: number): Promise<{
37
+ code: number;
38
+ output: string;
39
+ }>;
40
+ /** Null unless the serve runs with CASTLE_GIT=on. Whether the deck is attached is asked per commit. */
41
+ export declare function createServeGitHooks(opts: ServeGitHooksOptions): ServeGitHooks | null;
@@ -0,0 +1,318 @@
1
+ import { spawn } from 'child_process';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { AGENT_MARKER_FILES, cloudGitModeAsync, CONFLICT_MARKER_FILE, DEADLINE_ENV, EXIT_CONFLICT, EXIT_NOT_ENABLED, mergeInProgress, readLeavePending, readMergeState, setDeckBusy, } from './cloudGit.js';
6
+ // The serve's half of git in the cloud sandbox (castle-sandboxes docs/git-remotes-phase2.md):
7
+ // - `commit --reason turn` when the router settles with the task board idle,
8
+ // - `commit --reason task` when the task board goes idle,
9
+ // - the busy note (cloudGit's BUSY_FILE) while a task agent or the router is working, which
10
+ // keeps every other commit and sync from merging the remote into files mid-task,
11
+ // - and the markers `git sync` and `git attach` leave (a merge conflict, a cloud copy
12
+ // replaced by the remote's version) become router turns. A merge still unresolved gets
13
+ // another turn -- when a later commit is refused, or on its own every MERGE_CHECK_MS while
14
+ // the deck is idle -- at most every REASK_MS.
15
+ //
16
+ // Commits run as a child `castle-web commit`, never in-process: a commit ends with a fetch
17
+ // and a push, which must not block the serve's event loop, and the CLI's own lock already
18
+ // serializes it against the sandbox agent's commits.
19
+ const CLI_ENTRY = path.join(path.dirname(fileURLToPath(import.meta.url)), 'index.js');
20
+ const COMMIT_TIMEOUT_MS = 5 * 60_000;
21
+ // After the time limit a child gets SIGTERM, and stops at its next safe point (never inside a
22
+ // git command, and it skips packing once asked); SIGKILL follows only if it does not. The
23
+ // child is told the moment (DEADLINE_ENV, a margin short of the SIGKILL) and caps every git
24
+ // step's own timeout by it, so no step -- a push may take two minutes -- outlives the grace.
25
+ const KILL_GRACE_MS = 60_000;
26
+ const DEADLINE_MARGIN_MS = 5_000;
27
+ const CONFLICT_POLL_MS = 1500;
28
+ // How often an idle serve looks for a merge still waiting on the agent (asking again is
29
+ // rate-limited by REASK_MS on top of this).
30
+ export const MERGE_CHECK_MS = 2 * 60_000;
31
+ const MAX_TITLES_IN_MESSAGE = 3;
32
+ export const REASK_MS = 10 * 60_000;
33
+ const CONFLICT_NOTICE = 'Changes pushed from another computer conflicted with this deck; the agent is resolving them.';
34
+ /** Run this CLI as a child and collect its exit code and (the tail of) its output. */
35
+ export function runCastleWeb(args, cwd, env = process.env, timeoutMs = COMMIT_TIMEOUT_MS, graceMs = KILL_GRACE_MS) {
36
+ return new Promise((resolve) => {
37
+ const deadline = Date.now() + timeoutMs + graceMs - Math.min(DEADLINE_MARGIN_MS, graceMs / 4);
38
+ // Its own process group, so the SIGKILL reaches every git it started: an orphaned git
39
+ // still writing after the deck lock is taken over would race the next holder.
40
+ const child = spawn(process.execPath, [CLI_ENTRY, ...args], {
41
+ cwd,
42
+ env: { ...env, [DEADLINE_ENV]: String(deadline) },
43
+ stdio: ['ignore', 'pipe', 'pipe'],
44
+ detached: true,
45
+ });
46
+ const killGroup = () => {
47
+ try {
48
+ if (child.pid)
49
+ process.kill(-child.pid, 'SIGKILL');
50
+ }
51
+ catch {
52
+ /* already gone */
53
+ }
54
+ };
55
+ let output = '';
56
+ const collect = (chunk) => {
57
+ output = (output + chunk.toString('utf-8')).slice(-4000);
58
+ };
59
+ child.stdout.on('data', collect);
60
+ child.stderr.on('data', collect);
61
+ let hardKill = null;
62
+ let timedOut = false;
63
+ const timer = setTimeout(() => {
64
+ timedOut = true;
65
+ child.kill('SIGTERM');
66
+ hardKill = setTimeout(killGroup, graceMs);
67
+ hardKill.unref();
68
+ }, timeoutMs);
69
+ timer.unref();
70
+ let settled = false;
71
+ const finish = (code) => {
72
+ if (settled)
73
+ return;
74
+ settled = true;
75
+ clearTimeout(timer);
76
+ if (hardKill)
77
+ clearTimeout(hardKill);
78
+ resolve({ code, output: output.trim() });
79
+ };
80
+ child.on('error', (err) => {
81
+ output += String(err);
82
+ finish(1);
83
+ });
84
+ // Stopped by the time limit: whatever it left running in its group (a git a step timeout
85
+ // gave up on, a hook) goes too -- which also closes the output pipes they inherited.
86
+ child.on('exit', (code) => {
87
+ if (timedOut || code === null)
88
+ killGroup();
89
+ });
90
+ child.on('close', (code) => finish(code ?? 1));
91
+ });
92
+ }
93
+ function spawnCommit(deckDir, env) {
94
+ return async (reason, message) => {
95
+ const args = ['commit', '--reason', reason, '--dir', deckDir];
96
+ if (message)
97
+ args.push('-m', message);
98
+ const { code, output } = await runCastleWeb(args, deckDir, env);
99
+ if (code !== EXIT_NOT_ENABLED) {
100
+ const log = code === 0 || code === EXIT_CONFLICT ? console.log : console.error;
101
+ log(`[git] commit --reason ${reason} exited ${code}: ${output}`);
102
+ }
103
+ return code;
104
+ };
105
+ }
106
+ function taskMessage(titles) {
107
+ if (titles.length === 0)
108
+ return undefined;
109
+ const shown = titles.slice(0, MAX_TITLES_IN_MESSAGE).join('; ');
110
+ const more = titles.length > MAX_TITLES_IN_MESSAGE ? ` (+${titles.length - MAX_TITLES_IN_MESSAGE} more)` : '';
111
+ return `${titles.length === 1 ? 'Task' : 'Tasks'}: ${shown}${more}`;
112
+ }
113
+ /** Null unless the serve runs with CASTLE_GIT=on. Whether the deck is attached is asked per commit. */
114
+ export function createServeGitHooks(opts) {
115
+ const env = opts.env ?? process.env;
116
+ if (env.CASTLE_GIT !== 'on')
117
+ return null;
118
+ const runCommit = opts.runCommit ?? spawnCommit(opts.deckDir, env);
119
+ const now = opts.now ?? (() => Date.now());
120
+ let running = null;
121
+ let queued = null;
122
+ const finishedTitles = [];
123
+ // A resolver turn is in flight from when its instruction is queued until the router and the
124
+ // board are both idle again.
125
+ let resolverInFlight = false;
126
+ let lastRaisedAt = Number.NEGATIVE_INFINITY;
127
+ let lastBusy = null;
128
+ let lastMergeCheckAt = now();
129
+ function busyNow() {
130
+ return !opts.boardIdle() || (opts.routerBusy?.() ?? false);
131
+ }
132
+ function refreshBusy() {
133
+ const busy = busyNow();
134
+ if (busy === lastBusy)
135
+ return;
136
+ try {
137
+ setDeckBusy(opts.deckDir, busy);
138
+ lastBusy = busy;
139
+ }
140
+ catch (err) {
141
+ console.error(`[git] could not update the busy note: ${String(err)}`);
142
+ }
143
+ }
144
+ function drain() {
145
+ if (running || !queued)
146
+ return;
147
+ const next = queued;
148
+ queued = null;
149
+ running = (async () => {
150
+ // Past this first await, `running` holds this promise: the finally below clears it
151
+ // even when the commit is skipped without waiting on anything.
152
+ await Promise.resolve();
153
+ let code = null;
154
+ try {
155
+ // Checked again at the last moment: a task may have started since this was queued,
156
+ // and its files are not committed half-done or merged into.
157
+ if (!opts.boardIdle()) {
158
+ finishedTitles.unshift(...next.titles);
159
+ return;
160
+ }
161
+ refreshBusy();
162
+ if (!(await cloudGitModeAsync(opts.deckDir, env)))
163
+ return;
164
+ code = await runCommit(next.reason, taskMessage(next.titles));
165
+ }
166
+ catch (err) {
167
+ console.error(`[git] commit --reason ${next.reason} failed: ${String(err)}`);
168
+ }
169
+ finally {
170
+ running = null;
171
+ checkConflict();
172
+ if (code === EXIT_CONFLICT)
173
+ reraiseUnresolvedMerge();
174
+ drain();
175
+ }
176
+ })();
177
+ }
178
+ // One commit at a time, and at most one waiting: a waiting one commits everything dirty
179
+ // when it runs, so a second request adds nothing but its message. A task commit's message
180
+ // wins over a turn's, since it names the work.
181
+ function request(reason, titles = []) {
182
+ if (queued && queued.reason === 'task' && reason === 'turn')
183
+ return;
184
+ if (queued)
185
+ titles = [...queued.titles, ...titles];
186
+ queued = { reason, titles };
187
+ drain();
188
+ }
189
+ function consumeMarker(rel) {
190
+ const file = path.join(opts.deckDir, rel);
191
+ let report;
192
+ try {
193
+ report = JSON.parse(fs.readFileSync(file, 'utf-8'));
194
+ }
195
+ catch (e) {
196
+ if (e.code !== 'ENOENT')
197
+ fs.rmSync(file, { force: true });
198
+ return;
199
+ }
200
+ // Consumed first, so a throw below can never turn one marker into a loop of turns.
201
+ fs.rmSync(file, { force: true });
202
+ if (typeof report.instruction !== 'string' || !report.instruction)
203
+ return;
204
+ opts.addLog(typeof report.notice === 'string' && report.notice ? report.notice : CONFLICT_NOTICE);
205
+ if (rel === CONFLICT_MARKER_FILE) {
206
+ resolverInFlight = true;
207
+ lastRaisedAt = now();
208
+ }
209
+ opts.enqueueInstruction(report.instruction);
210
+ }
211
+ function checkConflict() {
212
+ for (const rel of AGENT_MARKER_FILES)
213
+ consumeMarker(rel);
214
+ }
215
+ // A commit was refused because a merge still waits, and no resolver is working on it: ask
216
+ // again, at most every REASK_MS, so a merge an earlier turn left unresolved is not stuck.
217
+ function reraiseUnresolvedMerge() {
218
+ if (resolverInFlight || now() - lastRaisedAt < REASK_MS || !mergeInProgress(opts.deckDir))
219
+ return;
220
+ const state = readMergeState(opts.deckDir);
221
+ const leave = readLeavePending(opts.deckDir);
222
+ const instruction = [
223
+ '[Castle] The merge with changes from another computer is still not concluded, so no commit can land until it is.',
224
+ ...(leave
225
+ ? [
226
+ `The user left the deck at ${leave.at} with edits that could not be committed because of it${leave.paths.length ? ` (${leave.paths.slice(0, 20).join(', ')}${leave.paths.length > 20 ? ', ...' : ''})` : ''}. They are still on disk; concluding the merge commits them too, so keep them.`,
227
+ ]
228
+ : []),
229
+ state?.instruction ??
230
+ 'Spawn one task agent to remove every conflict marker (<<<<<<< / ||||||| / ======= / >>>>>>>) from the conflicted files, preferring the other computer\'s side, and finish with `castle-web commit --resolve -m "Merge changes from another computer"`. Never force-push.',
231
+ ].join('\n');
232
+ try {
233
+ const file = path.join(opts.deckDir, CONFLICT_MARKER_FILE);
234
+ fs.mkdirSync(path.dirname(file), { recursive: true });
235
+ fs.writeFileSync(file, JSON.stringify({
236
+ instruction,
237
+ notice: 'A merge with changes from another computer is still unresolved; the agent is taking another look.',
238
+ }));
239
+ }
240
+ catch (err) {
241
+ console.error(`[git] could not queue the unresolved merge again: ${String(err)}`);
242
+ return;
243
+ }
244
+ checkConflict();
245
+ }
246
+ // Even with no commit to be refused (an idle deck), a merge left unresolved is raised again.
247
+ function checkWaitingMerge() {
248
+ if (now() - lastMergeCheckAt < (opts.mergeCheckMs ?? MERGE_CHECK_MS))
249
+ return;
250
+ lastMergeCheckAt = now();
251
+ if (running || busyNow())
252
+ return;
253
+ try {
254
+ reraiseUnresolvedMerge();
255
+ }
256
+ catch (err) {
257
+ console.error(`[git] could not check for a waiting merge: ${String(err)}`);
258
+ }
259
+ }
260
+ const poll = setInterval(() => {
261
+ refreshBusy();
262
+ checkConflict();
263
+ checkWaitingMerge();
264
+ }, opts.pollMs ?? CONFLICT_POLL_MS);
265
+ poll.unref();
266
+ // A marker left while the serve was down. Not synchronously: the caller wires the router
267
+ // queue up after creating these hooks.
268
+ setImmediate(() => {
269
+ refreshBusy();
270
+ checkConflict();
271
+ });
272
+ return {
273
+ routerSettled() {
274
+ refreshBusy();
275
+ // Mid-task, the task hook commits when the board empties; the router never commits
276
+ // work a task agent is still doing.
277
+ if (!opts.boardIdle())
278
+ return;
279
+ // The router and the board both idle: whatever a resolver turn was going to do, it did.
280
+ resolverInFlight = false;
281
+ request('turn');
282
+ },
283
+ taskStarted() {
284
+ refreshBusy();
285
+ },
286
+ taskFinished(title, done) {
287
+ if (done && title)
288
+ finishedTitles.push(title);
289
+ // After the scheduler's sweep: a finished task can start (or block) the next one.
290
+ setImmediate(() => {
291
+ refreshBusy();
292
+ if (!opts.boardIdle())
293
+ return;
294
+ if (!opts.routerBusy?.())
295
+ resolverInFlight = false;
296
+ request('task', finishedTitles.splice(0));
297
+ });
298
+ },
299
+ checkConflict,
300
+ async idle() {
301
+ while (running || queued) {
302
+ if (running)
303
+ await running;
304
+ else
305
+ drain();
306
+ }
307
+ },
308
+ stop() {
309
+ clearInterval(poll);
310
+ try {
311
+ setDeckBusy(opts.deckDir, false);
312
+ }
313
+ catch {
314
+ /* best effort */
315
+ }
316
+ },
317
+ };
318
+ }
@@ -0,0 +1,2 @@
1
+ (function(){var e=class extends Error{code;constructor(e,t){super(`${e}: ${t}`),this.name=`CoverCaptureError`,this.code=e}};function t(t,n){throw new e(t,n)}function n(t){return t instanceof e?t.code:`CAPTURE_FAILED`}var r=Reflect.apply,i=Object.getOwnPropertyDescriptor,a=URL,o=String.prototype.trim,s=globalThis,c=s.fetch,l=(e,t)=>r(c,s,[e,t]);function u(e){return r(o,e,[])}function d(e,t){return i(e,t)?.get}var f=d(URL.prototype,`href`),p=d(URL.prototype,`protocol`),m=d(URL.prototype,`origin`);function h(e,t){return i(e,t)?.set}var g=h(URL.prototype,`hash`),ee=h(URL.prototype,`username`),te=h(URL.prototype,`password`),_=typeof SecurityPolicyViolationEvent==`function`?SecurityPolicyViolationEvent.prototype:null,v=_?{disposition:d(_,`disposition`),effectiveDirective:d(_,`effectiveDirective`),blockedURI:d(_,`blockedURI`)}:null;function y(e,t){return e?r(e,t,[]):void 0}function ne(e){return v?{disposition:y(v.disposition,e),effectiveDirective:y(v.effectiveDirective,e),blockedURI:y(v.blockedURI,e)}:null}function re(e,t){let n;try{n=new a(e,t)}catch{return null}let i=String(y(p,n)),o=String(y(m,n));return g&&r(g,n,[``]),ee&&r(ee,n,[``]),te&&r(te,n,[``]),{reported:String(y(f,n)),protocol:i,origin:o}}function ie(){return Object.create(null)}function ae(e){return typeof CanvasRenderingContext2D==`function`?e():[]}var b=[[Reflect,`apply`],[Function.prototype,`call`],[Object,`keys`],[JSON,`stringify`],[Set.prototype,`has`],[Set.prototype,`add`],[Map.prototype,`get`],[Map.prototype,`set`],[Map.prototype,`has`],[Map.prototype,`delete`],[WeakMap.prototype,`get`],[WeakMap.prototype,`set`],[WeakMap.prototype,`has`],[Array.prototype,`push`],[Array.prototype,`filter`],[Array.prototype,`some`],[Array.prototype,`every`],[Array.prototype,`map`],[Array.prototype,`join`],[Array.prototype,`includes`],[Array.prototype,`slice`],[Array.prototype,Symbol.iterator],[String.prototype,`slice`],[String.prototype,`indexOf`],[String.prototype,`includes`],[String.prototype,`startsWith`],[String.prototype,`endsWith`],[String.prototype,`toLowerCase`],[String.prototype,`split`],[String.prototype,`replace`],[RegExp.prototype,`test`],[RegExp.prototype,`exec`],[RegExp.prototype,Symbol.replace],[RegExp.prototype,Symbol.split],[s,`URL`],[URL.prototype,`href`],[URL.prototype,`origin`],[URL.prototype,`protocol`],[s,`getComputedStyle`],...ae(()=>[[CanvasRenderingContext2D.prototype,`drawImage`],[CanvasRenderingContext2D.prototype,`getImageData`],[CanvasRenderingContext2D.prototype,`putImageData`],[HTMLCanvasElement.prototype,`toDataURL`],[s,`XMLSerializer`],[XMLSerializer.prototype,`serializeToString`]])];function oe(e,t){let n=i(e,t);return n?n.get??n.value:void 0}var se=[];function ce(){for(let e=0;e<b.length;e++)se[e]=oe(...b[e])}function le(){for(let e=0;e<b.length;e++){let[n,r]=b[e];oe(n,r)!==se[e]&&t(`BUILTINS_MODIFIED`,`the page replaced a built-in the capture uses (${String(r)})`)}}var x=new WeakMap,S=new WeakMap,ue=new WeakMap,de=new WeakMap,fe=new WeakMap,pe=ie(),me=ie(),he=ie(),C={getContext:HTMLCanvasElement.prototype.getContext,requestAnimationFrame:window.requestAnimationFrame.bind(window),cancelAnimationFrame:window.cancelAnimationFrame.bind(window),getRandomValues:crypto.getRandomValues.bind(crypto),toBlob:HTMLCanvasElement.prototype.toBlob},ge=!1,w=!1,_e=1,T=new Map,ve=null,ye=0,be=new Set,xe=null,Se=!1;function Ce(e){Se=e}function we(){return ye}function Te(){return T.size>0}function Ee(e){xe=e}function De(){w=!0}function Oe(){w=!1;for(let e of T.values())e.pending&&(e.pending=!1,Ue(e))}function ke(e){e instanceof HTMLCanvasElement&&(S.set(e,(S.get(e)??0)+1),ue.set(e,{batch:ye,width:e.width,height:e.height}))}var Ae=e=>e.canvas,je=e=>de.get(e);function Me(e,t,n=Ae){if(!e)return;let r=e;for(let e of t){let t=r[e];typeof t==`function`&&(r[e]=function(){let e=Reflect.apply(t,this,arguments);return Se&&ke(n(this)),e})}}var Ne=[`drawArraysInstancedANGLE`,`drawElementsInstancedANGLE`,`multiDrawArraysWEBGL`,`multiDrawElementsWEBGL`,`multiDrawArraysInstancedWEBGL`,`multiDrawElementsInstancedWEBGL`,`drawArraysInstancedBaseInstanceWEBGL`,`drawElementsInstancedBaseVertexBaseInstanceWEBGL`,`multiDrawArraysInstancedBaseInstanceWEBGL`,`multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL`],Pe=new WeakSet;function Fe(e,t){if(!e||typeof e!=`object`||!(t instanceof HTMLCanvasElement))return;de.set(e,t);let n=Object.getPrototypeOf(e);!n||Pe.has(n)||(Pe.add(n),Me(n,Ne,je))}function Ie(e){if(!e||!Object.prototype.hasOwnProperty.call(e,`getExtension`))return;let t=e,n=t.getExtension;typeof n==`function`&&(t.getExtension=function(e){let t=Reflect.apply(n,this,[e]);return Fe(t,this.canvas),t})}function Le(e){return e===`2d`?`2d`:[`webgl`,`experimental-webgl`,`webgl2`].includes(e)?`webgl`:`unsupported`}function Re(){let e=C.getContext,t=function(t,...n){let r=Reflect.apply(e,this,[t,...n]);if(r){let e=String(t).toLowerCase();x.set(this,{kind:Le(e),context:r,requestedType:e})}return r};HTMLCanvasElement.prototype.getContext=t,Me(window.CanvasRenderingContext2D?.prototype,[`clearRect`,`drawImage`,`fill`,`fillRect`,`fillText`,`putImageData`,`stroke`,`strokeRect`,`strokeText`]);let n=[`blitFramebuffer`,`clear`,`clearBufferfi`,`clearBufferfv`,`clearBufferiv`,`clearBufferuiv`,`drawArrays`,`drawArraysInstanced`,`drawElements`,`drawElementsInstanced`,`drawRangeElements`];Me(window.WebGLRenderingContext?.prototype,n),Me(window.WebGL2RenderingContext?.prototype,n),Ie(window.WebGLRenderingContext?.prototype),Ie(window.WebGL2RenderingContext?.prototype)}function ze(){typeof window.FontFace==`function`&&(window.FontFace=new Proxy(window.FontFace,{construct(e,t,n){let r=Reflect.construct(e,t,n),[i,a,o]=t;return fe.set(r,{family:String(i),source:a,descriptors:{...o??{}},baseUrl:document.baseURI}),r}}))}function Be(e){ve=e,ye++,be=new Set;for(let e of T.values())e.nativeId!==null&&be.add(e.id)}function Ve(){let e=0;for(let t of be)typeof T.get(t)?.nativeId==`number`&&e++;return e}function He(e,t){if(T.has(e.id)){if(t!==ve&&Be(t),e.nativeId=null,be.delete(e.id),w){e.pending=!0;return}T.delete(e.id);try{e.callback(t)}finally{Ve()===0&&xe?.()}}}function Ue(e){e.nativeId=C.requestAnimationFrame(t=>He(e,t))}function We(){window.requestAnimationFrame=e=>{if(typeof e!=`function`)throw TypeError(`requestAnimationFrame callback must be a function`);let t={id:_e++,callback:e,nativeId:null,pending:!1};return T.set(t.id,t),w?t.pending=!0:Ue(t),t.id},window.cancelAnimationFrame=e=>{let t=T.get(e);t&&(T.delete(e),t.nativeId!==null&&C.cancelAnimationFrame(t.nativeId))}}function Ge(){ge||(ge=!0,Re(),ze(),We(),qe(),Ke())}function Ke(){if(typeof PerformanceObserver!=`function`)return;let e=new PerformanceObserver(e=>{for(let t of e.getEntries()){if(!(t instanceof PerformanceResourceTiming)||t.responseEnd<=0)continue;let e=re(t.name,document.baseURI);e&&(he[e.reported]=!0)}});try{e.observe({type:`resource`,buffered:!0})}catch{}}function qe(){window.addEventListener(`securitypolicyviolation`,e=>{if(!e.isTrusted)return;let t=ne(e);!t||t.disposition!==`enforce`||typeof t.blockedURI!=`string`||!t.blockedURI||(t.effectiveDirective===`font-src`&&(pe[t.blockedURI]=!0),t.effectiveDirective===`img-src`&&(me[t.blockedURI]=!0))},!0)}function Je(e,n,r){let i=document.createElement(`canvas`);i.width=e,i.height=n;let a=Reflect.apply(C.getContext,i,[`2d`,{willReadFrequently:!0}]);return a||t(`RASTERIZE_FAILED`,`no 2D context for ${r}`),{canvas:i,context:a}}var Ye=new Set([`SCRIPT`,`NOSCRIPT`,`IFRAME`,`FRAME`,`OBJECT`,`EMBED`,`APPLET`,`VIDEO`,`AUDIO`,`SOURCE`,`TRACK`,`LINK`,`META`,`BASE`,`MATH`,`PORTAL`]),E=`http://www.w3.org/1999/xhtml`,Xe=`http://www.w3.org/2000/svg`,Ze=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`]),Qe=[`color`,`fill`,`flood-color`,`lighting-color`,`stop-color`,`stroke`],$e=/^\s*#[0-9a-f]{3}(?:[0-9a-f](?:[0-9a-f]{2}){0,2})?\s*$/i,et=[`checkbox`,`radio`,`button`,`submit`,`reset`];function tt(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)r+=e[r]===`\\`?2:1;return r+1}function nt(e,t){let n=t;for(;/\s/.test(e[n]??``);)n++;return n}function rt(e,t){let n=nt(e,t+4),r;if(e[n]===`"`||e[n]===`'`){let t=tt(e,n);if(r=e.slice(n+1,t-1),n=nt(e,t),e[n]!==`)`)return null}else{let t=e.indexOf(`)`,n);if(t<0)return null;r=e.slice(n,t),n=t}return{start:t,end:n+1,url:u(r)}}function it(e,t){return/^url\(/i.test(e.slice(t,t+4))&&!/[\w-]/.test(e[t-1]??``)}function D(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`\\`)n+=2;else if(r===`"`||r===`'`)n=tt(e,n);else if(it(e,n)){let r=rt(e,n);if(!r)return t;t.push(r),n=r.end}else n++}return t}function at(e){return D(e).map(e=>e.url)}function ot(e,t){let n=``,r=0;for(let[i,a]of t)n+=e.slice(r,i.start)+a,r=i.end;return n+e.slice(r)}function st(e){let t=[],n=0,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){i+=2;continue}if(a===`"`||a===`'`){i=tt(e,i);continue}a===`(`?n++:a===`)`?n=Math.max(0,n-1):a===`,`&&n===0&&(t.push(u(e.slice(r,i))),r=i+1),i++}return t.push(u(e.slice(r))),t.filter(Boolean)}function ct(e){let n=[],r=``,i=null,a=!1,o=()=>{let e=a?r:u(r).replace(/\s+/g,` `);e&&n.push(e.toLowerCase()),r=``,a=!1};for(let n=0;n<e.length;n++){let s=e[n];s===`\\`&&n+1<e.length?r+=e[++n]:i?s===i?i=null:r+=s:s===`"`||s===`'`?(i=s,a=!0,r=``):s===`,`?o():a?u(s)&&t(`UNSUPPORTED_FONT`,`font-family ${e} has text after a quoted name`):r+=s}return i&&t(`UNSUPPORTED_FONT`,`font-family ${e} has an unterminated quote`),o(),n}function O(e){let t=u(e),n=t[0];return t.length>=2&&(n===`"`||n===`'`)&&t.endsWith(n)?t.slice(1,-1).replace(/\\(.)/g,`$1`).toLowerCase():t.replace(/\s+/g,` `).toLowerCase()}function k(e){if(!e||e===`none`||e===`normal`)return null;if(/^url\(/i.test(e)&&t(`UNSUPPORTED_PSEUDO_RESOURCE`,`pseudo-element image content is not supported`),e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)||t(`UNSUPPORTED_PSEUDO_CONTENT`,`cannot freeze pseudo-element content ${e}`),e.startsWith(`"`))try{return JSON.parse(e)}catch{}return e.slice(1,-1).replace(/\\(['"\\])/g,`$1`)}function lt(e,t){if(t.display===`none`||t.visibility===`hidden`)return!1;for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&u(t.textContent??``))return!0;return e instanceof HTMLInputElement&&[`button`,`submit`,`reset`].includes(e.type)&&!!e.value}function A(e){let t=[],n=r=>{if(!(r!==e&&getComputedStyle(r).display===`none`)){t.push(r);for(let e of r.children)n(e)}};return n(e),t}function ut(e,n){Ze.has(e.localName)||t(`UNSUPPORTED_SVG_ELEMENT`,`${n} contains <${e.localName}>`);for(let r of e.attributes){/^on/i.test(r.name)&&t(`UNSUPPORTED_EVENT_HANDLER`,`${n} contains ${r.name}`);let e=Qe.includes(r.localName)&&$e.test(r.value);(/(?:^|:)href$/i.test(r.name)||/url\s*\(/i.test(r.value)||/^\s*#/.test(r.value)&&!e)&&t(`UNSUPPORTED_SVG_REFERENCE`,`${n} contains resource/reference attribute ${r.name}`)}}function dt(e){if(!(e instanceof HTMLElement))return!1;let t=getComputedStyle(e);if([`inline`,`contents`,`none`].includes(t.display))return!1;let n=e=>e===`auto`||e===`scroll`;if(!n(t.overflowX)&&!n(t.overflowY))return!1;let r=e=>Number.parseFloat(e)||0,i=e.offsetWidth-e.clientWidth-r(t.borderLeftWidth)-r(t.borderRightWidth),a=e.offsetHeight-e.clientHeight-r(t.borderTopWidth)-r(t.borderBottomWidth);return i>.5||a>.5}function ft(e){let t=getComputedStyle(e);if(![`block`,`flow-root`,`list-item`].includes(t.display))return`its display is ${t.display}`;if(t.writingMode!==`horizontal-tb`)return`its writing mode is ${t.writingMode}`;if(t.columnCount!==`auto`||t.columnWidth!==`auto`)return`it lays its content out in columns`;if(t.direction!==`ltr`)return`it lays out right to left`;for(let t of A(e)){if(t===e)continue;let n=getComputedStyle(t).position;if(n===`sticky`)return`it holds a sticky element`;if(n===`fixed`)return`it holds a fixed element`;if(n===`absolute`&&t instanceof HTMLElement){let n=t.offsetParent;if(!n||n===e||!e.contains(n))return`it holds an element positioned against it`}}return null}var pt=[`font-family`,`font-size`,`font-weight`,`font-style`,`font-variant`,`font-stretch`,`letter-spacing`,`word-spacing`,`line-height`,`text-transform`,`text-shadow`,`color`],mt=[[`background-color`,`rgba(0, 0, 0, 0)`],[`background-image`,`none`],[`text-decoration-line`,`none`],[`float`,`none`],[`vertical-align`,`baseline`]];function ht(e){let t=getComputedStyle(e);for(let n of[`::first-letter`,`::first-line`]){let r=getComputedStyle(e,n);for(let e of pt)if(r.getPropertyValue(e)!==t.getPropertyValue(e))return n;for(let[e,t]of mt)if(r.getPropertyValue(e)!==t)return n}return null}function gt(e){for(let n=M(e);n;n=M(n)){let e=ht(n);e&&t(`UNSUPPORTED_PSEUDO_STYLE`,`<${n.tagName.toLowerCase()}> around the card styles its ${e}`)}}var _t=[`font-family`,`font-size`,`font-weight`,`font-style`,`font-stretch`,`letter-spacing`,`text-shadow`,`color`];function vt(e){let t=getComputedStyle(e),n=getComputedStyle(e,`::marker`);return n.content===`normal`?_t.some(e=>n.getPropertyValue(e)!==t.getPropertyValue(e)):!0}var yt={disc:`•`,circle:`◦`,square:`▪`,decimal:`0123456789.`,"decimal-leading-zero":`0123456789.`,"lower-alpha":`abcdefghijklmnopqrstuvwxyz.`,"lower-latin":`abcdefghijklmnopqrstuvwxyz.`,"upper-alpha":`ABCDEFGHIJKLMNOPQRSTUVWXYZ.`,"upper-latin":`ABCDEFGHIJKLMNOPQRSTUVWXYZ.`,"lower-roman":`ivxlcdm.`,"upper-roman":`IVXLCDM.`,"disclosure-open":`▾`,"disclosure-closed":`▸`};function bt(e,t){if(!t.display.includes(`list-item`)||t.listStyleImage!==`none`)return null;let n=t.listStyleType;return n===`none`?null:n.startsWith(`"`)||n.startsWith(`'`)?k(n):yt[n]}function xt(e){let n=t=>{try{let n=document.createRange();return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n.intersectsNode(e)}catch{return!0}},r=document.getSelection();if(r&&!r.isCollapsed)for(let e=0;e<r.rangeCount;e++)n(r.getRangeAt(e))&&t(`CARD_TEXT_SELECTED`,`text on the card is selected`);let i=CSS.highlights;if(i)for(let e of i.values())for(let r of e)n(r)&&t(`UNSUPPORTED_HIGHLIGHT`,`a CSS highlight covers text on the card`)}var St=[`rgb(239, 239, 239)`,`rgb(107, 107, 107)`,`rgba(239, 239, 239, 0.3)`,`rgba(19, 1, 1, 0.3)`];function Ct(e,t){return t.appearance===`none`?!1:e instanceof HTMLProgressElement||e instanceof HTMLMeterElement?!0:e instanceof HTMLButtonElement||e instanceof HTMLInputElement&&[`button`,`submit`,`reset`].includes(e.type)?St.includes(t.backgroundColor)&&t.backgroundImage===`none`&&[`Top`,`Right`,`Bottom`,`Left`].every(e=>t.getPropertyValue(`border-${e.toLowerCase()}-style`)===`outset`&&t.getPropertyValue(`border-${e.toLowerCase()}-width`)===`2px`):!1}function wt(e){for(let t of[`:modal`,`:popover-open`])try{if(e.matches(t))return!0}catch{}return!1}var Tt=[[`filter`,`none`],[`backdrop-filter`,`none`],[`mix-blend-mode`,`normal`],[`mask-image`,`none`],[`-webkit-mask-image`,`none`],[`clip-path`,`none`]],Et=new Map;function Dt(){Et.clear()}function Ot(e,t){let n=new CSSStyleSheet;try{n.replaceSync(t),Et.set(e,n)}catch{}}var kt=new Set([`block`,`inline`,`inline-block`,`flow-root`,`inline-flow-root`,`flex`,`inline-flex`,`grid`,`inline-grid`,`table`,`inline-table`,`list-item`,`contents`,`none`,`-webkit-box`,`-webkit-inline-box`]);function At(e,t){let n=u(t).replace(/\s*!important$/i,``);kt.has(n)?e.values.add(n):e.unknown=!0}function jt(e,t){try{return e.matches(t)}catch{return null}}function j(e,t,n,r){for(let i of e){if(n.unknown)return;let e=i.constructor.name;if(e!==`CSSStartingStyleRule`){if(i instanceof CSSMediaRule){matchMedia(i.media.mediaText).matches&&j(i.cssRules,t,n,r);continue}if(i instanceof CSSSupportsRule){CSS.supports(i.conditionText)&&j(i.cssRules,t,n,r);continue}if(i instanceof CSSImportRule){(!i.media.mediaText||matchMedia(i.media.mediaText).matches)&&Nt(i.styleSheet,t,n,r+1);continue}if(e===`CSSNestedDeclarations`){i.style.getPropertyValue(`display`)&&(n.unknown=!0);continue}if(i instanceof CSSStyleRule){let e=i.style.getPropertyValue(`display`),r=i.cssRules.length>0;if(e){let r=jt(t,i.selectorText);r===null?n.unknown=!0:r&&At(n,e)}r&&Mt(i.cssRules)&&(n.unknown=!0);continue}if(e===`CSSContainerRule`||e===`CSSScopeRule`){Mt(i.cssRules)&&(n.unknown=!0);continue}`cssRules`in i&&j(i.cssRules,t,n,r)}}}function Mt(e){for(let t of e)if(t.style?.getPropertyValue(`display`)||`cssRules`in t&&Mt(t.cssRules))return!0;return!1}function Nt(e,t,n,r){if(!e||r>16){n.unknown=!0;return}if(e.disabled||e.media.mediaText&&!matchMedia(e.media.mediaText).matches)return;let i;try{i=e.cssRules}catch{let t=e.href?Et.get(e.href):void 0;if(!t){n.unknown=!0;return}i=t.cssRules}j(i,t,n,r)}function Pt(e){for(let t of e.getAnimations()){let e=t.effect;if(e instanceof KeyframeEffect&&e.getKeyframes().some(e=>`display`in e))return!0}return!1}function Ft(e){let t={values:new Set,unknown:!1},n=e instanceof HTMLElement?e.style.getPropertyValue(`display`):``;n&&At(t,n),Pt(e)&&(t.unknown=!0);let r=e.getRootNode(),i=[...document.styleSheets,...document.adoptedStyleSheets??[],...r instanceof ShadowRoot?[...r.styleSheets,...r.adoptedStyleSheets]:[]];for(let n of i)Nt(n,e,t,0);return t}var It=[`-webkit-box`,`-webkit-inline-box`];function Lt(e,n){let r=Number.parseInt(n.getPropertyValue(`-webkit-line-clamp`),10);if(!Number.isFinite(r)||n.getPropertyValue(`-webkit-box-orient`)!==`vertical`)return null;let i=[`inline-block`,`inline-flow-root`,`-webkit-inline-box`].includes(n.display);if(!i&&![`flow-root`,`-webkit-box`].includes(n.display))return null;let a=Ft(e),o=[...a.values],s=o.filter(e=>It.includes(e));return!a.unknown&&s.length===0?null:!a.unknown&&s.length===o.length?i?`-webkit-inline-box`:`-webkit-box`:t(`UNSUPPORTED_LINE_CLAMP`,`a line clamp on a box whose display is not plainly readable from the page's CSS`)}function Rt(e){for(let n of[`::before`,`::after`]){let r=getComputedStyle(e,n);r.content===`none`||r.content===`normal`||r.getPropertyValue(`-webkit-line-clamp`)!==`none`&&r.getPropertyValue(`-webkit-box-orient`)===`vertical`&&[`flow-root`,`inline-block`,`inline-flow-root`,`-webkit-box`,`-webkit-inline-box`].includes(r.display)&&t(`UNSUPPORTED_LINE_CLAMP`,`a line clamp on ${n} content`)}}function M(e){if(e.assignedSlot)return e.assignedSlot;if(e.parentElement)return e.parentElement;let t=e.parentNode;return t instanceof ShadowRoot?t.host:null}function zt(e){for(let n=M(e);n;n=M(n)){let e=getComputedStyle(n),r=`<${n.tagName.toLowerCase()}> around the card`;Number.parseFloat(e.opacity)<.999&&t(`UNSUPPORTED_ANCESTOR_EFFECT`,`${r} has opacity ${e.opacity}`);for(let[n,i]of Tt){let a=e.getPropertyValue(n);a&&a!==i&&t(`UNSUPPORTED_ANCESTOR_EFFECT`,`${r} has ${n}: ${a}`)}}}function Bt(e){return e.transform!==`none`||e.translate!==`none`||e.rotate!==`none`||e.scale!==`none`||e.transformStyle===`preserve-3d`||e.perspective!==`none`||e.contentVisibility!==``&&e.contentVisibility!==`visible`||e.containerType!==``&&e.containerType!==`normal`||e.filter!==`none`||e.getPropertyValue(`backdrop-filter`)!==`none`||/\b(?:paint|layout|strict|content)\b/.test(e.contain)||/\b(?:transform|perspective|filter)\b/.test(e.willChange)}function Vt(e,n){let r=e.getBoundingClientRect();if(!(Math.abs(r.left)<.5&&Math.abs(r.top)<.5&&Math.abs(r.width-window.innerWidth)<.5&&Math.abs(r.height-window.innerHeight)<.5))for(let r of n){if(r===e||getComputedStyle(r).position!==`fixed`)continue;let n=!1;for(let t=M(r);t&&!n&&(n=Bt(getComputedStyle(t)),t!==e);t=M(t));n||t(`UNSUPPORTED_FIXED_POSITION`,`a position:fixed element on the card is placed against the page, not the card`)}}function Ht(e,n){if(e.namespaceURI===`http://www.w3.org/2000/svg`){ut(e,n);return}if(e.namespaceURI!==`http://www.w3.org/1999/xhtml`&&t(`UNSUPPORTED_NAMESPACE`,`${n} uses unsupported namespace ${e.namespaceURI??`(none)`}`),Ye.has(e.tagName)&&t(`UNSUPPORTED_ELEMENT`,`${n} contains <${e.tagName.toLowerCase()}>`),e.shadowRoot&&t(`UNSUPPORTED_SHADOW_ROOT`,`${n} has a shadow root`),dt(e)&&t(`UNSUPPORTED_SCROLLBARS`,`${n} shows scrollbars that take up room`),e.scrollTop||e.scrollLeft){let r=ft(e);r&&t(`UNSUPPORTED_SCROLL_LAYOUT`,`${n} is scrolled and ${r}`)}e.hasAttribute(`srcset`)&&t(`UNSUPPORTED_RESOURCE`,`${n} has srcset`),Ct(e,getComputedStyle(e))&&t(`UNSUPPORTED_NATIVE_CONTROL`,`${n} is a native control drawn by the platform theme`),Lt(e,getComputedStyle(e)),Rt(e),wt(e)&&t(`UNSUPPORTED_TOP_LAYER`,`${n} is in the top layer (a modal or popover)`);let r=ht(e);if(r&&t(`UNSUPPORTED_PSEUDO_STYLE`,`${n} styles its ${r} differently`),getComputedStyle(e).display.includes(`list-item`)&&vt(e)&&t(`UNSUPPORTED_PSEUDO_STYLE`,`${n} styles its ::marker differently`),e instanceof HTMLInputElement){let r=e.type.toLowerCase();r===`password`&&t(`SENSITIVE_FORM_CONTROL`,`${n} is a password input`),et.includes(r)||t(`UNSUPPORTED_FORM_VALUE`,`${n} has a stateful ${r} value`)}(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&t(`UNSUPPORTED_FORM_VALUE`,`${n} contains a stateful form value`)}var Ut=200,Wt=24,Gt=[[`ultra-condensed`,50],[`extra-condensed`,62.5],[`condensed`,75],[`semi-condensed`,87.5],[`normal`,100],[`semi-expanded`,112.5],[`expanded`,125],[`extra-expanded`,150],[`ultra-expanded`,200]];function Kt(e){let t=Number.parseFloat(e);if(!Number.isFinite(t))return Gt.some(([t])=>t===e)?e:`normal`;let n=Gt[0];for(let e of Gt)Math.abs(e[1]-t)<Math.abs(n[1]-t)&&(n=e);return n[0]}function qt(e){let t=[];for(let n of e.split(`,`)){let e=u(n).replace(/^u\+/i,``);if(!e)continue;let[r,i]=e.includes(`?`)?[e.replace(/\?/g,`0`),e.replace(/\?/g,`F`)]:e.split(`-`),a=Number.parseInt(r,16),o=Number.parseInt(i??r,16);Number.isFinite(a)&&Number.isFinite(o)&&t.push([a,o])}return t}function Jt(e,t){return t.some(([t,n])=>e>=t&&e<=n)}function Yt(e,t,n){let r=n||void 0;return/\buppercase\b/.test(t)?e=e.toLocaleUpperCase(r):/\blowercase\b/.test(t)?e=e.toLocaleLowerCase(r):/\bcapitalize\b/.test(t)&&(e=e.replace(/(^|[\s\p{P}])(\p{L})/gu,(e,t,n)=>t+n.toLocaleUpperCase(r))),/\bfull-width\b/.test(t)&&(e=[...e].map(e=>{let t=e.codePointAt(0)??0;return t===32?` `:t>=33&&t<=126?String.fromCodePoint(t+65248):e}).join(``)),e}function N(e,t,n){let r=e.closest(`[lang]`)?.getAttribute(`lang`)??document.documentElement.lang;return{families:ct(t.fontFamily),weight:t.fontWeight,style:t.fontStyle,stretch:Kt(t.fontStretch),text:Yt(n,t.textTransform,r)}}var Xt=[];function Zt(e){let t=[];Xt=[];for(let n of A(e)){let e=getComputedStyle(n),r=``;for(let e of n.childNodes)e.nodeType===Node.TEXT_NODE&&(r+=e.textContent??``);n instanceof HTMLInputElement&&[`button`,`submit`,`reset`].includes(n.type)&&(r+=n.value),u(r)&&t.push(N(n,e,r));let i=bt(n,e);i===void 0?Xt.push(N(n,e,``)):i&&u(i)&&t.push(N(n,e,i));for(let e of[`::before`,`::after`]){let r=getComputedStyle(n,e);if(r.display===`none`)continue;let i=k(r.content);i&&u(i)&&t.push(N(n,r,i))}}return t}function Qt(e){let n=new Map,r=0;for(let t of document.fonts){if(t.status!==`loaded`)continue;let i=O(t.family);if(!e.has(i))continue;let a=n.get(i)??[];a.push({ranges:qt(t.unicodeRange),index:r++}),n.set(i,a)}return r>Ut&&t(`TOO_MANY_FONT_FACES`,`the card's fonts have ${r} loaded faces`),n}function $t(){let e=new Set;for(let t of document.fonts)e.add(O(t.family));return e}var en=/\p{M}/gu;function tn(e){return e===65038||e===65039||e===8419||e===8205||e>=127995&&e<=127999||e>=917536&&e<=917631||e>=127462&&e<=127487}function nn(e){return[...e].some(e=>tn(e.codePointAt(0)??0))?e:e.replace(en,``)}var rn=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`emoji`,`math`,`fangsong`]),an=new Map;function on(e,t,n){let r=e.length?e.map(e=>rn.has(e)?e:JSON.stringify(e)).join(`, `):`serif`,i=`${r}|${t.weight}|${t.style}|${n}`,a=an.get(i);if(a)return a;let{canvas:o,context:s}=Je(96,48,`a glyph test`);s.font=`${t.style} ${t.weight} 24px ${r}`,s.fillStyle=`#000`,s.fillText(n,8,32);let c=s.getImageData(0,0,96,48).data;return o.width=0,o.height=0,an.set(i,c),c}function sn(e,t,n,r){let i=on(e.slice(t),n,r),a=on(e.slice(t+1),n,r);for(let e=0;e<i.length;e++)if(i[e]!==a[e])return!0;return!1}function cn(e){return[...new Intl.Segmenter(void 0,{granularity:`grapheme`}).segment(e)].map(e=>e.segment)}var P=null;function ln(e,t){return P??=Reflect.apply(C.getContext,document.createElement(`canvas`),[`2d`]),P?(P.font=un(e,20,!0),P.fontStretch=e.stretch,P.measureText(t).width):t.length*20}function un(e,t,n){let r=n?`${JSON.stringify(e.family)}, serif`:`serif`;return`${e.style} ${e.weight} ${t}px ${r}`}function dn(e,t){let n=``,r=0;for(let i of e.clusters.keys()){if(n&&(r>=Wt||ln(e.sample,n+i)>t))break;n+=i,r++}return n}var fn=/^[a-z0-9.%+\s-]+$/i;function pn(e,n,r=e.getBoundingClientRect().width-16){if(!n.length||!document.fonts)return[];let i=Qt(new Set(n)),a=$t(),o=new Map;for(let n of Zt(e))for(let e of cn(n.text)){let r=nn(e);if(!u(r))continue;let s=r.codePointAt(0)??0;for(let[e,c]of n.families.entries()){if(!sn(n.families,e,n,r))continue;if(rn.has(c))break;let l=i.get(c)?.find(e=>Jt(s,e.ranges));if(l){let e={family:c,weight:n.weight,style:n.style,stretch:n.stretch};[e.weight,e.style,e.stretch].every(e=>fn.test(e))||t(`UNSUPPORTED_FONT_DESCRIPTOR`,`text in ${c} has an unusual font setting`);let i=JSON.stringify([e,l.index]),a=o.get(i)??{sample:e,clusters:new Map};a.clusters.has(r)||a.clusters.set(r,l.index),o.set(i,a);break}if(!a.has(c))break}}for(let e of Xt)e.families.some(e=>i.has(e))&&t(`UNSUPPORTED_MARKER`,`a list marker in ${e.families.join(`, `)} has a type the check cannot sample`);let s=[];for(let e of o.values())s.push({...e.sample,text:dn(e,Math.max(40,r)),faces:1});return s.length>120&&t(`TOO_MANY_FONT_STYLES`,`the card's text uses ${s.length} face and style combinations; 120 can be checked`),s}var mn=24,hn=new Map;function gn(e,n,r){let i=un(e,20,r),a=document.createElement(`canvas`),o=Reflect.apply(C.getContext,a,[`2d`]);o||t(`RASTERIZE_FAILED`,`no 2D context for a font sample`),o.font=i,o.fontStretch=e.stretch;let s=o.measureText(e.text),c=60+Math.max(s.width,s.actualBoundingBoxRight+s.actualBoundingBoxLeft),l=Math.ceil(c*n),u=Math.ceil(60*n),{canvas:d,context:f}=Je(l,u,`a font sample`);f.scale(n,n),f.font=i,f.fontStretch=e.stretch,f.fillStyle=`#000`,f.fillText(e.text,20,40);let p=f.getImageData(0,0,l,u).data;d.width=0,d.height=0;let m=new Uint8ClampedArray(l*u),h=null,g=null;for(let e=0;e<m.length;e++){if(m[e]=p[e*4+3],m[e]<=mn)continue;let t=e%l;(h===null||t<h)&&(h=t),(g===null||t>g)&&(g=t)}let ee=20*n;return{alpha:m,left:h===null?null:h-ee,right:g===null?null:g+1-ee}}function _n(e,t){let n=`${t}|${JSON.stringify(e)}`,r=hn.get(n);if(r)return r;let i=gn(e,t,!0),a=gn(e,t,!1),o=0;for(let e=0;e<i.alpha.length;e++)i.alpha[e]>mn!=a.alpha[e]>mn&&o++;let s={distinct:o>=6*t,left:i.left,right:i.right};return hn.set(n,s),s}var vn=`#00ff00`,F=28,yn=8,I=2*F,L=8,R=10,bn=24,xn=.25,Sn=.9;function Cn(e){return`rgb(255, ${wn(e)}, 255)`}function wn(e){return e*10}var Tn=48,En=4,Dn=4;function On(e){return Math.max(4,Math.min(20,Math.floor(e-2*En)))}function kn(e){return 2*On(e)+Dn+8}var An=[[255,0,0],[0,0,255],[255,255,0],[255,0,255]],z=null;function jn(){if(z)return z;let e=document.createElement(`canvas`);e.width=2,e.height=2;let n=Reflect.apply(C.getContext,e,[`2d`]);n||t(`RASTERIZE_FAILED`,`no 2D context for the check image`);let r=new ImageData(2,2);return An.forEach((e,t)=>r.data.set([...e,255],t*4)),n.putImageData(r,0,0),z=e.toDataURL(`image/png`),e.width=0,e.height=0,z}function B(e,t,n){return L*2+e.length*I+t.length*Tn+kn(n)}function Mn(e,t){return L+e.length*I+t.length*Tn+4}var Nn=[`img`,`background-image`];function Pn(e,t,n){let r=On(n);return{left:En,top:t+e*(r+Dn),size:r}}function Fn(e,t,n,r){let i=jn();return Nn.map((a,o)=>{let s=Pn(o,n,r),c=e.createElementNS(t,a===`img`?`img`:`div`),l=`position:absolute;margin:0;left:${s.left}px;top:${s.top}px;width:${s.size}px;height:${s.size}px;image-rendering:pixelated`;return a===`img`?(c.setAttribute(`src`,i),c.setAttribute(`alt`,``),c.setAttribute(`style`,`${l};display:block`)):c.setAttribute(`style`,`${l};background-image:url("${i}");background-size:100% 100%`),c})}function In(e,t,n,r){for(let[i,a]of Nn.entries()){let o=Pn(i,t,r);for(let[t,r]of An.entries()){let i=o.left+o.size*(t%2?3:1)/4,s=o.top+o.size*(t<2?1:3)/4,c=W(e,Math.floor(i*n),Math.floor(s*n));if(r.some((t,n)=>Math.abs(e.data[c+n]-t)>40))return`image: the strip's data: ${a} was not painted`}}return null}function Ln(e,t){return L+e.length*I+t*Tn}var V={left:30,width:40,top:14,height:20},Rn={"box-shadow":`background:#000;box-shadow:0 0 8px #000`,"drop-shadow":`background:#000;filter:drop-shadow(0 0 8px #000)`,"filter-blur":`background:#000;filter:blur(4px)`,"text-shadow":`font:20px/20px monospace;color:#000;text-shadow:0 0 6px #000;text-align:center;white-space:pre;overflow:visible`,"backdrop-blur":`background:transparent;backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)`};function zn(e,t,n,r){let i=(n,i)=>{let a=e.createElementNS(t,`div`);return a.setAttribute(`style`,`position:absolute;margin:0;padding:0;box-sizing:border-box;left:${i.left}px;top:${r+i.top}px;width:${i.width}px;height:${i.height}px;${n}`),a},a=i(Rn[n],V);return n===`text-shadow`&&(a.textContent=`██`),n===`backdrop-blur`?[i(`background:#000`,{left:10,top:4,width:40,height:40}),a]:[a]}function Bn(e,t,n,r,i){let a=e.createElementNS(t,`div`);return a.setAttribute(`style`,`position:relative;margin:0;width:${n}px;height:${B(r,i,n)}px;overflow:hidden;background:${vn}`),i.forEach((n,i)=>a.append(...zn(e,t,n,Ln(r,i)))),a.append(...Fn(e,t,Mn(r,i),n)),r.forEach((r,i)=>{let o=`${JSON.stringify(r.family)}, serif`;for(let[s,c]of[[0,o],[1,`serif`]]){let l=e.createElementNS(t,`div`),u=L+i*I+s*F;l.setAttribute(`style`,`position:absolute;left:0;top:${u}px;width:${n}px;height:${F}px;padding:0 0 0 ${yn}px;box-sizing:border-box;font:20px/${F}px ${o};font-weight:${r.weight};font-style:${r.style};font-stretch:${r.stretch};color:#000;white-space:pre;overflow:hidden`);let d=e.createElementNS(t,`span`);d.setAttribute(`style`,`font-family:${c}`),d.textContent=r.text,l.append(d),a.append(l)}}),a}function H(e){e.width=0,e.height=0}function U(e){let t=Vn(e);return H(e),t}function Vn(e){let n=Reflect.apply(C.getContext,e,[`2d`]);n||t(`RASTERIZE_FAILED`,`no 2D context`);try{return n.getImageData(0,0,e.width,e.height)}catch(e){throw e instanceof DOMException&&e.name===`SecurityError`&&t(`RASTERIZE_BLOCKED`,`the browser tainted the rasterized capture`),e}}function W(e,t,n){let r=Math.min(e.width-1,Math.max(0,t));return(Math.min(e.height-1,Math.max(0,n))*e.width+r)*4}function Hn(e,t,n){let r=W(e,t,n);return e.data[r+1]>200&&e.data[r]<60&&e.data[r+2]<60&&e.data[r+3]>200}function Un(e,t,n,r,i){let a=[];for(let o=n;o<n+i;o++)for(let n=t;n<t+r;n++)a.push(!Hn(e,n,o));return a}function Wn(e,t,n,r){let i=e=>{let t=n,i=r;for(let r=0;r<e.length;r++)e[r]&&(t=Math.min(t,r%n),i=Math.min(i,Math.floor(r/n)));return[t,i]},[a,o]=i(e),[s,c]=i(t),l=(e,t,i)=>t>=0&&i>=0&&t<n&&i<r&&e[i*n+t],u=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++)l(e,r+a,i+o)!==l(t,r+s,i+c)&&u++;return u}function Gn(e,t,n,r,i,a){if(i.left===null||i.right===null)return null;let o=-1,s=-1;for(let n=0;n<e.length;n++){if(!e[n])continue;let r=n%t;(o<0||r<o)&&(o=r),r>s&&(s=r)}if(o<0)return null;let c=yn*r+i.left,l=Math.min(yn*r+i.right,n*r),u=Math.max(2*r,.03*(l-c));return Math.abs(o-c)>u||Math.abs(s+1-l)>u?`font: ${a.family} ${a.weight} spans ${o}-${s+1}, the page ${Math.round(c)}-${Math.round(l)}`:null}function Kn(e,t,n,r,i,a=[],o=!1,s=_n){let c=n,l=n+B(i,a,t),u=[[3,c+3],[t-3,c+3],[3,l-3],[t-3,l-3]];for(let[t,n]of u)if(!Hn(e,Math.floor(t*r),Math.floor(n*r)))return`geometry: the strip is not where a ${r}x drawing puts it (${t},${n})`;for(let[n,a]of i.entries()){let i=Math.round((c+L+n*I)*r),o=Math.floor(F*r),l=Math.floor(t*r),u=Un(e,0,i,l,o),d=Un(e,0,i+o,l,o),f=u.filter(Boolean).length;if(f<4)return`font: nothing painted in ${a.family}`;if(s(a,r).distinct&&Wn(u,d,l,o)<Math.max(12,f*.05))return`font: ${a.family} ${a.weight} drew as its fallback`;let p=Gn(u,l,t,r,s(a,r),a);if(p)return p}if(o){let o=In(e,n+Mn(i,a),r,t);if(o)return o}if(a.length&&t<100)return`effect probes: the card is too narrow to probe its effects`;for(let[t,o]of a.entries()){let a=Xn(e,o,n+Ln(i,t),r);if(a)return`effect ${o}: ${a}`}return null}function qn(e,t,n,r){let i=W(e,Math.floor(t*r),Math.floor(n*r));return(255-e.data[i+1])/255}function Jn(e,t,n,r,i){let a=0;for(let o=Math.floor(n*i);o<Math.floor(r*i);o++){let n=(255-e.data[W(e,o,Math.floor(t*i))+1])/255;n>.08&&n<.85&&a++}return a}function Yn(e,t,n){let r={left:V.left,right:V.left+V.width,top:t+V.top,bottom:t+V.top+V.height},i=(r.left+r.right)/2,a=(r.top+r.bottom)/2,o=(t,r)=>qn(e,t,r,n),s={left:o(r.left-2,a),right:o(r.right+2,a),top:o(i,r.top-2),bottom:o(i,r.bottom+2)};return Object.values(s).some(e=>e<.12)?`no blur beside the box ${JSON.stringify(s)}`:Math.abs(s.left-s.right)>.2||Math.abs(s.top-s.bottom)>.2?`blur is lopsided ${JSON.stringify(s)}`:o(r.left-6,a)>s.left+.05||o(r.right+6,a)>s.right+.05?`blur does not fade outward`:o(r.left-14,a)>.1||o(r.right+14,a)>.1?`dark well past the blur`:null}function Xn(e,t,n,r){let i=n+V.top+V.height/2;if(t===`text-shadow`){let t=0;for(let n=V.left-10;n<V.left+V.width+10;n++)t=Math.max(t,qn(e,n,i,r));return t<.3?`no shadow drawn`:Jn(e,i,V.left-10,V.left+V.width+10,r)<4?`shadow is not blurred`:null}return t===`backdrop-blur`?Jn(e,i,40,60,r)<3?`the edge behind it is not blurred`:Jn(e,n+8,40,60,r)>2?`blurred outside the probe`:null:Yn(e,n,r)}var G=2,Zn=2;function Qn(e,t,n,r){let i=(n.radius+G)*r,a=n.x*r,o=n.y*r,s=(n.x+n.width)*r,c=(n.y+n.height)*r;return(e<a+i||e>s-i)&&(t<o+i||t>c-i)}function $n(e,t,n,r,i){for(let a of n){let n=0,o=0,s=Math.ceil((a.x+G)*r),c=Math.floor((a.x+a.width-G)*r),l=Math.ceil((a.y+G)*r),u=Math.floor((a.y+a.height-G)*r);for(let i=l;i<u;i+=Zn)for(let l=s;l<c;l+=Zn){if(Qn(l,i,a,r))continue;let s=W(e,l,i),c=W(t,l,i);n++;for(let n=0;n<3;n++)if(Math.abs(e.data[s+n]-t.data[c+n])>bn){o++;break}}if(n&&o>Math.max(16,n*.003))return`effect clip: ${i} changed ${o} of ${n} sampled pixels when its clip was removed`}return null}async function er(e){let n=new Map;for(let r of e){let e=new Image;e.src=r.dataUrl;try{await e.decode()}catch{continue}let i=document.createElement(`canvas`);i.width=e.naturalWidth,i.height=e.naturalHeight;let a=Reflect.apply(C.getContext,i,[`2d`]);!i.width||!i.height||(a||t(`RASTERIZE_FAILED`,`no 2D context to read a bitmap back`),a.drawImage(e,0,0),n.set(r.id,U(i)))}return n}function tr(e,t,n){let r=[255,255,255],i=[0,0,0];for(let a=-1;a<=1;a++)for(let o=-1;o<=1;o++){let s=W(e,t+o,n+a);if(e.data[s+3]<250)return null;for(let t=0;t<3;t++)r[t]=Math.min(r[t],e.data[s+t]),i[t]=Math.max(i[t],e.data[s+t])}return{min:r,max:i}}function nr(e,t,n,r,i,a){let o=W(e.real,r,i),s=Math.min((e.magenta.data[o]-e.black.data[o])/255,(e.magenta.data[o+2]-e.black.data[o+2])/255);if(s<xn)return null;let c=(e.magenta.data[o+1]-e.black.data[o+1])/s;if(Math.abs(c-wn(n.id))>4)return null;let l=tr(t,Math.floor(((r+.5)/a-n.x)/n.width*t.width),Math.floor(((i+.5)/a-n.y)/n.height*t.height));if(!l)return null;for(let t=0;t<3;t++){let n=e.black.data[o+t],r=e.real.data[o+t];if(r<n+s*l.min[t]-bn||r>n+s*l.max[t]+bn)return!1}return!0}function rr(e,t,n,r,i=!1){let a=0,o=0,s=Math.max(t.x,0),c=Math.max(t.y,0),l=Math.min(t.x+t.width,e.real.width/r)-s,u=Math.min(t.y+t.height,e.real.height/r)-c;if(l<=0||u<=0)return null;for(let i=0;i<R;i++)for(let d=0;d<R;d++){let f=nr(e,n,t,Math.floor((s+l*(d+.5)/R)*r),Math.floor((c+u*(i+.5)/R)*r),r);f!==null&&(a++,f&&o++)}return a>=4&&o/a<Sn?`bitmap ${t.id}: ${o} of ${a} visible points show its pixels`:i&&a<4?`unverifiable: bitmap ${t.id} shows too little to check`:null}var ir=4096*4096;function ar(e,t,n){let r=re(t,n);return r?e[r.reported]===!0||e[r.origin]===!0||e[r.protocol.slice(0,-1)]===!0:!1}function or(e,n){ar(me,e,document.baseURI)&&t(`RESOURCE_BLOCKED_BY_PAGE`,`${n}: the page's CSP img-src blocked ${e}`)}function sr(e,n){ar(he,e,document.baseURI)||t(`IMAGE_NOT_LOADED`,`${n}: the page has not finished loading ${e}`)}function cr(e,n){(!e.complete||e.naturalWidth===0)&&t(`IMAGE_NOT_LOADED`,`${n} has not finished loading`)}function lr(e,t){return Je(e,t,`an image check`)}function ur(e,t,n){let{canvas:r,context:i}=lr(t,n);try{return i.drawImage(e,0,0,t,n),i.getImageData(0,0,t,n)}catch(e){if(e instanceof DOMException&&e.name===`SecurityError`)return null;throw e}finally{H(r)}}function dr(e,t){if(e.width!==t.width||e.height!==t.height)return!1;let n=new Uint32Array(e.data.buffer),r=new Uint32Array(t.data.buffer);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function fr(e){let{canvas:t,context:n}=lr(e.width,e.height);try{return n.putImageData(e,0,0),t.toDataURL(`image/png`)}finally{H(t)}}async function pr(e,n){try{return await createImageBitmap(new Blob([e],{type:n}))}catch{return t(`RESOURCE_TYPE_MISMATCH`,`a fetched image could not be decoded`)}}function mr(e){return new Promise(t=>{let n=new Image;n.decoding=`sync`,new URL(e,document.baseURI).origin!==location.origin&&(n.crossOrigin=`anonymous`),n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}function hr(e,n,r){let i=[137,80,78,71,13,10,26,10].every((t,n)=>e[n]===t),a=e[0]===255&&e[1]===216&&e[2]===255;if((n===`image/png`?!i:!a)&&t(`RESOURCE_TYPE_MISMATCH`,`${r}: its bytes are not the ${n} it is labelled`),!i)return;let o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let n=8;n+8<=e.length;){let i=o.getUint32(n),a=String.fromCharCode(e[n+4],e[n+5],e[n+6],e[n+7]);if(a===`acTL`&&t(`RESOURCE_TYPE_MISMATCH`,`${r}: an animated PNG`),a===`IDAT`||a===`IEND`)return;n+=12+i}}async function gr(e,n,r){!r&&n.uncacheable&&t(`IMAGE_CHANGED`,`${e} may not be reused (Cache-Control), so the page's copy cannot be matched`);let i=await pr(n.bytes,n.mime);try{let a=r??await mr(e);(!a||a.naturalWidth===0)&&t(`IMAGE_NOT_LOADED`,`${e} does not load in this page`);let o=a.naturalWidth,s=a.naturalHeight;o*s>ir&&t(`RESOURCE_TOO_LARGE`,`${e} is too large to check (${o}x${s})`);let c=ur(a,o,s);c||t(`IMAGE_NOT_READABLE`,`${e}: the page's copy of this image cannot be read to compare (cross-origin without CORS)`),(i.width!==o||i.height!==s)&&t(`IMAGE_CHANGED`,`${e} is ${i.width}x${i.height} now, ${o}x${s} on the page`);let l=ur(i,o,s);return l&&dr(c,l)?n.dataUrl:r?fr(c):t(`IMAGE_CHANGED`,`${e} returned different pixels than the page shows`)}finally{i.close()}}var _r=4*1024*1024,vr=10*1024*1024,K=96,yr=/^data:image\/(?:png|jpeg);base64,[a-z0-9+/=]+$/i,br=/^data:(?:font\/(?:woff2?|ttf|otf)|application\/(?:font-woff|font-sfnt|octet-stream));base64,[a-z0-9+/=]+$/i,xr={"font/woff2":`font/woff2`,"font/woff":`font/woff`,"font/ttf":`font/ttf`,"font/otf":`font/otf`,"font/sfnt":`font/sfnt`,"font/collection":`font/collection`,"application/font-woff2":`font/woff2`,"application/font-woff":`font/woff`,"application/x-font-woff":`font/woff`,"application/font-sfnt":`font/sfnt`,"application/x-font-ttf":`font/ttf`,"application/x-font-truetype":`font/ttf`,"application/x-font-opentype":`font/otf`,"application/vnd.ms-opentype":`font/otf`,"application/octet-stream":`application/octet-stream`},Sr=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`emoji`,`math`,`fangsong`]),Cr={style:`font-style`,weight:`font-weight`,stretch:`font-stretch`,display:`font-display`,unicodeRange:`unicode-range`,featureSettings:`font-feature-settings`,variationSettings:`font-variation-settings`,ascentOverride:`ascent-override`,descentOverride:`descent-override`,lineGapOverride:`line-gap-override`,sizeAdjust:`size-adjust`};function wr(e){return{total:0,cache:new Map,cssCache:new Map,signal:e}}function Tr(e,t){let n=``;for(let t=0;t<e.length;t+=32768)n+=String.fromCharCode(...e.subarray(t,t+32768));return`data:${t};base64,${btoa(n)}`}var Er=/^data:[a-z0-9.+/-]+;base64,[a-z0-9+/=]+$/i;function Dr(e){return Er.test(e)||t(`UNSUPPORTED_RESOURCE`,`an embedded resource is not a plain data: URL`),e}function q(e,n,r=document.baseURI){if(n===`image`&&yr.test(e)||n===`font`&&br.test(e))return{inline:!0,url:e};/^\s*#/.test(e)&&t(`UNSUPPORTED_RESOURCE_REFERENCE`,`${n} uses a document fragment reference`);let i;try{i=new URL(e,r)}catch{t(`INVALID_RESOURCE_URL`,`cannot resolve ${n} URL`)}return[`http:`,`https:`].includes(i.protocol)||t(`UNSUPPORTED_RESOURCE_SCHEME`,`${n} uses ${i.protocol}`),i.hash=``,{inline:!1,url:i.href}}function Or(e){return e.cache.size+e.cssCache.size}function kr(e,n,r,i){e>_r&&t(`RESOURCE_TOO_LARGE`,`${r}: more than ${_r} bytes`),i.total+=n,i.total>vr&&t(`RESOURCE_BUDGET_EXCEEDED`,`${i.total} bytes exceeds ${vr}`)}function Ar(e,t,n){kr(e,e,t,n)}function jr(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}async function Mr(e,n,r,i){if(!e.body){let t=new Uint8Array(await e.arrayBuffer());return Ar(t.byteLength,n,r),t}let a=e.body.getReader(),o=[],s=0;try{for(;;){let{done:e,value:t}=await a.read();if(e)break;s+=t.byteLength,kr(s,t.byteLength,n,r),o.push(t)}}catch(e){throw i(),a.cancel().catch(()=>{}),r.signal.aborted&&t(`CAPTURE_CANCELED`,`the capture was canceled`),e}return jr(o,s)}async function Nr(e,n,r){try{return await l(e,{credentials:`same-origin`,redirect:`follow`,referrerPolicy:`no-referrer`,cache:`force-cache`,mode:`cors`,signal:r})}catch(r){n.signal.aborted&&t(`CAPTURE_CANCELED`,`the capture was canceled`),t(new URL(e).origin===location.origin?`RESOURCE_FETCH_FAILED`:`RESOURCE_ORIGIN_NOT_ALLOWED`,`${e}: ${r instanceof Error?r.message:String(r)}`)}}async function Pr(e,n,r){let i=new AbortController,a=()=>i.abort();r.signal.aborted&&t(`CAPTURE_CANCELED`,`${e}: capture already stopped`),r.signal.addEventListener(`abort`,a);try{let o=await Nr(e,r,i.signal);o.ok||(a(),t(`RESOURCE_FETCH_FAILED`,`${e}: HTTP ${o.status}`));try{q(o.url,n)}catch(e){throw a(),e}let s=Number(o.headers.get(`content-length`));return Number.isFinite(s)&&s>_r&&(a(),t(`RESOURCE_TOO_LARGE`,`${e}: declared ${s} bytes`)),{bytes:await Mr(o,e,r,a),mime:u((o.headers.get(`content-type`)??``).split(`;`)[0]).toLowerCase(),finalUrl:o.url,uncacheable:Fr(o.headers)}}finally{r.signal.removeEventListener(`abort`,a)}}function Fr(e){let t=e.get(`cache-control`)??``;return/\bno-store\b/i.test(t)?!0:/\b(?:no-cache|max-age\s*=\s*0)\b/i.test(t)&&!e.get(`etag`)&&!e.get(`last-modified`)}function Ir(e,n,r){if(n===`image`&&![`image/png`,`image/jpeg`].includes(e)&&t(`RESOURCE_TYPE_MISMATCH`,`${r}: expected static PNG/JPEG, got ${e||`unknown`}`),n===`font`){let n=e?xr[e]:`application/octet-stream`;return n||t(`UNSUPPORTED_FONT`,`${r}: expected a font type, got ${e.slice(0,60)}`),n}return e||`image/png`}function Lr(e){let n=e.indexOf(`,`),r=e.slice(5,e.indexOf(`;`)).toLowerCase(),i;try{i=atob(e.slice(n+1))}catch{return t(`RESOURCE_TYPE_MISMATCH`,`an inline image is not valid base64`)}let a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);hr(a,r,`an inline image`)}async function Rr(e,n,r,i,a=null){let o=q(e,r,i);if(o.inline)return r===`image`&&Lr(o.url),o.url;let s=n.cache.get(o.url);if(s!==void 0)return await s;Or(n)>=K&&t(`TOO_MANY_RESOURCES`,`more than ${K} resources`);let c=(async()=>{let e=await Pr(o.url,r,n),t=Ir(e.mime,r,o.url);r===`image`&&hr(e.bytes,t,o.url);let i=Tr(e.bytes,t);if(r!==`image`)return i;let s=await gr(o.url,{bytes:e.bytes,mime:t,dataUrl:i,uncacheable:e.uncacheable},a);return s!==i&&Ar(s.length,o.url,n),s})();n.cache.set(o.url,c);try{let e=await c;return n.cache.set(o.url,e),e}catch(e){throw n.cache.delete(o.url),e}}async function zr(e,t,n,r){let i=[];for(let a of D(e)){let e=Dr(await Rr(a.url,t,n,r));i.push([a,`url("${e}")`])}return ot(e,i)}function Br(e,n,r,i){let a=[];for(let o of D(e)){let e=q(o.url,`image`);if(e.inline)continue;let s=n.cache.get(e.url);typeof s!=`string`&&t(`RESOURCE_NOT_PRELOADED`,`${r} ${i} was not preloaded`),a.push([o,`url("${Dr(s)}")`])}return ot(e,a)}var Vr=new Set([`CAPTURE_CANCELED`,`RESOURCE_BUDGET_EXCEEDED`,`TOO_MANY_RESOURCES`,`RESOURCE_TOO_LARGE`]);async function Hr(t,n){if(Dt(),A(t).some(e=>getComputedStyle(e).getPropertyValue(`-webkit-line-clamp`)!==`none`)){for(let t of document.styleSheets)if(t.href)try{t.cssRules}catch{try{let e=await Ur(t.href,n);Ot(t.href,e.text)}catch(t){if(t instanceof e&&Vr.has(t.code))throw t}}}}async function Ur(e,n){let r=q(e,`stylesheet`),i=n.cssCache.get(r.url);if(i)return await i;Or(n)>=K&&t(`TOO_MANY_RESOURCES`,`more than ${K} resources`);let a=(async()=>{let e=await Pr(r.url,`stylesheet`,n);e.mime!==`text/css`&&t(`RESOURCE_TYPE_MISMATCH`,`${r.url}: expected text/css, got ${e.mime||`unknown`}`);let i=new TextDecoder(`utf-8`,{fatal:!0}).decode(e.bytes);return/@import\b/i.test(i)&&t(`UNSUPPORTED_FONT_STYLESHEET`,`${r.url}: @import is not supported`),{text:i,baseUrl:e.finalUrl}})();n.cssCache.set(r.url,a);try{return await a}catch(e){throw n.cssCache.delete(r.url),e}}function Wr(e){let n={imageSources:[],cssResources:[],usedTextFonts:new Set};matchMedia(`(forced-colors: active)`).matches&&t(`UNSUPPORTED_FORCED_COLORS`,`the browser is in forced-colors mode`),gt(e),xt(e),zt(e);let r=0;for(let i of A(e)){let e=`${i.tagName.toLowerCase()}[${r++}]`;if(Ht(i,e),i instanceof HTMLImageElement){let r=i.currentSrc||i.getAttribute(`src`)||``;r||t(`UNSUPPORTED_RESOURCE`,`${e} has no image source`),cr(i,e),or(r,e),n.imageSources.push({url:r,element:i})}Gr(i,n)}return Vt(e,A(e)),n}function Gr(e,n){for(let r of[null,`::before`,`::after`]){let i=getComputedStyle(e,r);if(r?k(i.content)!==null&&i.display!==`none`:lt(e,i)||bt(e,i)!==null)for(let e of ct(i.fontFamily))Sr.has(e)||n.usedTextFonts.add(e);for(let e of i){if(e.startsWith(`--`))continue;let r=i.getPropertyValue(e);/image-set\(/i.test(r)&&t(`UNSUPPORTED_IMAGE_SET`,`${e} uses image-set()`);let a=at(r);if(a.length!==0){for(let t of a)or(t,e),q(t,`image`).inline||sr(t,e);n.cssResources.push(r)}}}}function Kr(e){return!e.mediaText||matchMedia(e.mediaText).matches}function qr(e,n){if(e.disabled||!Kr(e.media))return;let r;try{r=e.cssRules}catch{e.href||t(`UNSUPPORTED_FONT_STYLESHEET`,`an inline stylesheet is not readable`),n.inaccessibleHrefs.push(e.href);return}Jr(r,n)}function Jr(e,t){for(let n of e)if(n instanceof CSSFontFaceRule)t.rules.push(n);else if(n instanceof CSSImportRule)n.styleSheet&&Kr(n.media)&&qr(n.styleSheet,t);else if(n instanceof CSSMediaRule&&!matchMedia(n.media.mediaText).matches)continue;else if(n instanceof CSSSupportsRule&&!CSS.supports(n.conditionText))continue;else `cssRules`in n&&Jr(n.cssRules,t)}function Yr(e){let t=e.parentStyleSheet;for(;t;){if(t.href)return t.href;if(!t.ownerNode&&!t.ownerRule)return null;t=t.ownerRule?.parentStyleSheet??null}return document.baseURI}function Xr(){let e={rules:[],inaccessibleHrefs:[]};for(let t of document.styleSheets)qr(t,e);for(let t of document.adoptedStyleSheets??[])qr(t,e);return e}function Zr(e,n){let r=new CSSStyleSheet;try{r.replaceSync(e)}catch(e){t(`UNSUPPORTED_FONT_STYLESHEET`,`${n}: ${e instanceof Error?e.message:``}`)}let i={rules:[],inaccessibleHrefs:[]};return Jr(r.cssRules,i),i.rules}function Qr(e){return[e.weight,e.style,e.stretch,e.unicodeRange].join(`|`).toLowerCase()}function $r(e){let n={},r=t=>u(e.style.getPropertyValue(t))||void 0;n.weight=r(`font-weight`),n.style=r(`font-style`),n.stretch=r(`font-stretch`),n.unicodeRange=r(`unicode-range`);try{return Qr(new FontFace(`castle-cover-probe`,`url(data:,)`,n))}catch{return t(`UNSUPPORTED_FONT_DESCRIPTOR`,`an @font-face rule has descriptors the browser rejects`)}}function ei(e,n){let r=$r(e),i=new Set;for(let e of document.fonts??[])O(e.family)===n&&Qr(e)===r&&i.add(e.status);return i.size===1&&i.has(`loaded`)?!0:i.has(`loaded`)?t(`UNSUPPORTED_FONT`,`${n} has faces the page loaded and faces it did not, with the same descriptors`):!1}function ti(e,n){let r=u(n).toLowerCase();(r===`optional`||r===`fallback`)&&t(`UNSUPPORTED_FONT_DISPLAY`,`${e} has font-display: ${r}; the page may still show the fallback (refused conservatively)`)}function ni(e,t){return ar(pe,e,t??document.baseURI)}function ri(e,n){let r=st(e).filter(e=>!D(e).some(e=>ni(e.url,n)));return r.length===0&&t(`UNSUPPORTED_FONT_SOURCE`,`every source of a loaded face was blocked by the page`),r.join(`, `)}async function ii(e,n,r){let i=O(e.style.getPropertyValue(`font-family`));if(!r.used.has(i)||!ei(e,i))return;let a=`${i}|${$r(e)}`;ti(i,e.style.getPropertyValue(`font-display`));let o=e.style.getPropertyValue(`src`),s=at(o);s.length===0&&t(`UNSUPPORTED_FONT_SOURCE`,`${i} has no URL source`);let c=n??ai(s,i),l=await zr(ri(o,c),r.budget,`font`,c);r.css.push(e.cssText.replace(o,()=>l)),r.covered.add(a)}function ai(e,n){for(let r of e)!URL.canParse(r)&&!/^data:/i.test(r)&&t(`UNSUPPORTED_FONT_SOURCE`,`${n} is in a constructed sheet with a relative URL`);return document.baseURI}function oi(e){return`url("${Dr(e)}")`}function si(e){return`"${e.replace(/[\\"\n\r\f]/g,e=>`\\${e.charCodeAt(0).toString(16)} `)}"`}var ci=/^(?:"[A-Za-z0-9-]+"|'[A-Za-z0-9-]+'|[A-Za-z0-9-]+)$/,li=/^(format|tech)\(([^()]*)\)\s*/i;function ui(e,n){let r=D(n);(r.length!==1||r[0].start!==0)&&t(`UNSUPPORTED_FONT_SOURCE`,`dynamic font ${e} has a source entry that is not url(...)`);let i=u(n.slice(r[0].end)),a=``;for(;i;){let n=li.exec(i),r=n?n[2].split(`,`).map(e=>u(e)):[];(!n||r.length===0||!r.every(e=>ci.test(e)))&&t(`UNSUPPORTED_FONT_SOURCE`,`dynamic font ${e} has a source hint the cover cannot copy`),a+=` ${n[1].toLowerCase()}(${r.join(`, `)})`,i=i.slice(n[0].length)}return{url:r[0].url,hints:a}}async function di(e,n){let r=e.source;if(typeof r==`string`){(r.includes(`/*`)||r.includes(`\\`))&&t(`UNSUPPORTED_FONT_SOURCE`,`dynamic font ${e.family} has a comment or escape in its source`);let i=st(r).map(t=>ui(e.family,t)).filter(t=>!ni(t.url,e.baseUrl));return i.length===0&&t(`UNSUPPORTED_FONT_SOURCE`,`dynamic font ${e.family} does not have an embeddable URL source`),(await Promise.all(i.map(t=>Rr(t.url,n,`font`,e.baseUrl)))).map((e,t)=>`${oi(e)}${i[t].hints}`).join(`, `)}if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)){let t=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return Ar(t.byteLength,`dynamic font ${e.family}`,n),oi(Tr(t,`application/octet-stream`))}t(`UNSUPPORTED_FONT_SOURCE`,`dynamic font ${e.family} has an unknown source`)}var fi=/^[A-Za-z0-9\s.,%+\-#"'()_?]*$/;function pi(e,n,r){let i=typeof r==`string`?r:``,a=(i.split(`"`).length-1)%2==0&&(i.split(`'`).length-1)%2==0;return(!i||!fi.test(i)||!a)&&t(`UNSUPPORTED_FONT_DESCRIPTOR`,`dynamic font ${e} has an unusable ${n}`),i}function mi(e,n,r){return Object.keys(r).map(r=>{let i=Cr[r];return i||t(`UNSUPPORTED_FONT_DESCRIPTOR`,`dynamic font ${n} uses descriptor ${r}`),`${i}:${pi(n,r,e[r])}`}).join(`;`)}async function hi(e){if(document.fonts)for(let t of document.fonts){let n=fe.get(t);if(!n||t.status!==`loaded`)continue;let r=O(n.family);if(!e.used.has(r))continue;ti(r,t.display);let i=await di(n,e.budget),a=mi(t,n.family,n.descriptors);e.trackedCss.push(`@font-face{font-family:${si(n.family)};src:${i};${a}}`),e.covered.add(`${r}|${Qr(t)}`)}}async function gi(e,n){let r={used:e,css:[],trackedCss:[],covered:new Set,budget:n};await hi(r);let i=Xr();for(let e of i.rules)await ii(e,Yr(e),r);if(_i(r).length>0)for(let e of new Set(i.inaccessibleHrefs)){let t=await Ur(e,n);for(let e of Zr(t.text,t.baseUrl))await ii(e,t.baseUrl,r)}let a=_i(r);a.length>0&&t(`UNSUPPORTED_FONT`,`DOM text uses ${a[0]}, whose embeddable source was not found`);let o=new Set([...r.covered].map(e=>e.split(`|`)[0])),s=vi();for(let n of e)o.has(n)||s.has(n)&&t(`UNSUPPORTED_FONT`,`DOM text uses ${n}, but its embeddable source was not discoverable`);return{css:[...r.css,...r.trackedCss].join(`
2
+ `),families:[...o]}}function _i(e){let t=[];for(let n of document.fonts??[]){if(n.status!==`loaded`)continue;let r=O(n.family),i=`${r}|${Qr(n)}`;e.used.has(r)&&!e.covered.has(i)&&t.push(i)}return t}function vi(){let e=new Set;if(document.fonts)for(let t of document.fonts)t.status===`loaded`&&e.add(O(t.family));return e}async function yi(e,n){let r=new AbortController,i=()=>r.abort();n.addEventListener(`abort`,i),n.aborted&&r.abort();let a=wr(r.signal);try{await Hr(e,a);let n=Wr(e);await Promise.all([...n.imageSources.map(({url:e,element:t})=>Rr(e,a,`image`,void 0,t)),...n.cssResources.map(e=>zr(e,a,`image`))]),await document.fonts?.ready,document.fonts&&document.fonts.status!==`loaded`&&t(`FONTS_PENDING`,`document fonts are not loaded`);let r=await gi(n.usedTextFonts,a);return{budget:a,fontCss:r.css,fontFamilies:r.families}}catch(e){throw r.abort(),e}finally{n.removeEventListener(`abort`,i)}}function J(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function bi(e,t){for(let n=e;n;n=n.parentElement){let e=getComputedStyle(n);if(e.filter!==`none`||e.mixBlendMode!==`normal`)return!1;if(n===t)break}let n=getComputedStyle(e);return n.objectFit===`fill`||n.objectFit===``}function xi(e,t,n,r){let i=getComputedStyle(e);if(i.visibility!==`visible`)return;let a=e.getBoundingClientRect(),o=r.scaleX,s=r.scaleY;if(!(Math.abs(a.width-e.offsetWidth*o)<=1&&Math.abs(a.height-e.offsetHeight*s)<=1)||!bi(e,r.root)||r.bitmaps.length>=25){r.unverified++;return}let c=(J(i.borderLeftWidth)+J(i.paddingLeft))*o,l=(J(i.borderRightWidth)+J(i.paddingRight))*o,u=(J(i.borderTopWidth)+J(i.paddingTop))*s,d=(J(i.borderBottomWidth)+J(i.paddingBottom))*s,f=a.width-c-l,p=a.height-u-d;if(f<4||p<4)return;let m=r.bitmaps.length;t.setAttribute(`${r.marker}-bitmap`,String(m)),r.bitmaps.push({id:m,dataUrl:n,x:a.left-r.originX+c,y:a.top-r.originY+u,width:f,height:p})}var Si=[`box-shadow`,`text-shadow`,`filter-blur`,`drop-shadow`,`backdrop-blur`];function Ci(e,t){e.boxShadow&&e.boxShadow!==`none`&&t.add(`box-shadow`),e.textShadow&&e.textShadow!==`none`&&t.add(`text-shadow`),/\bblur\(/.test(e.filter)&&t.add(`filter-blur`),/\bdrop-shadow\(/.test(e.filter)&&t.add(`drop-shadow`);let n=e.backdropFilter||e.getPropertyValue(`-webkit-backdrop-filter`);n&&n!==`none`&&t.add(`backdrop-blur`)}function wi(e){let t=new Set;for(let n of A(e))for(let e of[null,`::before`,`::after`])Ci(getComputedStyle(n,e),t);return Si.filter(e=>t.has(e))}var Ti=8;function Ei(e,t,n){let r=0;for(let i of[e.borderTopLeftRadius,e.borderTopRightRadius,e.borderBottomRightRadius,e.borderBottomLeftRadius])for(let e of i.split(/\s+/)){let i=Number.parseFloat(e);Number.isFinite(i)&&(r=Math.max(r,e.endsWith(`%`)?i/100*Math.max(t,n):i))}return r}function Di(e){return e.overflowX!==`visible`||e.overflowY!==`visible`}function Oi(e){let t=new Set;for(let n of[null,`::before`,`::after`])Ci(getComputedStyle(e,n),t);return t.size>0}function ki(e,t){let n=getComputedStyle(e),r=e.getBoundingClientRect();if(!(Math.abs(r.width-e.offsetWidth*t.scaleX)<=1&&Math.abs(r.height-e.offsetHeight*t.scaleY)<=1)||n.clipPath!==`none`)return`an effect is clipped by a transformed or clip-path box`;let i=(e,t)=>J(n.getPropertyValue(e))+J(n.getPropertyValue(t));if(e.offsetWidth-e.clientWidth-i(`border-left-width`,`border-right-width`)>.5||e.offsetHeight-e.clientHeight-i(`border-top-width`,`border-bottom-width`)>.5)return`an effect is clipped by a box with scrollbars that take up room`;let a=J(n.borderLeftWidth)*t.scaleX,o=J(n.borderTopWidth)*t.scaleY,s=r.width-a-J(n.borderRightWidth)*t.scaleX,c=r.height-o-J(n.borderBottomWidth)*t.scaleY;return{x:r.left-t.originX+a,y:r.top-t.originY+o,width:s,height:c,radius:Ei(n,s,c)*Math.max(t.scaleX,t.scaleY),ancestors:[]}}function Ai(e,t){let n=getComputedStyle(e),r=e.getBoundingClientRect(),i={clips:[],rootRadius:Ei(n,r.width,r.height)*Math.max(t.scaleX,t.scaleY),unverifiable:null},a=new Set,o=new Map;for(let n of A(e))if(Oi(n))for(let r=n.parentElement;r&&r!==e;r=r.parentElement){if(a.has(r)||!Di(getComputedStyle(r)))continue;a.add(r);let e=r instanceof HTMLElement?ki(r,t):`an effect is clipped by a non-HTML box`,n=t.clones.get(r);typeof e==`string`||!n?i.unverifiable=typeof e==`string`?e:`an effect clip was not copied`:i.clips.length>=Ti?i.unverifiable=`too many boxes clip effects`:(n.setAttribute(`${t.marker}-effect-clip`,String(i.clips.length)),o.set(r,i.clips.length),i.clips.push(e))}for(let[t,n]of o)for(let r=t.parentElement;r&&r!==e;r=r.parentElement){let e=o.get(r);e!==void 0&&i.clips[n].ancestors.push(e)}return i}function ji(e,t){let n=new Set;for(let t of[null,`::before`,`::after`])Ci(getComputedStyle(e,t),n);for(let e of n)t.add(e);for(let n of[`::first-letter`,`::first-line`,`::marker`]){let r=getComputedStyle(e,n).textShadow;r&&r!==`none`&&t.add(`text-shadow on ${n}`)}let r=getComputedStyle(e),i=r.getPropertyValue(`-webkit-box-reflect`);i&&i!==`none`&&t.add(`-webkit-box-reflect`);let a=r.maskImage||r.getPropertyValue(`-webkit-mask-image`);a&&a!==`none`&&t.add(`mask-image`)}function Mi(e){let t=new Set;for(let n of A(e))ji(n,t);return[...t].sort()}var Ni=3e3,Pi=12*1024*1024,Fi=2,Ii=[`href`,`action`,`formaction`,`srcset`,`poster`];function Li(e,t,n,r,i){let a=getComputedStyle(e,n);for(let e of a)e.startsWith(`--`)||t.style.setProperty(e,Br(a.getPropertyValue(e),i.budget,r,e),a.getPropertyPriority(e));let o=n?null:Lt(e,a);o&&(t.style.setProperty(`display`,o),t.style.setProperty(`-webkit-box-orient`,`vertical`)),t.style.setProperty(`animation`,`none`,`important`),t.style.setProperty(`transition`,`none`,`important`),t.style.setProperty(`caret-color`,`transparent`,`important`),t.style.setProperty(`overflow-anchor`,`none`,`important`)}function Ri(e,t,n,r,i){let a=getComputedStyle(e,n),o=k(a.content);if(o===null||a.display===`none`)return;let s=document.createElement(`span`);s.setAttribute(`data-cover-pseudo`,n.slice(2)),s.textContent=o,Li(e,s,n,`${r}${n}`,i),n===`::before`?t.prepend(s):t.append(s)}function zi(e,n,r){let i=q(e.currentSrc||n,`image`),a=i.inline?i.url:r.cache.get(i.url);return typeof a!=`string`&&t(`RESOURCE_NOT_PRELOADED`,`<img> source was not preloaded`),a}function Bi(e,n,r,i){for(let a of e.attributes){let o=a.name.toLowerCase();if(!(o===`style`||o===`id`||o===`class`||o.startsWith(`on`))){if(o.startsWith(`data-cover-`)){i.strippedMarks++;continue}if(!Ii.includes(o)){if(o===`src`){e instanceof HTMLImageElement||t(`UNSUPPORTED_RESOURCE`,`<${e.tagName.toLowerCase()}> has src`),n.setAttribute(`src`,zi(e,a.value,r));continue}n.setAttribute(a.name,a.value)}}}e instanceof HTMLInputElement&&[`checkbox`,`radio`].includes(e.type)&&(n.checked=e.checked,e.checked?n.setAttribute(`checked`,``):n.removeAttribute(`checked`))}function Vi(e,n,r){let i=x.get(e);if(i||t(`CANVAS_CONTEXT_UNKNOWN`,`${n} context was created before capture installation or never requested`),i.kind===`unsupported`&&t(`UNSUPPORTED_CANVAS_CONTEXT`,`${n} uses ${i.requestedType}`),i.kind===`webgl`){let a=r.webglFrames.get(e);a||t(`WEBGL_CAPTURE_REQUIRED`,`${n} needs an end-of-render capture`);let o=i.context;return a.valid||t(`WEBGL_CAPTURE_STALE`,`${n} was not captured synchronously in this turn`),(a.width!==o.drawingBufferWidth||a.height!==o.drawingBufferHeight)&&t(`WEBGL_CAPTURE_STALE`,`${n} was resized after capture`),a.dataUrl}try{return e.toDataURL(`image/png`)}catch(e){t(`CANVAS_READBACK_FAILED`,`${n}: ${e instanceof Error?e.message:``}`)}}function Hi(e,t,n){let r=document.createElement(`img`),i=Vi(e,t,n);return r.src=i,r.alt=``,r.draggable=!1,Li(e,r,null,t,n),xi(e,r,i,n.record),n.record.clones.set(e,r),r}function Ui(e,n,r){let i=[],a=0;for(let o of e.childNodes)if(o.nodeType===Node.TEXT_NODE)i.push(document.createTextNode(o.textContent??``));else if(o instanceof Element){if(a++,getComputedStyle(o).display===`none`)continue;i.push(Ki(o,`${n} > ${o.tagName.toLowerCase()}:nth-child(${a})`,r))}else o.nodeType!==Node.COMMENT_NODE&&t(`UNSUPPORTED_NODE`,`${n} contains node type ${o.nodeType}`);return i}function Wi(e){let t=e=>e===`auto`||e===`scroll`;return t(e.style.overflowX)||t(e.style.overflowY)}function Gi(e,t,n){if(Wi(t)&&t.style.setProperty(`scrollbar-width`,`none`,`important`),!e.scrollLeft&&!e.scrollTop){t.append(...n);return}let r=getComputedStyle(e),i=e=>Number.parseFloat(e)||0,a=e.clientWidth-i(r.paddingLeft)-i(r.paddingRight),o=e.scrollHeight-i(r.paddingTop)-i(r.paddingBottom),s=document.createElement(`div`);s.style.cssText=[`position:relative`,`width:${Math.max(0,a)}px`,`min-height:${Math.max(0,o)}px`,`transform:translate(${-e.scrollLeft}px,${-e.scrollTop}px)`,`transform-origin:top left`].join(`;`),s.append(...n),t.style.setProperty(`overflow`,`hidden`,`important`),t.append(s)}function Ki(e,n,r){if(++r.nodes>Ni&&t(`PACKAGE_TOO_COMPLEX`,`more than ${Ni} elements`),Ht(e,n),e instanceof HTMLCanvasElement)return Hi(e,n,r);let i=e.namespaceURI===`http://www.w3.org/2000/svg`?document.createElementNS(Xe,e.localName):document.createElement(e===document.body?`div`:e.tagName.toLowerCase());r.record.clones.set(e,i),Bi(e,i,r.budget,r.record),Li(e,i,null,n,r);let a=i.getAttribute(`src`);e instanceof HTMLImageElement&&a&&xi(e,i,a,r.record);let o=e.namespaceURI===E;return o&&Ri(e,i,`::before`,n,r),Gi(e,i,Ui(e,n,r)),o&&Ri(e,i,`::after`,n,r),i}function qi(e){let n=getComputedStyle(e).transform;if(n===`none`)return null;let r;try{r=new DOMMatrixReadOnly(n)}catch{t(`UNSUPPORTED_ROOT_TRANSFORM`,`cannot parse root transform ${n}`)}let i=1e-8;return(!r.is2D||Math.abs(r.b)>i||Math.abs(r.c)>i||r.a<=0||r.d<=0)&&t(`UNSUPPORTED_ROOT_TRANSFORM`,`only positive axis-aligned root scale/translation is supported`),{scaleX:r.a,scaleY:r.d}}function Ji(e,t,n,r){for(let[t,r]of[[`position`,`absolute`],[`inset`,`auto`],[`left`,`0`],[`top`,`0`],[`right`,`auto`],[`bottom`,`auto`],[`margin`,`0`],[`transform-origin`,`top left`],[`transform`,`scale(${n.scaleX},${n.scaleY})`]])e.style.setProperty(t,r,`important`);let i=document.createElement(`div`);return i.setAttribute(`${r}-root-wrapper`,``),i.style.cssText=`position:relative;width:${t.width}px;height:${t.height}px;overflow:hidden`,i.append(e),i}function Yi(e,n,r,i,a){let o=qi(e),s=e.getBoundingClientRect();s.width>0&&s.height>0||t(`EMPTY_TARGET`,`target has no visible bounds`);let c={originX:s.left,originY:s.top,scaleX:o?.scaleX??1,scaleY:o?.scaleY??1,root:e,bitmaps:[],unverified:0,clones:new Map,marker:Xi(),strippedMarks:0},l=Ki(e,e.tagName.toLowerCase(),{nodes:0,budget:n,webglFrames:a,record:c});o?l=Ji(l,s,o,c.marker):Zi(l);let u=Ai(e,c),d=l.outerHTML,f=new TextEncoder().encode(d+r).byteLength;return f>Pi&&t(`PACKAGE_TOO_LARGE`,`${f} bytes exceeds ${Pi}`),{version:Fi,width:Math.ceil(s.width),height:Math.ceil(s.height),backdropColor:getComputedStyle(document.body).backgroundColor,html:d,fontCss:r,byteLength:f,bitmaps:c.bitmaps,unverifiedBitmaps:c.unverified,textSamples:pn(e,i),effects:wi(e),webkitEffects:Mi(e),effectClips:u,marker:c.marker,strippedMarks:c.strippedMarks}}function Xi(){let e=new Uint8Array(6);return C.getRandomValues(e),`data-cover-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Zi(e){let t=e.style.getPropertyValue(`position`);(t===`fixed`||t===`absolute`||t===`sticky`)&&e.style.setProperty(`position`,`relative`,`important`);for(let t of[`left`,`top`,`right`,`bottom`])e.style.setProperty(t,`auto`,`important`);e.style.setProperty(`margin`,`0`,`important`)}var Qi=/\((?:iPhone|iPad|iPod)[;)]/,$i=/\b(?:CriOS|FxiOS|EdgiOS|OPiOS|GSA)\//,ea=/\b(?:Chrome|Chromium|HeadlessChrome)\//;function ta(e){let t=e.userAgent;return Qi.test(t)||$i.test(t)||e.platform===`MacIntel`&&(e.maxTouchPoints??0)>1?!0:ea.test(t)?!1:/AppleWebKit\//.test(t)||e.vendor===`Apple Computer, Inc.`}function na(){ia()&&t(`BROWSER_UNSUPPORTED`,`webkit: covers are not made in WebKit yet`)}var ra=typeof navigator>`u`?null:{userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints,vendor:navigator.vendor};function ia(){return typeof window<`u`&&window.__castleCoverAssumeWebKit===!0?!0:ra!==null&&ta(ra)}function aa(e){e.length&&t(`EFFECT_NOT_REPRODUCIBLE`,`webkit: the card uses ${e.join(`, `)}`)}var Y=null;function oa(e){return A(e).filter(e=>e instanceof HTMLCanvasElement)}function sa(e){return oa(e).filter(e=>{let t=x.get(e);return t?.kind===`webgl`?t.context.getContextAttributes()?.preserveDrawingBuffer!==!0:!1})}function ca(e,t){let n=e;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}function la(e){let t=2166136261,n=e=>{t=ca(t,String(e))};for(let t of A(e)){let e=t.getBoundingClientRect();n(t.namespaceURI),n(t.localName),n(`${e.x},${e.y},${e.width},${e.height},${t.scrollLeft},${t.scrollTop}`),t instanceof HTMLInputElement&&[`checkbox`,`radio`].includes(t.type)&&n(t.checked);for(let e of[null,`::before`,`::after`]){let r=getComputedStyle(t,e);if(e&&(r.content===`none`||r.content===`normal`)){n(r.content);continue}for(let e of r)n(e),n(r.getPropertyValue(e)),n(r.getPropertyPriority(e))}}return n(getComputedStyle(document.body).backgroundColor),t}function ua(e){let t=e.source,n=new MutationObserver(t=>{e.guard&&(e.guard.mutations+=t.length)});n.observe(t,{subtree:!0,attributes:!0,childList:!0,characterData:!0});for(let e=t.parentElement;e;e=e.parentElement)n.observe(e,{attributes:!0});n.observe(document.head,{subtree:!0,attributes:!0,childList:!0,characterData:!0}),e.guard={observer:n,mutations:0,fingerprint:la(t),canvases:oa(t).map(e=>({canvas:e,revision:S.get(e)??0,width:e.width,height:e.height}))}}function da(e){let n=e.guard;(!e.captured||!n)&&t(`CAPTURE_NOT_COMPLETED`,`the frame guard starts at the capture boundary`),n.mutations+=n.observer.takeRecords().length,n.mutations!==0&&t(`FRAME_CHANGED_AFTER_CAPTURE`,`observed a DOM/style mutation after the synchronous copy`);for(let e of n.canvases)((S.get(e.canvas)??0)!==e.revision||e.canvas.width!==e.width||e.canvas.height!==e.height)&&t(`FRAME_CHANGED_AFTER_CAPTURE`,`observed a canvas write or resize after the synchronous copy`);la(e.source)!==n.fingerprint&&t(`FRAME_CHANGED_AFTER_CAPTURE`,`computed style, geometry, or scrolling changed after the synchronous copy`)}function fa(e,t,n){let r=document.createElement(`canvas`);r.width=t,r.height=n;let i=Reflect.apply(C.getContext,r,[`2d`]),a=new Uint8ClampedArray(e.length),o=t*4;for(let t=0;t<n;t++)a.set(e.subarray(t*o,(t+1)*o),(n-t-1)*o);i.putImageData(new ImageData(a,t,n),0,0);let s=r.toDataURL(`image/png`);return r.width=0,r.height=0,s}function pa(e){let n=x.get(e);n?.kind!==`webgl`&&t(`WEBGL_CONTEXT_NOT_TRACKED`,`install the capture before creating the WebGL context`);let r=n.context;if(r.isContextLost()&&t(`WEBGL_CONTEXT_LOST`,`cannot capture a lost context`),r.finish(),r.getParameter(r.FRAMEBUFFER_BINDING)!==null&&t(`WEBGL_NONDEFAULT_FRAMEBUFFER`,`bind the default framebuffer`),n.requestedType===`webgl2`){let e=r;e.getParameter(e.READ_FRAMEBUFFER_BINDING)!==null&&t(`WEBGL_NONDEFAULT_READ_FRAMEBUFFER`,`bind the default read framebuffer`)}let i=r.drawingBufferWidth,a=r.drawingBufferHeight;(!i||!a)&&t(`WEBGL_EMPTY_BUFFER`,`drawing buffer has no pixels`);let o=new Uint8Array(i*a*4);r.readPixels(0,0,i,a,r.RGBA,r.UNSIGNED_BYTE,o);let s=r.getError();s!==r.NO_ERROR&&t(`WEBGL_READBACK_FAILED`,`gl.readPixels error ${s}`);for(let e=3;e<o.length;e+=4)o[e]!==255&&t(`WEBGL_TRANSPARENCY_UNSUPPORTED`,`only opaque WebGL default framebuffers are supported`);let c={dataUrl:fa(o,i,a),width:i,height:a,valid:!0};return queueMicrotask(()=>{c.valid=!1}),c}function ma(e){let t=new Map;for(let n of oa(e))x.get(n)?.kind===`webgl`&&t.set(n,pa(n));return t}function ha(e){e.armed=!1,e.nativeTickId!==void 0&&C.cancelAnimationFrame(e.nativeTickId),e.nativeTickId=void 0,Ee(null),e.frameEnd?.disconnect(),e.frameEnd=null,e.armTimer!==void 0&&window.clearTimeout(e.armTimer),e.armTimer=void 0,e.fallbackNativeId!==void 0&&C.cancelAnimationFrame(e.fallbackNativeId),e.fallbackNativeId=void 0}function ga(e){let t=e.settle;ha(e),De();try{ua(e);let n=ma(e.source),{budget:r,fontCss:i,fontFamilies:a}=e.resources,o=Yi(e.source,r,i,a,n);e.captured=!0,t?.resolve(o)}catch(e){t?.reject(e instanceof Error?e:Error(String(e)))}}function _a(e){let t=we();return sa(e.source).every(e=>{let n=ue.get(e);return n!==void 0&&n.batch===t&&n.width===e.width&&n.height===e.height})}function va(e){if(e.frameEnd?.disconnect(),e.frameEnd=null,e.armed){if(!_a(e)){e.batchesWithoutRender++;return}ga(e)}}function ya(e){if(!e.armed||e.frameEnd)return;let t=new ResizeObserver(()=>va(e));e.frameEnd=t,t.observe(document.documentElement)}function ba(e,n){return e.released&&t(`CAPTURE_CANCELED`,`the capture was released`),new Promise((t,r)=>{e.settle={resolve:t,reject:r},e.armed=!0,Ee(()=>ya(e)),!Te()&&sa(e.source).length===0&&(e.fallbackNativeId=C.requestAnimationFrame(()=>{e.fallbackNativeId=void 0,e.armed&&ga(e)})),xa(e),e.armTimer=window.setTimeout(()=>{ha(e),r(Ca(e,n))},n)})}function xa(e){let t=()=>{e.nativeTicks++,e.armed&&(e.nativeTickId=C.requestAnimationFrame(t))};e.nativeTickId=C.requestAnimationFrame(t)}function Sa(t){return new e(`FRAME_NOT_VISIBLE`,`${t} (visibilityState=${document.visibilityState})`)}function Ca(t,n){return t.nativeTicks===0?Sa(`the browser ran no animation frames in ${n} ms`):t.batchesWithoutRender>0?new e(`WEBGL_NOT_RENDERED_THIS_FRAME`,`no frame drew every visible WebGL canvas`):new e(`APPLICATION_FRAME_TIMEOUT`,`the browser ran ${t.nativeTicks} frames but the deck completed none`)}var wa=3e3;function Ta(){return new Promise((e,t)=>{let n=window.setTimeout(()=>t(Sa(`the browser ran no animation frames in ${wa} ms`)),wa);C.requestAnimationFrame(()=>C.requestAnimationFrame(()=>{window.clearTimeout(n),e()}))})}async function Ea(e,n,r){if(Y&&t(`CAPTURE_BUSY`,`release the previous capture first`),document.visibilityState===`hidden`)throw Sa(`the deck page is hidden`);na(),ia()&&aa(Mi(e)),document.compatMode!==`CSS1Compat`&&t(`QUIRKS_MODE_DOCUMENT`,`the deck document renders in quirks mode`);let i=await yi(e,n);n.aborted&&t(`CAPTURE_CANCELED`,`the capture was canceled`),Y&&t(`CAPTURE_BUSY`,`release the previous capture first`);let a=document.createElement(`style`);a.setAttribute(`data-castle-cover-freeze`,``),a.textContent=`*,*::before,*::after{animation-play-state:paused!important;transition:none!important;caret-color:transparent!important}`,document.head.append(a);let o={source:e,resources:i,freeze:a,released:!1,armed:!1,captured:!1,batchesWithoutRender:0,nativeTicks:0,nativeTickId:void 0,frameEnd:null,guard:null,armTimer:void 0,fallbackNativeId:void 0,settle:null};Y=o,Ce(!0),r?.(o);try{await Ta()}catch(e){throw X(o),e}return(o.released||n.aborted)&&(X(o),t(`CAPTURE_CANCELED`,`the capture was canceled`)),o}function X(t){if(t.released)return;let n=t.armed,r=t.settle;ha(t),t.released=!0,t.guard?.observer.disconnect(),t.freeze.remove(),Y===t&&(Y=null,Ce(!1)),Oe(),n&&r?.reject(new e(`CAPTURE_CANCELED`,`the capture was released before a frame completed`))}function Da(){Y&&X(Y)}var Oa=`castle-play-cover-result`,ka=1400,Aa=6*1024*1024,ja=5e3,Ma=25e3,Na={UNSUPPORTED_ELEMENT:`The card contains an element a cover cannot copy (an iframe, video, or script).`,UNSUPPORTED_SHADOW_ROOT:`The card uses a shadow root, which a cover cannot copy.`,UNSUPPORTED_NAMESPACE:`The card contains markup a cover cannot copy (such as MathML).`,UNSUPPORTED_SVG_ELEMENT:`The card contains SVG a cover cannot copy.`,UNSUPPORTED_SVG_REFERENCE:`The card contains SVG that references other content.`,UNSUPPORTED_EVENT_HANDLER:`The card contains SVG with an event handler.`,UNSUPPORTED_RESOURCE:`The card shows an image a cover cannot embed.`,UNSUPPORTED_RESOURCE_SCHEME:`The card shows an image a cover cannot embed.`,UNSUPPORTED_RESOURCE_REFERENCE:`The card shows an image a cover cannot embed.`,RESOURCE_ORIGIN_NOT_ALLOWED:`The card uses an image or font from a site that does not allow copying it.`,RESOURCE_FETCH_FAILED:`An image or font on the card could not be loaded for the cover.`,RESOURCE_TYPE_MISMATCH:`The card shows an animated or unsupported image format (use PNG or JPEG).`,IMAGE_NOT_LOADED:`An image on the card hasn't finished loading. Try again once it shows.`,IMAGE_NOT_READABLE:`The card shows an image from another site that the cover cannot check. Serve it from the deck itself, or allow it with CORS: an Access-Control-Allow-Origin header, plus crossorigin="anonymous" on an <img>.`,IMAGE_CHANGED:`An image on the card loads differently each time, so the cover could not copy the one on screen.`,RESOURCE_BLOCKED_BY_PAGE:`The card uses an image the deck's own content security policy blocks.`,RESOURCE_TOO_LARGE:`An image or font on the card is too large to embed.`,RESOURCE_BUDGET_EXCEEDED:`The images and fonts on the card are too large to embed.`,TOO_MANY_RESOURCES:`The card uses too many images and fonts to embed.`,UNSUPPORTED_FONT:`Text on the card uses a web font the cover cannot embed.`,UNSUPPORTED_FONT_SOURCE:`Text on the card uses a local font the cover cannot embed.`,UNSUPPORTED_FONT_STYLESHEET:`A font stylesheet on the card could not be read.`,UNSUPPORTED_FONT_DESCRIPTOR:`A font on the card uses a setting the cover cannot copy.`,TOO_MANY_FONT_FACES:`The card's fonts load more separate font files than the cover can check. Use fewer fonts, or fewer characters from large ones.`,TOO_MANY_FONT_STYLES:`Text on the card uses more fonts, weights and styles than the cover can check. Use fewer on the card.`,UNSUPPORTED_FONT_DISPLAY:`Text on the card uses a web font with font-display: optional or fallback, so the cover can't tell whether the page is showing it. Use font-display: swap or block.`,FONTS_PENDING:`Fonts were still loading. Try again in a moment.`,UNSUPPORTED_PSEUDO_RESOURCE:`The card uses a CSS pseudo-element image, which a cover cannot copy.`,UNSUPPORTED_PSEUDO_STYLE:`The card styles a first letter, first line or list marker on its own (a drop cap, say), which a cover cannot copy.`,CARD_TEXT_SELECTED:`Text on the card is selected. Click elsewhere to clear it, then try again.`,UNSUPPORTED_HIGHLIGHT:`The card highlights text with the CSS Highlight API, which a cover cannot copy.`,UNSUPPORTED_MARKER:`A list marker on the card uses a web font in a style the cover cannot check.`,UNSUPPORTED_NATIVE_CONTROL:`The card shows a native button, progress or meter bar, which a cover draws unstyled. Style it yourself (appearance: none and your own CSS).`,UNSUPPORTED_TOP_LAYER:`The card has an open modal dialog or popover, which a cover cannot copy. Close it and try again.`,UNSUPPORTED_ANCESTOR_EFFECT:`Something around the card fades, filters, blends or clips it, which a cover cannot copy.`,UNSUPPORTED_IMAGE_SET:`The card uses image-set() for an image, which a cover cannot resolve the same way.`,UNSUPPORTED_FIXED_POSITION:`The card has an element fixed to the page rather than the card, which a cover cannot place the same way.`,UNSUPPORTED_LINE_CLAMP:`The card has a line clamp the cover can't be sure is applied (its box is declared both as -webkit-box and as something else, or in a stylesheet it can't read).`,UNSUPPORTED_FORCED_COLORS:`The browser is in a forced-colors (high contrast) mode, which a cover can't copy. Turn it off to set a cover.`,UNSUPPORTED_PSEUDO_CONTENT:`The card uses CSS generated content a cover cannot copy.`,UNSUPPORTED_SCROLL_LAYOUT:`A scrolled box on the card lays its content out in a way a cover can't copy (flex, grid, sticky or pinned items, or right-to-left). Scroll it back to the top and try again.`,UNSUPPORTED_SCROLLBARS:`The card shows scrollbars, which a cover can't copy. Hide them (scrollbar-width: none) and try again.`,SENSITIVE_FORM_CONTROL:`The card shows a password field.`,UNSUPPORTED_FORM_VALUE:`The card shows a text field or menu, whose contents a cover cannot copy.`,UNSUPPORTED_NODE:`The card contains content a cover cannot copy.`,CANVAS_CONTEXT_UNKNOWN:`A canvas on the card was drawn before the capture could observe it. Restart the deck and try again.`,UNSUPPORTED_CANVAS_CONTEXT:`A canvas on the card uses a drawing mode a cover cannot read (such as WebGPU or bitmaprenderer).`,CANVAS_READBACK_FAILED:`A canvas on the card shows an image from another site, so it cannot be read.`,WEBGL_CAPTURE_REQUIRED:`The WebGL canvas was not drawn during an animation frame.`,WEBGL_NOT_RENDERED_THIS_FRAME:`The WebGL canvas was not drawn during the captured animation frame.`,WEBGL_CAPTURE_STALE:`The WebGL canvas changed while it was being copied. Try again.`,WEBGL_CONTEXT_LOST:`The WebGL canvas lost its context.`,WEBGL_CONTEXT_NOT_TRACKED:`A WebGL canvas on the card was created before the capture could observe it.`,WEBGL_NONDEFAULT_FRAMEBUFFER:`The WebGL canvas was bound to an offscreen framebuffer at the end of the frame.`,WEBGL_NONDEFAULT_READ_FRAMEBUFFER:`The WebGL canvas was bound to an offscreen framebuffer at the end of the frame.`,WEBGL_EMPTY_BUFFER:`The WebGL canvas has no pixels.`,WEBGL_READBACK_FAILED:`The WebGL canvas could not be read.`,WEBGL_TRANSPARENCY_UNSUPPORTED:`The WebGL canvas is transparent; covers need an opaque WebGL canvas.`,APPLICATION_FRAME_TIMEOUT:`The deck did not draw a new frame in time. Is it paused?`,FRAME_NOT_VISIBLE:`The browser paused the deck because it isn't on screen. Bring the Play panel fully into view and try again.`,FRAME_CHANGED_AFTER_CAPTURE:`The card changed while it was being copied. Try again.`,PACKAGE_TOO_COMPLEX:`The card has too many elements to copy.`,PACKAGE_TOO_LARGE:`The card is too large to copy.`,EMPTY_TARGET:`The card has no visible size.`,TARGET_NOT_FOUND:`No card was found to capture.`,UNSUPPORTED_ROOT_TRANSFORM:`The card is rotated or skewed, which a cover cannot copy.`,QUIRKS_MODE_DOCUMENT:`The deck's index.html has no <!doctype html>, so its layout cannot be copied exactly.`,RASTERIZE_BLOCKED:`This browser would not turn the capture into an image. Try Chrome.`,RASTERIZE_FAILED:`The capture could not be turned into an image.`,EFFECT_NOT_REPRODUCIBLE:`The card uses a shadow or blur this browser can't copy into a cover exactly (a backdrop-filter, or a shadow cut off at an edge).`,CAPTURE_UNVERIFIABLE:`This browser can't be checked copying an image or canvas on this card. Set this cover from Chrome or Edge on a computer instead.`,BUILTINS_MODIFIED:`The deck replaces built-in browser functions the cover relies on, so its capture cannot be trusted.`,BROWSER_UNSUPPORTED:`Safari and other WebKit browsers can't make a cover exactly yet. Set this cover from Chrome or Edge on a computer instead.`,RASTERIZE_MISMATCH:`This browser drew the capture differently from the page, so it wasn't used. Try Chrome.`,COVER_TOO_LARGE:`The captured image is too large to use as a cover.`,CAPTURE_BUSY:`A capture is already in progress.`,CAPTURE_TIMEOUT:`The capture took too long.`,CAPTURE_CANCELED:`The capture was canceled.`},Pa=`The deck could not be captured.`,Fa=`Safari and other WebKit browsers can't copy shadows or blur into a cover exactly. Set this cover from Chrome or Edge on a computer instead.`;function Ia(e,t=!1){return t&&e===`EFFECT_NOT_REPRODUCIBLE`?Fa:Na[e]??Pa}function La(){return[`viewbox`,`transform`,`transform-padded`]}function Ra(e){return Math.round(48*e)}var za=4;function Ba(e,t){return Math.min(2,ka/Math.max(e,t))}function Va(e,t,n){let r=document.implementation.createHTMLDocument(``);r.body.innerHTML=e.html;let{marker:i}=e;(t===`magenta`||t===`black`)&&Ha(r,t,i,null);let a=/^(magenta|black)-only-(\d+)$/.exec(t);if(a&&Ha(r,a[1],i,Number(a[2])),t===`unclip-root`)for(let e of Array.from(r.body.children))Z(e,!0,i);let o=t.startsWith(`unclip-box-`)?Number(t.slice(11)):-1;if(o>=0){for(let t of[o,...e.effectClips.clips[o].ancestors]){let e=r.body.querySelector(`[${i}-effect-clip="${t}"]`);e instanceof HTMLElement&&Z(e,!1,i)}for(let e of Array.from(r.body.children))Z(e,!0,i)}let s=r.createElementNS(E,`div`),c=t===`unclip-root`||o>=0?`visible`:`hidden`;if(s.setAttribute(`style`,`margin:0;width:${e.width}px;height:${e.height}px;overflow:${c};background:${e.backdropColor}`),e.fontCss){let t=r.createElementNS(E,`style`);t.textContent=e.fontCss,s.append(t)}if(s.append(...Array.from(r.body.childNodes)),!n)return new XMLSerializer().serializeToString(s);let l=r.createElementNS(E,`div`);return l.setAttribute(`style`,`margin:0;width:${e.width}px`),l.append(s,Bn(r,E,e.width,e.textSamples,e.effects)),new XMLSerializer().serializeToString(l)}function Z(e,t,n){let r=e.style;if(!r)return;let i=e=>e!==``&&e!==`visible`;(i(r.overflowX)||i(r.overflowY))&&(r.display===`block`&&r.setProperty(`display`,`flow-root`,`important`),r.setProperty(`overflow`,`clip`,`important`),r.setProperty(`overflow-clip-margin`,`8192px`,`important`)),t&&e.hasAttribute(`${n}-root-wrapper`)&&e.firstElementChild instanceof HTMLElement&&Z(e.firstElementChild,!1,n)}function Ha(e,t,n,r){for(let i of Array.from(e.querySelectorAll(`img[${n}-bitmap]`))){if(r!==null&&Number(i.getAttribute(`${n}-bitmap`))!==r)continue;let a=e.createElement(`span`),o=i.style;a.setAttribute(`style`,o.cssText),o.display===`inline`&&a.style.setProperty(`display`,`inline-block`,`important`);let s=Number(i.getAttribute(`${n}-bitmap`));a.style.setProperty(`background`,t===`magenta`?Cn(s):`#000000`,`important`),a.style.setProperty(`background-clip`,`content-box`,`important`),i.replaceWith(a)}}function Ua(e,t,n,r,i,a=0){let o=a/r,s=t+2*o,c=n+2*o,l=Math.round(t*r)+2*a,u=Math.round(n*r)+2*a,d=o?`<div xmlns="${E}" style="margin:0;padding:${o}px">${e}</div>`:e;return i===`viewbox`?`<svg xmlns="${Xe}" width="${l}" height="${u}" viewBox="0 0 ${s} ${c}"><foreignObject x="0" y="0" width="${s}" height="${c}">${d}</foreignObject></svg>`:`<svg xmlns="${Xe}" width="${l}" height="${u}"><foreignObject x="0" y="0" width="${l}" height="${u}"><div xmlns="${E}" style="margin:0;width:${s}px;height:${c}px;${i===`zoom`?`zoom:${r}`:`transform:scale(${r});transform-origin:0 0`}">${d}</div></foreignObject></svg>`}function Q(e,n,r){let i=document.createElement(`canvas`);i.width=n,i.height=r;let a=Reflect.apply(C.getContext,i,[`2d`]);a||t(`RASTERIZE_FAILED`,`no 2D context for the output canvas`);let o=e.padOut;return a.drawImage(e.image,-o,-o,n+2*o,r+2*o),i}async function Wa(e){let n=new Image;n.decoding=`sync`,n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;try{await n.decode()}catch(e){t(`RASTERIZE_FAILED`,`the capture did not decode as an image: ${e instanceof Error?e.message:``}`)}return n}function Ga(e){return new Promise(t=>window.setTimeout(t,e))}async function Ka(e,t){let{packet:n,scale:r}=e,i=t===`transform-padded`?`transform`:t,a=t===`transform-padded`?Ra(r):0,o=n.height+B(n.textSamples,n.effects,n.width),s=async(e,t,a)=>({image:await Wa(Ua(Va(n,e,t),n.width,t?o:n.height,r,i,a)),padOut:a}),c=n.effects.length>0;return{real:await s(`real`,!0,a),magenta:e.rasters.size?await s(`magenta`,!1,a):null,black:e.rasters.size?await s(`black`,!1,a):null,unclipRoot:c?await s(`unclip-root`,!1,Ra(r)):null,unclipBoxes:c?await Promise.all(n.effectClips.clips.map((e,t)=>s(`unclip-box-${t}`,!1,Ra(r)))):[],decode:e=>s(e,!1,a),isolated:new Map}}async function qa(e,t,n){if(!t.magenta||!t.black)return null;let r={real:n,magenta:U(Q(t.magenta,e.width,e.height)),black:U(Q(t.black,e.width,e.height))};for(let i of e.packet.bitmaps){let a=e.rasters.get(i.id);if(!a)continue;let o=rr(r,i,a,e.scale,e.webkit);if(o&&e.packet.bitmaps.length>1){let r=t.isolated.get(i.id);r||(r={magenta:await t.decode(`magenta-only-${i.id}`),black:await t.decode(`black-only-${i.id}`)},t.isolated.set(i.id,r)),o=rr({real:n,magenta:U(Q(r.magenta,e.width,e.height)),black:U(Q(r.black,e.width,e.height))},i,a,e.scale,e.webkit)}if(o)return o}return null}function Ja(e,t,n){let{packet:r,scale:i}=e;if(r.effectClips.unverifiable)return`effect clip: ${r.effectClips.unverifiable}`;if(n.unclipRoot){let a={x:0,y:0,width:r.width,height:r.height,radius:r.effectClips.rootRadius},o=$n(t,U(Q(n.unclipRoot,e.width,e.height)),[a],i,`the card`);if(o)return o}for(let[a,o]of n.unclipBoxes.entries()){let n=$n(t,U(Q(o,e.width,e.height)),[r.effectClips.clips[a]],i,`a clipped box`);if(n)return n}return null}async function Ya(e,n){let r=Q(n.real,e.width,e.fullHeight),i=Vn(r),{packet:a}=e,o=e=>(H(r),{reason:e}),s=Kn(i,a.width,a.height,e.scale,a.textSamples,a.effects,!0);if(s)return o(s);let c=Ja(e,i,n);if(c)return o(c);let l=await qa(e,n,i);if(l)return o(l);let u=document.createElement(`canvas`);u.width=e.width,u.height=e.height;let d=Reflect.apply(C.getContext,u,[`2d`]);return d||t(`RASTERIZE_FAILED`,`no 2D context for the output canvas`),d.drawImage(r,0,0,e.width,e.height,0,0,e.width,e.height),H(r),{canvas:u}}function Xa(e){e?.aborted&&t(`CAPTURE_CANCELED`,`the capture was canceled while rasterizing`)}async function Za(e,t,n){let r=await Ka(e,t),i=``;for(let a=1;a<=za;a++){Xa(n);let o=await Ya(e,r);if(`canvas`in o)return{canvas:o.canvas,attempts:a};if(o.reason===i&&!o.reason.startsWith(`font:`))break;i=o.reason,await Ga(50*2**a),a===za/2&&(r=await Ka(e,t))}return`${t}: ${i}`}function Qa(t){return new Promise((n,r)=>{try{Reflect.apply(C.toBlob,t,[t=>{t?n(t):r(new e(`RASTERIZE_FAILED`,`the canvas produced no PNG`))},`image/png`])}catch(t){r(t instanceof DOMException&&t.name===`SecurityError`?new e(`RASTERIZE_BLOCKED`,`the browser tainted the rasterized capture`):new e(`RASTERIZE_FAILED`,t instanceof Error?t.message:String(t)))}})}async function $a(e,n){let r=ia();r&&(aa(e.webkitEffects),e.unverifiedBitmaps>0&&t(`CAPTURE_UNVERIFIABLE`,`webkit: ${e.unverifiedBitmaps} image(s) or canvas(es) cannot be checked`));let i=Ba(e.width,e.height),a=Math.max(1,Math.round(e.width*i)),o=Math.max(1,Math.round(e.height*i)),s={packet:e,scale:i,width:a,height:o,fullHeight:Math.round((e.height+B(e.textSamples,e.effects,e.width))*i),rasters:await er(e.bitmaps),webkit:r},c=[];for(let r of La()){Xa(n);let i=await Za(s,r,n);if(typeof i==`string`){c.push(i);continue}let l=await Qa(i.canvas);return H(i.canvas),l.size>6291456&&t(`COVER_TOO_LARGE`,`${l.size} bytes exceeds ${Aa}`),{dataUrl:Tr(new Uint8Array(await l.arrayBuffer()),`image/png`),width:a,height:o,diagnostics:{geometry:r,attempts:i.attempts,bitmapsChecked:s.rasters.size,fontFacesChecked:e.textSamples.reduce((e,t)=>e+t.faces,0),unverifiedBitmaps:e.unverifiedBitmaps,strippedMarks:e.strippedMarks}}}c.some(e=>/^[a-z-]+: effect /.test(e))&&t(`EFFECT_NOT_REPRODUCIBLE`,c.join(`; `)),c.some(e=>/^[a-z-]+: unverifiable: /.test(e))&&t(`CAPTURE_UNVERIFIABLE`,c.join(`; `)),t(`RASTERIZE_MISMATCH`,c.join(`; `))}var $=null;function eo(){try{return window.parent===window?!1:new URLSearchParams(location.search).get(`edit`)===`0`}catch{return!1}}function to(){return document.querySelector(`#castle-card, [data-castle-card]`)??document.body}function no(e,t){try{window.parent.postMessage({type:Oa,requestId:e.requestId,...t},e.replyTo)}catch{}}function ro(t){let r=n(t),i=t instanceof e?t.message.slice(0,400):void 0;return{ok:!1,code:r,message:Ia(r,ia()),detail:i}}async function io(t){le();let n=await Ea(to(),t.controller.signal,e=>{t.session=e});try{let r=await ba(n,ja);da(n),le(),X(n);let i=await $a(r,t.controller.signal);if(t.controller.signal.aborted)throw new e(`CAPTURE_CANCELED`,`the capture was canceled`);return le(),i}finally{X(n)}}function ao(t,n){let r=0,i=new Promise((n,i)=>{r=window.setTimeout(()=>{t.controller.abort(),t.session&&X(t.session),i(new e(`CAPTURE_TIMEOUT`,`the capture exceeded its deadline`))},Ma)});return Promise.race([n,i]).finally(()=>window.clearTimeout(r))}async function oo(t,n){if($){no({requestId:t,replyTo:n},ro(new e(`CAPTURE_BUSY`,`a capture is running`)));return}let r={requestId:t,replyTo:n,controller:new AbortController,session:null};$=r;try{let e=await ao(r,io(r));no(r,{ok:!0,dataUrl:e.dataUrl,width:e.width,height:e.height,diagnostics:e.diagnostics})}catch(e){no(r,ro(e))}finally{$===r&&($=null)}}function so(e){let t=$;!t||t.requestId!==e||(t.controller.abort(),$=null,t.session&&X(t.session))}function co(e){if(e.source!==window.parent)return;let t=window.__castleShellOrigin;if(t&&e.origin!==t)return;let n=e.data;if(!n||typeof n!=`object`)return;let r=n.requestId;typeof r!=`string`||!r||r.length>64||(n.type===`castle-play-cover-capture`?oo(r,e.origin):n.type===`castle-play-cover-cancel`&&so(r))}eo()&&(Ge(),ce(),window.addEventListener(`message`,co),window.addEventListener(`pagehide`,()=>{$?.controller.abort(),$=null,Da()}))})();
@@ -70,7 +70,8 @@ export function sourcemapUrl(moduleUrl, etag) {
70
70
  return `${SOURCEMAP_ROUTE}?u=${encodeURIComponent(moduleUrl)}${version}`;
71
71
  }
72
72
  function isJavaScript(contentType) {
73
- return /^(text|application)\/javascript\b/.test(String(contentType ?? ''));
73
+ const value = Array.isArray(contentType) ? contentType.join(',') : String(contentType ?? '');
74
+ return /^(text|application)\/javascript\b/.test(value);
74
75
  }
75
76
  // Rewrites the body Vite hands to `res.end` in one piece (its `send` does exactly
76
77
  // that). Anything written in parts, or already sent, passes through untouched.
@@ -33,7 +33,10 @@ export interface GitInitDeps {
33
33
  warn(message: string): void;
34
34
  }
35
35
  export declare function isOnPath(name: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
36
- export declare function runGit(args: string[], cwd: string): GitResult;
36
+ export declare function runGit(args: string[], cwd: string, opts?: {
37
+ env?: NodeJS.ProcessEnv;
38
+ timeoutMs?: number;
39
+ }): GitResult;
37
40
  export declare function cloudKitFor(castleJson: Record<string, unknown> | null): CloudDeckKit;
38
41
  export declare const PENDING_INIT_FILE: string;
39
42
  export interface GitInitResult {
package/dist/gitRemote.js CHANGED
@@ -92,13 +92,15 @@ export function isOnPath(name, env = process.env, platform = process.platform) {
92
92
  }
93
93
  return false;
94
94
  }
95
- export function runGit(args, cwd) {
95
+ export function runGit(args, cwd, opts = {}) {
96
96
  // Force git's untranslated messages: callers match stderr text (e.g. "not a git repository"),
97
97
  // which a localized git would print in another language.
98
98
  const result = spawnSync('git', args, {
99
99
  cwd,
100
100
  encoding: 'utf-8',
101
- env: { ...process.env, LC_ALL: 'C', LANGUAGE: 'C' },
101
+ env: { ...(opts.env ?? process.env), LC_ALL: 'C', LANGUAGE: 'C' },
102
+ timeout: opts.timeoutMs,
103
+ maxBuffer: 64 * 1024 * 1024,
102
104
  });
103
105
  return {
104
106
  status: result.status,