@drincs/pixi-vn 1.9.1 → 1.9.3

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.
@@ -0,0 +1,153 @@
1
+ import { Difference } from 'microdiff';
2
+
3
+ /**
4
+ * Message protocol between the main thread and an optional {@link GameWorker}-registered
5
+ * Worker. Kept intentionally small: each request names one unit of work Pixi'VN (or a
6
+ * third-party library building on it, via `"custom"` - see `registerGameWorkerHandler`) knows
7
+ * how to hand off, and the worker replies with the same `id` so the caller can match the
8
+ * response.
9
+ *
10
+ * This protocol (and everything it carries) only ever deals with plain, structured-clone-safe
11
+ * data - never PixiJS/canvas/audio objects, which can't leave the main thread.
12
+ */
13
+ type GameWorkerRequest = {
14
+ id: number;
15
+ type: "restore-diff";
16
+ /** The base state to apply `diff` to (not mutated). */
17
+ state: object;
18
+ diff: Difference[];
19
+ } | {
20
+ id: number;
21
+ type: "diff";
22
+ /** The two states to compare (neither is mutated). */
23
+ before: object;
24
+ after: object;
25
+ } | {
26
+ id: number;
27
+ type: "clone";
28
+ /** The value to deep-clone. */
29
+ value: object;
30
+ } | {
31
+ id: number;
32
+ type: "custom";
33
+ /** Identifies which registered handler (see `registerGameWorkerHandler`) should run. */
34
+ kind: string;
35
+ payload: unknown;
36
+ };
37
+ type GameWorkerResponse = {
38
+ id: number;
39
+ type: "restore-diff-result";
40
+ result: object;
41
+ } | {
42
+ id: number;
43
+ type: "diff-result";
44
+ result: Difference[];
45
+ } | {
46
+ id: number;
47
+ type: "clone-result";
48
+ result: object;
49
+ } | {
50
+ id: number;
51
+ type: "custom-result";
52
+ result: unknown;
53
+ } | {
54
+ id: number;
55
+ type: "error";
56
+ error: string;
57
+ };
58
+
59
+ /**
60
+ * The worker-side half of the {@link GameWorkerManager} protocol. The game project creates its
61
+ * own Worker (so it controls the bundler-specific setup) and points its `message` handling here:
62
+ *
63
+ * ```ts
64
+ * // game-worker.ts, built as its own entry by the project's bundler
65
+ * import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";
66
+ *
67
+ * self.onmessage = async (event) => {
68
+ * const response = await handleGameWorkerMessage(event.data);
69
+ * if (response) self.postMessage(response);
70
+ * };
71
+ * ```
72
+ *
73
+ * A third-party library sharing this same worker (see `registerGameWorkerHandler`) just needs
74
+ * its own worker-side registration module imported alongside this one, in that same file.
75
+ *
76
+ * Everything this processes is plain, structured-clone-safe data by construction - it never
77
+ * touches PixiJS/canvas/audio, which only exist on the main thread.
78
+ */
79
+ declare function handleGameWorkerMessage(request: GameWorkerRequest): Promise<GameWorkerResponse>;
80
+
81
+ /**
82
+ * Optional integration point for offloading Pixi'VN's own heavy, pure (no DOM/PixiJS/audio)
83
+ * computations to a Worker the game project registers. Pixi'VN never creates a Worker itself
84
+ * and works exactly as before if none is registered - this is opt-in, not a requirement, so
85
+ * projects that can't or don't want to use Workers (SSR, certain embeds, ...) are unaffected.
86
+ *
87
+ * The game project owns the `Worker` instance (so it controls the bundler-specific `new
88
+ * Worker(new URL(...), { type: "module" })` call, any CSP/nonce concerns, and whether it exists
89
+ * at all) and just needs its `onmessage` wired to {@link handleGameWorkerMessage} - see that
90
+ * function's doc comment for the worker-side half of this.
91
+ */
92
+ declare class GameWorkerManager {
93
+ private static _worker;
94
+ private static _pending;
95
+ private static _nextId;
96
+ static get isAvailable(): boolean;
97
+ /**
98
+ * Registers the Worker Pixi'VN may use for eligible heavy computations. Replaces any
99
+ * previously registered worker (its still-pending requests are rejected, never left
100
+ * hanging).
101
+ */
102
+ static register(worker: Worker): void;
103
+ /** Stops using the registered worker (does not terminate it - the caller owns its lifecycle). */
104
+ static unregister(): void;
105
+ private static _handleMessage;
106
+ /**
107
+ * Sends one {@link GameWorkerRequest} and resolves with its matching response's `result`.
108
+ * Rejects if no worker is registered - callers are expected to fall back to computing the
109
+ * same result synchronously in that case (see {@link restoreDiff}/{@link diff}/{@link clone}'s
110
+ * own call sites), not to treat the worker as required.
111
+ */
112
+ private static _request;
113
+ /** Applies `diff` to `state` on the registered worker (see `restoreDiffChanges`). */
114
+ static restoreDiff<T extends object>(state: T, diff: Difference[]): Promise<T>;
115
+ /** Computes the `microdiff` difference between `before` and `after` on the registered worker. */
116
+ static diff(before: object, after: object): Promise<Difference[]>;
117
+ /** Deep-clones `value` (JSON round-trip, matching `createExportableElement`) on the registered worker. */
118
+ static clone<T extends object>(value: T): Promise<T>;
119
+ /**
120
+ * Runs the handler a third-party library registered for `kind` (see
121
+ * `registerGameWorkerHandler`) on the registered worker, passing it `payload`. Lets a
122
+ * library built on top of Pixi'VN share this same worker instead of needing one of its own -
123
+ * see that function's doc comment for the worker-side half of this.
124
+ */
125
+ static custom<TResult = unknown>(kind: string, payload: unknown): Promise<TResult>;
126
+ }
127
+
128
+ type GameWorkerHandler = (payload: unknown) => unknown | Promise<unknown>;
129
+ /** Registers (or replaces) the worker-side handler for `kind`. See this file's doc comment. */
130
+ declare function registerGameWorkerHandler(kind: string, handler: GameWorkerHandler): void;
131
+ /** Removes the worker-side handler previously registered for `kind`, if any. */
132
+ declare function unregisterGameWorkerHandler(kind: string): void;
133
+
134
+ /**
135
+ * Applies `stateDiff` to `state`, via the registered game worker if one is available (see
136
+ * `Game.worker`), falling back to computing it synchronously on the main thread otherwise -
137
+ * whether that's because no worker was registered, or because the worker call itself failed (the
138
+ * caller should never hard-fail just because the optional worker hiccuped).
139
+ */
140
+ declare function restoreDiffMaybeOffloaded<T extends object>(state: T, stateDiff: Difference[]): Promise<T>;
141
+ /**
142
+ * Computes the difference between `before` and `after`, via the registered game worker if
143
+ * available, falling back to the main thread otherwise. Mirrors
144
+ * {@link restoreDiffMaybeOffloaded} - same worker, opposite direction.
145
+ */
146
+ declare function diffMaybeOffloaded(before: object, after: object): Promise<Difference[]>;
147
+ /**
148
+ * Deep-clones `value` (matching `createExportableElement`'s JSON-round-trip semantics), via the
149
+ * registered game worker if available, falling back to the main thread otherwise.
150
+ */
151
+ declare function cloneMaybeOffloaded<T extends object>(value: T): Promise<T>;
152
+
153
+ export { type GameWorkerHandler, GameWorkerManager, type GameWorkerRequest, type GameWorkerResponse, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
@@ -0,0 +1,153 @@
1
+ import { Difference } from 'microdiff';
2
+
3
+ /**
4
+ * Message protocol between the main thread and an optional {@link GameWorker}-registered
5
+ * Worker. Kept intentionally small: each request names one unit of work Pixi'VN (or a
6
+ * third-party library building on it, via `"custom"` - see `registerGameWorkerHandler`) knows
7
+ * how to hand off, and the worker replies with the same `id` so the caller can match the
8
+ * response.
9
+ *
10
+ * This protocol (and everything it carries) only ever deals with plain, structured-clone-safe
11
+ * data - never PixiJS/canvas/audio objects, which can't leave the main thread.
12
+ */
13
+ type GameWorkerRequest = {
14
+ id: number;
15
+ type: "restore-diff";
16
+ /** The base state to apply `diff` to (not mutated). */
17
+ state: object;
18
+ diff: Difference[];
19
+ } | {
20
+ id: number;
21
+ type: "diff";
22
+ /** The two states to compare (neither is mutated). */
23
+ before: object;
24
+ after: object;
25
+ } | {
26
+ id: number;
27
+ type: "clone";
28
+ /** The value to deep-clone. */
29
+ value: object;
30
+ } | {
31
+ id: number;
32
+ type: "custom";
33
+ /** Identifies which registered handler (see `registerGameWorkerHandler`) should run. */
34
+ kind: string;
35
+ payload: unknown;
36
+ };
37
+ type GameWorkerResponse = {
38
+ id: number;
39
+ type: "restore-diff-result";
40
+ result: object;
41
+ } | {
42
+ id: number;
43
+ type: "diff-result";
44
+ result: Difference[];
45
+ } | {
46
+ id: number;
47
+ type: "clone-result";
48
+ result: object;
49
+ } | {
50
+ id: number;
51
+ type: "custom-result";
52
+ result: unknown;
53
+ } | {
54
+ id: number;
55
+ type: "error";
56
+ error: string;
57
+ };
58
+
59
+ /**
60
+ * The worker-side half of the {@link GameWorkerManager} protocol. The game project creates its
61
+ * own Worker (so it controls the bundler-specific setup) and points its `message` handling here:
62
+ *
63
+ * ```ts
64
+ * // game-worker.ts, built as its own entry by the project's bundler
65
+ * import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";
66
+ *
67
+ * self.onmessage = async (event) => {
68
+ * const response = await handleGameWorkerMessage(event.data);
69
+ * if (response) self.postMessage(response);
70
+ * };
71
+ * ```
72
+ *
73
+ * A third-party library sharing this same worker (see `registerGameWorkerHandler`) just needs
74
+ * its own worker-side registration module imported alongside this one, in that same file.
75
+ *
76
+ * Everything this processes is plain, structured-clone-safe data by construction - it never
77
+ * touches PixiJS/canvas/audio, which only exist on the main thread.
78
+ */
79
+ declare function handleGameWorkerMessage(request: GameWorkerRequest): Promise<GameWorkerResponse>;
80
+
81
+ /**
82
+ * Optional integration point for offloading Pixi'VN's own heavy, pure (no DOM/PixiJS/audio)
83
+ * computations to a Worker the game project registers. Pixi'VN never creates a Worker itself
84
+ * and works exactly as before if none is registered - this is opt-in, not a requirement, so
85
+ * projects that can't or don't want to use Workers (SSR, certain embeds, ...) are unaffected.
86
+ *
87
+ * The game project owns the `Worker` instance (so it controls the bundler-specific `new
88
+ * Worker(new URL(...), { type: "module" })` call, any CSP/nonce concerns, and whether it exists
89
+ * at all) and just needs its `onmessage` wired to {@link handleGameWorkerMessage} - see that
90
+ * function's doc comment for the worker-side half of this.
91
+ */
92
+ declare class GameWorkerManager {
93
+ private static _worker;
94
+ private static _pending;
95
+ private static _nextId;
96
+ static get isAvailable(): boolean;
97
+ /**
98
+ * Registers the Worker Pixi'VN may use for eligible heavy computations. Replaces any
99
+ * previously registered worker (its still-pending requests are rejected, never left
100
+ * hanging).
101
+ */
102
+ static register(worker: Worker): void;
103
+ /** Stops using the registered worker (does not terminate it - the caller owns its lifecycle). */
104
+ static unregister(): void;
105
+ private static _handleMessage;
106
+ /**
107
+ * Sends one {@link GameWorkerRequest} and resolves with its matching response's `result`.
108
+ * Rejects if no worker is registered - callers are expected to fall back to computing the
109
+ * same result synchronously in that case (see {@link restoreDiff}/{@link diff}/{@link clone}'s
110
+ * own call sites), not to treat the worker as required.
111
+ */
112
+ private static _request;
113
+ /** Applies `diff` to `state` on the registered worker (see `restoreDiffChanges`). */
114
+ static restoreDiff<T extends object>(state: T, diff: Difference[]): Promise<T>;
115
+ /** Computes the `microdiff` difference between `before` and `after` on the registered worker. */
116
+ static diff(before: object, after: object): Promise<Difference[]>;
117
+ /** Deep-clones `value` (JSON round-trip, matching `createExportableElement`) on the registered worker. */
118
+ static clone<T extends object>(value: T): Promise<T>;
119
+ /**
120
+ * Runs the handler a third-party library registered for `kind` (see
121
+ * `registerGameWorkerHandler`) on the registered worker, passing it `payload`. Lets a
122
+ * library built on top of Pixi'VN share this same worker instead of needing one of its own -
123
+ * see that function's doc comment for the worker-side half of this.
124
+ */
125
+ static custom<TResult = unknown>(kind: string, payload: unknown): Promise<TResult>;
126
+ }
127
+
128
+ type GameWorkerHandler = (payload: unknown) => unknown | Promise<unknown>;
129
+ /** Registers (or replaces) the worker-side handler for `kind`. See this file's doc comment. */
130
+ declare function registerGameWorkerHandler(kind: string, handler: GameWorkerHandler): void;
131
+ /** Removes the worker-side handler previously registered for `kind`, if any. */
132
+ declare function unregisterGameWorkerHandler(kind: string): void;
133
+
134
+ /**
135
+ * Applies `stateDiff` to `state`, via the registered game worker if one is available (see
136
+ * `Game.worker`), falling back to computing it synchronously on the main thread otherwise -
137
+ * whether that's because no worker was registered, or because the worker call itself failed (the
138
+ * caller should never hard-fail just because the optional worker hiccuped).
139
+ */
140
+ declare function restoreDiffMaybeOffloaded<T extends object>(state: T, stateDiff: Difference[]): Promise<T>;
141
+ /**
142
+ * Computes the difference between `before` and `after`, via the registered game worker if
143
+ * available, falling back to the main thread otherwise. Mirrors
144
+ * {@link restoreDiffMaybeOffloaded} - same worker, opposite direction.
145
+ */
146
+ declare function diffMaybeOffloaded(before: object, after: object): Promise<Difference[]>;
147
+ /**
148
+ * Deep-clones `value` (matching `createExportableElement`'s JSON-round-trip semantics), via the
149
+ * registered game worker if available, falling back to the main thread otherwise.
150
+ */
151
+ declare function cloneMaybeOffloaded<T extends object>(value: T): Promise<T>;
152
+
153
+ export { type GameWorkerHandler, GameWorkerManager, type GameWorkerRequest, type GameWorkerResponse, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
@@ -0,0 +1 @@
1
+ import {b,a as a$1}from'./chunk-AWU37VV6.mjs';function u(r){try{if(typeof r>"u")return r;let e=JSON.stringify(r);return JSON.parse(e)}catch(e){throw b.error("Error creating exportable element",r,e),new a$1("not_json_serializable","Error creating exportable element")}}function g(r,e){let t=u(r);return e.length>1&&"type"in e[0]&&(e=e.slice().reverse()),e.forEach(o=>{W(t,o);}),t}function W(r,e){let t=r;e.path&&e.path.length>0?e.path.forEach((o,f)=>{if(e.path&&f===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[o]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof o=="number"?t.splice(o,1):delete t[o];break}else t=t[o];}):b.warn("No path found, skipping diff",e);}var x=["Date","RegExp","String","Number"],T=Object.getOwnPropertyNames(globalThis.Temporal||{});function l(r,e,t={cyclesFix:true},o=[]){let f=[],d=Array.isArray(r);for(let i in r){let n=r[i],y=d?+i:i;if(!(i in e)){f.push({type:"REMOVE",path:[y],oldValue:n});continue}let c=e[i],w=typeof n=="object"&&typeof c=="object"&&Array.isArray(n)===Array.isArray(c),m=w&&n?Object.getPrototypeOf(n)?.constructor?.name:void 0;if(n&&c&&w&&!x.includes(m)&&!T.includes(m)&&(!t.cyclesFix||!o.includes(n))){t.cyclesFix&&o.push(n);let G=l(n,c,t,o);t.cyclesFix&&o.pop();for(let h of G)h.path.unshift(y),f.push(h);}else Object.is(n,c)||T.includes(m)&&String(n)===String(c)||x.includes(m)&&(isNaN(n)?n+""==c+"":+n==+c)||f.push({path:[y],type:"CHANGE",value:c,oldValue:n});}let p=Array.isArray(e);for(let i in e)i in r||f.push({type:"CREATE",path:[p?+i:i],value:e[i]});return f}var k=new Map;function v(r,e){k.set(r,e);}function D(r){k.delete(r);}function E(r){return k.get(r)}async function M(r){try{switch(r.type){case "restore-diff":{let e=g(r.state,r.diff);return {id:r.id,type:"restore-diff-result",result:e}}case "diff":{let e=l(r.before,r.after);return {id:r.id,type:"diff-result",result:e}}case "clone":{let e=JSON.parse(JSON.stringify(r.value));return {id:r.id,type:"clone-result",result:e}}case "custom":{let e=E(r.kind);if(!e)throw new Error(`No game worker handler registered for kind "${r.kind}"`);let t=await e(r.payload);return {id:r.id,type:"custom-result",result:t}}}}catch(e){return {id:r.id,type:"error",error:e instanceof Error?e.message:String(e)}}}var a=class r{static _worker;static _pending=new Map;static _nextId=0;static get isAvailable(){return r._worker!==void 0}static register(e){r.unregister(),r._worker=e,e.addEventListener("message",r._handleMessage);}static unregister(){let e=r._worker;if(e){e.removeEventListener("message",r._handleMessage),r._worker=void 0;for(let{reject:t}of r._pending.values())t(new Error("Game worker was unregistered"));r._pending.clear();}}static _handleMessage=e=>{let t=r._pending.get(e.data.id);t&&(r._pending.delete(e.data.id),e.data.type==="error"?t.reject(new Error(e.data.error)):t.resolve(e.data.result));};static _request(e){let t=r._worker;if(!t)return Promise.reject(new Error("No game worker is registered"));let o=r._nextId++;return new Promise((f,d)=>{r._pending.set(o,{resolve:f,reject:d});try{t.postMessage({...e,id:o});}catch(p){r._pending.delete(o),b.error("Error posting message to game worker",p),d(p);}})}static async restoreDiff(e,t){return await r._request({type:"restore-diff",state:e,diff:t})}static async diff(e,t){return await r._request({type:"diff",before:e,after:t})}static async clone(e){return await r._request({type:"clone",value:e})}static async custom(e,t){return await r._request({type:"custom",kind:e,payload:t})}};async function A(r,e){if(a.isAvailable)try{return await a.restoreDiff(r,e)}catch(t){b.warn("Game worker failed to restore diff, falling back to the main thread",t);}return g(r,e)}async function O(r,e){if(a.isAvailable)try{return await a.diff(r,e)}catch(t){b.warn("Game worker failed to compute diff, falling back to the main thread",t);}return l(r,e)}async function j(r){if(a.isAvailable)try{return await a.clone(r)}catch(e){b.warn("Game worker failed to clone value, falling back to the main thread",e);}return u(r)}export{a as GameWorkerManager,j as cloneMaybeOffloaded,O as diffMaybeOffloaded,M as handleGameWorkerMessage,v as registerGameWorkerHandler,A as restoreDiffMaybeOffloaded,D as unregisterGameWorkerHandler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN is a very versatile and powerful game/story-driven engine.",
6
6
  "main": "./dist/index.cjs",
@@ -36,6 +36,12 @@
36
36
  "require": "./dist/core.cjs",
37
37
  "default": "./dist/core.mjs"
38
38
  },
39
+ "./worker": {
40
+ "types": "./dist/worker.d.ts",
41
+ "import": "./dist/worker.mjs",
42
+ "require": "./dist/worker.cjs",
43
+ "default": "./dist/worker.mjs"
44
+ },
39
45
  "./pixi.js": {
40
46
  "types": "./dist/pixi/index.d.ts",
41
47
  "import": "./dist/pixi/index.js",
@@ -1 +0,0 @@
1
- var _="__game_layer__",E="Container",A="ImageContainer",e="Image",t="Sprite",o="Text",T="Video",N="general",R="storage",I="temp",S="narration",O="flags",n={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"};export{_ as a,E as b,A as c,e as d,t as e,o as f,T as g,N as h,R as i,I as j,S as k,O as l,n as m};
@@ -1 +0,0 @@
1
- import {PixiError}from'@drincs/pixi-vn/core';var Kt=Object.create;var xt=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Jt=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty;var Gt=l=>{throw TypeError(l)};var Xt=(l,e,i)=>e in l?xt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ie=(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});var se=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Yt=(l,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let h of Bt(e))!qt.call(l,h)&&h!==i&&xt(l,h,{get:()=>e[h],enumerable:!(s=$t(e,h))||s.enumerable});return l};var he=(l,e,i)=>(i=l!=null?Kt(Jt(l)):{},Yt(e||!l||!l.__esModule?xt(i,"default",{value:l,enumerable:true}):i,l));var T=(l,e,i)=>Xt(l,typeof e!="symbol"?e+"":e,i),Tt=(l,e,i)=>e.has(l)||Gt("Cannot "+i);var t=(l,e,i)=>(Tt(l,e,"read from private field"),i?i.call(l):e.get(l)),g=(l,e,i)=>e.has(l)?Gt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(Tt(l,e,"write to private field"),e.set(l,i),i),a=(l,e,i)=>(Tt(l,e,"access private method"),i);var yt=(l,e,i,s)=>({set _(h){f(l,e,h);},get _(){return t(l,e,s)}});var Qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,It=new Set,zt=typeof process=="object"&&process?process:{},Vt=(l,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Ft=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Ft>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Ft=class{constructor(){e();}signal=new jt;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 l=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,Vt("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 Zt=l=>!It.has(l);var tt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),Pt=l=>tt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?_t:null:null,_t=class extends Array{constructor(l){super(l),this.fill(0);}},Y,ct,te=(Y=class{heap;length;static create(e){let i=Pt(e);if(!i)return [];f(Y,ct,true);let s=new Y(e,i);return f(Y,ct,false),s}constructor(e,i){if(!t(Y,ct))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},ct=new WeakMap,g(Y,ct,false),Y),Mt,Nt,V,U,P,ot,k,ft,dt,H,O,K,A,b,d,W,G,z,F,$,E,B,J,j,M,q,ht,D,pt,n,Rt,rt,Q,vt,N,Ht,nt,gt,bt,et,it,Ct,At,Ot,v,Wt,St,st,Dt,wt,kt=(wt=class{constructor(e){g(this,n);g(this,V);g(this,U);g(this,P);g(this,ot);g(this,k);g(this,ft);g(this,dt);g(this,H);T(this,"ttl");T(this,"ttlResolution");T(this,"ttlAutopurge");T(this,"updateAgeOnGet");T(this,"updateAgeOnHas");T(this,"allowStale");T(this,"noDisposeOnSet");T(this,"noUpdateTTL");T(this,"maxEntrySize");T(this,"sizeCalculation");T(this,"noDeleteOnFetchRejection");T(this,"noDeleteOnStaleGet");T(this,"allowStaleOnFetchAbort");T(this,"allowStaleOnFetchRejection");T(this,"ignoreFetchAbort");g(this,O);g(this,K);g(this,A);g(this,b);g(this,d);g(this,W);g(this,G);g(this,z);g(this,F);g(this,$);g(this,E);g(this,B);g(this,J);g(this,j);g(this,M);g(this,q);g(this,ht);g(this,D);g(this,pt);g(this,rt,()=>{});g(this,Q,()=>{});g(this,vt,()=>{});g(this,N,()=>false);g(this,nt,e=>{});g(this,gt,(e,i,s)=>{});g(this,bt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});T(this,Mt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:u,allowStale:c,dispose:w,onInsert:x,disposeAfter:m,noDisposeOnSet:Z,noUpdateTTL:I,maxSize:X=0,maxEntrySize:y=0,sizeCalculation:S,fetchMethod:p,memoMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:mt,ignoreFetchAbort:lt,perf:at}=e;if(at!==void 0&&typeof at?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,H,at??Qt),i!==0&&!tt(i))throw new TypeError("max option must be a nonnegative integer");let ut=i?Pt(i):Array;if(!ut)throw new Error("invalid max value: "+i);if(f(this,V,i),f(this,U,X),this.maxEntrySize=y||t(this,U),this.sizeCalculation=S,this.sizeCalculation){if(!t(this,U)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,dt,R),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,ft,p),f(this,ht,!!p),f(this,A,new Map),f(this,b,new Array(i).fill(void 0)),f(this,d,new Array(i).fill(void 0)),f(this,W,new ut(i)),f(this,G,new ut(i)),f(this,z,0),f(this,F,0),f(this,$,te.create(i)),f(this,O,0),f(this,K,0),typeof w=="function"&&f(this,P,w),typeof x=="function"&&f(this,ot,x),typeof m=="function"?(f(this,k,m),f(this,E,[])):(f(this,k,void 0),f(this,E,void 0)),f(this,q,!!t(this,P)),f(this,pt,!!t(this,ot)),f(this,D,!!t(this,k)),this.noDisposeOnSet=!!Z,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!_,this.allowStaleOnFetchAbort=!!mt,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(t(this,U)!==0&&!tt(t(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");a(this,n,Ht).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!u,this.ttlResolution=tt(h)||h===0?h:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");a(this,n,Rt).call(this);}if(t(this,V)===0&&this.ttl===0&&t(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,V)&&!t(this,U)){let Et="LRU_CACHE_UNBOUNDED";Zt(Et)&&(It.add(Et),Vt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Et,wt));}}get perf(){return t(this,H)}static unsafeExposeInternals(e){return {starts:t(e,J),ttls:t(e,j),autopurgeTimers:t(e,M),sizes:t(e,B),keyMap:t(e,A),keyList:t(e,b),valList:t(e,d),next:t(e,W),prev:t(e,G),get head(){return t(e,z)},get tail(){return t(e,F)},free:t(e,$),isBackgroundFetch:i=>{var s;return a(s=e,n,v).call(s,i)},backgroundFetch:(i,s,h,r)=>{var o;return a(o=e,n,Ot).call(o,i,s,h,r)},moveToTail:i=>{var s;return a(s=e,n,St).call(s,i)},indexes:i=>{var s;return a(s=e,n,et).call(s,i)},rindexes:i=>{var s;return a(s=e,n,it).call(s,i)},isStale:i=>{var s;return t(s=e,N).call(s,i)}}}get max(){return t(this,V)}get maxSize(){return t(this,U)}get calculatedSize(){return t(this,K)}get size(){return t(this,O)}get fetchMethod(){return t(this,ft)}get memoMethod(){return t(this,dt)}get dispose(){return t(this,P)}get onInsert(){return t(this,ot)}get disposeAfter(){return t(this,k)}getRemainingTTL(e){return t(this,A).has(e)?1/0:0}*entries(){for(let e of a(this,n,et).call(this))t(this,d)[e]!==void 0&&t(this,b)[e]!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield [t(this,b)[e],t(this,d)[e]]);}*rentries(){for(let e of a(this,n,it).call(this))t(this,d)[e]!==void 0&&t(this,b)[e]!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield [t(this,b)[e],t(this,d)[e]]);}*keys(){for(let e of a(this,n,et).call(this)){let i=t(this,b)[e];i!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield i);}}*rkeys(){for(let e of a(this,n,it).call(this)){let i=t(this,b)[e];i!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield i);}}*values(){for(let e of a(this,n,et).call(this))t(this,d)[e]!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}*rvalues(){for(let e of a(this,n,it).call(this))t(this,d)[e]!==void 0&&!a(this,n,v).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}[(Nt=Symbol.iterator,Mt=Symbol.toStringTag,Nt)](){return this.entries()}find(e,i={}){for(let s of a(this,n,et).call(this)){let h=t(this,d)[s],r=a(this,n,v).call(this,h)?h.__staleWhileFetching:h;if(r!==void 0&&e(r,t(this,b)[s],this))return this.get(t(this,b)[s],i)}}forEach(e,i=this){for(let s of a(this,n,et).call(this)){let h=t(this,d)[s],r=a(this,n,v).call(this,h)?h.__staleWhileFetching:h;r!==void 0&&e.call(i,r,t(this,b)[s],this);}}rforEach(e,i=this){for(let s of a(this,n,it).call(this)){let h=t(this,d)[s],r=a(this,n,v).call(this,h)?h.__staleWhileFetching:h;r!==void 0&&e.call(i,r,t(this,b)[s],this);}}purgeStale(){let e=false;for(let i of a(this,n,it).call(this,{allowStale:true}))t(this,N).call(this,i)&&(a(this,n,st).call(this,t(this,b)[i],"expire"),e=true);return e}info(e){let i=t(this,A).get(e);if(i===void 0)return;let s=t(this,d)[i],h=a(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(h===void 0)return;let r={value:h};if(t(this,j)&&t(this,J)){let o=t(this,j)[i],u=t(this,J)[i];if(o&&u){let c=o-(t(this,H).now()-u);r.ttl=c,r.start=Date.now();}}return t(this,B)&&(r.size=t(this,B)[i]),r}dump(){let e=[];for(let i of a(this,n,et).call(this,{allowStale:true})){let s=t(this,b)[i],h=t(this,d)[i],r=a(this,n,v).call(this,h)?h.__staleWhileFetching:h;if(r===void 0||s===void 0)continue;let o={value:r};if(t(this,j)&&t(this,J)){o.ttl=t(this,j)[i];let u=t(this,H).now()-t(this,J)[i];o.start=Math.floor(Date.now()-u);}t(this,B)&&(o.size=t(this,B)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let h=Date.now()-s.start;s.start=t(this,H).now()-h;}this.set(i,s.value,s);}}set(e,i,s={}){var Z,I,X,y;if(i===void 0)return this.delete(e),this;let{ttl:h=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:u=this.sizeCalculation,status:c}=s,{noUpdateTTL:w=this.noUpdateTTL}=s,x=t(this,bt).call(this,e,i,s.size||0,u);if(this.maxEntrySize&&x>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),a(this,n,st).call(this,e,"set"),this;let m=t(this,O)===0?void 0:t(this,A).get(e);if(m===void 0)m=t(this,O)===0?t(this,F):t(this,$).length!==0?t(this,$).pop():t(this,O)===t(this,V)?a(this,n,At).call(this,false):t(this,O),t(this,b)[m]=e,t(this,d)[m]=i,t(this,A).set(e,m),t(this,W)[t(this,F)]=m,t(this,G)[m]=t(this,F),f(this,F,m),yt(this,O)._++,t(this,gt).call(this,m,x,c),c&&(c.set="add"),w=false,t(this,pt)&&((Z=t(this,ot))==null||Z.call(this,i,e,"add"));else {a(this,n,St).call(this,m);let S=t(this,d)[m];if(i!==S){if(t(this,ht)&&a(this,n,v).call(this,S)){S.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=S;p!==void 0&&!o&&(t(this,q)&&((I=t(this,P))==null||I.call(this,p,e,"set")),t(this,D)&&t(this,E)?.push([p,e,"set"]));}else o||(t(this,q)&&((X=t(this,P))==null||X.call(this,S,e,"set")),t(this,D)&&t(this,E)?.push([S,e,"set"]));if(t(this,nt).call(this,m),t(this,gt).call(this,m,x,c),t(this,d)[m]=i,c){c.set="replace";let p=S&&a(this,n,v).call(this,S)?S.__staleWhileFetching:S;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,pt)&&this.onInsert?.(i,e,i===S?"update":"replace");}if(h!==0&&!t(this,j)&&a(this,n,Rt).call(this),t(this,j)&&(w||t(this,vt).call(this,m,h,r),c&&t(this,Q).call(this,c,m)),!o&&t(this,D)&&t(this,E)){let S=t(this,E),p;for(;p=S?.shift();)(y=t(this,k))==null||y.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,d)[t(this,z)];if(a(this,n,At).call(this,!0),a(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,D)&&t(this,E)){let i=t(this,E),s;for(;s=i?.shift();)(e=t(this,k))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h}=i,r=t(this,A).get(e);if(r!==void 0){let o=t(this,d)[r];if(a(this,n,v).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,N).call(this,r))h&&(h.has="stale",t(this,Q).call(this,h,r));else return s&&t(this,rt).call(this,r),h&&(h.has="hit",t(this,Q).call(this,h,r)),true}else h&&(h.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,h=t(this,A).get(e);if(h===void 0||!s&&t(this,N).call(this,h))return;let r=t(this,d)[h];return a(this,n,v).call(this,r)?r.__staleWhileFetching:r}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:u=this.noDisposeOnSet,size:c=0,sizeCalculation:w=this.sizeCalculation,noUpdateTTL:x=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:X=this.allowStaleOnFetchAbort,context:y,forceRefresh:S=false,status:p,signal:R}=i;if(!t(this,ht))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:r,status:p});let L={allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:u,size:c,sizeCalculation:w,noUpdateTTL:x,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:X,ignoreFetchAbort:I,status:p,signal:R},C=t(this,A).get(e);if(C===void 0){p&&(p.fetch="miss");let _=a(this,n,Ot).call(this,e,C,L,y);return _.__returned=_}else {let _=t(this,d)[C];if(a(this,n,v).call(this,_)){let ut=s&&_.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",ut&&(p.returnedStale=true)),ut?_.__staleWhileFetching:_.__returned=_}let mt=t(this,N).call(this,C);if(!S&&!mt)return p&&(p.fetch="hit"),a(this,n,St).call(this,C),h&&t(this,rt).call(this,C),p&&t(this,Q).call(this,p,C),_;let lt=a(this,n,Ot).call(this,e,C,L,y),at=lt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=mt?"stale":"refresh",at&&mt&&(p.returnedStale=true)),at?lt.__staleWhileFetching:lt.__returned=lt}}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,i={}){let s=t(this,dt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:r,...o}=i,u=this.get(e,o);if(!r&&u!==void 0)return u;let c=s(e,u,{options:o,context:h});return this.set(e,c,o),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=i,u=t(this,A).get(e);if(u!==void 0){let c=t(this,d)[u],w=a(this,n,v).call(this,c);return o&&t(this,Q).call(this,o,u),t(this,N).call(this,u)?(o&&(o.get="stale"),w?(o&&s&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?c.__staleWhileFetching:void 0):(r||a(this,n,st).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?c:void 0)):(o&&(o.get="hit"),w?c.__staleWhileFetching:(a(this,n,St).call(this,u),h&&t(this,rt).call(this,u),c))}else o&&(o.get="miss");}delete(e){return a(this,n,st).call(this,e,"delete")}clear(){return a(this,n,Dt).call(this,"delete")}},V=new WeakMap,U=new WeakMap,P=new WeakMap,ot=new WeakMap,k=new WeakMap,ft=new WeakMap,dt=new WeakMap,H=new WeakMap,O=new WeakMap,K=new WeakMap,A=new WeakMap,b=new WeakMap,d=new WeakMap,W=new WeakMap,G=new WeakMap,z=new WeakMap,F=new WeakMap,$=new WeakMap,E=new WeakMap,B=new WeakMap,J=new WeakMap,j=new WeakMap,M=new WeakMap,q=new WeakMap,ht=new WeakMap,D=new WeakMap,pt=new WeakMap,n=new WeakSet,Rt=function(){let e=new _t(t(this,V)),i=new _t(t(this,V));f(this,j,e),f(this,J,i);let s=this.ttlAutopurge?new Array(t(this,V)):void 0;f(this,M,s),f(this,vt,(u,c,w=t(this,H).now())=>{i[u]=c!==0?w:0,e[u]=c,h(u,c);}),f(this,rt,u=>{i[u]=e[u]!==0?t(this,H).now():0,h(u,e[u]);});let h=this.ttlAutopurge?(u,c)=>{if(s?.[u]&&(clearTimeout(s[u]),s[u]=void 0),c&&c!==0&&s){let w=setTimeout(()=>{t(this,N).call(this,u)&&a(this,n,st).call(this,t(this,b)[u],"expire");},c+1);w.unref&&w.unref(),s[u]=w;}}:()=>{};f(this,Q,(u,c)=>{if(e[c]){let w=e[c],x=i[c];if(!w||!x)return;u.ttl=w,u.start=x,u.now=r||o();let m=u.now-x;u.remainingTTL=w-m;}});let r=0,o=()=>{let u=t(this,H).now();if(this.ttlResolution>0){r=u;let c=setTimeout(()=>r=0,this.ttlResolution);c.unref&&c.unref();}return u};this.getRemainingTTL=u=>{let c=t(this,A).get(u);if(c===void 0)return 0;let w=e[c],x=i[c];if(!w||!x)return 1/0;let m=(r||o())-x;return w-m},f(this,N,u=>{let c=i[u],w=e[u];return !!w&&!!c&&(r||o())-c>w});},rt=new WeakMap,Q=new WeakMap,vt=new WeakMap,N=new WeakMap,Ht=function(){let e=new _t(t(this,V));f(this,K,0),f(this,B,e),f(this,nt,i=>{f(this,K,t(this,K)-e[i]),e[i]=0;}),f(this,bt,(i,s,h,r)=>{if(a(this,n,v).call(this,s))return 0;if(!tt(h))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(h=r(s,i),!tt(h))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 h}),f(this,gt,(i,s,h)=>{if(e[i]=s,t(this,U)){let r=t(this,U)-e[i];for(;t(this,K)>r;)a(this,n,At).call(this,true);}f(this,K,t(this,K)+e[i]),h&&(h.entrySize=s,h.totalCalculatedSize=t(this,K));});},nt=new WeakMap,gt=new WeakMap,bt=new WeakMap,et=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,F);!(!a(this,n,Ct).call(this,i)||((e||!t(this,N).call(this,i))&&(yield i),i===t(this,z)));)i=t(this,G)[i];},it=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,z);!(!a(this,n,Ct).call(this,i)||((e||!t(this,N).call(this,i))&&(yield i),i===t(this,F)));)i=t(this,W)[i];},Ct=function(e){return e!==void 0&&t(this,A).get(t(this,b)[e])===e},At=function(e){var r;let i=t(this,z),s=t(this,b)[i],h=t(this,d)[i];return t(this,ht)&&a(this,n,v).call(this,h)?h.__abortController.abort(new Error("evicted")):(t(this,q)||t(this,D))&&(t(this,q)&&((r=t(this,P))==null||r.call(this,h,s,"evict")),t(this,D)&&t(this,E)?.push([h,s,"evict"])),t(this,nt).call(this,i),t(this,M)?.[i]&&(clearTimeout(t(this,M)[i]),t(this,M)[i]=void 0),e&&(t(this,b)[i]=void 0,t(this,d)[i]=void 0,t(this,$).push(i)),t(this,O)===1?(f(this,z,f(this,F,0)),t(this,$).length=0):f(this,z,t(this,W)[i]),t(this,A).delete(s),yt(this,O)._--,i},Ot=function(e,i,s,h){let r=i===void 0?void 0:t(this,d)[i];if(a(this,n,v).call(this,r))return r;let o=new Ft,{signal:u}=s;u?.addEventListener("abort",()=>o.abort(u.reason),{signal:o.signal});let c={signal:o.signal,options:s,context:h},w=(y,S=false)=>{let{aborted:p}=o.signal,R=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!S?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!R&&!S)return m(o.signal.reason,L);let C=I,_=t(this,d)[i];return (_===I||R&&S&&_===void 0)&&(y===void 0?C.__staleWhileFetching!==void 0?t(this,d)[i]=C.__staleWhileFetching:a(this,n,st).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},x=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),m(y,false)),m=(y,S)=>{let{aborted:p}=o.signal,R=p&&s.allowStaleOnFetchAbort,L=R||s.allowStaleOnFetchRejection,C=L||s.noDeleteOnFetchRejection,_=I;if(t(this,d)[i]===I&&(!C||!S&&_.__staleWhileFetching===void 0?a(this,n,st).call(this,e,"fetch"):R||(t(this,d)[i]=_.__staleWhileFetching)),L)return s.status&&_.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),_.__staleWhileFetching;if(_.__returned===_)throw y},Z=(y,S)=>{var R;let p=(R=t(this,ft))==null?void 0:R.call(this,e,r,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),S),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>w(L,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(Z).then(w,x),X=Object.assign(I,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return i===void 0?(this.set(e,X,{...c.options,status:void 0}),i=t(this,A).get(e)):t(this,d)[i]=X,X},v=function(e){if(!t(this,ht))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},Wt=function(e,i){t(this,G)[i]=e,t(this,W)[e]=i;},St=function(e){e!==t(this,F)&&(e===t(this,z)?f(this,z,t(this,W)[e]):a(this,n,Wt).call(this,t(this,G)[e],t(this,W)[e]),a(this,n,Wt).call(this,t(this,F),e),f(this,F,e));},st=function(e,i){var h,r;let s=false;if(t(this,O)!==0){let o=t(this,A).get(e);if(o!==void 0)if(t(this,M)?.[o]&&(clearTimeout(t(this,M)?.[o]),t(this,M)[o]=void 0),s=true,t(this,O)===1)a(this,n,Dt).call(this,i);else {t(this,nt).call(this,o);let u=t(this,d)[o];if(a(this,n,v).call(this,u)?u.__abortController.abort(new Error("deleted")):(t(this,q)||t(this,D))&&(t(this,q)&&((h=t(this,P))==null||h.call(this,u,e,i)),t(this,D)&&t(this,E)?.push([u,e,i])),t(this,A).delete(e),t(this,b)[o]=void 0,t(this,d)[o]=void 0,o===t(this,F))f(this,F,t(this,G)[o]);else if(o===t(this,z))f(this,z,t(this,W)[o]);else {let c=t(this,G)[o];t(this,W)[c]=t(this,W)[o];let w=t(this,W)[o];t(this,G)[w]=t(this,G)[o];}yt(this,O)._--,t(this,$).push(o);}}if(t(this,D)&&t(this,E)?.length){let o=t(this,E),u;for(;u=o?.shift();)(r=t(this,k))==null||r.call(this,...u);}return s},Dt=function(e){var i,s;for(let h of a(this,n,it).call(this,{allowStale:true})){let r=t(this,d)[h];if(a(this,n,v).call(this,r))r.__abortController.abort(new Error("deleted"));else {let o=t(this,b)[h];t(this,q)&&((i=t(this,P))==null||i.call(this,r,o,e)),t(this,D)&&t(this,E)?.push([r,o,e]);}}if(t(this,A).clear(),t(this,d).fill(void 0),t(this,b).fill(void 0),t(this,j)&&t(this,J)){t(this,j).fill(0),t(this,J).fill(0);for(let h of t(this,M)??[])h!==void 0&&clearTimeout(h);t(this,M)?.fill(void 0);}if(t(this,B)&&t(this,B).fill(0),f(this,z,0),f(this,F,0),t(this,$).length=0,f(this,K,0),f(this,O,0),t(this,D)&&t(this,E)){let h=t(this,E),r;for(;r=h?.shift();)(s=t(this,k))==null||s.call(this,...r);}},wt);var Lt=class{cache;map=new Map;constructor(e){this.cache=new kt({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 Ut;(h=>(h.log=(r,...o)=>console.log(`[Pixi\u2019VN] ${r}`,...o),h.warn=(r,...o)=>console.warn(`[Pixi\u2019VN] ${r}`,...o),h.error=(r,...o)=>console.error(`[Pixi\u2019VN] ${r}`,...o),h.info=(r,...o)=>console.info(`[Pixi\u2019VN] ${r}`,...o)))(Ut||={});function we(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw Ut.error("Error creating exportable element",l,e),new PixiError("not_json_serializable","Error creating exportable element")}}export{ie as a,se as b,he as c,Lt as d,Ut as e,we as f};
@@ -1 +0,0 @@
1
- import {j,l,i,k,m}from'./chunk-HD353M4B.mjs';import {d as d$1,f,e}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var I;(n=>{n.storage=new d$1({cacheSize:50}),n.defaultStorage=new d$1({cacheSize:10}),n.tempStorageDeadlines=new Map;let s;function S(r){n.tempStorageDeadlines.forEach((i,o)=>{i>r&&(n.storage.delete(`${j}:${o}`),s?.onClearOldTempVariable?.(o),n.tempStorageDeadlines.delete(o));});}n.clearOldTempVariables=S;function T(r){s=r;}n.setExternalStoreHandler=T;function h(r,i,o){o==null?n.storage.delete(`${r}:${i}`):n.storage.set(`${r}:${i}`,o),s?.onSetVariable?.(i,o);}n.setVariable=h;function V(r,i){let o=n.storage.get(`${r}:${i}`);return f(o)}n.getVariable=V;function O(r,i){n.storage.delete(`${r}:${i}`),s?.onRemoveVariable?.(i);}n.removeVariable=O;function M(r,i){let o=n.storage.get(l)||[];if(i)o.includes(r)||o.push(r);else {let y=o.indexOf(r);y>-1&&o.splice(y,1);}n.storage.set(l,o);}n.setFlag=M;function R(r){return (n.storage.get(l)||[]).includes(r)}n.getFlag=R;})(I||={});var a=I;var c=class{get base(){return a.storage.map}get cache(){return a.storage.cache}get tempStorageDeadlines(){return a.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,s])=>{a.defaultStorage.map.set(e,s);});}temp={set:(t,e)=>this.setTemp(t,e),remove:t=>this.removeTemp(t),get deadlines(){return a.tempStorageDeadlines}};flags={set:(t,e)=>a.setFlag(t,e),get:t=>a.getFlag(t)};set(t,e){return a.setVariable(i,t,e)}get(t){let e=a.getVariable(j,t);return e===void 0&&(e=a.getVariable(i,t)),e===void 0&&(e=f(a.defaultStorage.get(t))),e}remove(t){return this.temp.remove(t),a.removeVariable(i,t)}setTemp(t,e){if(e==null){this.temp.remove(t);return}else a.setVariable(j,t,e),this.temp.deadlines.has(t)||this.temp.deadlines.set(t,GameUnifier.openedLabels);}removeTemp(t){a.removeVariable(j,t),this.temp.deadlines.has(t)&&this.temp.deadlines.delete(t);}setTempVariable(t,e){this.temp.set(t,e);}removeTempVariable(t){this.temp.remove(t);}setFlag(t,e){this.flags.set(t,e);}getFlag(t){return this.flags.get(t)}setStorageHandler(t){a.setExternalStoreHandler(t);}clear(){this.base.clear(),this.cache.clear(),this.temp.deadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(s=>{t.push({key:s,value:this.base.get(s)});});let e=[];return [...this.temp.deadlines.keys()].forEach(s=>{e.push({key:s,value:this.temp.deadlines.get(s)});}),f({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":a.setVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":a.setVariable(k,m.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":a.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":a.setVariable(k,m.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":a.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":a.setVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":a.setVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":a.setVariable(k,m.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":a.setVariable(k,m.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":a.setVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":a.setVariable(k,m.LAST_STEP_GLUED,e.value);break;default:a.setVariable(i,e.key,e.value);}}),t.temp?.forEach(e=>{a.setVariable(j,e.key,e.value);}),t.flags?.forEach(e=>{a.setFlag(e,!0);}),t.main?.forEach(e=>{this.base.set(e.key,e.value);}),t.tempDeadlines?.forEach(e=>{this.temp.deadlines.set(e.key,e.value);})):e.warn("No storage data found");}catch(e$1){e.error("Error importing data",e$1);}}};var d=class{constructor(t,e){this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=a.getVariable(i,t);e&&(Object.entries(e).forEach(([s,S])=>{typeof S=="object"&&S!==null&&Object.entries(S).forEach(([T,h])=>{a.setVariable(this.categoryId,`${s}:${T}`,h);});}),a.removeVariable(i,t));}id;categoryId;setStorageProperty(t,e){a.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return a.getVariable(this.categoryId,`${e}:${t}`)}};var w=new c;export{a,d as b,w as c};