@drincs/pixi-vn 1.9.0 → 1.9.2

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.d.cts CHANGED
@@ -1,20 +1,20 @@
1
+ import * as historyUtils from '@drincs/pixi-vn/history';
2
+ export * from '@drincs/pixi-vn/history';
3
+ import * as narrationUtils from '@drincs/pixi-vn/narration';
4
+ import { NarrationGameState } from '@drincs/pixi-vn/narration';
5
+ export * from '@drincs/pixi-vn/narration';
6
+ import * as storageUtils from '@drincs/pixi-vn/storage';
7
+ export * from '@drincs/pixi-vn/storage';
1
8
  import * as canvasUtils from '@drincs/pixi-vn/canvas';
2
9
  export * from '@drincs/pixi-vn/canvas';
3
10
  import * as characterUtils from '@drincs/pixi-vn/characters';
4
11
  export * from '@drincs/pixi-vn/characters';
5
12
  import { OnErrorHandler, GameUnifier } from '@drincs/pixi-vn/core';
6
13
  export * from '@drincs/pixi-vn/core';
7
- import * as historyUtils from '@drincs/pixi-vn/history';
8
- export * from '@drincs/pixi-vn/history';
9
- import * as narrationUtils from '@drincs/pixi-vn/narration';
10
- import { NarrationGameState } from '@drincs/pixi-vn/narration';
11
- export * from '@drincs/pixi-vn/narration';
12
14
  import { ApplicationOptions } from '@drincs/pixi-vn/pixi.js';
13
15
  export { AllFederatedEventMap, ApplicationOptions, AssetSrc, AssetsBundle, AssetsManifest, FederatedEvent, LoadParserName, ResolvedAsset, ResolvedSrc, UnresolvedAsset } from '@drincs/pixi-vn/pixi.js';
14
16
  import * as soundUtils from '@drincs/pixi-vn/sound';
15
17
  export * from '@drincs/pixi-vn/sound';
16
- import * as storageUtils from '@drincs/pixi-vn/storage';
17
- export * from '@drincs/pixi-vn/storage';
18
18
  export { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
19
19
  import { e as CanvasGameState } from './ContainerMemory-BpDgacyr.cjs';
20
20
  import { H as HistoryGameState } from './HistoryGameState-CGfvq5iL.cjs';
@@ -29,7 +29,111 @@ import 'microdiff';
29
29
  import 'tone';
30
30
  import './StorageElementType-C7ETezlL.cjs';
31
31
 
32
- var version = "1.9.0";
32
+ /**
33
+ * One error captured by {@link createGameTesting}'s `enable` while testing is active, via
34
+ * `Game.addOnError`.
35
+ */
36
+ interface GameTestingErrorEntry {
37
+ error: unknown;
38
+ timestamp: number;
39
+ }
40
+ /**
41
+ * A read-only snapshot of everything a test session typically needs to decide its next
42
+ * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
43
+ * in a single call instead of reading several properties one by one.
44
+ */
45
+ interface GameTestingState {
46
+ dialogue: narrationUtils.DialogueInterface | undefined;
47
+ dialogueGlue: boolean;
48
+ choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
49
+ input: {
50
+ isRequired: boolean;
51
+ type: string | undefined;
52
+ value: storageUtils.StorageElementType;
53
+ };
54
+ canContinue: boolean;
55
+ canGoBack: boolean;
56
+ labelsOpened: narrationUtils.OpenedLabel[];
57
+ currentLabelId: string | undefined;
58
+ stepCounter: number;
59
+ }
60
+ /**
61
+ * The object attached to `window` (and returned) by `enable`. Every action method
62
+ * merges the most recent props passed to `setProps` with any `extraProps` given here,
63
+ * then delegates to the matching narration/history call — so calling these behaves exactly
64
+ * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
65
+ *
66
+ * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
67
+ * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
68
+ */
69
+ interface GameTestingAPI<TGame, T extends {} = {}> {
70
+ readonly Game: TGame;
71
+ readonly narration: narrationUtils.NarrationManagerInterface;
72
+ readonly storage: storageUtils.StorageManagerInterface;
73
+ readonly stepHistory: historyUtils.HistoryManagerInterface;
74
+ /**
75
+ * The most recent props passed to `setProps` — whatever your app's `StepLabelProps`
76
+ * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
77
+ * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
78
+ * for full control over what's on screen.
79
+ */
80
+ readonly props: narrationUtils.StepLabelPropsType<T>;
81
+ /** `Game.start` using the live props plus any `extraProps`. */
82
+ start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
83
+ /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
84
+ continue(extraProps?: Partial<T>, options?: {
85
+ steps?: number;
86
+ runNow?: boolean;
87
+ }): Promise<narrationUtils.StepLabelResultType>;
88
+ /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
89
+ call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
90
+ /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
91
+ jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
92
+ /**
93
+ * Selects the currently open choice with this `choiceIndex` (as seen in
94
+ * `getState().choices`), using the live props plus any `extraProps`.
95
+ * @throws when no open choice has that index.
96
+ */
97
+ selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
98
+ /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
99
+ setInput(value: storageUtils.StorageElementType): void;
100
+ /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
101
+ goBack(extraProps?: Partial<T>, options?: {
102
+ steps?: number;
103
+ }): Promise<narrationUtils.StepLabelResultType>;
104
+ /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
105
+ closeCurrentLabel(): void;
106
+ /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
107
+ closeAllLabels(): void;
108
+ /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
109
+ getState(): GameTestingState;
110
+ /** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
111
+ readonly errors: GameTestingErrorEntry[];
112
+ clearErrors(): void;
113
+ }
114
+ /**
115
+ * Per-action overrides an app can register via `setActions` so `Game.testing`'s
116
+ * window-exposed actions run the app's own narration functions — with whatever UI-only side
117
+ * effects they add (loading state, blocking while a menu is open, refreshing cached interface
118
+ * data, ...) — instead of calling {@link narrationUtils.narration} / {@link
119
+ * historyUtils.stepHistory} directly. Any action left undefined keeps the default behavior.
120
+ *
121
+ * `continue`/`back` take no arguments: the `extraProps`/`options` a caller passes to the
122
+ * corresponding {@link GameTestingAPI} method are ignored when an override is registered,
123
+ * since the override already has its own way to gather props (and typically doesn't support
124
+ * stepped/replay options). `selectChoice` receives the resolved choice item instead of the
125
+ * raw `choiceIndex`, since looking it up is already handled before the override runs.
126
+ */
127
+ interface GameTestingActions<T extends {} = {}> {
128
+ continue?: () => Promise<void>;
129
+ back?: () => Promise<void>;
130
+ selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
131
+ start?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<void>;
132
+ jump?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
133
+ call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
134
+ }
135
+
136
+ var version = "1.9.2";
33
137
 
34
138
  /**
35
139
  * Is a special alias to indicate the game layer.
@@ -364,6 +468,33 @@ declare namespace Game {
364
468
  */
365
469
  function addOnPreContinue(handler: () => Promise<void> | void): void;
366
470
  function removeOnPreContinue(handler: () => Promise<void> | void): void;
471
+ /**
472
+ * Lets an AI agent (or any external script/browser console) drive and inspect a running game
473
+ * through `window`, without needing to know the app's own UI wiring. Not enabled by default —
474
+ * something must opt in, typically only in development. Two pieces are needed:
475
+ * - `enable()`/`disable()` turn the `window` bridge on/off — the `@drincs/pixi-vn/vite` plugin's
476
+ * `testing` option does this automatically while its dev server is running, with no extra code.
477
+ * - `setProps(props)` keeps the live app props (`navigate`/`t`/`toast`/etc.) available to every
478
+ * action — call it unconditionally from wherever your app builds those props (e.g. at the end
479
+ * of a `useGameProps()`-style hook), since every action needs up-to-date props whether or not
480
+ * testing happens to be enabled right now.
481
+ * - `setActions(actions)` is optional: if the app wraps `narration`/`stepHistory` in its own
482
+ * functions to handle UI-only concerns (a loading indicator, blocking while a menu is open,
483
+ * refreshing cached interface data, ...), it can register those functions so `continue()`,
484
+ * `goBack()`, `selectChoice()`, `start()`, `jump()` and `call()` drive the game through them
485
+ * instead of calling `narration`/`stepHistory` directly — same as a real player action would.
486
+ * See the `pixi-vn-testing` skill for the full guide (activation patterns, the complete command
487
+ * surface, and cookbook snippets for a browser-driven test session).
488
+ */
489
+ const testing: {
490
+ setProps: <T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>) => void;
491
+ setActions: <T extends {} = {}>(actions: GameTestingActions<T>) => void;
492
+ enable: <T extends {} = {}>(options?: {
493
+ windowKey?: string;
494
+ } | undefined) => GameTestingAPI<typeof Game, T>;
495
+ disable: () => void;
496
+ isEnabled: () => boolean;
497
+ };
367
498
  }
368
499
  declare const _default: {
369
500
  canvas: canvasUtils.CanvasManagerInterface;
@@ -382,4 +513,4 @@ declare const _default: {
382
513
  PIXIVN_VERSION: string;
383
514
  };
384
515
 
385
- export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
516
+ export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, type GameTestingAPI, type GameTestingActions, type GameTestingErrorEntry, type GameTestingState, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
+ import * as historyUtils from '@drincs/pixi-vn/history';
2
+ export * from '@drincs/pixi-vn/history';
3
+ import * as narrationUtils from '@drincs/pixi-vn/narration';
4
+ import { NarrationGameState } from '@drincs/pixi-vn/narration';
5
+ export * from '@drincs/pixi-vn/narration';
6
+ import * as storageUtils from '@drincs/pixi-vn/storage';
7
+ export * from '@drincs/pixi-vn/storage';
1
8
  import * as canvasUtils from '@drincs/pixi-vn/canvas';
2
9
  export * from '@drincs/pixi-vn/canvas';
3
10
  import * as characterUtils from '@drincs/pixi-vn/characters';
4
11
  export * from '@drincs/pixi-vn/characters';
5
12
  import { OnErrorHandler, GameUnifier } from '@drincs/pixi-vn/core';
6
13
  export * from '@drincs/pixi-vn/core';
7
- import * as historyUtils from '@drincs/pixi-vn/history';
8
- export * from '@drincs/pixi-vn/history';
9
- import * as narrationUtils from '@drincs/pixi-vn/narration';
10
- import { NarrationGameState } from '@drincs/pixi-vn/narration';
11
- export * from '@drincs/pixi-vn/narration';
12
14
  import { ApplicationOptions } from '@drincs/pixi-vn/pixi.js';
13
15
  export { AllFederatedEventMap, ApplicationOptions, AssetSrc, AssetsBundle, AssetsManifest, FederatedEvent, LoadParserName, ResolvedAsset, ResolvedSrc, UnresolvedAsset } from '@drincs/pixi-vn/pixi.js';
14
16
  import * as soundUtils from '@drincs/pixi-vn/sound';
15
17
  export * from '@drincs/pixi-vn/sound';
16
- import * as storageUtils from '@drincs/pixi-vn/storage';
17
- export * from '@drincs/pixi-vn/storage';
18
18
  export { C as CachedMap } from './CachedMap-DZLvJAnA.js';
19
19
  import { e as CanvasGameState } from './ContainerMemory-BpDgacyr.js';
20
20
  import { H as HistoryGameState } from './HistoryGameState-C8ATx9K6.js';
@@ -29,7 +29,111 @@ import 'microdiff';
29
29
  import 'tone';
30
30
  import './StorageElementType-C7ETezlL.js';
31
31
 
32
- var version = "1.9.0";
32
+ /**
33
+ * One error captured by {@link createGameTesting}'s `enable` while testing is active, via
34
+ * `Game.addOnError`.
35
+ */
36
+ interface GameTestingErrorEntry {
37
+ error: unknown;
38
+ timestamp: number;
39
+ }
40
+ /**
41
+ * A read-only snapshot of everything a test session typically needs to decide its next
42
+ * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
43
+ * in a single call instead of reading several properties one by one.
44
+ */
45
+ interface GameTestingState {
46
+ dialogue: narrationUtils.DialogueInterface | undefined;
47
+ dialogueGlue: boolean;
48
+ choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
49
+ input: {
50
+ isRequired: boolean;
51
+ type: string | undefined;
52
+ value: storageUtils.StorageElementType;
53
+ };
54
+ canContinue: boolean;
55
+ canGoBack: boolean;
56
+ labelsOpened: narrationUtils.OpenedLabel[];
57
+ currentLabelId: string | undefined;
58
+ stepCounter: number;
59
+ }
60
+ /**
61
+ * The object attached to `window` (and returned) by `enable`. Every action method
62
+ * merges the most recent props passed to `setProps` with any `extraProps` given here,
63
+ * then delegates to the matching narration/history call — so calling these behaves exactly
64
+ * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
65
+ *
66
+ * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
67
+ * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
68
+ */
69
+ interface GameTestingAPI<TGame, T extends {} = {}> {
70
+ readonly Game: TGame;
71
+ readonly narration: narrationUtils.NarrationManagerInterface;
72
+ readonly storage: storageUtils.StorageManagerInterface;
73
+ readonly stepHistory: historyUtils.HistoryManagerInterface;
74
+ /**
75
+ * The most recent props passed to `setProps` — whatever your app's `StepLabelProps`
76
+ * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
77
+ * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
78
+ * for full control over what's on screen.
79
+ */
80
+ readonly props: narrationUtils.StepLabelPropsType<T>;
81
+ /** `Game.start` using the live props plus any `extraProps`. */
82
+ start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
83
+ /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
84
+ continue(extraProps?: Partial<T>, options?: {
85
+ steps?: number;
86
+ runNow?: boolean;
87
+ }): Promise<narrationUtils.StepLabelResultType>;
88
+ /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
89
+ call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
90
+ /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
91
+ jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
92
+ /**
93
+ * Selects the currently open choice with this `choiceIndex` (as seen in
94
+ * `getState().choices`), using the live props plus any `extraProps`.
95
+ * @throws when no open choice has that index.
96
+ */
97
+ selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
98
+ /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
99
+ setInput(value: storageUtils.StorageElementType): void;
100
+ /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
101
+ goBack(extraProps?: Partial<T>, options?: {
102
+ steps?: number;
103
+ }): Promise<narrationUtils.StepLabelResultType>;
104
+ /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
105
+ closeCurrentLabel(): void;
106
+ /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
107
+ closeAllLabels(): void;
108
+ /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
109
+ getState(): GameTestingState;
110
+ /** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
111
+ readonly errors: GameTestingErrorEntry[];
112
+ clearErrors(): void;
113
+ }
114
+ /**
115
+ * Per-action overrides an app can register via `setActions` so `Game.testing`'s
116
+ * window-exposed actions run the app's own narration functions — with whatever UI-only side
117
+ * effects they add (loading state, blocking while a menu is open, refreshing cached interface
118
+ * data, ...) — instead of calling {@link narrationUtils.narration} / {@link
119
+ * historyUtils.stepHistory} directly. Any action left undefined keeps the default behavior.
120
+ *
121
+ * `continue`/`back` take no arguments: the `extraProps`/`options` a caller passes to the
122
+ * corresponding {@link GameTestingAPI} method are ignored when an override is registered,
123
+ * since the override already has its own way to gather props (and typically doesn't support
124
+ * stepped/replay options). `selectChoice` receives the resolved choice item instead of the
125
+ * raw `choiceIndex`, since looking it up is already handled before the override runs.
126
+ */
127
+ interface GameTestingActions<T extends {} = {}> {
128
+ continue?: () => Promise<void>;
129
+ back?: () => Promise<void>;
130
+ selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
131
+ start?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<void>;
132
+ jump?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
133
+ call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
134
+ }
135
+
136
+ var version = "1.9.2";
33
137
 
34
138
  /**
35
139
  * Is a special alias to indicate the game layer.
@@ -364,6 +468,33 @@ declare namespace Game {
364
468
  */
365
469
  function addOnPreContinue(handler: () => Promise<void> | void): void;
366
470
  function removeOnPreContinue(handler: () => Promise<void> | void): void;
471
+ /**
472
+ * Lets an AI agent (or any external script/browser console) drive and inspect a running game
473
+ * through `window`, without needing to know the app's own UI wiring. Not enabled by default —
474
+ * something must opt in, typically only in development. Two pieces are needed:
475
+ * - `enable()`/`disable()` turn the `window` bridge on/off — the `@drincs/pixi-vn/vite` plugin's
476
+ * `testing` option does this automatically while its dev server is running, with no extra code.
477
+ * - `setProps(props)` keeps the live app props (`navigate`/`t`/`toast`/etc.) available to every
478
+ * action — call it unconditionally from wherever your app builds those props (e.g. at the end
479
+ * of a `useGameProps()`-style hook), since every action needs up-to-date props whether or not
480
+ * testing happens to be enabled right now.
481
+ * - `setActions(actions)` is optional: if the app wraps `narration`/`stepHistory` in its own
482
+ * functions to handle UI-only concerns (a loading indicator, blocking while a menu is open,
483
+ * refreshing cached interface data, ...), it can register those functions so `continue()`,
484
+ * `goBack()`, `selectChoice()`, `start()`, `jump()` and `call()` drive the game through them
485
+ * instead of calling `narration`/`stepHistory` directly — same as a real player action would.
486
+ * See the `pixi-vn-testing` skill for the full guide (activation patterns, the complete command
487
+ * surface, and cookbook snippets for a browser-driven test session).
488
+ */
489
+ const testing: {
490
+ setProps: <T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>) => void;
491
+ setActions: <T extends {} = {}>(actions: GameTestingActions<T>) => void;
492
+ enable: <T extends {} = {}>(options?: {
493
+ windowKey?: string;
494
+ } | undefined) => GameTestingAPI<typeof Game, T>;
495
+ disable: () => void;
496
+ isEnabled: () => boolean;
497
+ };
367
498
  }
368
499
  declare const _default: {
369
500
  canvas: canvasUtils.CanvasManagerInterface;
@@ -382,4 +513,4 @@ declare const _default: {
382
513
  PIXIVN_VERSION: string;
383
514
  };
384
515
 
385
- export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
516
+ export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, type GameTestingAPI, type GameTestingActions, type GameTestingErrorEntry, type GameTestingState, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {f as f$1,b as b$1,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as M from'@drincs/pixi-vn/canvas';export*from'@drincs/pixi-vn/canvas';import*as kt from'@drincs/pixi-vn/characters';export*from'@drincs/pixi-vn/characters';import {PixiError,GameUnifier}from'@drincs/pixi-vn/core';export*from'@drincs/pixi-vn/core';import*as st from'@drincs/pixi-vn/history';export*from'@drincs/pixi-vn/history';import*as O from'@drincs/pixi-vn/narration';export*from'@drincs/pixi-vn/narration';import*as ut from'@drincs/pixi-vn/sound';export*from'@drincs/pixi-vn/sound';import*as z from'@drincs/pixi-vn/storage';export*from'@drincs/pixi-vn/storage';import {motion}from'@drincs/pixi-vn/motion';var he=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xt=new Set,jt=typeof process=="object"&&process?process:{},Jt=(g,e,i,s)=>{typeof jt.emitWarning=="function"?jt.emitWarning(g,e,i,s):console.error(`[${i}] ${e}: ${g}`);},Nt=globalThis.AbortController,qt=globalThis.AbortSignal;if(typeof Nt>"u"){qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new qt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let g=jt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{g&&(g=false,Jt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var ce=g=>!Xt.has(g);var lt=g=>g&&g===Math.floor(g)&&g>0&&isFinite(g),Qt=g=>lt(g)?g<=Math.pow(2,8)?Uint8Array:g<=Math.pow(2,16)?Uint16Array:g<=Math.pow(2,32)?Uint32Array:g<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(g){super(g),this.fill(0);}},rt,vt,de=(rt=class{heap;length;static create(e){let i=Qt(e);if(!i)return [];g(rt,vt,true);let s=new rt(e,i);return g(rt,vt,false),s}constructor(e$1,i){if(!e(rt,vt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},vt=new WeakMap,f$1(rt,vt,false),rt),$t,Bt,q,V,B,ft,X,St,yt,J,R,Q,U,x,f,j,W,F,D,Z,C,tt,et,Y,H,it,pt,P,bt,a,Pt,mt,nt,Tt,K,te,gt,xt,Ut,ht,ct,Mt,Dt,Ct,b,zt,At,dt,Gt,Et,Zt=(Et=class{constructor(e$1){f$1(this,a);f$1(this,q);f$1(this,V);f$1(this,B);f$1(this,ft);f$1(this,X);f$1(this,St);f$1(this,yt);f$1(this,J);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f$1(this,R);f$1(this,Q);f$1(this,U);f$1(this,x);f$1(this,f);f$1(this,j);f$1(this,W);f$1(this,F);f$1(this,D);f$1(this,Z);f$1(this,C);f$1(this,tt);f$1(this,et);f$1(this,Y);f$1(this,H);f$1(this,it);f$1(this,pt);f$1(this,P);f$1(this,bt);f$1(this,mt,()=>{});f$1(this,nt,()=>{});f$1(this,Tt,()=>{});f$1(this,K,()=>false);f$1(this,gt,e=>{});f$1(this,xt,(e,i,s)=>{});f$1(this,Ut,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:c,dispose:v,onInsert:L,disposeAfter:S,noDisposeOnSet:ot,noUpdateTTL:G,maxSize:$=0,maxEntrySize:E=0,sizeCalculation:y,fetchMethod:m,memoMethod:u,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:d$1,allowStaleOnFetchAbort:A,ignoreFetchAbort:I,perf:k}=e$1;if(k!==void 0&&typeof k?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,J,k??he),i!==0&&!lt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?Qt(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(g(this,q,i),g(this,V,$),this.maxEntrySize=E||e(this,V),this.sizeCalculation=y,this.sizeCalculation){if(!e(this,V)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(u!==void 0&&typeof u!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,yt,u),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,St,m),g(this,pt,!!m),g(this,U,new Map),g(this,x,new Array(i).fill(void 0)),g(this,f,new Array(i).fill(void 0)),g(this,j,new _t(i)),g(this,W,new _t(i)),g(this,F,0),g(this,D,0),g(this,Z,de.create(i)),g(this,R,0),g(this,Q,0),typeof v=="function"&&g(this,B,v),typeof L=="function"&&g(this,ft,L),typeof S=="function"?(g(this,X,S),g(this,C,[])):(g(this,X,void 0),g(this,C,void 0)),g(this,it,!!e(this,B)),g(this,bt,!!e(this,ft)),g(this,P,!!e(this,X)),this.noDisposeOnSet=!!ot,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!d$1,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!I,this.maxEntrySize!==0){if(e(this,V)!==0&&!lt(e(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,te).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=lt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,Pt).call(this);}if(e(this,q)===0&&this.ttl===0&&e(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,q)&&!e(this,V)){let Ft="LRU_CACHE_UNBOUNDED";ce(Ft)&&(Xt.add(Ft),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,Et));}}get perf(){return e(this,J)}static unsafeExposeInternals(e$1){return {starts:e(e$1,et),ttls:e(e$1,Y),autopurgeTimers:e(e$1,H),sizes:e(e$1,tt),keyMap:e(e$1,U),keyList:e(e$1,x),valList:e(e$1,f),next:e(e$1,j),prev:e(e$1,W),get head(){return e(e$1,F)},get tail(){return e(e$1,D)},free:e(e$1,Z),isBackgroundFetch:i=>{var s;return h(s=e$1,a,b).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return h(o=e$1,a,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return h(s=e$1,a,At).call(s,i)},indexes:i=>{var s;return h(s=e$1,a,ht).call(s,i)},rindexes:i=>{var s;return h(s=e$1,a,ct).call(s,i)},isStale:i=>{var s;return e(s=e$1,K).call(s,i)}}}get max(){return e(this,q)}get maxSize(){return e(this,V)}get calculatedSize(){return e(this,Q)}get size(){return e(this,R)}get fetchMethod(){return e(this,St)}get memoMethod(){return e(this,yt)}get dispose(){return e(this,B)}get onInsert(){return e(this,ft)}get disposeAfter(){return e(this,X)}getRemainingTTL(e$1){return e(this,U).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,a,ht).call(this))e(this,f)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield [e(this,x)[e$1],e(this,f)[e$1]]);}*rentries(){for(let e$1 of h(this,a,ct).call(this))e(this,f)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield [e(this,x)[e$1],e(this,f)[e$1]]);}*keys(){for(let e$1 of h(this,a,ht).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,a,ct).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,a,ht).call(this))e(this,f)[e$1]!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}*rvalues(){for(let e$1 of h(this,a,ct).call(this))e(this,f)[e$1]!==void 0&&!h(this,a,b).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}[(Bt=Symbol.iterator,$t=Symbol.toStringTag,Bt)](){return this.entries()}find(e$1,i={}){for(let s of h(this,a,ht).call(this)){let r=e(this,f)[s],n=h(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e$1(n,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(e$1,i=this){for(let s of h(this,a,ht).call(this)){let r=e(this,f)[s],n=h(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,x)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,a,ct).call(this)){let r=e(this,f)[s],n=h(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,x)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,a,ct).call(this,{allowStale:true}))e(this,K).call(this,i)&&(h(this,a,dt).call(this,e(this,x)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,U).get(e$1);if(i===void 0)return;let s=e(this,f)[i],r=h(this,a,b).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(e(this,Y)&&e(this,et)){let o=e(this,Y)[i],l=e(this,et)[i];if(o&&l){let c=o-(e(this,J).now()-l);n.ttl=c,n.start=Date.now();}}return e(this,tt)&&(n.size=e(this,tt)[i]),n}dump(){let e$1=[];for(let i of h(this,a,ht).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,f)[i],n=h(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(e(this,Y)&&e(this,et)){o.ttl=e(this,Y)[i];let l=e(this,J).now()-e(this,et)[i];o.start=Math.floor(Date.now()-l);}e(this,tt)&&(o.size=e(this,tt)[i]),e$1.unshift([s,o]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,J).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var ot,G,$,E;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,L=e(this,Ut).call(this,e$1,i$1,s.size||0,l);if(this.maxEntrySize&&L>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,a,dt).call(this,e$1,"set"),this;let S=e(this,R)===0?void 0:e(this,U).get(e$1);if(S===void 0)S=e(this,R)===0?e(this,D):e(this,Z).length!==0?e(this,Z).pop():e(this,R)===e(this,q)?h(this,a,Dt).call(this,false):e(this,R),e(this,x)[S]=e$1,e(this,f)[S]=i$1,e(this,U).set(e$1,S),e(this,j)[e(this,D)]=S,e(this,W)[S]=e(this,D),g(this,D,S),i(this,R)._++,e(this,xt).call(this,S,L,c),c&&(c.set="add"),v=false,e(this,bt)&&((ot=e(this,ft))==null||ot.call(this,i$1,e$1,"add"));else {h(this,a,At).call(this,S);let y=e(this,f)[S];if(i$1!==y){if(e(this,pt)&&h(this,a,b).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=y;m!==void 0&&!o&&(e(this,it)&&((G=e(this,B))==null||G.call(this,m,e$1,"set")),e(this,P)&&e(this,C)?.push([m,e$1,"set"]));}else o||(e(this,it)&&(($=e(this,B))==null||$.call(this,y,e$1,"set")),e(this,P)&&e(this,C)?.push([y,e$1,"set"]));if(e(this,gt).call(this,S),e(this,xt).call(this,S,L,c),e(this,f)[S]=i$1,c){c.set="replace";let m=y&&h(this,a,b).call(this,y)?y.__staleWhileFetching:y;m!==void 0&&(c.oldValue=m);}}else c&&(c.set="update");e(this,bt)&&this.onInsert?.(i$1,e$1,i$1===y?"update":"replace");}if(r!==0&&!e(this,Y)&&h(this,a,Pt).call(this),e(this,Y)&&(v||e(this,Tt).call(this,S,r,n),c&&e(this,nt).call(this,c,S)),!o&&e(this,P)&&e(this,C)){let y=e(this,C),m;for(;m=y?.shift();)(E=e(this,X))==null||E.call(this,...m);}return this}pop(){var e$1;try{for(;e(this,R);){let i=e(this,f)[e(this,F)];if(h(this,a,Dt).call(this,!0),h(this,a,b).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,P)&&e(this,C)){let i=e(this,C),s;for(;s=i?.shift();)(e$1=e(this,X))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=e(this,U).get(e$1);if(n!==void 0){let o=e(this,f)[n];if(h(this,a,b).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(e(this,K).call(this,n))r&&(r.has="stale",e(this,nt).call(this,r,n));else return s&&e(this,mt).call(this,n),r&&(r.has="hit",e(this,nt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,U).get(e$1);if(r===void 0||!s&&e(this,K).call(this,r))return;let n=e(this,f)[r];return h(this,a,b).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ot=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:E,forceRefresh:y=false,status:m,signal:u}=i;if(!e(this,pt))return m&&(m.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:m});let w={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:l,size:c,sizeCalculation:v,noUpdateTTL:L,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:ot,allowStaleOnFetchAbort:$,ignoreFetchAbort:G,status:m,signal:u},T=e(this,U).get(e$1);if(T===void 0){m&&(m.fetch="miss");let d=h(this,a,Ct).call(this,e$1,T,w,E);return d.__returned=d}else {let d=e(this,f)[T];if(h(this,a,b).call(this,d)){let _t=s&&d.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",_t&&(m.returnedStale=true)),_t?d.__staleWhileFetching:d.__returned=d}let A=e(this,K).call(this,T);if(!y&&!A)return m&&(m.fetch="hit"),h(this,a,At).call(this,T),r&&e(this,mt).call(this,T),m&&e(this,nt).call(this,m,T),d;let I=h(this,a,Ct).call(this,e$1,T,w,E),k=I.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=A?"stale":"refresh",k&&A&&(m.returnedStale=true)),k?I.__staleWhileFetching:I.__returned=I}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,yt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,l=this.get(e$1,o);if(!n&&l!==void 0)return l;let c=s(e$1,l,{options:o,context:r});return this.set(e$1,c,o),c}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,l=e(this,U).get(e$1);if(l!==void 0){let c=e(this,f)[l],v=h(this,a,b).call(this,c);return o&&e(this,nt).call(this,o,l),e(this,K).call(this,l)?(o&&(o.get="stale"),v?(o&&s&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?c.__staleWhileFetching:void 0):(n||h(this,a,dt).call(this,e$1,"expire"),o&&s&&(o.returnedStale=true),s?c:void 0)):(o&&(o.get="hit"),v?c.__staleWhileFetching:(h(this,a,At).call(this,l),r&&e(this,mt).call(this,l),c))}else o&&(o.get="miss");}delete(e){return h(this,a,dt).call(this,e,"delete")}clear(){return h(this,a,Gt).call(this,"delete")}},q=new WeakMap,V=new WeakMap,B=new WeakMap,ft=new WeakMap,X=new WeakMap,St=new WeakMap,yt=new WeakMap,J=new WeakMap,R=new WeakMap,Q=new WeakMap,U=new WeakMap,x=new WeakMap,f=new WeakMap,j=new WeakMap,W=new WeakMap,F=new WeakMap,D=new WeakMap,Z=new WeakMap,C=new WeakMap,tt=new WeakMap,et=new WeakMap,Y=new WeakMap,H=new WeakMap,it=new WeakMap,pt=new WeakMap,P=new WeakMap,bt=new WeakMap,a=new WeakSet,Pt=function(){let e$1=new Lt(e(this,q)),i=new Lt(e(this,q));g(this,Y,e$1),g(this,et,i);let s=this.ttlAutopurge?new Array(e(this,q)):void 0;g(this,H,s),g(this,Tt,(l,c,v=e(this,J).now())=>{i[l]=c!==0?v:0,e$1[l]=c,r(l,c);}),g(this,mt,l=>{i[l]=e$1[l]!==0?e(this,J).now():0,r(l,e$1[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let v=setTimeout(()=>{e(this,K).call(this,l)&&h(this,a,dt).call(this,e(this,x)[l],"expire");},c+1);v.unref&&v.unref(),s[l]=v;}}:()=>{};g(this,nt,(l,c)=>{if(e$1[c]){let v=e$1[c],L=i[c];if(!v||!L)return;l.ttl=v,l.start=L,l.now=n||o();let S=l.now-L;l.remainingTTL=v-S;}});let n=0,o=()=>{let l=e(this,J).now();if(this.ttlResolution>0){n=l;let c=setTimeout(()=>n=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=e(this,U).get(l);if(c===void 0)return 0;let v=e$1[c],L=i[c];if(!v||!L)return 1/0;let S=(n||o())-L;return v-S},g(this,K,l=>{let c=i[l],v=e$1[l];return !!v&&!!c&&(n||o())-c>v});},mt=new WeakMap,nt=new WeakMap,Tt=new WeakMap,K=new WeakMap,te=function(){let e$1=new Lt(e(this,q));g(this,Q,0),g(this,tt,e$1),g(this,gt,i=>{g(this,Q,e(this,Q)-e$1[i]),e$1[i]=0;}),g(this,Ut,(i,s,r,n)=>{if(h(this,a,b).call(this,s))return 0;if(!lt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!lt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),g(this,xt,(i,s,r)=>{if(e$1[i]=s,e(this,V)){let n=e(this,V)-e$1[i];for(;e(this,Q)>n;)h(this,a,Dt).call(this,true);}g(this,Q,e(this,Q)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,Q));});},gt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,ht=function*({allowStale:e$1=this.allowStale}={}){if(e(this,R))for(let i=e(this,D);!(!h(this,a,Mt).call(this,i)||((e$1||!e(this,K).call(this,i))&&(yield i),i===e(this,F)));)i=e(this,W)[i];},ct=function*({allowStale:e$1=this.allowStale}={}){if(e(this,R))for(let i=e(this,F);!(!h(this,a,Mt).call(this,i)||((e$1||!e(this,K).call(this,i))&&(yield i),i===e(this,D)));)i=e(this,j)[i];},Mt=function(e$1){return e$1!==void 0&&e(this,U).get(e(this,x)[e$1])===e$1},Dt=function(e$1){var n;let i$1=e(this,F),s=e(this,x)[i$1],r=e(this,f)[i$1];return e(this,pt)&&h(this,a,b).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,it)||e(this,P))&&(e(this,it)&&((n=e(this,B))==null||n.call(this,r,s,"evict")),e(this,P)&&e(this,C)?.push([r,s,"evict"])),e(this,gt).call(this,i$1),e(this,H)?.[i$1]&&(clearTimeout(e(this,H)[i$1]),e(this,H)[i$1]=void 0),e$1&&(e(this,x)[i$1]=void 0,e(this,f)[i$1]=void 0,e(this,Z).push(i$1)),e(this,R)===1?(g(this,F,g(this,D,0)),e(this,Z).length=0):g(this,F,e(this,j)[i$1]),e(this,U).delete(s),i(this,R)._--,i$1},Ct=function(e$1,i,s,r){let n=i===void 0?void 0:e(this,f)[i];if(h(this,a,b).call(this,n))return n;let o=new Nt,{signal:l}=s;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let c={signal:o.signal,options:s,context:r},v=(E,y=false)=>{let{aborted:m}=o.signal,u=s.ignoreFetchAbort&&E!==void 0,w=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&E!==void 0);if(s.status&&(m&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,u&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!u&&!y)return S(o.signal.reason,w);let T=G,d=e(this,f)[i];return (d===G||u&&y&&d===void 0)&&(E===void 0?T.__staleWhileFetching!==void 0?e(this,f)[i]=T.__staleWhileFetching:h(this,a,dt).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,E,c.options))),E},L=E=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=E),S(E,false)),S=(E,y)=>{let{aborted:m}=o.signal,u=m&&s.allowStaleOnFetchAbort,w=u||s.allowStaleOnFetchRejection,T=w||s.noDeleteOnFetchRejection,d=G;if(e(this,f)[i]===G&&(!T||!y&&d.__staleWhileFetching===void 0?h(this,a,dt).call(this,e$1,"fetch"):u||(e(this,f)[i]=d.__staleWhileFetching)),w)return s.status&&d.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),d.__staleWhileFetching;if(d.__returned===d)throw E},ot=(E,y)=>{var u;let m=(u=e(this,St))==null?void 0:u.call(this,e$1,n,c);m&&m instanceof Promise&&m.then(w=>E(w===void 0?void 0:w),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(E(void 0),s.allowStaleOnFetchAbort&&(E=w=>v(w,true)));});};s.status&&(s.status.fetchDispatched=true);let G=new Promise(ot).then(v,L),$=Object.assign(G,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,$,{...c.options,status:void 0}),i=e(this,U).get(e$1)):e(this,f)[i]=$,$},b=function(e$1){if(!e(this,pt))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},zt=function(e$1,i){e(this,W)[i]=e$1,e(this,j)[e$1]=i;},At=function(e$1){e$1!==e(this,D)&&(e$1===e(this,F)?g(this,F,e(this,j)[e$1]):h(this,a,zt).call(this,e(this,W)[e$1],e(this,j)[e$1]),h(this,a,zt).call(this,e(this,D),e$1),g(this,D,e$1));},dt=function(e$1,i$1){var r,n;let s=false;if(e(this,R)!==0){let o=e(this,U).get(e$1);if(o!==void 0)if(e(this,H)?.[o]&&(clearTimeout(e(this,H)?.[o]),e(this,H)[o]=void 0),s=true,e(this,R)===1)h(this,a,Gt).call(this,i$1);else {e(this,gt).call(this,o);let l=e(this,f)[o];if(h(this,a,b).call(this,l)?l.__abortController.abort(new Error("deleted")):(e(this,it)||e(this,P))&&(e(this,it)&&((r=e(this,B))==null||r.call(this,l,e$1,i$1)),e(this,P)&&e(this,C)?.push([l,e$1,i$1])),e(this,U).delete(e$1),e(this,x)[o]=void 0,e(this,f)[o]=void 0,o===e(this,D))g(this,D,e(this,W)[o]);else if(o===e(this,F))g(this,F,e(this,j)[o]);else {let c=e(this,W)[o];e(this,j)[c]=e(this,j)[o];let v=e(this,j)[o];e(this,W)[v]=e(this,W)[o];}i(this,R)._--,e(this,Z).push(o);}}if(e(this,P)&&e(this,C)?.length){let o=e(this,C),l;for(;l=o?.shift();)(n=e(this,X))==null||n.call(this,...l);}return s},Gt=function(e$1){var i,s;for(let r of h(this,a,ct).call(this,{allowStale:true})){let n=e(this,f)[r];if(h(this,a,b).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=e(this,x)[r];e(this,it)&&((i=e(this,B))==null||i.call(this,n,o,e$1)),e(this,P)&&e(this,C)?.push([n,o,e$1]);}}if(e(this,U).clear(),e(this,f).fill(void 0),e(this,x).fill(void 0),e(this,Y)&&e(this,et)){e(this,Y).fill(0),e(this,et).fill(0);for(let r of e(this,H)??[])r!==void 0&&clearTimeout(r);e(this,H)?.fill(void 0);}if(e(this,tt)&&e(this,tt).fill(0),g(this,F,0),g(this,D,0),e(this,Z).length=0,g(this,Q,0),g(this,R,0),e(this,P)&&e(this,C)){let r=e(this,C),n;for(;n=r?.shift();)(s=e(this,X))==null||s.call(this,...n);}},Et);var It=class{cache;map=new Map;constructor(e){this.cache=new Zt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ot="1.9.0";var Vt={version:Ot};var Wt="__game_layer__";var pe={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ie={};var Yt={};b$1(Yt,{createExportableElement:()=>se});var wt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(wt||={});function se(g){try{if(typeof g>"u")return g;let e=JSON.stringify(g);return JSON.parse(e)}catch(e){throw wt.error("Error creating exportable element",g,e),new PixiError("not_json_serializable","Error creating exportable element")}}var fe=typeof window<"u"&&typeof document<"u",re=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Vt.version}`],oe=31,me="background:#2f90da;color:#fff;font-weight:bold;",ge="background:#c832bb;color:#fff;font-weight:bold;",_e="background:transparent;font-weight:bold;",Ht=` v${Vt.version}`;function ne(){if(!fe)return;let g=[],e=[];for(let i=0;i<re.length;i++){let s=re[i],r=s.endsWith(Ht),n=r?s.slice(0,-Ht.length):s,o=n.slice(0,oe),l=n.slice(oe),c=r?"%c%s%c%s%c%s":"%c%s%c%s";g.push(c),e.push(me,o,ge,l),r&&e.push(_e,Ht);}console.info(g.join(`
2
- `),...e);}function Kt(){let g=window.location.pathname+window.location.hash;return g.includes("#")&&(g=g.split("#")[1]),g}ne();var ae;(m=>{async function g(u,w,T){if(GameUnifier.init({navigate:w?.navigate,getCurrentGameStepState:()=>{let d=M.canvas.isInitialized?M.canvas.export():{};return {path:Kt(),storage:z.storage.export(),canvas:d,sound:ut.sound.export(),labelIndex:O.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:O.narration.openedLabels}},restoreGameStepState:async(d,A)=>{st.HistoryManagerStatic._originalStepData=d,O.NarrationManagerStatic.openedLabels=d.openedLabels,z.storage.restore(d.storage);try{M.canvas.isInitialized&&await M.canvas.restore(d.canvas),await ut.sound.restore(d.sound);}catch(I){wt.error("Error restoring game step state:",I);}await A(d.path);},getStepCounter:()=>O.narration.stepCounter,setStepCounter:d=>{O.NarrationManagerStatic._stepCounter=d;},getOpenedLabels:()=>O.narration.openedLabels.length,addHistoryItem:(d,A)=>st.stepHistory.add(d,A),getCharacter:d=>kt.RegisteredCharacters.get(d),processNavigationRequests:(d,A)=>{let I=d,k=Promise.resolve();return d>0?(I--,k=O.narration.continue(A)):d<0&&(I=0,k=st.stepHistory.back(A,{steps:d*-1})),{newValue:I,result:k}},animate:(d,A,I,k)=>motion.animate(d,A,I,k),getVariable:(d,A)=>z.StorageRegistry.getVariable(d,A),setVariable:(d,A,I)=>z.StorageRegistry.setVariable(d,A,I),removeVariable:(d,A)=>z.StorageRegistry.removeVariable(d,A),getFlag:d=>z.storage.flags.get(d),setFlag:(d,A)=>z.storage.flags.set(d,A),onLabelClosing:d=>z.StorageRegistry.clearOldTempVariables(d)}),!u||!w){wt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await M.canvas.init(u,w,T)}m.init=g;function e(){z.storage.clear(),M.canvas.isInitialized&&M.canvas.clear(),ut.sound.clear(),O.narration.clear(),st.stepHistory.clear();}m.clear=e;function i(){let u=M.canvas.isInitialized?M.canvas.export():{};return {pixivn_version:Ot,stepData:O.narration.export(),storageData:z.storage.export(),canvasData:u,soundData:ut.sound.export(),historyData:st.stepHistory.export(),path:Kt()}}m.exportGameState=i;async function s(u){st.stepHistory.restore(u.historyData);let w=st.stepHistory.lastKey;if(typeof w=="number"){let T=st.stepHistory.stepsInfoMap.get(w)||null;await O.narration.restore(u.stepData,T);}z.storage.restore(u.storageData);try{M.canvas.isInitialized&&await M.canvas.restore(u.canvasData),await ut.sound.restore(u.soundData);}catch{}await GameUnifier.navigate(u.path);}m.restoreGameState=s;async function r(u,w){return m.clear(),await O.narration.call(u,w)}m.start=r;function n(u){return JSON.parse(u)}m.jsonToGameState=n;function o(u){GameUnifier.onEnd=u;}m.onEnd=o;function l(u){return GameUnifier.addOnError(u)}m.addOnError=l;function c(u){return GameUnifier.removeOnError(u)}m.removeOnError=c;function v(u){O.NarrationManagerStatic.onStepStart=u;}m.onStepStart=v;function L(u){O.NarrationManagerStatic.onLoadingLabel=u;}m.onLoadingLabel=L;function S(u){O.NarrationManagerStatic.onStepEnd=u;}m.onStepEnd=S;function ot(u){O.NarrationManagerStatic.onLabelStarting=u;}m.onLabelStarting=ot;function G(u){O.NarrationManagerStatic.onLabelClosing=u;}m.onLabelClosing=G;function $(u){GameUnifier.navigate=u;}m.onNavigate=$;function E(u){return GameUnifier.addOnPreContinue(u)}m.addOnPreContinue=E;function y(u){return GameUnifier.removeOnPreContinue(u)}m.removeOnPreContinue=y;})(ae||={});var ke={characterUtils:kt,canvasUtils:M,narrationUtils:O,soundUtils:ut,CANVAS_APP_GAME_LAYER_ALIAS:Wt,PIXIVN_VERSION:Ot,...Yt,...ie,canvas:M.canvas,narration:O.narration,sound:ut.sound,storage:z.storage,history:st.stepHistory,Game:ae,GameUnifier:GameUnifier};export{Wt as CANVAS_APP_GAME_LAYER_ALIAS,It as CachedMap,ae as Game,Ot as PIXIVN_VERSION,pe as SYSTEM_RESERVED_STORAGE_KEYS,se as createExportableElement,ke as default};
1
+ import {f,b,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as k from'@drincs/pixi-vn/canvas';export*from'@drincs/pixi-vn/canvas';import*as Bt from'@drincs/pixi-vn/characters';export*from'@drincs/pixi-vn/characters';import {PixiError,GameUnifier}from'@drincs/pixi-vn/core';export*from'@drincs/pixi-vn/core';import*as ot from'@drincs/pixi-vn/history';export*from'@drincs/pixi-vn/history';import*as L from'@drincs/pixi-vn/narration';export*from'@drincs/pixi-vn/narration';import*as gt from'@drincs/pixi-vn/sound';export*from'@drincs/pixi-vn/sound';import*as K from'@drincs/pixi-vn/storage';export*from'@drincs/pixi-vn/storage';import {motion}from'@drincs/pixi-vn/motion';var ue=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,Ft=typeof process=="object"&&process?process:{},Zt=(g,e,i,s)=>{typeof Ft.emitWarning=="function"?Ft.emitWarning(g,e,i,s):console.error(`[${i}] ${e}: ${g}`);},Gt=globalThis.AbortController,$t=globalThis.AbortSignal;if(typeof Gt>"u"){$t=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new $t;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let g=Ft.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{g&&(g=false,Zt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var fe=g=>!Qt.has(g);var ct=g=>g&&g===Math.floor(g)&&g>0&&isFinite(g),te=g=>ct(g)?g<=Math.pow(2,8)?Uint8Array:g<=Math.pow(2,16)?Uint16Array:g<=Math.pow(2,32)?Uint32Array:g<=Number.MAX_SAFE_INTEGER?Pt:null:null,Pt=class extends Array{constructor(g){super(g),this.fill(0);}},at,bt,me=(at=class{heap;length;static create(e){let i=te(e);if(!i)return [];g(at,bt,true);let s=new at(e,i);return g(at,bt,false),s}constructor(e$1,i){if(!e(at,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},bt=new WeakMap,f(at,bt,false),at),Xt,Jt,J,W,Q,_t,Z,St,Tt,tt,I,et,R,x,m,z,Y,M,C,it,G,st,rt,q,B,nt,ft,V,wt,a,Mt,vt,lt,At,$,ie,yt,xt,Ot,dt,pt,zt,It,Ct,w,Vt,Ut,ut,Ht,Et,ee=(Et=class{constructor(e$1){f(this,a);f(this,J);f(this,W);f(this,Q);f(this,_t);f(this,Z);f(this,St);f(this,Tt);f(this,tt);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,I);f(this,et);f(this,R);f(this,x);f(this,m);f(this,z);f(this,Y);f(this,M);f(this,C);f(this,it);f(this,G);f(this,st);f(this,rt);f(this,q);f(this,B);f(this,nt);f(this,ft);f(this,V);f(this,wt);f(this,vt,()=>{});f(this,lt,()=>{});f(this,At,()=>{});f(this,$,()=>false);f(this,yt,e=>{});f(this,xt,(e,i,s)=>{});f(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Xt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:l,allowStale:c,dispose:y,onInsert:O,disposeAfter:S,noDisposeOnSet:j,noUpdateTTL:D,maxSize:H=0,maxEntrySize:u=0,sizeCalculation:_,fetchMethod:f$1,memoMethod:U,noDeleteOnFetchRejection:d$1,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:v,ignoreFetchAbort:A,perf:F}=e$1;if(F!==void 0&&typeof F?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,tt,F??ue),i!==0&&!ct(i))throw new TypeError("max option must be a nonnegative integer");let X=i?te(i):Array;if(!X)throw new Error("invalid max value: "+i);if(g(this,J,i),g(this,W,H),this.maxEntrySize=u||e(this,W),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,W)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(U!==void 0&&typeof U!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,Tt,U),f$1!==void 0&&typeof f$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,St,f$1),g(this,ft,!!f$1),g(this,R,new Map),g(this,x,new Array(i).fill(void 0)),g(this,m,new Array(i).fill(void 0)),g(this,z,new X(i)),g(this,Y,new X(i)),g(this,M,0),g(this,C,0),g(this,it,me.create(i)),g(this,I,0),g(this,et,0),typeof y=="function"&&g(this,Q,y),typeof O=="function"&&g(this,_t,O),typeof S=="function"?(g(this,Z,S),g(this,G,[])):(g(this,Z,void 0),g(this,G,void 0)),g(this,nt,!!e(this,Q)),g(this,wt,!!e(this,_t)),g(this,V,!!e(this,Z)),this.noDisposeOnSet=!!j,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!d$1,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(e(this,W)!==0&&!ct(e(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!ct(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,ie).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!l,this.ttlResolution=ct(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ct(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,Mt).call(this);}if(e(this,J)===0&&this.ttl===0&&e(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,J)&&!e(this,W)){let jt="LRU_CACHE_UNBOUNDED";fe(jt)&&(Qt.add(jt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",jt,Et));}}get perf(){return e(this,tt)}static unsafeExposeInternals(e$1){return {starts:e(e$1,rt),ttls:e(e$1,q),autopurgeTimers:e(e$1,B),sizes:e(e$1,st),keyMap:e(e$1,R),keyList:e(e$1,x),valList:e(e$1,m),next:e(e$1,z),prev:e(e$1,Y),get head(){return e(e$1,M)},get tail(){return e(e$1,C)},free:e(e$1,it),isBackgroundFetch:i=>{var s;return h(s=e$1,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return h(n=e$1,a,Ct).call(n,i,s,r,o)},moveToTail:i=>{var s;return h(s=e$1,a,Ut).call(s,i)},indexes:i=>{var s;return h(s=e$1,a,dt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,a,pt).call(s,i)},isStale:i=>{var s;return e(s=e$1,$).call(s,i)}}}get max(){return e(this,J)}get maxSize(){return e(this,W)}get calculatedSize(){return e(this,et)}get size(){return e(this,I)}get fetchMethod(){return e(this,St)}get memoMethod(){return e(this,Tt)}get dispose(){return e(this,Q)}get onInsert(){return e(this,_t)}get disposeAfter(){return e(this,Z)}getRemainingTTL(e$1){return e(this,R).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,a,dt).call(this))e(this,m)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield [e(this,x)[e$1],e(this,m)[e$1]]);}*rentries(){for(let e$1 of h(this,a,pt).call(this))e(this,m)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield [e(this,x)[e$1],e(this,m)[e$1]]);}*keys(){for(let e$1 of h(this,a,dt).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,a,pt).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,a,dt).call(this))e(this,m)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield e(this,m)[e$1]);}*rvalues(){for(let e$1 of h(this,a,pt).call(this))e(this,m)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield e(this,m)[e$1]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(e$1,i={}){for(let s of h(this,a,dt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e$1(o,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(e$1,i=this){for(let s of h(this,a,dt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,x)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,a,pt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,x)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,a,pt).call(this,{allowStale:true}))e(this,$).call(this,i)&&(h(this,a,ut).call(this,e(this,x)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,R).get(e$1);if(i===void 0)return;let s=e(this,m)[i],r=h(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,q)&&e(this,rt)){let n=e(this,q)[i],l=e(this,rt)[i];if(n&&l){let c=n-(e(this,tt).now()-l);o.ttl=c,o.start=Date.now();}}return e(this,st)&&(o.size=e(this,st)[i]),o}dump(){let e$1=[];for(let i of h(this,a,dt).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,m)[i],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,q)&&e(this,rt)){n.ttl=e(this,q)[i];let l=e(this,tt).now()-e(this,rt)[i];n.start=Math.floor(Date.now()-l);}e(this,st)&&(n.size=e(this,st)[i]),e$1.unshift([s,n]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,tt).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var j,D,H,u;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,O=e(this,Ot).call(this,e$1,i$1,s.size||0,l);if(this.maxEntrySize&&O>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,a,ut).call(this,e$1,"set"),this;let S=e(this,I)===0?void 0:e(this,R).get(e$1);if(S===void 0)S=e(this,I)===0?e(this,C):e(this,it).length!==0?e(this,it).pop():e(this,I)===e(this,J)?h(this,a,It).call(this,false):e(this,I),e(this,x)[S]=e$1,e(this,m)[S]=i$1,e(this,R).set(e$1,S),e(this,z)[e(this,C)]=S,e(this,Y)[S]=e(this,C),g(this,C,S),i(this,I)._++,e(this,xt).call(this,S,O,c),c&&(c.set="add"),y=false,e(this,wt)&&((j=e(this,_t))==null||j.call(this,i$1,e$1,"add"));else {h(this,a,Ut).call(this,S);let _=e(this,m)[S];if(i$1!==_){if(e(this,ft)&&h(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=_;f!==void 0&&!n&&(e(this,nt)&&((D=e(this,Q))==null||D.call(this,f,e$1,"set")),e(this,V)&&e(this,G)?.push([f,e$1,"set"]));}else n||(e(this,nt)&&((H=e(this,Q))==null||H.call(this,_,e$1,"set")),e(this,V)&&e(this,G)?.push([_,e$1,"set"]));if(e(this,yt).call(this,S),e(this,xt).call(this,S,O,c),e(this,m)[S]=i$1,c){c.set="replace";let f=_&&h(this,a,w).call(this,_)?_.__staleWhileFetching:_;f!==void 0&&(c.oldValue=f);}}else c&&(c.set="update");e(this,wt)&&this.onInsert?.(i$1,e$1,i$1===_?"update":"replace");}if(r!==0&&!e(this,q)&&h(this,a,Mt).call(this),e(this,q)&&(y||e(this,At).call(this,S,r,o),c&&e(this,lt).call(this,c,S)),!n&&e(this,V)&&e(this,G)){let _=e(this,G),f;for(;f=_?.shift();)(u=e(this,Z))==null||u.call(this,...f);}return this}pop(){var e$1;try{for(;e(this,I);){let i=e(this,m)[e(this,M)];if(h(this,a,It).call(this,!0),h(this,a,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,V)&&e(this,G)){let i=e(this,G),s;for(;s=i?.shift();)(e$1=e(this,Z))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,R).get(e$1);if(o!==void 0){let n=e(this,m)[o];if(h(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,$).call(this,o))r&&(r.has="stale",e(this,lt).call(this,r,o));else return s&&e(this,vt).call(this,o),r&&(r.has="hit",e(this,lt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,R).get(e$1);if(r===void 0||!s&&e(this,$).call(this,r))return;let o=e(this,m)[r];return h(this,a,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:O=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:u,forceRefresh:_=false,status:f,signal:U}=i;if(!e(this,ft))return f&&(f.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:f});let d={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:l,size:c,sizeCalculation:y,noUpdateTTL:O,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:H,ignoreFetchAbort:D,status:f,signal:U},E=e(this,R).get(e$1);if(E===void 0){f&&(f.fetch="miss");let T=h(this,a,Ct).call(this,e$1,E,d,u);return T.__returned=T}else {let T=e(this,m)[E];if(h(this,a,w).call(this,T)){let X=s&&T.__staleWhileFetching!==void 0;return f&&(f.fetch="inflight",X&&(f.returnedStale=true)),X?T.__staleWhileFetching:T.__returned=T}let v=e(this,$).call(this,E);if(!_&&!v)return f&&(f.fetch="hit"),h(this,a,Ut).call(this,E),r&&e(this,vt).call(this,E),f&&e(this,lt).call(this,f,E),T;let A=h(this,a,Ct).call(this,e$1,E,d,u),F=A.__staleWhileFetching!==void 0&&s;return f&&(f.fetch=v?"stale":"refresh",F&&v&&(f.returnedStale=true)),F?A.__staleWhileFetching:A.__returned=A}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,l=this.get(e$1,n);if(!o&&l!==void 0)return l;let c=s(e$1,l,{options:n,context:r});return this.set(e$1,c,n),c}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,l=e(this,R).get(e$1);if(l!==void 0){let c=e(this,m)[l],y=h(this,a,w).call(this,c);return n&&e(this,lt).call(this,n,l),e(this,$).call(this,l)?(n&&(n.get="stale"),y?(n&&s&&c.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,a,ut).call(this,e$1,"expire"),n&&s&&(n.returnedStale=true),s?c:void 0)):(n&&(n.get="hit"),y?c.__staleWhileFetching:(h(this,a,Ut).call(this,l),r&&e(this,vt).call(this,l),c))}else n&&(n.get="miss");}delete(e){return h(this,a,ut).call(this,e,"delete")}clear(){return h(this,a,Ht).call(this,"delete")}},J=new WeakMap,W=new WeakMap,Q=new WeakMap,_t=new WeakMap,Z=new WeakMap,St=new WeakMap,Tt=new WeakMap,tt=new WeakMap,I=new WeakMap,et=new WeakMap,R=new WeakMap,x=new WeakMap,m=new WeakMap,z=new WeakMap,Y=new WeakMap,M=new WeakMap,C=new WeakMap,it=new WeakMap,G=new WeakMap,st=new WeakMap,rt=new WeakMap,q=new WeakMap,B=new WeakMap,nt=new WeakMap,ft=new WeakMap,V=new WeakMap,wt=new WeakMap,a=new WeakSet,Mt=function(){let e$1=new Pt(e(this,J)),i=new Pt(e(this,J));g(this,q,e$1),g(this,rt,i);let s=this.ttlAutopurge?new Array(e(this,J)):void 0;g(this,B,s),g(this,At,(l,c,y=e(this,tt).now())=>{i[l]=c!==0?y:0,e$1[l]=c,r(l,c);}),g(this,vt,l=>{i[l]=e$1[l]!==0?e(this,tt).now():0,r(l,e$1[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let y=setTimeout(()=>{e(this,$).call(this,l)&&h(this,a,ut).call(this,e(this,x)[l],"expire");},c+1);y.unref&&y.unref(),s[l]=y;}}:()=>{};g(this,lt,(l,c)=>{if(e$1[c]){let y=e$1[c],O=i[c];if(!y||!O)return;l.ttl=y,l.start=O,l.now=o||n();let S=l.now-O;l.remainingTTL=y-S;}});let o=0,n=()=>{let l=e(this,tt).now();if(this.ttlResolution>0){o=l;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=e(this,R).get(l);if(c===void 0)return 0;let y=e$1[c],O=i[c];if(!y||!O)return 1/0;let S=(o||n())-O;return y-S},g(this,$,l=>{let c=i[l],y=e$1[l];return !!y&&!!c&&(o||n())-c>y});},vt=new WeakMap,lt=new WeakMap,At=new WeakMap,$=new WeakMap,ie=function(){let e$1=new Pt(e(this,J));g(this,et,0),g(this,st,e$1),g(this,yt,i=>{g(this,et,e(this,et)-e$1[i]),e$1[i]=0;}),g(this,Ot,(i,s,r,o)=>{if(h(this,a,w).call(this,s))return 0;if(!ct(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ct(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),g(this,xt,(i,s,r)=>{if(e$1[i]=s,e(this,W)){let o=e(this,W)-e$1[i];for(;e(this,et)>o;)h(this,a,It).call(this,true);}g(this,et,e(this,et)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,et));});},yt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,dt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,I))for(let i=e(this,C);!(!h(this,a,zt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,M)));)i=e(this,Y)[i];},pt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,I))for(let i=e(this,M);!(!h(this,a,zt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,z)[i];},zt=function(e$1){return e$1!==void 0&&e(this,R).get(e(this,x)[e$1])===e$1},It=function(e$1){var o;let i$1=e(this,M),s=e(this,x)[i$1],r=e(this,m)[i$1];return e(this,ft)&&h(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,nt)||e(this,V))&&(e(this,nt)&&((o=e(this,Q))==null||o.call(this,r,s,"evict")),e(this,V)&&e(this,G)?.push([r,s,"evict"])),e(this,yt).call(this,i$1),e(this,B)?.[i$1]&&(clearTimeout(e(this,B)[i$1]),e(this,B)[i$1]=void 0),e$1&&(e(this,x)[i$1]=void 0,e(this,m)[i$1]=void 0,e(this,it).push(i$1)),e(this,I)===1?(g(this,M,g(this,C,0)),e(this,it).length=0):g(this,M,e(this,z)[i$1]),e(this,R).delete(s),i(this,I)._--,i$1},Ct=function(e$1,i,s,r){let o=i===void 0?void 0:e(this,m)[i];if(h(this,a,w).call(this,o))return o;let n=new Gt,{signal:l}=s;l?.addEventListener("abort",()=>n.abort(l.reason),{signal:n.signal});let c={signal:n.signal,options:s,context:r},y=(u,_=false)=>{let{aborted:f}=n.signal,U=s.ignoreFetchAbort&&u!==void 0,d=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&u!==void 0);if(s.status&&(f&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,U&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),f&&!U&&!_)return S(n.signal.reason,d);let E=D,T=e(this,m)[i];return (T===D||U&&_&&T===void 0)&&(u===void 0?E.__staleWhileFetching!==void 0?e(this,m)[i]=E.__staleWhileFetching:h(this,a,ut).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,u,c.options))),u},O=u=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=u),S(u,false)),S=(u,_)=>{let{aborted:f}=n.signal,U=f&&s.allowStaleOnFetchAbort,d=U||s.allowStaleOnFetchRejection,E=d||s.noDeleteOnFetchRejection,T=D;if(e(this,m)[i]===D&&(!E||!_&&T.__staleWhileFetching===void 0?h(this,a,ut).call(this,e$1,"fetch"):U||(e(this,m)[i]=T.__staleWhileFetching)),d)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw u},j=(u,_)=>{var U;let f=(U=e(this,St))==null?void 0:U.call(this,e$1,o,c);f&&f instanceof Promise&&f.then(d=>u(d===void 0?void 0:d),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(u(void 0),s.allowStaleOnFetchAbort&&(u=d=>y(d,true)));});};s.status&&(s.status.fetchDispatched=true);let D=new Promise(j).then(y,O),H=Object.assign(D,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e$1,H,{...c.options,status:void 0}),i=e(this,R).get(e$1)):e(this,m)[i]=H,H},w=function(e$1){if(!e(this,ft))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Vt=function(e$1,i){e(this,Y)[i]=e$1,e(this,z)[e$1]=i;},Ut=function(e$1){e$1!==e(this,C)&&(e$1===e(this,M)?g(this,M,e(this,z)[e$1]):h(this,a,Vt).call(this,e(this,Y)[e$1],e(this,z)[e$1]),h(this,a,Vt).call(this,e(this,C),e$1),g(this,C,e$1));},ut=function(e$1,i$1){var r,o;let s=false;if(e(this,I)!==0){let n=e(this,R).get(e$1);if(n!==void 0)if(e(this,B)?.[n]&&(clearTimeout(e(this,B)?.[n]),e(this,B)[n]=void 0),s=true,e(this,I)===1)h(this,a,Ht).call(this,i$1);else {e(this,yt).call(this,n);let l=e(this,m)[n];if(h(this,a,w).call(this,l)?l.__abortController.abort(new Error("deleted")):(e(this,nt)||e(this,V))&&(e(this,nt)&&((r=e(this,Q))==null||r.call(this,l,e$1,i$1)),e(this,V)&&e(this,G)?.push([l,e$1,i$1])),e(this,R).delete(e$1),e(this,x)[n]=void 0,e(this,m)[n]=void 0,n===e(this,C))g(this,C,e(this,Y)[n]);else if(n===e(this,M))g(this,M,e(this,z)[n]);else {let c=e(this,Y)[n];e(this,z)[c]=e(this,z)[n];let y=e(this,z)[n];e(this,Y)[y]=e(this,Y)[n];}i(this,I)._--,e(this,it).push(n);}}if(e(this,V)&&e(this,G)?.length){let n=e(this,G),l;for(;l=n?.shift();)(o=e(this,Z))==null||o.call(this,...l);}return s},Ht=function(e$1){var i,s;for(let r of h(this,a,pt).call(this,{allowStale:true})){let o=e(this,m)[r];if(h(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,x)[r];e(this,nt)&&((i=e(this,Q))==null||i.call(this,o,n,e$1)),e(this,V)&&e(this,G)?.push([o,n,e$1]);}}if(e(this,R).clear(),e(this,m).fill(void 0),e(this,x).fill(void 0),e(this,q)&&e(this,rt)){e(this,q).fill(0),e(this,rt).fill(0);for(let r of e(this,B)??[])r!==void 0&&clearTimeout(r);e(this,B)?.fill(void 0);}if(e(this,st)&&e(this,st).fill(0),g(this,M,0),g(this,C,0),e(this,it).length=0,g(this,et,0),g(this,I,0),e(this,V)&&e(this,G)){let r=e(this,G),o;for(;o=r?.shift();)(s=e(this,Z))==null||s.call(this,...o);}},Et);var Dt=class{cache;map=new Map;constructor(e){this.cache=new ee({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Lt="1.9.2";var kt={version:Lt};var Kt="__game_layer__";var ge={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var re={};var Wt={};b(Wt,{createExportableElement:()=>ne});var mt;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(mt||={});function ne(g){try{if(typeof g>"u")return g;let e=JSON.stringify(g);return JSON.parse(e)}catch(e){throw mt.error("Error creating exportable element",g,e),new PixiError("not_json_serializable","Error creating exportable element")}}function ae(g){let e,i={},s={};function r(y){i=y;}function o(y){s=y;}function n(y){e&&l();let O=y?.windowKey??"pixiVN",S=[],j=u=>({...i,...u}),D={Game:g,narration:L.narration,storage:K.storage,stepHistory:ot.stepHistory,get props(){return i},start:(u,_)=>s.start?s.start(u,_):g.start(u,j(_)),continue:(u,_)=>s.continue?s.continue():L.narration.continue(j(u),_),call:(u,_)=>s.call?s.call(u,_):L.narration.call(u,j(_)),jump:(u,_)=>s.jump?s.jump(u,_):L.narration.jump(u,j(_)),selectChoice:(u,_)=>{let f=L.narration.choices.list?.find(U=>U.choiceIndex===u);if(!f){let U=L.narration.choices.list?.map(d=>d.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${u}. Available: ${U}`)}return s.selectChoice?s.selectChoice(f):L.narration.choices.select(f,j(_))},setInput:u=>{L.narration.input.value=u;},goBack:(u,_)=>s.back?s.back():ot.stepHistory.back(j(u),_),closeCurrentLabel:()=>L.narration.labels.closeCurrent(),closeAllLabels:()=>L.narration.labels.closeAll(),getState:()=>({dialogue:L.narration.dialogue,dialogueGlue:L.narration.dialogGlue,choices:L.narration.choices.list,input:{isRequired:L.narration.input.isRequired,type:L.narration.input.type,value:L.narration.input.value},canContinue:L.narration.canContinue,canGoBack:ot.stepHistory.canGoBack,labelsOpened:L.narration.labels.opened,currentLabelId:L.narration.labels.current?.id,stepCounter:L.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=u=>{S.push({error:u,timestamp:Date.now()});};return g.addOnError(H),typeof window<"u"?window[O]=D:mt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:D,windowKey:O,errorHandler:H},D}function l(){e&&(g.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function c(){return e!==void 0}return {setProps:r,setActions:o,enable:n,disable:l,isEnabled:c}}var ve=typeof window<"u"&&typeof document<"u",le=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${kt.version}`],he=31,ye="background:#2f90da;color:#fff;font-weight:bold;",be="background:#c832bb;color:#fff;font-weight:bold;",Se="background:transparent;font-weight:bold;",Yt=` v${kt.version}`;function ce(){if(!ve)return;let g=[],e=[];for(let i=0;i<le.length;i++){let s=le[i],r=s.endsWith(Yt),o=r?s.slice(0,-Yt.length):s,n=o.slice(0,he),l=o.slice(he),c=r?"%c%s%c%s%c%s":"%c%s%c%s";g.push(c),e.push(ye,n,be,l),r&&e.push(Se,Yt);}console.info(g.join(`
2
+ `),...e);}function qt(){let g=window.location.pathname+window.location.hash;return g.includes("#")&&(g=g.split("#")[1]),g}ce();var de;(U=>{async function g(d,E,T){if(GameUnifier.init({navigate:E?.navigate,getCurrentGameStepState:()=>{let v=k.canvas.isInitialized?k.canvas.export():{};return {path:qt(),storage:K.storage.export(),canvas:v,sound:gt.sound.export(),labelIndex:L.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L.narration.openedLabels}},restoreGameStepState:async(v,A)=>{ot.HistoryManagerStatic._originalStepData=v,L.NarrationManagerStatic.openedLabels=v.openedLabels,K.storage.restore(v.storage);try{k.canvas.isInitialized&&await k.canvas.restore(v.canvas),await gt.sound.restore(v.sound);}catch(F){mt.error("Error restoring game step state:",F);}await A(v.path);},getStepCounter:()=>L.narration.stepCounter,setStepCounter:v=>{L.NarrationManagerStatic._stepCounter=v;},getOpenedLabels:()=>L.narration.openedLabels.length,addHistoryItem:(v,A)=>ot.stepHistory.add(v,A),getCharacter:v=>Bt.RegisteredCharacters.get(v),processNavigationRequests:(v,A)=>{let F=v,X=Promise.resolve();return v>0?(F--,X=L.narration.continue(A)):v<0&&(F=0,X=ot.stepHistory.back(A,{steps:v*-1})),{newValue:F,result:X}},animate:(v,A,F,X)=>motion.animate(v,A,F,X),getVariable:(v,A)=>K.StorageRegistry.getVariable(v,A),setVariable:(v,A,F)=>K.StorageRegistry.setVariable(v,A,F),removeVariable:(v,A)=>K.StorageRegistry.removeVariable(v,A),getFlag:v=>K.storage.flags.get(v),setFlag:(v,A)=>K.storage.flags.set(v,A),onLabelClosing:v=>K.StorageRegistry.clearOldTempVariables(v)}),!d||!E){mt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await k.canvas.init(d,E,T)}U.init=g;function e(){K.storage.clear(),k.canvas.isInitialized&&k.canvas.clear(),gt.sound.clear(),L.narration.clear(),ot.stepHistory.clear();}U.clear=e;function i(){let d=k.canvas.isInitialized?k.canvas.export():{};return {pixivn_version:Lt,stepData:L.narration.export(),storageData:K.storage.export(),canvasData:d,soundData:gt.sound.export(),historyData:ot.stepHistory.export(),path:qt()}}U.exportGameState=i;async function s(d){ot.stepHistory.restore(d.historyData);let E=ot.stepHistory.lastKey;if(typeof E=="number"){let T=ot.stepHistory.stepsInfoMap.get(E)||null;await L.narration.restore(d.stepData,T);}K.storage.restore(d.storageData);try{k.canvas.isInitialized&&await k.canvas.restore(d.canvasData),await gt.sound.restore(d.soundData);}catch{}await GameUnifier.navigate(d.path);}U.restoreGameState=s;async function r(d,E){return U.clear(),await L.narration.call(d,E)}U.start=r;function o(d){return JSON.parse(d)}U.jsonToGameState=o;function n(d){GameUnifier.onEnd=d;}U.onEnd=n;function l(d){return GameUnifier.addOnError(d)}U.addOnError=l;function c(d){return GameUnifier.removeOnError(d)}U.removeOnError=c;function y(d){L.NarrationManagerStatic.onStepStart=d;}U.onStepStart=y;function O(d){L.NarrationManagerStatic.onLoadingLabel=d;}U.onLoadingLabel=O;function S(d){L.NarrationManagerStatic.onStepEnd=d;}U.onStepEnd=S;function j(d){L.NarrationManagerStatic.onLabelStarting=d;}U.onLabelStarting=j;function D(d){L.NarrationManagerStatic.onLabelClosing=d;}U.onLabelClosing=D;function H(d){GameUnifier.navigate=d;}U.onNavigate=H;function u(d){return GameUnifier.addOnPreContinue(d)}U.addOnPreContinue=u;function _(d){return GameUnifier.removeOnPreContinue(d)}U.removeOnPreContinue=_,U.testing=ae(U);})(de||={});var Ze={characterUtils:Bt,canvasUtils:k,narrationUtils:L,soundUtils:gt,CANVAS_APP_GAME_LAYER_ALIAS:Kt,PIXIVN_VERSION:Lt,...Wt,...re,canvas:k.canvas,narration:L.narration,sound:gt.sound,storage:K.storage,history:ot.stepHistory,Game:de,GameUnifier:GameUnifier};export{Kt as CANVAS_APP_GAME_LAYER_ALIAS,Dt as CachedMap,de as Game,Lt as PIXIVN_VERSION,ge as SYSTEM_RESERVED_STORAGE_KEYS,ne as createExportableElement,Ze as default};