@drincs/pixi-vn-json 1.7.1 → 1.7.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,550 @@
1
+ import { StorageElementType, CanvasBaseInterface, ImageSprite, KeyframesType, AnimationOptions, UPDATE_PRIORITY, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions, ShakeEffectProps, FadeAlphaTickerProps, MoveTickerProps, RotateTickerProps, ZoomTickerProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, ContainerOptions, ContainerMemory, SoundPlayOptions, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
2
+
3
+ type PixiVNJsonStepSwitchElementType<Then> = Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>;
4
+ type PixiVNJsonStepSwitchElementsType<Then> = PixiVNJsonStepSwitchElementType<Then>[] | PixiVNJsonConditionalStatements<Then[]>;
5
+ interface PixiVNJsonRandom<Then> {
6
+ type: "stepswitch";
7
+ choiceType: "random";
8
+ elements: PixiVNJsonStepSwitchElementsType<Then>;
9
+ }
10
+ interface PixiVNJsonSequentialRandom<Then> {
11
+ type: "stepswitch";
12
+ choiceType: "sequentialrandom";
13
+ elements: PixiVNJsonStepSwitchElementsType<Then>;
14
+ /**
15
+ * When the sequential ends, what should be the value? If undefined, it will return undefined.
16
+ * If "lastItem", it will return the last item in the array.
17
+ */
18
+ end: undefined | "lastItem";
19
+ /**
20
+ * The subId is used for manager nested switches
21
+ */
22
+ nestedId?: string;
23
+ }
24
+ interface PixiVNJsonSequential<Then> {
25
+ type: "stepswitch";
26
+ choiceType: "sequential";
27
+ elements: PixiVNJsonStepSwitchElementsType<Then>;
28
+ /**
29
+ * When the sequential ends, what should be the value? If undefined, it will return undefined.
30
+ * If "lastItem", it will return the last item in the array.
31
+ */
32
+ end: undefined | "lastItem";
33
+ /**
34
+ * The subId is used for manager nested switches
35
+ */
36
+ nestedId?: string;
37
+ }
38
+ interface PixiVNJsonLoop<Then> {
39
+ type: "stepswitch";
40
+ choiceType: "loop";
41
+ elements: PixiVNJsonStepSwitchElementsType<Then>;
42
+ nestedId?: string;
43
+ }
44
+ type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<Then> | PixiVNJsonLoop<Then> | PixiVNJsonSequentialRandom<Then>;
45
+
46
+ /**
47
+ * This element is used in case a {@link PixiVNJsonConditionalStatements} gives a result that must be combined with another calculated through other {@link PixiVNJsonConditionalStatements}.
48
+ * in case this possibility is not managed, it will be taken into consideration {@link PixiVNJsonConditionalResultToCombine.firstItem}
49
+ */
50
+ type PixiVNJsonConditionalResultToCombine<T> = {
51
+ type: "resulttocombine";
52
+ /**
53
+ * This variable is interpreted differently by Pixi'VN depending on the value
54
+ */
55
+ combine: "cross" | "union";
56
+ firstItem?: T;
57
+ secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
58
+ };
59
+
60
+ type PixiVNJsonStorageGet = {
61
+ type: "value";
62
+ storageOperationType: "get";
63
+ /**
64
+ * Key of the storage
65
+ */
66
+ key: string;
67
+ /**
68
+ * Type of the storage, if it is a flagStorage or a storage.
69
+ * If it is a flagStorage, the value will be get with the function {@link getFlag}
70
+ */
71
+ storageType: "storage" | "flagStorage" | "tempstorage";
72
+ };
73
+ type PixiVNJsonParamGet = {
74
+ type: "value";
75
+ storageOperationType: "get";
76
+ /**
77
+ * Key of the storage
78
+ */
79
+ key: number;
80
+ storageType: "params";
81
+ };
82
+ type PixiVNJsonLabelGet = {
83
+ type: "value";
84
+ storageOperationType: "get";
85
+ /**
86
+ * Id of the label
87
+ */
88
+ label: string;
89
+ /**
90
+ * If it is a label, the value will be get with the function {@link narration.getTimesLabelOpened}
91
+ */
92
+ storageType: "label";
93
+ };
94
+ type PixiVNJsonChoiceGet = {
95
+ type: "value";
96
+ storageOperationType: "get";
97
+ /**
98
+ * index of the choice
99
+ */
100
+ index: number;
101
+ /**
102
+ * If it is a choice, the value will be get with the function {@link narration.getTimesChoiceOpened}
103
+ */
104
+ storageType: "choice";
105
+ };
106
+ type PixiVNJsonLogicGet = {
107
+ type: "value";
108
+ storageOperationType: "get";
109
+ operation: PixiVNJsonArithmeticOperations | PixiVNJsonConditions;
110
+ storageType: "logic";
111
+ };
112
+ type PixiVNJsonValueGet = PixiVNJsonStorageGet | PixiVNJsonParamGet | PixiVNJsonLabelGet | PixiVNJsonChoiceGet | PixiVNJsonLogicGet;
113
+ type PixiVNJsonOnlyStorageSet = {
114
+ type: "value";
115
+ storageOperationType: "set";
116
+ /**
117
+ * Key of the storage
118
+ */
119
+ key: string;
120
+ /**
121
+ * Value to be set in the storage
122
+ */
123
+ value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
124
+ /**
125
+ * Type of the storage, if it is a flagStorage or a storage.
126
+ */
127
+ storageType: "storage" | "tempstorage";
128
+ };
129
+ type PixiVNJsonOnlyParamSet = {
130
+ type: "value";
131
+ storageOperationType: "set";
132
+ /**
133
+ * Key of the storage
134
+ */
135
+ key: number;
136
+ /**
137
+ * Value to be set in the storage
138
+ */
139
+ value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
140
+ storageType: "params";
141
+ };
142
+ type PixiVNJsonFlagSet = {
143
+ type: "value";
144
+ storageOperationType: "set";
145
+ /**
146
+ * Key of the storage
147
+ */
148
+ key: string;
149
+ /**
150
+ * Value to be set in the storage
151
+ */
152
+ value: boolean;
153
+ /**
154
+ * Type of the storage, if it is a flagStorage or a storage.
155
+ */
156
+ storageType: "flagStorage";
157
+ };
158
+ type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
159
+
160
+ interface PixiVNJsonArithmeticOperationsArithmetic {
161
+ type: "arithmetic";
162
+ /**
163
+ * Left value of the arithmetic operation
164
+ */
165
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
166
+ /**
167
+ * Right value of the arithmetic operation
168
+ */
169
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
170
+ /**
171
+ * Operator of the arithmetic operation
172
+ */
173
+ operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
174
+ }
175
+ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
176
+ type: "arithmeticsingle";
177
+ /**
178
+ * Left value of the arithmetic operation
179
+ */
180
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
181
+ /**
182
+ * Operator of the arithmetic operation
183
+ */
184
+ operator: "INT" | "FLOOR" | "FLOAT";
185
+ }
186
+ /**
187
+ * Arithmetic operations for the PixiVNJson
188
+ */
189
+ type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
190
+
191
+ type PixiVNJsonUnionConditionAndOr = {
192
+ type: "union";
193
+ conditions: PixiVNJsonConditions[];
194
+ unionType: "and" | "or";
195
+ };
196
+ type PixiVNJsonUnionConditionNot = {
197
+ type: "union";
198
+ condition: PixiVNJsonConditions;
199
+ unionType: "not";
200
+ };
201
+ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
202
+
203
+ /**
204
+ * Comparation for PixiVNJson.
205
+ * In this comparation, the values to be converted to string and compared.
206
+ */
207
+ type PixiVNJsonComparation = {
208
+ type: "compare";
209
+ /**
210
+ * Left value of the comparation
211
+ */
212
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
213
+ /**
214
+ * Right value of the comparation
215
+ */
216
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
217
+ /**
218
+ * Operator of the comparation
219
+ */
220
+ operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
221
+ };
222
+ type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
223
+ /**
224
+ * Conditions for PixiVNJson
225
+ */
226
+ type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
227
+
228
+ /**
229
+ * If-Else condition for PixiVNJson
230
+ */
231
+ interface PixiVNJsonIfElse<Then> {
232
+ type: "ifelse";
233
+ /**
234
+ * The list of conditions to be checked.
235
+ */
236
+ condition: PixiVNJsonConditions;
237
+ /**
238
+ * The value to be returned if the condition is true.
239
+ */
240
+ then: Then | PixiVNJsonIfElse<Then>;
241
+ /**
242
+ * The value to be returned if the condition is false.
243
+ */
244
+ else?: Then | PixiVNJsonIfElse<Then>;
245
+ }
246
+
247
+ type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
248
+
249
+ type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
250
+ type: "animate";
251
+ alias: string | string[];
252
+ keyframes: KeyframesType<T>;
253
+ options?: AnimationOptions;
254
+ priority?: UPDATE_PRIORITY;
255
+ };
256
+ type PixiVNJsonAnimateSequence<T extends CanvasBaseInterface<any>> = {
257
+ type: "animate-sequence";
258
+ alias: string;
259
+ sequence: (ObjectSegment<T> | ObjectSegmentWithTransition<T>)[];
260
+ options?: SequenceOptions;
261
+ priority?: UPDATE_PRIORITY;
262
+ };
263
+ type PixiVNJsonCanvasAnimate<T extends CanvasBaseInterface<any> = ImageSprite> = PixiVNJsonAnimateBase<T> | PixiVNJsonAnimateSequence<T>;
264
+
265
+ type PixiVNJsonEffectShake = {
266
+ type: "shake";
267
+ alias: string;
268
+ props: ShakeEffectProps;
269
+ priority?: UPDATE_PRIORITY;
270
+ };
271
+ type PixiVNJsonCanvasEffect = PixiVNJsonEffectShake;
272
+
273
+ /**
274
+ * @deprecated
275
+ */
276
+ type PixiVNJsonTickerFade = {
277
+ type: "fade";
278
+ alias: string | string[];
279
+ duration?: number;
280
+ props: FadeAlphaTickerProps;
281
+ priority?: UPDATE_PRIORITY;
282
+ };
283
+ /**
284
+ * @deprecated
285
+ */
286
+ type PixiVNJsonTickerMove = {
287
+ type: "move";
288
+ alias: string | string[];
289
+ duration?: number;
290
+ props: MoveTickerProps;
291
+ priority?: UPDATE_PRIORITY;
292
+ };
293
+ /**
294
+ * @deprecated
295
+ */
296
+ type PixiVNJsonTickerRotate = {
297
+ type: "rotate";
298
+ alias: string | string[];
299
+ duration?: number;
300
+ props: RotateTickerProps;
301
+ priority?: UPDATE_PRIORITY;
302
+ };
303
+ /**
304
+ * @deprecated
305
+ */
306
+ type PixiVNJsonTickerZoom = {
307
+ type: "zoom";
308
+ alias: string | string[];
309
+ duration?: number;
310
+ props: ZoomTickerProps;
311
+ priority?: UPDATE_PRIORITY;
312
+ };
313
+ /**
314
+ * @deprecated
315
+ */
316
+ type PixiVNJsonCanvasTicker = PixiVNJsonTickerFade | PixiVNJsonTickerMove | PixiVNJsonTickerRotate | PixiVNJsonTickerZoom;
317
+
318
+ type DissolveTransition = {
319
+ type: "dissolve";
320
+ props?: ShowWithDissolveTransitionProps;
321
+ priority?: UPDATE_PRIORITY;
322
+ };
323
+ type FadeTransition = {
324
+ type: "fade";
325
+ props?: ShowWithFadeTransitionProps;
326
+ priority?: UPDATE_PRIORITY;
327
+ };
328
+ type MoveInOutTransition = {
329
+ type: "movein" | "moveout";
330
+ props?: MoveInOutProps;
331
+ priority?: UPDATE_PRIORITY;
332
+ };
333
+ type ZoomInOutTransition = {
334
+ type: "zoomin" | "zoomout";
335
+ props?: ZoomInOutProps;
336
+ priority?: UPDATE_PRIORITY;
337
+ };
338
+ type PushInOutTransition = {
339
+ type: "pushin" | "pushout";
340
+ props?: PushInOutProps;
341
+ priority?: UPDATE_PRIORITY;
342
+ };
343
+ type PixiVNJsonMediaTransiotions = DissolveTransition | FadeTransition | MoveInOutTransition | ZoomInOutTransition | PushInOutTransition;
344
+
345
+ type PixiVNJsonCanvasImageVideoShow = {
346
+ type: "image" | "video";
347
+ operationType: "show";
348
+ alias: string;
349
+ /**
350
+ * The url of the image or video.
351
+ * If the url is not provided, the url will be set to the alias.
352
+ */
353
+ url?: string;
354
+ props?: ImageSpriteOptions;
355
+ transition?: PixiVNJsonMediaTransiotions;
356
+ };
357
+ type PixiVNJsonCanvasImageContainerShow = {
358
+ type: "imagecontainer";
359
+ operationType: "show";
360
+ alias: string;
361
+ urls: string[];
362
+ props?: ImageContainerOptions<ImageSprite>;
363
+ transition?: PixiVNJsonMediaTransiotions;
364
+ };
365
+ type PixiVNJsonImageEdit = {
366
+ type: "image";
367
+ operationType: "edit";
368
+ alias: string;
369
+ props?: Partial<ImageSpriteMemory>;
370
+ };
371
+ type PixiVNJsonVideoEdit = {
372
+ type: "video";
373
+ operationType: "edit";
374
+ alias: string;
375
+ props?: Partial<VideoSpriteMemory>;
376
+ };
377
+ type PixiVNJsonImageContainerEdit = {
378
+ type: "imagecontainer";
379
+ operationType: "edit";
380
+ alias: string;
381
+ props?: Partial<ImageContainerMemory>;
382
+ };
383
+ type PixiVNJsonUnknownEdit<T extends ContainerOptions> = {
384
+ type: "canvaselement";
385
+ operationType: "edit";
386
+ alias: string;
387
+ props?: Partial<T>;
388
+ };
389
+ type PixiVNJsonCanvasRemove = {
390
+ type: "image" | "video" | "imagecontainer" | "canvaselement";
391
+ operationType: "remove";
392
+ alias: string;
393
+ transition?: PixiVNJsonMediaTransiotions;
394
+ };
395
+ type PixiVNJsonVideoPauseResume = {
396
+ type: "video";
397
+ operationType: "pause" | "resume";
398
+ alias: string;
399
+ };
400
+ type PixiVNJsonAssetsLoad = {
401
+ type: "assets" | "bundle";
402
+ operationType: "load" | "lazyload";
403
+ aliases: string[];
404
+ };
405
+ type PixiVNJsonCanvasShow = PixiVNJsonCanvasImageContainerShow | PixiVNJsonCanvasImageVideoShow;
406
+ type PixiVNJsonCanvasEdit = PixiVNJsonImageEdit | PixiVNJsonVideoEdit | PixiVNJsonImageContainerEdit | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory>;
407
+ type PixiVNJsonCanvas = PixiVNJsonCanvasShow | PixiVNJsonCanvasEdit | PixiVNJsonCanvasRemove | PixiVNJsonVideoPauseResume | PixiVNJsonAssetsLoad | PixiVNJsonCanvasTicker | PixiVNJsonCanvasAnimate | PixiVNJsonCanvasEffect;
408
+
409
+ type PixiVNJsonInputRequest = {
410
+ type: "input";
411
+ operationType: "request";
412
+ valueType?: string;
413
+ defaultValue?: any;
414
+ };
415
+ type PixiVNJsonInput = PixiVNJsonInputRequest;
416
+
417
+ type PixiVNJsonSoundPlay = {
418
+ type: "sound";
419
+ operationType: "play";
420
+ alias: string;
421
+ props?: SoundPlayOptions;
422
+ };
423
+ type PixiVNJsonSoundRemove = {
424
+ type: "sound";
425
+ operationType: "stop";
426
+ alias: string;
427
+ };
428
+ type PixiVNJsonSoundPauseResume = {
429
+ type: "sound";
430
+ operationType: "pause" | "resume";
431
+ alias: string;
432
+ };
433
+ type PixiVNJsonSoundVolume = {
434
+ type: "sound";
435
+ operationType: "volume";
436
+ alias: string;
437
+ value: number;
438
+ };
439
+ type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundVolume;
440
+
441
+ type PixiVNJsonOperationString = {
442
+ type: "operationtoconvert";
443
+ values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
444
+ };
445
+ type PixiVNJsonOperation = PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonInput;
446
+ type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
447
+
448
+ type PixiVNJsonChoice = {
449
+ /**
450
+ * The text to be displayed.
451
+ */
452
+ text: PixiVNJsonDialogText;
453
+ /**
454
+ * The label id to be opened.
455
+ */
456
+ label: string;
457
+ /**
458
+ * Label opening mode
459
+ */
460
+ type: LabelRunModeType;
461
+ /**
462
+ * The properties to be passed to the label.
463
+ */
464
+ props: StorageObjectType;
465
+ /**
466
+ * If this is true, the choice can only be made once.
467
+ */
468
+ oneTime?: boolean;
469
+ /**
470
+ * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected.
471
+ */
472
+ onlyHaveNoChoice?: boolean;
473
+ /**
474
+ * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label.
475
+ */
476
+ autoSelect?: boolean;
477
+ };
478
+ type PixiVNJsonChoices = (PixiVNJsonChoice | PixiVNJsonConditionalStatements<PixiVNJsonChoice>)[];
479
+ type PixiVNJsonDialogText = string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]> | (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]>)[];
480
+ type PixiVNJsonDialog<Text = string> = {
481
+ /**
482
+ * The character id that will speak.
483
+ */
484
+ character: string;
485
+ /**
486
+ * The text to be displayed.
487
+ */
488
+ text: Text;
489
+ } | Text;
490
+ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
491
+ /**
492
+ * The id of the label to open.
493
+ */
494
+ label: string | PixiVNJsonValueGet;
495
+ /**
496
+ * Label opening mode
497
+ */
498
+ type: LabelRunModeType;
499
+ /**
500
+ * The properties to be passed to the label. if you don't want to pass a object, but a list of parameters, you can use the {@link PixiVNJsonLabelToOpen.params} attribute.
501
+ */
502
+ props?: StepLabelPropsType<T>;
503
+ /**
504
+ * **It is not recommended to use it, use it only if necessary**. The parameters to be passed to the label. If you want to pass an object, use the {@link PixiVNJsonLabelToOpen.props} attribute.
505
+ * "params" attribute will be stored in the temp storage with the key: {@link PIXIVNJSON_PARAM_ID} + ({@link narration.openedLabels.length} - 1).
506
+ */
507
+ params?: any[];
508
+ };
509
+ /**
510
+ * Steps of a label.
511
+ * Order of operations:
512
+ * 1. run all {@link PixiVNJsonLabelStep.operations}
513
+ * 2. set {@link PixiVNJsonLabelStep.choices}, {@link PixiVNJsonLabelStep.dialogue}, {@link PixiVNJsonLabelStep.glueEnabled}
514
+ * 3. open {@link PixiVNJsonLabelStep.labelToOpen}
515
+ * 4. go to next step if {@link PixiVNJsonLabelStep.goNextStep} is true
516
+ * 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
517
+ */
518
+ type PixiVNJsonLabelStep = {
519
+ operations?: PixiVNJsonConditionalOperation[];
520
+ /**
521
+ * Variable used to display a choice menu.
522
+ */
523
+ choices?: PixiVNJsonChoices | PixiVNJsonConditionalStatements<PixiVNJsonChoices>;
524
+ /**
525
+ * Variable used to display a dialog.
526
+ */
527
+ dialogue?: PixiVNJsonDialog<PixiVNJsonDialogText> | PixiVNJsonConditionalStatements<PixiVNJsonDialog<PixiVNJsonDialogText>>;
528
+ /**
529
+ * This variable is used to add the next dialog text into the current dialog memory.
530
+ * This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue
531
+ */
532
+ glueEnabled?: boolean | PixiVNJsonConditionalStatements<boolean>;
533
+ /**
534
+ * Variable used to open a label.
535
+ */
536
+ labelToOpen?: PixiVNJsonLabelToOpen | PixiVNJsonConditionalStatements<PixiVNJsonLabelToOpen> | (PixiVNJsonLabelToOpen | PixiVNJsonConditionalStatements<PixiVNJsonLabelToOpen>)[];
537
+ /**
538
+ * If is true, the next step will be executed automatically.
539
+ */
540
+ goNextStep?: boolean | PixiVNJsonConditionalStatements<boolean>;
541
+ /**
542
+ * Variable used to end some elements of the narrative.
543
+ * - game_end: ends the game
544
+ * - label_end: ends the label
545
+ */
546
+ end?: "game_end" | "label_end" | PixiVNJsonConditionalStatements<"game_end" | "label_end">;
547
+ conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
548
+ };
549
+
550
+ export type { PixiVNJsonLabelStep as P, PixiVNJsonConditionalOperation as a, PixiVNJsonOperation as b };
package/dist/importer.cjs CHANGED
@@ -1 +1,3 @@
1
- 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Y=Object.create;var z=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var ie=(s,e,i)=>e in s?z(s,e,{enumerable:true,configurable:true,writable:true,value:i}):s[e]=i;var B=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var $=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var te=(s,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!ee.call(s,n)&&n!==i&&z(s,n,{get:()=>e[n],enumerable:!(o=j(e,n))||o.enumerable});return s};var ne=(s,e,i)=>(i=s!=null?Y(Z(s)):{},te(z(i,"default",{value:s,enumerable:true}),s));var v=(s,e,i)=>ie(s,typeof e!="symbol"?e+"":e,i);var G=$((A,K)=>{(function(s,e){typeof A=="object"?K.exports=A=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(A,function(){var s=s||(function(e,i){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof B=="function")try{o=B("crypto");}catch{}var n=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),p={},c=p.lib={},h=c.Base=(function(){return {extend:function(t){var r=a(this);return t&&r.mixIn(t),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=c.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=i?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||g).stringify(this)},concat:function(t){var r=this.words,m=t.words,u=this.sigBytes,C=t.sigBytes;if(this.clamp(),u%4)for(var b=0;b<C;b++){var k=m[b>>>2]>>>24-b%4*8&255;r[u+b>>>2]|=k<<24-(u+b)%4*8;}else for(var E=0;E<C;E+=4)r[u+E>>>2]=m[E>>>2];return this.sigBytes+=C,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new y.init(r,t)}}),d=p.enc={},g=d.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push((b>>>4).toString(16)),u.push((b&15).toString(16));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u+=2)m[u>>>3]|=parseInt(t.substr(u,2),16)<<24-u%8*4;return new y.init(m,r/2)}},x=d.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push(String.fromCharCode(b));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u++)m[u>>>2]|=(t.charCodeAt(u)&255)<<24-u%4*8;return new y.init(m,r)}},S=d.Utf8={stringify:function(t){try{return decodeURIComponent(escape(x.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return x.parse(unescape(encodeURIComponent(t)))}},V=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=S.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,u=m.words,C=m.sigBytes,b=this.blockSize,k=b*4,E=C/k;t?E=e.ceil(E):E=e.max((E|0)-this._minBufferSize,0);var L=E*b,H=e.min(L*4,C);if(L){for(var D=0;D<L;D+=b)this._doProcessBlock(u,D);r=u.splice(0,L),m.sigBytes-=H;}return new y.init(r,H)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});c.Hasher=V.extend({cfg:h.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){V.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new P.HMAC.init(t,m).finalize(r)}}});var P=p.algo={};return p})(Math);return s});});var F=$((I,W)=>{(function(s,e){typeof I=="object"?W.exports=I=e(G()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(I,function(s){return (function(){var e=s,i=e.lib,o=i.WordArray,n=i.Hasher,a=e.algo,p=[],c=a.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,y){for(var d=this._hash.words,g=d[0],x=d[1],S=d[2],V=d[3],J=d[4],P=0;P<80;P++){if(P<16)p[P]=h[y+P]|0;else {var t=p[P-3]^p[P-8]^p[P-14]^p[P-16];p[P]=t<<1|t>>>31;}var r=(g<<5|g>>>27)+J+p[P];P<20?r+=(x&S|~x&V)+1518500249:P<40?r+=(x^S^V)+1859775393:P<60?r+=(x&S|x&V|S&V)-1894007588:r+=(x^S^V)-899497514,J=V,V=S,S=x<<30|x>>>2,x=g,g=r;}d[0]=d[0]+g|0,d[1]=d[1]+x|0,d[2]=d[2]+S|0,d[3]=d[3]+V|0,d[4]=d[4]+J|0;},_doFinalize:function(){var h=this._data,y=h.words,d=this._nDataBytes*8,g=h.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(d/4294967296),y[(g+64>>>9<<4)+15]=d,h.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(c),e.HmacSHA1=n._createHmacHelper(c);})(),s.SHA1});});var N;(n=>(n.log=(a,...p)=>console.log(`[Pixi\u2019VN Json] ${a}`,...p),n.warn=(a,...p)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...p),n.error=(a,...p)=>console.error(`[Pixi\u2019VN Json] ${a}`,...p),n.info=(a,...p)=>console.info(`[Pixi\u2019VN Json] ${a}`,...p)))(N||(N={}));var l=class{static init(e){this._loadAssets=e.loadAssets,this._soundOperation=e.soundOperation,this._imageOperation=e.imageOperation,this._videoOperation=e.videoOperation,this._imageContainerOperation=e.imageContainerOperation,this._canvasElementOperation=e.canvasElementOperation,this._setStorageValue=e.setStorageValue,this._inputOperation=e.inputOperation,this._tickerOperation=e.tickerOperation,this._effectOperation=e.effectOperation,this._animateOperation=e.animateOperation,this._getLogichValue=e.getLogichValue,this._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};v(l,"_loadAssets",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_soundOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_videoOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageContainerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_canvasElementOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_setStorageValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_inputOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_tickerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_effectOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_animateOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getLogichValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getConditionalStep",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")});async function _(s,e){let i=l.getLogichValue(s);if(i)switch(i.type){case "sound":l.soundOperation(i);break;case "assets":case "bundle":await l.loadAssets(i);break;case "image":await l.imageOperation(i);break;case "video":await l.videoOperation(i);break;case "imagecontainer":await l.imageContainerOperation(i);break;case "canvaselement":await l.canvasElementOperation(i);break;case "value":l.setStorageValue(i);break;case "operationtoconvert":if(e){let o="";i.values.forEach(a=>{if(typeof a=="string")o+=a;else {let p=l.getLogichValue(a);o+=`${p}`;}});let n=await e(o);n&&await _(n,e);}break;case "input":l.inputOperation(i);break;case "fade":case "move":case "rotate":case "zoom":l.tickerOperation(i);break;case "shake":await l.effectOperation(i);break;case "animate":case "animate-sequence":l.animateOperation(i);break}}async function re(s,e={}){let{operationStringConvert:i,skipEmptyDialogs:o}=e;if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {N.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=s.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(h){N.error("Error parsing imported Pixi'VN JSON",h),c={};}return c}),p=(await Promise.all(n)).map(async c=>{let h=[];if(c.initialOperations){c.initialOperations.forEach(d=>{let g=_(d,i?x=>i(x,{},{}):void 0);h.push(g);});let y={};[...storage.storage.storage.keys()].forEach((d,g)=>{y[d]=storage.storage.storage.get(d);}),storage.storage.startingStorage=y;}if(c.labels){let y=c.labels;for(let d in y)try{let g=y[d],x=new w(d,g,void 0,e);narration.RegisteredLabels.add(x);}catch(g){N.error(`Error creating JSON label ${d}`,g);}}return Promise.all(h)});await Promise.all(p);}var q=ne(F());var R="___param___";var f=class f{static t(e){return Array.isArray(e)?e.map(i=>f.translate(`${i}`)):f.translate(`${e}`)}static set beforeToTranslate(e){f._beforeToTranslate=e;}static set translate(e){f._translate=e;}static get translate(){return e=>{let i=e;return f._beforeToTranslate&&(i=f._beforeToTranslate(i)),i=f._translate(i),f._afterToTranslate&&(i=f._afterToTranslate(i)),i}}static set afterToTranslate(e){f._afterToTranslate=e;}static addKey(e,i,o){let n=o.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(a=>{e[a]===void 0&&(n==="empty_string"?e[a]="":n==="copy_key"&&(f._beforeToTranslate?e[a]=f._beforeToTranslate(a):e[a]=a));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f.getConditionalsThenElse(e.then,i),e.else&&f.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(o=>{f.getConditionalsThenElse(o,i);});else if(e.elements.type==="ifelse"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else f.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(o=>{f.getConditionalsThenElse(o,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},o={}){let{defaultValue:n="copy_key"}=o;return e.forEach(a=>{if(a.choices){let p=[];Array.isArray(a.choices)?p=[a.choices]:p=f.getConditionalsThenElse(a.choices),p.forEach(c=>c.forEach(h=>{if("type"in h){let y=[];h.type==="ifelse"||h.type==="stepswitch"?f.getConditionalsThenElse(h,y):y=[h],y.map(g=>f.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(x=>{Array.isArray(x)?x.forEach(S=>{typeof S=="string"?f.addKey(i,S,{defaultValue:n}):f.getConditionalsThenElse(S).forEach(V=>{Array.isArray(V)?V.forEach(J=>{typeof J=="string"&&f.addKey(i,J,{defaultValue:n});}):typeof V=="string"&&f.addKey(i,V,{defaultValue:n});});}):typeof x=="string"&&f.addKey(i,x,{defaultValue:n});});});}}));}if(a.dialogue){let p=[];Array.isArray(a.dialogue)?p=[a.dialogue]:p=f.getConditionalsThenElse(a.dialogue),p.forEach(c=>{if(typeof c=="string")f.addKey(i,c,{defaultValue:n});else if("text"in c){let h=f.getConditionalsThenElse(c.text);typeof h=="string"&&(h=[h]),h.forEach(y=>{typeof y=="string"?f.addKey(i,y,{defaultValue:n}):f.getConditionalsThenElse(y).forEach(g=>{typeof g=="string"?f.addKey(i,g,{defaultValue:n}):Array.isArray(g)&&g.forEach(x=>{typeof x=="string"?f.addKey(i,x,{defaultValue:n}):f.getConditionalsThenElse(x).forEach(S=>{typeof S=="string"&&f.addKey(i,S,{defaultValue:n});});});});});}});}a.conditionalStep&&f.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?f.generateJsonTranslation(c,i,o):f.generateJsonTranslation([c],i,o);});}),i}};v(f,"_beforeToTranslate"),v(f,"_translate",e=>e),v(f,"_afterToTranslate");var O=f;function ae(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw N.error("Error creating exportable element",s,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends narration.LabelAbstract{constructor(i,o,n,a={}){n||(n={}),n.onLoadingLabel=async()=>{for(let p of o){let c;if(typeof p=="function"?c=p():c=p,c=l.getConditionalStep(c),c.operations){let h=c.operations.map(y=>l.loadAssets(y));await Promise.all(h);}}};super(i,n);v(this,"_steps");v(this,"operationStringConvert");v(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||false;}get steps(){return this._steps.map(i=>this.stepConverter(i))}get stepCount(){return this._steps.length}getStepById(i){if(i<0||i>=this._steps.length)return;let o=this._steps[i];return this.stepConverter(o)}getStepSha(i){if(i<0||i>=this.steps.length)return;let o=this._steps[i];return (0, q.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let o="";if(Array.isArray(i)){let n=[];i.forEach(a=>{if(typeof a=="string")n.push(a);else if(a&&typeof a=="object"){let p=l.getLogichValue(a);p?(p&&!Array.isArray(p)&&typeof p=="object"&&(p=l.getLogichValue(p)||""),Array.isArray(p)?n=n.concat(p):n.push(`${p}`)):n.push(`${a}`);}}),o=n;}else {let n=l.getLogichValue(i)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(i){if(i==null)return;let o=l.getLogichValue(i);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:O.t(this.getDialogueText(o.text))}:O.t(this.getDialogueText(o))}getChoices(i){return l.getLogichValue(i)?.map(a=>l.getLogichValue(a)).filter(a=>a!==void 0)}stepConverter(i){return async o=>{let n=typeof i=="function"?i():i;n=ae(n),n=l.getConditionalStep(n);let a=this.operationStringConvert?V=>this.operationStringConvert(V,n,o):void 0,{operations:p=[]}=n;for(let V of p)await _(V,a);let{labelToOpen:c=[]}=n,h=this.getChoices(n.choices),y=l.getLogichValue(n.glueEnabled),d=this.getDialogue(n.dialogue),g=[];Array.isArray(c)||(c=[c]),c.forEach(V=>{let J=l.getLogichValue(V);J&&g.push(J);});let x=l.getLogichValue(n.goNextStep),S=l.getLogichValue(n.end);if(h){let V=h.map(J=>{let P="";if(Array.isArray(J.text)){let r=[];J.text.forEach(m=>{if(typeof m=="string")r.push(O.t(m));else if(m&&typeof m=="object"){let u=l.getLogichValue(m);u&&!Array.isArray(u)&&typeof u=="object"&&(u=l.getLogichValue(u)||""),u&&(Array.isArray(u)?r=r.concat(O.t(u)):r.push(O.t(u)));}}),P=r;}else typeof J.text=="string"&&(P=O.t(J.text));return {label:J.label,text:P,props:J.props,type:J.type,oneTime:J.oneTime,onlyHaveNoChoice:J.onlyHaveNoChoice,autoSelect:J.autoSelect}});narration.narration.choiceMenuOptions=V;}else narration.narration.choiceMenuOptions=void 0;d!==void 0&&(narration.narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(x=true)),y?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):y===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let V of g){let J=V.label;typeof J=="object"&&(J=l.getLogichValue(J)||"");let P=V.params?.map(t=>l.getLogichValue(t));o={...o,...V.props},V.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${R}${narration.narration.openedLabels.length}`,P),await narration.narration.callLabel(J,o)):(storage.storage.setTempVariable(`${R}${narration.narration.openedLabels.length}`,P),await narration.narration.callLabel(J,o));}S==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(o,{runNow:true})):S==="label_end"&&narration.narration.closeCurrentLabel(),x&&await narration.narration.goNext(o,{runNow:true});}}};exports.LabelJson=w;exports.importPixiVNJson=re;
1
+ 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var ae=Object.create;var W=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var fe=(i,e,t)=>e in i?W(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var X=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Q=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ue=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!pe.call(i,o)&&o!==t&&W(i,o,{get:()=>e[o],enumerable:!(r=se(e,o))||r.enumerable});return i};var de=(i,e,t)=>(t=i!=null?ae(ce(i)):{},ue(W(t,"default",{value:i,enumerable:true}),i));var S=(i,e,t)=>fe(i,typeof e!="symbol"?e+"":e,t);var te=Q((H,ee)=>{(function(i,e){typeof H=="object"?ee.exports=H=e():typeof define=="function"&&define.amd?define([],e):i.CryptoJS=e();})(H,function(){var i=i||(function(e,t){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof X=="function")try{r=X("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||(function(){function n(){}return function(a){var p;return n.prototype=a,p=new n,n.prototype=null,p}})(),l={},c=l.lib={},u=c.Base=(function(){return {extend:function(n){var a=s(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),x=c.WordArray=u.extend({init:function(n,a){n=this.words=n||[],a!=t?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||V).stringify(this)},concat:function(n){var a=this.words,p=n.words,h=this.sigBytes,C=n.sigBytes;if(this.clamp(),h%4)for(var E=0;E<C;E++){var M=p[E>>>2]>>>24-E%4*8&255;a[h+E>>>2]|=M<<24-(h+E)%4*8;}else for(var L=0;L<C;L+=4)a[h+L>>>2]=p[L>>>2];return this.sigBytes+=C,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=e.ceil(a/4);},clone:function(){var n=u.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],p=0;p<n;p+=4)a.push(o());return new x.init(a,n)}}),d=l.enc={},V=d.Hex={stringify:function(n){for(var a=n.words,p=n.sigBytes,h=[],C=0;C<p;C++){var E=a[C>>>2]>>>24-C%4*8&255;h.push((E>>>4).toString(16)),h.push((E&15).toString(16));}return h.join("")},parse:function(n){for(var a=n.length,p=[],h=0;h<a;h+=2)p[h>>>3]|=parseInt(n.substr(h,2),16)<<24-h%8*4;return new x.init(p,a/2)}},y=d.Latin1={stringify:function(n){for(var a=n.words,p=n.sigBytes,h=[],C=0;C<p;C++){var E=a[C>>>2]>>>24-C%4*8&255;h.push(String.fromCharCode(E));}return h.join("")},parse:function(n){for(var a=n.length,p=[],h=0;h<a;h++)p[h>>>2]|=(n.charCodeAt(h)&255)<<24-h%4*8;return new x.init(p,a)}},v=d.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},N=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new x.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=v.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,p=this._data,h=p.words,C=p.sigBytes,E=this.blockSize,M=E*4,L=C/M;n?L=e.ceil(L):L=e.max((L|0)-this._minBufferSize,0);var B=L*E,U=e.min(B*4,C);if(B){for(var K=0;K<B;K+=E)this._doProcessBlock(h,K);a=h.splice(0,B),p.sigBytes-=U;}return new x.init(a,U)},clone:function(){var n=u.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});c.Hasher=N.extend({cfg:u.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){N.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,p){return new n.init(p).finalize(a)}},_createHmacHelper:function(n){return function(a,p){return new b.HMAC.init(n,p).finalize(a)}}});var b=l.algo={};return l})(Math);return i});});var ne=Q(($,ie)=>{(function(i,e){typeof $=="object"?ie.exports=$=e(te()):typeof define=="function"&&define.amd?define(["./core"],e):e(i.CryptoJS);})($,function(i){return (function(){var e=i,t=e.lib,r=t.WordArray,o=t.Hasher,s=e.algo,l=[],c=s.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,x){for(var d=this._hash.words,V=d[0],y=d[1],v=d[2],N=d[3],T=d[4],b=0;b<80;b++){if(b<16)l[b]=u[x+b]|0;else {var n=l[b-3]^l[b-8]^l[b-14]^l[b-16];l[b]=n<<1|n>>>31;}var a=(V<<5|V>>>27)+T+l[b];b<20?a+=(y&v|~y&N)+1518500249:b<40?a+=(y^v^N)+1859775393:b<60?a+=(y&v|y&N|v&N)-1894007588:a+=(y^v^N)-899497514,T=N,N=v,v=y<<30|y>>>2,y=V,V=a;}d[0]=d[0]+V|0,d[1]=d[1]+y|0,d[2]=d[2]+v|0,d[3]=d[3]+N|0,d[4]=d[4]+T|0;},_doFinalize:function(){var u=this._data,x=u.words,d=this._nDataBytes*8,V=u.sigBytes*8;return x[V>>>5]|=128<<24-V%32,x[(V+64>>>9<<4)+14]=Math.floor(d/4294967296),x[(V+64>>>9<<4)+15]=d,u.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var u=o.clone.call(this);return u._hash=this._hash.clone(),u}});e.SHA1=o._createHelper(c),e.HmacSHA1=o._createHmacHelper(c);})(),i.SHA1});});var J;(o=>(o.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),o.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),o.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),o.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(J||(J={}));var f=class f{static t(e){return Array.isArray(e)?e.map(t=>f.translate(`${t}`)):f.translate(`${e}`)}static set beforeToTranslate(e){f._beforeToTranslate=e;}static set translate(e){f._translate=e;}static get translate(){return e=>{let t=e;return f._beforeToTranslate&&(t=f._beforeToTranslate(t)),t=f._translate(t),f._afterToTranslate&&(t=f._afterToTranslate(t)),t}}static set afterToTranslate(e){f._afterToTranslate=e;}static addKey(e,t,r){let o=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{e[s]===void 0&&(o==="empty_string"?e[s]="":o==="copy_key"&&(f._beforeToTranslate?e[s]=f._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f.getConditionalsThenElse(e.then,t),e.else&&f.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(r=>{f.getConditionalsThenElse(r,t);});else if(e.elements.type==="ifelse"){let r=[];f.getConditionalsThenElse(e.elements,r),r.forEach(o=>{t.push(...o);});}else if(e.elements.type==="stepswitch"){let r=[];f.getConditionalsThenElse(e.elements,r),r.forEach(o=>{t.push(...o);});}else f.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&f.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(r=>{f.getConditionalsThenElse(r,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},r={}){let{defaultValue:o="copy_key"}=r;return e.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=f.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let x=[];u.type==="ifelse"||u.type==="stepswitch"?f.getConditionalsThenElse(u,x):x=[u],x.map(V=>f.getConditionalsThenElse(V.text)).forEach(V=>{Array.isArray(V)&&V.forEach(y=>{Array.isArray(y)?y.forEach(v=>{typeof v=="string"?f.addKey(t,v,{defaultValue:o}):f.getConditionalsThenElse(v).forEach(N=>{Array.isArray(N)?N.forEach(T=>{typeof T=="string"&&f.addKey(t,T,{defaultValue:o});}):typeof N=="string"&&f.addKey(t,N,{defaultValue:o});});}):typeof y=="string"&&f.addKey(t,y,{defaultValue:o});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=f.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")f.addKey(t,c,{defaultValue:o});else if("text"in c){let u=f.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(x=>{typeof x=="string"?f.addKey(t,x,{defaultValue:o}):f.getConditionalsThenElse(x).forEach(V=>{typeof V=="string"?f.addKey(t,V,{defaultValue:o}):Array.isArray(V)&&V.forEach(y=>{typeof y=="string"?f.addKey(t,y,{defaultValue:o}):f.getConditionalsThenElse(y).forEach(v=>{typeof v=="string"&&f.addKey(t,v,{defaultValue:o});});});});});}});}s.conditionalStep&&f.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?f.generateJsonTranslation(c,t,r):f.generateJsonTranslation([c],t,r);});}),t}};S(f,"_beforeToTranslate"),S(f,"_translate",e=>e),S(f,"_afterToTranslate");var D=f;var w=D;var _="___param___";function G(i){try{if(typeof i>"u")return i;let e=JSON.stringify(i);return JSON.parse(e)}catch(e){throw J.error("Error creating exportable element",i,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Z(i){let e=P(i.value),t;switch(e&&typeof e=="object"&&"type"in e?t=P(e):t=e,i.storageType){case "flagStorage":storage.storage.setFlag(i.key,i.value);break;case "storage":storage.storage.setVariable(i.key,t);break;case "tempstorage":storage.storage.setTempVariable(i.key,t);break;case "params":let r=storage.storage.getVariable(`${_}${narration.narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=t),storage.storage.setTempVariable(`${_}${narration.narration.openedLabels.length-1}`,r);break}}function P(i){let e=ye(i);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return he(e);case "arithmetic":case "arithmeticsingle":return ge(e);case "compare":case "valueCondition":case "union":return xe(e)}return e}function ge(i){let e=P(i.leftValue);switch(i.type){case "arithmetic":let t=P(i.rightValue);switch(i.operator){case "*":return e*t;case "/":return e/t;case "+":return e+t;case "-":return e-t;case "%":return e%t;case "POW":return Math.pow(e,t);case "RANDOM":return narration.narration.getRandomNumber(e,t)}case "arithmeticsingle":switch(i.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function he(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(i.key);case "flagStorage":return storage.storage.getFlag(i.key);case "label":return narration.narration.getTimesLabelOpened(i.label);case "choice":return narration.narration.getTimesChoiceMade(i.index);case "logic":return P(i.operation);case "params":let e=storage.storage.getVariable(`${_}${narration.narration.openedLabels.length-1}`)||[];if(e&&e.length>i.key)return e[i.key];J.warn("getValue params not found");return}return i}function xe(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let e=P(i.leftValue),t=P(i.rightValue);switch(i.operator){case "==":return e===t;case "!=":return e!==t;case "<":return e<t;case "<=":return e<=t;case ">":return e>t;case ">=":return e>=t;case "CONTAINS":return e.toString().includes(t.toString())}break;case "valueCondition":return !!P(i.value);case "union":return me(i)}return !!i}function me(i){if(i.unionType==="not")return !P(i.condition);let e=i.unionType==="and";for(let t=0;t<i.conditions.length;t++)if(e=P(i.conditions[t])||false,i.unionType==="and"){if(!e)return false}else if(e)return true;return e}function Ve(i,e){return Math.floor(Math.random()*(e-i+1)+i)}function ye(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return Pe(i);case "ifelse":return P(i.condition)?P(i.then):P(i.else);case "stepswitch":let t=P(i.elements)||[];if(t.length===0){J.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let r=Ve(0,t.length-1);return P(t[r]);case "loop":let o=narration.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return o>t.length-1&&(o=o%t.length),P(t[o]);case "sequential":let s,l=narration.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(s=P(t[t.length-1])),l>t.length-1?s:P(t[l]);case "sequentialrandom":let c=narration.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:i.nestedId,onceOnly:true});if(c==null&&i.end=="lastItem"){let u=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!u||!u?.usedRandomNumbers){J.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=u.usedRandomNumbers[`0-${t.length-1}`];return P(t[x[x.length-1]])}if(c==null){J.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return P(t[c])}}return i}function z(i){if(i.conditionalStep){let e=G(P(i.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let t={...i,conditionalStep:void 0,...e};return z(t)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function Pe(i){let e=i.firstItem,t=[];i.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let l=P(s);t.push(l);});else {let s=P(o);t.push(s);}});let r=e?[e,...t]:t;if(r.length===0){J.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return w.t(r);if(typeof r[0]=="object"){let o=r,s,l=o.map((n,a)=>{n=z(n);let p=P(n.dialogue)||"";return a===0?(s=P(n.glueEnabled)||false,p):(typeof p=="object"&&"text"in p&&(p=p.character+": "+p.text),s===false&&(p=`
2
+
3
+ `+p),s=P(n.glueEnabled)||false,p)}),c=P(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,x=l.flatMap(n=>{let a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let p;return Array.isArray(a)?p=a.map(h=>{let C=P(h);return w.t(`${C}`)}):p=P(a)||"",w.t(p)}),d=o.find(n=>n.end),V=o.find(n=>n.choices),y=false,v=false;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),y=o[o.length-1].glueEnabled,v=o.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let N=o.find(n=>n.labelToOpen),T=[];return o.forEach(n=>{n.operations&&T.forEach(a=>{T.push(a);});}),{dialogue:u?{character:u,text:x}:x,end:d?.end,choices:V?.choices,glueEnabled:y,goNextStep:v,labelToOpen:N?.labelToOpen,operations:T}}}var g=class g{static init(e){g._loadAssets=e.loadAssets,g._soundOperation=e.soundOperation,g._imageOperation=e.imageOperation,g._videoOperation=e.videoOperation,g._imageContainerOperation=e.imageContainerOperation,g._canvasElementOperation=e.canvasElementOperation,g._setStorageValue=e.setStorageValue,g._inputOperation=e.inputOperation,g._tickerOperation=e.tickerOperation,g._effectOperation=e.effectOperation,g._animateOperation=e.animateOperation,g._getLogichValue=e.getLogichValue,g._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return g._loadAssets}static get soundOperation(){return g._soundOperation}static get imageOperation(){return g._imageOperation}static get videoOperation(){return g._videoOperation}static get imageContainerOperation(){return g._imageContainerOperation}static get canvasElementOperation(){return g._canvasElementOperation}static get setStorageValue(){return g._setStorageValue}static get inputOperation(){return g._inputOperation}static get tickerOperation(){return g._tickerOperation}static get effectOperation(){return g._effectOperation}static get animateOperation(){return g._animateOperation}static get getLogichValue(){return g._getLogichValue}static get getConditionalStep(){return g._getConditionalStep}};S(g,"_loadAssets",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_soundOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_imageOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_videoOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_imageContainerOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_canvasElementOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_setStorageValue",Z),S(g,"_inputOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_tickerOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_effectOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_animateOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_getLogichValue",P),S(g,"_getConditionalStep",z);var m=g;async function R(i,e){let t=m.getLogichValue(i);if(t)switch(t.type){case "sound":m.soundOperation(t);break;case "assets":case "bundle":await m.loadAssets(t);break;case "image":await m.imageOperation(t);break;case "video":await m.videoOperation(t);break;case "imagecontainer":await m.imageContainerOperation(t);break;case "canvaselement":await m.canvasElementOperation(t);break;case "value":m.setStorageValue(t);break;case "operationtoconvert":if(e){let r="";t.values.forEach(s=>{if(typeof s=="string")r+=s;else {let l=m.getLogichValue(s);r+=`${l}`;}});let o=await e(r);o&&await R(o,e);}break;case "input":m.inputOperation(t);break;case "fade":case "move":case "rotate":case "zoom":m.tickerOperation(t);break;case "shake":await m.effectOperation(t);break;case "animate":case "animate-sequence":m.animateOperation(t);break}}async function Te(i,e={}){let{operationStringConvert:t,skipEmptyDialogs:r}=e;if(!Array.isArray(i))if(typeof i=="object"||typeof i=="string")i=[i];else {J.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=i.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(u){J.error("Error parsing imported Pixi'VN JSON",u),c={};}return c}),l=(await Promise.all(o)).map(async c=>{let u=[];if(c.initialOperations){c.initialOperations.forEach(d=>{let V=R(d,t?y=>t(y,{},{}):void 0);u.push(V);});let x={};[...storage.storage.storage.keys()].forEach((d,V)=>{x[d]=storage.storage.storage.get(d);}),storage.storage.startingStorage=x;}if(c.labels){let x=c.labels;for(let d in x)try{let V=x[d],y=new k(d,V,void 0,e);narration.RegisteredLabels.add(y);}catch(V){J.error(`Error creating JSON label ${d}`,V);}}return Promise.all(u)});await Promise.all(l);}var re=de(ne());var k=class extends narration.LabelAbstract{constructor(t,r,o,s={}){o||(o={}),o.onLoadingLabel=async()=>{for(let l of r){let c;if(typeof l=="function"?c=l():c=l,c=m.getConditionalStep(c),c.operations){let u=c.operations.map(x=>m.loadAssets(x));await Promise.all(u);}}};super(t,o);S(this,"_steps");S(this,"operationStringConvert");S(this,"skipEmptyDialogs",false);this._steps=r,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let r=this._steps[t];return this.stepConverter(r)}getStepSha(t){if(t<0||t>=this.steps.length)return;let r=this._steps[t];return (0, re.default)(r.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let r="";if(Array.isArray(t)){let o=[];t.forEach(s=>{if(typeof s=="string")o.push(s);else if(s&&typeof s=="object"){let l=m.getLogichValue(s);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=m.getLogichValue(l)||""),Array.isArray(l)?o=o.concat(l):o.push(`${l}`)):o.push(`${s}`);}}),r=o;}else {let o=m.getLogichValue(t)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=m.getLogichValue(o)||""),r=o;}return `${r}`}getDialogue(t){if(t==null)return;let r=m.getLogichValue(t);return r==null?"":typeof r=="object"&&"character"in r&&"text"in r?{character:r.character,text:w.t(this.getDialogueText(r.text))}:w.t(this.getDialogueText(r))}getChoices(t){return m.getLogichValue(t)?.map(s=>m.getLogichValue(s)).filter(s=>s!==void 0)}stepConverter(t){return async r=>{let o=typeof t=="function"?t():t;o=G(o),o=m.getConditionalStep(o);let s=this.operationStringConvert?N=>this.operationStringConvert(N,o,r):void 0,{operations:l=[]}=o;for(let N of l)await R(N,s);let{labelToOpen:c=[]}=o,u=this.getChoices(o.choices),x=m.getLogichValue(o.glueEnabled),d=this.getDialogue(o.dialogue),V=[];Array.isArray(c)||(c=[c]),c.forEach(N=>{let T=m.getLogichValue(N);T&&V.push(T);});let y=m.getLogichValue(o.goNextStep),v=m.getLogichValue(o.end);if(u){let N=u.map(T=>{let b="";if(Array.isArray(T.text)){let a=[];T.text.forEach(p=>{if(typeof p=="string")a.push(w.t(p));else if(p&&typeof p=="object"){let h=m.getLogichValue(p);h&&!Array.isArray(h)&&typeof h=="object"&&(h=m.getLogichValue(h)||""),h&&(Array.isArray(h)?a=a.concat(w.t(h)):a.push(w.t(h)));}}),b=a;}else typeof T.text=="string"&&(b=w.t(T.text));return {label:T.label,text:b,props:T.props,type:T.type,oneTime:T.oneTime,onlyHaveNoChoice:T.onlyHaveNoChoice,autoSelect:T.autoSelect}});narration.narration.choiceMenuOptions=N;}else narration.narration.choiceMenuOptions=void 0;d!==void 0&&(narration.narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(y=true)),x?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):x===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let N of V){let T=N.label;typeof T=="object"&&(T=m.getLogichValue(T)||"");let b=N.params?.map(n=>m.getLogichValue(n));r={...r,...N.props},N.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${_}${narration.narration.openedLabels.length}`,b),await narration.narration.callLabel(T,r)):(storage.storage.setTempVariable(`${_}${narration.narration.openedLabels.length}`,b),await narration.narration.callLabel(T,r));}v==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(r,{runNow:true})):v==="label_end"&&narration.narration.closeCurrentLabel(),y&&await narration.narration.goNext(r,{runNow:true});}}};exports.LabelJson=k;exports.importPixiVNJson=Te;