@automataframework/shell 0.0.0-stage → 0.0.1-preview.17.sha-d17daef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3381 @@
1
+ import { createFeed, createSaves, defaultBindings, defineKind, loadGame, newState, step } from "@automataframework/core";
2
+ import { browserStore, readInputs, startLoop } from "@automataframework/core/browser";
3
+ import { frameStats, openStage } from "@automataframework/2d";
4
+ import { getContext, mount, setContext } from "svelte";
5
+ import { get, writable } from "svelte/store";
6
+ import { z } from "zod";
7
+ import "svelte/internal/init-operations";
8
+ import "svelte/internal/disclose-version";
9
+ import * as $ from "svelte/internal/client";
10
+ // \0rolldown/runtime.js
11
+ var __defProp = Object.defineProperty;
12
+ var __exportAll = (all, flags) => {
13
+ let target = Object.setPrototypeOf({}, null);
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return flags & 2 ? target : Object.preventExtensions(target);
20
+ };
21
+ // compiled/runtime.js
22
+ /** @type {any} */
23
+ var URLPattern = {};
24
+ /**
25
+ * The project's locales that have been specified in the settings.
26
+ *
27
+ * @example
28
+ * if (locales.includes(userSelectedLocale) === false) {
29
+ * throw new Error('Locale is not available');
30
+ * }
31
+ */
32
+ var locales = ["en", "es"];
33
+ /** @type {string} */
34
+ var cookieName = "PARAGLIDE_LOCALE";
35
+ /**
36
+ * @type {Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>}
37
+ */
38
+ var strategy = ["globalVariable", "baseLocale"];
39
+ /**
40
+ * Route-level strategy overrides.
41
+ *
42
+ * `match` uses URLPattern syntax.
43
+ *
44
+ * @type {Array<{
45
+ * match: string;
46
+ * strategy?: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
47
+ * exclude?: boolean;
48
+ * }>}
49
+ */
50
+ var routeStrategies = [];
51
+ var isServer = typeof window === "undefined";
52
+ /** @type {any} */ globalThis.__paraglide = globalThis.__paraglide ?? {};
53
+ /** @type {any} */ globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
54
+ /**
55
+ * This is a fallback to get started with a custom
56
+ * strategy and avoid type errors.
57
+ *
58
+ * The implementation is overwritten
59
+ * by `overwriteGetLocale()` and `defineSetLocale()`.
60
+ *
61
+ * @type {Locale | undefined}
62
+ */
63
+ var _locale;
64
+ var localeInitiallySet = false;
65
+ /**
66
+ * Get the current locale.
67
+ *
68
+ * The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
69
+ * in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
70
+ * which is set by the `paraglideMiddleware()`.
71
+ *
72
+ * @see https://paraglidejs.com/strategy - Configure locale detection strategies
73
+ *
74
+ * @example
75
+ * if (getLocale() === 'de') {
76
+ * console.log('Germany 🇩🇪');
77
+ * } else if (getLocale() === 'nl') {
78
+ * console.log('Netherlands 🇳🇱');
79
+ * }
80
+ *
81
+ * @returns {Locale} The current locale.
82
+ */
83
+ var getLocale = () => {
84
+ let strategyToUse = strategy;
85
+ if (!isServer && typeof window !== "undefined" && window.location?.href) strategyToUse = getStrategyForUrl(window.location.href);
86
+ const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : void 0);
87
+ if (resolved) {
88
+ if (!localeInitiallySet) {
89
+ _locale = resolved;
90
+ localeInitiallySet = true;
91
+ setLocale(resolved, { reload: false });
92
+ }
93
+ return resolved;
94
+ }
95
+ throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
96
+ };
97
+ /**
98
+ * @param {typeof strategy} strategyToUse
99
+ * @param {string | undefined} urlForUrlStrategy
100
+ * @returns {Locale | undefined}
101
+ */
102
+ function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
103
+ /** @type {string | undefined} */
104
+ let locale;
105
+ for (const strat of strategyToUse) {
106
+ if (strat === "baseLocale") locale = "en";
107
+ else if (strat === "globalVariable" && _locale !== void 0) locale = _locale;
108
+ else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
109
+ const handler = customClientStrategies.get(strat);
110
+ if (handler) {
111
+ const result = handler.getLocale();
112
+ if (result instanceof Promise) continue;
113
+ if (result !== void 0) return assertIsLocale(result);
114
+ }
115
+ }
116
+ const matchedLocale = toLocale(locale);
117
+ if (matchedLocale) return matchedLocale;
118
+ }
119
+ }
120
+ /**
121
+ * Navigates to the localized URL, or reloads the current page
122
+ *
123
+ * @param {string} [newLocation] The new location
124
+ */
125
+ var navigateOrReload = (newLocation) => {
126
+ if (newLocation) window.location.href = newLocation;
127
+ else window.location.reload();
128
+ };
129
+ /**
130
+ * @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise<void>} SetLocaleFn
131
+ */
132
+ /**
133
+ * Set the locale.
134
+ *
135
+ * Updates the locale using your configured strategies (cookie, localStorage, URL, etc.).
136
+ * By default, this navigates the client to the localized URL or reloads the current
137
+ * document to reflect the new locale. `reload: false` is a narrow browser-only escape
138
+ * hatch for a fully client-rendered, non-URL-routed surface that owns its reactive
139
+ * updates and document state. It does not re-render the UI or update the document.
140
+ * Do not use it for normal locale pickers, URL-routed pages, or switching an SSR,
141
+ * SSG, or hydrated document. It is incompatible with per-locale builds.
142
+ *
143
+ * If any custom strategy's `setLocale` function is async, then this function
144
+ * will become async as well.
145
+ *
146
+ * @see https://paraglidejs.com/strategy
147
+ *
148
+ * @example
149
+ * setLocale('en');
150
+ *
151
+ * @example
152
+ * setLocale('en', { reload: false });
153
+ *
154
+ * @type {SetLocaleFn}
155
+ */
156
+ var setLocale = (newLocale, options) => {
157
+ const optionsWithDefaults = {
158
+ reload: true,
159
+ ...options
160
+ };
161
+ /** @type {Locale | undefined} */
162
+ let currentLocale;
163
+ try {
164
+ currentLocale = getLocale();
165
+ } catch {}
166
+ /** @type {Array<Promise<void>>} */
167
+ const customSetLocalePromises = [];
168
+ /** @type {string | undefined} */
169
+ let newLocation = void 0;
170
+ let strategyToUse = strategy;
171
+ if (!isServer && typeof window !== "undefined" && window.location?.href) strategyToUse = getStrategyForUrl(window.location.href);
172
+ for (const strat of strategyToUse) if (strat === "globalVariable") _locale = newLocale;
173
+ else if (strat === "baseLocale") continue;
174
+ else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
175
+ const handler = customClientStrategies.get(strat);
176
+ if (handler) {
177
+ let result = handler.setLocale(newLocale);
178
+ if (result instanceof Promise) {
179
+ result = result.catch((error) => {
180
+ throw new Error(`Custom strategy "${strat}" setLocale failed.`, { cause: error });
181
+ });
182
+ customSetLocalePromises.push(result);
183
+ }
184
+ }
185
+ }
186
+ const runReload = () => {
187
+ if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) navigateOrReload(newLocation);
188
+ };
189
+ if (customSetLocalePromises.length) return Promise.all(customSetLocalePromises).then(() => {
190
+ runReload();
191
+ });
192
+ runReload();
193
+ };
194
+ /**
195
+ * The origin of the current URL.
196
+ *
197
+ * Defaults to "http://example.com" in non-browser environments. If this
198
+ * behavior is not desired, the implementation can be overwritten
199
+ * by `overwriteGetUrlOrigin()`.
200
+ *
201
+ * @type {() => string}
202
+ */
203
+ var getUrlOrigin = () => {
204
+ if (typeof window !== "undefined") return window.location.origin;
205
+ return "http://fallback.com";
206
+ };
207
+ /**
208
+ * Coerces a locale-like string to the canonical locale value used by the runtime.
209
+ *
210
+ * @param {unknown} value
211
+ * @returns {Locale | undefined}
212
+ */
213
+ function toLocale(value) {
214
+ if (typeof value !== "string") return;
215
+ const lowerValue = value.toLowerCase();
216
+ for (const locale of locales) if (locale.toLowerCase() === lowerValue) return locale;
217
+ }
218
+ /**
219
+ * Asserts that the input can be normalized to a locale.
220
+ *
221
+ * @param {unknown} input - The input to check.
222
+ * @returns {Locale} The input normalized to a Locale.
223
+ * @throws {Error} If the input is not a locale.
224
+ */
225
+ function assertIsLocale(input) {
226
+ const locale = toLocale(input);
227
+ if (locale) return locale;
228
+ throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
229
+ }
230
+ /**
231
+ * Applies the configured trailing slash policy to a URL.
232
+ *
233
+ * The root pathname always remains `/`. Query parameters and hashes are not
234
+ * modified.
235
+ *
236
+ * @param {URL} url
237
+ * @returns {URL}
238
+ */
239
+ function normalizeTrailingSlash(url) {
240
+ return url;
241
+ }
242
+ /**
243
+ * Matches a canonical URL while allowing configured patterns to retain their
244
+ * existing trailing slash style.
245
+ *
246
+ * @param {URLPattern} pattern
247
+ * @param {URL} url
248
+ * @returns {any}
249
+ */
250
+ function execUrlPattern(pattern, url) {
251
+ return pattern.exec(url.href);
252
+ }
253
+ var cookieNamePattern = cookieName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
254
+ new RegExp(`(?:^|;\\s*)${cookieNamePattern}=([^;]*)`);
255
+ /**
256
+ * Low-level URL de-localization function, primarily used in server contexts.
257
+ *
258
+ * This function is designed for server-side usage where you need precise control
259
+ * over URL de-localization, such as in middleware or request handlers. It works with
260
+ * URL objects and always returns absolute URLs.
261
+ *
262
+ * For client-side UI components, use `deLocalizeHref()` instead, which provides
263
+ * a more convenient API with relative paths.
264
+ *
265
+ * @see https://paraglidejs.com/i18n-routing
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * // Server middleware example
270
+ * app.use((req, res, next) => {
271
+ * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
272
+ * const baseUrl = deLocalizeUrl(url);
273
+ *
274
+ * // Store the base URL for later use
275
+ * req.baseUrl = baseUrl;
276
+ * next();
277
+ * });
278
+ * ```
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * // Using with URL patterns
283
+ * const url = new URL("https://example.com/de/about");
284
+ * deLocalizeUrl(url); // => URL("https://example.com/about")
285
+ *
286
+ * // Using with domain-based localization
287
+ * const url = new URL("https://de.example.com/store");
288
+ * deLocalizeUrl(url); // => URL("https://example.com/store")
289
+ * ```
290
+ *
291
+ * @param {string | URL} url - The URL to de-localize. If string, must be absolute.
292
+ * @returns {URL} The de-localized URL, always absolute
293
+ */
294
+ function deLocalizeUrl(url) {
295
+ return deLocalizeUrlDefaultPattern(url);
296
+ }
297
+ /**
298
+ * De-localizes a URL using the default pattern (/:locale/*)
299
+ * @param {string|URL} url
300
+ * @returns {URL}
301
+ */
302
+ function deLocalizeUrlDefaultPattern(url) {
303
+ const urlObj = normalizeTrailingSlash(typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url));
304
+ const pathSegments = urlObj.pathname.replace(/^\/+/, "").split("/");
305
+ if (pathSegments.length > 0 && toLocale(pathSegments[0])) urlObj.pathname = "/" + pathSegments.slice(1).join("/");
306
+ return normalizeTrailingSlash(urlObj);
307
+ }
308
+ /** @type {string | undefined} */
309
+ var cachedRouteStrategyUrl;
310
+ /** @type {{ match: string; strategy?: typeof strategy; exclude?: boolean } | undefined} */
311
+ var cachedRouteStrategy;
312
+ /**
313
+ * Match route policy against both the public URL and its canonical URL.
314
+ *
315
+ * The function is deliberately separate from variables.js: configuration is
316
+ * inert data, while canonicalization and route selection form a routing layer.
317
+ *
318
+ * @param {string | URL} url
319
+ * @returns {{ match: string; strategy?: typeof strategy; exclude?: boolean } | undefined}
320
+ */
321
+ function findMatchingRouteStrategy(url) {
322
+ if (routeStrategies.length === 0) return;
323
+ const urlString = typeof url === "string" ? url : url.href;
324
+ if (cachedRouteStrategyUrl === urlString) return cachedRouteStrategy;
325
+ const publicUrl = normalizeTrailingSlash(new URL(urlString, "http://example.com"));
326
+ const canonicalUrl = deLocalizeUrl(publicUrl);
327
+ const candidateUrls = canonicalUrl.href === publicUrl.href ? [publicUrl] : [publicUrl, canonicalUrl];
328
+ let match;
329
+ for (const candidateUrl of candidateUrls) {
330
+ for (const routeStrategy of routeStrategies) if (execUrlPattern(new URLPattern(routeStrategy.match, candidateUrl.href), candidateUrl)) {
331
+ match = routeStrategy;
332
+ break;
333
+ }
334
+ if (match) break;
335
+ }
336
+ cachedRouteStrategyUrl = urlString;
337
+ cachedRouteStrategy = match;
338
+ return match;
339
+ }
340
+ /**
341
+ * Returns the strategy to use for a specific URL.
342
+ *
343
+ * If no route strategy matches (or the matching rule is `exclude: true`),
344
+ * the global strategy is returned.
345
+ *
346
+ * @param {string | URL} url
347
+ * @returns {typeof strategy}
348
+ */
349
+ function getStrategyForUrl(url) {
350
+ const routeStrategy = findMatchingRouteStrategy(url);
351
+ if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) return routeStrategy.strategy;
352
+ return strategy;
353
+ }
354
+ /** @type {Map<string, CustomClientStrategyHandler>} */
355
+ var customClientStrategies = /* @__PURE__ */ new Map();
356
+ /**
357
+ * Checks if the given strategy is a custom strategy.
358
+ *
359
+ * @param {unknown} strategy The name of the custom strategy to validate.
360
+ * Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
361
+ * @returns {boolean} Returns true if it is a custom strategy, false otherwise.
362
+ */
363
+ function isCustomStrategy(strategy) {
364
+ return typeof strategy === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy);
365
+ }
366
+ /**
367
+ * A locale that is available in the project.
368
+ *
369
+ * @example
370
+ * setLocale(request.locale as Locale)
371
+ *
372
+ * @typedef {typeof locales[number]} Locale
373
+ */
374
+ /**
375
+ * A branded type representing a localized string.
376
+ *
377
+ * Message functions return this type instead of \`string\`, enabling TypeScript
378
+ * to distinguish translated strings from regular strings at compile time.
379
+ * This allows you to enforce that only properly localized content is used
380
+ * in your UI components.
381
+ *
382
+ * Since \`LocalizedString\` is a branded subtype of \`string\`, it remains fully
383
+ * backward compatible—you can pass it anywhere a \`string\` is expected.
384
+ *
385
+ * @example
386
+ * // Enforce localized strings in your components
387
+ * function PageTitle(props: { title: LocalizedString }) {
388
+ * return <h1>{props.title}</h1>
389
+ * }
390
+ *
391
+ * // ✅ Correct: using a message function
392
+ * <PageTitle title={m.welcome_title()} />
393
+ *
394
+ * // ❌ Type error: raw strings are not LocalizedString
395
+ * <PageTitle title="Welcome" />
396
+ *
397
+ * @example
398
+ * // LocalizedString is assignable to string (backward compatible)
399
+ * const localized: LocalizedString = m.greeting()
400
+ * const str: string = localized // ✅ works fine
401
+ *
402
+ * // But string is not assignable to LocalizedString
403
+ * const raw: LocalizedString = "Hello" // ❌ Type error
404
+ *
405
+ * @example
406
+ * // Catches accidental string concatenation
407
+ * function showMessage(msg: LocalizedString) { ... }
408
+ *
409
+ * showMessage(m.hello()) // ✅
410
+ * showMessage("Hello " + userName) // ❌ Type error
411
+ * showMessage(m.hello_user({ name: userName })) // ✅ use params instead
412
+ *
413
+ * @typedef {string & { readonly __brand: 'LocalizedString' }} LocalizedString
414
+ */
415
+ /**
416
+ * A single markup option passed to a tag instance.
417
+ *
418
+ * @typedef {{
419
+ * name: string;
420
+ * value: unknown;
421
+ * }} MessageMarkupOption
422
+ */
423
+ /**
424
+ * A single static markup attribute attached to a tag instance.
425
+ *
426
+ * @typedef {{
427
+ * name: string;
428
+ * value: string | true;
429
+ * }} MessageMarkupAttribute
430
+ */
431
+ /**
432
+ * Record of markup options for a tag instance.
433
+ *
434
+ * @typedef {Record<string, unknown>} MessageMarkupOptions
435
+ */
436
+ /**
437
+ * Record of markup attributes for a tag instance.
438
+ *
439
+ * @typedef {Record<string, string | true>} MessageMarkupAttributes
440
+ */
441
+ /**
442
+ * Type-level schema for a single markup tag.
443
+ *
444
+ * @typedef {{
445
+ * options: MessageMarkupOptions;
446
+ * attributes: MessageMarkupAttributes;
447
+ * children: boolean;
448
+ * }} MessageMarkupTag
449
+ */
450
+ /**
451
+ * Type-level schema for all markup tags in a message.
452
+ *
453
+ * @typedef {Record<string, MessageMarkupTag>} MessageMarkupSchema
454
+ */
455
+ /**
456
+ * Type-only metadata attached to compiled message functions.
457
+ *
458
+ * @template Inputs
459
+ * @template Options
460
+ * @template {MessageMarkupSchema} [Markup = MessageMarkupSchema]
461
+ * @typedef {{
462
+ * readonly __paraglide?: {
463
+ * inputs: Inputs;
464
+ * options: Options;
465
+ * markup: Markup;
466
+ * };
467
+ * }} MessageMetadata
468
+ */
469
+ /**
470
+ * A compiled, framework-neutral message part.
471
+ *
472
+ * @typedef {{
473
+ * type: "text";
474
+ * value: string;
475
+ * } | {
476
+ * type: "markup-start";
477
+ * name: string;
478
+ * options: MessageMarkupOptions;
479
+ * attributes: MessageMarkupAttributes;
480
+ * } | {
481
+ * type: "markup-end";
482
+ * name: string;
483
+ * options: MessageMarkupOptions;
484
+ * attributes: MessageMarkupAttributes;
485
+ * } | {
486
+ * type: "markup-standalone";
487
+ * name: string;
488
+ * options: MessageMarkupOptions;
489
+ * attributes: MessageMarkupAttributes;
490
+ * }} MessagePart
491
+ */
492
+ /**
493
+ * A message function is a message for a specific locale.
494
+ *
495
+ * @example
496
+ * m.hello({ name: 'world' })
497
+ *
498
+ * @typedef {(inputs?: Record<string, never>) => LocalizedString} MessageFunction
499
+ */
500
+ /**
501
+ * A message bundle function that selects the message to be returned.
502
+ *
503
+ * Uses `getLocale()` under the hood to determine the locale with an option.
504
+ *
505
+ * @template {string} T
506
+ *
507
+ * @example
508
+ * * m.hello({ name: 'world' }, { locale: "en" })
509
+ *
510
+ * @typedef {(params: Record<string, never>, options: { locale: T }) => LocalizedString} MessageBundleFunction
511
+ */
512
+ // compiled/messages/en.js
513
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
514
+ /** @typedef {{}} ArrowsInputs */
515
+ /** @typedef {{}} Askmainmenu2Inputs */
516
+ /** @typedef {{}} Askmainmenubody3Inputs */
517
+ /** @typedef {{}} Askmainmenuyes3Inputs */
518
+ /** @typedef {{}} AutosaveInputs */
519
+ /** @typedef {{}} BackInputs */
520
+ /** @typedef {{}} _ContinueInputs */
521
+ /** @typedef {{}} ContrastInputs */
522
+ /** @typedef {{}} Contrastmore1Inputs */
523
+ /** @typedef {{}} Contrastmost1Inputs */
524
+ /** @typedef {{}} Contrastnormal1Inputs */
525
+ /** @typedef {{}} ControlsInputs */
526
+ /** @typedef {{}} CreditsInputs */
527
+ /** @typedef {{}} EffectsInputs */
528
+ /** @typedef {{}} EmptyInputs */
529
+ /** @typedef {{}} Framecounter1Inputs */
530
+ /** @typedef {{}} LanguageInputs */
531
+ /** @typedef {{}} LessInputs */
532
+ /** @typedef {{}} LoseInputs */
533
+ /** @typedef {{}} Mainmenu1Inputs */
534
+ /** @typedef {{}} MasterInputs */
535
+ /** @typedef {{}} MoreInputs */
536
+ /** @typedef {{}} MotionInputs */
537
+ /** @typedef {{}} Motionless1Inputs */
538
+ /** @typedef {{}} Motionnone1Inputs */
539
+ /** @typedef {{}} Motionnormal1Inputs */
540
+ /** @typedef {{}} MusicInputs */
541
+ /** @typedef {{}} MuteInputs */
542
+ /** @typedef {{}} Newgame1Inputs */
543
+ /** @typedef {{}} OffInputs */
544
+ /** @typedef {{}} OnInputs */
545
+ /** @typedef {{}} OopsInputs */
546
+ /** @typedef {{}} Oopsbody1Inputs */
547
+ /** @typedef {{}} PausedInputs */
548
+ /** @typedef {{}} Playagain1Inputs */
549
+ /** @typedef {{}} ResumeInputs */
550
+ /** @typedef {{}} SavesInputs */
551
+ /** @typedef {{}} SettingsInputs */
552
+ /** @typedef {{}} SkipInputs */
553
+ /** @typedef {{ number: NonNullable<unknown> }} SlotInputs */
554
+ /** @typedef {{}} SoundInputs */
555
+ /** @typedef {{}} StayInputs */
556
+ /** @typedef {{}} Textbig1Inputs */
557
+ /** @typedef {{}} Textbigger1Inputs */
558
+ /** @typedef {{}} Textbiggest1Inputs */
559
+ /** @typedef {{}} Textnormal1Inputs */
560
+ /** @typedef {{}} Textsize1Inputs */
561
+ /** @typedef {{}} Tryagain1Inputs */
562
+ /** @typedef {{}} WinInputs */
563
+ /** @typedef {{}} YesInputs */
564
+ var arrows$2 = () => {
565
+ return `Arrows`;
566
+ };
567
+ var askmainmenu2$2 = () => {
568
+ return `Go to the main menu?`;
569
+ };
570
+ var askmainmenubody3$2 = () => {
571
+ return `You will lose what you did since your last save.`;
572
+ };
573
+ var askmainmenuyes3$2 = () => {
574
+ return `Go to main menu`;
575
+ };
576
+ var autosave$2 = () => {
577
+ return `Autosave`;
578
+ };
579
+ var back$2 = () => {
580
+ return `Back`;
581
+ };
582
+ var _continue$2 = () => {
583
+ return `Continue`;
584
+ };
585
+ var contrast$2 = () => {
586
+ return `More contrast`;
587
+ };
588
+ var contrastmore1$2 = () => {
589
+ return `More`;
590
+ };
591
+ var contrastmost1$2 = () => {
592
+ return `Most`;
593
+ };
594
+ var contrastnormal1$2 = () => {
595
+ return `Normal`;
596
+ };
597
+ var controls$2 = () => {
598
+ return `Controls`;
599
+ };
600
+ var credits$2 = () => {
601
+ return `Credits`;
602
+ };
603
+ var effects$2 = () => {
604
+ return `Effects`;
605
+ };
606
+ var empty$2 = () => {
607
+ return `Empty`;
608
+ };
609
+ var framecounter1$2 = () => {
610
+ return `Show frame count`;
611
+ };
612
+ var language$2 = () => {
613
+ return `Language`;
614
+ };
615
+ var less$2 = () => {
616
+ return `Less`;
617
+ };
618
+ var lose$2 = () => {
619
+ return `Out of time`;
620
+ };
621
+ var mainmenu1$2 = () => {
622
+ return `Main menu`;
623
+ };
624
+ var master$2 = () => {
625
+ return `Everything`;
626
+ };
627
+ var more$2 = () => {
628
+ return `More`;
629
+ };
630
+ var motion$2 = () => {
631
+ return `Less motion`;
632
+ };
633
+ var motionless1$2 = () => {
634
+ return `Less`;
635
+ };
636
+ var motionnone1$2 = () => {
637
+ return `None`;
638
+ };
639
+ var motionnormal1$2 = () => {
640
+ return `Normal`;
641
+ };
642
+ var music$2 = () => {
643
+ return `Music`;
644
+ };
645
+ var mute$2 = () => {
646
+ return `Mute all sound`;
647
+ };
648
+ var newgame1$2 = () => {
649
+ return `New game`;
650
+ };
651
+ var off$2 = () => {
652
+ return `Off`;
653
+ };
654
+ var on$2 = () => {
655
+ return `On`;
656
+ };
657
+ var oops$2 = () => {
658
+ return `Something went wrong`;
659
+ };
660
+ var oopsbody1$2 = () => {
661
+ return `The game hit a problem. Your saves are safe.`;
662
+ };
663
+ var paused$2 = () => {
664
+ return `Paused`;
665
+ };
666
+ var playagain1$2 = () => {
667
+ return `Play again`;
668
+ };
669
+ var resume$2 = () => {
670
+ return `Resume`;
671
+ };
672
+ var saves$2 = () => {
673
+ return `Your saves`;
674
+ };
675
+ var settings$2 = () => {
676
+ return `Settings`;
677
+ };
678
+ var skip$2 = () => {
679
+ return `Tap to skip`;
680
+ };
681
+ var slot$2 = (i) => {
682
+ return `Save ${i?.number}`;
683
+ };
684
+ var sound$2 = () => {
685
+ return `Sound`;
686
+ };
687
+ var stay$2 = () => {
688
+ return `Stay here`;
689
+ };
690
+ var textbig1$2 = () => {
691
+ return `Big`;
692
+ };
693
+ var textbigger1$2 = () => {
694
+ return `Bigger`;
695
+ };
696
+ var textbiggest1$2 = () => {
697
+ return `Biggest`;
698
+ };
699
+ var textnormal1$2 = () => {
700
+ return `Normal`;
701
+ };
702
+ var textsize1$2 = () => {
703
+ return `Bigger text`;
704
+ };
705
+ var tryagain1$2 = () => {
706
+ return `Try again`;
707
+ };
708
+ var win$2 = () => {
709
+ return `You did it!`;
710
+ };
711
+ var yes$2 = () => {
712
+ return `Yes`;
713
+ };
714
+ // compiled/messages/es.js
715
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
716
+ /** @typedef {{}} ArrowsInputs */
717
+ /** @typedef {{}} Askmainmenu2Inputs */
718
+ /** @typedef {{}} Askmainmenubody3Inputs */
719
+ /** @typedef {{}} Askmainmenuyes3Inputs */
720
+ /** @typedef {{}} AutosaveInputs */
721
+ /** @typedef {{}} BackInputs */
722
+ /** @typedef {{}} _ContinueInputs */
723
+ /** @typedef {{}} ContrastInputs */
724
+ /** @typedef {{}} Contrastmore1Inputs */
725
+ /** @typedef {{}} Contrastmost1Inputs */
726
+ /** @typedef {{}} Contrastnormal1Inputs */
727
+ /** @typedef {{}} ControlsInputs */
728
+ /** @typedef {{}} CreditsInputs */
729
+ /** @typedef {{}} EffectsInputs */
730
+ /** @typedef {{}} EmptyInputs */
731
+ /** @typedef {{}} Framecounter1Inputs */
732
+ /** @typedef {{}} LanguageInputs */
733
+ /** @typedef {{}} LessInputs */
734
+ /** @typedef {{}} LoseInputs */
735
+ /** @typedef {{}} Mainmenu1Inputs */
736
+ /** @typedef {{}} MasterInputs */
737
+ /** @typedef {{}} MoreInputs */
738
+ /** @typedef {{}} MotionInputs */
739
+ /** @typedef {{}} Motionless1Inputs */
740
+ /** @typedef {{}} Motionnone1Inputs */
741
+ /** @typedef {{}} Motionnormal1Inputs */
742
+ /** @typedef {{}} MusicInputs */
743
+ /** @typedef {{}} MuteInputs */
744
+ /** @typedef {{}} Newgame1Inputs */
745
+ /** @typedef {{}} OffInputs */
746
+ /** @typedef {{}} OnInputs */
747
+ /** @typedef {{}} OopsInputs */
748
+ /** @typedef {{}} Oopsbody1Inputs */
749
+ /** @typedef {{}} PausedInputs */
750
+ /** @typedef {{}} Playagain1Inputs */
751
+ /** @typedef {{}} ResumeInputs */
752
+ /** @typedef {{}} SavesInputs */
753
+ /** @typedef {{}} SettingsInputs */
754
+ /** @typedef {{}} SkipInputs */
755
+ /** @typedef {{ number: NonNullable<unknown> }} SlotInputs */
756
+ /** @typedef {{}} SoundInputs */
757
+ /** @typedef {{}} StayInputs */
758
+ /** @typedef {{}} Textbig1Inputs */
759
+ /** @typedef {{}} Textbigger1Inputs */
760
+ /** @typedef {{}} Textbiggest1Inputs */
761
+ /** @typedef {{}} Textnormal1Inputs */
762
+ /** @typedef {{}} Textsize1Inputs */
763
+ /** @typedef {{}} Tryagain1Inputs */
764
+ /** @typedef {{}} WinInputs */
765
+ /** @typedef {{}} YesInputs */
766
+ var arrows$1 = () => {
767
+ return `Flechas`;
768
+ };
769
+ var askmainmenu2$1 = () => {
770
+ return `¿Ir al menú principal?`;
771
+ };
772
+ var askmainmenubody3$1 = () => {
773
+ return `Perderás lo que hiciste desde tu último guardado.`;
774
+ };
775
+ var askmainmenuyes3$1 = () => {
776
+ return `Ir al menú principal`;
777
+ };
778
+ var autosave$1 = () => {
779
+ return `Guardado automático`;
780
+ };
781
+ var back$1 = () => {
782
+ return `Volver`;
783
+ };
784
+ var _continue$1 = () => {
785
+ return `Continuar`;
786
+ };
787
+ var contrast$1 = () => {
788
+ return `Más contraste`;
789
+ };
790
+ var contrastmore1$1 = () => {
791
+ return `Más`;
792
+ };
793
+ var contrastmost1$1 = () => {
794
+ return `Máximo`;
795
+ };
796
+ var contrastnormal1$1 = () => {
797
+ return `Normal`;
798
+ };
799
+ var controls$1 = () => {
800
+ return `Controles`;
801
+ };
802
+ var credits$1 = () => {
803
+ return `Créditos`;
804
+ };
805
+ var effects$1 = () => {
806
+ return `Efectos`;
807
+ };
808
+ var empty$1 = () => {
809
+ return `Vacía`;
810
+ };
811
+ var framecounter1$1 = () => {
812
+ return `Mostrar cuadros por segundo`;
813
+ };
814
+ var language$1 = () => {
815
+ return `Idioma`;
816
+ };
817
+ var less$1 = () => {
818
+ return `Menos`;
819
+ };
820
+ var lose$1 = () => {
821
+ return `Se acabó el tiempo`;
822
+ };
823
+ var mainmenu1$1 = () => {
824
+ return `Menú principal`;
825
+ };
826
+ var master$1 = () => {
827
+ return `Todo`;
828
+ };
829
+ var more$1 = () => {
830
+ return `Más`;
831
+ };
832
+ var motion$1 = () => {
833
+ return `Menos movimiento`;
834
+ };
835
+ var motionless1$1 = () => {
836
+ return `Menos`;
837
+ };
838
+ var motionnone1$1 = () => {
839
+ return `Ninguno`;
840
+ };
841
+ var motionnormal1$1 = () => {
842
+ return `Normal`;
843
+ };
844
+ var music$1 = () => {
845
+ return `Música`;
846
+ };
847
+ var mute$1 = () => {
848
+ return `Silenciar todo`;
849
+ };
850
+ var newgame1$1 = () => {
851
+ return `Juego nuevo`;
852
+ };
853
+ var off$1 = () => {
854
+ return `No`;
855
+ };
856
+ var on$1 = () => {
857
+ return `Sí`;
858
+ };
859
+ var oops$1 = () => {
860
+ return `Algo salió mal`;
861
+ };
862
+ var oopsbody1$1 = () => {
863
+ return `El juego tuvo un problema. Tus partidas están a salvo.`;
864
+ };
865
+ var paused$1 = () => {
866
+ return `En pausa`;
867
+ };
868
+ var playagain1$1 = () => {
869
+ return `Jugar otra vez`;
870
+ };
871
+ var resume$1 = () => {
872
+ return `Seguir jugando`;
873
+ };
874
+ var saves$1 = () => {
875
+ return `Tus partidas`;
876
+ };
877
+ var settings$1 = () => {
878
+ return `Ajustes`;
879
+ };
880
+ var skip$1 = () => {
881
+ return `Toca para saltar`;
882
+ };
883
+ var slot$1 = (i) => {
884
+ return `Partida ${i?.number}`;
885
+ };
886
+ var sound$1 = () => {
887
+ return `Sonido`;
888
+ };
889
+ var stay$1 = () => {
890
+ return `Quedarme aquí`;
891
+ };
892
+ var textbig1$1 = () => {
893
+ return `Grande`;
894
+ };
895
+ var textbigger1$1 = () => {
896
+ return `Más grande`;
897
+ };
898
+ var textbiggest1$1 = () => {
899
+ return `Enorme`;
900
+ };
901
+ var textnormal1$1 = () => {
902
+ return `Normal`;
903
+ };
904
+ var textsize1$1 = () => {
905
+ return `Texto más grande`;
906
+ };
907
+ var tryagain1$1 = () => {
908
+ return `Volver a intentar`;
909
+ };
910
+ var win$1 = () => {
911
+ return `¡Lo lograste!`;
912
+ };
913
+ var yes$1 = () => {
914
+ return `Sí`;
915
+ };
916
+ // compiled/messages/_index.js
917
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
918
+ /** @typedef {{}} ArrowsInputs */
919
+ /** @typedef {{}} Askmainmenu2Inputs */
920
+ /** @typedef {{}} Askmainmenubody3Inputs */
921
+ /** @typedef {{}} Askmainmenuyes3Inputs */
922
+ /** @typedef {{}} AutosaveInputs */
923
+ /** @typedef {{}} BackInputs */
924
+ /** @typedef {{}} _ContinueInputs */
925
+ /** @typedef {{}} ContrastInputs */
926
+ /** @typedef {{}} Contrastmore1Inputs */
927
+ /** @typedef {{}} Contrastmost1Inputs */
928
+ /** @typedef {{}} Contrastnormal1Inputs */
929
+ /** @typedef {{}} ControlsInputs */
930
+ /** @typedef {{}} CreditsInputs */
931
+ /** @typedef {{}} EffectsInputs */
932
+ /** @typedef {{}} EmptyInputs */
933
+ /** @typedef {{}} Framecounter1Inputs */
934
+ /** @typedef {{}} LanguageInputs */
935
+ /** @typedef {{}} LessInputs */
936
+ /** @typedef {{}} LoseInputs */
937
+ /** @typedef {{}} Mainmenu1Inputs */
938
+ /** @typedef {{}} MasterInputs */
939
+ /** @typedef {{}} MoreInputs */
940
+ /** @typedef {{}} MotionInputs */
941
+ /** @typedef {{}} Motionless1Inputs */
942
+ /** @typedef {{}} Motionnone1Inputs */
943
+ /** @typedef {{}} Motionnormal1Inputs */
944
+ /** @typedef {{}} MusicInputs */
945
+ /** @typedef {{}} MuteInputs */
946
+ /** @typedef {{}} Newgame1Inputs */
947
+ /** @typedef {{}} OffInputs */
948
+ /** @typedef {{}} OnInputs */
949
+ /** @typedef {{}} OopsInputs */
950
+ /** @typedef {{}} Oopsbody1Inputs */
951
+ /** @typedef {{}} PausedInputs */
952
+ /** @typedef {{}} Playagain1Inputs */
953
+ /** @typedef {{}} ResumeInputs */
954
+ /** @typedef {{}} SavesInputs */
955
+ /** @typedef {{}} SettingsInputs */
956
+ /** @typedef {{}} SkipInputs */
957
+ /** @typedef {{ number: NonNullable<unknown> }} SlotInputs */
958
+ /** @typedef {{}} SoundInputs */
959
+ /** @typedef {{}} StayInputs */
960
+ /** @typedef {{}} Textbig1Inputs */
961
+ /** @typedef {{}} Textbigger1Inputs */
962
+ /** @typedef {{}} Textbiggest1Inputs */
963
+ /** @typedef {{}} Textnormal1Inputs */
964
+ /** @typedef {{}} Textsize1Inputs */
965
+ /** @typedef {{}} Tryagain1Inputs */
966
+ /** @typedef {{}} WinInputs */
967
+ /** @typedef {{}} YesInputs */
968
+ var _index_exports = /* @__PURE__ */ __exportAll({
969
+ arrows: () => arrows,
970
+ askMainMenu: () => askmainmenu2,
971
+ askMainMenuBody: () => askmainmenubody3,
972
+ askMainMenuYes: () => askmainmenuyes3,
973
+ autosave: () => autosave,
974
+ back: () => back,
975
+ continue: () => _continue,
976
+ contrast: () => contrast,
977
+ contrastMore: () => contrastmore1,
978
+ contrastMost: () => contrastmost1,
979
+ contrastNormal: () => contrastnormal1,
980
+ controls: () => controls,
981
+ credits: () => credits,
982
+ effects: () => effects,
983
+ empty: () => empty,
984
+ frameCounter: () => framecounter1,
985
+ language: () => language,
986
+ less: () => less,
987
+ lose: () => lose,
988
+ mainMenu: () => mainmenu1,
989
+ master: () => master,
990
+ more: () => more,
991
+ motion: () => motion,
992
+ motionLess: () => motionless1,
993
+ motionNone: () => motionnone1,
994
+ motionNormal: () => motionnormal1,
995
+ music: () => music,
996
+ mute: () => mute,
997
+ newGame: () => newgame1,
998
+ off: () => off,
999
+ on: () => on,
1000
+ oops: () => oops,
1001
+ oopsBody: () => oopsbody1,
1002
+ paused: () => paused,
1003
+ playAgain: () => playagain1,
1004
+ resume: () => resume,
1005
+ saves: () => saves,
1006
+ settings: () => settings,
1007
+ skip: () => skip,
1008
+ slot: () => slot,
1009
+ sound: () => sound,
1010
+ stay: () => stay,
1011
+ textBig: () => textbig1,
1012
+ textBigger: () => textbigger1,
1013
+ textBiggest: () => textbiggest1,
1014
+ textNormal: () => textnormal1,
1015
+ textSize: () => textsize1,
1016
+ tryAgain: () => tryagain1,
1017
+ win: () => win,
1018
+ yes: () => yes
1019
+ });
1020
+ /**
1021
+ * | output |
1022
+ * | --- |
1023
+ * | "Arrows" |
1024
+ *
1025
+ * @param {ArrowsInputs} inputs
1026
+ * @param {{ locale?: "en" | "es" }} options
1027
+ * @returns {LocalizedString}
1028
+ */
1029
+ var arrows = ((inputs = {}, options = {}) => {
1030
+ if ((options.locale ?? getLocale()) === "es") return arrows$1(inputs);
1031
+ return arrows$2(inputs);
1032
+ });
1033
+ /**
1034
+ * | output |
1035
+ * | --- |
1036
+ * | "Go to the main menu?" |
1037
+ *
1038
+ * @param {Askmainmenu2Inputs} inputs
1039
+ * @param {{ locale?: "en" | "es" }} options
1040
+ * @returns {LocalizedString}
1041
+ */
1042
+ var askmainmenu2 = ((inputs = {}, options = {}) => {
1043
+ if ((options.locale ?? getLocale()) === "es") return askmainmenu2$1(inputs);
1044
+ return askmainmenu2$2(inputs);
1045
+ });
1046
+ /**
1047
+ * | output |
1048
+ * | --- |
1049
+ * | "You will lose what you did since your last save." |
1050
+ *
1051
+ * @param {Askmainmenubody3Inputs} inputs
1052
+ * @param {{ locale?: "en" | "es" }} options
1053
+ * @returns {LocalizedString}
1054
+ */
1055
+ var askmainmenubody3 = ((inputs = {}, options = {}) => {
1056
+ if ((options.locale ?? getLocale()) === "es") return askmainmenubody3$1(inputs);
1057
+ return askmainmenubody3$2(inputs);
1058
+ });
1059
+ /**
1060
+ * | output |
1061
+ * | --- |
1062
+ * | "Go to main menu" |
1063
+ *
1064
+ * @param {Askmainmenuyes3Inputs} inputs
1065
+ * @param {{ locale?: "en" | "es" }} options
1066
+ * @returns {LocalizedString}
1067
+ */
1068
+ var askmainmenuyes3 = ((inputs = {}, options = {}) => {
1069
+ if ((options.locale ?? getLocale()) === "es") return askmainmenuyes3$1(inputs);
1070
+ return askmainmenuyes3$2(inputs);
1071
+ });
1072
+ /**
1073
+ * | output |
1074
+ * | --- |
1075
+ * | "Autosave" |
1076
+ *
1077
+ * @param {AutosaveInputs} inputs
1078
+ * @param {{ locale?: "en" | "es" }} options
1079
+ * @returns {LocalizedString}
1080
+ */
1081
+ var autosave = ((inputs = {}, options = {}) => {
1082
+ if ((options.locale ?? getLocale()) === "es") return autosave$1(inputs);
1083
+ return autosave$2(inputs);
1084
+ });
1085
+ /**
1086
+ * | output |
1087
+ * | --- |
1088
+ * | "Back" |
1089
+ *
1090
+ * @param {BackInputs} inputs
1091
+ * @param {{ locale?: "en" | "es" }} options
1092
+ * @returns {LocalizedString}
1093
+ */
1094
+ var back = ((inputs = {}, options = {}) => {
1095
+ if ((options.locale ?? getLocale()) === "es") return back$1(inputs);
1096
+ return back$2(inputs);
1097
+ });
1098
+ /**
1099
+ * | output |
1100
+ * | --- |
1101
+ * | "Continue" |
1102
+ *
1103
+ * @param {_ContinueInputs} inputs
1104
+ * @param {{ locale?: "en" | "es" }} options
1105
+ * @returns {LocalizedString}
1106
+ */
1107
+ var _continue = ((inputs = {}, options = {}) => {
1108
+ if ((options.locale ?? getLocale()) === "es") return _continue$1(inputs);
1109
+ return _continue$2(inputs);
1110
+ });
1111
+ /**
1112
+ * | output |
1113
+ * | --- |
1114
+ * | "More contrast" |
1115
+ *
1116
+ * @param {ContrastInputs} inputs
1117
+ * @param {{ locale?: "en" | "es" }} options
1118
+ * @returns {LocalizedString}
1119
+ */
1120
+ var contrast = ((inputs = {}, options = {}) => {
1121
+ if ((options.locale ?? getLocale()) === "es") return contrast$1(inputs);
1122
+ return contrast$2(inputs);
1123
+ });
1124
+ /**
1125
+ * | output |
1126
+ * | --- |
1127
+ * | "More" |
1128
+ *
1129
+ * @param {Contrastmore1Inputs} inputs
1130
+ * @param {{ locale?: "en" | "es" }} options
1131
+ * @returns {LocalizedString}
1132
+ */
1133
+ var contrastmore1 = ((inputs = {}, options = {}) => {
1134
+ if ((options.locale ?? getLocale()) === "es") return contrastmore1$1(inputs);
1135
+ return contrastmore1$2(inputs);
1136
+ });
1137
+ /**
1138
+ * | output |
1139
+ * | --- |
1140
+ * | "Most" |
1141
+ *
1142
+ * @param {Contrastmost1Inputs} inputs
1143
+ * @param {{ locale?: "en" | "es" }} options
1144
+ * @returns {LocalizedString}
1145
+ */
1146
+ var contrastmost1 = ((inputs = {}, options = {}) => {
1147
+ if ((options.locale ?? getLocale()) === "es") return contrastmost1$1(inputs);
1148
+ return contrastmost1$2(inputs);
1149
+ });
1150
+ /**
1151
+ * | output |
1152
+ * | --- |
1153
+ * | "Normal" |
1154
+ *
1155
+ * @param {Contrastnormal1Inputs} inputs
1156
+ * @param {{ locale?: "en" | "es" }} options
1157
+ * @returns {LocalizedString}
1158
+ */
1159
+ var contrastnormal1 = ((inputs = {}, options = {}) => {
1160
+ if ((options.locale ?? getLocale()) === "es") return contrastnormal1$1(inputs);
1161
+ return contrastnormal1$2(inputs);
1162
+ });
1163
+ /**
1164
+ * | output |
1165
+ * | --- |
1166
+ * | "Controls" |
1167
+ *
1168
+ * @param {ControlsInputs} inputs
1169
+ * @param {{ locale?: "en" | "es" }} options
1170
+ * @returns {LocalizedString}
1171
+ */
1172
+ var controls = ((inputs = {}, options = {}) => {
1173
+ if ((options.locale ?? getLocale()) === "es") return controls$1(inputs);
1174
+ return controls$2(inputs);
1175
+ });
1176
+ /**
1177
+ * | output |
1178
+ * | --- |
1179
+ * | "Credits" |
1180
+ *
1181
+ * @param {CreditsInputs} inputs
1182
+ * @param {{ locale?: "en" | "es" }} options
1183
+ * @returns {LocalizedString}
1184
+ */
1185
+ var credits = ((inputs = {}, options = {}) => {
1186
+ if ((options.locale ?? getLocale()) === "es") return credits$1(inputs);
1187
+ return credits$2(inputs);
1188
+ });
1189
+ /**
1190
+ * | output |
1191
+ * | --- |
1192
+ * | "Effects" |
1193
+ *
1194
+ * @param {EffectsInputs} inputs
1195
+ * @param {{ locale?: "en" | "es" }} options
1196
+ * @returns {LocalizedString}
1197
+ */
1198
+ var effects = ((inputs = {}, options = {}) => {
1199
+ if ((options.locale ?? getLocale()) === "es") return effects$1(inputs);
1200
+ return effects$2(inputs);
1201
+ });
1202
+ /**
1203
+ * | output |
1204
+ * | --- |
1205
+ * | "Empty" |
1206
+ *
1207
+ * @param {EmptyInputs} inputs
1208
+ * @param {{ locale?: "en" | "es" }} options
1209
+ * @returns {LocalizedString}
1210
+ */
1211
+ var empty = ((inputs = {}, options = {}) => {
1212
+ if ((options.locale ?? getLocale()) === "es") return empty$1(inputs);
1213
+ return empty$2(inputs);
1214
+ });
1215
+ /**
1216
+ * | output |
1217
+ * | --- |
1218
+ * | "Show frame count" |
1219
+ *
1220
+ * @param {Framecounter1Inputs} inputs
1221
+ * @param {{ locale?: "en" | "es" }} options
1222
+ * @returns {LocalizedString}
1223
+ */
1224
+ var framecounter1 = ((inputs = {}, options = {}) => {
1225
+ if ((options.locale ?? getLocale()) === "es") return framecounter1$1(inputs);
1226
+ return framecounter1$2(inputs);
1227
+ });
1228
+ /**
1229
+ * | output |
1230
+ * | --- |
1231
+ * | "Language" |
1232
+ *
1233
+ * @param {LanguageInputs} inputs
1234
+ * @param {{ locale?: "en" | "es" }} options
1235
+ * @returns {LocalizedString}
1236
+ */
1237
+ var language = ((inputs = {}, options = {}) => {
1238
+ if ((options.locale ?? getLocale()) === "es") return language$1(inputs);
1239
+ return language$2(inputs);
1240
+ });
1241
+ /**
1242
+ * | output |
1243
+ * | --- |
1244
+ * | "Less" |
1245
+ *
1246
+ * @param {LessInputs} inputs
1247
+ * @param {{ locale?: "en" | "es" }} options
1248
+ * @returns {LocalizedString}
1249
+ */
1250
+ var less = ((inputs = {}, options = {}) => {
1251
+ if ((options.locale ?? getLocale()) === "es") return less$1(inputs);
1252
+ return less$2(inputs);
1253
+ });
1254
+ /**
1255
+ * | output |
1256
+ * | --- |
1257
+ * | "Out of time" |
1258
+ *
1259
+ * @param {LoseInputs} inputs
1260
+ * @param {{ locale?: "en" | "es" }} options
1261
+ * @returns {LocalizedString}
1262
+ */
1263
+ var lose = ((inputs = {}, options = {}) => {
1264
+ if ((options.locale ?? getLocale()) === "es") return lose$1(inputs);
1265
+ return lose$2(inputs);
1266
+ });
1267
+ /**
1268
+ * | output |
1269
+ * | --- |
1270
+ * | "Main menu" |
1271
+ *
1272
+ * @param {Mainmenu1Inputs} inputs
1273
+ * @param {{ locale?: "en" | "es" }} options
1274
+ * @returns {LocalizedString}
1275
+ */
1276
+ var mainmenu1 = ((inputs = {}, options = {}) => {
1277
+ if ((options.locale ?? getLocale()) === "es") return mainmenu1$1(inputs);
1278
+ return mainmenu1$2(inputs);
1279
+ });
1280
+ /**
1281
+ * | output |
1282
+ * | --- |
1283
+ * | "Everything" |
1284
+ *
1285
+ * @param {MasterInputs} inputs
1286
+ * @param {{ locale?: "en" | "es" }} options
1287
+ * @returns {LocalizedString}
1288
+ */
1289
+ var master = ((inputs = {}, options = {}) => {
1290
+ if ((options.locale ?? getLocale()) === "es") return master$1(inputs);
1291
+ return master$2(inputs);
1292
+ });
1293
+ /**
1294
+ * | output |
1295
+ * | --- |
1296
+ * | "More" |
1297
+ *
1298
+ * @param {MoreInputs} inputs
1299
+ * @param {{ locale?: "en" | "es" }} options
1300
+ * @returns {LocalizedString}
1301
+ */
1302
+ var more = ((inputs = {}, options = {}) => {
1303
+ if ((options.locale ?? getLocale()) === "es") return more$1(inputs);
1304
+ return more$2(inputs);
1305
+ });
1306
+ /**
1307
+ * | output |
1308
+ * | --- |
1309
+ * | "Less motion" |
1310
+ *
1311
+ * @param {MotionInputs} inputs
1312
+ * @param {{ locale?: "en" | "es" }} options
1313
+ * @returns {LocalizedString}
1314
+ */
1315
+ var motion = ((inputs = {}, options = {}) => {
1316
+ if ((options.locale ?? getLocale()) === "es") return motion$1(inputs);
1317
+ return motion$2(inputs);
1318
+ });
1319
+ /**
1320
+ * | output |
1321
+ * | --- |
1322
+ * | "Less" |
1323
+ *
1324
+ * @param {Motionless1Inputs} inputs
1325
+ * @param {{ locale?: "en" | "es" }} options
1326
+ * @returns {LocalizedString}
1327
+ */
1328
+ var motionless1 = ((inputs = {}, options = {}) => {
1329
+ if ((options.locale ?? getLocale()) === "es") return motionless1$1(inputs);
1330
+ return motionless1$2(inputs);
1331
+ });
1332
+ /**
1333
+ * | output |
1334
+ * | --- |
1335
+ * | "None" |
1336
+ *
1337
+ * @param {Motionnone1Inputs} inputs
1338
+ * @param {{ locale?: "en" | "es" }} options
1339
+ * @returns {LocalizedString}
1340
+ */
1341
+ var motionnone1 = ((inputs = {}, options = {}) => {
1342
+ if ((options.locale ?? getLocale()) === "es") return motionnone1$1(inputs);
1343
+ return motionnone1$2(inputs);
1344
+ });
1345
+ /**
1346
+ * | output |
1347
+ * | --- |
1348
+ * | "Normal" |
1349
+ *
1350
+ * @param {Motionnormal1Inputs} inputs
1351
+ * @param {{ locale?: "en" | "es" }} options
1352
+ * @returns {LocalizedString}
1353
+ */
1354
+ var motionnormal1 = ((inputs = {}, options = {}) => {
1355
+ if ((options.locale ?? getLocale()) === "es") return motionnormal1$1(inputs);
1356
+ return motionnormal1$2(inputs);
1357
+ });
1358
+ /**
1359
+ * | output |
1360
+ * | --- |
1361
+ * | "Music" |
1362
+ *
1363
+ * @param {MusicInputs} inputs
1364
+ * @param {{ locale?: "en" | "es" }} options
1365
+ * @returns {LocalizedString}
1366
+ */
1367
+ var music = ((inputs = {}, options = {}) => {
1368
+ if ((options.locale ?? getLocale()) === "es") return music$1(inputs);
1369
+ return music$2(inputs);
1370
+ });
1371
+ /**
1372
+ * | output |
1373
+ * | --- |
1374
+ * | "Mute all sound" |
1375
+ *
1376
+ * @param {MuteInputs} inputs
1377
+ * @param {{ locale?: "en" | "es" }} options
1378
+ * @returns {LocalizedString}
1379
+ */
1380
+ var mute = ((inputs = {}, options = {}) => {
1381
+ if ((options.locale ?? getLocale()) === "es") return mute$1(inputs);
1382
+ return mute$2(inputs);
1383
+ });
1384
+ /**
1385
+ * | output |
1386
+ * | --- |
1387
+ * | "New game" |
1388
+ *
1389
+ * @param {Newgame1Inputs} inputs
1390
+ * @param {{ locale?: "en" | "es" }} options
1391
+ * @returns {LocalizedString}
1392
+ */
1393
+ var newgame1 = ((inputs = {}, options = {}) => {
1394
+ if ((options.locale ?? getLocale()) === "es") return newgame1$1(inputs);
1395
+ return newgame1$2(inputs);
1396
+ });
1397
+ /**
1398
+ * | output |
1399
+ * | --- |
1400
+ * | "Off" |
1401
+ *
1402
+ * @param {OffInputs} inputs
1403
+ * @param {{ locale?: "en" | "es" }} options
1404
+ * @returns {LocalizedString}
1405
+ */
1406
+ var off = ((inputs = {}, options = {}) => {
1407
+ if ((options.locale ?? getLocale()) === "es") return off$1(inputs);
1408
+ return off$2(inputs);
1409
+ });
1410
+ /**
1411
+ * | output |
1412
+ * | --- |
1413
+ * | "On" |
1414
+ *
1415
+ * @param {OnInputs} inputs
1416
+ * @param {{ locale?: "en" | "es" }} options
1417
+ * @returns {LocalizedString}
1418
+ */
1419
+ var on = ((inputs = {}, options = {}) => {
1420
+ if ((options.locale ?? getLocale()) === "es") return on$1(inputs);
1421
+ return on$2(inputs);
1422
+ });
1423
+ /**
1424
+ * | output |
1425
+ * | --- |
1426
+ * | "Something went wrong" |
1427
+ *
1428
+ * @param {OopsInputs} inputs
1429
+ * @param {{ locale?: "en" | "es" }} options
1430
+ * @returns {LocalizedString}
1431
+ */
1432
+ var oops = ((inputs = {}, options = {}) => {
1433
+ if ((options.locale ?? getLocale()) === "es") return oops$1(inputs);
1434
+ return oops$2(inputs);
1435
+ });
1436
+ /**
1437
+ * | output |
1438
+ * | --- |
1439
+ * | "The game hit a problem. Your saves are safe." |
1440
+ *
1441
+ * @param {Oopsbody1Inputs} inputs
1442
+ * @param {{ locale?: "en" | "es" }} options
1443
+ * @returns {LocalizedString}
1444
+ */
1445
+ var oopsbody1 = ((inputs = {}, options = {}) => {
1446
+ if ((options.locale ?? getLocale()) === "es") return oopsbody1$1(inputs);
1447
+ return oopsbody1$2(inputs);
1448
+ });
1449
+ /**
1450
+ * | output |
1451
+ * | --- |
1452
+ * | "Paused" |
1453
+ *
1454
+ * @param {PausedInputs} inputs
1455
+ * @param {{ locale?: "en" | "es" }} options
1456
+ * @returns {LocalizedString}
1457
+ */
1458
+ var paused = ((inputs = {}, options = {}) => {
1459
+ if ((options.locale ?? getLocale()) === "es") return paused$1(inputs);
1460
+ return paused$2(inputs);
1461
+ });
1462
+ /**
1463
+ * | output |
1464
+ * | --- |
1465
+ * | "Play again" |
1466
+ *
1467
+ * @param {Playagain1Inputs} inputs
1468
+ * @param {{ locale?: "en" | "es" }} options
1469
+ * @returns {LocalizedString}
1470
+ */
1471
+ var playagain1 = ((inputs = {}, options = {}) => {
1472
+ if ((options.locale ?? getLocale()) === "es") return playagain1$1(inputs);
1473
+ return playagain1$2(inputs);
1474
+ });
1475
+ /**
1476
+ * | output |
1477
+ * | --- |
1478
+ * | "Resume" |
1479
+ *
1480
+ * @param {ResumeInputs} inputs
1481
+ * @param {{ locale?: "en" | "es" }} options
1482
+ * @returns {LocalizedString}
1483
+ */
1484
+ var resume = ((inputs = {}, options = {}) => {
1485
+ if ((options.locale ?? getLocale()) === "es") return resume$1(inputs);
1486
+ return resume$2(inputs);
1487
+ });
1488
+ /**
1489
+ * | output |
1490
+ * | --- |
1491
+ * | "Your saves" |
1492
+ *
1493
+ * @param {SavesInputs} inputs
1494
+ * @param {{ locale?: "en" | "es" }} options
1495
+ * @returns {LocalizedString}
1496
+ */
1497
+ var saves = ((inputs = {}, options = {}) => {
1498
+ if ((options.locale ?? getLocale()) === "es") return saves$1(inputs);
1499
+ return saves$2(inputs);
1500
+ });
1501
+ /**
1502
+ * | output |
1503
+ * | --- |
1504
+ * | "Settings" |
1505
+ *
1506
+ * @param {SettingsInputs} inputs
1507
+ * @param {{ locale?: "en" | "es" }} options
1508
+ * @returns {LocalizedString}
1509
+ */
1510
+ var settings = ((inputs = {}, options = {}) => {
1511
+ if ((options.locale ?? getLocale()) === "es") return settings$1(inputs);
1512
+ return settings$2(inputs);
1513
+ });
1514
+ /**
1515
+ * | output |
1516
+ * | --- |
1517
+ * | "Tap to skip" |
1518
+ *
1519
+ * @param {SkipInputs} inputs
1520
+ * @param {{ locale?: "en" | "es" }} options
1521
+ * @returns {LocalizedString}
1522
+ */
1523
+ var skip = ((inputs = {}, options = {}) => {
1524
+ if ((options.locale ?? getLocale()) === "es") return skip$1(inputs);
1525
+ return skip$2(inputs);
1526
+ });
1527
+ /**
1528
+ * | output |
1529
+ * | --- |
1530
+ * | "Save {number}" |
1531
+ *
1532
+ * @param {SlotInputs} inputs
1533
+ * @param {{ locale?: "en" | "es" }} options
1534
+ * @returns {LocalizedString}
1535
+ */
1536
+ var slot = ((inputs, options = {}) => {
1537
+ if ((options.locale ?? getLocale()) === "es") return slot$1(inputs);
1538
+ return slot$2(inputs);
1539
+ });
1540
+ /**
1541
+ * | output |
1542
+ * | --- |
1543
+ * | "Sound" |
1544
+ *
1545
+ * @param {SoundInputs} inputs
1546
+ * @param {{ locale?: "en" | "es" }} options
1547
+ * @returns {LocalizedString}
1548
+ */
1549
+ var sound = ((inputs = {}, options = {}) => {
1550
+ if ((options.locale ?? getLocale()) === "es") return sound$1(inputs);
1551
+ return sound$2(inputs);
1552
+ });
1553
+ /**
1554
+ * | output |
1555
+ * | --- |
1556
+ * | "Stay here" |
1557
+ *
1558
+ * @param {StayInputs} inputs
1559
+ * @param {{ locale?: "en" | "es" }} options
1560
+ * @returns {LocalizedString}
1561
+ */
1562
+ var stay = ((inputs = {}, options = {}) => {
1563
+ if ((options.locale ?? getLocale()) === "es") return stay$1(inputs);
1564
+ return stay$2(inputs);
1565
+ });
1566
+ /**
1567
+ * | output |
1568
+ * | --- |
1569
+ * | "Big" |
1570
+ *
1571
+ * @param {Textbig1Inputs} inputs
1572
+ * @param {{ locale?: "en" | "es" }} options
1573
+ * @returns {LocalizedString}
1574
+ */
1575
+ var textbig1 = ((inputs = {}, options = {}) => {
1576
+ if ((options.locale ?? getLocale()) === "es") return textbig1$1(inputs);
1577
+ return textbig1$2(inputs);
1578
+ });
1579
+ /**
1580
+ * | output |
1581
+ * | --- |
1582
+ * | "Bigger" |
1583
+ *
1584
+ * @param {Textbigger1Inputs} inputs
1585
+ * @param {{ locale?: "en" | "es" }} options
1586
+ * @returns {LocalizedString}
1587
+ */
1588
+ var textbigger1 = ((inputs = {}, options = {}) => {
1589
+ if ((options.locale ?? getLocale()) === "es") return textbigger1$1(inputs);
1590
+ return textbigger1$2(inputs);
1591
+ });
1592
+ /**
1593
+ * | output |
1594
+ * | --- |
1595
+ * | "Biggest" |
1596
+ *
1597
+ * @param {Textbiggest1Inputs} inputs
1598
+ * @param {{ locale?: "en" | "es" }} options
1599
+ * @returns {LocalizedString}
1600
+ */
1601
+ var textbiggest1 = ((inputs = {}, options = {}) => {
1602
+ if ((options.locale ?? getLocale()) === "es") return textbiggest1$1(inputs);
1603
+ return textbiggest1$2(inputs);
1604
+ });
1605
+ /**
1606
+ * | output |
1607
+ * | --- |
1608
+ * | "Normal" |
1609
+ *
1610
+ * @param {Textnormal1Inputs} inputs
1611
+ * @param {{ locale?: "en" | "es" }} options
1612
+ * @returns {LocalizedString}
1613
+ */
1614
+ var textnormal1 = ((inputs = {}, options = {}) => {
1615
+ if ((options.locale ?? getLocale()) === "es") return textnormal1$1(inputs);
1616
+ return textnormal1$2(inputs);
1617
+ });
1618
+ /**
1619
+ * | output |
1620
+ * | --- |
1621
+ * | "Bigger text" |
1622
+ *
1623
+ * @param {Textsize1Inputs} inputs
1624
+ * @param {{ locale?: "en" | "es" }} options
1625
+ * @returns {LocalizedString}
1626
+ */
1627
+ var textsize1 = ((inputs = {}, options = {}) => {
1628
+ if ((options.locale ?? getLocale()) === "es") return textsize1$1(inputs);
1629
+ return textsize1$2(inputs);
1630
+ });
1631
+ /**
1632
+ * | output |
1633
+ * | --- |
1634
+ * | "Try again" |
1635
+ *
1636
+ * @param {Tryagain1Inputs} inputs
1637
+ * @param {{ locale?: "en" | "es" }} options
1638
+ * @returns {LocalizedString}
1639
+ */
1640
+ var tryagain1 = ((inputs = {}, options = {}) => {
1641
+ if ((options.locale ?? getLocale()) === "es") return tryagain1$1(inputs);
1642
+ return tryagain1$2(inputs);
1643
+ });
1644
+ /**
1645
+ * | output |
1646
+ * | --- |
1647
+ * | "You did it!" |
1648
+ *
1649
+ * @param {WinInputs} inputs
1650
+ * @param {{ locale?: "en" | "es" }} options
1651
+ * @returns {LocalizedString}
1652
+ */
1653
+ var win = ((inputs = {}, options = {}) => {
1654
+ if ((options.locale ?? getLocale()) === "es") return win$1(inputs);
1655
+ return win$2(inputs);
1656
+ });
1657
+ /**
1658
+ * | output |
1659
+ * | --- |
1660
+ * | "Yes" |
1661
+ *
1662
+ * @param {YesInputs} inputs
1663
+ * @param {{ locale?: "en" | "es" }} options
1664
+ * @returns {LocalizedString}
1665
+ */
1666
+ var yes = ((inputs = {}, options = {}) => {
1667
+ if ((options.locale ?? getLocale()) === "es") return yes$1(inputs);
1668
+ return yes$2(inputs);
1669
+ });
1670
+ // compiled/messages.js
1671
+ var messages_exports = /* @__PURE__ */ __exportAll({
1672
+ arrows: () => arrows,
1673
+ askMainMenu: () => askmainmenu2,
1674
+ askMainMenuBody: () => askmainmenubody3,
1675
+ askMainMenuYes: () => askmainmenuyes3,
1676
+ autosave: () => autosave,
1677
+ back: () => back,
1678
+ continue: () => _continue,
1679
+ contrast: () => contrast,
1680
+ contrastMore: () => contrastmore1,
1681
+ contrastMost: () => contrastmost1,
1682
+ contrastNormal: () => contrastnormal1,
1683
+ controls: () => controls,
1684
+ credits: () => credits,
1685
+ effects: () => effects,
1686
+ empty: () => empty,
1687
+ frameCounter: () => framecounter1,
1688
+ language: () => language,
1689
+ less: () => less,
1690
+ lose: () => lose,
1691
+ m: () => _index_exports,
1692
+ mainMenu: () => mainmenu1,
1693
+ master: () => master,
1694
+ more: () => more,
1695
+ motion: () => motion,
1696
+ motionLess: () => motionless1,
1697
+ motionNone: () => motionnone1,
1698
+ motionNormal: () => motionnormal1,
1699
+ music: () => music,
1700
+ mute: () => mute,
1701
+ newGame: () => newgame1,
1702
+ off: () => off,
1703
+ on: () => on,
1704
+ oops: () => oops,
1705
+ oopsBody: () => oopsbody1,
1706
+ paused: () => paused,
1707
+ playAgain: () => playagain1,
1708
+ resume: () => resume,
1709
+ saves: () => saves,
1710
+ settings: () => settings,
1711
+ skip: () => skip,
1712
+ slot: () => slot,
1713
+ sound: () => sound,
1714
+ stay: () => stay,
1715
+ textBig: () => textbig1,
1716
+ textBigger: () => textbigger1,
1717
+ textBiggest: () => textbiggest1,
1718
+ textNormal: () => textnormal1,
1719
+ textSize: () => textsize1,
1720
+ tryAgain: () => tryagain1,
1721
+ win: () => win,
1722
+ yes: () => yes
1723
+ });
1724
+ // src/features/error/error.ts
1725
+ /** The one screen the shell holds itself: what shows when the game's own code fails. Its words are the shell's. */
1726
+ var somethingWentWrong = {
1727
+ format: 1,
1728
+ id: "something-went-wrong",
1729
+ kind: "screen",
1730
+ above: "gameName",
1731
+ title: "oops",
1732
+ items: [
1733
+ {
1734
+ type: "text",
1735
+ words: "oopsBody"
1736
+ },
1737
+ {
1738
+ type: "button",
1739
+ id: "try-again",
1740
+ label: "tryAgain",
1741
+ does: "retry",
1742
+ main: true
1743
+ },
1744
+ {
1745
+ type: "button",
1746
+ id: "main-menu",
1747
+ label: "mainMenu",
1748
+ does: "main-menu"
1749
+ }
1750
+ ]
1751
+ };
1752
+ /** The built-in question the flow asks with `{ ask, yes }`: the question's word is the title, its `Body` the line under it. */
1753
+ function questionScreen(word, has) {
1754
+ return {
1755
+ format: 1,
1756
+ id: `ask-${word}`,
1757
+ kind: "screen",
1758
+ title: word,
1759
+ items: [
1760
+ ...has(`${word}Body`) ? [{
1761
+ type: "text",
1762
+ words: `${word}Body`
1763
+ }] : [],
1764
+ {
1765
+ type: "button",
1766
+ id: "stay",
1767
+ label: "stay",
1768
+ does: "ask-no",
1769
+ main: true
1770
+ },
1771
+ {
1772
+ type: "button",
1773
+ id: "yes",
1774
+ label: has(`${word}Yes`) ? `${word}Yes` : "yes",
1775
+ does: "ask-yes"
1776
+ }
1777
+ ]
1778
+ };
1779
+ }
1780
+ // src/features/formats/formats.ts
1781
+ var id = z.string().regex(/^[a-z][a-z0-9-]*$/, "use small letters, numbers and dashes, starting with a letter");
1782
+ /** The name of a message. A word is never written out in a screen file; the words live in `messages/`. */
1783
+ var word = z.string().min(1);
1784
+ var event = z.string().regex(/^[a-z][a-z0-9-]*$/, "use small letters, numbers and dashes, starting with a letter");
1785
+ var setting = z.enum([
1786
+ "language",
1787
+ "master",
1788
+ "music",
1789
+ "effects",
1790
+ "mute",
1791
+ "textSize",
1792
+ "contrast",
1793
+ "motion",
1794
+ "frameCounter"
1795
+ ]);
1796
+ var button = z.object({
1797
+ type: z.literal("button"),
1798
+ id,
1799
+ label: word,
1800
+ does: event,
1801
+ /** The screen's main button is the first one that shows and says `main`. */
1802
+ main: z.boolean().optional(),
1803
+ /** Marks a row that opens another screen: it is shown with a ">" on the right. */
1804
+ opens: z.boolean().optional(),
1805
+ /** Shown on the right of the row. */
1806
+ shows: z.literal("language").optional(),
1807
+ /** Only with (or only without) a save to continue from. */
1808
+ when: z.enum(["has-save", "no-save"]).optional()
1809
+ });
1810
+ var text = z.object({
1811
+ type: z.literal("text"),
1812
+ words: word
1813
+ });
1814
+ var image = z.object({
1815
+ type: z.literal("image"),
1816
+ asset: id
1817
+ });
1818
+ var slider = z.object({
1819
+ type: z.literal("slider"),
1820
+ id,
1821
+ label: word,
1822
+ setting
1823
+ });
1824
+ var steps = z.object({
1825
+ type: z.literal("steps"),
1826
+ id,
1827
+ label: word,
1828
+ setting,
1829
+ /** The name of each level, from the lowest. */
1830
+ levels: z.array(word).min(2)
1831
+ });
1832
+ var switchItem = z.object({
1833
+ type: z.literal("switch"),
1834
+ id,
1835
+ label: word,
1836
+ setting
1837
+ });
1838
+ var list = z.object({
1839
+ type: z.literal("list"),
1840
+ from: z.enum([
1841
+ "saves",
1842
+ "languages",
1843
+ "controls",
1844
+ "credits"
1845
+ ])
1846
+ });
1847
+ var item = z.discriminatedUnion("type", [
1848
+ button,
1849
+ text,
1850
+ image,
1851
+ slider,
1852
+ steps,
1853
+ switchItem,
1854
+ list
1855
+ ]);
1856
+ /** The `screen` content kind. Formats may change. */
1857
+ var screenSchema = z.looseObject({
1858
+ format: z.literal(1),
1859
+ id,
1860
+ kind: z.literal("screen"),
1861
+ title: word.optional(),
1862
+ /** A small line over the title, such as the game's name. */
1863
+ above: word.optional(),
1864
+ /** `card` slides up as a sheet or sits in the middle; `splash` fills the screen and skips on any key or tap. */
1865
+ layout: z.enum(["card", "splash"]).optional(),
1866
+ /** Shows a "Back" button under the items. */
1867
+ back: z.boolean().optional(),
1868
+ items: z.array(item)
1869
+ });
1870
+ var where = z.enum([
1871
+ "top-left",
1872
+ "top",
1873
+ "top-right",
1874
+ "bottom-left",
1875
+ "bottom",
1876
+ "bottom-right"
1877
+ ]);
1878
+ /** The `hud` content kind. Formats may change. */
1879
+ var hudSchema = z.looseObject({
1880
+ format: z.literal(1),
1881
+ id,
1882
+ kind: z.literal("hud"),
1883
+ items: z.array(z.object({
1884
+ type: z.enum([
1885
+ "text",
1886
+ "icon",
1887
+ "bar"
1888
+ ]),
1889
+ /** A path into the game's state, such as `game.score`. A bar reads a number from 0 to 1. */
1890
+ shows: z.string().min(1),
1891
+ label: word,
1892
+ where,
1893
+ player: z.number().int().min(0).optional()
1894
+ }))
1895
+ });
1896
+ var goTo = z.union([id, z.object({
1897
+ ask: word,
1898
+ yes: id
1899
+ })]);
1900
+ /** The `flow` content kind. A state shows a screen, or plays the game and shows a HUD. Formats may change. */
1901
+ var flowSchema = z.looseObject({
1902
+ format: z.literal(1),
1903
+ id,
1904
+ kind: z.literal("flow"),
1905
+ start: id,
1906
+ screens: z.record(id, z.object({
1907
+ screen: id.optional(),
1908
+ hud: id.optional(),
1909
+ /** Milliseconds until `timeout` happens by itself. */
1910
+ after: z.number().int().positive().optional(),
1911
+ on: z.record(event, goTo)
1912
+ }))
1913
+ });
1914
+ var corner = z.object({
1915
+ size: z.number().min(0),
1916
+ steep: z.number().min(1)
1917
+ });
1918
+ var colour = z.string().min(1);
1919
+ /** The `theme` content kind. Every key is optional: a missing one takes the shell's own look. Formats may change. */
1920
+ var themeSchema = z.looseObject({
1921
+ format: z.literal(1),
1922
+ id,
1923
+ kind: z.literal("theme"),
1924
+ colours: z.object({
1925
+ page: colour.optional(),
1926
+ words: colour.optional(),
1927
+ muted: colour.optional(),
1928
+ button: colour.optional(),
1929
+ buttonWords: colour.optional(),
1930
+ primary: colour.optional(),
1931
+ primaryWords: colour.optional(),
1932
+ line: colour.optional(),
1933
+ focus: colour.optional(),
1934
+ player: z.array(colour).optional()
1935
+ }).optional(),
1936
+ fonts: z.object({
1937
+ title: z.string().optional(),
1938
+ main: z.string().optional(),
1939
+ plain: z.string().optional()
1940
+ }).optional(),
1941
+ corners: z.object({
1942
+ card: corner.optional(),
1943
+ button: corner.optional(),
1944
+ small: corner.optional()
1945
+ }).optional(),
1946
+ outline: z.number().min(0).optional(),
1947
+ pixelArt: z.boolean().optional(),
1948
+ playerMarks: z.array(z.string()).optional()
1949
+ });
1950
+ /** The `credits` content kind. Formats may change. */
1951
+ var creditsSchema = z.looseObject({
1952
+ format: z.literal(1),
1953
+ id,
1954
+ kind: z.literal("credits"),
1955
+ lines: z.array(z.object({
1956
+ role: word,
1957
+ names: z.array(z.string())
1958
+ }))
1959
+ });
1960
+ var defined = false;
1961
+ /** Teaches `/core` the shell's content kinds, so a mistake in one of its files is named with its file and line. */
1962
+ function defineShellKinds() {
1963
+ if (defined) return;
1964
+ defined = true;
1965
+ defineKind("screen", screenSchema);
1966
+ defineKind("hud", hudSchema);
1967
+ defineKind("flow", flowSchema);
1968
+ defineKind("theme", themeSchema);
1969
+ defineKind("credits", creditsSchema);
1970
+ }
1971
+ // src/features/flow/flow.ts
1972
+ /**
1973
+ * The flow file as a plain machine. An event moves the player from one state to the next by the state's `on`. `back`
1974
+ * goes to where the player came from unless the state says otherwise. A target `{ ask, yes }` asks first: `ask-yes`
1975
+ * goes on, `ask-no` (or `back`) stays. Built-in events are skip, timeout, new-game, continue, pause, resume, win,
1976
+ * lose, retry and back; a flow may add its own.
1977
+ */
1978
+ function createFlow(flow, options = {}) {
1979
+ const playing = Object.entries(flow.screens).find(([, state]) => state.hud !== void 0)?.[0];
1980
+ let at = options.startPlaying && playing ? playing : flow.start;
1981
+ let stack = [];
1982
+ let question;
1983
+ const place = () => {
1984
+ const state = flow.screens[at];
1985
+ return {
1986
+ at,
1987
+ screen: state?.screen,
1988
+ hud: state?.hud,
1989
+ asking: question?.word,
1990
+ after: state?.after
1991
+ };
1992
+ };
1993
+ function go(target) {
1994
+ const seen = stack.indexOf(target);
1995
+ if (seen >= 0) stack = stack.slice(0, seen);
1996
+ else if (target !== at) stack = [...stack, at];
1997
+ at = target;
1998
+ question = void 0;
1999
+ }
2000
+ return {
2001
+ place,
2002
+ /** True when the event changed where the player is. */
2003
+ send(event) {
2004
+ if (question) {
2005
+ if (event === "ask-yes") go(question.yes);
2006
+ else if (event === "ask-no" || event === "back") question = void 0;
2007
+ else return false;
2008
+ return true;
2009
+ }
2010
+ const target = flow.screens[at]?.on[event];
2011
+ if (target === void 0) {
2012
+ if (event !== "back" || stack.length === 0) return false;
2013
+ const previous = stack.at(-1);
2014
+ stack = stack.slice(0, -1);
2015
+ at = previous;
2016
+ return true;
2017
+ }
2018
+ if (typeof target === "string") go(target);
2019
+ else question = {
2020
+ word: target.ask,
2021
+ yes: target.yes
2022
+ };
2023
+ return true;
2024
+ },
2025
+ /** Goes straight to a named state, forgetting the way back. */
2026
+ to(name) {
2027
+ at = name in flow.screens ? name : flow.start;
2028
+ stack = [];
2029
+ question = void 0;
2030
+ },
2031
+ /** Goes straight to the state that plays the game (a saved game being continued). */
2032
+ play() {
2033
+ if (!playing) return false;
2034
+ stack = [];
2035
+ question = void 0;
2036
+ at = playing;
2037
+ return true;
2038
+ },
2039
+ /** True when the state handles this event. */
2040
+ handles: (event) => flow.screens[at]?.on[event] !== void 0
2041
+ };
2042
+ }
2043
+ /** What is wrong with the flow's links to the other files, one plain sentence each. */
2044
+ function flowProblems(flow, screens, huds) {
2045
+ const found = [];
2046
+ const known = new Set(Object.keys(flow.screens));
2047
+ const unknown = (name, message, fix) => found.push({
2048
+ name,
2049
+ message,
2050
+ fix
2051
+ });
2052
+ if (!known.has(flow.start)) unknown(flow.start, `The flow starts at "${flow.start}", which it does not have.`, "Start at one of its screens.");
2053
+ for (const [name, state] of Object.entries(flow.screens)) {
2054
+ if (state.screen === void 0 === (state.hud === void 0)) unknown(name, `"${name}" must show either a screen or a hud.`, "Give it a \"screen\" or a \"hud\", not both.");
2055
+ if (state.screen !== void 0 && !screens.has(state.screen)) unknown(state.screen, `"${name}" shows the screen "${state.screen}", which is not in automata.json.`, "List that screen file, or use another.");
2056
+ if (state.hud !== void 0 && !huds.has(state.hud)) unknown(state.hud, `"${name}" shows the hud "${state.hud}", which is not in automata.json.`, "List that hud file, or use another.");
2057
+ for (const target of Object.values(state.on)) {
2058
+ const to = typeof target === "string" ? target : target.yes;
2059
+ if (!known.has(to)) unknown(to, `"${name}" goes to "${to}", which the flow does not have.`, "Go to one of its screens.");
2060
+ }
2061
+ }
2062
+ return found;
2063
+ }
2064
+ // src/features/theme/corner.ts
2065
+ var unit = /* @__PURE__ */ new Map();
2066
+ /** One corner as `steps + 1` points from the top edge to the side edge, scaled to fit a 1 by 1 square. */
2067
+ function unitCorner(k) {
2068
+ const known = unit.get(k);
2069
+ if (known) return known;
2070
+ const points = [[0, 0]];
2071
+ let x = 0;
2072
+ let y = 0;
2073
+ const fine = 24;
2074
+ for (let i = 0; i < 432; i += 1) {
2075
+ const s = (i + .5) / 432;
2076
+ const a = s ** k;
2077
+ const turn = Math.PI / 2 * a / (a + (1 - s) ** k);
2078
+ x += Math.sin(turn);
2079
+ y += Math.cos(turn);
2080
+ if ((i + 1) % fine === 0) points.push([x, y]);
2081
+ }
2082
+ const made = points.map(([px, py]) => [px / x, py / x]);
2083
+ unit.set(k, made);
2084
+ return made;
2085
+ }
2086
+ var allCurved = [
2087
+ true,
2088
+ true,
2089
+ true,
2090
+ true
2091
+ ];
2092
+ /** The points of a `width` by `height` shape, grown by `grow` all round, with corners of size `size` and steepness `k`. */
2093
+ function shapePoints(width, height, size, k, grow = 0, curved = allCurved) {
2094
+ const [x0, y0, x1, y1] = [
2095
+ 0 - grow,
2096
+ 0 - grow,
2097
+ width + grow,
2098
+ height + grow
2099
+ ];
2100
+ const r = Math.max(0, Math.min(size + grow, (x1 - x0) / 2, (y1 - y0) / 2));
2101
+ const from = unitCorner(k);
2102
+ const back = from.toReversed();
2103
+ const out = [];
2104
+ if (curved[0] && r > 0) for (const [u, v] of from) out.push([x0 + r * u, y0 + r - r * v]);
2105
+ else out.push([x0, y0]);
2106
+ if (curved[1] && r > 0) for (const [u, v] of back) out.push([x1 - r * u, y0 + r - r * v]);
2107
+ else out.push([x1, y0]);
2108
+ if (curved[2] && r > 0) for (const [u, v] of from) out.push([x1 - r * u, y1 - r + r * v]);
2109
+ else out.push([x1, y1]);
2110
+ if (curved[3] && r > 0) for (const [u, v] of back) out.push([x0 + r * u, y1 - r + r * v]);
2111
+ else out.push([x0, y1]);
2112
+ return out;
2113
+ }
2114
+ /** The same, as the text of an SVG path. The same inputs always give the same text. */
2115
+ function shapePath(...args) {
2116
+ return `M${shapePoints(...args).map(([x, y]) => `${x.toFixed(2)} ${y.toFixed(2)}`).join("L")}Z`;
2117
+ }
2118
+ // src/features/theme/shape.ts
2119
+ var ns = "http://www.w3.org/2000/svg";
2120
+ /**
2121
+ * Draws a part's shape behind its content: an SVG with two paths, the body (filled from a token by the part's own CSS)
2122
+ * and the focus ring (the same shape grown 4 px and stroked 3 px in `focus`, shown only while the part has focus from a
2123
+ * keyboard). A `ResizeObserver` draws it again when the part changes size. `corner` is in `em` of the part's own font size.
2124
+ */
2125
+ function shape(node, options) {
2126
+ let current = options;
2127
+ const svg = document.createElementNS(ns, "svg");
2128
+ svg.setAttribute("class", "shape");
2129
+ svg.setAttribute("aria-hidden", "true");
2130
+ const body = document.createElementNS(ns, "path");
2131
+ body.setAttribute("class", "body");
2132
+ const ring = document.createElementNS(ns, "path");
2133
+ ring.setAttribute("class", "ring");
2134
+ svg.append(body, ring);
2135
+ node.prepend(svg);
2136
+ const draw = () => {
2137
+ const width = node.offsetWidth;
2138
+ const height = node.offsetHeight;
2139
+ if (width === 0 || height === 0) return;
2140
+ const px = current.corner.size * Number.parseFloat(getComputedStyle(node).fontSize);
2141
+ body.setAttribute("d", shapePath(width, height, px, current.corner.steep, 0, current.curved));
2142
+ ring.setAttribute("d", shapePath(width, height, px, current.corner.steep, 4, current.curved));
2143
+ };
2144
+ const watcher = new ResizeObserver(draw);
2145
+ watcher.observe(node);
2146
+ draw();
2147
+ return {
2148
+ update(next) {
2149
+ current = next;
2150
+ draw();
2151
+ },
2152
+ destroy() {
2153
+ watcher.disconnect();
2154
+ svg.remove();
2155
+ }
2156
+ };
2157
+ }
2158
+ // src/features/hud/Hud.svelte
2159
+ var root$8 = $.from_html(`<span class="bar"><i></i></span>`);
2160
+ var root_1$5 = $.from_html(`<span> </span> <b> </b>`, 1);
2161
+ var root_2$4 = $.from_html(`<b> </b>`);
2162
+ var root_3$3 = $.from_html(`<span><!></span>`);
2163
+ var root_4$1 = $.from_html(`<div></div>`);
2164
+ var root_5$1 = $.from_html(`<div class="hud"><!> <button class="chip pausebtn"><i></i><i></i></button></div>`);
2165
+ function Hud($$anchor, $$props) {
2166
+ $.push($$props, true);
2167
+ const $t = () => $.store_get(t, "$t", $$stores);
2168
+ const $values = () => $.store_get($$props.values, "$values", $$stores);
2169
+ const [$$stores, $$cleanup] = $.setup_stores();
2170
+ const host = getContext("host");
2171
+ const { t } = host;
2172
+ const places = [
2173
+ "top-left",
2174
+ "top",
2175
+ "top-right",
2176
+ "bottom-left",
2177
+ "bottom",
2178
+ "bottom-right"
2179
+ ];
2180
+ const at = (where) => $$props.hud.items.map((item, index) => ({
2181
+ item,
2182
+ index
2183
+ })).filter((one) => one.item.where === where);
2184
+ const share = (value) => Math.min(1, Math.max(0, Number(value) || 0));
2185
+ var div = root_5$1();
2186
+ var node = $.child(div);
2187
+ $.each(node, 16, () => places, (where) => where, ($$anchor, where) => {
2188
+ var div_1 = root_4$1();
2189
+ $.each(div_1, 21, () => at(where), ({ item, index }) => index, ($$anchor, $$item) => {
2190
+ let item = () => $.get($$item).item;
2191
+ let index = () => $.get($$item).index;
2192
+ var span = root_3$3();
2193
+ var node_1 = $.child(span);
2194
+ var consequent = ($$anchor) => {
2195
+ var span_1 = root$8();
2196
+ var i = $.child(span_1);
2197
+ let styles;
2198
+ $.reset(span_1);
2199
+ $.template_effect(($0) => styles = $.set_style(i, "", styles, { width: $0 }), [() => `${share($values()[index()] ?? "") * 100}%`]);
2200
+ $.append($$anchor, span_1);
2201
+ };
2202
+ var consequent_1 = ($$anchor) => {
2203
+ var fragment = root_1$5();
2204
+ var span_2 = $.first_child(fragment);
2205
+ var text = $.only_child(span_2, true);
2206
+ var b = $.sibling(span_2, 2);
2207
+ var text_1 = $.only_child(b, true);
2208
+ $.template_effect(($0) => {
2209
+ $.set_text(text, $0);
2210
+ $.set_text(text_1, $values()[index()] ?? "");
2211
+ }, [() => $t()(item().label)]);
2212
+ $.append($$anchor, fragment);
2213
+ };
2214
+ var alternate = ($$anchor) => {
2215
+ var b_1 = root_2$4();
2216
+ var text_2 = $.only_child(b_1, true);
2217
+ $.template_effect(() => $.set_text(text_2, $values()[index()] ?? ""));
2218
+ $.append($$anchor, b_1);
2219
+ };
2220
+ $.if(node_1, ($$render) => {
2221
+ if (item().type === "bar") $$render(consequent);
2222
+ else if (item().type === "text") $$render(consequent_1, 1);
2223
+ else $$render(alternate, -1);
2224
+ });
2225
+ $.reset(span);
2226
+ $.action(span, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.small }));
2227
+ $.template_effect(($0, $1) => {
2228
+ $.set_class(span, 1, `chip ${item().type ?? ""}`);
2229
+ $.set_attribute(span, "role", item().type === "bar" ? "meter" : void 0);
2230
+ $.set_attribute(span, "aria-label", $0);
2231
+ $.set_attribute(span, "aria-valuenow", $1);
2232
+ $.set_attribute(span, "aria-valuemin", item().type === "bar" ? 0 : void 0);
2233
+ $.set_attribute(span, "aria-valuemax", item().type === "bar" ? 1 : void 0);
2234
+ }, [() => $t()(item().label), () => item().type === "bar" ? share($values()[index()] ?? "") : void 0]);
2235
+ $.append($$anchor, span);
2236
+ });
2237
+ $.reset(div_1);
2238
+ $.template_effect(() => $.set_class(div_1, 1, `slot ${where ?? ""}`));
2239
+ $.append($$anchor, div_1);
2240
+ });
2241
+ var button = $.sibling(node, 2);
2242
+ $.action(button, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.small }));
2243
+ $.reset(div);
2244
+ $.template_effect(($0) => $.set_attribute(button, "aria-label", $0), [() => $t()("paused")]);
2245
+ $.delegated("click", button, () => host.send("pause"));
2246
+ $.append($$anchor, div);
2247
+ $.pop();
2248
+ $$cleanup();
2249
+ }
2250
+ $.delegate(["click"]);
2251
+ // src/features/theme/css.ts
2252
+ /** The theme as CSS custom properties for the shell's root. No component holds a colour or a font of its own. */
2253
+ function cssVars(look) {
2254
+ const { colours, fonts } = look;
2255
+ return {
2256
+ "--page": colours.page,
2257
+ "--words": colours.words,
2258
+ "--muted": colours.muted,
2259
+ "--button": colours.button,
2260
+ "--button-words": colours.buttonWords,
2261
+ "--primary": colours.primary,
2262
+ "--primary-words": colours.primaryWords,
2263
+ "--line": colours.line,
2264
+ "--focus": colours.focus,
2265
+ "--f-title": fonts.title,
2266
+ "--f-main": fonts.main,
2267
+ "--f-plain": fonts.plain,
2268
+ "--outline": `${look.outline}px`,
2269
+ "--ease-card": look.pixelArt ? "steps(5)" : "cubic-bezier(.2,1.25,.35,1)",
2270
+ "--ease-logo": look.pixelArt ? "steps(5)" : "cubic-bezier(.2,1.5,.35,1)"
2271
+ };
2272
+ }
2273
+ /** Registers each font asset under its asset id, so a theme may name it in `fonts`. */
2274
+ async function registerFonts(assets, fonts) {
2275
+ await Promise.all(assets.filter((asset) => asset.kind === "font").map(async (asset) => {
2276
+ const face = new FontFace(asset.id, `url(${asset.path})`);
2277
+ fonts.add(await face.load());
2278
+ }));
2279
+ }
2280
+ // src/features/words/words.ts
2281
+ var isMessage = (value) => typeof value === "function";
2282
+ /** A language written in its own words: "English", "Español". */
2283
+ function languageName(code) {
2284
+ const name = new Intl.DisplayNames([code], { type: "language" }).of(code) ?? code;
2285
+ return name.charAt(0).toLocaleUpperCase(code) + name.slice(1);
2286
+ }
2287
+ /**
2288
+ * Looks a word up by its message name in the language now chosen: first in the game's own words, then in the shell's.
2289
+ * Paraglide gives the English words wherever a language has none, so a missing word is never blank. A name nobody wrote
2290
+ * comes back as the name itself (or the plain text the game gave for it, such as its name); `automata check` names that file and word before a game ships.
2291
+ */
2292
+ function createWords(sources, language) {
2293
+ const find = (name) => {
2294
+ const own = sources.game?.[name];
2295
+ if (isMessage(own)) return own;
2296
+ const shell = sources.shell[name];
2297
+ return isMessage(shell) ? shell : void 0;
2298
+ };
2299
+ return {
2300
+ word(name, inputs = {}) {
2301
+ const message = find(name);
2302
+ return message ? message(inputs, { locale: language() }) : sources.plain?.[name] ?? name;
2303
+ },
2304
+ has: (name) => find(name) !== void 0 || sources.plain?.[name] !== void 0
2305
+ };
2306
+ }
2307
+ // src/features/screens/Button.svelte
2308
+ var root$7 = $.from_html(`<span class="val"> </span>`);
2309
+ var root_1$4 = $.from_html(`<span class="chev" aria-hidden="true">›</span>`);
2310
+ var root_2$3 = $.from_html(`<button><span class="lbl"> </span> <!> <!></button>`);
2311
+ function Button($$anchor, $$props) {
2312
+ $.push($$props, true);
2313
+ const $t = () => $.store_get(t, "$t", $$stores);
2314
+ const $settings = () => $.store_get(settings, "$settings", $$stores);
2315
+ const [$$stores, $$cleanup] = $.setup_stores();
2316
+ const host = getContext("host");
2317
+ const { t, settings } = host;
2318
+ var button = root_2$3();
2319
+ let classes;
2320
+ var span = $.child(button);
2321
+ var text = $.only_child(span, true);
2322
+ var node = $.sibling(span, 2);
2323
+ var consequent = ($$anchor) => {
2324
+ var span_1 = root$7();
2325
+ var text_1 = $.only_child(span_1, true);
2326
+ $.template_effect(($0) => $.set_text(text_1, $0), [() => languageName($settings().language)]);
2327
+ $.append($$anchor, span_1);
2328
+ };
2329
+ $.if(node, ($$render) => {
2330
+ if ($$props.item.shows === "language") $$render(consequent);
2331
+ });
2332
+ var node_1 = $.sibling(node, 2);
2333
+ var consequent_1 = ($$anchor) => {
2334
+ var span_2 = root_1$4();
2335
+ $.append($$anchor, span_2);
2336
+ };
2337
+ $.if(node_1, ($$render) => {
2338
+ if ($$props.item.opens) $$render(consequent_1);
2339
+ });
2340
+ $.reset(button);
2341
+ $.action(button, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2342
+ $.template_effect(($0) => {
2343
+ classes = $.set_class(button, 1, "item", null, classes, {
2344
+ primary: $$props.main,
2345
+ nav: $$props.item.opens === true
2346
+ });
2347
+ $.set_text(text, $0);
2348
+ }, [() => $t()($$props.item.label)]);
2349
+ $.delegated("click", button, () => host.send($$props.item.does));
2350
+ $.append($$anchor, button);
2351
+ $.pop();
2352
+ $$cleanup();
2353
+ }
2354
+ $.delegate(["click"]);
2355
+ // src/features/screens/Image.svelte
2356
+ var root$6 = $.from_html(`<img class="picture" alt=""/>`);
2357
+ function Image($$anchor, $$props) {
2358
+ $.push($$props, true);
2359
+ const host = getContext("host");
2360
+ const url = $.derived(() => host.assetUrl($$props.item.asset));
2361
+ var fragment = $.comment();
2362
+ var node = $.first_child(fragment);
2363
+ var consequent = ($$anchor) => {
2364
+ var img = root$6();
2365
+ $.template_effect(() => $.set_attribute(img, "src", $.get(url)));
2366
+ $.append($$anchor, img);
2367
+ };
2368
+ $.if(node, ($$render) => {
2369
+ if ($.get(url)) $$render(consequent);
2370
+ });
2371
+ $.append($$anchor, fragment);
2372
+ $.pop();
2373
+ }
2374
+ // src/features/screens/List.svelte
2375
+ var root$5 = $.from_html(`<button class="item radio" role="radio"><span class="lbl"> </span> <span class="tick" aria-hidden="true"> </span></button>`);
2376
+ var root_1$3 = $.from_html(`<button class="item save"><span class="lbl"> </span> <small> </small></button>`);
2377
+ var root_2$2 = $.from_html(`<div class="item bind"><span class="lbl"> </span> <span class="key"> </span></div>`);
2378
+ var root_3$2 = $.from_html(`<div class="credit"><small> </small> <span> </span></div>`);
2379
+ function List($$anchor, $$props) {
2380
+ $.push($$props, true);
2381
+ const $settings = () => $.store_get(settings, "$settings", $$stores);
2382
+ const $t = () => $.store_get(t, "$t", $$stores);
2383
+ const [$$stores, $$cleanup] = $.setup_stores();
2384
+ const host = getContext("host");
2385
+ const { t, settings } = host;
2386
+ const when = (at) => new Intl.DateTimeFormat($settings().language, {
2387
+ dateStyle: "medium",
2388
+ timeStyle: "short"
2389
+ }).format(at);
2390
+ var fragment = $.comment();
2391
+ var node = $.first_child(fragment);
2392
+ var consequent = ($$anchor) => {
2393
+ var fragment_1 = $.comment();
2394
+ var node_1 = $.first_child(fragment_1);
2395
+ $.each(node_1, 16, () => host.languages, (code) => code, ($$anchor, code) => {
2396
+ var button = root$5();
2397
+ var span = $.child(button);
2398
+ var text = $.only_child(span, true);
2399
+ var span_1 = $.sibling(span, 2);
2400
+ var text_1 = $.only_child(span_1, true);
2401
+ $.reset(button);
2402
+ $.action(button, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2403
+ $.template_effect(($0) => {
2404
+ $.set_attribute(button, "aria-checked", $settings().language === code);
2405
+ $.set_attribute(button, "lang", code);
2406
+ $.set_text(text, $0);
2407
+ $.set_text(text_1, $settings().language === code ? "✓" : "");
2408
+ }, [() => languageName(code)]);
2409
+ $.delegated("click", button, () => host.set("language", code));
2410
+ $.append($$anchor, button);
2411
+ });
2412
+ $.append($$anchor, fragment_1);
2413
+ };
2414
+ var consequent_1 = ($$anchor) => {
2415
+ var fragment_2 = $.comment();
2416
+ var node_2 = $.first_child(fragment_2);
2417
+ $.each(node_2, 17, () => host.saves(), (row) => row.slot, ($$anchor, row) => {
2418
+ var button_1 = root_1$3();
2419
+ var span_2 = $.child(button_1);
2420
+ var text_2 = $.only_child(span_2, true);
2421
+ var small = $.sibling(span_2, 2);
2422
+ var text_3 = $.only_child(small, true);
2423
+ $.reset(button_1);
2424
+ $.action(button_1, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2425
+ $.template_effect(($0, $1) => {
2426
+ $.set_text(text_2, $0);
2427
+ $.set_text(text_3, $1);
2428
+ }, [() => $.get(row).slot === "auto" ? $t()("autosave") : $t()("slot", { number: $.get(row).slot }), () => $.get(row).empty ? $t()("empty") : when($.get(row).savedAt)]);
2429
+ $.delegated("click", button_1, () => host.send(`slot-${$.get(row).slot}`));
2430
+ $.append($$anchor, button_1);
2431
+ });
2432
+ $.append($$anchor, fragment_2);
2433
+ };
2434
+ var consequent_2 = ($$anchor) => {
2435
+ var fragment_3 = $.comment();
2436
+ var node_3 = $.first_child(fragment_3);
2437
+ $.each(node_3, 17, () => host.controls(), (row) => row.id, ($$anchor, row) => {
2438
+ var div = root_2$2();
2439
+ var span_3 = $.child(div);
2440
+ var text_4 = $.only_child(span_3, true);
2441
+ var span_4 = $.sibling(span_3, 2);
2442
+ var text_5 = $.only_child(span_4, true);
2443
+ $.action(span_4, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.small }));
2444
+ $.reset(div);
2445
+ $.action(div, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2446
+ $.template_effect(($0) => {
2447
+ $.set_text(text_4, $.get(row).label);
2448
+ $.set_text(text_5, $0);
2449
+ }, [() => $.get(row).key === "arrows" ? $t()("arrows") : $.get(row).key]);
2450
+ $.append($$anchor, div);
2451
+ });
2452
+ $.append($$anchor, fragment_3);
2453
+ };
2454
+ var alternate = ($$anchor) => {
2455
+ var fragment_4 = $.comment();
2456
+ var node_4 = $.first_child(fragment_4);
2457
+ $.each(node_4, 17, () => host.credits()?.lines ?? [], (line) => line.role, ($$anchor, line) => {
2458
+ var div_1 = root_3$2();
2459
+ var small_1 = $.child(div_1);
2460
+ var text_6 = $.only_child(small_1, true);
2461
+ var span_5 = $.sibling(small_1, 2);
2462
+ var text_7 = $.only_child(span_5, true);
2463
+ $.reset(div_1);
2464
+ $.template_effect(($0, $1) => {
2465
+ $.set_text(text_6, $0);
2466
+ $.set_text(text_7, $1);
2467
+ }, [() => $t()($.get(line).role), () => $.get(line).names.join(", ")]);
2468
+ $.append($$anchor, div_1);
2469
+ });
2470
+ $.append($$anchor, fragment_4);
2471
+ };
2472
+ $.if(node, ($$render) => {
2473
+ if ($$props.item.from === "languages") $$render(consequent);
2474
+ else if ($$props.item.from === "saves") $$render(consequent_1, 1);
2475
+ else if ($$props.item.from === "controls") $$render(consequent_2, 2);
2476
+ else $$render(alternate, -1);
2477
+ });
2478
+ $.append($$anchor, fragment);
2479
+ $.pop();
2480
+ $$cleanup();
2481
+ }
2482
+ $.delegate(["click"]);
2483
+ // src/features/screens/Slider.svelte
2484
+ var root$4 = $.from_html(`<label class="item slider"><span class="lbl"> </span> <span class="out"> </span> <input type="range" min="0" max="100" step="5"/></label>`);
2485
+ function Slider($$anchor, $$props) {
2486
+ $.push($$props, true);
2487
+ const $t = () => $.store_get(t, "$t", $$stores);
2488
+ const [$$stores, $$cleanup] = $.setup_stores();
2489
+ const host = getContext("host");
2490
+ const { t } = host;
2491
+ const input = $.derived(() => `slider-${$$props.item.id}`);
2492
+ var label = root$4();
2493
+ var span = $.child(label);
2494
+ var text = $.only_child(span, true);
2495
+ var span_1 = $.sibling(span, 2);
2496
+ var text_1 = $.only_child(span_1, true);
2497
+ var input_1 = $.sibling(span_1, 2);
2498
+ $.remove_input_defaults(input_1);
2499
+ let styles;
2500
+ $.reset(label);
2501
+ $.action(label, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2502
+ $.template_effect(($0) => {
2503
+ $.set_attribute(label, "for", $.get(input));
2504
+ $.set_text(text, $0);
2505
+ $.set_text(text_1, $$props.value);
2506
+ $.set_attribute(input_1, "id", $.get(input));
2507
+ $.set_value(input_1, $$props.value);
2508
+ styles = $.set_style(input_1, "", styles, { "--p": `${$$props.value ?? ""}%` });
2509
+ }, [() => $t()($$props.item.label)]);
2510
+ $.delegated("input", input_1, (e) => $$props.onchange(Number(e.currentTarget.value)));
2511
+ $.append($$anchor, label);
2512
+ $.pop();
2513
+ $$cleanup();
2514
+ }
2515
+ $.delegate(["input"]);
2516
+ // src/features/screens/Steps.svelte
2517
+ var root$3 = $.from_html(`<i></i>`);
2518
+ var root_1$2 = $.from_html(`<div class="item steps" role="group"><span class="lbl"> </span> <div class="stepper"><button class="step">−</button> <span class="stepval" aria-live="polite"><span> </span> <span class="pips" aria-hidden="true"></span></span> <button class="step">+</button></div></div>`);
2519
+ function Steps($$anchor, $$props) {
2520
+ $.push($$props, true);
2521
+ const $t = () => $.store_get(t, "$t", $$stores);
2522
+ const [$$stores, $$cleanup] = $.setup_stores();
2523
+ const host = getContext("host");
2524
+ const { t } = host;
2525
+ const last = $.derived(() => $$props.item.levels.length - 1);
2526
+ var div = root_1$2();
2527
+ var span = $.child(div);
2528
+ var text = $.only_child(span, true);
2529
+ var div_1 = $.sibling(span, 2);
2530
+ var button = $.child(div_1);
2531
+ $.action(button, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.small }));
2532
+ var span_1 = $.sibling(button, 2);
2533
+ var span_2 = $.child(span_1);
2534
+ var text_1 = $.only_child(span_2, true);
2535
+ var span_3 = $.sibling(span_2, 2);
2536
+ $.each(span_3, 21, () => ({ length: $.get(last) }), $.index, ($$anchor, _, i) => {
2537
+ var i_1 = root$3();
2538
+ let classes;
2539
+ $.template_effect(() => classes = $.set_class(i_1, 1, "", null, classes, { on: i < $$props.value }));
2540
+ $.append($$anchor, i_1);
2541
+ });
2542
+ $.reset(span_3);
2543
+ $.reset(span_1);
2544
+ var button_1 = $.sibling(span_1, 2);
2545
+ $.action(button_1, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.small }));
2546
+ $.reset(div_1);
2547
+ $.reset(div);
2548
+ $.action(div, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2549
+ $.template_effect(($0, $1, $2, $3, $4, $5, $6) => {
2550
+ $.set_attribute(div, "aria-label", $0);
2551
+ $.set_text(text, $1);
2552
+ button.disabled = $$props.value <= 0;
2553
+ $.set_attribute(button, "aria-label", `${$2 ?? ""}: ${$3 ?? ""}`);
2554
+ $.set_text(text_1, $4);
2555
+ button_1.disabled = $$props.value >= $.get(last);
2556
+ $.set_attribute(button_1, "aria-label", `${$5 ?? ""}: ${$6 ?? ""}`);
2557
+ }, [
2558
+ () => $t()($$props.item.label),
2559
+ () => $t()($$props.item.label),
2560
+ () => $t()($$props.item.label),
2561
+ () => $t()("less"),
2562
+ () => $t()($$props.item.levels[$$props.value] ?? ""),
2563
+ () => $t()($$props.item.label),
2564
+ () => $t()("more")
2565
+ ]);
2566
+ $.delegated("click", button, () => $$props.onchange($$props.value - 1));
2567
+ $.delegated("click", button_1, () => $$props.onchange($$props.value + 1));
2568
+ $.append($$anchor, div);
2569
+ $.pop();
2570
+ $$cleanup();
2571
+ }
2572
+ $.delegate(["click"]);
2573
+ // src/features/screens/Switch.svelte
2574
+ var root$2 = $.from_html(`<button class="item switch" role="switch"><span class="lbl"> </span> <span class="sw"><span> </span> <span class="track"><span class="knob"></span></span></span></button>`);
2575
+ function Switch($$anchor, $$props) {
2576
+ $.push($$props, true);
2577
+ const $t = () => $.store_get(t, "$t", $$stores);
2578
+ const [$$stores, $$cleanup] = $.setup_stores();
2579
+ const host = getContext("host");
2580
+ const { t } = host;
2581
+ var button = root$2();
2582
+ var span = $.child(button);
2583
+ var text = $.only_child(span, true);
2584
+ var span_1 = $.sibling(span, 2);
2585
+ var span_2 = $.child(span_1);
2586
+ var text_1 = $.only_child(span_2, true);
2587
+ $.next(2);
2588
+ $.reset(span_1);
2589
+ $.reset(button);
2590
+ $.action(button, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({ corner: host.look.corners.button }));
2591
+ $.template_effect(($0, $1) => {
2592
+ $.set_attribute(button, "aria-checked", $$props.value);
2593
+ $.set_text(text, $0);
2594
+ $.set_text(text_1, $1);
2595
+ }, [() => $t()($$props.item.label), () => $t()($$props.value ? "on" : "off")]);
2596
+ $.delegated("click", button, () => $$props.onchange(!$$props.value));
2597
+ $.append($$anchor, button);
2598
+ $.pop();
2599
+ $$cleanup();
2600
+ }
2601
+ $.delegate(["click"]);
2602
+ // src/features/screens/Text.svelte
2603
+ var root$1 = $.from_html(`<p class="text"> </p>`);
2604
+ function Text($$anchor, $$props) {
2605
+ $.push($$props, true);
2606
+ const $t = () => $.store_get(t, "$t", $$stores);
2607
+ const [$$stores, $$cleanup] = $.setup_stores();
2608
+ const { t } = getContext("host");
2609
+ var p = root$1();
2610
+ var text = $.only_child(p, true);
2611
+ $.template_effect(($0) => $.set_text(text, $0), [() => $t()($$props.item.words)]);
2612
+ $.append($$anchor, p);
2613
+ $.pop();
2614
+ $$cleanup();
2615
+ }
2616
+ // src/features/screens/Screen.svelte
2617
+ var root = $.from_html(`<div class="name"> </div>`);
2618
+ var root_1$1 = $.from_html(`<span> </span>`);
2619
+ var root_2$1 = $.from_html(`<div class="splash" role="button" tabindex="0"><div class="logo"><!> <!></div> <div class="skip"></div></div>`);
2620
+ var root_3$1 = $.from_html(`<p class="eyebrow"> </p>`);
2621
+ var root_4 = $.from_html(`<header><!> <h1> </h1></header>`);
2622
+ var root_5 = $.from_html(`<button class="back"> </button>`);
2623
+ var root_6 = $.from_html(`<section class="screen"><!> <div></div> <!></section>`);
2624
+ function Screen($$anchor, $$props) {
2625
+ $.push($$props, true);
2626
+ const $hasSave = () => $.store_get(hasSave, "$hasSave", $$stores);
2627
+ const $stageWidth = () => $.store_get(stageWidth, "$stageWidth", $$stores);
2628
+ const $t = () => $.store_get(t, "$t", $$stores);
2629
+ const $settings = () => $.store_get(settings, "$settings", $$stores);
2630
+ const [$$stores, $$cleanup] = $.setup_stores();
2631
+ const host = getContext("host");
2632
+ const { t, settings, hasSave, stageWidth } = host;
2633
+ const shows = (item, saved) => item.type !== "button" || item.when === void 0 || item.when === "has-save" === saved;
2634
+ const items = $.derived(() => $$props.screen.items.filter((item) => shows(item, $hasSave())));
2635
+ const mainIndex = $.derived(() => $.get(items).findIndex((item) => item.type === "button" && item.main === true));
2636
+ const curved = $.derived(() => $stageWidth() < 600 ? [
2637
+ true,
2638
+ true,
2639
+ false,
2640
+ false
2641
+ ] : [
2642
+ true,
2643
+ true,
2644
+ true,
2645
+ true
2646
+ ]);
2647
+ let more = $.state(false);
2648
+ function fade(node) {
2649
+ const check = () => void $.set(more, node.scrollHeight - node.clientHeight - node.scrollTop > 6);
2650
+ node.addEventListener("scroll", check);
2651
+ const watcher = new ResizeObserver(check);
2652
+ watcher.observe(node);
2653
+ for (const child of node.children) watcher.observe(child);
2654
+ check();
2655
+ return { destroy() {
2656
+ node.removeEventListener("scroll", check);
2657
+ watcher.disconnect();
2658
+ } };
2659
+ }
2660
+ var fragment = $.comment();
2661
+ var node_1 = $.first_child(fragment);
2662
+ var consequent_3 = ($$anchor) => {
2663
+ var div = root_2$1();
2664
+ var div_1 = $.child(div);
2665
+ var node_2 = $.child(div_1);
2666
+ $.each(node_2, 17, () => $$props.screen.items, $.index, ($$anchor, item) => {
2667
+ var fragment_1 = $.comment();
2668
+ var node_3 = $.first_child(fragment_1);
2669
+ var consequent = ($$anchor) => {
2670
+ Image($$anchor, { get item() {
2671
+ return $.get(item);
2672
+ } });
2673
+ };
2674
+ $.if(node_3, ($$render) => {
2675
+ if ($.get(item).type === "image") $$render(consequent);
2676
+ });
2677
+ $.append($$anchor, fragment_1);
2678
+ });
2679
+ var node_4 = $.sibling(node_2, 2);
2680
+ var consequent_1 = ($$anchor) => {
2681
+ var div_2 = root();
2682
+ var text = $.only_child(div_2, true);
2683
+ $.template_effect(($0) => $.set_text(text, $0), [() => $t()($$props.screen.title)]);
2684
+ $.append($$anchor, div_2);
2685
+ };
2686
+ $.if(node_4, ($$render) => {
2687
+ if ($$props.screen.title) $$render(consequent_1);
2688
+ });
2689
+ $.reset(div_1);
2690
+ var div_3 = $.sibling(div_1, 2);
2691
+ $.each(div_3, 21, () => $$props.screen.items, $.index, ($$anchor, item) => {
2692
+ var fragment_3 = $.comment();
2693
+ var node_5 = $.first_child(fragment_3);
2694
+ var consequent_2 = ($$anchor) => {
2695
+ var span = root_1$1();
2696
+ var text_1 = $.only_child(span, true);
2697
+ $.template_effect(($0) => $.set_text(text_1, $0), [() => $t()($.get(item).words)]);
2698
+ $.append($$anchor, span);
2699
+ };
2700
+ $.if(node_5, ($$render) => {
2701
+ if ($.get(item).type === "text") $$render(consequent_2);
2702
+ });
2703
+ $.append($$anchor, fragment_3);
2704
+ });
2705
+ $.reset(div_3);
2706
+ $.reset(div);
2707
+ $.template_effect(($0) => $.set_attribute(div, "aria-label", $0), [() => [$$props.screen.title ? $t()($$props.screen.title) : "", ...$$props.screen.items.flatMap((i) => i.type === "text" ? [$t()(i.words)] : [])].join(". ")]);
2708
+ $.delegated("click", div, () => host.send("skip"));
2709
+ $.append($$anchor, div);
2710
+ };
2711
+ var alternate_1 = ($$anchor) => {
2712
+ var section = root_6();
2713
+ var node_6 = $.child(section);
2714
+ var consequent_5 = ($$anchor) => {
2715
+ var header = root_4();
2716
+ var node_7 = $.child(header);
2717
+ var consequent_4 = ($$anchor) => {
2718
+ var p = root_3$1();
2719
+ var text_2 = $.only_child(p, true);
2720
+ $.template_effect(($0) => $.set_text(text_2, $0), [() => $t()($$props.screen.above)]);
2721
+ $.append($$anchor, p);
2722
+ };
2723
+ $.if(node_7, ($$render) => {
2724
+ if ($$props.screen.above) $$render(consequent_4);
2725
+ });
2726
+ var h1 = $.sibling(node_7, 2);
2727
+ var text_3 = $.only_child(h1, true);
2728
+ $.reset(header);
2729
+ $.template_effect(($0) => $.set_text(text_3, $0), [() => $t()($$props.screen.title)]);
2730
+ $.append($$anchor, header);
2731
+ };
2732
+ $.if(node_6, ($$render) => {
2733
+ if ($$props.screen.title) $$render(consequent_5);
2734
+ });
2735
+ var div_4 = $.sibling(node_6, 2);
2736
+ let classes;
2737
+ $.each(div_4, 23, () => $.get(items), (item, i) => `${item.type}-${"id" in item ? item.id : i}`, ($$anchor, item, i) => {
2738
+ var fragment_4 = $.comment();
2739
+ var node_8 = $.first_child(fragment_4);
2740
+ var consequent_6 = ($$anchor) => {
2741
+ {
2742
+ let $0 = $.derived(() => $.get(i) === $.get(mainIndex));
2743
+ Button($$anchor, {
2744
+ get item() {
2745
+ return $.get(item);
2746
+ },
2747
+ get main() {
2748
+ return $.get($0);
2749
+ }
2750
+ });
2751
+ }
2752
+ };
2753
+ var consequent_7 = ($$anchor) => {
2754
+ Text($$anchor, { get item() {
2755
+ return $.get(item);
2756
+ } });
2757
+ };
2758
+ var consequent_8 = ($$anchor) => {
2759
+ Image($$anchor, { get item() {
2760
+ return $.get(item);
2761
+ } });
2762
+ };
2763
+ var consequent_9 = ($$anchor) => {
2764
+ Slider($$anchor, {
2765
+ get item() {
2766
+ return $.get(item);
2767
+ },
2768
+ get value() {
2769
+ return $settings()[$.get(item).setting];
2770
+ },
2771
+ onchange: (v) => host.set($.get(item).setting, v)
2772
+ });
2773
+ };
2774
+ var consequent_10 = ($$anchor) => {
2775
+ Steps($$anchor, {
2776
+ get item() {
2777
+ return $.get(item);
2778
+ },
2779
+ get value() {
2780
+ return $settings()[$.get(item).setting];
2781
+ },
2782
+ onchange: (v) => host.set($.get(item).setting, v)
2783
+ });
2784
+ };
2785
+ var consequent_11 = ($$anchor) => {
2786
+ Switch($$anchor, {
2787
+ get item() {
2788
+ return $.get(item);
2789
+ },
2790
+ get value() {
2791
+ return $settings()[$.get(item).setting];
2792
+ },
2793
+ onchange: (v) => host.set($.get(item).setting, v)
2794
+ });
2795
+ };
2796
+ var alternate = ($$anchor) => {
2797
+ List($$anchor, { get item() {
2798
+ return $.get(item);
2799
+ } });
2800
+ };
2801
+ $.if(node_8, ($$render) => {
2802
+ if ($.get(item).type === "button") $$render(consequent_6);
2803
+ else if ($.get(item).type === "text") $$render(consequent_7, 1);
2804
+ else if ($.get(item).type === "image") $$render(consequent_8, 2);
2805
+ else if ($.get(item).type === "slider") $$render(consequent_9, 3);
2806
+ else if ($.get(item).type === "steps") $$render(consequent_10, 4);
2807
+ else if ($.get(item).type === "switch") $$render(consequent_11, 5);
2808
+ else $$render(alternate, -1);
2809
+ });
2810
+ $.append($$anchor, fragment_4);
2811
+ });
2812
+ $.reset(div_4);
2813
+ $.action(div_4, ($$node) => fade?.($$node));
2814
+ var node_9 = $.sibling(div_4, 2);
2815
+ var consequent_12 = ($$anchor) => {
2816
+ var button = root_5();
2817
+ var text_4 = $.only_child(button);
2818
+ $.template_effect(($0) => $.set_text(text_4, `‹ ${$0 ?? ""}`), [() => $t()("back")]);
2819
+ $.delegated("click", button, () => host.send("back"));
2820
+ $.append($$anchor, button);
2821
+ };
2822
+ $.if(node_9, ($$render) => {
2823
+ if ($$props.screen.back) $$render(consequent_12);
2824
+ });
2825
+ $.reset(section);
2826
+ $.action(section, ($$node, $$action_arg) => shape?.($$node, $$action_arg), () => ({
2827
+ corner: host.look.corners.card,
2828
+ curved: $.get(curved)
2829
+ }));
2830
+ $.template_effect(($0) => {
2831
+ $.set_attribute(section, "aria-label", $0);
2832
+ classes = $.set_class(div_4, 1, "items", null, classes, { more: $.get(more) });
2833
+ }, [() => $$props.screen.title ? $t()($$props.screen.title) : void 0]);
2834
+ $.append($$anchor, section);
2835
+ };
2836
+ $.if(node_1, ($$render) => {
2837
+ if ($$props.screen.layout === "splash") $$render(consequent_3);
2838
+ else $$render(alternate_1, -1);
2839
+ });
2840
+ $.append($$anchor, fragment);
2841
+ $.pop();
2842
+ $$cleanup();
2843
+ }
2844
+ $.delegate(["click"]);
2845
+ // src/features/screens/Shell.svelte
2846
+ var root_1 = $.from_html(`<div class="scrim svelte-1le5zrv"></div>`);
2847
+ var root_2 = $.from_html(`<div><!> <!></div>`);
2848
+ var root_3 = $.from_html(`<div class="automata-shell svelte-1le5zrv"><div class="layer svelte-1le5zrv"><!></div></div>`);
2849
+ var $$css = {
2850
+ hash: "svelte-1le5zrv",
2851
+ code: "\n /* The shell root is a size container laid over the canvas: every rule follows the game's stage, not the window. */.automata-shell.svelte-1le5zrv {--ts: 1;--mo: 1;position:absolute;inset:0;container-type:size;font-family:var(--f-main);color:var(--words);line-height:1.3;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation;pointer-events:none;}.automata-shell.svelte-1le5zrv * {box-sizing:border-box;}.layer.svelte-1le5zrv {position:absolute;inset:0;font-size:calc(17px * var(--ts));}\n @container (min-width: 900px) {.layer.svelte-1le5zrv {font-size:calc(21px * var(--ts));}\n }\n @container (min-width: 1200px) {.layer.svelte-1le5zrv {font-size:calc(22px * var(--ts));}\n }.automata-shell.svelte-1le5zrv button {font:inherit;color:inherit;background:none;border:0;padding:0;margin:0;cursor:pointer;text-align:inherit;border-radius:0;pointer-events:auto;}.view.svelte-1le5zrv {position:absolute;inset:0;display:flex;align-items:flex-end;justify-content:center;pointer-events:auto;}.view.splashing.svelte-1le5zrv {display:block;}.scrim.svelte-1le5zrv {position:absolute;inset:0;background:rgba(8, 12, 18, 0.55);\n animation: svelte-1le5zrv-fade calc(240ms * var(--mo)) both;}\n @keyframes svelte-1le5zrv-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n @keyframes svelte-1le5zrv-sheet {\n from {\n transform: translateY(45%);\n opacity: 0;\n }\n to {\n transform: none;\n opacity: 1;\n }\n }\n @keyframes svelte-1le5zrv-card {\n from {\n transform: scale(0.92);\n opacity: 0;\n }\n to {\n transform: none;\n opacity: 1;\n }\n }\n\n /* --- a card, and the sheet it becomes on a narrow stage --- */.automata-shell.svelte-1le5zrv .screen {position:relative;isolation:isolate;display:flex;flex-direction:column;gap:0.8em;min-height:0;min-width:0;width:100%;max-height:94%;padding:1.5em 1.1em 1.3em;\n animation: svelte-1le5zrv-sheet calc(460ms * var(--mo)) var(--ease-card) both;}\n @container (min-width: 600px) {.view.svelte-1le5zrv {align-items:center;}.automata-shell.svelte-1le5zrv .screen {width:min(100% - 2em, 25em);max-height:calc(100% - 1.4em);padding-top:1.3em;\n animation-name: svelte-1le5zrv-card;animation-duration:calc(320ms * var(--mo));}\n }.automata-shell.svelte-1le5zrv header {flex:none;text-align:center;}.automata-shell.svelte-1le5zrv .eyebrow {margin:0;font-size:0.8em;font-weight:600;color:var(--muted);}.automata-shell.svelte-1le5zrv h1 {margin:0;font-family:var(--f-title);font-weight:700;font-size:min(1.9em, 9cqw);line-height:1.1;letter-spacing:-0.01em;text-wrap:balance;overflow-wrap:anywhere;}.automata-shell.svelte-1le5zrv .items {display:flex;flex-direction:column;gap:0.55em;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:3px;margin:-3px;}.automata-shell.svelte-1le5zrv .items.more {-webkit-mask-image:linear-gradient(#000 calc(100% - 2.2em), transparent);mask-image:linear-gradient(#000 calc(100% - 2.2em), transparent);}.automata-shell.svelte-1le5zrv .text {margin:0;font-weight:400;color:var(--muted);text-align:center;}.automata-shell.svelte-1le5zrv .picture {max-width:100%;align-self:center;}\n\n /* --- the shapes our corner draws behind a part --- */.automata-shell.svelte-1le5zrv .shape {position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:-1;}.automata-shell.svelte-1le5zrv .shape .ring {fill:none;stroke:none;}.automata-shell.svelte-1le5zrv .screen > .shape .body {fill:var(--page);stroke:var(--words);stroke-width:var(--outline);}.automata-shell.svelte-1le5zrv .screen > .shape {filter:drop-shadow(0 0.5em 1.3em rgba(0, 0, 0, 0.35));}.automata-shell.svelte-1le5zrv .item > .shape .body {fill:var(--button);}.automata-shell.svelte-1le5zrv .item.primary > .shape .body {fill:var(--primary);}.automata-shell.svelte-1le5zrv .step > .shape .body,\n .automata-shell.svelte-1le5zrv .key > .shape .body {fill:var(--page);}.automata-shell.svelte-1le5zrv .chip > .shape .body {fill:var(--page);}.automata-shell.svelte-1le5zrv :focus-visible > .shape .ring {stroke:var(--focus);stroke-width:3;}.automata-shell.svelte-1le5zrv button:focus-visible,\n .automata-shell.svelte-1le5zrv .splash:focus-visible {outline:none;}\n\n /* --- parts --- */.automata-shell.svelte-1le5zrv .item {position:relative;isolation:isolate;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:0.3em 1em;width:100%;flex:none;min-height:3.5em;padding:0.4em 1.1em;color:var(--button-words);font-weight:600;transition:transform calc(140ms * var(--mo));}.automata-shell.svelte-1le5zrv button.item {flex-wrap:nowrap;justify-content:center;text-align:center;}.automata-shell.svelte-1le5zrv button.item.nav,\n .automata-shell.svelte-1le5zrv button.item.switch,\n .automata-shell.svelte-1le5zrv button.item.radio {justify-content:space-between;text-align:left;}.automata-shell.svelte-1le5zrv .item .lbl {flex:0 1 auto;min-width:0;}.automata-shell.svelte-1le5zrv button.item.nav .lbl,\n .automata-shell.svelte-1le5zrv button.item.switch .lbl,\n .automata-shell.svelte-1le5zrv button.item.radio .lbl {flex:1 1 auto;}.automata-shell.svelte-1le5zrv .item .val {flex:none;font-weight:400;opacity:0.85;}.automata-shell.svelte-1le5zrv button.item:active {transform:scale(0.97);}\n @media (hover: hover) {.automata-shell.svelte-1le5zrv button.item:hover {transform:scale(1.015);}\n }.automata-shell.svelte-1le5zrv .item.primary {color:var(--primary-words);}.automata-shell.svelte-1le5zrv .stepper {display:flex;align-items:center;gap:0.25em;flex:none;margin-left:auto;}.automata-shell.svelte-1le5zrv .step {position:relative;isolation:isolate;width:44px;height:44px;display:flex;align-items:center;justify-content:center;font-size:1.3em;line-height:1;flex:none;}.automata-shell.svelte-1le5zrv .step[disabled] {opacity:0.35;cursor:default;}.automata-shell.svelte-1le5zrv .stepval {display:flex;flex-direction:column;align-items:center;gap:0.25em;min-width:4.4em;text-align:center;font-size:0.9em;}.automata-shell.svelte-1le5zrv .pips {display:flex;gap:4px;}.automata-shell.svelte-1le5zrv .pips i {display:block;width:16px;height:6px;border-radius:3px;background:var(--line);}.automata-shell.svelte-1le5zrv .pips i.on {background:var(--primary);}.automata-shell.svelte-1le5zrv .slider .out {flex:none;min-width:2.5em;text-align:right;font-variant-numeric:tabular-nums;}.automata-shell.svelte-1le5zrv .slider {pointer-events:auto;background:none;}.automata-shell.svelte-1le5zrv input[type='range'] {-webkit-appearance:none;appearance:none;background:none;height:44px;flex:1 1 100%;margin:0;min-width:0;cursor:pointer;}.automata-shell.svelte-1le5zrv input[type='range']::-webkit-slider-runnable-track {height:10px;border-radius:4px;background:linear-gradient(90deg, var(--primary) var(--p), var(--line) var(--p));}.automata-shell.svelte-1le5zrv input[type='range']::-moz-range-track {height:10px;border-radius:4px;background:linear-gradient(90deg, var(--primary) var(--p), var(--line) var(--p));}.automata-shell.svelte-1le5zrv input[type='range']::-webkit-slider-thumb {-webkit-appearance:none;width:28px;height:28px;border-radius:9px;background:var(--page);border:2px solid var(--primary);margin-top:-9px;}.automata-shell.svelte-1le5zrv input[type='range']::-moz-range-thumb {width:28px;height:28px;border-radius:9px;background:var(--page);border:2px solid var(--primary);}.automata-shell.svelte-1le5zrv .sw {display:flex;align-items:center;gap:0.6em;flex:none;}.automata-shell.svelte-1le5zrv .track {position:relative;display:block;width:46px;height:26px;border-radius:9px;background:var(--line);}.automata-shell.svelte-1le5zrv .switch[aria-checked='true'] .track {background:var(--primary);}.automata-shell.svelte-1le5zrv .knob {position:absolute;top:50%;left:3px;width:20px;height:20px;margin-top:-10px;border-radius:6px;background:#fff;box-shadow:0 1px 3px rgba(0, 0, 0, 0.35);transition:transform calc(160ms * var(--mo));}.automata-shell.svelte-1le5zrv .switch[aria-checked='true'] .knob {transform:translateX(20px);}.automata-shell.svelte-1le5zrv .tick {flex:none;width:1.2em;text-align:center;font-weight:700;}.automata-shell.svelte-1le5zrv button.item.save {flex-direction:column;align-items:flex-start;justify-content:center;gap:0.1em;text-align:left;}.automata-shell.svelte-1le5zrv .save small {font-size:0.8em;font-weight:400;opacity:0.8;}.automata-shell.svelte-1le5zrv .key {position:relative;isolation:isolate;flex:none;min-width:5.5em;min-height:44px;padding:0 0.8em;display:flex;align-items:center;justify-content:center;}.automata-shell.svelte-1le5zrv .credit {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.05em;min-height:2.8em;font-weight:600;}.automata-shell.svelte-1le5zrv .credit small {font-size:0.8em;font-weight:400;color:var(--muted);}.automata-shell.svelte-1le5zrv .back {align-self:center;min-height:44px;padding:0 1.2em;font-weight:600;color:var(--muted);}\n\n /* --- the splash --- */.automata-shell.svelte-1le5zrv .splash {position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1em;text-align:center;padding:1.5em;cursor:pointer;background:var(--page);color:var(--words);\n animation: svelte-1le5zrv-fade calc(300ms * var(--mo)) both;pointer-events:auto;}.automata-shell.svelte-1le5zrv .splash .logo {display:flex;flex-direction:column;align-items:center;gap:0.4em;\n animation: svelte-1le5zrv-card calc(600ms * var(--mo)) var(--ease-logo) both;}.automata-shell.svelte-1le5zrv .splash .name {font-family:var(--f-title);font-size:2.4em;font-weight:800;line-height:1;letter-spacing:-0.02em;}.automata-shell.svelte-1le5zrv .splash .skip {position:absolute;left:0;right:0;bottom:1.6em;font-size:0.9em;color:var(--muted);}\n\n /* --- the HUD --- */.automata-shell.svelte-1le5zrv .hud {position:absolute;inset:0;pointer-events:none;padding:0.7em;}.automata-shell.svelte-1le5zrv .hud .slot {position:absolute;display:flex;flex-direction:column;gap:0.4em;pointer-events:none;}.automata-shell.svelte-1le5zrv .slot.top-left {left:0.7em;top:0.7em;align-items:flex-start;}.automata-shell.svelte-1le5zrv .slot.top {left:50%;top:0.7em;transform:translateX(-50%);align-items:center;}.automata-shell.svelte-1le5zrv .slot.top-right {right:calc(0.7em + 48px + 0.5em);top:0.7em;align-items:flex-end;}.automata-shell.svelte-1le5zrv .slot.bottom-left {left:0.7em;bottom:0.7em;align-items:flex-start;}.automata-shell.svelte-1le5zrv .slot.bottom {left:50%;bottom:0.7em;transform:translateX(-50%);align-items:center;}.automata-shell.svelte-1le5zrv .slot.bottom-right {right:0.7em;bottom:0.7em;align-items:flex-end;}.automata-shell.svelte-1le5zrv .chip {position:relative;isolation:isolate;display:inline-flex;align-items:center;gap:0.4em;min-height:2.2em;padding:0 0.75em;font-weight:600;font-variant-numeric:tabular-nums;color:var(--words);pointer-events:none;}.automata-shell.svelte-1le5zrv .chip .bar {display:block;width:6em;height:0.6em;background:var(--line);border-radius:3px;overflow:hidden;}.automata-shell.svelte-1le5zrv .chip .bar i {display:block;height:100%;background:var(--primary);}.automata-shell.svelte-1le5zrv .chip.pausebtn {position:absolute;right:0.7em;top:0.7em;width:48px;height:48px;justify-content:center;padding:0;pointer-events:auto;}.automata-shell.svelte-1le5zrv .pausebtn i {display:block;width:5px;height:16px;background:currentColor;margin:0 2.5px;}"
2852
+ };
2853
+ function Shell($$anchor, $$props) {
2854
+ $.push($$props, true);
2855
+ $.append_styles($$anchor, $$css);
2856
+ const $view = () => $.store_get($$props.view, "$view", $$stores);
2857
+ const [$$stores, $$cleanup] = $.setup_stores();
2858
+ /** The built-in question: a screen made from the words of the question the flow asks. */
2859
+ setContext("host", $$props.host);
2860
+ const vars = Object.entries(cssVars($$props.host.look)).map(([name, value]) => `${name}:${value}`).join(";");
2861
+ let width = $.state(0);
2862
+ $.user_effect(() => $$props.host.setStageWidth($.get(width)));
2863
+ let root = $.state(void 0);
2864
+ const focusable = () => $.get(root) ? [...$.get(root).querySelectorAll("button:not([disabled]), input, [role=button][tabindex]")] : [];
2865
+ function keydown(event) {
2866
+ $$props.host.noteKeyboard();
2867
+ if ($view().kind === "screen" && $view().screen.layout === "splash") {
2868
+ if (event.key !== "Tab") $$props.host.send("skip");
2869
+ return;
2870
+ }
2871
+ if (event.key === "Escape") {
2872
+ $$props.host.send($view().kind === "play" ? "pause" : "back");
2873
+ return;
2874
+ }
2875
+ if ($view().kind === "play" || !event.key.startsWith("Arrow")) return;
2876
+ const target = event.target;
2877
+ if (target instanceof HTMLInputElement && target.type === "range" && (event.key === "ArrowLeft" || event.key === "ArrowRight")) return;
2878
+ const all = focusable();
2879
+ if (all.length === 0) return;
2880
+ event.preventDefault();
2881
+ const now = all.indexOf(document.activeElement);
2882
+ const step = event.key === "ArrowUp" || event.key === "ArrowLeft" ? -1 : 1;
2883
+ all[now < 0 ? step > 0 ? 0 : all.length - 1 : (now + step + all.length) % all.length]?.focus();
2884
+ }
2885
+ var div = root_3();
2886
+ $.event("keydown", $.window, keydown);
2887
+ $.event("pointerdown", $.window, () => $$props.host.noteKeyboard(false));
2888
+ var div_1 = $.child(div);
2889
+ var node = $.child(div_1);
2890
+ var consequent = ($$anchor) => {
2891
+ Hud($$anchor, {
2892
+ get hud() {
2893
+ return $$props.hud;
2894
+ },
2895
+ get values() {
2896
+ return $$props.hudValues;
2897
+ }
2898
+ });
2899
+ };
2900
+ var consequent_2 = ($$anchor) => {
2901
+ const screen = $.derived(() => $view().kind === "screen" ? $view().screen : $$props.asking($view().word));
2902
+ var div_2 = root_2();
2903
+ let classes;
2904
+ var node_1 = $.child(div_2);
2905
+ var consequent_1 = ($$anchor) => {
2906
+ var div_3 = root_1();
2907
+ $.append($$anchor, div_3);
2908
+ };
2909
+ $.if(node_1, ($$render) => {
2910
+ if ($.get(screen).layout !== "splash") $$render(consequent_1);
2911
+ });
2912
+ var node_2 = $.sibling(node_1, 2);
2913
+ $.key(node_2, () => $view().kind === "screen" ? $.get(screen).id : $view().word, ($$anchor) => {
2914
+ Screen($$anchor, { get screen() {
2915
+ return $.get(screen);
2916
+ } });
2917
+ });
2918
+ $.reset(div_2);
2919
+ $.template_effect(() => classes = $.set_class(div_2, 1, "view svelte-1le5zrv", null, classes, { splashing: $.get(screen).layout === "splash" }));
2920
+ $.append($$anchor, div_2);
2921
+ };
2922
+ $.if(node, ($$render) => {
2923
+ if ($view().kind === "play" && $$props.hud) $$render(consequent);
2924
+ else if ($view().kind === "screen" || $view().kind === "ask") $$render(consequent_2, 1);
2925
+ });
2926
+ $.reset(div_1);
2927
+ $.reset(div);
2928
+ $.bind_this(div, ($$value) => $.set(root, $$value), () => $.get(root));
2929
+ $.template_effect(() => $.set_style(div, vars));
2930
+ $.bind_element_size(div, "clientWidth", ($$value) => $.set(width, $$value));
2931
+ $.append($$anchor, div);
2932
+ $.pop();
2933
+ $$cleanup();
2934
+ }
2935
+ // src/features/hud/read-path.ts
2936
+ /** The value at a path into the game's state, such as `game.score`, as text. */
2937
+ function readPath(state, path) {
2938
+ let at = state;
2939
+ for (const part of path.split(".")) {
2940
+ if (at === null || typeof at !== "object") return "";
2941
+ at = at[part];
2942
+ }
2943
+ return at === void 0 || at === null || typeof at === "object" ? "" : String(at);
2944
+ }
2945
+ // src/features/settings/settings.ts
2946
+ var defaults = (language) => ({
2947
+ language,
2948
+ master: 80,
2949
+ music: 60,
2950
+ effects: 80,
2951
+ mute: false,
2952
+ textSize: 0,
2953
+ contrast: 0,
2954
+ motion: 0,
2955
+ frameCounter: false
2956
+ });
2957
+ /**
2958
+ * The player's settings, kept in the browser under `automata:<game id>:settings`. A first visit takes the language the
2959
+ * browser asks for, when the game has it. A value of the wrong kind in storage is thrown away, never trusted.
2960
+ */
2961
+ function createSettings(store, gameId, languages, browserLanguages) {
2962
+ const key = `automata:${gameId}:settings`;
2963
+ const first = languages[0] ?? "en";
2964
+ const base = defaults(browserLanguages.map((l) => l.toLowerCase().split("-")[0]).find((l) => l && languages.includes(l)) ?? first);
2965
+ let current = { ...base };
2966
+ try {
2967
+ const raw = store.get(key);
2968
+ const saved = raw === null ? {} : JSON.parse(raw);
2969
+ for (const name of Object.keys(base)) if (typeof saved[name] === typeof base[name]) current[name] = saved[name];
2970
+ if (!languages.includes(current.language)) current.language = base.language;
2971
+ } catch {
2972
+ current = { ...base };
2973
+ }
2974
+ const listeners = /* @__PURE__ */ new Set();
2975
+ return {
2976
+ all: () => current,
2977
+ get: (name) => current[name],
2978
+ set(name, value) {
2979
+ current = {
2980
+ ...current,
2981
+ [name]: value
2982
+ };
2983
+ try {
2984
+ store.set(key, JSON.stringify(current));
2985
+ } catch {}
2986
+ for (const listener of listeners) listener(current);
2987
+ },
2988
+ subscribe(listener) {
2989
+ listeners.add(listener);
2990
+ listener(current);
2991
+ return () => void listeners.delete(listener);
2992
+ }
2993
+ };
2994
+ }
2995
+ // src/features/theme/default.ts
2996
+ var plain = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
2997
+ /** What a game with no theme file looks like: the light Soft look with crisp corners. Code, not a content file. */
2998
+ var softLook = {
2999
+ colours: {
3000
+ page: "#f4f6f8",
3001
+ words: "#131a22",
3002
+ muted: "#4c5866",
3003
+ button: "#e2e7ec",
3004
+ buttonWords: "#131a22",
3005
+ primary: "#131a22",
3006
+ primaryWords: "#ffffff",
3007
+ line: "#c9d1d9",
3008
+ focus: "#2f5bff",
3009
+ player: ["#2f5bff", "#c2410c"]
3010
+ },
3011
+ fonts: {
3012
+ title: `'Bricolage Grotesque Variable', ${plain}`,
3013
+ main: `'Figtree Variable', ${plain}`,
3014
+ plain
3015
+ },
3016
+ corners: {
3017
+ card: {
3018
+ size: 2.1,
3019
+ steep: 5
3020
+ },
3021
+ button: {
3022
+ size: 1.25,
3023
+ steep: 3.2
3024
+ },
3025
+ small: {
3026
+ size: .9,
3027
+ steep: 3.2
3028
+ }
3029
+ },
3030
+ outline: 0,
3031
+ pixelArt: false,
3032
+ playerMarks: ["circle", "square"]
3033
+ };
3034
+ /** An object without its undefined keys, so a key a theme leaves out never wipes out the default. */
3035
+ var set = (value) => Object.fromEntries(Object.entries(value ?? {}).filter(([, v]) => v !== void 0));
3036
+ /** A theme file laid over the Soft look: every key it leaves out stays as it was. */
3037
+ function lookOf(theme) {
3038
+ return {
3039
+ colours: {
3040
+ ...softLook.colours,
3041
+ ...set(theme?.colours)
3042
+ },
3043
+ fonts: {
3044
+ ...softLook.fonts,
3045
+ ...set(theme?.fonts)
3046
+ },
3047
+ corners: {
3048
+ card: {
3049
+ ...softLook.corners.card,
3050
+ ...set(theme?.corners?.card)
3051
+ },
3052
+ button: {
3053
+ ...softLook.corners.button,
3054
+ ...set(theme?.corners?.button)
3055
+ },
3056
+ small: {
3057
+ ...softLook.corners.small,
3058
+ ...set(theme?.corners?.small)
3059
+ }
3060
+ },
3061
+ outline: theme?.outline ?? softLook.outline,
3062
+ pixelArt: theme?.pixelArt ?? softLook.pixelArt,
3063
+ playerMarks: theme?.playerMarks ?? softLook.playerMarks
3064
+ };
3065
+ }
3066
+ // src/features/start/start.ts
3067
+ var readText = (path) => fetch(path).then((r) => r.ok ? r.text() : Promise.reject(/* @__PURE__ */ new Error(`${path} is not there.`)));
3068
+ var readBlob = (path) => fetch(path).then((r) => r.ok ? r.blob() : Promise.reject(/* @__PURE__ */ new Error(`${path} is not there.`)));
3069
+ var nothing = (_event) => void 0;
3070
+ var lineOf = (text, name) => {
3071
+ const at = text.split("\n").findIndex((line) => line.includes(`"${name}"`));
3072
+ return at < 0 ? 1 : at + 1;
3073
+ };
3074
+ /** Mistakes in a game's files, written on the page for a person. No game starts. */
3075
+ function say(root, problems) {
3076
+ const box = document.createElement("div");
3077
+ box.setAttribute("role", "alert");
3078
+ box.style.cssText = "position:absolute;inset:0;overflow:auto;padding:1em;background:#000;color:#fff;font:17px/1.4 system-ui,sans-serif;white-space:pre-wrap";
3079
+ box.textContent = problems.map((p) => `${p.file}, line ${p.line}: ${p.message} ${p.fix}`).join("\n");
3080
+ root.replaceChildren(box);
3081
+ }
3082
+ /**
3083
+ * The whole of a game's main file: loads the game's files, draws its screens from them over the canvas, and plays it.
3084
+ * A mistake in a file is written on the page and no game starts. `window.__automata` is there from the start, and
3085
+ * `ready` is true once the first frame is on the screen.
3086
+ */
3087
+ function startGame(game, options = {}) {
3088
+ const root = options.root ?? document.body;
3089
+ const feed = createFeed();
3090
+ let state;
3091
+ let place = "loading";
3092
+ let send = nothing;
3093
+ const api = {
3094
+ ready: false,
3095
+ state: () => state,
3096
+ stats: () => ({
3097
+ ticks: state?.tick ?? 0,
3098
+ ...frameStats()
3099
+ }),
3100
+ feed: (inputs) => feed.hold(inputs),
3101
+ feedRuns: (runs) => feed.runs(runs),
3102
+ /** Does what a button does: `send('new-game')`. An event the screen does not handle changes nothing. */
3103
+ send: (event) => send(event),
3104
+ /** The name of the flow state the player is in. */
3105
+ screen: () => place
3106
+ };
3107
+ Object.assign(window, { __automata: api });
3108
+ begin(game, root, options, feed, api, (next) => state = next, (fn) => send = fn, (name) => place = name).catch((error) => say(root, [{
3109
+ file: "the game",
3110
+ line: 1,
3111
+ message: `It cannot start here. ${error instanceof Error ? error.message : String(error)}`,
3112
+ fix: "Check the files and reload."
3113
+ }]));
3114
+ }
3115
+ async function begin(game, root, options, feed, api, setState, setSend, setPlace) {
3116
+ defineShellKinds();
3117
+ const loaded = await loadGame(readText);
3118
+ if (!loaded.ok) return say(root, loaded.problems);
3119
+ const { manifest, files } = loaded.value;
3120
+ const ofKind = (kind) => manifest.content.filter((c) => c.kind === kind).map((c) => files[c.id]);
3121
+ const flow = ofKind("flow")[0];
3122
+ const screens = new Map(ofKind("screen").map((s) => [s.id, s]));
3123
+ const huds = new Map(ofKind("hud").map((h) => [h.id, h]));
3124
+ if (!flow) return say(root, [{
3125
+ file: "automata.json",
3126
+ line: 1,
3127
+ message: "No \"flow\" file is listed.",
3128
+ fix: "List a flow file that says which screen comes first."
3129
+ }]);
3130
+ const flowPath = manifest.content.find((c) => c.kind === "flow")?.path ?? "flow";
3131
+ const links = flowProblems(flow, new Set(screens.keys()), new Set(huds.keys()));
3132
+ if (links.length > 0) {
3133
+ const text = await readText(flowPath).catch(() => "");
3134
+ return say(root, links.map((p) => ({
3135
+ file: flowPath,
3136
+ line: lineOf(text, p.name),
3137
+ message: p.message,
3138
+ fix: p.fix
3139
+ })));
3140
+ }
3141
+ const look = lookOf(ofKind("theme")[0]);
3142
+ const store = browserStore();
3143
+ const saves = createSaves(store, manifest.id, () => Date.now());
3144
+ const settings = createSettings(store, manifest.id, manifest.languages, navigator.languages);
3145
+ const words = createWords({
3146
+ game: options.messages,
3147
+ shell: messages_exports,
3148
+ plain: { gameName: manifest.name }
3149
+ }, () => settings.get("language"));
3150
+ document.documentElement.lang = settings.get("language");
3151
+ await registerFonts(manifest.assets, document.fonts);
3152
+ if (root === document.body) {
3153
+ document.body.style.cssText = "margin:0;background:#000";
3154
+ document.documentElement.style.cssText = "background:#000";
3155
+ }
3156
+ const box = document.createElement("div");
3157
+ box.style.cssText = `position:${root === document.body ? "fixed" : "absolute"};inset:0;overflow:hidden;background:#000;display:flex;align-items:center;justify-content:center`;
3158
+ root.replaceChildren(box);
3159
+ const stage = await openStage({
3160
+ manifest,
3161
+ pixelArt: look.pixelArt,
3162
+ parent: box,
3163
+ read: readBlob
3164
+ });
3165
+ const fit = () => stage.fit(box.clientWidth, box.clientHeight);
3166
+ new ResizeObserver(fit).observe(box);
3167
+ fit();
3168
+ const controls = ofKind("controls")[0];
3169
+ const reader = controls ? readInputs(controls, defaultBindings(controls)) : void 0;
3170
+ let pointer = null;
3171
+ stage.canvas.addEventListener("pointerdown", (e) => pointer = stage.pointAt(e.clientX, e.clientY));
3172
+ stage.canvas.addEventListener("pointermove", (e) => pointer && (pointer = stage.pointAt(e.clientX, e.clientY)));
3173
+ window.addEventListener("pointerup", () => pointer = null);
3174
+ const real = () => {
3175
+ const inputs = reader?.read() ?? [{
3176
+ down: [],
3177
+ sticks: {}
3178
+ }];
3179
+ const first = inputs[0];
3180
+ if (first && pointer) {
3181
+ first.down = [...first.down, "pointer"];
3182
+ first.sticks = {
3183
+ ...first.sticks,
3184
+ pointer
3185
+ };
3186
+ }
3187
+ return inputs;
3188
+ };
3189
+ let current = setState(newState(game, {
3190
+ players: 1,
3191
+ seed: 1
3192
+ }));
3193
+ let playing = false;
3194
+ let slot = "1";
3195
+ const newGame = () => {
3196
+ slot = [
3197
+ "1",
3198
+ "2",
3199
+ "3"
3200
+ ].find((s) => !saves.list().some((row) => row.slot === s)) ?? "1";
3201
+ current = setState(newState(game, {
3202
+ players: 1,
3203
+ seed: Date.now() & 0x7fffffff || 1
3204
+ }));
3205
+ };
3206
+ const hasSave = writable(saves.list().length > 0);
3207
+ const refreshSaves = () => hasSave.set(saves.list().length > 0);
3208
+ const view = writable({ kind: "none" });
3209
+ const hudValues = writable([]);
3210
+ const width = writable(0);
3211
+ const language = writable(settings.get("language"));
3212
+ const settingsStore = writable(settings.all());
3213
+ const t = writable(words.word);
3214
+ settings.subscribe((all) => {
3215
+ settingsStore.set(all);
3216
+ if (all.language !== get(language)) {
3217
+ language.set(all.language);
3218
+ document.documentElement.lang = all.language;
3219
+ t.set((name, inputs) => words.word(name, inputs));
3220
+ }
3221
+ });
3222
+ let keyboard = false;
3223
+ const flowMachine = createFlow(flow, { startPlaying: manifest.start === "play" });
3224
+ let failed = false;
3225
+ let hud;
3226
+ let timer;
3227
+ const host = {
3228
+ t,
3229
+ settings: settingsStore,
3230
+ set: (name, value) => settings.set(name, value),
3231
+ send: (event) => sendEvent(event),
3232
+ hasSave,
3233
+ languages: manifest.languages,
3234
+ look,
3235
+ stageWidth: width,
3236
+ setStageWidth: (w) => width.set(w),
3237
+ noteKeyboard: (on = true) => void (keyboard = on),
3238
+ saves: () => [
3239
+ "auto",
3240
+ "1",
3241
+ "2",
3242
+ "3"
3243
+ ].map((s) => {
3244
+ const found = saves.list().find((row) => row.slot === s);
3245
+ return {
3246
+ slot: s,
3247
+ empty: !found,
3248
+ savedAt: found?.savedAt ?? 0
3249
+ };
3250
+ }),
3251
+ controls: () => (controls?.actions ?? []).map((action) => ({
3252
+ id: action.id,
3253
+ label: action.label,
3254
+ key: action.kind === "stick" ? "arrows" : (action.keys[0] ?? "").replace(/^Key/, "").replace(/^Digit/, "")
3255
+ })),
3256
+ credits: () => ofKind("credits")[0],
3257
+ assetUrl: (id) => manifest.assets.find((asset) => asset.id === id)?.path
3258
+ };
3259
+ mount(Shell, {
3260
+ target: box,
3261
+ props: {
3262
+ host,
3263
+ view,
3264
+ get hud() {
3265
+ return hud;
3266
+ },
3267
+ hudValues,
3268
+ asking: (word) => questionScreen(word, words.has)
3269
+ }
3270
+ });
3271
+ function show() {
3272
+ clearTimeout(timer);
3273
+ if (failed) {
3274
+ setPlace("error");
3275
+ view.set({
3276
+ kind: "screen",
3277
+ screen: somethingWentWrong
3278
+ });
3279
+ } else {
3280
+ const here = flowMachine.place();
3281
+ setPlace(here.at);
3282
+ if (here.hud !== void 0) {
3283
+ hud = huds.get(here.hud);
3284
+ playing = true;
3285
+ view.set({ kind: "play" });
3286
+ } else {
3287
+ playing = false;
3288
+ if (here.asking !== void 0) view.set({
3289
+ kind: "ask",
3290
+ word: here.asking
3291
+ });
3292
+ else view.set({
3293
+ kind: "screen",
3294
+ screen: screens.get(here.screen ?? "")
3295
+ });
3296
+ if (here.after !== void 0 && here.asking === void 0) timer = setTimeout(() => sendEvent("timeout"), here.after);
3297
+ }
3298
+ }
3299
+ if (keyboard && !playing) requestAnimationFrame(() => root.querySelector("button.item, .splash")?.focus({ preventScroll: true }));
3300
+ }
3301
+ const saveHere = () => {
3302
+ if (current.outcome === null) saves.write(slot, current);
3303
+ refreshSaves();
3304
+ };
3305
+ const loadSlot = (which) => {
3306
+ const read = saves.read(which);
3307
+ if (!read.ok) return false;
3308
+ slot = which;
3309
+ current = setState(read.value);
3310
+ flowMachine.play();
3311
+ return true;
3312
+ };
3313
+ function sendEvent(event) {
3314
+ if (failed) {
3315
+ if (event === "retry") {
3316
+ failed = false;
3317
+ newGame();
3318
+ flowMachine.play();
3319
+ loop.resume();
3320
+ } else if (event === "main-menu") {
3321
+ failed = false;
3322
+ flowMachine.to("menu");
3323
+ loop.resume();
3324
+ } else return;
3325
+ return show();
3326
+ }
3327
+ if (event.startsWith("slot-")) {
3328
+ const which = event.slice(5);
3329
+ if (!loadSlot(which)) {
3330
+ slot = which;
3331
+ newGame();
3332
+ slot = which;
3333
+ flowMachine.play();
3334
+ }
3335
+ return show();
3336
+ }
3337
+ if (event === "continue" && !flowMachine.handles("continue")) {
3338
+ const newest = saves.list().toSorted((a, b) => b.savedAt - a.savedAt)[0];
3339
+ if (newest && loadSlot(newest.slot)) show();
3340
+ return;
3341
+ }
3342
+ const before = flowMachine.place();
3343
+ if (!flowMachine.send(event)) return;
3344
+ const after = flowMachine.place();
3345
+ if (after.hud !== void 0 && before.hud === void 0 && (event === "new-game" || event === "retry")) newGame();
3346
+ if (before.hud !== void 0 && after.hud === void 0 && event === "pause") saveHere();
3347
+ show();
3348
+ }
3349
+ setSend(sendEvent);
3350
+ const loop = startLoop({
3351
+ step() {
3352
+ if (!playing) return;
3353
+ const begun = performance.now();
3354
+ current = setState(step(game, current, feed.next(real)));
3355
+ stage.timeUpdate(performance.now() - begun);
3356
+ if (current.outcome !== null) sendEvent(current.outcome);
3357
+ },
3358
+ draw() {
3359
+ stage.draw(game, current);
3360
+ if (playing) {
3361
+ const next = (hud?.items ?? []).map((item) => readPath(current, item.shows));
3362
+ if (next.join("\0") !== get(hudValues).join("\0")) hudValues.set(next);
3363
+ }
3364
+ api.ready = true;
3365
+ },
3366
+ onError(error) {
3367
+ console.error(error);
3368
+ failed = true;
3369
+ show();
3370
+ }
3371
+ });
3372
+ document.addEventListener("visibilitychange", () => {
3373
+ if (document.hidden) {
3374
+ loop.pause();
3375
+ if (playing) sendEvent("pause");
3376
+ } else if (!failed) loop.resume();
3377
+ });
3378
+ if (manifest.start === "play") newGame();
3379
+ show();
3380
+ }
3381
+ export { creditsSchema, flowSchema, hudSchema, screenSchema, softLook, startGame, themeSchema };