adofai 2.11.1 → 2.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,112 +1,112 @@
1
- # ADOFAI
2
-
3
- A Javascript library for ADOFAI levels.
4
-
5
- ## Usage
6
- Preview / Edit the `.adofai` file.
7
-
8
- Re_ADOJAS(A Level Player of ADOFAI) uses `adofai` to parse ADOFAI Level file.
9
-
10
- ## Installation
11
-
12
- ```bash
13
- npm install adofai
14
- # or
15
- yarn add adofai
16
- # or
17
- pnpm install adofai
18
- ```
19
-
20
- if you want to display highlight of adofai file, you can use `Rhythm Game Syntax Highlighter` vscode extension.
21
-
22
- ## Got Started
23
-
24
- ### Import
25
-
26
- For Commonjs:
27
- ```ts
28
- const adofai = require('adofai');
29
- ```
30
-
31
- For ES6 Modules:
32
- ```ts
33
- import * as adofai from 'adofai';
34
- ```
35
-
36
- ### Create a Level
37
-
38
- ```ts
39
- const file = new adofai.Level(adofaiFileContent);
40
-
41
- //or
42
-
43
- const parser = new adofai.Parsers.StringParser();
44
- const file = new adofai.Level(adofaiFileContent,parser);
45
-
46
- //The advantage of the latter over the former is that it pre-initializes the Parser, avoiding multiple instantiations.
47
- ```
48
-
49
- Format:
50
- ```ts
51
- class Level {
52
- constructor(opt: string | LevelOptions, provider?: ParseProvider)
53
- }
54
-
55
- ```
56
- Available ParseProviders:
57
- `StringParser` `ArrayBufferParser` `BufferParser`
58
-
59
-
60
- Usually,only `StringParser` is needed.
61
- but you can use `BufferParser` to parse ADOFAI files in Node environment.
62
-
63
- On browser, you can also use `ArrayBuffer` to parse ADOFAI files.
64
- (`BufferParser` is not available in browser,but you can use browserify `Buffer` to polyfill)
65
-
66
- ### Load Level
67
- ```ts
68
- file.on('load'() => {
69
- //logic...
70
- })
71
- file.load()
72
- ```
73
-
74
- or you can use `then()`
75
- ```ts
76
- file.load().then(() => {
77
-
78
- })
79
- ```
80
-
81
- ### Export Level
82
- ```ts
83
- type FileType = 'string'|'object'
84
-
85
- file.export(type: FileType = 'string',indent?:number,useAdofaiStyle:boolean = true)
86
- ```
87
-
88
- method `export()` returns a Object or String.
89
-
90
- Object: return ADOFAI Object.
91
- String: return ADOFAI String.
92
-
93
- ```ts
94
- import fs from 'fs'
95
- type FileType = 'string'|'object'
96
-
97
- const content = file.export('string',null,true);
98
- fs.writeFileSync('output.adofai',content)
99
- ```
100
-
101
-
102
- ## Data Operation
103
-
104
- See interfaces to see all data.
105
-
106
- ```ts
107
- //Get AngleDatas:
108
- const angleDatas = file.angleData;
109
-
110
-
111
-
1
+ # ADOFAI
2
+
3
+ A Javascript library for ADOFAI levels.
4
+
5
+ ## Usage
6
+ Preview / Edit the `.adofai` file.
7
+
8
+ Re_ADOJAS(A Level Player of ADOFAI) uses `adofai` to parse ADOFAI Level file.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install adofai
14
+ # or
15
+ yarn add adofai
16
+ # or
17
+ pnpm install adofai
18
+ ```
19
+
20
+ if you want to display highlight of adofai file, you can use `Rhythm Game Syntax Highlighter` vscode extension.
21
+
22
+ ## Got Started
23
+
24
+ ### Import
25
+
26
+ For Commonjs:
27
+ ```ts
28
+ const adofai = require('adofai');
29
+ ```
30
+
31
+ For ES6 Modules:
32
+ ```ts
33
+ import * as adofai from 'adofai';
34
+ ```
35
+
36
+ ### Create a Level
37
+
38
+ ```ts
39
+ const file = new adofai.Level(adofaiFileContent);
40
+
41
+ //or
42
+
43
+ const parser = new adofai.Parsers.StringParser();
44
+ const file = new adofai.Level(adofaiFileContent,parser);
45
+
46
+ //The advantage of the latter over the former is that it pre-initializes the Parser, avoiding multiple instantiations.
47
+ ```
48
+
49
+ Format:
50
+ ```ts
51
+ class Level {
52
+ constructor(opt: string | LevelOptions, provider?: ParseProvider)
53
+ }
54
+
55
+ ```
56
+ Available ParseProviders:
57
+ `StringParser` `ArrayBufferParser` `BufferParser`
58
+
59
+
60
+ Usually,only `StringParser` is needed.
61
+ but you can use `BufferParser` to parse ADOFAI files in Node environment.
62
+
63
+ On browser, you can also use `ArrayBuffer` to parse ADOFAI files.
64
+ (`BufferParser` is not available in browser,but you can use browserify `Buffer` to polyfill)
65
+
66
+ ### Load Level
67
+ ```ts
68
+ file.on('load'() => {
69
+ //logic...
70
+ })
71
+ file.load()
72
+ ```
73
+
74
+ or you can use `then()`
75
+ ```ts
76
+ file.load().then(() => {
77
+
78
+ })
79
+ ```
80
+
81
+ ### Export Level
82
+ ```ts
83
+ type FileType = 'string'|'object'
84
+
85
+ file.export(type: FileType = 'string',indent?:number,useAdofaiStyle:boolean = true)
86
+ ```
87
+
88
+ method `export()` returns a Object or String.
89
+
90
+ Object: return ADOFAI Object.
91
+ String: return ADOFAI String.
92
+
93
+ ```ts
94
+ import fs from 'fs'
95
+ type FileType = 'string'|'object'
96
+
97
+ const content = file.export('string',null,true);
98
+ fs.writeFileSync('output.adofai',content)
99
+ ```
100
+
101
+
102
+ ## Data Operation
103
+
104
+ See interfaces to see all data.
105
+
106
+ ```ts
107
+ //Get AngleDatas:
108
+ const angleDatas = file.angleData;
109
+
110
+
111
+
112
112
  ```
@@ -0,0 +1,32 @@
1
+ interface Tile {
2
+ addDecorations?: any[];
3
+ actions?: Action[];
4
+ [key: string]: any;
5
+ }
6
+ interface Action {
7
+ eventType: string;
8
+ [key: string]: any;
9
+ }
10
+ /**
11
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
12
+ * @returns {Array} new Tiles
13
+ */
14
+ declare function clearDecorations(tiles: Tile[]): Tile[];
15
+ /**
16
+ * @param {Array} eventTypes Eventlist to remove
17
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
18
+ * @returns {Array} new Tiles
19
+ */
20
+ declare function clearEvents(eventTypes: string[], tiles: Tile[]): Tile[];
21
+ /**
22
+ * @param {Array} eventTypes Eventlist to keep
23
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
24
+ * @returns {Array} new Tiles
25
+ */
26
+ declare function keepEvents(eventTypes: string[], tiles: Tile[]): Tile[];
27
+ declare const effectProcessor: {
28
+ clearDecorations: typeof clearDecorations;
29
+ clearEvents: typeof clearEvents;
30
+ keepEvents: typeof keepEvents;
31
+ };
32
+ export default effectProcessor;
@@ -0,0 +1,54 @@
1
+ import * as presets from './presets';
2
+ /**
3
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
4
+ * @returns {Array} new Tiles
5
+ */
6
+ function clearDecorations(tiles) {
7
+ if (!Array.isArray(tiles)) {
8
+ throw new Error('Arguments are not supported.');
9
+ }
10
+ return tiles.map(tile => {
11
+ const newTile = Object.assign({}, tile);
12
+ if (newTile.hasOwnProperty('addDecorations')) {
13
+ newTile.addDecorations = [];
14
+ }
15
+ if (Array.isArray(newTile.actions)) {
16
+ newTile.actions = newTile.actions.filter(action => !presets.preset_inner_no_deco.events.includes(action.eventType));
17
+ }
18
+ return newTile;
19
+ });
20
+ }
21
+ /**
22
+ * @param {Array} eventTypes Eventlist to remove
23
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
24
+ * @returns {Array} new Tiles
25
+ */
26
+ function clearEvents(eventTypes, tiles) {
27
+ return tiles.map(tile => {
28
+ const newTile = Object.assign({}, tile);
29
+ if (Array.isArray(newTile.actions)) {
30
+ newTile.actions = newTile.actions.filter(action => !eventTypes.includes(action.eventType));
31
+ }
32
+ return newTile;
33
+ });
34
+ }
35
+ /**
36
+ * @param {Array} eventTypes Eventlist to keep
37
+ * @param {Array} tiles ADOFAI Tiles from ADOFAI.Level
38
+ * @returns {Array} new Tiles
39
+ */
40
+ function keepEvents(eventTypes, tiles) {
41
+ return tiles.map(tile => {
42
+ const newTile = Object.assign({}, tile);
43
+ if (Array.isArray(newTile.actions)) {
44
+ newTile.actions = newTile.actions.filter(action => eventTypes.includes(action.eventType));
45
+ }
46
+ return newTile;
47
+ });
48
+ }
49
+ const effectProcessor = {
50
+ clearDecorations,
51
+ clearEvents,
52
+ keepEvents
53
+ };
54
+ export default effectProcessor;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {object} obj - JSON Object
3
+ * @param {number} indent - No usage
4
+ * @param {boolean} isRoot - Is JSON the Root?
5
+ * @returns ADOFAI File Content or Object
6
+ */
7
+ declare function exportAsADOFAI(obj: any, indent?: number, isRoot?: boolean): string;
8
+ export default exportAsADOFAI;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @param {object} obj - JSON Object
3
+ * @param {number} indent - No usage
4
+ * @param {boolean} isRoot - Is JSON the Root?
5
+ * @returns ADOFAI File Content or Object
6
+ */
7
+ function exportAsADOFAI(obj, indent = 0, isRoot = false) {
8
+ if (typeof obj !== 'object' || obj === null) {
9
+ return JSON.stringify(obj);
10
+ }
11
+ if (Array.isArray(obj)) {
12
+ const allPrimitives = obj.every(item => typeof item !== 'object' || item === null);
13
+ if (allPrimitives) {
14
+ return '[' + obj.map(item => exportAsADOFAI(item)).join(',') + ']';
15
+ }
16
+ const spaces = ' '.repeat(indent);
17
+ const arrayItems = obj.map(item => spaces + ' ' + formatAsSingleLine(item)).join(',\n');
18
+ return '[\n' + arrayItems + '\n' + spaces + ']';
19
+ }
20
+ const spaces = ' '.repeat(indent);
21
+ const keys = Object.keys(obj);
22
+ if (isRoot) {
23
+ const objectItems = keys.map(key => ' ' + JSON.stringify(key) + ': ' + exportAsADOFAI(obj[key], 2)).join(',\n');
24
+ return '{\n' + objectItems + '\n}';
25
+ }
26
+ const objectItems = keys.map(key => spaces + ' ' + JSON.stringify(key) + ': ' + exportAsADOFAI(obj[key], indent + 2)).join(',\n');
27
+ return '{\n' + objectItems + '\n' + spaces + '}';
28
+ }
29
+ /**
30
+ * @param {Array} obj Eventlist to keep
31
+ * @returns {string} JSON formated as singleline
32
+ */
33
+ function formatAsSingleLine(obj) {
34
+ if (typeof obj !== 'object' || obj === null) {
35
+ return exportAsADOFAI(obj);
36
+ }
37
+ if (Array.isArray(obj)) {
38
+ return '[' + obj.map(formatAsSingleLine).join(',') + ']';
39
+ }
40
+ const keys = Object.keys(obj);
41
+ const entries = keys.map(key => JSON.stringify(key) + ': ' + formatAsSingleLine(obj[key])).join(', ');
42
+ return '{' + entries + '}';
43
+ }
44
+ export default exportAsADOFAI;
@@ -0,0 +1,9 @@
1
+ import Parser from "./Parser";
2
+ export declare class ArrayBufferParser extends Parser<ArrayBuffer | string, any> {
3
+ parse(input: ArrayBuffer | string): any;
4
+ stringify(obj: any): string;
5
+ }
6
+ export declare function stripBOM(buffer: ArrayBuffer): ArrayBuffer;
7
+ export declare function normalizeJsonArrayBuffer(buffer: ArrayBuffer): ArrayBuffer;
8
+ export declare function decodeStringFromUTF8BOM(buffer: ArrayBuffer): string;
9
+ export default ArrayBufferParser;
@@ -0,0 +1,98 @@
1
+ import Parser from "./Parser";
2
+ import StringParser from "./StringParser";
3
+ const BOM = new Uint8Array([0xef, 0xbb, 0xbf]);
4
+ const COMMA = new Uint8Array([44]); // ASCII for ','
5
+ export class ArrayBufferParser extends Parser {
6
+ parse(input) {
7
+ if (typeof input === "string") {
8
+ return StringParser.prototype.parse.call(StringParser.prototype, input);
9
+ }
10
+ else {
11
+ return StringParser.prototype.parse.call(StringParser.prototype, decodeStringFromUTF8BOM(normalizeJsonArrayBuffer(stripBOM(input))));
12
+ }
13
+ }
14
+ stringify(obj) {
15
+ return JSON.stringify(obj);
16
+ }
17
+ }
18
+ export function stripBOM(buffer) {
19
+ const view = new Uint8Array(buffer);
20
+ if (view.length >= 3 && view[0] === BOM[0] && view[1] === BOM[1] && view[2] === BOM[2]) {
21
+ return buffer.slice(3);
22
+ }
23
+ return buffer;
24
+ }
25
+ export function normalizeJsonArrayBuffer(buffer) {
26
+ const view = new Uint8Array(buffer);
27
+ let builder = [];
28
+ let last = "other";
29
+ let from = 0;
30
+ for (let i = 0; i < view.length; i++) {
31
+ const charCode = view[i];
32
+ if (last == "escape") {
33
+ last = "string";
34
+ }
35
+ else {
36
+ switch (charCode) {
37
+ case 34: // "
38
+ switch (last) {
39
+ case "string":
40
+ last = "other";
41
+ break;
42
+ case "comma":
43
+ builder.push(COMMA);
44
+ default:
45
+ last = "string";
46
+ break;
47
+ }
48
+ break;
49
+ case 92: // \
50
+ if (last === "string")
51
+ last = "escape";
52
+ break;
53
+ case 44: // ,
54
+ builder.push(view.subarray(from, i));
55
+ from = i + 1;
56
+ if (last === "other")
57
+ last = "comma";
58
+ break;
59
+ case 93: // ]
60
+ case 125: // }
61
+ if (last === "comma")
62
+ last = "other";
63
+ break;
64
+ case 9: // \t
65
+ case 10: // \n
66
+ case 11: // \v
67
+ case 12: // \f
68
+ case 13: // \r
69
+ case 32: // space
70
+ break;
71
+ default:
72
+ if (last === "comma") {
73
+ builder.push(COMMA);
74
+ last = "other";
75
+ }
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ builder.push(view.subarray(from));
81
+ let totalLength = 0;
82
+ for (const arr of builder) {
83
+ totalLength += arr.length;
84
+ }
85
+ const result = new Uint8Array(totalLength);
86
+ let offset = 0;
87
+ for (const arr of builder) {
88
+ result.set(arr, offset);
89
+ offset += arr.length;
90
+ }
91
+ return result.buffer;
92
+ }
93
+ export function decodeStringFromUTF8BOM(buffer) {
94
+ const strippedBuffer = stripBOM(buffer);
95
+ const decoder = new TextDecoder('utf-8');
96
+ return decoder.decode(strippedBuffer);
97
+ }
98
+ export default ArrayBufferParser;
@@ -0,0 +1,9 @@
1
+ import Parser from "./Parser";
2
+ export declare class BufferParser extends Parser<Buffer | string, any> {
3
+ parse(input: Buffer | string): any;
4
+ stringify(obj: any): string;
5
+ }
6
+ export declare function stripBOM(buffer: Buffer): Buffer;
7
+ export declare function normalizeJsonBuffer(text: Buffer): Buffer;
8
+ export declare function decodeStringFromUTF8BOM(buffer: Buffer): string;
9
+ export default BufferParser;
@@ -0,0 +1,92 @@
1
+ import Parser from "./Parser";
2
+ import StringParser from "./StringParser";
3
+ let BOM;
4
+ let COMMA;
5
+ try {
6
+ BOM = Buffer.of(0xef, 0xbb, 0xbf);
7
+ COMMA = Buffer.from(",");
8
+ }
9
+ catch (e) {
10
+ console.warn('Buffer is not available in current environment, try to use ArrayBufferParser');
11
+ BOM = { equals: () => false, subarray: () => null };
12
+ COMMA = { equals: () => false, subarray: () => null };
13
+ }
14
+ export class BufferParser extends Parser {
15
+ parse(input) {
16
+ if (typeof input === "string") {
17
+ return StringParser.prototype.parse.call(StringParser.prototype, input);
18
+ }
19
+ else {
20
+ return StringParser.prototype.parse.call(StringParser.prototype, decodeStringFromUTF8BOM(normalizeJsonBuffer(stripBOM(input))));
21
+ }
22
+ }
23
+ stringify(obj) {
24
+ return JSON.stringify(obj);
25
+ }
26
+ }
27
+ export function stripBOM(buffer) {
28
+ if (buffer.length >= 3 && BOM.equals(buffer.subarray(0, 3))) {
29
+ return buffer.subarray(3);
30
+ }
31
+ return buffer;
32
+ }
33
+ export function normalizeJsonBuffer(text) {
34
+ let builder = [];
35
+ let last = "other";
36
+ let from = 0;
37
+ text.forEach((charCode, i) => {
38
+ if (last == "escape") {
39
+ last = "string";
40
+ }
41
+ else {
42
+ switch (charCode) {
43
+ case 34:
44
+ switch (last) {
45
+ case "string":
46
+ last = "other";
47
+ break;
48
+ case "comma":
49
+ builder.push(COMMA);
50
+ default:
51
+ last = "string";
52
+ break;
53
+ }
54
+ break;
55
+ case 92:
56
+ if (last === "string")
57
+ last = "escape";
58
+ break;
59
+ case 44:
60
+ builder.push(text.subarray(from, i));
61
+ from = i + 1;
62
+ if (last === "other")
63
+ last = "comma";
64
+ break;
65
+ case 93:
66
+ case 125:
67
+ if (last === "comma")
68
+ last = "other";
69
+ break;
70
+ case 9:
71
+ case 10:
72
+ case 11:
73
+ case 12:
74
+ case 13:
75
+ case 32:
76
+ break;
77
+ default:
78
+ if (last === "comma") {
79
+ builder.push(COMMA);
80
+ last = "other";
81
+ }
82
+ break;
83
+ }
84
+ }
85
+ });
86
+ builder.push(text.subarray(from));
87
+ return Buffer.concat(builder);
88
+ }
89
+ export function decodeStringFromUTF8BOM(buffer) {
90
+ return stripBOM(buffer).toString("utf-8");
91
+ }
92
+ export default BufferParser;
@@ -0,0 +1,23 @@
1
+ import Parser from "./Parser";
2
+ /**
3
+ * 用于解析和序列化 ArrayBuffer 数据的解析器
4
+ */
5
+ declare class BufferParserX extends Parser<ArrayBuffer, any> {
6
+ /**
7
+ * 解析 ArrayBuffer 为对象
8
+ * @param buffer 输入的 ArrayBuffer
9
+ * @param reviver 可选的 reviver 函数
10
+ */
11
+ parse(buffer: ArrayBuffer, reviver?: (key: string, value: any) => any): any;
12
+ /**
13
+ * 序列化对象为 ArrayBuffer
14
+ * @param value 要序列化的对象
15
+ * @param replacer 可选的 replacer 函数
16
+ * @param space 可选的缩进
17
+ */
18
+ stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): ArrayBuffer;
19
+ private static _decodeUtf8;
20
+ private static _encodeUtf8;
21
+ private static _applyReviver;
22
+ }
23
+ export default BufferParserX;
@@ -0,0 +1,77 @@
1
+ import Parser from "./Parser";
2
+ import { ParserX, Serializer } from "./StringParser";
3
+ /**
4
+ * 用于解析和序列化 ArrayBuffer 数据的解析器
5
+ */
6
+ class BufferParserX extends Parser {
7
+ /**
8
+ * 解析 ArrayBuffer 为对象
9
+ * @param buffer 输入的 ArrayBuffer
10
+ * @param reviver 可选的 reviver 函数
11
+ */
12
+ parse(buffer, reviver) {
13
+ if (!buffer)
14
+ return null;
15
+ const text = BufferParserX._decodeUtf8(buffer);
16
+ const result = new StringParserX(text).parseValue();
17
+ if (typeof reviver === "function") {
18
+ return BufferParserX._applyReviver("", result, reviver);
19
+ }
20
+ console.log(result);
21
+ return result;
22
+ }
23
+ /**
24
+ * 序列化对象为 ArrayBuffer
25
+ * @param value 要序列化的对象
26
+ * @param replacer 可选的 replacer 函数
27
+ * @param space 可选的缩进
28
+ */
29
+ stringify(value, replacer, space) {
30
+ const serializer = new SerializerX(replacer, space);
31
+ const str = serializer.serialize(value);
32
+ return BufferParserX._encodeUtf8(str);
33
+ }
34
+ static _decodeUtf8(buffer) {
35
+ return new TextDecoder().decode(new Uint8Array(buffer));
36
+ }
37
+ static _encodeUtf8(str) {
38
+ return new TextEncoder().encode(str).buffer;
39
+ }
40
+ static _applyReviver(key, value, reviver) {
41
+ if (value && typeof value === "object") {
42
+ if (Array.isArray(value)) {
43
+ for (let i = 0; i < value.length; i++) {
44
+ value[i] = BufferParserX._applyReviver(i.toString(), value[i], reviver);
45
+ }
46
+ }
47
+ else {
48
+ for (const prop in value) {
49
+ if (Object.prototype.hasOwnProperty.call(value, prop)) {
50
+ value[prop] = BufferParserX._applyReviver(prop, value[prop], reviver);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ return reviver(key, value);
56
+ }
57
+ }
58
+ // StringParserX 仅用于内部解析字符串,逻辑与 StringParser 类似,但只暴露 parseValue 方法
59
+ class StringParserX {
60
+ constructor(text) {
61
+ // @ts-ignore
62
+ this.parser = new ParserX(text);
63
+ }
64
+ parseValue() {
65
+ return this.parser.parseValue();
66
+ }
67
+ }
68
+ class SerializerX {
69
+ constructor(replacer, space) {
70
+ // @ts-ignore
71
+ this.serializer = new Serializer(replacer, space);
72
+ }
73
+ serialize(obj) {
74
+ return this.serializer.serialize(obj);
75
+ }
76
+ }
77
+ export default BufferParserX;
@@ -0,0 +1,9 @@
1
+ import StringParser from './StringParser';
2
+ declare abstract class FileParser<TOutput = any> {
3
+ protected fileContent: string;
4
+ protected parser: StringParser;
5
+ preload(filePath: string): Promise<void>;
6
+ parse(): TOutput;
7
+ stringify(obj: TOutput): string;
8
+ }
9
+ export default FileParser;
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import StringParser from './StringParser';
11
+ class FileParser {
12
+ constructor() {
13
+ this.fileContent = '';
14
+ this.parser = new StringParser();
15
+ }
16
+ preload(filePath) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const fs = yield import('fs/promises');
19
+ this.fileContent = yield fs.readFile(filePath, 'utf-8');
20
+ });
21
+ }
22
+ parse() {
23
+ return this.parser.parse(this.fileContent);
24
+ }
25
+ ;
26
+ stringify(obj) {
27
+ return this.parser.stringify(obj);
28
+ }
29
+ }
30
+ export default FileParser;
@@ -0,0 +1,13 @@
1
+ interface PathDataTable {
2
+ [key: string]: number;
3
+ }
4
+ /**
5
+ * @param {string} pathdata - PathData from ADOFAI
6
+ * @returns {Array<number>} Converted AngleData
7
+ */
8
+ declare function parseToangleData(pathdata: string): number[];
9
+ declare const _default: {
10
+ pathDataTable: PathDataTable;
11
+ parseToangleData: typeof parseToangleData;
12
+ };
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ const pathDataTable = { "R": 0, "p": 15, "J": 30, "E": 45, "T": 60, "o": 75, "U": 90, "q": 105, "G": 120, "Q": 135, "H": 150, "W": 165, "L": 180, "x": 195, "N": 210, "Z": 225, "F": 240, "V": 255, "D": 270, "Y": 285, "B": 300, "C": 315, "M": 330, "A": 345, "5": 555, "6": 666, "7": 777, "8": 888, "!": 999 };
2
+ /**
3
+ * @param {string} pathdata - PathData from ADOFAI
4
+ * @returns {Array<number>} Converted AngleData
5
+ */
6
+ function parseToangleData(pathdata) {
7
+ let pt = Array.from(String(pathdata));
8
+ let result = pt.map(t => pathDataTable[t]);
9
+ return result;
10
+ }
11
+ export default {
12
+ pathDataTable,
13
+ parseToangleData
14
+ };
@@ -0,0 +1,10 @@
1
+ export interface Preset {
2
+ type: 'include' | 'exclude' | "special";
3
+ events: string[];
4
+ [key: string]: any;
5
+ }
6
+ export declare const preset_noeffect: Preset;
7
+ export declare const preset_noholds: Preset;
8
+ export declare const preset_nomovecamera: Preset;
9
+ export declare const preset_noeffect_completely: Preset;
10
+ export declare const preset_inner_no_deco: Preset;
@@ -0,0 +1,75 @@
1
+ export const preset_noeffect = {
2
+ type: 'exclude', events: [
3
+ 'Flash',
4
+ 'SetFilter',
5
+ 'SetFilterAdvanced',
6
+ 'HallOfMirrors',
7
+ 'Bloom',
8
+ 'ScalePlanets',
9
+ 'ScreenTile',
10
+ 'ScreenScroll',
11
+ 'ShakeScreen'
12
+ ]
13
+ };
14
+ export const preset_noholds = {
15
+ type: 'exclude', events: [
16
+ 'Hold',
17
+ ]
18
+ };
19
+ export const preset_nomovecamera = {
20
+ type: 'exclude', events: [
21
+ 'MoveCamera',
22
+ ]
23
+ };
24
+ export const preset_noeffect_completely = {
25
+ type: 'exclude', events: [
26
+ "AddDecoration",
27
+ "AddText",
28
+ "AddObject",
29
+ "Checkpoint",
30
+ "SetHitsound",
31
+ "PlaySound",
32
+ "SetPlanetRotation",
33
+ "ScalePlanets",
34
+ "ColorTrack",
35
+ "AnimateTrack",
36
+ "RecolorTrack",
37
+ "MoveTrack",
38
+ "PositionTrack",
39
+ "MoveDecorations",
40
+ "SetText",
41
+ "SetObject",
42
+ "SetDefaultText",
43
+ "CustomBackground",
44
+ "Flash",
45
+ "MoveCamera",
46
+ "SetFilter",
47
+ "HallOfMirrors",
48
+ "ShakeScreen",
49
+ "Bloom",
50
+ "ScreenTile",
51
+ "ScreenScroll",
52
+ "SetFrameRate",
53
+ "RepeatEvents",
54
+ "SetConditionalEvents",
55
+ "EditorComment",
56
+ "Bookmark",
57
+ "Hold",
58
+ "SetHoldSound",
59
+ //"MultiPlanet",
60
+ //"FreeRoam",
61
+ //"FreeRoamTwirl",
62
+ //"FreeRoamRemove",
63
+ "Hide",
64
+ "ScaleMargin",
65
+ "ScaleRadius"
66
+ ]
67
+ };
68
+ export const preset_inner_no_deco = {
69
+ type: "special", events: [
70
+ "MoveDecorations",
71
+ "SetText",
72
+ "SetObject",
73
+ "SetDefaultText"
74
+ ]
75
+ };
@@ -97,7 +97,7 @@ export class Level {
97
97
  return;
98
98
  }
99
99
  // 阶段3: 提取其他数据
100
- if (options && typeof options === 'object' && options !== null && typeof options.actions !== 'undefined') {
100
+ if (options && typeof options === 'object' && options !== null && Array.isArray(options.actions)) {
101
101
  this.actions = options['actions'];
102
102
  }
103
103
  else {
@@ -110,7 +110,7 @@ export class Level {
110
110
  reject("There is no ADOFAI settings.");
111
111
  return;
112
112
  }
113
- if (options && typeof options === 'object' && options !== null && typeof options.decorations !== 'undefined') {
113
+ if (options && typeof options === 'object' && options !== null && Array.isArray(options.decorations)) {
114
114
  this.__decorations = options['decorations'];
115
115
  }
116
116
  else {
@@ -165,13 +165,12 @@ export class Level {
165
165
  const tiles = [];
166
166
  const batchSize = Math.max(1, Math.floor(xLength / 100)); // 每批处理的数量,至少1个
167
167
  for (let i = 0; i < xLength; i++) {
168
- // 注意顺序:先 _filterByFloor 更新 _twirlCount,再 _parseAngle 计算角度
169
- const actions = this._filterByFloor(opt.actions, i);
168
+ // 计算相对角度(会更新 _twirlCount
170
169
  const angle = this._parseAngle(opt.angleData, i, this._twirlCount % 2);
171
170
  const tile = {
172
171
  direction: opt.angleData[i],
173
172
  _lastdir: opt.angleData[i - 1] || 0,
174
- actions: actions,
173
+ actions: this._filterByFloor(opt.actions, i),
175
174
  angle: angle,
176
175
  addDecorations: this._filterByFloorwithDeco(opt.decorations, i),
177
176
  twirl: this._twirlCount,
@@ -235,6 +234,8 @@ export class Level {
235
234
  return prev;
236
235
  }
237
236
  _filterByFloor(arr, i) {
237
+ if (!Array.isArray(arr))
238
+ return [];
238
239
  let actionT = arr.filter(item => item.floor === i);
239
240
  this._twirlCount += actionT.filter(t => t.eventType === 'Twirl').length;
240
241
  return actionT.map((_a) => {
@@ -246,12 +247,14 @@ export class Level {
246
247
  return arr.map(item => item.direction);
247
248
  }
248
249
  _flattenActionsWithFloor(arr) {
249
- return arr.flatMap((tile, index) => ((tile === null || tile === void 0 ? void 0 : tile.actions) || []).map((_a) => {
250
+ return arr.flatMap((tile, index) => (Array.isArray(tile === null || tile === void 0 ? void 0 : tile.actions) ? tile.actions : []).map((_a) => {
250
251
  var { floor } = _a, rest = __rest(_a, ["floor"]);
251
252
  return (Object.assign({ floor: index }, rest));
252
253
  }));
253
254
  }
254
255
  _filterByFloorwithDeco(arr, i) {
256
+ if (!Array.isArray(arr))
257
+ return [];
255
258
  let actionT = arr.filter(item => item.floor === i);
256
259
  return actionT.map((_a) => {
257
260
  var { floor } = _a, rest = __rest(_a, ["floor"]);
@@ -259,7 +262,7 @@ export class Level {
259
262
  });
260
263
  }
261
264
  _flattenDecorationsWithFloor(arr) {
262
- return arr.flatMap((tile, index) => ((tile === null || tile === void 0 ? void 0 : tile.addDecorations) || []).map((_a) => {
265
+ return arr.flatMap((tile, index) => (Array.isArray(tile === null || tile === void 0 ? void 0 : tile.addDecorations) ? tile.addDecorations : []).map((_a) => {
263
266
  var { floor } = _a, rest = __rest(_a, ["floor"]);
264
267
  return (Object.assign({ floor: index }, rest));
265
268
  }));
@@ -293,7 +296,7 @@ export class Level {
293
296
  }
294
297
  filterActionsByEventType(en) {
295
298
  return Object.entries(this.tiles)
296
- .flatMap(([index, a]) => (a.actions || []).map(b => ({ b, index })))
299
+ .flatMap(([index, a]) => (Array.isArray(a.actions) ? a.actions : []).map(b => ({ b, index })))
297
300
  .filter(({ b }) => b.eventType === en)
298
301
  .map(({ b, index }) => ({
299
302
  index: Number(index),
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {object} obj - JSON Object
3
+ * @param {number} indent - No usage
4
+ * @param {boolean} isRoot - Is JSON the Root?
5
+ * @returns ADOFAI File Content or Object
6
+ */
7
+ declare function exportAsADOFAI(obj: any, indent?: number, isRoot?: boolean): string;
8
+ export default exportAsADOFAI;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @param {object} obj - JSON Object
3
+ * @param {number} indent - No usage
4
+ * @param {boolean} isRoot - Is JSON the Root?
5
+ * @returns ADOFAI File Content or Object
6
+ */
7
+ function exportAsADOFAI(obj, indent = 0, isRoot = false) {
8
+ if (typeof obj !== 'object' || obj === null) {
9
+ return JSON.stringify(obj);
10
+ }
11
+ if (Array.isArray(obj)) {
12
+ const allPrimitives = obj.every(item => typeof item !== 'object' || item === null);
13
+ if (allPrimitives) {
14
+ return '[' + obj.map(item => exportAsADOFAI(item)).join(',') + ']';
15
+ }
16
+ const spaces = ' '.repeat(indent);
17
+ const arrayItems = obj.map(item => spaces + ' ' + formatAsSingleLine(item)).join(',\n');
18
+ return '[\n' + arrayItems + '\n' + spaces + ']';
19
+ }
20
+ const spaces = ' '.repeat(indent);
21
+ const keys = Object.keys(obj);
22
+ if (isRoot) {
23
+ const objectItems = keys.map(key => ' ' + JSON.stringify(key) + ': ' + exportAsADOFAI(obj[key], 2)).join(',\n');
24
+ return '{\n' + objectItems + '\n}';
25
+ }
26
+ const objectItems = keys.map(key => spaces + ' ' + JSON.stringify(key) + ': ' + exportAsADOFAI(obj[key], indent + 2)).join(',\n');
27
+ return '{\n' + objectItems + '\n' + spaces + '}';
28
+ }
29
+ /**
30
+ * @param {Array} obj Eventlist to keep
31
+ * @returns {string} JSON formated as singleline
32
+ */
33
+ function formatAsSingleLine(obj) {
34
+ if (typeof obj !== 'object' || obj === null) {
35
+ return exportAsADOFAI(obj);
36
+ }
37
+ if (Array.isArray(obj)) {
38
+ return '[' + obj.map(formatAsSingleLine).join(',') + ']';
39
+ }
40
+ const keys = Object.keys(obj);
41
+ const entries = keys.map(key => JSON.stringify(key) + ': ' + formatAsSingleLine(obj[key])).join(', ');
42
+ return '{' + entries + '}';
43
+ }
44
+ export default exportAsADOFAI;
package/dist/umd/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ADOFAI=e():t.ADOFAI=e()}(globalThis,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Level:()=>wt,Parsers:()=>r,Presets:()=>n,Structure:()=>o,pathData:()=>a});var r={};t.r(r),t.d(r,{ArrayBufferParser:()=>Y,BufferParser:()=>K,StringParser:()=>T,default:()=>q});var n={};t.r(n),t.d(n,{preset_inner_no_deco:()=>at,preset_noeffect:()=>rt,preset_noeffect_completely:()=>it,preset_noholds:()=>nt,preset_nomovecamera:()=>ot});var o={};t.r(o),t.d(o,{default:()=>wt});var i={R:0,p:15,J:30,E:45,T:60,o:75,U:90,q:105,G:120,Q:135,H:150,W:165,L:180,x:195,N:210,Z:225,F:240,V:255,D:270,Y:285,B:300,C:315,M:330,A:345,5:555,6:666,7:777,8:888,"!":999};const a={pathDataTable:i,parseToangleData:function(t){return Array.from(t).map(function(t){return i[t]})}};function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=s(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}const l=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return e=t,r=[{key:"parseError",value:function(t){return t}},{key:"parseAsObject",value:function(e,r){return(r||JSON).parse(t.parseAsText(e))}},{key:"parseAsText",value:function(t){return this.parseError(t)}}],null&&u(e.prototype,null),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function p(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,h(n.key),n)}}function y(t,e,r){return e&&p(t.prototype,e),r&&p(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}const v=y(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)});function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,S(n.key),n)}}function O(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function S(t){var e=function(t){if("object"!=d(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=d(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==d(e)?e:e+""}function k(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(k=function(){return!!t})()}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}var j=function(t){function e(){return g(this,e),t=this,n=arguments,r=w(r=e),function(t,e){if(e&&("object"==d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,k()?Reflect.construct(r,n||[],w(t).constructor):r.apply(t,n));var t,r,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}(e,t),O(e,[{key:"parse",value:function(t,r){if(null==t)return null;var n=new A(t).parseValue();return"function"==typeof r?e._applyReviver("",n,r):n}},{key:"stringify",value:function(t,e,r){return new E(e,r).serialize(t)}}],[{key:"_applyReviver",value:function(t,r,n){if(r&&"object"===d(r))if(Array.isArray(r))for(var o=0;o<r.length;o++)r[o]=e._applyReviver(o.toString(),r[o],n);else for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=e._applyReviver(i,r[i],n));return n(t,r)}}])}(v),A=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;g(this,t),this.json=e,this.position=0,this.endSection=r,65279===this.peek()&&this.read()}return O(t,[{key:"parseValue",value:function(){return this.parseByToken(this.nextToken)}},{key:"parseObject",value:function(){var e={};for(this.read();;){var r=void 0;do{if((r=this.nextToken)===t.TOKEN.NONE)return null;if(r===t.TOKEN.CURLY_CLOSE)return e}while(r===t.TOKEN.COMMA);var n=this.parseString();if(null===n)return null;if(this.nextToken!==t.TOKEN.COLON)return null;if(null!=this.endSection&&n===this.endSection)return e;this.read(),e[n]=this.parseValue()}}},{key:"parseArray",value:function(){var e=[];this.read();for(var r=!0;r;){var n=this.nextToken;switch(n){case t.TOKEN.NONE:return null;case t.TOKEN.SQUARED_CLOSE:r=!1;break;case t.TOKEN.COMMA:break;default:var o=this.parseByToken(n);e.push(o)}}return e}},{key:"parseByToken",value:function(e){switch(e){case t.TOKEN.CURLY_OPEN:return this.parseObject();case t.TOKEN.SQUARED_OPEN:return this.parseArray();case t.TOKEN.STRING:return this.parseString();case t.TOKEN.NUMBER:return this.parseNumber();case t.TOKEN.TRUE:return!0;case t.TOKEN.FALSE:return!1;case t.TOKEN.NULL:default:return null}}},{key:"parseString",value:function(){var t="";this.read();for(var e=!0;e&&-1!==this.peek();){var r=this.nextChar;switch(r){case'"':e=!1;break;case"\\":if(-1===this.peek()){e=!1;break}var n=this.nextChar;switch(n){case'"':case"/":case"\\":t+=n;break;case"b":t+="\b";break;case"f":t+="\f";break;case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"u":for(var o="",i=0;i<4;i++)o+=this.nextChar;t+=String.fromCharCode(Number.parseInt(o,16))}break;default:t+=r}}return t}},{key:"parseNumber",value:function(){var t=this.nextWord;return-1===t.indexOf(".")?Number.parseInt(t,10)||0:Number.parseFloat(t)||0}},{key:"eatWhitespace",value:function(){for(;-1!==t.WHITE_SPACE.indexOf(this.peekChar)&&(this.read(),-1!==this.peek()););}},{key:"peek",value:function(){return this.position>=this.json.length?-1:this.json.charCodeAt(this.position)}},{key:"read",value:function(){return this.position>=this.json.length?-1:this.json.charCodeAt(this.position++)}},{key:"peekChar",get:function(){var t=this.peek();return-1===t?"\0":String.fromCharCode(t)}},{key:"nextChar",get:function(){var t=this.read();return-1===t?"\0":String.fromCharCode(t)}},{key:"nextWord",get:function(){for(var e="";-1===t.WORD_BREAK.indexOf(this.peekChar)&&(e+=this.nextChar,-1!==this.peek()););return e}},{key:"nextToken",get:function(){if(this.eatWhitespace(),-1===this.peek())return t.TOKEN.NONE;switch(this.peekChar){case'"':return t.TOKEN.STRING;case",":return this.read(),t.TOKEN.COMMA;case"-":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return t.TOKEN.NUMBER;case":":return t.TOKEN.COLON;case"[":return t.TOKEN.SQUARED_OPEN;case"]":return this.read(),t.TOKEN.SQUARED_CLOSE;case"{":return t.TOKEN.CURLY_OPEN;case"}":return this.read(),t.TOKEN.CURLY_CLOSE;default:switch(this.nextWord){case"false":return t.TOKEN.FALSE;case"true":return t.TOKEN.TRUE;case"null":return t.TOKEN.NULL;default:return t.TOKEN.NONE}}}}])}();A.WHITE_SPACE=" \t\n\r\ufeff",A.WORD_BREAK=' \t\n\r{}[],:"',A.TOKEN={NONE:0,CURLY_OPEN:1,CURLY_CLOSE:2,SQUARED_OPEN:3,SQUARED_CLOSE:4,COLON:5,COMMA:6,STRING:7,NUMBER:8,TRUE:9,FALSE:10,NULL:11};var E=function(){return O(function t(e,r){g(this,t),this.result="",this.indent=0,this.indentStr="",this.replacer=e||null,this.space=r||null,"number"==typeof r?this.indentStr=" ".repeat(Math.min(10,Math.max(0,r))):"string"==typeof r&&(this.indentStr=r.slice(0,10))},[{key:"serialize",value:function(t){return this.result="",this.serializeValue(t,""),this.result}},{key:"serializeValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";"function"==typeof this.replacer&&(t=this.replacer(e,t)),null==t?this.result+="null":"string"==typeof t?this.serializeString(t):"boolean"==typeof t?this.result+=t.toString():Array.isArray(t)?this.serializeArray(t):"object"===d(t)?this.serializeObject(t):this.serializeOther(t)}},{key:"serializeObject",value:function(t){var e=!0;for(var r in this.result+="{",this.indentStr&&(this.result+="\n",this.indent++),t)if(Object.prototype.hasOwnProperty.call(t,r)){if(Array.isArray(this.replacer)&&!this.replacer.includes(r))continue;e||(this.result+=",",this.indentStr&&(this.result+="\n")),this.indentStr&&(this.result+=this.indentStr.repeat(this.indent)),this.serializeString(r.toString()),this.result+=":",this.indentStr&&(this.result+=" "),this.serializeValue(t[r],r),e=!1}this.indentStr&&(this.result+="\n",this.indent--,this.result+=this.indentStr.repeat(this.indent)),this.result+="}"}},{key:"serializeArray",value:function(t){this.result+="[",this.indentStr&&t.length>0&&(this.result+="\n",this.indent++);for(var e=!0,r=0;r<t.length;r++)e||(this.result+=",",this.indentStr&&(this.result+="\n")),this.indentStr&&(this.result+=this.indentStr.repeat(this.indent)),this.serializeValue(t[r],r.toString()),e=!1;this.indentStr&&t.length>0&&(this.result+="\n",this.indent--,this.result+=this.indentStr.repeat(this.indent)),this.result+="]"}},{key:"serializeString",value:function(t){this.result+='"';var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return b(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;switch(n){case"\b":this.result+="\\b";break;case"\t":this.result+="\\t";break;case"\n":this.result+="\\n";break;case"\f":this.result+="\\f";break;case"\r":this.result+="\\r";break;case'"':this.result+='\\"';break;case"\\":this.result+="\\\\";break;default:var o=n.charCodeAt(0);this.result+=o>=32&&o<=126?n:"\\u"+o.toString(16).padStart(4,"0")}}}catch(t){r.e(t)}finally{r.f()}this.result+='"'}},{key:"serializeOther",value:function(t){"number"==typeof t?isFinite(t)?this.result+=t.toString():this.result+="null":this.serializeString(t.toString())}}])}();const T=j;function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function D(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,N(n.key),n)}}function N(t){var e=function(t){if("object"!=P(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}function C(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(C=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}var U,M;try{U=Buffer.of(239,187,191),M=Buffer.from(",")}catch(t){console.warn("Buffer is not available in current environment, try to use ArrayBufferParser"),U={equals:function(){return!1},subarray:function(){return null}},M={equals:function(){return!1},subarray:function(){return null}}}function B(t){return t.length>=3&&U.equals(t.subarray(0,3))?t.subarray(3):t}function I(t){return B(t).toString("utf-8")}const K=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=x(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,C()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"parse",value:function(t){if("string"==typeof t)return T.prototype.parse.call(T.prototype,t);var e=B(t),r=new Uint8Array(e);if(function(t){for(var e="other",r=0;r<t.length;r++){var n=t[r];if("escape"!==e)switch(n){case 34:e="string"===e?"other":"string";break;case 92:"string"===e&&(e="escape");break;case 44:"other"===e&&(e="comma");break;case 93:case 125:default:"comma"===e&&(e="other");break;case 9:case 10:case 11:case 12:case 13:case 32:if((10===n||13===n)&&"string"===e)return!0}else e="string"}return!1}(r))return T.prototype.parse.call(T.prototype,I(e));try{var n=function(t){for(var e=[],r="other",n=0,o=0;o<t.length;o++){var i=t[o];if("escape"!==r)switch(i){case 34:switch(r){case"string":r="other";break;case"comma":e.push(M||new Uint8Array([44]));default:r="string"}break;case 92:"string"===r&&(r="escape");break;case 44:e.push(t.subarray(n,o)),n=o+1,"other"===r&&(r="comma");break;case 93:case 125:"comma"===r&&(r="other");break;case 9:case 10:case 11:case 12:case 13:case 32:break;default:"comma"===r&&(e.push(M||new Uint8Array([44])),r="other")}else r="string"}e.push(t.subarray(n));for(var a=0,s=0,u=e;s<u.length;s++)a+=u[s].length;for(var c=new Uint8Array(a),l=0,f=0,p=e;f<p.length;f++){var y=p[f];c.set(y,l),l+=y.length}return c}(r),o=I(Buffer.from(n));return JSON.parse(o)}catch(t){return T.prototype.parse.call(T.prototype,I(e))}}},{key:"stringify",value:function(t){return JSON.stringify(t)}}])&&D(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(v);function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,z(n.key),n)}}function z(t){var e=function(t){if("object"!=F(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=F(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(e)?e:e+""}function W(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(W=function(){return!!t})()}function G(t){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},G(t)}function V(t,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},V(t,e)}var H=new Uint8Array([239,187,191]),J=new Uint8Array([44]);function Q(t){var e=new Uint8Array(t);return e.length>=3&&e[0]===H[0]&&e[1]===H[1]&&e[2]===H[2]?t.slice(3):t}const Y=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=G(e),function(t,e){if(e&&("object"==F(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,W()?Reflect.construct(e,r||[],G(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&V(t,e)}(e,t),r=e,(n=[{key:"parse",value:function(t){return"string"==typeof t?T.prototype.parse.call(T.prototype,t):T.prototype.parse.call(T.prototype,(e=function(t){for(var e=new Uint8Array(t),r=[],n="other",o=0,i=0;i<e.length;i++){var a=e[i];if("escape"==n)n="string";else switch(a){case 34:switch(n){case"string":n="other";break;case"comma":r.push(J);default:n="string"}break;case 92:"string"===n&&(n="escape");break;case 44:r.push(e.subarray(o,i)),o=i+1,"other"===n&&(n="comma");break;case 93:case 125:"comma"===n&&(n="other");break;case 9:case 10:case 11:case 12:case 13:case 32:break;default:"comma"===n&&(r.push(J),n="other")}}r.push(e.subarray(o));for(var s=0,u=0,c=r;u<c.length;u++)s+=c[u].length;for(var l=new Uint8Array(s),f=0,p=0,y=r;p<y.length;p++){var h=y[p];l.set(h,f),f+=h.length}return l.buffer}(Q(t)),r=Q(e),new TextDecoder("utf-8").decode(r)));var e,r}},{key:"stringify",value:function(t){return JSON.stringify(t)}}])&&L(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(v),q=l;function $(t){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(t)}function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"\t",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;if("object"!==$(t)||null===t)return JSON.stringify(t);if(Array.isArray(t)){if(t.every(function(t){return"object"!==$(t)||null===t}))return"["+t.map(function(t){return Z(t,0,!1,n,o)}).join(",")+"]";var i=n.repeat(e),a=n.repeat(e+o);return"[\n"+t.map(function(t){return a+X(t,n)}).join(",\n")+"\n"+i+"]"}var s=n.repeat(e),u=Object.keys(t);if(r){var c=n.repeat(o);return"{\n"+u.map(function(e){return c+JSON.stringify(e)+": "+Z(t[e],o,!1,n,o)}).join(",\n")+"\n}"}return"{\n"+u.map(function(r){return s+n.repeat(o)+JSON.stringify(r)+": "+Z(t[r],e+o,!1,n,o)}).join(",\n")+"\n"+s+"}"}function X(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\t";return"object"!==$(t)||null===t?Z(t,0,!1,e):Array.isArray(t)?"["+t.map(function(t){return X(t,e)}).join(",")+"]":"{"+Object.keys(t).map(function(r){return JSON.stringify(r)+": "+X(t[r],e)}).join(", ")+"}"}const tt=Z;var et,rt={type:"exclude",events:["Flash","SetFilter","SetFilterAdvanced","HallOfMirrors","Bloom","ScalePlanets","ScreenTile","ScreenScroll","ShakeScreen"]},nt={type:"exclude",events:["Hold"]},ot={type:"exclude",events:["MoveCamera"]},it={type:"exclude",events:["AddDecoration","AddText","AddObject","Checkpoint","SetHitsound","PlaySound","SetPlanetRotation","ScalePlanets","ColorTrack","AnimateTrack","RecolorTrack","MoveTrack","PositionTrack","MoveDecorations","SetText","SetObject","SetDefaultText","CustomBackground","Flash","MoveCamera","SetFilter","HallOfMirrors","ShakeScreen","Bloom","ScreenTile","ScreenScroll","SetFrameRate","RepeatEvents","SetConditionalEvents","EditorComment","Bookmark","Hold","SetHoldSound","Hide","ScaleMargin","ScaleRadius"]},at={type:"special",events:["MoveDecorations","SetText","SetObject","SetDefaultText"]};!function(t){t.include="include",t.exclude="exclude",t.special="special"}(et||(et={}));const st=function(t){if(!Array.isArray(t))throw new Error("Arguments are not supported.");return t.map(function(t){var e=Object.assign({},t);return e.hasOwnProperty("addDecorations")&&(e.addDecorations=[]),Array.isArray(e.actions)&&(e.actions=e.actions.filter(function(t){return!at.events.includes(t.eventType)})),e})},ut=function(t,e){return e.map(function(e){var r=Object.assign({},e);return Array.isArray(e.actions)&&(r.actions=e.actions.filter(function(e){return!t.includes(e.eventType)})),r})},ct=function(t,e){return e.map(function(e){var r=Object.assign({},e);return Array.isArray(e.actions)&&(r.actions=e.actions.filter(function(e){return t.includes(e.eventType)})),r})},lt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let ft;const pt=new Uint8Array(16),yt=[];for(let t=0;t<256;++t)yt.push((t+256).toString(16).slice(1));function ht(t,e,r){const n=(t=t||{}).random??t.rng?.()??function(){if(!ft){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ft=crypto.getRandomValues.bind(crypto)}return ft(pt)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return function(t,e=0){return(yt[t[e+0]]+yt[t[e+1]]+yt[t[e+2]]+yt[t[e+3]]+"-"+yt[t[e+4]]+yt[t[e+5]]+"-"+yt[t[e+6]]+yt[t[e+7]]+"-"+yt[t[e+8]]+yt[t[e+9]]+"-"+yt[t[e+10]]+yt[t[e+11]]+yt[t[e+12]]+yt[t[e+13]]+yt[t[e+14]]+yt[t[e+15]]).toLowerCase()}(n)}function vt(t,e){if(t){if("string"==typeof t)return bt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?bt(t,e):void 0}}function bt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function dt(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return gt(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,s=0,u=t,p.n=r,a}};function y(r,n){for(s=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,i=l[e],y=p.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(s=0,p.v=n,p.n=i[1]):y<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,p.n=h,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&y(l,h),s=l,u=h;(e=s<2?t:u)||!f;){i||(s?s<3?(s>1&&(p.n=-1),y(s,u)):p.n=u:p.v=u);try{if(c=2,i){if(s||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(gt(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,gt(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,gt(f,"constructor",c),gt(c,"constructor",u),u.displayName="GeneratorFunction",gt(c,o,"GeneratorFunction"),gt(f),gt(f,o,"Generator"),gt(f,n,function(){return this}),gt(f,"toString",function(){return"[object Generator]"}),(dt=function(){return{w:i,m:p}})()}function gt(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}gt=function(t,e,r,n){function i(e,r){gt(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},gt(t,e,r,n)}function mt(t){return mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(t)}function Ot(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,St(n.key),n)}}function St(t){var e=function(t){if("object"!=mt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=mt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}var kt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},wt=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._events=new Map,this.guidCallbacks=new Map,this._options=e,this._provider=r},e=[{key:"generateGUID",value:function(){return"event_".concat(!lt.randomUUID||e||t?ht(t,e,r):lt.randomUUID());var t,e,r}},{key:"_emitProgress",value:function(t,e,r,n){var o={stage:t,current:e,total:r,percent:r>0?Math.round(e/r*100):0,data:n};this.trigger("parse:progress",o),this.trigger("parse:".concat(t),o)}},{key:"load",value:function(){var t=this;return new Promise(function(e,r){var n,o=t._options;switch(t._emitProgress("start",0,0),mt(o)){case"string":try{n=q.parseAsObject(o,t._provider)}catch(t){return void r(t)}break;case"object":n=Object.assign({},o);break;default:return void r("Options must be String or Object")}var i=n&&"object"===mt(n)&&null!==n&&void 0!==n.pathData,s=n&&"object"===mt(n)&&null!==n&&void 0!==n.angleData;if(i){var u=n.pathData;t._emitProgress("pathData",0,u.length,{source:u}),t.angleData=a.parseToangleData(u),t._emitProgress("pathData",u.length,u.length,{source:u,processed:t.angleData})}else{if(!s)return void r("There is not any angle datas.");t.angleData=n.angleData,t._emitProgress("angleData",t.angleData.length,t.angleData.length,{processed:t.angleData})}n&&"object"===mt(n)&&null!==n&&void 0!==n.actions?t.actions=n.actions:t.actions=[],n&&"object"===mt(n)&&null!==n&&void 0!==n.settings?(t.settings=n.settings,n&&"object"===mt(n)&&null!==n&&void 0!==n.decorations?t.__decorations=n.decorations:t.__decorations=[],t.tiles=[],t._angleDir=-180,t._twirlCount=0,t._createArray(t.angleData.length,{angleData:t.angleData,actions:t.actions,decorations:t.__decorations}).then(function(r){t.tiles=r,t._emitProgress("complete",t.angleData.length,t.angleData.length),t.trigger("load",t),e(!0)}).catch(function(t){r(t)})):r("There is no ADOFAI settings.")})}},{key:"on",value:function(t,e){this._events.has(t)||this._events.set(t,[]);var r=this.generateGUID();return this._events.get(t).push({guid:r,callback:e}),this.guidCallbacks.set(r,{eventName:t,callback:e}),r}},{key:"trigger",value:function(t,e){this._events.has(t)&&this._events.get(t).forEach(function(t){return(0,t.callback)(e)})}},{key:"off",value:function(t){if(this.guidCallbacks.has(t)){var e=this.guidCallbacks.get(t).eventName;if(this.guidCallbacks.delete(t),this._events.has(e)){var r=this._events.get(e),n=r.findIndex(function(e){return e.guid===t});-1!==n&&r.splice(n,1)}}}},{key:"_createArray",value:function(t,e){return r=this,n=void 0,o=void 0,i=dt().m(function r(){var n,o,i,a,s,u;return dt().w(function(r){for(;;)switch(r.n){case 0:n=[],o=Math.max(1,Math.floor(t/100)),i=0;case 1:if(!(i<t)){r.n=3;break}if(a=this._filterByFloor(e.actions,i),s=this._parseAngle(e.angleData,i,this._twirlCount%2),u={direction:e.angleData[i],_lastdir:e.angleData[i-1]||0,actions:a,angle:s,addDecorations:this._filterByFloorwithDeco(e.decorations,i),twirl:this._twirlCount,extraProps:{}},n.push(u),i%o!==0&&i!==t-1){r.n=2;break}if(this._emitProgress("relativeAngle",i+1,t,{tileIndex:i,tile:u,angle:e.angleData[i],relativeAngle:s}),i%(10*o)!=0){r.n=2;break}return r.n=2,new Promise(function(t){return setTimeout(t,0)});case 2:i++,r.n=1;break;case 3:return r.a(2,n)}},r,this)}),new(o||(o=Promise))(function(t,e){function a(t){try{u(i.next(t))}catch(t){e(t)}}function s(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o(function(t){t(r)})).then(a,s)}u((i=i.apply(r,n||[])).next())});var r,n,o,i}},{key:"_changeAngle",value:function(){var t=this,e=0;return this.tiles.map(function(r){return e++,r.angle=t._parsechangedAngle(r.direction,e,r.twirl,r._lastdir),r})}},{key:"_normalizeAngle",value:function(t){return(t%360+360)%360}},{key:"_parsechangedAngle",value:function(t,e,r,n){var o=0;if(0===e&&(this._angleDir=180),999===t)this._angleDir=this._normalizeAngle(n),isNaN(this._angleDir)&&(this._angleDir=0),o=0;else{var i=this._normalizeAngle(this._angleDir-t);0===(o=0===r?i:this._normalizeAngle(360-i))&&(o=360),this._angleDir=this._normalizeAngle(t+180)}return o}},{key:"_filterByFloor",value:function(t,e){var r=t.filter(function(t){return t.floor===e});return this._twirlCount+=r.filter(function(t){return"Twirl"===t.eventType}).length,r.map(function(t){return t.floor,kt(t,["floor"])})}},{key:"_flattenAngleDatas",value:function(t){return t.map(function(t){return t.direction})}},{key:"_flattenActionsWithFloor",value:function(t){return t.flatMap(function(t,e){return((null==t?void 0:t.actions)||[]).map(function(t){t.floor;var r=kt(t,["floor"]);return Object.assign({floor:e},r)})})}},{key:"_filterByFloorwithDeco",value:function(t,e){return t.filter(function(t){return t.floor===e}).map(function(t){return t.floor,kt(t,["floor"])})}},{key:"_flattenDecorationsWithFloor",value:function(t){return t.flatMap(function(t,e){return((null==t?void 0:t.addDecorations)||[]).map(function(t){t.floor;var r=kt(t,["floor"]);return Object.assign({floor:e},r)})})}},{key:"_parseAngle",value:function(t,e,r){var n=0;if(0===e&&(this._angleDir=180),999===t[e])this._angleDir=this._normalizeAngle(t[e-1]),isNaN(this._angleDir)&&(this._angleDir=0),n=0;else{var o=this._normalizeAngle(this._angleDir-t[e]);0===(n=0===r?o:this._normalizeAngle(360-o))&&(n=360),this._angleDir=this._normalizeAngle(t[e]+180)}return n}},{key:"filterActionsByEventType",value:function(t){return Object.entries(this.tiles).flatMap(function(t){var e=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||vt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),r=e[0];return(e[1].actions||[]).map(function(t){return{b:t,index:r}})}).filter(function(e){return e.b.eventType===t}).map(function(t){var e=t.b,r=t.index;return{index:Number(r),action:e}})}},{key:"getActionsByIndex",value:function(t,e){var r=this.filterActionsByEventType(t).filter(function(t){return t.index===e});return{count:r.length,actions:r.map(function(t){return t.action})}}},{key:"calculateTileCoordinates",value:function(){console.warn("calculateTileCoordinates is deprecated. Use calculateTilePosition instead.")}},{key:"calculateTilePosition",value:function(){var t,e=this.angleData,r=this.tiles.length,n=[],o=[0,0],i=new Map,a=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=vt(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(a)throw o}}}}(this.actions);try{for(a.s();!(t=a.n()).done;){var s=t.value;"PositionTrack"===s.eventType&&s.positionOffset&&!0!==s.editorOnly&&"Enabled"!==s.editorOnly&&i.set(s.floor,s)}}catch(t){a.e(t)}finally{a.f()}this._emitProgress("tilePosition",0,r);for(var u=new Array(r),c=0;c<r;c++)u[c]=999===e[c]?e[c-1]+180:e[c];for(var l=Math.max(100,Math.floor(r/100)),f=0;f<=r;f++){var p=f===r,y=p?u[f-1]||0:u[f],h=0===f?0:u[f-1]||0,v=this.tiles[f],b=i.get(f);(null==b?void 0:b.positionOffset)&&(o[0]+=b.positionOffset[0],o[1]+=b.positionOffset[1]);var d=[o[0],o[1]];n.push(d),v&&(v.position=d,v.extraProps.angle1=y,v.extraProps.angle2=h-180,v.extraProps.cangle=p?u[f-1]+180:u[f]);var g=y*Math.PI/180;o[0]+=Math.cos(g),o[1]+=Math.sin(g),(f%l===0||p)&&this._emitProgress("tilePosition",f,r,{tileIndex:f,tile:v,position:d,angle:y})}return this._emitProgress("tilePosition",r,r,{processed:n.flat()}),n}},{key:"floorOperation",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{type:"append",direction:0};switch(t.type){case"append":this.appendFloor(t);break;case"insert":"number"==typeof t.id&&this.tiles.splice(t.id,0,{direction:t.direction||0,angle:0,actions:[],addDecorations:[],_lastdir:this.tiles[t.id-1].direction,twirl:this.tiles[t.id-1].twirl});break;case"delete":"number"==typeof t.id&&this.tiles.splice(t.id,1)}this._changeAngle()}},{key:"appendFloor",value:function(t){this.tiles.push({direction:t.direction,angle:0,actions:[],addDecorations:[],_lastdir:this.tiles[this.tiles.length-1].direction,twirl:this.tiles[this.tiles.length-1].twirl,extraProps:{}}),this._changeAngle()}},{key:"clearDeco",value:function(){return this.tiles=st(this.tiles),!0}},{key:"clearEffect",value:function(t){this.clearEvent(n[t])}},{key:"clearEvent",value:function(t){t.type==et.include?this.tiles=ct(t.events,this.tiles):t.type==et.exclude&&(this.tiles=ut(t.events,this.tiles))}},{key:"export",value:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i={angleData:this._flattenAngleDatas(this.tiles),settings:this.settings,actions:this._flattenActionsWithFloor(this.tiles),decorations:this._flattenDecorationsWithFloor(this.tiles)};return"object"===t?i:tt(i,e,r,n,o)}}],e&&Ot(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();return e})());
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ADOFAI=e():t.ADOFAI=e()}(globalThis,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Level:()=>St,Parsers:()=>r,Presets:()=>n,Structure:()=>o,pathData:()=>a});var r={};t.r(r),t.d(r,{ArrayBufferParser:()=>Q,BufferParser:()=>F,StringParser:()=>T,default:()=>q});var n={};t.r(n),t.d(n,{preset_inner_no_deco:()=>at,preset_noeffect:()=>rt,preset_noeffect_completely:()=>it,preset_noholds:()=>nt,preset_nomovecamera:()=>ot});var o={};t.r(o),t.d(o,{default:()=>St});var i={R:0,p:15,J:30,E:45,T:60,o:75,U:90,q:105,G:120,Q:135,H:150,W:165,L:180,x:195,N:210,Z:225,F:240,V:255,D:270,Y:285,B:300,C:315,M:330,A:345,5:555,6:666,7:777,8:888,"!":999};const a={pathDataTable:i,parseToangleData:function(t){return Array.from(t).map((function(t){return i[t]}))}};function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=s(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}const l=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return e=t,r=[{key:"parseError",value:function(t){return t}},{key:"parseAsObject",value:function(e,r){return(r||JSON).parse(t.parseAsText(e))}},{key:"parseAsText",value:function(t){return this.parseError(t)}}],null&&u(e.prototype,null),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,y(n.key),n)}}function p(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}const v=p((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}));function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,w(n.key),n)}}function O(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(t){var e=function(t){if("object"!=b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==b(e)?e:e+""}function S(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(S=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}var E=function(t){function e(){return g(this,e),t=this,n=arguments,r=k(r=e),function(t,e){if(e&&("object"==b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,S()?Reflect.construct(r,n||[],k(t).constructor):r.apply(t,n));var t,r,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}(e,t),O(e,[{key:"parse",value:function(t,r){if(null==t)return null;var n=new A(t).parseValue();return"function"==typeof r?e._applyReviver("",n,r):n}},{key:"stringify",value:function(t,e,r){return new j(e,r).serialize(t)}}],[{key:"_applyReviver",value:function(t,r,n){if(r&&"object"===b(r))if(Array.isArray(r))for(var o=0;o<r.length;o++)r[o]=e._applyReviver(o.toString(),r[o],n);else for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=e._applyReviver(i,r[i],n));return n(t,r)}}])}(v),A=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;g(this,t),this.json=e,this.position=0,this.endSection=r,65279===this.peek()&&this.read()}return O(t,[{key:"parseValue",value:function(){return this.parseByToken(this.nextToken)}},{key:"parseObject",value:function(){var e={};for(this.read();;){var r=void 0;do{if((r=this.nextToken)===t.TOKEN.NONE)return null;if(r===t.TOKEN.CURLY_CLOSE)return e}while(r===t.TOKEN.COMMA);var n=this.parseString();if(null===n)return null;if(this.nextToken!==t.TOKEN.COLON)return null;if(null!=this.endSection&&n===this.endSection)return e;this.read(),e[n]=this.parseValue()}}},{key:"parseArray",value:function(){var e=[];this.read();for(var r=!0;r;){var n=this.nextToken;switch(n){case t.TOKEN.NONE:return null;case t.TOKEN.SQUARED_CLOSE:r=!1;break;case t.TOKEN.COMMA:break;default:var o=this.parseByToken(n);e.push(o)}}return e}},{key:"parseByToken",value:function(e){switch(e){case t.TOKEN.CURLY_OPEN:return this.parseObject();case t.TOKEN.SQUARED_OPEN:return this.parseArray();case t.TOKEN.STRING:return this.parseString();case t.TOKEN.NUMBER:return this.parseNumber();case t.TOKEN.TRUE:return!0;case t.TOKEN.FALSE:return!1;case t.TOKEN.NULL:default:return null}}},{key:"parseString",value:function(){var t="";this.read();for(var e=!0;e&&-1!==this.peek();){var r=this.nextChar;switch(r){case'"':e=!1;break;case"\\":if(-1===this.peek()){e=!1;break}var n=this.nextChar;switch(n){case'"':case"/":case"\\":t+=n;break;case"b":t+="\b";break;case"f":t+="\f";break;case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"u":for(var o="",i=0;i<4;i++)o+=this.nextChar;t+=String.fromCharCode(Number.parseInt(o,16))}break;default:t+=r}}return t}},{key:"parseNumber",value:function(){var t=this.nextWord;return-1===t.indexOf(".")?Number.parseInt(t,10)||0:Number.parseFloat(t)||0}},{key:"eatWhitespace",value:function(){for(;-1!==t.WHITE_SPACE.indexOf(this.peekChar)&&(this.read(),-1!==this.peek()););}},{key:"peek",value:function(){return this.position>=this.json.length?-1:this.json.charCodeAt(this.position)}},{key:"read",value:function(){return this.position>=this.json.length?-1:this.json.charCodeAt(this.position++)}},{key:"peekChar",get:function(){var t=this.peek();return-1===t?"\0":String.fromCharCode(t)}},{key:"nextChar",get:function(){var t=this.read();return-1===t?"\0":String.fromCharCode(t)}},{key:"nextWord",get:function(){for(var e="";-1===t.WORD_BREAK.indexOf(this.peekChar)&&(e+=this.nextChar,-1!==this.peek()););return e}},{key:"nextToken",get:function(){if(this.eatWhitespace(),-1===this.peek())return t.TOKEN.NONE;switch(this.peekChar){case'"':return t.TOKEN.STRING;case",":return this.read(),t.TOKEN.COMMA;case"-":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return t.TOKEN.NUMBER;case":":return t.TOKEN.COLON;case"[":return t.TOKEN.SQUARED_OPEN;case"]":return this.read(),t.TOKEN.SQUARED_CLOSE;case"{":return t.TOKEN.CURLY_OPEN;case"}":return this.read(),t.TOKEN.CURLY_CLOSE;default:switch(this.nextWord){case"false":return t.TOKEN.FALSE;case"true":return t.TOKEN.TRUE;case"null":return t.TOKEN.NULL;default:return t.TOKEN.NONE}}}}])}();A.WHITE_SPACE=" \t\n\r\ufeff",A.WORD_BREAK=' \t\n\r{}[],:"',A.TOKEN={NONE:0,CURLY_OPEN:1,CURLY_CLOSE:2,SQUARED_OPEN:3,SQUARED_CLOSE:4,COLON:5,COMMA:6,STRING:7,NUMBER:8,TRUE:9,FALSE:10,NULL:11};var j=function(){return O((function t(e,r){g(this,t),this.result="",this.indent=0,this.indentStr="",this.replacer=e||null,this.space=r||null,"number"==typeof r?this.indentStr=" ".repeat(Math.min(10,Math.max(0,r))):"string"==typeof r&&(this.indentStr=r.slice(0,10))}),[{key:"serialize",value:function(t){return this.result="",this.serializeValue(t,""),this.result}},{key:"serializeValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";"function"==typeof this.replacer&&(t=this.replacer(e,t)),null==t?this.result+="null":"string"==typeof t?this.serializeString(t):"boolean"==typeof t?this.result+=t.toString():Array.isArray(t)?this.serializeArray(t):"object"===b(t)?this.serializeObject(t):this.serializeOther(t)}},{key:"serializeObject",value:function(t){var e=!0;for(var r in this.result+="{",this.indentStr&&(this.result+="\n",this.indent++),t)if(Object.prototype.hasOwnProperty.call(t,r)){if(Array.isArray(this.replacer)&&!this.replacer.includes(r))continue;e||(this.result+=",",this.indentStr&&(this.result+="\n")),this.indentStr&&(this.result+=this.indentStr.repeat(this.indent)),this.serializeString(r.toString()),this.result+=":",this.indentStr&&(this.result+=" "),this.serializeValue(t[r],r),e=!1}this.indentStr&&(this.result+="\n",this.indent--,this.result+=this.indentStr.repeat(this.indent)),this.result+="}"}},{key:"serializeArray",value:function(t){this.result+="[",this.indentStr&&t.length>0&&(this.result+="\n",this.indent++);for(var e=!0,r=0;r<t.length;r++)e||(this.result+=",",this.indentStr&&(this.result+="\n")),this.indentStr&&(this.result+=this.indentStr.repeat(this.indent)),this.serializeValue(t[r],r.toString()),e=!1;this.indentStr&&t.length>0&&(this.result+="\n",this.indent--,this.result+=this.indentStr.repeat(this.indent)),this.result+="]"}},{key:"serializeString",value:function(t){this.result+='"';var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return d(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;switch(n){case"\b":this.result+="\\b";break;case"\t":this.result+="\\t";break;case"\n":this.result+="\\n";break;case"\f":this.result+="\\f";break;case"\r":this.result+="\\r";break;case'"':this.result+='\\"';break;case"\\":this.result+="\\\\";break;default:var o=n.charCodeAt(0);this.result+=o>=32&&o<=126?n:"\\u"+o.toString(16).padStart(4,"0")}}}catch(t){r.e(t)}finally{r.f()}this.result+='"'}},{key:"serializeOther",value:function(t){"number"==typeof t?isFinite(t)?this.result+=t.toString():this.result+="null":this.serializeString(t.toString())}}])}();const T=E;function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function D(t){var e=function(t){if("object"!=P(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=function(){return!!t})()}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}var U,M;try{U=Buffer.of(239,187,191),M=Buffer.from(",")}catch(t){console.warn("Buffer is not available in current environment, try to use ArrayBufferParser"),U={equals:function(){return!1},subarray:function(){return null}},M={equals:function(){return!1},subarray:function(){return null}}}function I(t){return t.length>=3&&U.equals(t.subarray(0,3))?t.subarray(3):t}function B(t){return I(t).toString("utf-8")}const F=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=C(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,N()?Reflect.construct(e,r||[],C(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"parse",value:function(t){if("string"==typeof t)return T.prototype.parse.call(T.prototype,t);var e=I(t),r=new Uint8Array(e);if(function(t){for(var e="other",r=0;r<t.length;r++){var n=t[r];if("escape"!==e)switch(n){case 34:e="string"===e?"other":"string";break;case 92:"string"===e&&(e="escape");break;case 44:"other"===e&&(e="comma");break;case 93:case 125:default:"comma"===e&&(e="other");break;case 9:case 10:case 11:case 12:case 13:case 32:if((10===n||13===n)&&"string"===e)return!0}else e="string"}return!1}(r))return T.prototype.parse.call(T.prototype,B(e));try{var n=function(t){for(var e=[],r="other",n=0,o=0;o<t.length;o++){var i=t[o];if("escape"!==r)switch(i){case 34:switch(r){case"string":r="other";break;case"comma":e.push(M||new Uint8Array([44]));default:r="string"}break;case 92:"string"===r&&(r="escape");break;case 44:e.push(t.subarray(n,o)),n=o+1,"other"===r&&(r="comma");break;case 93:case 125:"comma"===r&&(r="other");break;case 9:case 10:case 11:case 12:case 13:case 32:break;default:"comma"===r&&(e.push(M||new Uint8Array([44])),r="other")}else r="string"}e.push(t.subarray(n));for(var a=0,s=0,u=e;s<u.length;s++)a+=u[s].length;for(var c=new Uint8Array(a),l=0,f=0,h=e;f<h.length;f++){var p=h[f];c.set(p,l),l+=p.length}return c}(r),o=B(Buffer.from(n));return JSON.parse(o)}catch(t){return T.prototype.parse.call(T.prototype,B(e))}}},{key:"stringify",value:function(t){return JSON.stringify(t)}}])&&x(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(v);function K(t){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},K(t)}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,z(n.key),n)}}function z(t){var e=function(t){if("object"!=K(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=K(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==K(e)?e:e+""}function G(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(G=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function V(t,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},V(t,e)}var H=new Uint8Array([239,187,191]),J=new Uint8Array([44]);function Y(t){var e=new Uint8Array(t);return e.length>=3&&e[0]===H[0]&&e[1]===H[1]&&e[2]===H[2]?t.slice(3):t}const Q=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=W(e),function(t,e){if(e&&("object"==K(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,G()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&V(t,e)}(e,t),r=e,(n=[{key:"parse",value:function(t){return"string"==typeof t?T.prototype.parse.call(T.prototype,t):T.prototype.parse.call(T.prototype,(e=function(t){for(var e=new Uint8Array(t),r=[],n="other",o=0,i=0;i<e.length;i++){var a=e[i];if("escape"==n)n="string";else switch(a){case 34:switch(n){case"string":n="other";break;case"comma":r.push(J);default:n="string"}break;case 92:"string"===n&&(n="escape");break;case 44:r.push(e.subarray(o,i)),o=i+1,"other"===n&&(n="comma");break;case 93:case 125:"comma"===n&&(n="other");break;case 9:case 10:case 11:case 12:case 13:case 32:break;default:"comma"===n&&(r.push(J),n="other")}}r.push(e.subarray(o));for(var s=0,u=0,c=r;u<c.length;u++)s+=c[u].length;for(var l=new Uint8Array(s),f=0,h=0,p=r;h<p.length;h++){var y=p[h];l.set(y,f),f+=y.length}return l.buffer}(Y(t)),r=Y(e),new TextDecoder("utf-8").decode(r)));var e,r}},{key:"stringify",value:function(t){return JSON.stringify(t)}}])&&L(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(v),q=l;function $(t){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(t)}function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"\t",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;if("object"!==$(t)||null===t)return JSON.stringify(t);if(Array.isArray(t)){if(t.every((function(t){return"object"!==$(t)||null===t})))return"["+t.map((function(t){return Z(t,0,!1,n,o)})).join(",")+"]";var i=n.repeat(e),a=n.repeat(e+o);return"[\n"+t.map((function(t){return a+X(t,n)})).join(",\n")+"\n"+i+"]"}var s=n.repeat(e),u=Object.keys(t);if(r){var c=n.repeat(o);return"{\n"+u.map((function(e){return c+JSON.stringify(e)+": "+Z(t[e],o,!1,n,o)})).join(",\n")+"\n}"}return"{\n"+u.map((function(r){return s+n.repeat(o)+JSON.stringify(r)+": "+Z(t[r],e+o,!1,n,o)})).join(",\n")+"\n"+s+"}"}function X(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\t";return"object"!==$(t)||null===t?Z(t,0,!1,e):Array.isArray(t)?"["+t.map((function(t){return X(t,e)})).join(",")+"]":"{"+Object.keys(t).map((function(r){return JSON.stringify(r)+": "+X(t[r],e)})).join(", ")+"}"}const tt=Z;var et,rt={type:"exclude",events:["Flash","SetFilter","SetFilterAdvanced","HallOfMirrors","Bloom","ScalePlanets","ScreenTile","ScreenScroll","ShakeScreen"]},nt={type:"exclude",events:["Hold"]},ot={type:"exclude",events:["MoveCamera"]},it={type:"exclude",events:["AddDecoration","AddText","AddObject","Checkpoint","SetHitsound","PlaySound","SetPlanetRotation","ScalePlanets","ColorTrack","AnimateTrack","RecolorTrack","MoveTrack","PositionTrack","MoveDecorations","SetText","SetObject","SetDefaultText","CustomBackground","Flash","MoveCamera","SetFilter","HallOfMirrors","ShakeScreen","Bloom","ScreenTile","ScreenScroll","SetFrameRate","RepeatEvents","SetConditionalEvents","EditorComment","Bookmark","Hold","SetHoldSound","Hide","ScaleMargin","ScaleRadius"]},at={type:"special",events:["MoveDecorations","SetText","SetObject","SetDefaultText"]};!function(t){t.include="include",t.exclude="exclude",t.special="special"}(et||(et={}));const st=function(t){if(!Array.isArray(t))throw new Error("Arguments are not supported.");return t.map((function(t){var e=Object.assign({},t);return e.hasOwnProperty("addDecorations")&&(e.addDecorations=[]),Array.isArray(e.actions)&&(e.actions=e.actions.filter((function(t){return!at.events.includes(t.eventType)}))),e}))},ut=function(t,e){return e.map((function(e){var r=Object.assign({},e);return Array.isArray(e.actions)&&(r.actions=e.actions.filter((function(e){return!t.includes(e.eventType)}))),r}))},ct=function(t,e){return e.map((function(e){var r=Object.assign({},e);return Array.isArray(e.actions)&&(r.actions=e.actions.filter((function(e){return t.includes(e.eventType)}))),r}))},lt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let ft;const ht=new Uint8Array(16),pt=[];for(let t=0;t<256;++t)pt.push((t+256).toString(16).slice(1));function yt(t,e,r){const n=(t=t||{}).random??t.rng?.()??function(){if(!ft){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ft=crypto.getRandomValues.bind(crypto)}return ft(ht)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return function(t,e=0){return(pt[t[e+0]]+pt[t[e+1]]+pt[t[e+2]]+pt[t[e+3]]+"-"+pt[t[e+4]]+pt[t[e+5]]+"-"+pt[t[e+6]]+pt[t[e+7]]+"-"+pt[t[e+8]]+pt[t[e+9]]+"-"+pt[t[e+10]]+pt[t[e+11]]+pt[t[e+12]]+pt[t[e+13]]+pt[t[e+14]]+pt[t[e+15]]).toLowerCase()}(n)}function vt(t,e){if(t){if("string"==typeof t)return dt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dt(t,e):void 0}}function dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function bt(){bt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function u(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(e,r,n,o){var i=r&&r.prototype instanceof h?r:h,a=Object.create(i.prototype);return u(a,"_invoke",function(e,r,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=w(s,n);if(u){if(u===f)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var c=l(e,r,n);if("normal"===c.type){if(o=n.done?4:2,c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=4,n.method="throw",n.arg=c.arg)}}}(e,n,new _(o||[])),!0),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var f={};function h(){}function p(){}function y(){}var v={};u(v,i,(function(){return this}));var d=Object.getPrototypeOf,b=d&&d(d(E([])));b&&b!==r&&n.call(b,i)&&(v=b);var g=y.prototype=h.prototype=Object.create(v);function m(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,i,a,s){var u=l(t[o],t,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==gt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;u(this,"_invoke",(function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}),!0)}function w(e,r){var n=r.method,o=e.i[n];if(o===t)return r.delegate=null,"throw"===n&&e.i.return&&(r.method="return",r.arg=t,w(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=l(o,e.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,f;var a=i.arg;return a?a.done?(r[e.r]=a.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,f):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function S(t){this.tryEntries.push(t)}function k(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function _(t){this.tryEntries=[[-1]],t.forEach(S,this),this.reset(!0)}function E(e){if(null!=e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(gt(e)+" is not iterable")}return p.prototype=y,u(g,"constructor",y),u(y,"constructor",p),p.displayName=u(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},e.awrap=function(t){return{__await:t}},m(O.prototype),u(O.prototype,a,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new O(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),u(g,s,"Generator"),u(g,i,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},e.values=E,_.prototype={constructor:_,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t){a.type="throw",a.arg=e,r.next=t}for(var o=r.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],s=this.prev,u=i[1],c=i[2];if(-1===i[0])return n("end"),!1;if(!u&&!c)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=s){if(s<u)return this.method="next",this.arg=t,n(u),!0;if(s<c)return n(c),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break}}o&&("break"===t||"continue"===t)&&o[0]<=e&&e<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o[2],f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={i:E(e),r,n},"next"===this.method&&(this.arg=t),f}},e}function gt(t){return gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gt(t)}function mt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function Ot(t){var e=function(t){if("object"!=gt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var wt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},St=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._events=new Map,this.guidCallbacks=new Map,this._options=e,this._provider=r},e=[{key:"generateGUID",value:function(){return"event_".concat(!lt.randomUUID||e||t?yt(t,e,r):lt.randomUUID());var t,e,r}},{key:"_emitProgress",value:function(t,e,r,n){var o={stage:t,current:e,total:r,percent:r>0?Math.round(e/r*100):0,data:n};this.trigger("parse:progress",o),this.trigger("parse:".concat(t),o)}},{key:"load",value:function(){var t=this;return new Promise((function(e,r){var n,o=t._options;switch(t._emitProgress("start",0,0),gt(o)){case"string":try{n=q.parseAsObject(o,t._provider)}catch(t){return void r(t)}break;case"object":n=Object.assign({},o);break;default:return void r("Options must be String or Object")}var i=n&&"object"===gt(n)&&null!==n&&void 0!==n.pathData,s=n&&"object"===gt(n)&&null!==n&&void 0!==n.angleData;if(i){var u=n.pathData;t._emitProgress("pathData",0,u.length,{source:u}),t.angleData=a.parseToangleData(u),t._emitProgress("pathData",u.length,u.length,{source:u,processed:t.angleData})}else{if(!s)return void r("There is not any angle datas.");t.angleData=n.angleData,t._emitProgress("angleData",t.angleData.length,t.angleData.length,{processed:t.angleData})}n&&"object"===gt(n)&&null!==n&&Array.isArray(n.actions)?t.actions=n.actions:t.actions=[],n&&"object"===gt(n)&&null!==n&&void 0!==n.settings?(t.settings=n.settings,n&&"object"===gt(n)&&null!==n&&Array.isArray(n.decorations)?t.__decorations=n.decorations:t.__decorations=[],t.tiles=[],t._angleDir=-180,t._twirlCount=0,t._createArray(t.angleData.length,{angleData:t.angleData,actions:t.actions,decorations:t.__decorations}).then((function(r){t.tiles=r,t._emitProgress("complete",t.angleData.length,t.angleData.length),t.trigger("load",t),e(!0)})).catch((function(t){r(t)}))):r("There is no ADOFAI settings.")}))}},{key:"on",value:function(t,e){this._events.has(t)||this._events.set(t,[]);var r=this.generateGUID();return this._events.get(t).push({guid:r,callback:e}),this.guidCallbacks.set(r,{eventName:t,callback:e}),r}},{key:"trigger",value:function(t,e){this._events.has(t)&&this._events.get(t).forEach((function(t){return(0,t.callback)(e)}))}},{key:"off",value:function(t){if(this.guidCallbacks.has(t)){var e=this.guidCallbacks.get(t).eventName;if(this.guidCallbacks.delete(t),this._events.has(e)){var r=this._events.get(e),n=r.findIndex((function(e){return e.guid===t}));-1!==n&&r.splice(n,1)}}}},{key:"_createArray",value:function(t,e){return r=this,n=void 0,o=void 0,i=bt().mark((function r(){var n,o,i,a,s;return bt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=[],o=Math.max(1,Math.floor(t/100)),i=0;case 3:if(!(i<t)){r.next=15;break}if(a=this._parseAngle(e.angleData,i,this._twirlCount%2),s={direction:e.angleData[i],_lastdir:e.angleData[i-1]||0,actions:this._filterByFloor(e.actions,i),angle:a,addDecorations:this._filterByFloorwithDeco(e.decorations,i),twirl:this._twirlCount,extraProps:{}},n.push(s),i%o!==0&&i!==t-1){r.next=12;break}if(this._emitProgress("relativeAngle",i+1,t,{tileIndex:i,tile:s,angle:e.angleData[i],relativeAngle:a}),i%(10*o)!=0){r.next=12;break}return r.next=12,new Promise((function(t){return setTimeout(t,0)}));case 12:i++,r.next=3;break;case 15:return r.abrupt("return",n);case 16:case"end":return r.stop()}}),r,this)})),new(o||(o=Promise))((function(t,e){function a(t){try{u(i.next(t))}catch(t){e(t)}}function s(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(a,s)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i}},{key:"_changeAngle",value:function(){var t=this,e=0;return this.tiles.map((function(r){return e++,r.angle=t._parsechangedAngle(r.direction,e,r.twirl,r._lastdir),r}))}},{key:"_normalizeAngle",value:function(t){return(t%360+360)%360}},{key:"_parsechangedAngle",value:function(t,e,r,n){var o=0;if(0===e&&(this._angleDir=180),999===t)this._angleDir=this._normalizeAngle(n),isNaN(this._angleDir)&&(this._angleDir=0),o=0;else{var i=this._normalizeAngle(this._angleDir-t);0===(o=0===r?i:this._normalizeAngle(360-i))&&(o=360),this._angleDir=this._normalizeAngle(t+180)}return o}},{key:"_filterByFloor",value:function(t,e){if(!Array.isArray(t))return[];var r=t.filter((function(t){return t.floor===e}));return this._twirlCount+=r.filter((function(t){return"Twirl"===t.eventType})).length,r.map((function(t){return t.floor,wt(t,["floor"])}))}},{key:"_flattenAngleDatas",value:function(t){return t.map((function(t){return t.direction}))}},{key:"_flattenActionsWithFloor",value:function(t){return t.flatMap((function(t,e){return(Array.isArray(null==t?void 0:t.actions)?t.actions:[]).map((function(t){t.floor;var r=wt(t,["floor"]);return Object.assign({floor:e},r)}))}))}},{key:"_filterByFloorwithDeco",value:function(t,e){return Array.isArray(t)?t.filter((function(t){return t.floor===e})).map((function(t){return t.floor,wt(t,["floor"])})):[]}},{key:"_flattenDecorationsWithFloor",value:function(t){return t.flatMap((function(t,e){return(Array.isArray(null==t?void 0:t.addDecorations)?t.addDecorations:[]).map((function(t){t.floor;var r=wt(t,["floor"]);return Object.assign({floor:e},r)}))}))}},{key:"_parseAngle",value:function(t,e,r){var n=0;if(0===e&&(this._angleDir=180),999===t[e])this._angleDir=this._normalizeAngle(t[e-1]),isNaN(this._angleDir)&&(this._angleDir=0),n=0;else{var o=this._normalizeAngle(this._angleDir-t[e]);0===(n=0===r?o:this._normalizeAngle(360-o))&&(n=360),this._angleDir=this._normalizeAngle(t[e]+180)}return n}},{key:"filterActionsByEventType",value:function(t){return Object.entries(this.tiles).flatMap((function(t){var e=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||vt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),r=e[0],n=e[1];return(Array.isArray(n.actions)?n.actions:[]).map((function(t){return{b:t,index:r}}))})).filter((function(e){return e.b.eventType===t})).map((function(t){var e=t.b,r=t.index;return{index:Number(r),action:e}}))}},{key:"getActionsByIndex",value:function(t,e){var r=this.filterActionsByEventType(t).filter((function(t){return t.index===e}));return{count:r.length,actions:r.map((function(t){return t.action}))}}},{key:"calculateTileCoordinates",value:function(){console.warn("calculateTileCoordinates is deprecated. Use calculateTilePosition instead.")}},{key:"calculateTilePosition",value:function(){var t,e=this.angleData,r=this.tiles.length,n=[],o=[0,0],i=new Map,a=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=vt(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(a)throw o}}}}(this.actions);try{for(a.s();!(t=a.n()).done;){var s=t.value;"PositionTrack"===s.eventType&&s.positionOffset&&!0!==s.editorOnly&&"Enabled"!==s.editorOnly&&i.set(s.floor,s)}}catch(t){a.e(t)}finally{a.f()}this._emitProgress("tilePosition",0,r);for(var u=new Array(r),c=0;c<r;c++)u[c]=999===e[c]?e[c-1]+180:e[c];for(var l=Math.max(100,Math.floor(r/100)),f=0;f<=r;f++){var h=f===r,p=h?u[f-1]||0:u[f],y=0===f?0:u[f-1]||0,v=this.tiles[f],d=i.get(f);(null==d?void 0:d.positionOffset)&&(o[0]+=d.positionOffset[0],o[1]+=d.positionOffset[1]);var b=[o[0],o[1]];n.push(b),v&&(v.position=b,v.extraProps.angle1=p,v.extraProps.angle2=y-180,v.extraProps.cangle=h?u[f-1]+180:u[f]);var g=p*Math.PI/180;o[0]+=Math.cos(g),o[1]+=Math.sin(g),(f%l===0||h)&&this._emitProgress("tilePosition",f,r,{tileIndex:f,tile:v,position:b,angle:p})}return this._emitProgress("tilePosition",r,r,{processed:n.flat()}),n}},{key:"floorOperation",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{type:"append",direction:0};switch(t.type){case"append":this.appendFloor(t);break;case"insert":"number"==typeof t.id&&this.tiles.splice(t.id,0,{direction:t.direction||0,angle:0,actions:[],addDecorations:[],_lastdir:this.tiles[t.id-1].direction,twirl:this.tiles[t.id-1].twirl});break;case"delete":"number"==typeof t.id&&this.tiles.splice(t.id,1)}this._changeAngle()}},{key:"appendFloor",value:function(t){this.tiles.push({direction:t.direction,angle:0,actions:[],addDecorations:[],_lastdir:this.tiles[this.tiles.length-1].direction,twirl:this.tiles[this.tiles.length-1].twirl,extraProps:{}}),this._changeAngle()}},{key:"clearDeco",value:function(){return this.tiles=st(this.tiles),!0}},{key:"clearEffect",value:function(t){this.clearEvent(n[t])}},{key:"clearEvent",value:function(t){t.type==et.include?this.tiles=ct(t.events,this.tiles):t.type==et.exclude&&(this.tiles=ut(t.events,this.tiles))}},{key:"export",value:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i={angleData:this._flattenAngleDatas(this.tiles),settings:this.settings,actions:this._flattenActionsWithFloor(this.tiles),decorations:this._flattenDecorationsWithFloor(this.tiles)};return"object"===t?i:tt(i,e,r,n,o)}}],e&&mt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();return e})()));
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "adofai",
3
- "version": "2.11.1",
4
- "main": "dist/src/index.js",
5
- "types": "dist/src/index.d.ts",
6
- "scripts": {
7
- "webpack": "webpack",
8
- "tsc": "tsc",
9
- "build": "webpack && pnpm tsc"
10
- },
11
- "keywords": [
12
- "adofai",
13
- "adofai-js",
14
- "adofai-ts",
15
- "adofai-ts-lib"
16
- ],
17
- "files": [
18
- "dist"
19
- ],
20
- "author": "Xbodwf",
21
- "license": "BSD-3-Clause",
22
- "homepage": "https://xbodwf.github.io/packages/adofai-js/",
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/Xbodwf/ADOFAI-JS.git"
26
- },
27
- "bugs": "https://github.com/Xbodwf/ADOFAI-JS/issues",
28
- "description": "A Javascript library for ADOFAI levels.",
29
- "devDependencies": {
30
- "@babel/core": "^7.27.1",
31
- "@babel/preset-env": "^7.27.2",
32
- "@types/node": "^20.11.0",
33
- "babel-loader": "^10.0.0",
34
- "ts-loader": "^9.5.1",
35
- "typescript": "^5.9.3",
36
- "webpack": "^5.99.9",
37
- "webpack-cli": "^6.0.1"
38
- },
39
- "dependencies": {
40
- "uuid": "^13.0.0"
41
- }
42
- }
1
+ {
2
+ "name": "adofai",
3
+ "version": "2.11.2",
4
+ "main": "dist/src/index.js",
5
+ "types": "dist/src/index.d.ts",
6
+ "scripts": {
7
+ "webpack": "webpack",
8
+ "tsc": "tsc",
9
+ "build": "webpack && pnpm tsc"
10
+ },
11
+ "keywords": [
12
+ "adofai",
13
+ "adofai-js",
14
+ "adofai-ts",
15
+ "adofai-ts-lib"
16
+ ],
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "author": "Xbodwf",
21
+ "license": "BSD-3-Clause",
22
+ "homepage": "https://xbodwf.github.io/packages/adofai-js/",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Xbodwf/ADOFAI-JS.git"
26
+ },
27
+ "bugs": "https://github.com/Xbodwf/ADOFAI-JS/issues",
28
+ "description": "A Javascript library for ADOFAI levels.",
29
+ "devDependencies": {
30
+ "@babel/core": "^7.27.1",
31
+ "@babel/preset-env": "^7.27.2",
32
+ "@types/node": "^20.11.0",
33
+ "babel-loader": "^10.0.0",
34
+ "ts-loader": "^9.5.1",
35
+ "typescript": "^5.9.3",
36
+ "webpack": "^5.99.9",
37
+ "webpack-cli": "^6.0.1"
38
+ },
39
+ "dependencies": {
40
+ "uuid": "^13.0.0"
41
+ }
42
+ }