webgal-parser 4.3.13-1 → 4.3.13-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.
@@ -0,0 +1,1710 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var commandType;
6
+ (function (commandType) {
7
+ commandType[commandType["say"] = 0] = "say";
8
+ commandType[commandType["changeBg"] = 1] = "changeBg";
9
+ commandType[commandType["changeFigure"] = 2] = "changeFigure";
10
+ commandType[commandType["bgm"] = 3] = "bgm";
11
+ commandType[commandType["video"] = 4] = "video";
12
+ commandType[commandType["pixi"] = 5] = "pixi";
13
+ commandType[commandType["pixiInit"] = 6] = "pixiInit";
14
+ commandType[commandType["intro"] = 7] = "intro";
15
+ commandType[commandType["miniAvatar"] = 8] = "miniAvatar";
16
+ commandType[commandType["changeScene"] = 9] = "changeScene";
17
+ commandType[commandType["choose"] = 10] = "choose";
18
+ commandType[commandType["end"] = 11] = "end";
19
+ commandType[commandType["setComplexAnimation"] = 12] = "setComplexAnimation";
20
+ commandType[commandType["setFilter"] = 13] = "setFilter";
21
+ commandType[commandType["label"] = 14] = "label";
22
+ commandType[commandType["jumpLabel"] = 15] = "jumpLabel";
23
+ commandType[commandType["chooseLabel"] = 16] = "chooseLabel";
24
+ commandType[commandType["setVar"] = 17] = "setVar";
25
+ commandType[commandType["if"] = 18] = "if";
26
+ commandType[commandType["callScene"] = 19] = "callScene";
27
+ commandType[commandType["showVars"] = 20] = "showVars";
28
+ commandType[commandType["unlockCg"] = 21] = "unlockCg";
29
+ commandType[commandType["unlockBgm"] = 22] = "unlockBgm";
30
+ commandType[commandType["filmMode"] = 23] = "filmMode";
31
+ commandType[commandType["setTextbox"] = 24] = "setTextbox";
32
+ commandType[commandType["setAnimation"] = 25] = "setAnimation";
33
+ commandType[commandType["playEffect"] = 26] = "playEffect";
34
+ commandType[commandType["setTempAnimation"] = 27] = "setTempAnimation";
35
+ commandType[commandType["comment"] = 28] = "comment";
36
+ })(commandType || (commandType = {}));
37
+
38
+ /**
39
+ * 处理命令
40
+ * @param commandRaw
41
+ * @param ADD_NEXT_ARG_LIST
42
+ * @param SCRIPT_CONFIG
43
+ * @return {parsedCommand} 处理后的命令
44
+ */
45
+ const commandParser = (commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
46
+ let returnCommand = {
47
+ type: commandType.say,
48
+ additionalArgs: []
49
+ };
50
+ // 开始处理命令内容
51
+ const type = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
52
+ returnCommand.type = type;
53
+ // 如果是对话,加上额外的参数
54
+ if (type === commandType.say) {
55
+ returnCommand.additionalArgs.push({
56
+ key: "speaker",
57
+ value: commandRaw
58
+ });
59
+ }
60
+ returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
61
+ return returnCommand;
62
+ };
63
+ /**
64
+ * 根据command原始值判断是什么命令
65
+ * @param command command原始值
66
+ * @param ADD_NEXT_ARG_LIST
67
+ * @param SCRIPT_CONFIG
68
+ * @return {commandType} 得到的command类型
69
+ */
70
+ function getCommandType(command, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
71
+ // if (command.match(/if/)) {
72
+ // return commandType.if;
73
+ // }
74
+ const commandMap = new Map();
75
+ SCRIPT_CONFIG.forEach((e) => {
76
+ commandMap.set(e.scriptString, e.scriptType);
77
+ });
78
+ if (commandMap.has(command)) {
79
+ return commandMap.get(command);
80
+ }
81
+ else
82
+ return commandType.say;
83
+ }
84
+ function addNextArg(commandToParse, thisCommandType, ADD_NEXT_ARG_LIST) {
85
+ if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
86
+ commandToParse.additionalArgs.push({
87
+ key: "next",
88
+ value: true
89
+ });
90
+ }
91
+ return commandToParse;
92
+ }
93
+
94
+ /**
95
+ * 内置资源类型的枚举
96
+ */
97
+ var fileType;
98
+ (function (fileType) {
99
+ fileType[fileType["background"] = 0] = "background";
100
+ fileType[fileType["bgm"] = 1] = "bgm";
101
+ fileType[fileType["figure"] = 2] = "figure";
102
+ fileType[fileType["scene"] = 3] = "scene";
103
+ fileType[fileType["tex"] = 4] = "tex";
104
+ fileType[fileType["vocal"] = 5] = "vocal";
105
+ fileType[fileType["video"] = 6] = "video";
106
+ })(fileType || (fileType = {}));
107
+
108
+ /**
109
+ * 参数解析器
110
+ * @param argsRaw 原始参数字符串
111
+ * @param assetSetter
112
+ * @return {Array<arg>} 解析后的参数列表
113
+ */
114
+ function argsParser(argsRaw, assetSetter) {
115
+ const returnArrayList = [];
116
+ // 处理参数
117
+ // 不要去空格
118
+ let newArgsRaw = argsRaw.replace(/ /g, " ");
119
+ // 分割参数列表
120
+ let rawArgsList = newArgsRaw.split(" -");
121
+ // 去除空字符串
122
+ rawArgsList = rawArgsList.filter((e) => {
123
+ return e !== "";
124
+ });
125
+ rawArgsList.forEach((e) => {
126
+ const argName = e.split("=")[0];
127
+ const argValue = e.split("=")[1];
128
+ // 判断是不是语音参数
129
+ if (e.match(/.ogg|.mp3|.wav/)) {
130
+ returnArrayList.push({
131
+ key: "vocal",
132
+ value: assetSetter(e, fileType.vocal)
133
+ });
134
+ }
135
+ else {
136
+ // 判断是不是省略参数
137
+ if (argValue === undefined) {
138
+ returnArrayList.push({
139
+ key: argName,
140
+ value: true
141
+ });
142
+ }
143
+ else {
144
+ // 是字符串描述的布尔值
145
+ if (argValue === "true" || argValue === "false") {
146
+ returnArrayList.push({
147
+ key: argName,
148
+ value: argValue === "true"
149
+ });
150
+ }
151
+ else {
152
+ // 是数字
153
+ if (!isNaN(Number(argValue))) {
154
+ returnArrayList.push({
155
+ key: argName,
156
+ value: Number(argValue)
157
+ });
158
+ }
159
+ else {
160
+ // 是普通参数
161
+ returnArrayList.push({
162
+ key: argName,
163
+ value: argValue
164
+ });
165
+ }
166
+ }
167
+ }
168
+ }
169
+ });
170
+ return returnArrayList;
171
+ }
172
+
173
+ /**
174
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
175
+ * @param contentRaw 原始语句内容
176
+ * @param type 语句类型
177
+ * @param assetSetter
178
+ * @return {string} 解析后的语句内容
179
+ */
180
+ const contentParser = (contentRaw, type, assetSetter) => {
181
+ if (contentRaw === "none" || contentRaw === "") {
182
+ return "";
183
+ }
184
+ switch (type) {
185
+ case commandType.playEffect:
186
+ return assetSetter(contentRaw, fileType.vocal);
187
+ case commandType.changeBg:
188
+ return assetSetter(contentRaw, fileType.background);
189
+ case commandType.changeFigure:
190
+ return assetSetter(contentRaw, fileType.figure);
191
+ case commandType.bgm:
192
+ return assetSetter(contentRaw, fileType.bgm);
193
+ case commandType.callScene:
194
+ return assetSetter(contentRaw, fileType.scene);
195
+ case commandType.changeScene:
196
+ return assetSetter(contentRaw, fileType.scene);
197
+ case commandType.miniAvatar:
198
+ return assetSetter(contentRaw, fileType.figure);
199
+ case commandType.video:
200
+ return assetSetter(contentRaw, fileType.video);
201
+ case commandType.choose:
202
+ return getChooseContent(contentRaw, assetSetter);
203
+ case commandType.unlockBgm:
204
+ return assetSetter(contentRaw, fileType.bgm);
205
+ case commandType.unlockCg:
206
+ return assetSetter(contentRaw, fileType.background);
207
+ default:
208
+ return contentRaw;
209
+ }
210
+ };
211
+ function getChooseContent(contentRaw, assetSetter) {
212
+ const chooseList = contentRaw.split("|");
213
+ const chooseKeyList = [];
214
+ const chooseValueList = [];
215
+ for (const e of chooseList) {
216
+ chooseKeyList.push(e.split(":")[0]);
217
+ chooseValueList.push(e.split(":")[1]);
218
+ }
219
+ const parsedChooseList = chooseValueList.map((e) => {
220
+ if (e.match(/\./)) {
221
+ return assetSetter(e, fileType.scene);
222
+ }
223
+ else {
224
+ return e;
225
+ }
226
+ });
227
+ let ret = "";
228
+ for (let i = 0; i < chooseKeyList.length; i++) {
229
+ if (i !== 0) {
230
+ ret = ret + "|";
231
+ }
232
+ ret = ret + `${chooseKeyList[i]}:${parsedChooseList[i]}`;
233
+ }
234
+ return ret;
235
+ }
236
+
237
+ /**
238
+ * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
239
+ * @param command 语句类型
240
+ * @param content 语句内容
241
+ * @param args 参数列表
242
+ * @return {Array<IAsset>} 语句携带的参数列表
243
+ */
244
+ const assetsScanner = (command, content, args) => {
245
+ const returnAssetsList = [];
246
+ if (command === commandType.say) {
247
+ args.forEach((e) => {
248
+ if (e.key === 'vocal') {
249
+ returnAssetsList.push({
250
+ name: e.value,
251
+ url: e.value,
252
+ lineNumber: 0,
253
+ type: fileType.vocal,
254
+ });
255
+ }
256
+ });
257
+ }
258
+ if (content === 'none' || content === '') {
259
+ return returnAssetsList;
260
+ }
261
+ // 处理语句携带的资源
262
+ if (command === commandType.changeBg) {
263
+ returnAssetsList.push({
264
+ name: content,
265
+ url: content,
266
+ lineNumber: 0,
267
+ type: fileType.background,
268
+ });
269
+ }
270
+ if (command === commandType.changeFigure) {
271
+ returnAssetsList.push({
272
+ name: content,
273
+ url: content,
274
+ lineNumber: 0,
275
+ type: fileType.figure,
276
+ });
277
+ }
278
+ if (command === commandType.miniAvatar) {
279
+ returnAssetsList.push({
280
+ name: content,
281
+ url: content,
282
+ lineNumber: 0,
283
+ type: fileType.figure,
284
+ });
285
+ }
286
+ if (command === commandType.video) {
287
+ returnAssetsList.push({
288
+ name: content,
289
+ url: content,
290
+ lineNumber: 0,
291
+ type: fileType.video,
292
+ });
293
+ }
294
+ if (command === commandType.bgm) {
295
+ returnAssetsList.push({
296
+ name: content,
297
+ url: content,
298
+ lineNumber: 0,
299
+ type: fileType.bgm,
300
+ });
301
+ }
302
+ return returnAssetsList;
303
+ };
304
+
305
+ /**
306
+ * 扫描子场景
307
+ * @param content 语句内容
308
+ * @return {Array<string>} 子场景列表
309
+ */
310
+ const subSceneScanner = (command, content) => {
311
+ const subSceneList = [];
312
+ if (command === commandType.changeScene || command === commandType.callScene) {
313
+ subSceneList.push(content);
314
+ }
315
+ if (command === commandType.choose) {
316
+ const chooseList = content.split('|');
317
+ const chooseValue = chooseList.map((e) => e.split(':')[1]);
318
+ chooseValue.forEach((e) => {
319
+ if (e.match(/\./)) {
320
+ subSceneList.push(e);
321
+ }
322
+ });
323
+ }
324
+ return subSceneList;
325
+ };
326
+
327
+ /**
328
+ * 语句解析器
329
+ * @param sentenceRaw 原始语句
330
+ * @param assetSetter
331
+ * @param ADD_NEXT_ARG_LIST
332
+ * @param SCRIPT_CONFIG
333
+ */
334
+ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
335
+ let command; // 默认为对话
336
+ let content; // 语句内容
337
+ let subScene; // 语句携带的子场景(可能没有)
338
+ const args = []; // 语句参数列表
339
+ let sentenceAssets; // 语句携带的资源列表
340
+ let parsedCommand; // 解析后的命令
341
+ let commandRaw;
342
+ // 正式开始解析
343
+ // 去分号,前面已做,这里不再需要
344
+ let newSentenceRaw = sentenceRaw.split(";")[0];
345
+ if (newSentenceRaw === "") {
346
+ // 注释提前返回
347
+ return {
348
+ command: commandType.comment,
349
+ commandRaw: "comment",
350
+ content: sentenceRaw.split(";")[1] ?? "",
351
+ args: [{ key: "next", value: true }],
352
+ sentenceAssets: [],
353
+ subScene: [] // 语句携带的子场景
354
+ };
355
+ }
356
+ // 截取命令
357
+ const getCommandResult = /:/.exec(newSentenceRaw);
358
+ /**
359
+ * 拆分命令和语句,同时处理连续对话。
360
+ */
361
+ // 没有command,说明这是一条连续对话或单条语句
362
+ if (getCommandResult === null) {
363
+ commandRaw = newSentenceRaw;
364
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
365
+ command = parsedCommand.type;
366
+ for (const e of parsedCommand.additionalArgs) {
367
+ // 由于是连续对话,所以我们去除 speaker 参数。
368
+ if (command === commandType.say && e.key === "speaker") {
369
+ continue;
370
+ }
371
+ args.push(e);
372
+ }
373
+ }
374
+ else {
375
+ commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
376
+ // 划分命令区域和content区域
377
+ newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
378
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
379
+ command = parsedCommand.type;
380
+ for (const e of parsedCommand.additionalArgs) {
381
+ args.push(e);
382
+ }
383
+ }
384
+ // 截取参数区域
385
+ const getArgsResult = / -/.exec(newSentenceRaw);
386
+ // 获取到参数
387
+ if (getArgsResult) {
388
+ const argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
389
+ newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
390
+ for (const e of argsParser(argsRaw, assetSetter)) {
391
+ args.push(e);
392
+ }
393
+ }
394
+ content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
395
+ sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
396
+ subScene = subSceneScanner(command, content); // 扫描语句携带子场景
397
+ return {
398
+ command: command,
399
+ commandRaw: commandRaw,
400
+ content: content,
401
+ args: args,
402
+ sentenceAssets: sentenceAssets,
403
+ subScene: subScene // 语句携带的子场景
404
+ };
405
+ };
406
+
407
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
408
+
409
+ /** Detect free variable `global` from Node.js. */
410
+
411
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
412
+
413
+ var _freeGlobal = freeGlobal$1;
414
+
415
+ var freeGlobal = _freeGlobal;
416
+
417
+ /** Detect free variable `self`. */
418
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
419
+
420
+ /** Used as a reference to the global object. */
421
+ var root$4 = freeGlobal || freeSelf || Function('return this')();
422
+
423
+ var _root = root$4;
424
+
425
+ var root$3 = _root;
426
+
427
+ /** Built-in value references. */
428
+ var Symbol$2 = root$3.Symbol;
429
+
430
+ var _Symbol = Symbol$2;
431
+
432
+ var Symbol$1 = _Symbol;
433
+
434
+ /** Used for built-in method references. */
435
+ var objectProto$4 = Object.prototype;
436
+
437
+ /** Used to check objects for own properties. */
438
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
439
+
440
+ /**
441
+ * Used to resolve the
442
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
443
+ * of values.
444
+ */
445
+ var nativeObjectToString$1 = objectProto$4.toString;
446
+
447
+ /** Built-in value references. */
448
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
449
+
450
+ /**
451
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
452
+ *
453
+ * @private
454
+ * @param {*} value The value to query.
455
+ * @returns {string} Returns the raw `toStringTag`.
456
+ */
457
+ function getRawTag$1(value) {
458
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
459
+ tag = value[symToStringTag$1];
460
+
461
+ try {
462
+ value[symToStringTag$1] = undefined;
463
+ var unmasked = true;
464
+ } catch (e) {}
465
+
466
+ var result = nativeObjectToString$1.call(value);
467
+ if (unmasked) {
468
+ if (isOwn) {
469
+ value[symToStringTag$1] = tag;
470
+ } else {
471
+ delete value[symToStringTag$1];
472
+ }
473
+ }
474
+ return result;
475
+ }
476
+
477
+ var _getRawTag = getRawTag$1;
478
+
479
+ /** Used for built-in method references. */
480
+
481
+ var objectProto$3 = Object.prototype;
482
+
483
+ /**
484
+ * Used to resolve the
485
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
486
+ * of values.
487
+ */
488
+ var nativeObjectToString = objectProto$3.toString;
489
+
490
+ /**
491
+ * Converts `value` to a string using `Object.prototype.toString`.
492
+ *
493
+ * @private
494
+ * @param {*} value The value to convert.
495
+ * @returns {string} Returns the converted string.
496
+ */
497
+ function objectToString$1(value) {
498
+ return nativeObjectToString.call(value);
499
+ }
500
+
501
+ var _objectToString = objectToString$1;
502
+
503
+ var Symbol = _Symbol,
504
+ getRawTag = _getRawTag,
505
+ objectToString = _objectToString;
506
+
507
+ /** `Object#toString` result references. */
508
+ var nullTag = '[object Null]',
509
+ undefinedTag = '[object Undefined]';
510
+
511
+ /** Built-in value references. */
512
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
513
+
514
+ /**
515
+ * The base implementation of `getTag` without fallbacks for buggy environments.
516
+ *
517
+ * @private
518
+ * @param {*} value The value to query.
519
+ * @returns {string} Returns the `toStringTag`.
520
+ */
521
+ function baseGetTag$1(value) {
522
+ if (value == null) {
523
+ return value === undefined ? undefinedTag : nullTag;
524
+ }
525
+ return (symToStringTag && symToStringTag in Object(value))
526
+ ? getRawTag(value)
527
+ : objectToString(value);
528
+ }
529
+
530
+ var _baseGetTag = baseGetTag$1;
531
+
532
+ /**
533
+ * Checks if `value` is the
534
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
535
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
536
+ *
537
+ * @static
538
+ * @memberOf _
539
+ * @since 0.1.0
540
+ * @category Lang
541
+ * @param {*} value The value to check.
542
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
543
+ * @example
544
+ *
545
+ * _.isObject({});
546
+ * // => true
547
+ *
548
+ * _.isObject([1, 2, 3]);
549
+ * // => true
550
+ *
551
+ * _.isObject(_.noop);
552
+ * // => true
553
+ *
554
+ * _.isObject(null);
555
+ * // => false
556
+ */
557
+
558
+ function isObject$2(value) {
559
+ var type = typeof value;
560
+ return value != null && (type == 'object' || type == 'function');
561
+ }
562
+
563
+ var isObject_1 = isObject$2;
564
+
565
+ var baseGetTag = _baseGetTag,
566
+ isObject$1 = isObject_1;
567
+
568
+ /** `Object#toString` result references. */
569
+ var asyncTag = '[object AsyncFunction]',
570
+ funcTag = '[object Function]',
571
+ genTag = '[object GeneratorFunction]',
572
+ proxyTag = '[object Proxy]';
573
+
574
+ /**
575
+ * Checks if `value` is classified as a `Function` object.
576
+ *
577
+ * @static
578
+ * @memberOf _
579
+ * @since 0.1.0
580
+ * @category Lang
581
+ * @param {*} value The value to check.
582
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
583
+ * @example
584
+ *
585
+ * _.isFunction(_);
586
+ * // => true
587
+ *
588
+ * _.isFunction(/abc/);
589
+ * // => false
590
+ */
591
+ function isFunction$1(value) {
592
+ if (!isObject$1(value)) {
593
+ return false;
594
+ }
595
+ // The use of `Object#toString` avoids issues with the `typeof` operator
596
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
597
+ var tag = baseGetTag(value);
598
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
599
+ }
600
+
601
+ var isFunction_1 = isFunction$1;
602
+
603
+ var root$2 = _root;
604
+
605
+ /** Used to detect overreaching core-js shims. */
606
+ var coreJsData$1 = root$2['__core-js_shared__'];
607
+
608
+ var _coreJsData = coreJsData$1;
609
+
610
+ var coreJsData = _coreJsData;
611
+
612
+ /** Used to detect methods masquerading as native. */
613
+ var maskSrcKey = (function() {
614
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
615
+ return uid ? ('Symbol(src)_1.' + uid) : '';
616
+ }());
617
+
618
+ /**
619
+ * Checks if `func` has its source masked.
620
+ *
621
+ * @private
622
+ * @param {Function} func The function to check.
623
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
624
+ */
625
+ function isMasked$1(func) {
626
+ return !!maskSrcKey && (maskSrcKey in func);
627
+ }
628
+
629
+ var _isMasked = isMasked$1;
630
+
631
+ /** Used for built-in method references. */
632
+
633
+ var funcProto$1 = Function.prototype;
634
+
635
+ /** Used to resolve the decompiled source of functions. */
636
+ var funcToString$1 = funcProto$1.toString;
637
+
638
+ /**
639
+ * Converts `func` to its source code.
640
+ *
641
+ * @private
642
+ * @param {Function} func The function to convert.
643
+ * @returns {string} Returns the source code.
644
+ */
645
+ function toSource$1(func) {
646
+ if (func != null) {
647
+ try {
648
+ return funcToString$1.call(func);
649
+ } catch (e) {}
650
+ try {
651
+ return (func + '');
652
+ } catch (e) {}
653
+ }
654
+ return '';
655
+ }
656
+
657
+ var _toSource = toSource$1;
658
+
659
+ var isFunction = isFunction_1,
660
+ isMasked = _isMasked,
661
+ isObject = isObject_1,
662
+ toSource = _toSource;
663
+
664
+ /**
665
+ * Used to match `RegExp`
666
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
667
+ */
668
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
669
+
670
+ /** Used to detect host constructors (Safari). */
671
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
672
+
673
+ /** Used for built-in method references. */
674
+ var funcProto = Function.prototype,
675
+ objectProto$2 = Object.prototype;
676
+
677
+ /** Used to resolve the decompiled source of functions. */
678
+ var funcToString = funcProto.toString;
679
+
680
+ /** Used to check objects for own properties. */
681
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
682
+
683
+ /** Used to detect if a method is native. */
684
+ var reIsNative = RegExp('^' +
685
+ funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
686
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
687
+ );
688
+
689
+ /**
690
+ * The base implementation of `_.isNative` without bad shim checks.
691
+ *
692
+ * @private
693
+ * @param {*} value The value to check.
694
+ * @returns {boolean} Returns `true` if `value` is a native function,
695
+ * else `false`.
696
+ */
697
+ function baseIsNative$1(value) {
698
+ if (!isObject(value) || isMasked(value)) {
699
+ return false;
700
+ }
701
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
702
+ return pattern.test(toSource(value));
703
+ }
704
+
705
+ var _baseIsNative = baseIsNative$1;
706
+
707
+ /**
708
+ * Gets the value at `key` of `object`.
709
+ *
710
+ * @private
711
+ * @param {Object} [object] The object to query.
712
+ * @param {string} key The key of the property to get.
713
+ * @returns {*} Returns the property value.
714
+ */
715
+
716
+ function getValue$1(object, key) {
717
+ return object == null ? undefined : object[key];
718
+ }
719
+
720
+ var _getValue = getValue$1;
721
+
722
+ var baseIsNative = _baseIsNative,
723
+ getValue = _getValue;
724
+
725
+ /**
726
+ * Gets the native function at `key` of `object`.
727
+ *
728
+ * @private
729
+ * @param {Object} object The object to query.
730
+ * @param {string} key The key of the method to get.
731
+ * @returns {*} Returns the function if it's native, else `undefined`.
732
+ */
733
+ function getNative$3(object, key) {
734
+ var value = getValue(object, key);
735
+ return baseIsNative(value) ? value : undefined;
736
+ }
737
+
738
+ var _getNative = getNative$3;
739
+
740
+ var getNative$2 = _getNative;
741
+
742
+ /* Built-in method references that are verified to be native. */
743
+ var nativeCreate$4 = getNative$2(Object, 'create');
744
+
745
+ var _nativeCreate = nativeCreate$4;
746
+
747
+ var nativeCreate$3 = _nativeCreate;
748
+
749
+ /**
750
+ * Removes all key-value entries from the hash.
751
+ *
752
+ * @private
753
+ * @name clear
754
+ * @memberOf Hash
755
+ */
756
+ function hashClear$1() {
757
+ this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
758
+ this.size = 0;
759
+ }
760
+
761
+ var _hashClear = hashClear$1;
762
+
763
+ /**
764
+ * Removes `key` and its value from the hash.
765
+ *
766
+ * @private
767
+ * @name delete
768
+ * @memberOf Hash
769
+ * @param {Object} hash The hash to modify.
770
+ * @param {string} key The key of the value to remove.
771
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
772
+ */
773
+
774
+ function hashDelete$1(key) {
775
+ var result = this.has(key) && delete this.__data__[key];
776
+ this.size -= result ? 1 : 0;
777
+ return result;
778
+ }
779
+
780
+ var _hashDelete = hashDelete$1;
781
+
782
+ var nativeCreate$2 = _nativeCreate;
783
+
784
+ /** Used to stand-in for `undefined` hash values. */
785
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
786
+
787
+ /** Used for built-in method references. */
788
+ var objectProto$1 = Object.prototype;
789
+
790
+ /** Used to check objects for own properties. */
791
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
792
+
793
+ /**
794
+ * Gets the hash value for `key`.
795
+ *
796
+ * @private
797
+ * @name get
798
+ * @memberOf Hash
799
+ * @param {string} key The key of the value to get.
800
+ * @returns {*} Returns the entry value.
801
+ */
802
+ function hashGet$1(key) {
803
+ var data = this.__data__;
804
+ if (nativeCreate$2) {
805
+ var result = data[key];
806
+ return result === HASH_UNDEFINED$2 ? undefined : result;
807
+ }
808
+ return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
809
+ }
810
+
811
+ var _hashGet = hashGet$1;
812
+
813
+ var nativeCreate$1 = _nativeCreate;
814
+
815
+ /** Used for built-in method references. */
816
+ var objectProto = Object.prototype;
817
+
818
+ /** Used to check objects for own properties. */
819
+ var hasOwnProperty = objectProto.hasOwnProperty;
820
+
821
+ /**
822
+ * Checks if a hash value for `key` exists.
823
+ *
824
+ * @private
825
+ * @name has
826
+ * @memberOf Hash
827
+ * @param {string} key The key of the entry to check.
828
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
829
+ */
830
+ function hashHas$1(key) {
831
+ var data = this.__data__;
832
+ return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
833
+ }
834
+
835
+ var _hashHas = hashHas$1;
836
+
837
+ var nativeCreate = _nativeCreate;
838
+
839
+ /** Used to stand-in for `undefined` hash values. */
840
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
841
+
842
+ /**
843
+ * Sets the hash `key` to `value`.
844
+ *
845
+ * @private
846
+ * @name set
847
+ * @memberOf Hash
848
+ * @param {string} key The key of the value to set.
849
+ * @param {*} value The value to set.
850
+ * @returns {Object} Returns the hash instance.
851
+ */
852
+ function hashSet$1(key, value) {
853
+ var data = this.__data__;
854
+ this.size += this.has(key) ? 0 : 1;
855
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
856
+ return this;
857
+ }
858
+
859
+ var _hashSet = hashSet$1;
860
+
861
+ var hashClear = _hashClear,
862
+ hashDelete = _hashDelete,
863
+ hashGet = _hashGet,
864
+ hashHas = _hashHas,
865
+ hashSet = _hashSet;
866
+
867
+ /**
868
+ * Creates a hash object.
869
+ *
870
+ * @private
871
+ * @constructor
872
+ * @param {Array} [entries] The key-value pairs to cache.
873
+ */
874
+ function Hash$1(entries) {
875
+ var index = -1,
876
+ length = entries == null ? 0 : entries.length;
877
+
878
+ this.clear();
879
+ while (++index < length) {
880
+ var entry = entries[index];
881
+ this.set(entry[0], entry[1]);
882
+ }
883
+ }
884
+
885
+ // Add methods to `Hash`.
886
+ Hash$1.prototype.clear = hashClear;
887
+ Hash$1.prototype['delete'] = hashDelete;
888
+ Hash$1.prototype.get = hashGet;
889
+ Hash$1.prototype.has = hashHas;
890
+ Hash$1.prototype.set = hashSet;
891
+
892
+ var _Hash = Hash$1;
893
+
894
+ /**
895
+ * Removes all key-value entries from the list cache.
896
+ *
897
+ * @private
898
+ * @name clear
899
+ * @memberOf ListCache
900
+ */
901
+
902
+ function listCacheClear$1() {
903
+ this.__data__ = [];
904
+ this.size = 0;
905
+ }
906
+
907
+ var _listCacheClear = listCacheClear$1;
908
+
909
+ /**
910
+ * Performs a
911
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
912
+ * comparison between two values to determine if they are equivalent.
913
+ *
914
+ * @static
915
+ * @memberOf _
916
+ * @since 4.0.0
917
+ * @category Lang
918
+ * @param {*} value The value to compare.
919
+ * @param {*} other The other value to compare.
920
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
921
+ * @example
922
+ *
923
+ * var object = { 'a': 1 };
924
+ * var other = { 'a': 1 };
925
+ *
926
+ * _.eq(object, object);
927
+ * // => true
928
+ *
929
+ * _.eq(object, other);
930
+ * // => false
931
+ *
932
+ * _.eq('a', 'a');
933
+ * // => true
934
+ *
935
+ * _.eq('a', Object('a'));
936
+ * // => false
937
+ *
938
+ * _.eq(NaN, NaN);
939
+ * // => true
940
+ */
941
+
942
+ function eq$1(value, other) {
943
+ return value === other || (value !== value && other !== other);
944
+ }
945
+
946
+ var eq_1 = eq$1;
947
+
948
+ var eq = eq_1;
949
+
950
+ /**
951
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
952
+ *
953
+ * @private
954
+ * @param {Array} array The array to inspect.
955
+ * @param {*} key The key to search for.
956
+ * @returns {number} Returns the index of the matched value, else `-1`.
957
+ */
958
+ function assocIndexOf$4(array, key) {
959
+ var length = array.length;
960
+ while (length--) {
961
+ if (eq(array[length][0], key)) {
962
+ return length;
963
+ }
964
+ }
965
+ return -1;
966
+ }
967
+
968
+ var _assocIndexOf = assocIndexOf$4;
969
+
970
+ var assocIndexOf$3 = _assocIndexOf;
971
+
972
+ /** Used for built-in method references. */
973
+ var arrayProto = Array.prototype;
974
+
975
+ /** Built-in value references. */
976
+ var splice = arrayProto.splice;
977
+
978
+ /**
979
+ * Removes `key` and its value from the list cache.
980
+ *
981
+ * @private
982
+ * @name delete
983
+ * @memberOf ListCache
984
+ * @param {string} key The key of the value to remove.
985
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
986
+ */
987
+ function listCacheDelete$1(key) {
988
+ var data = this.__data__,
989
+ index = assocIndexOf$3(data, key);
990
+
991
+ if (index < 0) {
992
+ return false;
993
+ }
994
+ var lastIndex = data.length - 1;
995
+ if (index == lastIndex) {
996
+ data.pop();
997
+ } else {
998
+ splice.call(data, index, 1);
999
+ }
1000
+ --this.size;
1001
+ return true;
1002
+ }
1003
+
1004
+ var _listCacheDelete = listCacheDelete$1;
1005
+
1006
+ var assocIndexOf$2 = _assocIndexOf;
1007
+
1008
+ /**
1009
+ * Gets the list cache value for `key`.
1010
+ *
1011
+ * @private
1012
+ * @name get
1013
+ * @memberOf ListCache
1014
+ * @param {string} key The key of the value to get.
1015
+ * @returns {*} Returns the entry value.
1016
+ */
1017
+ function listCacheGet$1(key) {
1018
+ var data = this.__data__,
1019
+ index = assocIndexOf$2(data, key);
1020
+
1021
+ return index < 0 ? undefined : data[index][1];
1022
+ }
1023
+
1024
+ var _listCacheGet = listCacheGet$1;
1025
+
1026
+ var assocIndexOf$1 = _assocIndexOf;
1027
+
1028
+ /**
1029
+ * Checks if a list cache value for `key` exists.
1030
+ *
1031
+ * @private
1032
+ * @name has
1033
+ * @memberOf ListCache
1034
+ * @param {string} key The key of the entry to check.
1035
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1036
+ */
1037
+ function listCacheHas$1(key) {
1038
+ return assocIndexOf$1(this.__data__, key) > -1;
1039
+ }
1040
+
1041
+ var _listCacheHas = listCacheHas$1;
1042
+
1043
+ var assocIndexOf = _assocIndexOf;
1044
+
1045
+ /**
1046
+ * Sets the list cache `key` to `value`.
1047
+ *
1048
+ * @private
1049
+ * @name set
1050
+ * @memberOf ListCache
1051
+ * @param {string} key The key of the value to set.
1052
+ * @param {*} value The value to set.
1053
+ * @returns {Object} Returns the list cache instance.
1054
+ */
1055
+ function listCacheSet$1(key, value) {
1056
+ var data = this.__data__,
1057
+ index = assocIndexOf(data, key);
1058
+
1059
+ if (index < 0) {
1060
+ ++this.size;
1061
+ data.push([key, value]);
1062
+ } else {
1063
+ data[index][1] = value;
1064
+ }
1065
+ return this;
1066
+ }
1067
+
1068
+ var _listCacheSet = listCacheSet$1;
1069
+
1070
+ var listCacheClear = _listCacheClear,
1071
+ listCacheDelete = _listCacheDelete,
1072
+ listCacheGet = _listCacheGet,
1073
+ listCacheHas = _listCacheHas,
1074
+ listCacheSet = _listCacheSet;
1075
+
1076
+ /**
1077
+ * Creates an list cache object.
1078
+ *
1079
+ * @private
1080
+ * @constructor
1081
+ * @param {Array} [entries] The key-value pairs to cache.
1082
+ */
1083
+ function ListCache$1(entries) {
1084
+ var index = -1,
1085
+ length = entries == null ? 0 : entries.length;
1086
+
1087
+ this.clear();
1088
+ while (++index < length) {
1089
+ var entry = entries[index];
1090
+ this.set(entry[0], entry[1]);
1091
+ }
1092
+ }
1093
+
1094
+ // Add methods to `ListCache`.
1095
+ ListCache$1.prototype.clear = listCacheClear;
1096
+ ListCache$1.prototype['delete'] = listCacheDelete;
1097
+ ListCache$1.prototype.get = listCacheGet;
1098
+ ListCache$1.prototype.has = listCacheHas;
1099
+ ListCache$1.prototype.set = listCacheSet;
1100
+
1101
+ var _ListCache = ListCache$1;
1102
+
1103
+ var getNative$1 = _getNative,
1104
+ root$1 = _root;
1105
+
1106
+ /* Built-in method references that are verified to be native. */
1107
+ var Map$2 = getNative$1(root$1, 'Map');
1108
+
1109
+ var _Map = Map$2;
1110
+
1111
+ var Hash = _Hash,
1112
+ ListCache = _ListCache,
1113
+ Map$1 = _Map;
1114
+
1115
+ /**
1116
+ * Removes all key-value entries from the map.
1117
+ *
1118
+ * @private
1119
+ * @name clear
1120
+ * @memberOf MapCache
1121
+ */
1122
+ function mapCacheClear$1() {
1123
+ this.size = 0;
1124
+ this.__data__ = {
1125
+ 'hash': new Hash,
1126
+ 'map': new (Map$1 || ListCache),
1127
+ 'string': new Hash
1128
+ };
1129
+ }
1130
+
1131
+ var _mapCacheClear = mapCacheClear$1;
1132
+
1133
+ /**
1134
+ * Checks if `value` is suitable for use as unique object key.
1135
+ *
1136
+ * @private
1137
+ * @param {*} value The value to check.
1138
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1139
+ */
1140
+
1141
+ function isKeyable$1(value) {
1142
+ var type = typeof value;
1143
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1144
+ ? (value !== '__proto__')
1145
+ : (value === null);
1146
+ }
1147
+
1148
+ var _isKeyable = isKeyable$1;
1149
+
1150
+ var isKeyable = _isKeyable;
1151
+
1152
+ /**
1153
+ * Gets the data for `map`.
1154
+ *
1155
+ * @private
1156
+ * @param {Object} map The map to query.
1157
+ * @param {string} key The reference key.
1158
+ * @returns {*} Returns the map data.
1159
+ */
1160
+ function getMapData$4(map, key) {
1161
+ var data = map.__data__;
1162
+ return isKeyable(key)
1163
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1164
+ : data.map;
1165
+ }
1166
+
1167
+ var _getMapData = getMapData$4;
1168
+
1169
+ var getMapData$3 = _getMapData;
1170
+
1171
+ /**
1172
+ * Removes `key` and its value from the map.
1173
+ *
1174
+ * @private
1175
+ * @name delete
1176
+ * @memberOf MapCache
1177
+ * @param {string} key The key of the value to remove.
1178
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1179
+ */
1180
+ function mapCacheDelete$1(key) {
1181
+ var result = getMapData$3(this, key)['delete'](key);
1182
+ this.size -= result ? 1 : 0;
1183
+ return result;
1184
+ }
1185
+
1186
+ var _mapCacheDelete = mapCacheDelete$1;
1187
+
1188
+ var getMapData$2 = _getMapData;
1189
+
1190
+ /**
1191
+ * Gets the map value for `key`.
1192
+ *
1193
+ * @private
1194
+ * @name get
1195
+ * @memberOf MapCache
1196
+ * @param {string} key The key of the value to get.
1197
+ * @returns {*} Returns the entry value.
1198
+ */
1199
+ function mapCacheGet$1(key) {
1200
+ return getMapData$2(this, key).get(key);
1201
+ }
1202
+
1203
+ var _mapCacheGet = mapCacheGet$1;
1204
+
1205
+ var getMapData$1 = _getMapData;
1206
+
1207
+ /**
1208
+ * Checks if a map value for `key` exists.
1209
+ *
1210
+ * @private
1211
+ * @name has
1212
+ * @memberOf MapCache
1213
+ * @param {string} key The key of the entry to check.
1214
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1215
+ */
1216
+ function mapCacheHas$1(key) {
1217
+ return getMapData$1(this, key).has(key);
1218
+ }
1219
+
1220
+ var _mapCacheHas = mapCacheHas$1;
1221
+
1222
+ var getMapData = _getMapData;
1223
+
1224
+ /**
1225
+ * Sets the map `key` to `value`.
1226
+ *
1227
+ * @private
1228
+ * @name set
1229
+ * @memberOf MapCache
1230
+ * @param {string} key The key of the value to set.
1231
+ * @param {*} value The value to set.
1232
+ * @returns {Object} Returns the map cache instance.
1233
+ */
1234
+ function mapCacheSet$1(key, value) {
1235
+ var data = getMapData(this, key),
1236
+ size = data.size;
1237
+
1238
+ data.set(key, value);
1239
+ this.size += data.size == size ? 0 : 1;
1240
+ return this;
1241
+ }
1242
+
1243
+ var _mapCacheSet = mapCacheSet$1;
1244
+
1245
+ var mapCacheClear = _mapCacheClear,
1246
+ mapCacheDelete = _mapCacheDelete,
1247
+ mapCacheGet = _mapCacheGet,
1248
+ mapCacheHas = _mapCacheHas,
1249
+ mapCacheSet = _mapCacheSet;
1250
+
1251
+ /**
1252
+ * Creates a map cache object to store key-value pairs.
1253
+ *
1254
+ * @private
1255
+ * @constructor
1256
+ * @param {Array} [entries] The key-value pairs to cache.
1257
+ */
1258
+ function MapCache$1(entries) {
1259
+ var index = -1,
1260
+ length = entries == null ? 0 : entries.length;
1261
+
1262
+ this.clear();
1263
+ while (++index < length) {
1264
+ var entry = entries[index];
1265
+ this.set(entry[0], entry[1]);
1266
+ }
1267
+ }
1268
+
1269
+ // Add methods to `MapCache`.
1270
+ MapCache$1.prototype.clear = mapCacheClear;
1271
+ MapCache$1.prototype['delete'] = mapCacheDelete;
1272
+ MapCache$1.prototype.get = mapCacheGet;
1273
+ MapCache$1.prototype.has = mapCacheHas;
1274
+ MapCache$1.prototype.set = mapCacheSet;
1275
+
1276
+ var _MapCache = MapCache$1;
1277
+
1278
+ /** Used to stand-in for `undefined` hash values. */
1279
+
1280
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1281
+
1282
+ /**
1283
+ * Adds `value` to the array cache.
1284
+ *
1285
+ * @private
1286
+ * @name add
1287
+ * @memberOf SetCache
1288
+ * @alias push
1289
+ * @param {*} value The value to cache.
1290
+ * @returns {Object} Returns the cache instance.
1291
+ */
1292
+ function setCacheAdd$1(value) {
1293
+ this.__data__.set(value, HASH_UNDEFINED);
1294
+ return this;
1295
+ }
1296
+
1297
+ var _setCacheAdd = setCacheAdd$1;
1298
+
1299
+ /**
1300
+ * Checks if `value` is in the array cache.
1301
+ *
1302
+ * @private
1303
+ * @name has
1304
+ * @memberOf SetCache
1305
+ * @param {*} value The value to search for.
1306
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1307
+ */
1308
+
1309
+ function setCacheHas$1(value) {
1310
+ return this.__data__.has(value);
1311
+ }
1312
+
1313
+ var _setCacheHas = setCacheHas$1;
1314
+
1315
+ var MapCache = _MapCache,
1316
+ setCacheAdd = _setCacheAdd,
1317
+ setCacheHas = _setCacheHas;
1318
+
1319
+ /**
1320
+ *
1321
+ * Creates an array cache object to store unique values.
1322
+ *
1323
+ * @private
1324
+ * @constructor
1325
+ * @param {Array} [values] The values to cache.
1326
+ */
1327
+ function SetCache$1(values) {
1328
+ var index = -1,
1329
+ length = values == null ? 0 : values.length;
1330
+
1331
+ this.__data__ = new MapCache;
1332
+ while (++index < length) {
1333
+ this.add(values[index]);
1334
+ }
1335
+ }
1336
+
1337
+ // Add methods to `SetCache`.
1338
+ SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
1339
+ SetCache$1.prototype.has = setCacheHas;
1340
+
1341
+ var _SetCache = SetCache$1;
1342
+
1343
+ /**
1344
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
1345
+ * support for iteratee shorthands.
1346
+ *
1347
+ * @private
1348
+ * @param {Array} array The array to inspect.
1349
+ * @param {Function} predicate The function invoked per iteration.
1350
+ * @param {number} fromIndex The index to search from.
1351
+ * @param {boolean} [fromRight] Specify iterating from right to left.
1352
+ * @returns {number} Returns the index of the matched value, else `-1`.
1353
+ */
1354
+
1355
+ function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
1356
+ var length = array.length,
1357
+ index = fromIndex + (fromRight ? 1 : -1);
1358
+
1359
+ while ((fromRight ? index-- : ++index < length)) {
1360
+ if (predicate(array[index], index, array)) {
1361
+ return index;
1362
+ }
1363
+ }
1364
+ return -1;
1365
+ }
1366
+
1367
+ var _baseFindIndex = baseFindIndex$1;
1368
+
1369
+ /**
1370
+ * The base implementation of `_.isNaN` without support for number objects.
1371
+ *
1372
+ * @private
1373
+ * @param {*} value The value to check.
1374
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
1375
+ */
1376
+
1377
+ function baseIsNaN$1(value) {
1378
+ return value !== value;
1379
+ }
1380
+
1381
+ var _baseIsNaN = baseIsNaN$1;
1382
+
1383
+ /**
1384
+ * A specialized version of `_.indexOf` which performs strict equality
1385
+ * comparisons of values, i.e. `===`.
1386
+ *
1387
+ * @private
1388
+ * @param {Array} array The array to inspect.
1389
+ * @param {*} value The value to search for.
1390
+ * @param {number} fromIndex The index to search from.
1391
+ * @returns {number} Returns the index of the matched value, else `-1`.
1392
+ */
1393
+
1394
+ function strictIndexOf$1(array, value, fromIndex) {
1395
+ var index = fromIndex - 1,
1396
+ length = array.length;
1397
+
1398
+ while (++index < length) {
1399
+ if (array[index] === value) {
1400
+ return index;
1401
+ }
1402
+ }
1403
+ return -1;
1404
+ }
1405
+
1406
+ var _strictIndexOf = strictIndexOf$1;
1407
+
1408
+ var baseFindIndex = _baseFindIndex,
1409
+ baseIsNaN = _baseIsNaN,
1410
+ strictIndexOf = _strictIndexOf;
1411
+
1412
+ /**
1413
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1414
+ *
1415
+ * @private
1416
+ * @param {Array} array The array to inspect.
1417
+ * @param {*} value The value to search for.
1418
+ * @param {number} fromIndex The index to search from.
1419
+ * @returns {number} Returns the index of the matched value, else `-1`.
1420
+ */
1421
+ function baseIndexOf$1(array, value, fromIndex) {
1422
+ return value === value
1423
+ ? strictIndexOf(array, value, fromIndex)
1424
+ : baseFindIndex(array, baseIsNaN, fromIndex);
1425
+ }
1426
+
1427
+ var _baseIndexOf = baseIndexOf$1;
1428
+
1429
+ var baseIndexOf = _baseIndexOf;
1430
+
1431
+ /**
1432
+ * A specialized version of `_.includes` for arrays without support for
1433
+ * specifying an index to search from.
1434
+ *
1435
+ * @private
1436
+ * @param {Array} [array] The array to inspect.
1437
+ * @param {*} target The value to search for.
1438
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
1439
+ */
1440
+ function arrayIncludes$1(array, value) {
1441
+ var length = array == null ? 0 : array.length;
1442
+ return !!length && baseIndexOf(array, value, 0) > -1;
1443
+ }
1444
+
1445
+ var _arrayIncludes = arrayIncludes$1;
1446
+
1447
+ /**
1448
+ * This function is like `arrayIncludes` except that it accepts a comparator.
1449
+ *
1450
+ * @private
1451
+ * @param {Array} [array] The array to inspect.
1452
+ * @param {*} target The value to search for.
1453
+ * @param {Function} comparator The comparator invoked per element.
1454
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
1455
+ */
1456
+
1457
+ function arrayIncludesWith$1(array, value, comparator) {
1458
+ var index = -1,
1459
+ length = array == null ? 0 : array.length;
1460
+
1461
+ while (++index < length) {
1462
+ if (comparator(value, array[index])) {
1463
+ return true;
1464
+ }
1465
+ }
1466
+ return false;
1467
+ }
1468
+
1469
+ var _arrayIncludesWith = arrayIncludesWith$1;
1470
+
1471
+ /**
1472
+ * Checks if a `cache` value for `key` exists.
1473
+ *
1474
+ * @private
1475
+ * @param {Object} cache The cache to query.
1476
+ * @param {string} key The key of the entry to check.
1477
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1478
+ */
1479
+
1480
+ function cacheHas$1(cache, key) {
1481
+ return cache.has(key);
1482
+ }
1483
+
1484
+ var _cacheHas = cacheHas$1;
1485
+
1486
+ var getNative = _getNative,
1487
+ root = _root;
1488
+
1489
+ /* Built-in method references that are verified to be native. */
1490
+ var Set$1 = getNative(root, 'Set');
1491
+
1492
+ var _Set = Set$1;
1493
+
1494
+ /**
1495
+ * This method returns `undefined`.
1496
+ *
1497
+ * @static
1498
+ * @memberOf _
1499
+ * @since 2.3.0
1500
+ * @category Util
1501
+ * @example
1502
+ *
1503
+ * _.times(2, _.noop);
1504
+ * // => [undefined, undefined]
1505
+ */
1506
+
1507
+ function noop$1() {
1508
+ // No operation performed.
1509
+ }
1510
+
1511
+ var noop_1 = noop$1;
1512
+
1513
+ /**
1514
+ * Converts `set` to an array of its values.
1515
+ *
1516
+ * @private
1517
+ * @param {Object} set The set to convert.
1518
+ * @returns {Array} Returns the values.
1519
+ */
1520
+
1521
+ function setToArray$2(set) {
1522
+ var index = -1,
1523
+ result = Array(set.size);
1524
+
1525
+ set.forEach(function(value) {
1526
+ result[++index] = value;
1527
+ });
1528
+ return result;
1529
+ }
1530
+
1531
+ var _setToArray = setToArray$2;
1532
+
1533
+ var Set = _Set,
1534
+ noop = noop_1,
1535
+ setToArray$1 = _setToArray;
1536
+
1537
+ /** Used as references for various `Number` constants. */
1538
+ var INFINITY = 1 / 0;
1539
+
1540
+ /**
1541
+ * Creates a set object of `values`.
1542
+ *
1543
+ * @private
1544
+ * @param {Array} values The values to add to the set.
1545
+ * @returns {Object} Returns the new set.
1546
+ */
1547
+ var createSet$1 = !(Set && (1 / setToArray$1(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
1548
+ return new Set(values);
1549
+ };
1550
+
1551
+ var _createSet = createSet$1;
1552
+
1553
+ var SetCache = _SetCache,
1554
+ arrayIncludes = _arrayIncludes,
1555
+ arrayIncludesWith = _arrayIncludesWith,
1556
+ cacheHas = _cacheHas,
1557
+ createSet = _createSet,
1558
+ setToArray = _setToArray;
1559
+
1560
+ /** Used as the size to enable large array optimizations. */
1561
+ var LARGE_ARRAY_SIZE = 200;
1562
+
1563
+ /**
1564
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
1565
+ *
1566
+ * @private
1567
+ * @param {Array} array The array to inspect.
1568
+ * @param {Function} [iteratee] The iteratee invoked per element.
1569
+ * @param {Function} [comparator] The comparator invoked per element.
1570
+ * @returns {Array} Returns the new duplicate free array.
1571
+ */
1572
+ function baseUniq$1(array, iteratee, comparator) {
1573
+ var index = -1,
1574
+ includes = arrayIncludes,
1575
+ length = array.length,
1576
+ isCommon = true,
1577
+ result = [],
1578
+ seen = result;
1579
+
1580
+ if (comparator) {
1581
+ isCommon = false;
1582
+ includes = arrayIncludesWith;
1583
+ }
1584
+ else if (length >= LARGE_ARRAY_SIZE) {
1585
+ var set = iteratee ? null : createSet(array);
1586
+ if (set) {
1587
+ return setToArray(set);
1588
+ }
1589
+ isCommon = false;
1590
+ includes = cacheHas;
1591
+ seen = new SetCache;
1592
+ }
1593
+ else {
1594
+ seen = iteratee ? [] : result;
1595
+ }
1596
+ outer:
1597
+ while (++index < length) {
1598
+ var value = array[index],
1599
+ computed = iteratee ? iteratee(value) : value;
1600
+
1601
+ value = (comparator || value !== 0) ? value : 0;
1602
+ if (isCommon && computed === computed) {
1603
+ var seenIndex = seen.length;
1604
+ while (seenIndex--) {
1605
+ if (seen[seenIndex] === computed) {
1606
+ continue outer;
1607
+ }
1608
+ }
1609
+ if (iteratee) {
1610
+ seen.push(computed);
1611
+ }
1612
+ result.push(value);
1613
+ }
1614
+ else if (!includes(seen, computed, comparator)) {
1615
+ if (seen !== result) {
1616
+ seen.push(computed);
1617
+ }
1618
+ result.push(value);
1619
+ }
1620
+ }
1621
+ return result;
1622
+ }
1623
+
1624
+ var _baseUniq = baseUniq$1;
1625
+
1626
+ var baseUniq = _baseUniq;
1627
+
1628
+ /**
1629
+ * This method is like `_.uniq` except that it accepts `comparator` which
1630
+ * is invoked to compare elements of `array`. The order of result values is
1631
+ * determined by the order they occur in the array.The comparator is invoked
1632
+ * with two arguments: (arrVal, othVal).
1633
+ *
1634
+ * @static
1635
+ * @memberOf _
1636
+ * @since 4.0.0
1637
+ * @category Array
1638
+ * @param {Array} array The array to inspect.
1639
+ * @param {Function} [comparator] The comparator invoked per element.
1640
+ * @returns {Array} Returns the new duplicate free array.
1641
+ * @example
1642
+ *
1643
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
1644
+ *
1645
+ * _.uniqWith(objects, _.isEqual);
1646
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
1647
+ */
1648
+ function uniqWith(array, comparator) {
1649
+ comparator = typeof comparator == 'function' ? comparator : undefined;
1650
+ return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
1651
+ }
1652
+
1653
+ var uniqWith_1 = uniqWith;
1654
+
1655
+ /**
1656
+ * 场景解析器
1657
+ * @param rawScene 原始场景
1658
+ * @param sceneName 场景名称
1659
+ * @param sceneUrl 场景url
1660
+ * @param assetsPrefetcher
1661
+ * @param assetSetter
1662
+ * @param ADD_NEXT_ARG_LIST
1663
+ * @param SCRIPT_CONFIG
1664
+ * @return {IScene} 解析后的场景
1665
+ */
1666
+ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
1667
+ const rawSentenceList = rawScene.split("\n"); // 原始句子列表
1668
+ // 去分号留到后面去做了,现在注释要单独处理
1669
+ const rawSentenceListWithoutEmpty = rawSentenceList;
1670
+ // .map((sentence) => sentence.split(";")[0])
1671
+ // .filter((sentence) => sentence.trim() !== "");
1672
+ let assetsList = []; // 场景资源列表
1673
+ let subSceneList = []; // 子场景列表
1674
+ const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
1675
+ const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
1676
+ // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1677
+ assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1678
+ subSceneList = [...subSceneList, ...returnSentence.subScene];
1679
+ return returnSentence;
1680
+ });
1681
+ // 开始资源的预加载
1682
+ assetsList = uniqWith_1(assetsList); // 去重
1683
+ assetsPrefetcher(assetsList);
1684
+ return {
1685
+ sceneName: sceneName,
1686
+ sceneUrl: sceneUrl,
1687
+ sentenceList: sentenceList,
1688
+ assetsList: assetsList,
1689
+ subSceneList: subSceneList // 子场景列表
1690
+ };
1691
+ };
1692
+
1693
+ class SceneParser {
1694
+ assetsPrefetcher;
1695
+ assetSetter;
1696
+ ADD_NEXT_ARG_LIST;
1697
+ SCRIPT_CONFIG;
1698
+ constructor(assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
1699
+ this.assetsPrefetcher = assetsPrefetcher;
1700
+ this.assetSetter = assetSetter;
1701
+ this.ADD_NEXT_ARG_LIST = ADD_NEXT_ARG_LIST;
1702
+ this.SCRIPT_CONFIG = SCRIPT_CONFIG;
1703
+ }
1704
+ parse(rawScene, sceneName, sceneUrl) {
1705
+ return sceneParser(rawScene, sceneName, sceneUrl, this.assetsPrefetcher, this.assetSetter, this.ADD_NEXT_ARG_LIST, this.SCRIPT_CONFIG);
1706
+ }
1707
+ }
1708
+
1709
+ exports.default = SceneParser;
1710
+ //# sourceMappingURL=index.js.map