UNPKG

248 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["WaveformPlaylist"] = factory();
8 else
9 root["WaveformPlaylist"] = factory();
10})(self, function() {
11return /******/ (() => { // webpackBootstrap
12/******/ var __webpack_modules__ = ({
13
14/***/ 6824:
15/***/ ((module) => {
16
17/*!
18 * Cross-Browser Split 1.1.1
19 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
20 * Available under the MIT License
21 * ECMAScript compliant, uniform cross-browser split method
22 */
23
24/**
25 * Splits a string into an array of strings using a regex or string separator. Matches of the
26 * separator are not included in the result array. However, if `separator` is a regex that contains
27 * capturing groups, backreferences are spliced into the result each time `separator` is matched.
28 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
29 * cross-browser.
30 * @param {String} str String to split.
31 * @param {RegExp|String} separator Regex or string to use for separating the string.
32 * @param {Number} [limit] Maximum number of items to include in the result array.
33 * @returns {Array} Array of substrings.
34 * @example
35 *
36 * // Basic use
37 * split('a b c d', ' ');
38 * // -> ['a', 'b', 'c', 'd']
39 *
40 * // With limit
41 * split('a b c d', ' ', 2);
42 * // -> ['a', 'b']
43 *
44 * // Backreferences in result array
45 * split('..word1 word2..', /([a-z]+)(\d+)/i);
46 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
47 */
48module.exports = (function split(undef) {
49
50 var nativeSplit = String.prototype.split,
51 compliantExecNpcg = /()??/.exec("")[1] === undef,
52 // NPCG: nonparticipating capturing group
53 self;
54
55 self = function(str, separator, limit) {
56 // If `separator` is not a regex, use `nativeSplit`
57 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
58 return nativeSplit.call(str, separator, limit);
59 }
60 var output = [],
61 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
62 (separator.sticky ? "y" : ""),
63 // Firefox 3+
64 lastLastIndex = 0,
65 // Make `global` and avoid `lastIndex` issues by working with a copy
66 separator = new RegExp(separator.source, flags + "g"),
67 separator2, match, lastIndex, lastLength;
68 str += ""; // Type-convert
69 if (!compliantExecNpcg) {
70 // Doesn't need flags gy, but they don't hurt
71 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
72 }
73 /* Values for `limit`, per the spec:
74 * If undefined: 4294967295 // Math.pow(2, 32) - 1
75 * If 0, Infinity, or NaN: 0
76 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
77 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
78 * If other: Type-convert, then use the above rules
79 */
80 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
81 limit >>> 0; // ToUint32(limit)
82 while (match = separator.exec(str)) {
83 // `separator.lastIndex` is not reliable cross-browser
84 lastIndex = match.index + match[0].length;
85 if (lastIndex > lastLastIndex) {
86 output.push(str.slice(lastLastIndex, match.index));
87 // Fix browsers whose `exec` methods don't consistently return `undefined` for
88 // nonparticipating capturing groups
89 if (!compliantExecNpcg && match.length > 1) {
90 match[0].replace(separator2, function() {
91 for (var i = 1; i < arguments.length - 2; i++) {
92 if (arguments[i] === undef) {
93 match[i] = undef;
94 }
95 }
96 });
97 }
98 if (match.length > 1 && match.index < str.length) {
99 Array.prototype.push.apply(output, match.slice(1));
100 }
101 lastLength = match[0].length;
102 lastLastIndex = lastIndex;
103 if (output.length >= limit) {
104 break;
105 }
106 }
107 if (separator.lastIndex === match.index) {
108 separator.lastIndex++; // Avoid an infinite loop
109 }
110 }
111 if (lastLastIndex === str.length) {
112 if (lastLength || !separator.test("")) {
113 output.push("");
114 }
115 } else {
116 output.push(str.slice(lastLastIndex));
117 }
118 return output.length > limit ? output.slice(0, limit) : output;
119 };
120
121 return self;
122})();
123
124
125/***/ }),
126
127/***/ 1804:
128/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
129
130"use strict";
131
132
133var isValue = __webpack_require__(5618)
134 , isPlainFunction = __webpack_require__(7205)
135 , assign = __webpack_require__(7191)
136 , normalizeOpts = __webpack_require__(5516)
137 , contains = __webpack_require__(9981);
138
139var d = (module.exports = function (dscr, value/*, options*/) {
140 var c, e, w, options, desc;
141 if (arguments.length < 2 || typeof dscr !== "string") {
142 options = value;
143 value = dscr;
144 dscr = null;
145 } else {
146 options = arguments[2];
147 }
148 if (isValue(dscr)) {
149 c = contains.call(dscr, "c");
150 e = contains.call(dscr, "e");
151 w = contains.call(dscr, "w");
152 } else {
153 c = w = true;
154 e = false;
155 }
156
157 desc = { value: value, configurable: c, enumerable: e, writable: w };
158 return !options ? desc : assign(normalizeOpts(options), desc);
159});
160
161d.gs = function (dscr, get, set/*, options*/) {
162 var c, e, options, desc;
163 if (typeof dscr !== "string") {
164 options = set;
165 set = get;
166 get = dscr;
167 dscr = null;
168 } else {
169 options = arguments[3];
170 }
171 if (!isValue(get)) {
172 get = undefined;
173 } else if (!isPlainFunction(get)) {
174 options = get;
175 get = set = undefined;
176 } else if (!isValue(set)) {
177 set = undefined;
178 } else if (!isPlainFunction(set)) {
179 options = set;
180 set = undefined;
181 }
182 if (isValue(dscr)) {
183 c = contains.call(dscr, "c");
184 e = contains.call(dscr, "e");
185 } else {
186 c = true;
187 e = false;
188 }
189
190 desc = { get: get, set: set, configurable: c, enumerable: e };
191 return !options ? desc : assign(normalizeOpts(options), desc);
192};
193
194
195/***/ }),
196
197/***/ 430:
198/***/ ((module) => {
199
200"use strict";
201
202
203// eslint-disable-next-line no-empty-function
204module.exports = function () {};
205
206
207/***/ }),
208
209/***/ 7191:
210/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
211
212"use strict";
213
214
215module.exports = __webpack_require__(6560)() ? Object.assign : __webpack_require__(7346);
216
217
218/***/ }),
219
220/***/ 6560:
221/***/ ((module) => {
222
223"use strict";
224
225
226module.exports = function () {
227 var assign = Object.assign, obj;
228 if (typeof assign !== "function") return false;
229 obj = { foo: "raz" };
230 assign(obj, { bar: "dwa" }, { trzy: "trzy" });
231 return obj.foo + obj.bar + obj.trzy === "razdwatrzy";
232};
233
234
235/***/ }),
236
237/***/ 7346:
238/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
239
240"use strict";
241
242
243var keys = __webpack_require__(5103)
244 , value = __webpack_require__(2745)
245 , max = Math.max;
246
247module.exports = function (dest, src/*, …srcn*/) {
248 var error, i, length = max(arguments.length, 2), assign;
249 dest = Object(value(dest));
250 assign = function (key) {
251 try {
252 dest[key] = src[key];
253 } catch (e) {
254 if (!error) error = e;
255 }
256 };
257 for (i = 1; i < length; ++i) {
258 src = arguments[i];
259 keys(src).forEach(assign);
260 }
261 if (error !== undefined) throw error;
262 return dest;
263};
264
265
266/***/ }),
267
268/***/ 6914:
269/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
270
271"use strict";
272
273
274var _undefined = __webpack_require__(430)(); // Support ES3 engines
275
276module.exports = function (val) { return val !== _undefined && val !== null; };
277
278
279/***/ }),
280
281/***/ 5103:
282/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
283
284"use strict";
285
286
287module.exports = __webpack_require__(7446)() ? Object.keys : __webpack_require__(6137);
288
289
290/***/ }),
291
292/***/ 7446:
293/***/ ((module) => {
294
295"use strict";
296
297
298module.exports = function () {
299 try {
300 Object.keys("primitive");
301 return true;
302 } catch (e) {
303 return false;
304 }
305};
306
307
308/***/ }),
309
310/***/ 6137:
311/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
312
313"use strict";
314
315
316var isValue = __webpack_require__(6914);
317
318var keys = Object.keys;
319
320module.exports = function (object) { return keys(isValue(object) ? Object(object) : object); };
321
322
323/***/ }),
324
325/***/ 5516:
326/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
327
328"use strict";
329
330
331var isValue = __webpack_require__(6914);
332
333var forEach = Array.prototype.forEach, create = Object.create;
334
335var process = function (src, obj) {
336 var key;
337 for (key in src) obj[key] = src[key];
338};
339
340// eslint-disable-next-line no-unused-vars
341module.exports = function (opts1/*, …options*/) {
342 var result = create(null);
343 forEach.call(arguments, function (options) {
344 if (!isValue(options)) return;
345 process(Object(options), result);
346 });
347 return result;
348};
349
350
351/***/ }),
352
353/***/ 1290:
354/***/ ((module) => {
355
356"use strict";
357
358
359module.exports = function (fn) {
360 if (typeof fn !== "function") throw new TypeError(fn + " is not a function");
361 return fn;
362};
363
364
365/***/ }),
366
367/***/ 2745:
368/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
369
370"use strict";
371
372
373var isValue = __webpack_require__(6914);
374
375module.exports = function (value) {
376 if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
377 return value;
378};
379
380
381/***/ }),
382
383/***/ 9981:
384/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
385
386"use strict";
387
388
389module.exports = __webpack_require__(3591)() ? String.prototype.contains : __webpack_require__(6042);
390
391
392/***/ }),
393
394/***/ 3591:
395/***/ ((module) => {
396
397"use strict";
398
399
400var str = "razdwatrzy";
401
402module.exports = function () {
403 if (typeof str.contains !== "function") return false;
404 return str.contains("dwa") === true && str.contains("foo") === false;
405};
406
407
408/***/ }),
409
410/***/ 6042:
411/***/ ((module) => {
412
413"use strict";
414
415
416var indexOf = String.prototype.indexOf;
417
418module.exports = function (searchString/*, position*/) {
419 return indexOf.call(this, searchString, arguments[1]) > -1;
420};
421
422
423/***/ }),
424
425/***/ 8832:
426/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
427
428"use strict";
429
430
431var OneVersionConstraint = __webpack_require__(4167);
432
433var MY_VERSION = '7';
434OneVersionConstraint('ev-store', MY_VERSION);
435
436var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
437
438module.exports = EvStore;
439
440function EvStore(elem) {
441 var hash = elem[hashKey];
442
443 if (!hash) {
444 hash = elem[hashKey] = {};
445 }
446
447 return hash;
448}
449
450
451/***/ }),
452
453/***/ 8370:
454/***/ ((module, exports, __webpack_require__) => {
455
456"use strict";
457
458
459var d = __webpack_require__(1804)
460 , callable = __webpack_require__(1290)
461
462 , apply = Function.prototype.apply, call = Function.prototype.call
463 , create = Object.create, defineProperty = Object.defineProperty
464 , defineProperties = Object.defineProperties
465 , hasOwnProperty = Object.prototype.hasOwnProperty
466 , descriptor = { configurable: true, enumerable: false, writable: true }
467
468 , on, once, off, emit, methods, descriptors, base;
469
470on = function (type, listener) {
471 var data;
472
473 callable(listener);
474
475 if (!hasOwnProperty.call(this, '__ee__')) {
476 data = descriptor.value = create(null);
477 defineProperty(this, '__ee__', descriptor);
478 descriptor.value = null;
479 } else {
480 data = this.__ee__;
481 }
482 if (!data[type]) data[type] = listener;
483 else if (typeof data[type] === 'object') data[type].push(listener);
484 else data[type] = [data[type], listener];
485
486 return this;
487};
488
489once = function (type, listener) {
490 var once, self;
491
492 callable(listener);
493 self = this;
494 on.call(this, type, once = function () {
495 off.call(self, type, once);
496 apply.call(listener, this, arguments);
497 });
498
499 once.__eeOnceListener__ = listener;
500 return this;
501};
502
503off = function (type, listener) {
504 var data, listeners, candidate, i;
505
506 callable(listener);
507
508 if (!hasOwnProperty.call(this, '__ee__')) return this;
509 data = this.__ee__;
510 if (!data[type]) return this;
511 listeners = data[type];
512
513 if (typeof listeners === 'object') {
514 for (i = 0; (candidate = listeners[i]); ++i) {
515 if ((candidate === listener) ||
516 (candidate.__eeOnceListener__ === listener)) {
517 if (listeners.length === 2) data[type] = listeners[i ? 0 : 1];
518 else listeners.splice(i, 1);
519 }
520 }
521 } else {
522 if ((listeners === listener) ||
523 (listeners.__eeOnceListener__ === listener)) {
524 delete data[type];
525 }
526 }
527
528 return this;
529};
530
531emit = function (type) {
532 var i, l, listener, listeners, args;
533
534 if (!hasOwnProperty.call(this, '__ee__')) return;
535 listeners = this.__ee__[type];
536 if (!listeners) return;
537
538 if (typeof listeners === 'object') {
539 l = arguments.length;
540 args = new Array(l - 1);
541 for (i = 1; i < l; ++i) args[i - 1] = arguments[i];
542
543 listeners = listeners.slice();
544 for (i = 0; (listener = listeners[i]); ++i) {
545 apply.call(listener, this, args);
546 }
547 } else {
548 switch (arguments.length) {
549 case 1:
550 call.call(listeners, this);
551 break;
552 case 2:
553 call.call(listeners, this, arguments[1]);
554 break;
555 case 3:
556 call.call(listeners, this, arguments[1], arguments[2]);
557 break;
558 default:
559 l = arguments.length;
560 args = new Array(l - 1);
561 for (i = 1; i < l; ++i) {
562 args[i - 1] = arguments[i];
563 }
564 apply.call(listeners, this, args);
565 }
566 }
567};
568
569methods = {
570 on: on,
571 once: once,
572 off: off,
573 emit: emit
574};
575
576descriptors = {
577 on: d(on),
578 once: d(once),
579 off: d(off),
580 emit: d(emit)
581};
582
583base = defineProperties({}, descriptors);
584
585module.exports = exports = function (o) {
586 return (o == null) ? create(base) : defineProperties(Object(o), descriptors);
587};
588exports.methods = methods;
589
590
591/***/ }),
592
593/***/ 6226:
594/***/ ((__unused_webpack_module, exports) => {
595
596"use strict";
597
598
599Object.defineProperty(exports, "__esModule", ({
600 value: true
601}));
602exports.linear = linear;
603exports.exponential = exponential;
604exports.sCurve = sCurve;
605exports.logarithmic = logarithmic;
606function linear(length, rotation) {
607 var curve = new Float32Array(length),
608 i,
609 x,
610 scale = length - 1;
611
612 for (i = 0; i < length; i++) {
613 x = i / scale;
614
615 if (rotation > 0) {
616 curve[i] = x;
617 } else {
618 curve[i] = 1 - x;
619 }
620 }
621
622 return curve;
623}
624
625function exponential(length, rotation) {
626 var curve = new Float32Array(length),
627 i,
628 x,
629 scale = length - 1,
630 index;
631
632 for (i = 0; i < length; i++) {
633 x = i / scale;
634 index = rotation > 0 ? i : length - 1 - i;
635
636 curve[index] = Math.exp(2 * x - 1) / Math.exp(1);
637 }
638
639 return curve;
640}
641
642//creating a curve to simulate an S-curve with setValueCurveAtTime.
643function sCurve(length, rotation) {
644 var curve = new Float32Array(length),
645 i,
646 phase = rotation > 0 ? Math.PI / 2 : -(Math.PI / 2);
647
648 for (i = 0; i < length; ++i) {
649 curve[i] = Math.sin(Math.PI * i / length - phase) / 2 + 0.5;
650 }
651 return curve;
652}
653
654//creating a curve to simulate a logarithmic curve with setValueCurveAtTime.
655function logarithmic(length, base, rotation) {
656 var curve = new Float32Array(length),
657 index,
658 x = 0,
659 i;
660
661 for (i = 0; i < length; i++) {
662 //index for the curve array.
663 index = rotation > 0 ? i : length - 1 - i;
664
665 x = i / length;
666 curve[index] = Math.log(1 + base * x) / Math.log(1 + base);
667 }
668
669 return curve;
670}
671
672
673/***/ }),
674
675/***/ 1114:
676/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
677
678"use strict";
679var __webpack_unused_export__;
680
681
682__webpack_unused_export__ = ({
683 value: true
684});
685exports.h7 = exports.Y1 = exports.Hp = exports.Jl = exports.t$ = exports._h = undefined;
686exports.L7 = createFadeIn;
687exports.Mt = createFadeOut;
688
689var _fadeCurves = __webpack_require__(6226);
690
691var SCURVE = exports._h = "sCurve";
692var LINEAR = exports.t$ = "linear";
693var EXPONENTIAL = exports.Jl = "exponential";
694var LOGARITHMIC = exports.Hp = "logarithmic";
695
696var FADEIN = exports.Y1 = "FadeIn";
697var FADEOUT = exports.h7 = "FadeOut";
698
699function sCurveFadeIn(start, duration) {
700 var curve = (0, _fadeCurves.sCurve)(10000, 1);
701 this.setValueCurveAtTime(curve, start, duration);
702}
703
704function sCurveFadeOut(start, duration) {
705 var curve = (0, _fadeCurves.sCurve)(10000, -1);
706 this.setValueCurveAtTime(curve, start, duration);
707}
708
709function linearFadeIn(start, duration) {
710 this.linearRampToValueAtTime(0, start);
711 this.linearRampToValueAtTime(1, start + duration);
712}
713
714function linearFadeOut(start, duration) {
715 this.linearRampToValueAtTime(1, start);
716 this.linearRampToValueAtTime(0, start + duration);
717}
718
719function exponentialFadeIn(start, duration) {
720 this.exponentialRampToValueAtTime(0.01, start);
721 this.exponentialRampToValueAtTime(1, start + duration);
722}
723
724function exponentialFadeOut(start, duration) {
725 this.exponentialRampToValueAtTime(1, start);
726 this.exponentialRampToValueAtTime(0.01, start + duration);
727}
728
729function logarithmicFadeIn(start, duration) {
730 var curve = (0, _fadeCurves.logarithmic)(10000, 10, 1);
731 this.setValueCurveAtTime(curve, start, duration);
732}
733
734function logarithmicFadeOut(start, duration) {
735 var curve = (0, _fadeCurves.logarithmic)(10000, 10, -1);
736 this.setValueCurveAtTime(curve, start, duration);
737}
738
739function createFadeIn(gain, shape, start, duration) {
740 switch (shape) {
741 case SCURVE:
742 sCurveFadeIn.call(gain, start, duration);
743 break;
744 case LINEAR:
745 linearFadeIn.call(gain, start, duration);
746 break;
747 case EXPONENTIAL:
748 exponentialFadeIn.call(gain, start, duration);
749 break;
750 case LOGARITHMIC:
751 logarithmicFadeIn.call(gain, start, duration);
752 break;
753 default:
754 throw new Error("Unsupported Fade type");
755 }
756}
757
758function createFadeOut(gain, shape, start, duration) {
759 switch (shape) {
760 case SCURVE:
761 sCurveFadeOut.call(gain, start, duration);
762 break;
763 case LINEAR:
764 linearFadeOut.call(gain, start, duration);
765 break;
766 case EXPONENTIAL:
767 exponentialFadeOut.call(gain, start, duration);
768 break;
769 case LOGARITHMIC:
770 logarithmicFadeOut.call(gain, start, duration);
771 break;
772 default:
773 throw new Error("Unsupported Fade type");
774 }
775}
776
777
778/***/ }),
779
780/***/ 9144:
781/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
782
783var topLevel = typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g :
784 typeof window !== 'undefined' ? window : {}
785var minDoc = __webpack_require__(5893);
786
787var doccy;
788
789if (typeof document !== 'undefined') {
790 doccy = document;
791} else {
792 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
793
794 if (!doccy) {
795 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
796 }
797}
798
799module.exports = doccy;
800
801
802/***/ }),
803
804/***/ 8070:
805/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
806
807"use strict";
808
809
810/*global window, global*/
811
812var root = typeof window !== 'undefined' ?
813 window : typeof __webpack_require__.g !== 'undefined' ?
814 __webpack_require__.g : {};
815
816module.exports = Individual;
817
818function Individual(key, value) {
819 if (key in root) {
820 return root[key];
821 }
822
823 root[key] = value;
824
825 return value;
826}
827
828
829/***/ }),
830
831/***/ 4167:
832/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
833
834"use strict";
835
836
837var Individual = __webpack_require__(8070);
838
839module.exports = OneVersion;
840
841function OneVersion(moduleName, version, defaultValue) {
842 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
843 var enforceKey = key + '_ENFORCE_SINGLETON';
844
845 var versionValue = Individual(enforceKey, version);
846
847 if (versionValue !== version) {
848 throw new Error('Can only have one copy of ' +
849 moduleName + '.\n' +
850 'You already have version ' + versionValue +
851 ' installed.\n' +
852 'This means you cannot install version ' + version);
853 }
854
855 return Individual(key, defaultValue);
856}
857
858
859/***/ }),
860
861/***/ 849:
862/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
863
864var WORKER_ENABLED = !!(__webpack_require__.g === __webpack_require__.g.window && __webpack_require__.g.URL && __webpack_require__.g.Blob && __webpack_require__.g.Worker);
865
866function InlineWorker(func, self) {
867 var _this = this;
868 var functionBody;
869
870 self = self || {};
871
872 if (WORKER_ENABLED) {
873 functionBody = func.toString().trim().match(
874 /^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/
875 )[1];
876
877 return new __webpack_require__.g.Worker(__webpack_require__.g.URL.createObjectURL(
878 new __webpack_require__.g.Blob([ functionBody ], { type: "text/javascript" })
879 ));
880 }
881
882 function postMessage(data) {
883 setTimeout(function() {
884 _this.onmessage({ data: data });
885 }, 0);
886 }
887
888 this.self = self;
889 this.self.postMessage = postMessage;
890
891 setTimeout(func.bind(self, self), 0);
892}
893
894InlineWorker.prototype.postMessage = function postMessage(data) {
895 var _this = this;
896
897 setTimeout(function() {
898 _this.self.onmessage({ data: data });
899 }, 0);
900};
901
902module.exports = InlineWorker;
903
904
905/***/ }),
906
907/***/ 6240:
908/***/ ((module) => {
909
910"use strict";
911
912
913module.exports = function isObject(x) {
914 return typeof x === "object" && x !== null;
915};
916
917
918/***/ }),
919
920/***/ 1730:
921/***/ ((module) => {
922
923/**
924 * lodash (Custom Build) <https://lodash.com/>
925 * Build: `lodash modularize exports="npm" -o ./`
926 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
927 * Released under MIT license <https://lodash.com/license>
928 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
929 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
930 */
931
932/** Used as references for various `Number` constants. */
933var MAX_SAFE_INTEGER = 9007199254740991;
934
935/** `Object#toString` result references. */
936var argsTag = '[object Arguments]',
937 funcTag = '[object Function]',
938 genTag = '[object GeneratorFunction]';
939
940/** Used to detect unsigned integer values. */
941var reIsUint = /^(?:0|[1-9]\d*)$/;
942
943/**
944 * A faster alternative to `Function#apply`, this function invokes `func`
945 * with the `this` binding of `thisArg` and the arguments of `args`.
946 *
947 * @private
948 * @param {Function} func The function to invoke.
949 * @param {*} thisArg The `this` binding of `func`.
950 * @param {Array} args The arguments to invoke `func` with.
951 * @returns {*} Returns the result of `func`.
952 */
953function apply(func, thisArg, args) {
954 switch (args.length) {
955 case 0: return func.call(thisArg);
956 case 1: return func.call(thisArg, args[0]);
957 case 2: return func.call(thisArg, args[0], args[1]);
958 case 3: return func.call(thisArg, args[0], args[1], args[2]);
959 }
960 return func.apply(thisArg, args);
961}
962
963/**
964 * The base implementation of `_.times` without support for iteratee shorthands
965 * or max array length checks.
966 *
967 * @private
968 * @param {number} n The number of times to invoke `iteratee`.
969 * @param {Function} iteratee The function invoked per iteration.
970 * @returns {Array} Returns the array of results.
971 */
972function baseTimes(n, iteratee) {
973 var index = -1,
974 result = Array(n);
975
976 while (++index < n) {
977 result[index] = iteratee(index);
978 }
979 return result;
980}
981
982/**
983 * Creates a unary function that invokes `func` with its argument transformed.
984 *
985 * @private
986 * @param {Function} func The function to wrap.
987 * @param {Function} transform The argument transform.
988 * @returns {Function} Returns the new function.
989 */
990function overArg(func, transform) {
991 return function(arg) {
992 return func(transform(arg));
993 };
994}
995
996/** Used for built-in method references. */
997var objectProto = Object.prototype;
998
999/** Used to check objects for own properties. */
1000var hasOwnProperty = objectProto.hasOwnProperty;
1001
1002/**
1003 * Used to resolve the
1004 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1005 * of values.
1006 */
1007var objectToString = objectProto.toString;
1008
1009/** Built-in value references. */
1010var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1011
1012/* Built-in method references for those with the same name as other `lodash` methods. */
1013var nativeKeys = overArg(Object.keys, Object),
1014 nativeMax = Math.max;
1015
1016/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
1017var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
1018
1019/**
1020 * Creates an array of the enumerable property names of the array-like `value`.
1021 *
1022 * @private
1023 * @param {*} value The value to query.
1024 * @param {boolean} inherited Specify returning inherited property names.
1025 * @returns {Array} Returns the array of property names.
1026 */
1027function arrayLikeKeys(value, inherited) {
1028 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1029 // Safari 9 makes `arguments.length` enumerable in strict mode.
1030 var result = (isArray(value) || isArguments(value))
1031 ? baseTimes(value.length, String)
1032 : [];
1033
1034 var length = result.length,
1035 skipIndexes = !!length;
1036
1037 for (var key in value) {
1038 if ((inherited || hasOwnProperty.call(value, key)) &&
1039 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
1040 result.push(key);
1041 }
1042 }
1043 return result;
1044}
1045
1046/**
1047 * Assigns `value` to `key` of `object` if the existing value is not equivalent
1048 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1049 * for equality comparisons.
1050 *
1051 * @private
1052 * @param {Object} object The object to modify.
1053 * @param {string} key The key of the property to assign.
1054 * @param {*} value The value to assign.
1055 */
1056function assignValue(object, key, value) {
1057 var objValue = object[key];
1058 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
1059 (value === undefined && !(key in object))) {
1060 object[key] = value;
1061 }
1062}
1063
1064/**
1065 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1066 *
1067 * @private
1068 * @param {Object} object The object to query.
1069 * @returns {Array} Returns the array of property names.
1070 */
1071function baseKeys(object) {
1072 if (!isPrototype(object)) {
1073 return nativeKeys(object);
1074 }
1075 var result = [];
1076 for (var key in Object(object)) {
1077 if (hasOwnProperty.call(object, key) && key != 'constructor') {
1078 result.push(key);
1079 }
1080 }
1081 return result;
1082}
1083
1084/**
1085 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1086 *
1087 * @private
1088 * @param {Function} func The function to apply a rest parameter to.
1089 * @param {number} [start=func.length-1] The start position of the rest parameter.
1090 * @returns {Function} Returns the new function.
1091 */
1092function baseRest(func, start) {
1093 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1094 return function() {
1095 var args = arguments,
1096 index = -1,
1097 length = nativeMax(args.length - start, 0),
1098 array = Array(length);
1099
1100 while (++index < length) {
1101 array[index] = args[start + index];
1102 }
1103 index = -1;
1104 var otherArgs = Array(start + 1);
1105 while (++index < start) {
1106 otherArgs[index] = args[index];
1107 }
1108 otherArgs[start] = array;
1109 return apply(func, this, otherArgs);
1110 };
1111}
1112
1113/**
1114 * Copies properties of `source` to `object`.
1115 *
1116 * @private
1117 * @param {Object} source The object to copy properties from.
1118 * @param {Array} props The property identifiers to copy.
1119 * @param {Object} [object={}] The object to copy properties to.
1120 * @param {Function} [customizer] The function to customize copied values.
1121 * @returns {Object} Returns `object`.
1122 */
1123function copyObject(source, props, object, customizer) {
1124 object || (object = {});
1125
1126 var index = -1,
1127 length = props.length;
1128
1129 while (++index < length) {
1130 var key = props[index];
1131
1132 var newValue = customizer
1133 ? customizer(object[key], source[key], key, object, source)
1134 : undefined;
1135
1136 assignValue(object, key, newValue === undefined ? source[key] : newValue);
1137 }
1138 return object;
1139}
1140
1141/**
1142 * Creates a function like `_.assign`.
1143 *
1144 * @private
1145 * @param {Function} assigner The function to assign values.
1146 * @returns {Function} Returns the new assigner function.
1147 */
1148function createAssigner(assigner) {
1149 return baseRest(function(object, sources) {
1150 var index = -1,
1151 length = sources.length,
1152 customizer = length > 1 ? sources[length - 1] : undefined,
1153 guard = length > 2 ? sources[2] : undefined;
1154
1155 customizer = (assigner.length > 3 && typeof customizer == 'function')
1156 ? (length--, customizer)
1157 : undefined;
1158
1159 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1160 customizer = length < 3 ? undefined : customizer;
1161 length = 1;
1162 }
1163 object = Object(object);
1164 while (++index < length) {
1165 var source = sources[index];
1166 if (source) {
1167 assigner(object, source, index, customizer);
1168 }
1169 }
1170 return object;
1171 });
1172}
1173
1174/**
1175 * Checks if `value` is a valid array-like index.
1176 *
1177 * @private
1178 * @param {*} value The value to check.
1179 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1180 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1181 */
1182function isIndex(value, length) {
1183 length = length == null ? MAX_SAFE_INTEGER : length;
1184 return !!length &&
1185 (typeof value == 'number' || reIsUint.test(value)) &&
1186 (value > -1 && value % 1 == 0 && value < length);
1187}
1188
1189/**
1190 * Checks if the given arguments are from an iteratee call.
1191 *
1192 * @private
1193 * @param {*} value The potential iteratee value argument.
1194 * @param {*} index The potential iteratee index or key argument.
1195 * @param {*} object The potential iteratee object argument.
1196 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1197 * else `false`.
1198 */
1199function isIterateeCall(value, index, object) {
1200 if (!isObject(object)) {
1201 return false;
1202 }
1203 var type = typeof index;
1204 if (type == 'number'
1205 ? (isArrayLike(object) && isIndex(index, object.length))
1206 : (type == 'string' && index in object)
1207 ) {
1208 return eq(object[index], value);
1209 }
1210 return false;
1211}
1212
1213/**
1214 * Checks if `value` is likely a prototype object.
1215 *
1216 * @private
1217 * @param {*} value The value to check.
1218 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1219 */
1220function isPrototype(value) {
1221 var Ctor = value && value.constructor,
1222 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1223
1224 return value === proto;
1225}
1226
1227/**
1228 * Performs a
1229 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1230 * comparison between two values to determine if they are equivalent.
1231 *
1232 * @static
1233 * @memberOf _
1234 * @since 4.0.0
1235 * @category Lang
1236 * @param {*} value The value to compare.
1237 * @param {*} other The other value to compare.
1238 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1239 * @example
1240 *
1241 * var object = { 'a': 1 };
1242 * var other = { 'a': 1 };
1243 *
1244 * _.eq(object, object);
1245 * // => true
1246 *
1247 * _.eq(object, other);
1248 * // => false
1249 *
1250 * _.eq('a', 'a');
1251 * // => true
1252 *
1253 * _.eq('a', Object('a'));
1254 * // => false
1255 *
1256 * _.eq(NaN, NaN);
1257 * // => true
1258 */
1259function eq(value, other) {
1260 return value === other || (value !== value && other !== other);
1261}
1262
1263/**
1264 * Checks if `value` is likely an `arguments` object.
1265 *
1266 * @static
1267 * @memberOf _
1268 * @since 0.1.0
1269 * @category Lang
1270 * @param {*} value The value to check.
1271 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1272 * else `false`.
1273 * @example
1274 *
1275 * _.isArguments(function() { return arguments; }());
1276 * // => true
1277 *
1278 * _.isArguments([1, 2, 3]);
1279 * // => false
1280 */
1281function isArguments(value) {
1282 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1283 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1284 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1285}
1286
1287/**
1288 * Checks if `value` is classified as an `Array` object.
1289 *
1290 * @static
1291 * @memberOf _
1292 * @since 0.1.0
1293 * @category Lang
1294 * @param {*} value The value to check.
1295 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1296 * @example
1297 *
1298 * _.isArray([1, 2, 3]);
1299 * // => true
1300 *
1301 * _.isArray(document.body.children);
1302 * // => false
1303 *
1304 * _.isArray('abc');
1305 * // => false
1306 *
1307 * _.isArray(_.noop);
1308 * // => false
1309 */
1310var isArray = Array.isArray;
1311
1312/**
1313 * Checks if `value` is array-like. A value is considered array-like if it's
1314 * not a function and has a `value.length` that's an integer greater than or
1315 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1316 *
1317 * @static
1318 * @memberOf _
1319 * @since 4.0.0
1320 * @category Lang
1321 * @param {*} value The value to check.
1322 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1323 * @example
1324 *
1325 * _.isArrayLike([1, 2, 3]);
1326 * // => true
1327 *
1328 * _.isArrayLike(document.body.children);
1329 * // => true
1330 *
1331 * _.isArrayLike('abc');
1332 * // => true
1333 *
1334 * _.isArrayLike(_.noop);
1335 * // => false
1336 */
1337function isArrayLike(value) {
1338 return value != null && isLength(value.length) && !isFunction(value);
1339}
1340
1341/**
1342 * This method is like `_.isArrayLike` except that it also checks if `value`
1343 * is an object.
1344 *
1345 * @static
1346 * @memberOf _
1347 * @since 4.0.0
1348 * @category Lang
1349 * @param {*} value The value to check.
1350 * @returns {boolean} Returns `true` if `value` is an array-like object,
1351 * else `false`.
1352 * @example
1353 *
1354 * _.isArrayLikeObject([1, 2, 3]);
1355 * // => true
1356 *
1357 * _.isArrayLikeObject(document.body.children);
1358 * // => true
1359 *
1360 * _.isArrayLikeObject('abc');
1361 * // => false
1362 *
1363 * _.isArrayLikeObject(_.noop);
1364 * // => false
1365 */
1366function isArrayLikeObject(value) {
1367 return isObjectLike(value) && isArrayLike(value);
1368}
1369
1370/**
1371 * Checks if `value` is classified as a `Function` object.
1372 *
1373 * @static
1374 * @memberOf _
1375 * @since 0.1.0
1376 * @category Lang
1377 * @param {*} value The value to check.
1378 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1379 * @example
1380 *
1381 * _.isFunction(_);
1382 * // => true
1383 *
1384 * _.isFunction(/abc/);
1385 * // => false
1386 */
1387function isFunction(value) {
1388 // The use of `Object#toString` avoids issues with the `typeof` operator
1389 // in Safari 8-9 which returns 'object' for typed array and other constructors.
1390 var tag = isObject(value) ? objectToString.call(value) : '';
1391 return tag == funcTag || tag == genTag;
1392}
1393
1394/**
1395 * Checks if `value` is a valid array-like length.
1396 *
1397 * **Note:** This method is loosely based on
1398 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1399 *
1400 * @static
1401 * @memberOf _
1402 * @since 4.0.0
1403 * @category Lang
1404 * @param {*} value The value to check.
1405 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1406 * @example
1407 *
1408 * _.isLength(3);
1409 * // => true
1410 *
1411 * _.isLength(Number.MIN_VALUE);
1412 * // => false
1413 *
1414 * _.isLength(Infinity);
1415 * // => false
1416 *
1417 * _.isLength('3');
1418 * // => false
1419 */
1420function isLength(value) {
1421 return typeof value == 'number' &&
1422 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1423}
1424
1425/**
1426 * Checks if `value` is the
1427 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1428 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1429 *
1430 * @static
1431 * @memberOf _
1432 * @since 0.1.0
1433 * @category Lang
1434 * @param {*} value The value to check.
1435 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1436 * @example
1437 *
1438 * _.isObject({});
1439 * // => true
1440 *
1441 * _.isObject([1, 2, 3]);
1442 * // => true
1443 *
1444 * _.isObject(_.noop);
1445 * // => true
1446 *
1447 * _.isObject(null);
1448 * // => false
1449 */
1450function isObject(value) {
1451 var type = typeof value;
1452 return !!value && (type == 'object' || type == 'function');
1453}
1454
1455/**
1456 * Checks if `value` is object-like. A value is object-like if it's not `null`
1457 * and has a `typeof` result of "object".
1458 *
1459 * @static
1460 * @memberOf _
1461 * @since 4.0.0
1462 * @category Lang
1463 * @param {*} value The value to check.
1464 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1465 * @example
1466 *
1467 * _.isObjectLike({});
1468 * // => true
1469 *
1470 * _.isObjectLike([1, 2, 3]);
1471 * // => true
1472 *
1473 * _.isObjectLike(_.noop);
1474 * // => false
1475 *
1476 * _.isObjectLike(null);
1477 * // => false
1478 */
1479function isObjectLike(value) {
1480 return !!value && typeof value == 'object';
1481}
1482
1483/**
1484 * Assigns own enumerable string keyed properties of source objects to the
1485 * destination object. Source objects are applied from left to right.
1486 * Subsequent sources overwrite property assignments of previous sources.
1487 *
1488 * **Note:** This method mutates `object` and is loosely based on
1489 * [`Object.assign`](https://mdn.io/Object/assign).
1490 *
1491 * @static
1492 * @memberOf _
1493 * @since 0.10.0
1494 * @category Object
1495 * @param {Object} object The destination object.
1496 * @param {...Object} [sources] The source objects.
1497 * @returns {Object} Returns `object`.
1498 * @see _.assignIn
1499 * @example
1500 *
1501 * function Foo() {
1502 * this.a = 1;
1503 * }
1504 *
1505 * function Bar() {
1506 * this.c = 3;
1507 * }
1508 *
1509 * Foo.prototype.b = 2;
1510 * Bar.prototype.d = 4;
1511 *
1512 * _.assign({ 'a': 0 }, new Foo, new Bar);
1513 * // => { 'a': 1, 'c': 3 }
1514 */
1515var assign = createAssigner(function(object, source) {
1516 if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
1517 copyObject(source, keys(source), object);
1518 return;
1519 }
1520 for (var key in source) {
1521 if (hasOwnProperty.call(source, key)) {
1522 assignValue(object, key, source[key]);
1523 }
1524 }
1525});
1526
1527/**
1528 * Creates an array of the own enumerable property names of `object`.
1529 *
1530 * **Note:** Non-object values are coerced to objects. See the
1531 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1532 * for more details.
1533 *
1534 * @static
1535 * @since 0.1.0
1536 * @memberOf _
1537 * @category Object
1538 * @param {Object} object The object to query.
1539 * @returns {Array} Returns the array of property names.
1540 * @example
1541 *
1542 * function Foo() {
1543 * this.a = 1;
1544 * this.b = 2;
1545 * }
1546 *
1547 * Foo.prototype.c = 3;
1548 *
1549 * _.keys(new Foo);
1550 * // => ['a', 'b'] (iteration order is not guaranteed)
1551 *
1552 * _.keys('hi');
1553 * // => ['0', '1']
1554 */
1555function keys(object) {
1556 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1557}
1558
1559module.exports = assign;
1560
1561
1562/***/ }),
1563
1564/***/ 2098:
1565/***/ ((module, exports, __webpack_require__) => {
1566
1567/* module decorator */ module = __webpack_require__.nmd(module);
1568/**
1569 * Lodash (Custom Build) <https://lodash.com/>
1570 * Build: `lodash modularize exports="npm" -o ./`
1571 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1572 * Released under MIT license <https://lodash.com/license>
1573 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1574 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1575 */
1576
1577/** Used as the size to enable large array optimizations. */
1578var LARGE_ARRAY_SIZE = 200;
1579
1580/** Used to stand-in for `undefined` hash values. */
1581var HASH_UNDEFINED = '__lodash_hash_undefined__';
1582
1583/** Used to detect hot functions by number of calls within a span of milliseconds. */
1584var HOT_COUNT = 800,
1585 HOT_SPAN = 16;
1586
1587/** Used as references for various `Number` constants. */
1588var MAX_SAFE_INTEGER = 9007199254740991;
1589
1590/** `Object#toString` result references. */
1591var argsTag = '[object Arguments]',
1592 arrayTag = '[object Array]',
1593 asyncTag = '[object AsyncFunction]',
1594 boolTag = '[object Boolean]',
1595 dateTag = '[object Date]',
1596 errorTag = '[object Error]',
1597 funcTag = '[object Function]',
1598 genTag = '[object GeneratorFunction]',
1599 mapTag = '[object Map]',
1600 numberTag = '[object Number]',
1601 nullTag = '[object Null]',
1602 objectTag = '[object Object]',
1603 proxyTag = '[object Proxy]',
1604 regexpTag = '[object RegExp]',
1605 setTag = '[object Set]',
1606 stringTag = '[object String]',
1607 undefinedTag = '[object Undefined]',
1608 weakMapTag = '[object WeakMap]';
1609
1610var arrayBufferTag = '[object ArrayBuffer]',
1611 dataViewTag = '[object DataView]',
1612 float32Tag = '[object Float32Array]',
1613 float64Tag = '[object Float64Array]',
1614 int8Tag = '[object Int8Array]',
1615 int16Tag = '[object Int16Array]',
1616 int32Tag = '[object Int32Array]',
1617 uint8Tag = '[object Uint8Array]',
1618 uint8ClampedTag = '[object Uint8ClampedArray]',
1619 uint16Tag = '[object Uint16Array]',
1620 uint32Tag = '[object Uint32Array]';
1621
1622/**
1623 * Used to match `RegExp`
1624 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1625 */
1626var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1627
1628/** Used to detect host constructors (Safari). */
1629var reIsHostCtor = /^\[object .+?Constructor\]$/;
1630
1631/** Used to detect unsigned integer values. */
1632var reIsUint = /^(?:0|[1-9]\d*)$/;
1633
1634/** Used to identify `toStringTag` values of typed arrays. */
1635var typedArrayTags = {};
1636typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1637typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1638typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1639typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1640typedArrayTags[uint32Tag] = true;
1641typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1642typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1643typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1644typedArrayTags[errorTag] = typedArrayTags[funcTag] =
1645typedArrayTags[mapTag] = typedArrayTags[numberTag] =
1646typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
1647typedArrayTags[setTag] = typedArrayTags[stringTag] =
1648typedArrayTags[weakMapTag] = false;
1649
1650/** Detect free variable `global` from Node.js. */
1651var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
1652
1653/** Detect free variable `self`. */
1654var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1655
1656/** Used as a reference to the global object. */
1657var root = freeGlobal || freeSelf || Function('return this')();
1658
1659/** Detect free variable `exports`. */
1660var freeExports = true && exports && !exports.nodeType && exports;
1661
1662/** Detect free variable `module`. */
1663var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
1664
1665/** Detect the popular CommonJS extension `module.exports`. */
1666var moduleExports = freeModule && freeModule.exports === freeExports;
1667
1668/** Detect free variable `process` from Node.js. */
1669var freeProcess = moduleExports && freeGlobal.process;
1670
1671/** Used to access faster Node.js helpers. */
1672var nodeUtil = (function() {
1673 try {
1674 // Use `util.types` for Node.js 10+.
1675 var types = freeModule && freeModule.require && freeModule.require('util').types;
1676
1677 if (types) {
1678 return types;
1679 }
1680
1681 // Legacy `process.binding('util')` for Node.js < 10.
1682 return freeProcess && freeProcess.binding && freeProcess.binding('util');
1683 } catch (e) {}
1684}());
1685
1686/* Node.js helper references. */
1687var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1688
1689/**
1690 * A faster alternative to `Function#apply`, this function invokes `func`
1691 * with the `this` binding of `thisArg` and the arguments of `args`.
1692 *
1693 * @private
1694 * @param {Function} func The function to invoke.
1695 * @param {*} thisArg The `this` binding of `func`.
1696 * @param {Array} args The arguments to invoke `func` with.
1697 * @returns {*} Returns the result of `func`.
1698 */
1699function apply(func, thisArg, args) {
1700 switch (args.length) {
1701 case 0: return func.call(thisArg);
1702 case 1: return func.call(thisArg, args[0]);
1703 case 2: return func.call(thisArg, args[0], args[1]);
1704 case 3: return func.call(thisArg, args[0], args[1], args[2]);
1705 }
1706 return func.apply(thisArg, args);
1707}
1708
1709/**
1710 * The base implementation of `_.times` without support for iteratee shorthands
1711 * or max array length checks.
1712 *
1713 * @private
1714 * @param {number} n The number of times to invoke `iteratee`.
1715 * @param {Function} iteratee The function invoked per iteration.
1716 * @returns {Array} Returns the array of results.
1717 */
1718function baseTimes(n, iteratee) {
1719 var index = -1,
1720 result = Array(n);
1721
1722 while (++index < n) {
1723 result[index] = iteratee(index);
1724 }
1725 return result;
1726}
1727
1728/**
1729 * The base implementation of `_.unary` without support for storing metadata.
1730 *
1731 * @private
1732 * @param {Function} func The function to cap arguments for.
1733 * @returns {Function} Returns the new capped function.
1734 */
1735function baseUnary(func) {
1736 return function(value) {
1737 return func(value);
1738 };
1739}
1740
1741/**
1742 * Gets the value at `key` of `object`.
1743 *
1744 * @private
1745 * @param {Object} [object] The object to query.
1746 * @param {string} key The key of the property to get.
1747 * @returns {*} Returns the property value.
1748 */
1749function getValue(object, key) {
1750 return object == null ? undefined : object[key];
1751}
1752
1753/**
1754 * Creates a unary function that invokes `func` with its argument transformed.
1755 *
1756 * @private
1757 * @param {Function} func The function to wrap.
1758 * @param {Function} transform The argument transform.
1759 * @returns {Function} Returns the new function.
1760 */
1761function overArg(func, transform) {
1762 return function(arg) {
1763 return func(transform(arg));
1764 };
1765}
1766
1767/** Used for built-in method references. */
1768var arrayProto = Array.prototype,
1769 funcProto = Function.prototype,
1770 objectProto = Object.prototype;
1771
1772/** Used to detect overreaching core-js shims. */
1773var coreJsData = root['__core-js_shared__'];
1774
1775/** Used to resolve the decompiled source of functions. */
1776var funcToString = funcProto.toString;
1777
1778/** Used to check objects for own properties. */
1779var hasOwnProperty = objectProto.hasOwnProperty;
1780
1781/** Used to detect methods masquerading as native. */
1782var maskSrcKey = (function() {
1783 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1784 return uid ? ('Symbol(src)_1.' + uid) : '';
1785}());
1786
1787/**
1788 * Used to resolve the
1789 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1790 * of values.
1791 */
1792var nativeObjectToString = objectProto.toString;
1793
1794/** Used to infer the `Object` constructor. */
1795var objectCtorString = funcToString.call(Object);
1796
1797/** Used to detect if a method is native. */
1798var reIsNative = RegExp('^' +
1799 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1800 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1801);
1802
1803/** Built-in value references. */
1804var Buffer = moduleExports ? root.Buffer : undefined,
1805 Symbol = root.Symbol,
1806 Uint8Array = root.Uint8Array,
1807 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1808 getPrototype = overArg(Object.getPrototypeOf, Object),
1809 objectCreate = Object.create,
1810 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1811 splice = arrayProto.splice,
1812 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1813
1814var defineProperty = (function() {
1815 try {
1816 var func = getNative(Object, 'defineProperty');
1817 func({}, '', {});
1818 return func;
1819 } catch (e) {}
1820}());
1821
1822/* Built-in method references for those with the same name as other `lodash` methods. */
1823var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1824 nativeMax = Math.max,
1825 nativeNow = Date.now;
1826
1827/* Built-in method references that are verified to be native. */
1828var Map = getNative(root, 'Map'),
1829 nativeCreate = getNative(Object, 'create');
1830
1831/**
1832 * The base implementation of `_.create` without support for assigning
1833 * properties to the created object.
1834 *
1835 * @private
1836 * @param {Object} proto The object to inherit from.
1837 * @returns {Object} Returns the new object.
1838 */
1839var baseCreate = (function() {
1840 function object() {}
1841 return function(proto) {
1842 if (!isObject(proto)) {
1843 return {};
1844 }
1845 if (objectCreate) {
1846 return objectCreate(proto);
1847 }
1848 object.prototype = proto;
1849 var result = new object;
1850 object.prototype = undefined;
1851 return result;
1852 };
1853}());
1854
1855/**
1856 * Creates a hash object.
1857 *
1858 * @private
1859 * @constructor
1860 * @param {Array} [entries] The key-value pairs to cache.
1861 */
1862function Hash(entries) {
1863 var index = -1,
1864 length = entries == null ? 0 : entries.length;
1865
1866 this.clear();
1867 while (++index < length) {
1868 var entry = entries[index];
1869 this.set(entry[0], entry[1]);
1870 }
1871}
1872
1873/**
1874 * Removes all key-value entries from the hash.
1875 *
1876 * @private
1877 * @name clear
1878 * @memberOf Hash
1879 */
1880function hashClear() {
1881 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1882 this.size = 0;
1883}
1884
1885/**
1886 * Removes `key` and its value from the hash.
1887 *
1888 * @private
1889 * @name delete
1890 * @memberOf Hash
1891 * @param {Object} hash The hash to modify.
1892 * @param {string} key The key of the value to remove.
1893 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1894 */
1895function hashDelete(key) {
1896 var result = this.has(key) && delete this.__data__[key];
1897 this.size -= result ? 1 : 0;
1898 return result;
1899}
1900
1901/**
1902 * Gets the hash value for `key`.
1903 *
1904 * @private
1905 * @name get
1906 * @memberOf Hash
1907 * @param {string} key The key of the value to get.
1908 * @returns {*} Returns the entry value.
1909 */
1910function hashGet(key) {
1911 var data = this.__data__;
1912 if (nativeCreate) {
1913 var result = data[key];
1914 return result === HASH_UNDEFINED ? undefined : result;
1915 }
1916 return hasOwnProperty.call(data, key) ? data[key] : undefined;
1917}
1918
1919/**
1920 * Checks if a hash value for `key` exists.
1921 *
1922 * @private
1923 * @name has
1924 * @memberOf Hash
1925 * @param {string} key The key of the entry to check.
1926 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1927 */
1928function hashHas(key) {
1929 var data = this.__data__;
1930 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1931}
1932
1933/**
1934 * Sets the hash `key` to `value`.
1935 *
1936 * @private
1937 * @name set
1938 * @memberOf Hash
1939 * @param {string} key The key of the value to set.
1940 * @param {*} value The value to set.
1941 * @returns {Object} Returns the hash instance.
1942 */
1943function hashSet(key, value) {
1944 var data = this.__data__;
1945 this.size += this.has(key) ? 0 : 1;
1946 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1947 return this;
1948}
1949
1950// Add methods to `Hash`.
1951Hash.prototype.clear = hashClear;
1952Hash.prototype['delete'] = hashDelete;
1953Hash.prototype.get = hashGet;
1954Hash.prototype.has = hashHas;
1955Hash.prototype.set = hashSet;
1956
1957/**
1958 * Creates an list cache object.
1959 *
1960 * @private
1961 * @constructor
1962 * @param {Array} [entries] The key-value pairs to cache.
1963 */
1964function ListCache(entries) {
1965 var index = -1,
1966 length = entries == null ? 0 : entries.length;
1967
1968 this.clear();
1969 while (++index < length) {
1970 var entry = entries[index];
1971 this.set(entry[0], entry[1]);
1972 }
1973}
1974
1975/**
1976 * Removes all key-value entries from the list cache.
1977 *
1978 * @private
1979 * @name clear
1980 * @memberOf ListCache
1981 */
1982function listCacheClear() {
1983 this.__data__ = [];
1984 this.size = 0;
1985}
1986
1987/**
1988 * Removes `key` and its value from the list cache.
1989 *
1990 * @private
1991 * @name delete
1992 * @memberOf ListCache
1993 * @param {string} key The key of the value to remove.
1994 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1995 */
1996function listCacheDelete(key) {
1997 var data = this.__data__,
1998 index = assocIndexOf(data, key);
1999
2000 if (index < 0) {
2001 return false;
2002 }
2003 var lastIndex = data.length - 1;
2004 if (index == lastIndex) {
2005 data.pop();
2006 } else {
2007 splice.call(data, index, 1);
2008 }
2009 --this.size;
2010 return true;
2011}
2012
2013/**
2014 * Gets the list cache value for `key`.
2015 *
2016 * @private
2017 * @name get
2018 * @memberOf ListCache
2019 * @param {string} key The key of the value to get.
2020 * @returns {*} Returns the entry value.
2021 */
2022function listCacheGet(key) {
2023 var data = this.__data__,
2024 index = assocIndexOf(data, key);
2025
2026 return index < 0 ? undefined : data[index][1];
2027}
2028
2029/**
2030 * Checks if a list cache value for `key` exists.
2031 *
2032 * @private
2033 * @name has
2034 * @memberOf ListCache
2035 * @param {string} key The key of the entry to check.
2036 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2037 */
2038function listCacheHas(key) {
2039 return assocIndexOf(this.__data__, key) > -1;
2040}
2041
2042/**
2043 * Sets the list cache `key` to `value`.
2044 *
2045 * @private
2046 * @name set
2047 * @memberOf ListCache
2048 * @param {string} key The key of the value to set.
2049 * @param {*} value The value to set.
2050 * @returns {Object} Returns the list cache instance.
2051 */
2052function listCacheSet(key, value) {
2053 var data = this.__data__,
2054 index = assocIndexOf(data, key);
2055
2056 if (index < 0) {
2057 ++this.size;
2058 data.push([key, value]);
2059 } else {
2060 data[index][1] = value;
2061 }
2062 return this;
2063}
2064
2065// Add methods to `ListCache`.
2066ListCache.prototype.clear = listCacheClear;
2067ListCache.prototype['delete'] = listCacheDelete;
2068ListCache.prototype.get = listCacheGet;
2069ListCache.prototype.has = listCacheHas;
2070ListCache.prototype.set = listCacheSet;
2071
2072/**
2073 * Creates a map cache object to store key-value pairs.
2074 *
2075 * @private
2076 * @constructor
2077 * @param {Array} [entries] The key-value pairs to cache.
2078 */
2079function MapCache(entries) {
2080 var index = -1,
2081 length = entries == null ? 0 : entries.length;
2082
2083 this.clear();
2084 while (++index < length) {
2085 var entry = entries[index];
2086 this.set(entry[0], entry[1]);
2087 }
2088}
2089
2090/**
2091 * Removes all key-value entries from the map.
2092 *
2093 * @private
2094 * @name clear
2095 * @memberOf MapCache
2096 */
2097function mapCacheClear() {
2098 this.size = 0;
2099 this.__data__ = {
2100 'hash': new Hash,
2101 'map': new (Map || ListCache),
2102 'string': new Hash
2103 };
2104}
2105
2106/**
2107 * Removes `key` and its value from the map.
2108 *
2109 * @private
2110 * @name delete
2111 * @memberOf MapCache
2112 * @param {string} key The key of the value to remove.
2113 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2114 */
2115function mapCacheDelete(key) {
2116 var result = getMapData(this, key)['delete'](key);
2117 this.size -= result ? 1 : 0;
2118 return result;
2119}
2120
2121/**
2122 * Gets the map value for `key`.
2123 *
2124 * @private
2125 * @name get
2126 * @memberOf MapCache
2127 * @param {string} key The key of the value to get.
2128 * @returns {*} Returns the entry value.
2129 */
2130function mapCacheGet(key) {
2131 return getMapData(this, key).get(key);
2132}
2133
2134/**
2135 * Checks if a map value for `key` exists.
2136 *
2137 * @private
2138 * @name has
2139 * @memberOf MapCache
2140 * @param {string} key The key of the entry to check.
2141 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2142 */
2143function mapCacheHas(key) {
2144 return getMapData(this, key).has(key);
2145}
2146
2147/**
2148 * Sets the map `key` to `value`.
2149 *
2150 * @private
2151 * @name set
2152 * @memberOf MapCache
2153 * @param {string} key The key of the value to set.
2154 * @param {*} value The value to set.
2155 * @returns {Object} Returns the map cache instance.
2156 */
2157function mapCacheSet(key, value) {
2158 var data = getMapData(this, key),
2159 size = data.size;
2160
2161 data.set(key, value);
2162 this.size += data.size == size ? 0 : 1;
2163 return this;
2164}
2165
2166// Add methods to `MapCache`.
2167MapCache.prototype.clear = mapCacheClear;
2168MapCache.prototype['delete'] = mapCacheDelete;
2169MapCache.prototype.get = mapCacheGet;
2170MapCache.prototype.has = mapCacheHas;
2171MapCache.prototype.set = mapCacheSet;
2172
2173/**
2174 * Creates a stack cache object to store key-value pairs.
2175 *
2176 * @private
2177 * @constructor
2178 * @param {Array} [entries] The key-value pairs to cache.
2179 */
2180function Stack(entries) {
2181 var data = this.__data__ = new ListCache(entries);
2182 this.size = data.size;
2183}
2184
2185/**
2186 * Removes all key-value entries from the stack.
2187 *
2188 * @private
2189 * @name clear
2190 * @memberOf Stack
2191 */
2192function stackClear() {
2193 this.__data__ = new ListCache;
2194 this.size = 0;
2195}
2196
2197/**
2198 * Removes `key` and its value from the stack.
2199 *
2200 * @private
2201 * @name delete
2202 * @memberOf Stack
2203 * @param {string} key The key of the value to remove.
2204 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2205 */
2206function stackDelete(key) {
2207 var data = this.__data__,
2208 result = data['delete'](key);
2209
2210 this.size = data.size;
2211 return result;
2212}
2213
2214/**
2215 * Gets the stack value for `key`.
2216 *
2217 * @private
2218 * @name get
2219 * @memberOf Stack
2220 * @param {string} key The key of the value to get.
2221 * @returns {*} Returns the entry value.
2222 */
2223function stackGet(key) {
2224 return this.__data__.get(key);
2225}
2226
2227/**
2228 * Checks if a stack value for `key` exists.
2229 *
2230 * @private
2231 * @name has
2232 * @memberOf Stack
2233 * @param {string} key The key of the entry to check.
2234 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2235 */
2236function stackHas(key) {
2237 return this.__data__.has(key);
2238}
2239
2240/**
2241 * Sets the stack `key` to `value`.
2242 *
2243 * @private
2244 * @name set
2245 * @memberOf Stack
2246 * @param {string} key The key of the value to set.
2247 * @param {*} value The value to set.
2248 * @returns {Object} Returns the stack cache instance.
2249 */
2250function stackSet(key, value) {
2251 var data = this.__data__;
2252 if (data instanceof ListCache) {
2253 var pairs = data.__data__;
2254 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2255 pairs.push([key, value]);
2256 this.size = ++data.size;
2257 return this;
2258 }
2259 data = this.__data__ = new MapCache(pairs);
2260 }
2261 data.set(key, value);
2262 this.size = data.size;
2263 return this;
2264}
2265
2266// Add methods to `Stack`.
2267Stack.prototype.clear = stackClear;
2268Stack.prototype['delete'] = stackDelete;
2269Stack.prototype.get = stackGet;
2270Stack.prototype.has = stackHas;
2271Stack.prototype.set = stackSet;
2272
2273/**
2274 * Creates an array of the enumerable property names of the array-like `value`.
2275 *
2276 * @private
2277 * @param {*} value The value to query.
2278 * @param {boolean} inherited Specify returning inherited property names.
2279 * @returns {Array} Returns the array of property names.
2280 */
2281function arrayLikeKeys(value, inherited) {
2282 var isArr = isArray(value),
2283 isArg = !isArr && isArguments(value),
2284 isBuff = !isArr && !isArg && isBuffer(value),
2285 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2286 skipIndexes = isArr || isArg || isBuff || isType,
2287 result = skipIndexes ? baseTimes(value.length, String) : [],
2288 length = result.length;
2289
2290 for (var key in value) {
2291 if ((inherited || hasOwnProperty.call(value, key)) &&
2292 !(skipIndexes && (
2293 // Safari 9 has enumerable `arguments.length` in strict mode.
2294 key == 'length' ||
2295 // Node.js 0.10 has enumerable non-index properties on buffers.
2296 (isBuff && (key == 'offset' || key == 'parent')) ||
2297 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2298 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2299 // Skip index properties.
2300 isIndex(key, length)
2301 ))) {
2302 result.push(key);
2303 }
2304 }
2305 return result;
2306}
2307
2308/**
2309 * This function is like `assignValue` except that it doesn't assign
2310 * `undefined` values.
2311 *
2312 * @private
2313 * @param {Object} object The object to modify.
2314 * @param {string} key The key of the property to assign.
2315 * @param {*} value The value to assign.
2316 */
2317function assignMergeValue(object, key, value) {
2318 if ((value !== undefined && !eq(object[key], value)) ||
2319 (value === undefined && !(key in object))) {
2320 baseAssignValue(object, key, value);
2321 }
2322}
2323
2324/**
2325 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2326 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2327 * for equality comparisons.
2328 *
2329 * @private
2330 * @param {Object} object The object to modify.
2331 * @param {string} key The key of the property to assign.
2332 * @param {*} value The value to assign.
2333 */
2334function assignValue(object, key, value) {
2335 var objValue = object[key];
2336 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2337 (value === undefined && !(key in object))) {
2338 baseAssignValue(object, key, value);
2339 }
2340}
2341
2342/**
2343 * Gets the index at which the `key` is found in `array` of key-value pairs.
2344 *
2345 * @private
2346 * @param {Array} array The array to inspect.
2347 * @param {*} key The key to search for.
2348 * @returns {number} Returns the index of the matched value, else `-1`.
2349 */
2350function assocIndexOf(array, key) {
2351 var length = array.length;
2352 while (length--) {
2353 if (eq(array[length][0], key)) {
2354 return length;
2355 }
2356 }
2357 return -1;
2358}
2359
2360/**
2361 * The base implementation of `assignValue` and `assignMergeValue` without
2362 * value checks.
2363 *
2364 * @private
2365 * @param {Object} object The object to modify.
2366 * @param {string} key The key of the property to assign.
2367 * @param {*} value The value to assign.
2368 */
2369function baseAssignValue(object, key, value) {
2370 if (key == '__proto__' && defineProperty) {
2371 defineProperty(object, key, {
2372 'configurable': true,
2373 'enumerable': true,
2374 'value': value,
2375 'writable': true
2376 });
2377 } else {
2378 object[key] = value;
2379 }
2380}
2381
2382/**
2383 * The base implementation of `baseForOwn` which iterates over `object`
2384 * properties returned by `keysFunc` and invokes `iteratee` for each property.
2385 * Iteratee functions may exit iteration early by explicitly returning `false`.
2386 *
2387 * @private
2388 * @param {Object} object The object to iterate over.
2389 * @param {Function} iteratee The function invoked per iteration.
2390 * @param {Function} keysFunc The function to get the keys of `object`.
2391 * @returns {Object} Returns `object`.
2392 */
2393var baseFor = createBaseFor();
2394
2395/**
2396 * The base implementation of `getTag` without fallbacks for buggy environments.
2397 *
2398 * @private
2399 * @param {*} value The value to query.
2400 * @returns {string} Returns the `toStringTag`.
2401 */
2402function baseGetTag(value) {
2403 if (value == null) {
2404 return value === undefined ? undefinedTag : nullTag;
2405 }
2406 return (symToStringTag && symToStringTag in Object(value))
2407 ? getRawTag(value)
2408 : objectToString(value);
2409}
2410
2411/**
2412 * The base implementation of `_.isArguments`.
2413 *
2414 * @private
2415 * @param {*} value The value to check.
2416 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2417 */
2418function baseIsArguments(value) {
2419 return isObjectLike(value) && baseGetTag(value) == argsTag;
2420}
2421
2422/**
2423 * The base implementation of `_.isNative` without bad shim checks.
2424 *
2425 * @private
2426 * @param {*} value The value to check.
2427 * @returns {boolean} Returns `true` if `value` is a native function,
2428 * else `false`.
2429 */
2430function baseIsNative(value) {
2431 if (!isObject(value) || isMasked(value)) {
2432 return false;
2433 }
2434 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
2435 return pattern.test(toSource(value));
2436}
2437
2438/**
2439 * The base implementation of `_.isTypedArray` without Node.js optimizations.
2440 *
2441 * @private
2442 * @param {*} value The value to check.
2443 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2444 */
2445function baseIsTypedArray(value) {
2446 return isObjectLike(value) &&
2447 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
2448}
2449
2450/**
2451 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2452 *
2453 * @private
2454 * @param {Object} object The object to query.
2455 * @returns {Array} Returns the array of property names.
2456 */
2457function baseKeysIn(object) {
2458 if (!isObject(object)) {
2459 return nativeKeysIn(object);
2460 }
2461 var isProto = isPrototype(object),
2462 result = [];
2463
2464 for (var key in object) {
2465 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
2466 result.push(key);
2467 }
2468 }
2469 return result;
2470}
2471
2472/**
2473 * The base implementation of `_.merge` without support for multiple sources.
2474 *
2475 * @private
2476 * @param {Object} object The destination object.
2477 * @param {Object} source The source object.
2478 * @param {number} srcIndex The index of `source`.
2479 * @param {Function} [customizer] The function to customize merged values.
2480 * @param {Object} [stack] Tracks traversed source values and their merged
2481 * counterparts.
2482 */
2483function baseMerge(object, source, srcIndex, customizer, stack) {
2484 if (object === source) {
2485 return;
2486 }
2487 baseFor(source, function(srcValue, key) {
2488 stack || (stack = new Stack);
2489 if (isObject(srcValue)) {
2490 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
2491 }
2492 else {
2493 var newValue = customizer
2494 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
2495 : undefined;
2496
2497 if (newValue === undefined) {
2498 newValue = srcValue;
2499 }
2500 assignMergeValue(object, key, newValue);
2501 }
2502 }, keysIn);
2503}
2504
2505/**
2506 * A specialized version of `baseMerge` for arrays and objects which performs
2507 * deep merges and tracks traversed objects enabling objects with circular
2508 * references to be merged.
2509 *
2510 * @private
2511 * @param {Object} object The destination object.
2512 * @param {Object} source The source object.
2513 * @param {string} key The key of the value to merge.
2514 * @param {number} srcIndex The index of `source`.
2515 * @param {Function} mergeFunc The function to merge values.
2516 * @param {Function} [customizer] The function to customize assigned values.
2517 * @param {Object} [stack] Tracks traversed source values and their merged
2518 * counterparts.
2519 */
2520function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
2521 var objValue = safeGet(object, key),
2522 srcValue = safeGet(source, key),
2523 stacked = stack.get(srcValue);
2524
2525 if (stacked) {
2526 assignMergeValue(object, key, stacked);
2527 return;
2528 }
2529 var newValue = customizer
2530 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
2531 : undefined;
2532
2533 var isCommon = newValue === undefined;
2534
2535 if (isCommon) {
2536 var isArr = isArray(srcValue),
2537 isBuff = !isArr && isBuffer(srcValue),
2538 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
2539
2540 newValue = srcValue;
2541 if (isArr || isBuff || isTyped) {
2542 if (isArray(objValue)) {
2543 newValue = objValue;
2544 }
2545 else if (isArrayLikeObject(objValue)) {
2546 newValue = copyArray(objValue);
2547 }
2548 else if (isBuff) {
2549 isCommon = false;
2550 newValue = cloneBuffer(srcValue, true);
2551 }
2552 else if (isTyped) {
2553 isCommon = false;
2554 newValue = cloneTypedArray(srcValue, true);
2555 }
2556 else {
2557 newValue = [];
2558 }
2559 }
2560 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2561 newValue = objValue;
2562 if (isArguments(objValue)) {
2563 newValue = toPlainObject(objValue);
2564 }
2565 else if (!isObject(objValue) || isFunction(objValue)) {
2566 newValue = initCloneObject(srcValue);
2567 }
2568 }
2569 else {
2570 isCommon = false;
2571 }
2572 }
2573 if (isCommon) {
2574 // Recursively merge objects and arrays (susceptible to call stack limits).
2575 stack.set(srcValue, newValue);
2576 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
2577 stack['delete'](srcValue);
2578 }
2579 assignMergeValue(object, key, newValue);
2580}
2581
2582/**
2583 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
2584 *
2585 * @private
2586 * @param {Function} func The function to apply a rest parameter to.
2587 * @param {number} [start=func.length-1] The start position of the rest parameter.
2588 * @returns {Function} Returns the new function.
2589 */
2590function baseRest(func, start) {
2591 return setToString(overRest(func, start, identity), func + '');
2592}
2593
2594/**
2595 * The base implementation of `setToString` without support for hot loop shorting.
2596 *
2597 * @private
2598 * @param {Function} func The function to modify.
2599 * @param {Function} string The `toString` result.
2600 * @returns {Function} Returns `func`.
2601 */
2602var baseSetToString = !defineProperty ? identity : function(func, string) {
2603 return defineProperty(func, 'toString', {
2604 'configurable': true,
2605 'enumerable': false,
2606 'value': constant(string),
2607 'writable': true
2608 });
2609};
2610
2611/**
2612 * Creates a clone of `buffer`.
2613 *
2614 * @private
2615 * @param {Buffer} buffer The buffer to clone.
2616 * @param {boolean} [isDeep] Specify a deep clone.
2617 * @returns {Buffer} Returns the cloned buffer.
2618 */
2619function cloneBuffer(buffer, isDeep) {
2620 if (isDeep) {
2621 return buffer.slice();
2622 }
2623 var length = buffer.length,
2624 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2625
2626 buffer.copy(result);
2627 return result;
2628}
2629
2630/**
2631 * Creates a clone of `arrayBuffer`.
2632 *
2633 * @private
2634 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2635 * @returns {ArrayBuffer} Returns the cloned array buffer.
2636 */
2637function cloneArrayBuffer(arrayBuffer) {
2638 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2639 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2640 return result;
2641}
2642
2643/**
2644 * Creates a clone of `typedArray`.
2645 *
2646 * @private
2647 * @param {Object} typedArray The typed array to clone.
2648 * @param {boolean} [isDeep] Specify a deep clone.
2649 * @returns {Object} Returns the cloned typed array.
2650 */
2651function cloneTypedArray(typedArray, isDeep) {
2652 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
2653 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2654}
2655
2656/**
2657 * Copies the values of `source` to `array`.
2658 *
2659 * @private
2660 * @param {Array} source The array to copy values from.
2661 * @param {Array} [array=[]] The array to copy values to.
2662 * @returns {Array} Returns `array`.
2663 */
2664function copyArray(source, array) {
2665 var index = -1,
2666 length = source.length;
2667
2668 array || (array = Array(length));
2669 while (++index < length) {
2670 array[index] = source[index];
2671 }
2672 return array;
2673}
2674
2675/**
2676 * Copies properties of `source` to `object`.
2677 *
2678 * @private
2679 * @param {Object} source The object to copy properties from.
2680 * @param {Array} props The property identifiers to copy.
2681 * @param {Object} [object={}] The object to copy properties to.
2682 * @param {Function} [customizer] The function to customize copied values.
2683 * @returns {Object} Returns `object`.
2684 */
2685function copyObject(source, props, object, customizer) {
2686 var isNew = !object;
2687 object || (object = {});
2688
2689 var index = -1,
2690 length = props.length;
2691
2692 while (++index < length) {
2693 var key = props[index];
2694
2695 var newValue = customizer
2696 ? customizer(object[key], source[key], key, object, source)
2697 : undefined;
2698
2699 if (newValue === undefined) {
2700 newValue = source[key];
2701 }
2702 if (isNew) {
2703 baseAssignValue(object, key, newValue);
2704 } else {
2705 assignValue(object, key, newValue);
2706 }
2707 }
2708 return object;
2709}
2710
2711/**
2712 * Creates a function like `_.assign`.
2713 *
2714 * @private
2715 * @param {Function} assigner The function to assign values.
2716 * @returns {Function} Returns the new assigner function.
2717 */
2718function createAssigner(assigner) {
2719 return baseRest(function(object, sources) {
2720 var index = -1,
2721 length = sources.length,
2722 customizer = length > 1 ? sources[length - 1] : undefined,
2723 guard = length > 2 ? sources[2] : undefined;
2724
2725 customizer = (assigner.length > 3 && typeof customizer == 'function')
2726 ? (length--, customizer)
2727 : undefined;
2728
2729 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
2730 customizer = length < 3 ? undefined : customizer;
2731 length = 1;
2732 }
2733 object = Object(object);
2734 while (++index < length) {
2735 var source = sources[index];
2736 if (source) {
2737 assigner(object, source, index, customizer);
2738 }
2739 }
2740 return object;
2741 });
2742}
2743
2744/**
2745 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
2746 *
2747 * @private
2748 * @param {boolean} [fromRight] Specify iterating from right to left.
2749 * @returns {Function} Returns the new base function.
2750 */
2751function createBaseFor(fromRight) {
2752 return function(object, iteratee, keysFunc) {
2753 var index = -1,
2754 iterable = Object(object),
2755 props = keysFunc(object),
2756 length = props.length;
2757
2758 while (length--) {
2759 var key = props[fromRight ? length : ++index];
2760 if (iteratee(iterable[key], key, iterable) === false) {
2761 break;
2762 }
2763 }
2764 return object;
2765 };
2766}
2767
2768/**
2769 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
2770 * objects into destination objects that are passed thru.
2771 *
2772 * @private
2773 * @param {*} objValue The destination value.
2774 * @param {*} srcValue The source value.
2775 * @param {string} key The key of the property to merge.
2776 * @param {Object} object The parent object of `objValue`.
2777 * @param {Object} source The parent object of `srcValue`.
2778 * @param {Object} [stack] Tracks traversed source values and their merged
2779 * counterparts.
2780 * @returns {*} Returns the value to assign.
2781 */
2782function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
2783 if (isObject(objValue) && isObject(srcValue)) {
2784 // Recursively merge objects and arrays (susceptible to call stack limits).
2785 stack.set(srcValue, objValue);
2786 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
2787 stack['delete'](srcValue);
2788 }
2789 return objValue;
2790}
2791
2792/**
2793 * Gets the data for `map`.
2794 *
2795 * @private
2796 * @param {Object} map The map to query.
2797 * @param {string} key The reference key.
2798 * @returns {*} Returns the map data.
2799 */
2800function getMapData(map, key) {
2801 var data = map.__data__;
2802 return isKeyable(key)
2803 ? data[typeof key == 'string' ? 'string' : 'hash']
2804 : data.map;
2805}
2806
2807/**
2808 * Gets the native function at `key` of `object`.
2809 *
2810 * @private
2811 * @param {Object} object The object to query.
2812 * @param {string} key The key of the method to get.
2813 * @returns {*} Returns the function if it's native, else `undefined`.
2814 */
2815function getNative(object, key) {
2816 var value = getValue(object, key);
2817 return baseIsNative(value) ? value : undefined;
2818}
2819
2820/**
2821 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
2822 *
2823 * @private
2824 * @param {*} value The value to query.
2825 * @returns {string} Returns the raw `toStringTag`.
2826 */
2827function getRawTag(value) {
2828 var isOwn = hasOwnProperty.call(value, symToStringTag),
2829 tag = value[symToStringTag];
2830
2831 try {
2832 value[symToStringTag] = undefined;
2833 var unmasked = true;
2834 } catch (e) {}
2835
2836 var result = nativeObjectToString.call(value);
2837 if (unmasked) {
2838 if (isOwn) {
2839 value[symToStringTag] = tag;
2840 } else {
2841 delete value[symToStringTag];
2842 }
2843 }
2844 return result;
2845}
2846
2847/**
2848 * Initializes an object clone.
2849 *
2850 * @private
2851 * @param {Object} object The object to clone.
2852 * @returns {Object} Returns the initialized clone.
2853 */
2854function initCloneObject(object) {
2855 return (typeof object.constructor == 'function' && !isPrototype(object))
2856 ? baseCreate(getPrototype(object))
2857 : {};
2858}
2859
2860/**
2861 * Checks if `value` is a valid array-like index.
2862 *
2863 * @private
2864 * @param {*} value The value to check.
2865 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2866 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2867 */
2868function isIndex(value, length) {
2869 var type = typeof value;
2870 length = length == null ? MAX_SAFE_INTEGER : length;
2871
2872 return !!length &&
2873 (type == 'number' ||
2874 (type != 'symbol' && reIsUint.test(value))) &&
2875 (value > -1 && value % 1 == 0 && value < length);
2876}
2877
2878/**
2879 * Checks if the given arguments are from an iteratee call.
2880 *
2881 * @private
2882 * @param {*} value The potential iteratee value argument.
2883 * @param {*} index The potential iteratee index or key argument.
2884 * @param {*} object The potential iteratee object argument.
2885 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
2886 * else `false`.
2887 */
2888function isIterateeCall(value, index, object) {
2889 if (!isObject(object)) {
2890 return false;
2891 }
2892 var type = typeof index;
2893 if (type == 'number'
2894 ? (isArrayLike(object) && isIndex(index, object.length))
2895 : (type == 'string' && index in object)
2896 ) {
2897 return eq(object[index], value);
2898 }
2899 return false;
2900}
2901
2902/**
2903 * Checks if `value` is suitable for use as unique object key.
2904 *
2905 * @private
2906 * @param {*} value The value to check.
2907 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2908 */
2909function isKeyable(value) {
2910 var type = typeof value;
2911 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2912 ? (value !== '__proto__')
2913 : (value === null);
2914}
2915
2916/**
2917 * Checks if `func` has its source masked.
2918 *
2919 * @private
2920 * @param {Function} func The function to check.
2921 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
2922 */
2923function isMasked(func) {
2924 return !!maskSrcKey && (maskSrcKey in func);
2925}
2926
2927/**
2928 * Checks if `value` is likely a prototype object.
2929 *
2930 * @private
2931 * @param {*} value The value to check.
2932 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
2933 */
2934function isPrototype(value) {
2935 var Ctor = value && value.constructor,
2936 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
2937
2938 return value === proto;
2939}
2940
2941/**
2942 * This function is like
2943 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2944 * except that it includes inherited enumerable properties.
2945 *
2946 * @private
2947 * @param {Object} object The object to query.
2948 * @returns {Array} Returns the array of property names.
2949 */
2950function nativeKeysIn(object) {
2951 var result = [];
2952 if (object != null) {
2953 for (var key in Object(object)) {
2954 result.push(key);
2955 }
2956 }
2957 return result;
2958}
2959
2960/**
2961 * Converts `value` to a string using `Object.prototype.toString`.
2962 *
2963 * @private
2964 * @param {*} value The value to convert.
2965 * @returns {string} Returns the converted string.
2966 */
2967function objectToString(value) {
2968 return nativeObjectToString.call(value);
2969}
2970
2971/**
2972 * A specialized version of `baseRest` which transforms the rest array.
2973 *
2974 * @private
2975 * @param {Function} func The function to apply a rest parameter to.
2976 * @param {number} [start=func.length-1] The start position of the rest parameter.
2977 * @param {Function} transform The rest array transform.
2978 * @returns {Function} Returns the new function.
2979 */
2980function overRest(func, start, transform) {
2981 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
2982 return function() {
2983 var args = arguments,
2984 index = -1,
2985 length = nativeMax(args.length - start, 0),
2986 array = Array(length);
2987
2988 while (++index < length) {
2989 array[index] = args[start + index];
2990 }
2991 index = -1;
2992 var otherArgs = Array(start + 1);
2993 while (++index < start) {
2994 otherArgs[index] = args[index];
2995 }
2996 otherArgs[start] = transform(array);
2997 return apply(func, this, otherArgs);
2998 };
2999}
3000
3001/**
3002 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
3003 *
3004 * @private
3005 * @param {Object} object The object to query.
3006 * @param {string} key The key of the property to get.
3007 * @returns {*} Returns the property value.
3008 */
3009function safeGet(object, key) {
3010 if (key === 'constructor' && typeof object[key] === 'function') {
3011 return;
3012 }
3013
3014 if (key == '__proto__') {
3015 return;
3016 }
3017
3018 return object[key];
3019}
3020
3021/**
3022 * Sets the `toString` method of `func` to return `string`.
3023 *
3024 * @private
3025 * @param {Function} func The function to modify.
3026 * @param {Function} string The `toString` result.
3027 * @returns {Function} Returns `func`.
3028 */
3029var setToString = shortOut(baseSetToString);
3030
3031/**
3032 * Creates a function that'll short out and invoke `identity` instead
3033 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
3034 * milliseconds.
3035 *
3036 * @private
3037 * @param {Function} func The function to restrict.
3038 * @returns {Function} Returns the new shortable function.
3039 */
3040function shortOut(func) {
3041 var count = 0,
3042 lastCalled = 0;
3043
3044 return function() {
3045 var stamp = nativeNow(),
3046 remaining = HOT_SPAN - (stamp - lastCalled);
3047
3048 lastCalled = stamp;
3049 if (remaining > 0) {
3050 if (++count >= HOT_COUNT) {
3051 return arguments[0];
3052 }
3053 } else {
3054 count = 0;
3055 }
3056 return func.apply(undefined, arguments);
3057 };
3058}
3059
3060/**
3061 * Converts `func` to its source code.
3062 *
3063 * @private
3064 * @param {Function} func The function to convert.
3065 * @returns {string} Returns the source code.
3066 */
3067function toSource(func) {
3068 if (func != null) {
3069 try {
3070 return funcToString.call(func);
3071 } catch (e) {}
3072 try {
3073 return (func + '');
3074 } catch (e) {}
3075 }
3076 return '';
3077}
3078
3079/**
3080 * Performs a
3081 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3082 * comparison between two values to determine if they are equivalent.
3083 *
3084 * @static
3085 * @memberOf _
3086 * @since 4.0.0
3087 * @category Lang
3088 * @param {*} value The value to compare.
3089 * @param {*} other The other value to compare.
3090 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3091 * @example
3092 *
3093 * var object = { 'a': 1 };
3094 * var other = { 'a': 1 };
3095 *
3096 * _.eq(object, object);
3097 * // => true
3098 *
3099 * _.eq(object, other);
3100 * // => false
3101 *
3102 * _.eq('a', 'a');
3103 * // => true
3104 *
3105 * _.eq('a', Object('a'));
3106 * // => false
3107 *
3108 * _.eq(NaN, NaN);
3109 * // => true
3110 */
3111function eq(value, other) {
3112 return value === other || (value !== value && other !== other);
3113}
3114
3115/**
3116 * Checks if `value` is likely an `arguments` object.
3117 *
3118 * @static
3119 * @memberOf _
3120 * @since 0.1.0
3121 * @category Lang
3122 * @param {*} value The value to check.
3123 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3124 * else `false`.
3125 * @example
3126 *
3127 * _.isArguments(function() { return arguments; }());
3128 * // => true
3129 *
3130 * _.isArguments([1, 2, 3]);
3131 * // => false
3132 */
3133var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
3134 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
3135 !propertyIsEnumerable.call(value, 'callee');
3136};
3137
3138/**
3139 * Checks if `value` is classified as an `Array` object.
3140 *
3141 * @static
3142 * @memberOf _
3143 * @since 0.1.0
3144 * @category Lang
3145 * @param {*} value The value to check.
3146 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3147 * @example
3148 *
3149 * _.isArray([1, 2, 3]);
3150 * // => true
3151 *
3152 * _.isArray(document.body.children);
3153 * // => false
3154 *
3155 * _.isArray('abc');
3156 * // => false
3157 *
3158 * _.isArray(_.noop);
3159 * // => false
3160 */
3161var isArray = Array.isArray;
3162
3163/**
3164 * Checks if `value` is array-like. A value is considered array-like if it's
3165 * not a function and has a `value.length` that's an integer greater than or
3166 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3167 *
3168 * @static
3169 * @memberOf _
3170 * @since 4.0.0
3171 * @category Lang
3172 * @param {*} value The value to check.
3173 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3174 * @example
3175 *
3176 * _.isArrayLike([1, 2, 3]);
3177 * // => true
3178 *
3179 * _.isArrayLike(document.body.children);
3180 * // => true
3181 *
3182 * _.isArrayLike('abc');
3183 * // => true
3184 *
3185 * _.isArrayLike(_.noop);
3186 * // => false
3187 */
3188function isArrayLike(value) {
3189 return value != null && isLength(value.length) && !isFunction(value);
3190}
3191
3192/**
3193 * This method is like `_.isArrayLike` except that it also checks if `value`
3194 * is an object.
3195 *
3196 * @static
3197 * @memberOf _
3198 * @since 4.0.0
3199 * @category Lang
3200 * @param {*} value The value to check.
3201 * @returns {boolean} Returns `true` if `value` is an array-like object,
3202 * else `false`.
3203 * @example
3204 *
3205 * _.isArrayLikeObject([1, 2, 3]);
3206 * // => true
3207 *
3208 * _.isArrayLikeObject(document.body.children);
3209 * // => true
3210 *
3211 * _.isArrayLikeObject('abc');
3212 * // => false
3213 *
3214 * _.isArrayLikeObject(_.noop);
3215 * // => false
3216 */
3217function isArrayLikeObject(value) {
3218 return isObjectLike(value) && isArrayLike(value);
3219}
3220
3221/**
3222 * Checks if `value` is a buffer.
3223 *
3224 * @static
3225 * @memberOf _
3226 * @since 4.3.0
3227 * @category Lang
3228 * @param {*} value The value to check.
3229 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
3230 * @example
3231 *
3232 * _.isBuffer(new Buffer(2));
3233 * // => true
3234 *
3235 * _.isBuffer(new Uint8Array(2));
3236 * // => false
3237 */
3238var isBuffer = nativeIsBuffer || stubFalse;
3239
3240/**
3241 * Checks if `value` is classified as a `Function` object.
3242 *
3243 * @static
3244 * @memberOf _
3245 * @since 0.1.0
3246 * @category Lang
3247 * @param {*} value The value to check.
3248 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3249 * @example
3250 *
3251 * _.isFunction(_);
3252 * // => true
3253 *
3254 * _.isFunction(/abc/);
3255 * // => false
3256 */
3257function isFunction(value) {
3258 if (!isObject(value)) {
3259 return false;
3260 }
3261 // The use of `Object#toString` avoids issues with the `typeof` operator
3262 // in Safari 9 which returns 'object' for typed arrays and other constructors.
3263 var tag = baseGetTag(value);
3264 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
3265}
3266
3267/**
3268 * Checks if `value` is a valid array-like length.
3269 *
3270 * **Note:** This method is loosely based on
3271 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3272 *
3273 * @static
3274 * @memberOf _
3275 * @since 4.0.0
3276 * @category Lang
3277 * @param {*} value The value to check.
3278 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3279 * @example
3280 *
3281 * _.isLength(3);
3282 * // => true
3283 *
3284 * _.isLength(Number.MIN_VALUE);
3285 * // => false
3286 *
3287 * _.isLength(Infinity);
3288 * // => false
3289 *
3290 * _.isLength('3');
3291 * // => false
3292 */
3293function isLength(value) {
3294 return typeof value == 'number' &&
3295 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3296}
3297
3298/**
3299 * Checks if `value` is the
3300 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3301 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3302 *
3303 * @static
3304 * @memberOf _
3305 * @since 0.1.0
3306 * @category Lang
3307 * @param {*} value The value to check.
3308 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3309 * @example
3310 *
3311 * _.isObject({});
3312 * // => true
3313 *
3314 * _.isObject([1, 2, 3]);
3315 * // => true
3316 *
3317 * _.isObject(_.noop);
3318 * // => true
3319 *
3320 * _.isObject(null);
3321 * // => false
3322 */
3323function isObject(value) {
3324 var type = typeof value;
3325 return value != null && (type == 'object' || type == 'function');
3326}
3327
3328/**
3329 * Checks if `value` is object-like. A value is object-like if it's not `null`
3330 * and has a `typeof` result of "object".
3331 *
3332 * @static
3333 * @memberOf _
3334 * @since 4.0.0
3335 * @category Lang
3336 * @param {*} value The value to check.
3337 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3338 * @example
3339 *
3340 * _.isObjectLike({});
3341 * // => true
3342 *
3343 * _.isObjectLike([1, 2, 3]);
3344 * // => true
3345 *
3346 * _.isObjectLike(_.noop);
3347 * // => false
3348 *
3349 * _.isObjectLike(null);
3350 * // => false
3351 */
3352function isObjectLike(value) {
3353 return value != null && typeof value == 'object';
3354}
3355
3356/**
3357 * Checks if `value` is a plain object, that is, an object created by the
3358 * `Object` constructor or one with a `[[Prototype]]` of `null`.
3359 *
3360 * @static
3361 * @memberOf _
3362 * @since 0.8.0
3363 * @category Lang
3364 * @param {*} value The value to check.
3365 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
3366 * @example
3367 *
3368 * function Foo() {
3369 * this.a = 1;
3370 * }
3371 *
3372 * _.isPlainObject(new Foo);
3373 * // => false
3374 *
3375 * _.isPlainObject([1, 2, 3]);
3376 * // => false
3377 *
3378 * _.isPlainObject({ 'x': 0, 'y': 0 });
3379 * // => true
3380 *
3381 * _.isPlainObject(Object.create(null));
3382 * // => true
3383 */
3384function isPlainObject(value) {
3385 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
3386 return false;
3387 }
3388 var proto = getPrototype(value);
3389 if (proto === null) {
3390 return true;
3391 }
3392 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
3393 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
3394 funcToString.call(Ctor) == objectCtorString;
3395}
3396
3397/**
3398 * Checks if `value` is classified as a typed array.
3399 *
3400 * @static
3401 * @memberOf _
3402 * @since 3.0.0
3403 * @category Lang
3404 * @param {*} value The value to check.
3405 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3406 * @example
3407 *
3408 * _.isTypedArray(new Uint8Array);
3409 * // => true
3410 *
3411 * _.isTypedArray([]);
3412 * // => false
3413 */
3414var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
3415
3416/**
3417 * Converts `value` to a plain object flattening inherited enumerable string
3418 * keyed properties of `value` to own properties of the plain object.
3419 *
3420 * @static
3421 * @memberOf _
3422 * @since 3.0.0
3423 * @category Lang
3424 * @param {*} value The value to convert.
3425 * @returns {Object} Returns the converted plain object.
3426 * @example
3427 *
3428 * function Foo() {
3429 * this.b = 2;
3430 * }
3431 *
3432 * Foo.prototype.c = 3;
3433 *
3434 * _.assign({ 'a': 1 }, new Foo);
3435 * // => { 'a': 1, 'b': 2 }
3436 *
3437 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
3438 * // => { 'a': 1, 'b': 2, 'c': 3 }
3439 */
3440function toPlainObject(value) {
3441 return copyObject(value, keysIn(value));
3442}
3443
3444/**
3445 * This method is like `_.defaults` except that it recursively assigns
3446 * default properties.
3447 *
3448 * **Note:** This method mutates `object`.
3449 *
3450 * @static
3451 * @memberOf _
3452 * @since 3.10.0
3453 * @category Object
3454 * @param {Object} object The destination object.
3455 * @param {...Object} [sources] The source objects.
3456 * @returns {Object} Returns `object`.
3457 * @see _.defaults
3458 * @example
3459 *
3460 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
3461 * // => { 'a': { 'b': 2, 'c': 3 } }
3462 */
3463var defaultsDeep = baseRest(function(args) {
3464 args.push(undefined, customDefaultsMerge);
3465 return apply(mergeWith, undefined, args);
3466});
3467
3468/**
3469 * Creates an array of the own and inherited enumerable property names of `object`.
3470 *
3471 * **Note:** Non-object values are coerced to objects.
3472 *
3473 * @static
3474 * @memberOf _
3475 * @since 3.0.0
3476 * @category Object
3477 * @param {Object} object The object to query.
3478 * @returns {Array} Returns the array of property names.
3479 * @example
3480 *
3481 * function Foo() {
3482 * this.a = 1;
3483 * this.b = 2;
3484 * }
3485 *
3486 * Foo.prototype.c = 3;
3487 *
3488 * _.keysIn(new Foo);
3489 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3490 */
3491function keysIn(object) {
3492 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
3493}
3494
3495/**
3496 * This method is like `_.merge` except that it accepts `customizer` which
3497 * is invoked to produce the merged values of the destination and source
3498 * properties. If `customizer` returns `undefined`, merging is handled by the
3499 * method instead. The `customizer` is invoked with six arguments:
3500 * (objValue, srcValue, key, object, source, stack).
3501 *
3502 * **Note:** This method mutates `object`.
3503 *
3504 * @static
3505 * @memberOf _
3506 * @since 4.0.0
3507 * @category Object
3508 * @param {Object} object The destination object.
3509 * @param {...Object} sources The source objects.
3510 * @param {Function} customizer The function to customize assigned values.
3511 * @returns {Object} Returns `object`.
3512 * @example
3513 *
3514 * function customizer(objValue, srcValue) {
3515 * if (_.isArray(objValue)) {
3516 * return objValue.concat(srcValue);
3517 * }
3518 * }
3519 *
3520 * var object = { 'a': [1], 'b': [2] };
3521 * var other = { 'a': [3], 'b': [4] };
3522 *
3523 * _.mergeWith(object, other, customizer);
3524 * // => { 'a': [1, 3], 'b': [2, 4] }
3525 */
3526var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
3527 baseMerge(object, source, srcIndex, customizer);
3528});
3529
3530/**
3531 * Creates a function that returns `value`.
3532 *
3533 * @static
3534 * @memberOf _
3535 * @since 2.4.0
3536 * @category Util
3537 * @param {*} value The value to return from the new function.
3538 * @returns {Function} Returns the new constant function.
3539 * @example
3540 *
3541 * var objects = _.times(2, _.constant({ 'a': 1 }));
3542 *
3543 * console.log(objects);
3544 * // => [{ 'a': 1 }, { 'a': 1 }]
3545 *
3546 * console.log(objects[0] === objects[1]);
3547 * // => true
3548 */
3549function constant(value) {
3550 return function() {
3551 return value;
3552 };
3553}
3554
3555/**
3556 * This method returns the first argument it receives.
3557 *
3558 * @static
3559 * @since 0.1.0
3560 * @memberOf _
3561 * @category Util
3562 * @param {*} value Any value.
3563 * @returns {*} Returns `value`.
3564 * @example
3565 *
3566 * var object = { 'a': 1 };
3567 *
3568 * console.log(_.identity(object) === object);
3569 * // => true
3570 */
3571function identity(value) {
3572 return value;
3573}
3574
3575/**
3576 * This method returns `false`.
3577 *
3578 * @static
3579 * @memberOf _
3580 * @since 4.13.0
3581 * @category Util
3582 * @returns {boolean} Returns `false`.
3583 * @example
3584 *
3585 * _.times(2, _.stubFalse);
3586 * // => [false, false]
3587 */
3588function stubFalse() {
3589 return false;
3590}
3591
3592module.exports = defaultsDeep;
3593
3594
3595/***/ }),
3596
3597/***/ 3520:
3598/***/ ((module) => {
3599
3600/**
3601 * lodash (Custom Build) <https://lodash.com/>
3602 * Build: `lodash modularize exports="npm" -o ./`
3603 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
3604 * Released under MIT license <https://lodash.com/license>
3605 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3606 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
3607 */
3608
3609/** Used as references for various `Number` constants. */
3610var MAX_SAFE_INTEGER = 9007199254740991;
3611
3612/** `Object#toString` result references. */
3613var argsTag = '[object Arguments]',
3614 funcTag = '[object Function]',
3615 genTag = '[object GeneratorFunction]';
3616
3617/** Used to detect unsigned integer values. */
3618var reIsUint = /^(?:0|[1-9]\d*)$/;
3619
3620/**
3621 * The base implementation of `_.times` without support for iteratee shorthands
3622 * or max array length checks.
3623 *
3624 * @private
3625 * @param {number} n The number of times to invoke `iteratee`.
3626 * @param {Function} iteratee The function invoked per iteration.
3627 * @returns {Array} Returns the array of results.
3628 */
3629function baseTimes(n, iteratee) {
3630 var index = -1,
3631 result = Array(n);
3632
3633 while (++index < n) {
3634 result[index] = iteratee(index);
3635 }
3636 return result;
3637}
3638
3639/**
3640 * Creates a unary function that invokes `func` with its argument transformed.
3641 *
3642 * @private
3643 * @param {Function} func The function to wrap.
3644 * @param {Function} transform The argument transform.
3645 * @returns {Function} Returns the new function.
3646 */
3647function overArg(func, transform) {
3648 return function(arg) {
3649 return func(transform(arg));
3650 };
3651}
3652
3653/** Used for built-in method references. */
3654var objectProto = Object.prototype;
3655
3656/** Used to check objects for own properties. */
3657var hasOwnProperty = objectProto.hasOwnProperty;
3658
3659/**
3660 * Used to resolve the
3661 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3662 * of values.
3663 */
3664var objectToString = objectProto.toString;
3665
3666/** Built-in value references. */
3667var propertyIsEnumerable = objectProto.propertyIsEnumerable;
3668
3669/* Built-in method references for those with the same name as other `lodash` methods. */
3670var nativeKeys = overArg(Object.keys, Object);
3671
3672/**
3673 * Creates an array of the enumerable property names of the array-like `value`.
3674 *
3675 * @private
3676 * @param {*} value The value to query.
3677 * @param {boolean} inherited Specify returning inherited property names.
3678 * @returns {Array} Returns the array of property names.
3679 */
3680function arrayLikeKeys(value, inherited) {
3681 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
3682 // Safari 9 makes `arguments.length` enumerable in strict mode.
3683 var result = (isArray(value) || isArguments(value))
3684 ? baseTimes(value.length, String)
3685 : [];
3686
3687 var length = result.length,
3688 skipIndexes = !!length;
3689
3690 for (var key in value) {
3691 if ((inherited || hasOwnProperty.call(value, key)) &&
3692 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
3693 result.push(key);
3694 }
3695 }
3696 return result;
3697}
3698
3699/**
3700 * The base implementation of `baseForOwn` which iterates over `object`
3701 * properties returned by `keysFunc` and invokes `iteratee` for each property.
3702 * Iteratee functions may exit iteration early by explicitly returning `false`.
3703 *
3704 * @private
3705 * @param {Object} object The object to iterate over.
3706 * @param {Function} iteratee The function invoked per iteration.
3707 * @param {Function} keysFunc The function to get the keys of `object`.
3708 * @returns {Object} Returns `object`.
3709 */
3710var baseFor = createBaseFor();
3711
3712/**
3713 * The base implementation of `_.forOwn` without support for iteratee shorthands.
3714 *
3715 * @private
3716 * @param {Object} object The object to iterate over.
3717 * @param {Function} iteratee The function invoked per iteration.
3718 * @returns {Object} Returns `object`.
3719 */
3720function baseForOwn(object, iteratee) {
3721 return object && baseFor(object, iteratee, keys);
3722}
3723
3724/**
3725 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3726 *
3727 * @private
3728 * @param {Object} object The object to query.
3729 * @returns {Array} Returns the array of property names.
3730 */
3731function baseKeys(object) {
3732 if (!isPrototype(object)) {
3733 return nativeKeys(object);
3734 }
3735 var result = [];
3736 for (var key in Object(object)) {
3737 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3738 result.push(key);
3739 }
3740 }
3741 return result;
3742}
3743
3744/**
3745 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
3746 *
3747 * @private
3748 * @param {boolean} [fromRight] Specify iterating from right to left.
3749 * @returns {Function} Returns the new base function.
3750 */
3751function createBaseFor(fromRight) {
3752 return function(object, iteratee, keysFunc) {
3753 var index = -1,
3754 iterable = Object(object),
3755 props = keysFunc(object),
3756 length = props.length;
3757
3758 while (length--) {
3759 var key = props[fromRight ? length : ++index];
3760 if (iteratee(iterable[key], key, iterable) === false) {
3761 break;
3762 }
3763 }
3764 return object;
3765 };
3766}
3767
3768/**
3769 * Checks if `value` is a valid array-like index.
3770 *
3771 * @private
3772 * @param {*} value The value to check.
3773 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
3774 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
3775 */
3776function isIndex(value, length) {
3777 length = length == null ? MAX_SAFE_INTEGER : length;
3778 return !!length &&
3779 (typeof value == 'number' || reIsUint.test(value)) &&
3780 (value > -1 && value % 1 == 0 && value < length);
3781}
3782
3783/**
3784 * Checks if `value` is likely a prototype object.
3785 *
3786 * @private
3787 * @param {*} value The value to check.
3788 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
3789 */
3790function isPrototype(value) {
3791 var Ctor = value && value.constructor,
3792 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
3793
3794 return value === proto;
3795}
3796
3797/**
3798 * Checks if `value` is likely an `arguments` object.
3799 *
3800 * @static
3801 * @memberOf _
3802 * @since 0.1.0
3803 * @category Lang
3804 * @param {*} value The value to check.
3805 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3806 * else `false`.
3807 * @example
3808 *
3809 * _.isArguments(function() { return arguments; }());
3810 * // => true
3811 *
3812 * _.isArguments([1, 2, 3]);
3813 * // => false
3814 */
3815function isArguments(value) {
3816 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
3817 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
3818 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
3819}
3820
3821/**
3822 * Checks if `value` is classified as an `Array` object.
3823 *
3824 * @static
3825 * @memberOf _
3826 * @since 0.1.0
3827 * @category Lang
3828 * @param {*} value The value to check.
3829 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3830 * @example
3831 *
3832 * _.isArray([1, 2, 3]);
3833 * // => true
3834 *
3835 * _.isArray(document.body.children);
3836 * // => false
3837 *
3838 * _.isArray('abc');
3839 * // => false
3840 *
3841 * _.isArray(_.noop);
3842 * // => false
3843 */
3844var isArray = Array.isArray;
3845
3846/**
3847 * Checks if `value` is array-like. A value is considered array-like if it's
3848 * not a function and has a `value.length` that's an integer greater than or
3849 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3850 *
3851 * @static
3852 * @memberOf _
3853 * @since 4.0.0
3854 * @category Lang
3855 * @param {*} value The value to check.
3856 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3857 * @example
3858 *
3859 * _.isArrayLike([1, 2, 3]);
3860 * // => true
3861 *
3862 * _.isArrayLike(document.body.children);
3863 * // => true
3864 *
3865 * _.isArrayLike('abc');
3866 * // => true
3867 *
3868 * _.isArrayLike(_.noop);
3869 * // => false
3870 */
3871function isArrayLike(value) {
3872 return value != null && isLength(value.length) && !isFunction(value);
3873}
3874
3875/**
3876 * This method is like `_.isArrayLike` except that it also checks if `value`
3877 * is an object.
3878 *
3879 * @static
3880 * @memberOf _
3881 * @since 4.0.0
3882 * @category Lang
3883 * @param {*} value The value to check.
3884 * @returns {boolean} Returns `true` if `value` is an array-like object,
3885 * else `false`.
3886 * @example
3887 *
3888 * _.isArrayLikeObject([1, 2, 3]);
3889 * // => true
3890 *
3891 * _.isArrayLikeObject(document.body.children);
3892 * // => true
3893 *
3894 * _.isArrayLikeObject('abc');
3895 * // => false
3896 *
3897 * _.isArrayLikeObject(_.noop);
3898 * // => false
3899 */
3900function isArrayLikeObject(value) {
3901 return isObjectLike(value) && isArrayLike(value);
3902}
3903
3904/**
3905 * Checks if `value` is classified as a `Function` object.
3906 *
3907 * @static
3908 * @memberOf _
3909 * @since 0.1.0
3910 * @category Lang
3911 * @param {*} value The value to check.
3912 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3913 * @example
3914 *
3915 * _.isFunction(_);
3916 * // => true
3917 *
3918 * _.isFunction(/abc/);
3919 * // => false
3920 */
3921function isFunction(value) {
3922 // The use of `Object#toString` avoids issues with the `typeof` operator
3923 // in Safari 8-9 which returns 'object' for typed array and other constructors.
3924 var tag = isObject(value) ? objectToString.call(value) : '';
3925 return tag == funcTag || tag == genTag;
3926}
3927
3928/**
3929 * Checks if `value` is a valid array-like length.
3930 *
3931 * **Note:** This method is loosely based on
3932 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3933 *
3934 * @static
3935 * @memberOf _
3936 * @since 4.0.0
3937 * @category Lang
3938 * @param {*} value The value to check.
3939 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3940 * @example
3941 *
3942 * _.isLength(3);
3943 * // => true
3944 *
3945 * _.isLength(Number.MIN_VALUE);
3946 * // => false
3947 *
3948 * _.isLength(Infinity);
3949 * // => false
3950 *
3951 * _.isLength('3');
3952 * // => false
3953 */
3954function isLength(value) {
3955 return typeof value == 'number' &&
3956 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3957}
3958
3959/**
3960 * Checks if `value` is the
3961 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3962 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3963 *
3964 * @static
3965 * @memberOf _
3966 * @since 0.1.0
3967 * @category Lang
3968 * @param {*} value The value to check.
3969 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3970 * @example
3971 *
3972 * _.isObject({});
3973 * // => true
3974 *
3975 * _.isObject([1, 2, 3]);
3976 * // => true
3977 *
3978 * _.isObject(_.noop);
3979 * // => true
3980 *
3981 * _.isObject(null);
3982 * // => false
3983 */
3984function isObject(value) {
3985 var type = typeof value;
3986 return !!value && (type == 'object' || type == 'function');
3987}
3988
3989/**
3990 * Checks if `value` is object-like. A value is object-like if it's not `null`
3991 * and has a `typeof` result of "object".
3992 *
3993 * @static
3994 * @memberOf _
3995 * @since 4.0.0
3996 * @category Lang
3997 * @param {*} value The value to check.
3998 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3999 * @example
4000 *
4001 * _.isObjectLike({});
4002 * // => true
4003 *
4004 * _.isObjectLike([1, 2, 3]);
4005 * // => true
4006 *
4007 * _.isObjectLike(_.noop);
4008 * // => false
4009 *
4010 * _.isObjectLike(null);
4011 * // => false
4012 */
4013function isObjectLike(value) {
4014 return !!value && typeof value == 'object';
4015}
4016
4017/**
4018 * Iterates over own enumerable string keyed properties of an object and
4019 * invokes `iteratee` for each property. The iteratee is invoked with three
4020 * arguments: (value, key, object). Iteratee functions may exit iteration
4021 * early by explicitly returning `false`.
4022 *
4023 * @static
4024 * @memberOf _
4025 * @since 0.3.0
4026 * @category Object
4027 * @param {Object} object The object to iterate over.
4028 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
4029 * @returns {Object} Returns `object`.
4030 * @see _.forOwnRight
4031 * @example
4032 *
4033 * function Foo() {
4034 * this.a = 1;
4035 * this.b = 2;
4036 * }
4037 *
4038 * Foo.prototype.c = 3;
4039 *
4040 * _.forOwn(new Foo, function(value, key) {
4041 * console.log(key);
4042 * });
4043 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
4044 */
4045function forOwn(object, iteratee) {
4046 return object && baseForOwn(object, typeof iteratee == 'function' ? iteratee : identity);
4047}
4048
4049/**
4050 * Creates an array of the own enumerable property names of `object`.
4051 *
4052 * **Note:** Non-object values are coerced to objects. See the
4053 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
4054 * for more details.
4055 *
4056 * @static
4057 * @since 0.1.0
4058 * @memberOf _
4059 * @category Object
4060 * @param {Object} object The object to query.
4061 * @returns {Array} Returns the array of property names.
4062 * @example
4063 *
4064 * function Foo() {
4065 * this.a = 1;
4066 * this.b = 2;
4067 * }
4068 *
4069 * Foo.prototype.c = 3;
4070 *
4071 * _.keys(new Foo);
4072 * // => ['a', 'b'] (iteration order is not guaranteed)
4073 *
4074 * _.keys('hi');
4075 * // => ['0', '1']
4076 */
4077function keys(object) {
4078 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
4079}
4080
4081/**
4082 * This method returns the first argument it receives.
4083 *
4084 * @static
4085 * @since 0.1.0
4086 * @memberOf _
4087 * @category Util
4088 * @param {*} value Any value.
4089 * @returns {*} Returns `value`.
4090 * @example
4091 *
4092 * var object = { 'a': 1 };
4093 *
4094 * console.log(_.identity(object) === object);
4095 * // => true
4096 */
4097function identity(value) {
4098 return value;
4099}
4100
4101module.exports = forOwn;
4102
4103
4104/***/ }),
4105
4106/***/ 372:
4107/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4108
4109"use strict";
4110
4111
4112var isPrototype = __webpack_require__(6060);
4113
4114module.exports = function (value) {
4115 if (typeof value !== "function") return false;
4116
4117 if (!hasOwnProperty.call(value, "length")) return false;
4118
4119 try {
4120 if (typeof value.length !== "number") return false;
4121 if (typeof value.call !== "function") return false;
4122 if (typeof value.apply !== "function") return false;
4123 } catch (error) {
4124 return false;
4125 }
4126
4127 return !isPrototype(value);
4128};
4129
4130
4131/***/ }),
4132
4133/***/ 3940:
4134/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4135
4136"use strict";
4137
4138
4139var isValue = __webpack_require__(5618);
4140
4141// prettier-ignore
4142var possibleTypes = { "object": true, "function": true, "undefined": true /* document.all */ };
4143
4144module.exports = function (value) {
4145 if (!isValue(value)) return false;
4146 return hasOwnProperty.call(possibleTypes, typeof value);
4147};
4148
4149
4150/***/ }),
4151
4152/***/ 7205:
4153/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4154
4155"use strict";
4156
4157
4158var isFunction = __webpack_require__(372);
4159
4160var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
4161
4162module.exports = function (value) {
4163 if (!isFunction(value)) return false;
4164 if (classRe.test(functionToString.call(value))) return false;
4165 return true;
4166};
4167
4168
4169/***/ }),
4170
4171/***/ 6060:
4172/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4173
4174"use strict";
4175
4176
4177var isObject = __webpack_require__(3940);
4178
4179module.exports = function (value) {
4180 if (!isObject(value)) return false;
4181 try {
4182 if (!value.constructor) return false;
4183 return value.constructor.prototype === value;
4184 } catch (error) {
4185 return false;
4186 }
4187};
4188
4189
4190/***/ }),
4191
4192/***/ 5618:
4193/***/ ((module) => {
4194
4195"use strict";
4196
4197
4198// ES3 safe
4199var _undefined = void 0;
4200
4201module.exports = function (value) { return value !== _undefined && value !== null; };
4202
4203
4204/***/ }),
4205
4206/***/ 4935:
4207/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4208
4209var createElement = __webpack_require__(3513)
4210
4211module.exports = createElement
4212
4213
4214/***/ }),
4215
4216/***/ 7921:
4217/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4218
4219var diff = __webpack_require__(3072)
4220
4221module.exports = diff
4222
4223
4224/***/ }),
4225
4226/***/ 347:
4227/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4228
4229var h = __webpack_require__(8744)
4230
4231module.exports = h
4232
4233
4234/***/ }),
4235
4236/***/ 9720:
4237/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4238
4239var patch = __webpack_require__(6943)
4240
4241module.exports = patch
4242
4243
4244/***/ }),
4245
4246/***/ 6672:
4247/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4248
4249var isObject = __webpack_require__(6240)
4250var isHook = __webpack_require__(7265)
4251
4252module.exports = applyProperties
4253
4254function applyProperties(node, props, previous) {
4255 for (var propName in props) {
4256 var propValue = props[propName]
4257
4258 if (propValue === undefined) {
4259 removeProperty(node, propName, propValue, previous);
4260 } else if (isHook(propValue)) {
4261 removeProperty(node, propName, propValue, previous)
4262 if (propValue.hook) {
4263 propValue.hook(node,
4264 propName,
4265 previous ? previous[propName] : undefined)
4266 }
4267 } else {
4268 if (isObject(propValue)) {
4269 patchObject(node, props, previous, propName, propValue);
4270 } else {
4271 node[propName] = propValue
4272 }
4273 }
4274 }
4275}
4276
4277function removeProperty(node, propName, propValue, previous) {
4278 if (previous) {
4279 var previousValue = previous[propName]
4280
4281 if (!isHook(previousValue)) {
4282 if (propName === "attributes") {
4283 for (var attrName in previousValue) {
4284 node.removeAttribute(attrName)
4285 }
4286 } else if (propName === "style") {
4287 for (var i in previousValue) {
4288 node.style[i] = ""
4289 }
4290 } else if (typeof previousValue === "string") {
4291 node[propName] = ""
4292 } else {
4293 node[propName] = null
4294 }
4295 } else if (previousValue.unhook) {
4296 previousValue.unhook(node, propName, propValue)
4297 }
4298 }
4299}
4300
4301function patchObject(node, props, previous, propName, propValue) {
4302 var previousValue = previous ? previous[propName] : undefined
4303
4304 // Set attributes
4305 if (propName === "attributes") {
4306 for (var attrName in propValue) {
4307 var attrValue = propValue[attrName]
4308
4309 if (attrValue === undefined) {
4310 node.removeAttribute(attrName)
4311 } else {
4312 node.setAttribute(attrName, attrValue)
4313 }
4314 }
4315
4316 return
4317 }
4318
4319 if(previousValue && isObject(previousValue) &&
4320 getPrototype(previousValue) !== getPrototype(propValue)) {
4321 node[propName] = propValue
4322 return
4323 }
4324
4325 if (!isObject(node[propName])) {
4326 node[propName] = {}
4327 }
4328
4329 var replacer = propName === "style" ? "" : undefined
4330
4331 for (var k in propValue) {
4332 var value = propValue[k]
4333 node[propName][k] = (value === undefined) ? replacer : value
4334 }
4335}
4336
4337function getPrototype(value) {
4338 if (Object.getPrototypeOf) {
4339 return Object.getPrototypeOf(value)
4340 } else if (value.__proto__) {
4341 return value.__proto__
4342 } else if (value.constructor) {
4343 return value.constructor.prototype
4344 }
4345}
4346
4347
4348/***/ }),
4349
4350/***/ 3513:
4351/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4352
4353var document = __webpack_require__(9144)
4354
4355var applyProperties = __webpack_require__(6672)
4356
4357var isVNode = __webpack_require__(5170)
4358var isVText = __webpack_require__(6221)
4359var isWidget = __webpack_require__(4097)
4360var handleThunk = __webpack_require__(6078)
4361
4362module.exports = createElement
4363
4364function createElement(vnode, opts) {
4365 var doc = opts ? opts.document || document : document
4366 var warn = opts ? opts.warn : null
4367
4368 vnode = handleThunk(vnode).a
4369
4370 if (isWidget(vnode)) {
4371 return vnode.init()
4372 } else if (isVText(vnode)) {
4373 return doc.createTextNode(vnode.text)
4374 } else if (!isVNode(vnode)) {
4375 if (warn) {
4376 warn("Item is not a valid virtual dom node", vnode)
4377 }
4378 return null
4379 }
4380
4381 var node = (vnode.namespace === null) ?
4382 doc.createElement(vnode.tagName) :
4383 doc.createElementNS(vnode.namespace, vnode.tagName)
4384
4385 var props = vnode.properties
4386 applyProperties(node, props)
4387
4388 var children = vnode.children
4389
4390 for (var i = 0; i < children.length; i++) {
4391 var childNode = createElement(children[i], opts)
4392 if (childNode) {
4393 node.appendChild(childNode)
4394 }
4395 }
4396
4397 return node
4398}
4399
4400
4401/***/ }),
4402
4403/***/ 8992:
4404/***/ ((module) => {
4405
4406// Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
4407// We don't want to read all of the DOM nodes in the tree so we use
4408// the in-order tree indexing to eliminate recursion down certain branches.
4409// We only recurse into a DOM node if we know that it contains a child of
4410// interest.
4411
4412var noChild = {}
4413
4414module.exports = domIndex
4415
4416function domIndex(rootNode, tree, indices, nodes) {
4417 if (!indices || indices.length === 0) {
4418 return {}
4419 } else {
4420 indices.sort(ascending)
4421 return recurse(rootNode, tree, indices, nodes, 0)
4422 }
4423}
4424
4425function recurse(rootNode, tree, indices, nodes, rootIndex) {
4426 nodes = nodes || {}
4427
4428
4429 if (rootNode) {
4430 if (indexInRange(indices, rootIndex, rootIndex)) {
4431 nodes[rootIndex] = rootNode
4432 }
4433
4434 var vChildren = tree.children
4435
4436 if (vChildren) {
4437
4438 var childNodes = rootNode.childNodes
4439
4440 for (var i = 0; i < tree.children.length; i++) {
4441 rootIndex += 1
4442
4443 var vChild = vChildren[i] || noChild
4444 var nextIndex = rootIndex + (vChild.count || 0)
4445
4446 // skip recursion down the tree if there are no nodes down here
4447 if (indexInRange(indices, rootIndex, nextIndex)) {
4448 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
4449 }
4450
4451 rootIndex = nextIndex
4452 }
4453 }
4454 }
4455
4456 return nodes
4457}
4458
4459// Binary search for an index in the interval [left, right]
4460function indexInRange(indices, left, right) {
4461 if (indices.length === 0) {
4462 return false
4463 }
4464
4465 var minIndex = 0
4466 var maxIndex = indices.length - 1
4467 var currentIndex
4468 var currentItem
4469
4470 while (minIndex <= maxIndex) {
4471 currentIndex = ((maxIndex + minIndex) / 2) >> 0
4472 currentItem = indices[currentIndex]
4473
4474 if (minIndex === maxIndex) {
4475 return currentItem >= left && currentItem <= right
4476 } else if (currentItem < left) {
4477 minIndex = currentIndex + 1
4478 } else if (currentItem > right) {
4479 maxIndex = currentIndex - 1
4480 } else {
4481 return true
4482 }
4483 }
4484
4485 return false;
4486}
4487
4488function ascending(a, b) {
4489 return a > b ? 1 : -1
4490}
4491
4492
4493/***/ }),
4494
4495/***/ 9120:
4496/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4497
4498var applyProperties = __webpack_require__(6672)
4499
4500var isWidget = __webpack_require__(4097)
4501var VPatch = __webpack_require__(8057)
4502
4503var updateWidget = __webpack_require__(6670)
4504
4505module.exports = applyPatch
4506
4507function applyPatch(vpatch, domNode, renderOptions) {
4508 var type = vpatch.type
4509 var vNode = vpatch.vNode
4510 var patch = vpatch.patch
4511
4512 switch (type) {
4513 case VPatch.REMOVE:
4514 return removeNode(domNode, vNode)
4515 case VPatch.INSERT:
4516 return insertNode(domNode, patch, renderOptions)
4517 case VPatch.VTEXT:
4518 return stringPatch(domNode, vNode, patch, renderOptions)
4519 case VPatch.WIDGET:
4520 return widgetPatch(domNode, vNode, patch, renderOptions)
4521 case VPatch.VNODE:
4522 return vNodePatch(domNode, vNode, patch, renderOptions)
4523 case VPatch.ORDER:
4524 reorderChildren(domNode, patch)
4525 return domNode
4526 case VPatch.PROPS:
4527 applyProperties(domNode, patch, vNode.properties)
4528 return domNode
4529 case VPatch.THUNK:
4530 return replaceRoot(domNode,
4531 renderOptions.patch(domNode, patch, renderOptions))
4532 default:
4533 return domNode
4534 }
4535}
4536
4537function removeNode(domNode, vNode) {
4538 var parentNode = domNode.parentNode
4539
4540 if (parentNode) {
4541 parentNode.removeChild(domNode)
4542 }
4543
4544 destroyWidget(domNode, vNode);
4545
4546 return null
4547}
4548
4549function insertNode(parentNode, vNode, renderOptions) {
4550 var newNode = renderOptions.render(vNode, renderOptions)
4551
4552 if (parentNode) {
4553 parentNode.appendChild(newNode)
4554 }
4555
4556 return parentNode
4557}
4558
4559function stringPatch(domNode, leftVNode, vText, renderOptions) {
4560 var newNode
4561
4562 if (domNode.nodeType === 3) {
4563 domNode.replaceData(0, domNode.length, vText.text)
4564 newNode = domNode
4565 } else {
4566 var parentNode = domNode.parentNode
4567 newNode = renderOptions.render(vText, renderOptions)
4568
4569 if (parentNode && newNode !== domNode) {
4570 parentNode.replaceChild(newNode, domNode)
4571 }
4572 }
4573
4574 return newNode
4575}
4576
4577function widgetPatch(domNode, leftVNode, widget, renderOptions) {
4578 var updating = updateWidget(leftVNode, widget)
4579 var newNode
4580
4581 if (updating) {
4582 newNode = widget.update(leftVNode, domNode) || domNode
4583 } else {
4584 newNode = renderOptions.render(widget, renderOptions)
4585 }
4586
4587 var parentNode = domNode.parentNode
4588
4589 if (parentNode && newNode !== domNode) {
4590 parentNode.replaceChild(newNode, domNode)
4591 }
4592
4593 if (!updating) {
4594 destroyWidget(domNode, leftVNode)
4595 }
4596
4597 return newNode
4598}
4599
4600function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
4601 var parentNode = domNode.parentNode
4602 var newNode = renderOptions.render(vNode, renderOptions)
4603
4604 if (parentNode && newNode !== domNode) {
4605 parentNode.replaceChild(newNode, domNode)
4606 }
4607
4608 return newNode
4609}
4610
4611function destroyWidget(domNode, w) {
4612 if (typeof w.destroy === "function" && isWidget(w)) {
4613 w.destroy(domNode)
4614 }
4615}
4616
4617function reorderChildren(domNode, moves) {
4618 var childNodes = domNode.childNodes
4619 var keyMap = {}
4620 var node
4621 var remove
4622 var insert
4623
4624 for (var i = 0; i < moves.removes.length; i++) {
4625 remove = moves.removes[i]
4626 node = childNodes[remove.from]
4627 if (remove.key) {
4628 keyMap[remove.key] = node
4629 }
4630 domNode.removeChild(node)
4631 }
4632
4633 var length = childNodes.length
4634 for (var j = 0; j < moves.inserts.length; j++) {
4635 insert = moves.inserts[j]
4636 node = keyMap[insert.key]
4637 // this is the weirdest bug i've ever seen in webkit
4638 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
4639 }
4640}
4641
4642function replaceRoot(oldRoot, newRoot) {
4643 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
4644 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
4645 }
4646
4647 return newRoot;
4648}
4649
4650
4651/***/ }),
4652
4653/***/ 6943:
4654/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4655
4656var document = __webpack_require__(9144)
4657var isArray = __webpack_require__(7362)
4658
4659var render = __webpack_require__(3513)
4660var domIndex = __webpack_require__(8992)
4661var patchOp = __webpack_require__(9120)
4662module.exports = patch
4663
4664function patch(rootNode, patches, renderOptions) {
4665 renderOptions = renderOptions || {}
4666 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
4667 ? renderOptions.patch
4668 : patchRecursive
4669 renderOptions.render = renderOptions.render || render
4670
4671 return renderOptions.patch(rootNode, patches, renderOptions)
4672}
4673
4674function patchRecursive(rootNode, patches, renderOptions) {
4675 var indices = patchIndices(patches)
4676
4677 if (indices.length === 0) {
4678 return rootNode
4679 }
4680
4681 var index = domIndex(rootNode, patches.a, indices)
4682 var ownerDocument = rootNode.ownerDocument
4683
4684 if (!renderOptions.document && ownerDocument !== document) {
4685 renderOptions.document = ownerDocument
4686 }
4687
4688 for (var i = 0; i < indices.length; i++) {
4689 var nodeIndex = indices[i]
4690 rootNode = applyPatch(rootNode,
4691 index[nodeIndex],
4692 patches[nodeIndex],
4693 renderOptions)
4694 }
4695
4696 return rootNode
4697}
4698
4699function applyPatch(rootNode, domNode, patchList, renderOptions) {
4700 if (!domNode) {
4701 return rootNode
4702 }
4703
4704 var newNode
4705
4706 if (isArray(patchList)) {
4707 for (var i = 0; i < patchList.length; i++) {
4708 newNode = patchOp(patchList[i], domNode, renderOptions)
4709
4710 if (domNode === rootNode) {
4711 rootNode = newNode
4712 }
4713 }
4714 } else {
4715 newNode = patchOp(patchList, domNode, renderOptions)
4716
4717 if (domNode === rootNode) {
4718 rootNode = newNode
4719 }
4720 }
4721
4722 return rootNode
4723}
4724
4725function patchIndices(patches) {
4726 var indices = []
4727
4728 for (var key in patches) {
4729 if (key !== "a") {
4730 indices.push(Number(key))
4731 }
4732 }
4733
4734 return indices
4735}
4736
4737
4738/***/ }),
4739
4740/***/ 6670:
4741/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4742
4743var isWidget = __webpack_require__(4097)
4744
4745module.exports = updateWidget
4746
4747function updateWidget(a, b) {
4748 if (isWidget(a) && isWidget(b)) {
4749 if ("name" in a && "name" in b) {
4750 return a.id === b.id
4751 } else {
4752 return a.init === b.init
4753 }
4754 }
4755
4756 return false
4757}
4758
4759
4760/***/ }),
4761
4762/***/ 6505:
4763/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4764
4765"use strict";
4766
4767
4768var EvStore = __webpack_require__(8832);
4769
4770module.exports = EvHook;
4771
4772function EvHook(value) {
4773 if (!(this instanceof EvHook)) {
4774 return new EvHook(value);
4775 }
4776
4777 this.value = value;
4778}
4779
4780EvHook.prototype.hook = function (node, propertyName) {
4781 var es = EvStore(node);
4782 var propName = propertyName.substr(3);
4783
4784 es[propName] = this.value;
4785};
4786
4787EvHook.prototype.unhook = function(node, propertyName) {
4788 var es = EvStore(node);
4789 var propName = propertyName.substr(3);
4790
4791 es[propName] = undefined;
4792};
4793
4794
4795/***/ }),
4796
4797/***/ 7199:
4798/***/ ((module) => {
4799
4800"use strict";
4801
4802
4803module.exports = SoftSetHook;
4804
4805function SoftSetHook(value) {
4806 if (!(this instanceof SoftSetHook)) {
4807 return new SoftSetHook(value);
4808 }
4809
4810 this.value = value;
4811}
4812
4813SoftSetHook.prototype.hook = function (node, propertyName) {
4814 if (node[propertyName] !== this.value) {
4815 node[propertyName] = this.value;
4816 }
4817};
4818
4819
4820/***/ }),
4821
4822/***/ 8744:
4823/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4824
4825"use strict";
4826
4827
4828var isArray = __webpack_require__(7362);
4829
4830var VNode = __webpack_require__(4282);
4831var VText = __webpack_require__(4268);
4832var isVNode = __webpack_require__(5170);
4833var isVText = __webpack_require__(6221);
4834var isWidget = __webpack_require__(4097);
4835var isHook = __webpack_require__(7265);
4836var isVThunk = __webpack_require__(6741);
4837
4838var parseTag = __webpack_require__(1948);
4839var softSetHook = __webpack_require__(7199);
4840var evHook = __webpack_require__(6505);
4841
4842module.exports = h;
4843
4844function h(tagName, properties, children) {
4845 var childNodes = [];
4846 var tag, props, key, namespace;
4847
4848 if (!children && isChildren(properties)) {
4849 children = properties;
4850 props = {};
4851 }
4852
4853 props = props || properties || {};
4854 tag = parseTag(tagName, props);
4855
4856 // support keys
4857 if (props.hasOwnProperty('key')) {
4858 key = props.key;
4859 props.key = undefined;
4860 }
4861
4862 // support namespace
4863 if (props.hasOwnProperty('namespace')) {
4864 namespace = props.namespace;
4865 props.namespace = undefined;
4866 }
4867
4868 // fix cursor bug
4869 if (tag === 'INPUT' &&
4870 !namespace &&
4871 props.hasOwnProperty('value') &&
4872 props.value !== undefined &&
4873 !isHook(props.value)
4874 ) {
4875 props.value = softSetHook(props.value);
4876 }
4877
4878 transformProperties(props);
4879
4880 if (children !== undefined && children !== null) {
4881 addChild(children, childNodes, tag, props);
4882 }
4883
4884
4885 return new VNode(tag, props, childNodes, key, namespace);
4886}
4887
4888function addChild(c, childNodes, tag, props) {
4889 if (typeof c === 'string') {
4890 childNodes.push(new VText(c));
4891 } else if (typeof c === 'number') {
4892 childNodes.push(new VText(String(c)));
4893 } else if (isChild(c)) {
4894 childNodes.push(c);
4895 } else if (isArray(c)) {
4896 for (var i = 0; i < c.length; i++) {
4897 addChild(c[i], childNodes, tag, props);
4898 }
4899 } else if (c === null || c === undefined) {
4900 return;
4901 } else {
4902 throw UnexpectedVirtualElement({
4903 foreignObject: c,
4904 parentVnode: {
4905 tagName: tag,
4906 properties: props
4907 }
4908 });
4909 }
4910}
4911
4912function transformProperties(props) {
4913 for (var propName in props) {
4914 if (props.hasOwnProperty(propName)) {
4915 var value = props[propName];
4916
4917 if (isHook(value)) {
4918 continue;
4919 }
4920
4921 if (propName.substr(0, 3) === 'ev-') {
4922 // add ev-foo support
4923 props[propName] = evHook(value);
4924 }
4925 }
4926 }
4927}
4928
4929function isChild(x) {
4930 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
4931}
4932
4933function isChildren(x) {
4934 return typeof x === 'string' || isArray(x) || isChild(x);
4935}
4936
4937function UnexpectedVirtualElement(data) {
4938 var err = new Error();
4939
4940 err.type = 'virtual-hyperscript.unexpected.virtual-element';
4941 err.message = 'Unexpected virtual child passed to h().\n' +
4942 'Expected a VNode / Vthunk / VWidget / string but:\n' +
4943 'got:\n' +
4944 errorString(data.foreignObject) +
4945 '.\n' +
4946 'The parent vnode is:\n' +
4947 errorString(data.parentVnode)
4948 '\n' +
4949 'Suggested fix: change your `h(..., [ ... ])` callsite.';
4950 err.foreignObject = data.foreignObject;
4951 err.parentVnode = data.parentVnode;
4952
4953 return err;
4954}
4955
4956function errorString(obj) {
4957 try {
4958 return JSON.stringify(obj, null, ' ');
4959 } catch (e) {
4960 return String(obj);
4961 }
4962}
4963
4964
4965/***/ }),
4966
4967/***/ 1948:
4968/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4969
4970"use strict";
4971
4972
4973var split = __webpack_require__(6824);
4974
4975var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
4976var notClassId = /^\.|#/;
4977
4978module.exports = parseTag;
4979
4980function parseTag(tag, props) {
4981 if (!tag) {
4982 return 'DIV';
4983 }
4984
4985 var noId = !(props.hasOwnProperty('id'));
4986
4987 var tagParts = split(tag, classIdSplit);
4988 var tagName = null;
4989
4990 if (notClassId.test(tagParts[1])) {
4991 tagName = 'DIV';
4992 }
4993
4994 var classes, part, type, i;
4995
4996 for (i = 0; i < tagParts.length; i++) {
4997 part = tagParts[i];
4998
4999 if (!part) {
5000 continue;
5001 }
5002
5003 type = part.charAt(0);
5004
5005 if (!tagName) {
5006 tagName = part;
5007 } else if (type === '.') {
5008 classes = classes || [];
5009 classes.push(part.substring(1, part.length));
5010 } else if (type === '#' && noId) {
5011 props.id = part.substring(1, part.length);
5012 }
5013 }
5014
5015 if (classes) {
5016 if (props.className) {
5017 classes.push(props.className);
5018 }
5019
5020 props.className = classes.join(' ');
5021 }
5022
5023 return props.namespace ? tagName : tagName.toUpperCase();
5024}
5025
5026
5027/***/ }),
5028
5029/***/ 6078:
5030/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5031
5032var isVNode = __webpack_require__(5170)
5033var isVText = __webpack_require__(6221)
5034var isWidget = __webpack_require__(4097)
5035var isThunk = __webpack_require__(6741)
5036
5037module.exports = handleThunk
5038
5039function handleThunk(a, b) {
5040 var renderedA = a
5041 var renderedB = b
5042
5043 if (isThunk(b)) {
5044 renderedB = renderThunk(b, a)
5045 }
5046
5047 if (isThunk(a)) {
5048 renderedA = renderThunk(a, null)
5049 }
5050
5051 return {
5052 a: renderedA,
5053 b: renderedB
5054 }
5055}
5056
5057function renderThunk(thunk, previous) {
5058 var renderedThunk = thunk.vnode
5059
5060 if (!renderedThunk) {
5061 renderedThunk = thunk.vnode = thunk.render(previous)
5062 }
5063
5064 if (!(isVNode(renderedThunk) ||
5065 isVText(renderedThunk) ||
5066 isWidget(renderedThunk))) {
5067 throw new Error("thunk did not return a valid node");
5068 }
5069
5070 return renderedThunk
5071}
5072
5073
5074/***/ }),
5075
5076/***/ 6741:
5077/***/ ((module) => {
5078
5079module.exports = isThunk
5080
5081function isThunk(t) {
5082 return t && t.type === "Thunk"
5083}
5084
5085
5086/***/ }),
5087
5088/***/ 7265:
5089/***/ ((module) => {
5090
5091module.exports = isHook
5092
5093function isHook(hook) {
5094 return hook &&
5095 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
5096 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
5097}
5098
5099
5100/***/ }),
5101
5102/***/ 5170:
5103/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5104
5105var version = __webpack_require__(9962)
5106
5107module.exports = isVirtualNode
5108
5109function isVirtualNode(x) {
5110 return x && x.type === "VirtualNode" && x.version === version
5111}
5112
5113
5114/***/ }),
5115
5116/***/ 6221:
5117/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5118
5119var version = __webpack_require__(9962)
5120
5121module.exports = isVirtualText
5122
5123function isVirtualText(x) {
5124 return x && x.type === "VirtualText" && x.version === version
5125}
5126
5127
5128/***/ }),
5129
5130/***/ 4097:
5131/***/ ((module) => {
5132
5133module.exports = isWidget
5134
5135function isWidget(w) {
5136 return w && w.type === "Widget"
5137}
5138
5139
5140/***/ }),
5141
5142/***/ 9962:
5143/***/ ((module) => {
5144
5145module.exports = "2"
5146
5147
5148/***/ }),
5149
5150/***/ 4282:
5151/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5152
5153var version = __webpack_require__(9962)
5154var isVNode = __webpack_require__(5170)
5155var isWidget = __webpack_require__(4097)
5156var isThunk = __webpack_require__(6741)
5157var isVHook = __webpack_require__(7265)
5158
5159module.exports = VirtualNode
5160
5161var noProperties = {}
5162var noChildren = []
5163
5164function VirtualNode(tagName, properties, children, key, namespace) {
5165 this.tagName = tagName
5166 this.properties = properties || noProperties
5167 this.children = children || noChildren
5168 this.key = key != null ? String(key) : undefined
5169 this.namespace = (typeof namespace === "string") ? namespace : null
5170
5171 var count = (children && children.length) || 0
5172 var descendants = 0
5173 var hasWidgets = false
5174 var hasThunks = false
5175 var descendantHooks = false
5176 var hooks
5177
5178 for (var propName in properties) {
5179 if (properties.hasOwnProperty(propName)) {
5180 var property = properties[propName]
5181 if (isVHook(property) && property.unhook) {
5182 if (!hooks) {
5183 hooks = {}
5184 }
5185
5186 hooks[propName] = property
5187 }
5188 }
5189 }
5190
5191 for (var i = 0; i < count; i++) {
5192 var child = children[i]
5193 if (isVNode(child)) {
5194 descendants += child.count || 0
5195
5196 if (!hasWidgets && child.hasWidgets) {
5197 hasWidgets = true
5198 }
5199
5200 if (!hasThunks && child.hasThunks) {
5201 hasThunks = true
5202 }
5203
5204 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
5205 descendantHooks = true
5206 }
5207 } else if (!hasWidgets && isWidget(child)) {
5208 if (typeof child.destroy === "function") {
5209 hasWidgets = true
5210 }
5211 } else if (!hasThunks && isThunk(child)) {
5212 hasThunks = true;
5213 }
5214 }
5215
5216 this.count = count + descendants
5217 this.hasWidgets = hasWidgets
5218 this.hasThunks = hasThunks
5219 this.hooks = hooks
5220 this.descendantHooks = descendantHooks
5221}
5222
5223VirtualNode.prototype.version = version
5224VirtualNode.prototype.type = "VirtualNode"
5225
5226
5227/***/ }),
5228
5229/***/ 8057:
5230/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5231
5232var version = __webpack_require__(9962)
5233
5234VirtualPatch.NONE = 0
5235VirtualPatch.VTEXT = 1
5236VirtualPatch.VNODE = 2
5237VirtualPatch.WIDGET = 3
5238VirtualPatch.PROPS = 4
5239VirtualPatch.ORDER = 5
5240VirtualPatch.INSERT = 6
5241VirtualPatch.REMOVE = 7
5242VirtualPatch.THUNK = 8
5243
5244module.exports = VirtualPatch
5245
5246function VirtualPatch(type, vNode, patch) {
5247 this.type = Number(type)
5248 this.vNode = vNode
5249 this.patch = patch
5250}
5251
5252VirtualPatch.prototype.version = version
5253VirtualPatch.prototype.type = "VirtualPatch"
5254
5255
5256/***/ }),
5257
5258/***/ 4268:
5259/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5260
5261var version = __webpack_require__(9962)
5262
5263module.exports = VirtualText
5264
5265function VirtualText(text) {
5266 this.text = String(text)
5267}
5268
5269VirtualText.prototype.version = version
5270VirtualText.prototype.type = "VirtualText"
5271
5272
5273/***/ }),
5274
5275/***/ 9973:
5276/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5277
5278var isObject = __webpack_require__(6240)
5279var isHook = __webpack_require__(7265)
5280
5281module.exports = diffProps
5282
5283function diffProps(a, b) {
5284 var diff
5285
5286 for (var aKey in a) {
5287 if (!(aKey in b)) {
5288 diff = diff || {}
5289 diff[aKey] = undefined
5290 }
5291
5292 var aValue = a[aKey]
5293 var bValue = b[aKey]
5294
5295 if (aValue === bValue) {
5296 continue
5297 } else if (isObject(aValue) && isObject(bValue)) {
5298 if (getPrototype(bValue) !== getPrototype(aValue)) {
5299 diff = diff || {}
5300 diff[aKey] = bValue
5301 } else if (isHook(bValue)) {
5302 diff = diff || {}
5303 diff[aKey] = bValue
5304 } else {
5305 var objectDiff = diffProps(aValue, bValue)
5306 if (objectDiff) {
5307 diff = diff || {}
5308 diff[aKey] = objectDiff
5309 }
5310 }
5311 } else {
5312 diff = diff || {}
5313 diff[aKey] = bValue
5314 }
5315 }
5316
5317 for (var bKey in b) {
5318 if (!(bKey in a)) {
5319 diff = diff || {}
5320 diff[bKey] = b[bKey]
5321 }
5322 }
5323
5324 return diff
5325}
5326
5327function getPrototype(value) {
5328 if (Object.getPrototypeOf) {
5329 return Object.getPrototypeOf(value)
5330 } else if (value.__proto__) {
5331 return value.__proto__
5332 } else if (value.constructor) {
5333 return value.constructor.prototype
5334 }
5335}
5336
5337
5338/***/ }),
5339
5340/***/ 3072:
5341/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5342
5343var isArray = __webpack_require__(7362)
5344
5345var VPatch = __webpack_require__(8057)
5346var isVNode = __webpack_require__(5170)
5347var isVText = __webpack_require__(6221)
5348var isWidget = __webpack_require__(4097)
5349var isThunk = __webpack_require__(6741)
5350var handleThunk = __webpack_require__(6078)
5351
5352var diffProps = __webpack_require__(9973)
5353
5354module.exports = diff
5355
5356function diff(a, b) {
5357 var patch = { a: a }
5358 walk(a, b, patch, 0)
5359 return patch
5360}
5361
5362function walk(a, b, patch, index) {
5363 if (a === b) {
5364 return
5365 }
5366
5367 var apply = patch[index]
5368 var applyClear = false
5369
5370 if (isThunk(a) || isThunk(b)) {
5371 thunks(a, b, patch, index)
5372 } else if (b == null) {
5373
5374 // If a is a widget we will add a remove patch for it
5375 // Otherwise any child widgets/hooks must be destroyed.
5376 // This prevents adding two remove patches for a widget.
5377 if (!isWidget(a)) {
5378 clearState(a, patch, index)
5379 apply = patch[index]
5380 }
5381
5382 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
5383 } else if (isVNode(b)) {
5384 if (isVNode(a)) {
5385 if (a.tagName === b.tagName &&
5386 a.namespace === b.namespace &&
5387 a.key === b.key) {
5388 var propsPatch = diffProps(a.properties, b.properties)
5389 if (propsPatch) {
5390 apply = appendPatch(apply,
5391 new VPatch(VPatch.PROPS, a, propsPatch))
5392 }
5393 apply = diffChildren(a, b, patch, apply, index)
5394 } else {
5395 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
5396 applyClear = true
5397 }
5398 } else {
5399 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
5400 applyClear = true
5401 }
5402 } else if (isVText(b)) {
5403 if (!isVText(a)) {
5404 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
5405 applyClear = true
5406 } else if (a.text !== b.text) {
5407 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
5408 }
5409 } else if (isWidget(b)) {
5410 if (!isWidget(a)) {
5411 applyClear = true
5412 }
5413
5414 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
5415 }
5416
5417 if (apply) {
5418 patch[index] = apply
5419 }
5420
5421 if (applyClear) {
5422 clearState(a, patch, index)
5423 }
5424}
5425
5426function diffChildren(a, b, patch, apply, index) {
5427 var aChildren = a.children
5428 var orderedSet = reorder(aChildren, b.children)
5429 var bChildren = orderedSet.children
5430
5431 var aLen = aChildren.length
5432 var bLen = bChildren.length
5433 var len = aLen > bLen ? aLen : bLen
5434
5435 for (var i = 0; i < len; i++) {
5436 var leftNode = aChildren[i]
5437 var rightNode = bChildren[i]
5438 index += 1
5439
5440 if (!leftNode) {
5441 if (rightNode) {
5442 // Excess nodes in b need to be added
5443 apply = appendPatch(apply,
5444 new VPatch(VPatch.INSERT, null, rightNode))
5445 }
5446 } else {
5447 walk(leftNode, rightNode, patch, index)
5448 }
5449
5450 if (isVNode(leftNode) && leftNode.count) {
5451 index += leftNode.count
5452 }
5453 }
5454
5455 if (orderedSet.moves) {
5456 // Reorder nodes last
5457 apply = appendPatch(apply, new VPatch(
5458 VPatch.ORDER,
5459 a,
5460 orderedSet.moves
5461 ))
5462 }
5463
5464 return apply
5465}
5466
5467function clearState(vNode, patch, index) {
5468 // TODO: Make this a single walk, not two
5469 unhook(vNode, patch, index)
5470 destroyWidgets(vNode, patch, index)
5471}
5472
5473// Patch records for all destroyed widgets must be added because we need
5474// a DOM node reference for the destroy function
5475function destroyWidgets(vNode, patch, index) {
5476 if (isWidget(vNode)) {
5477 if (typeof vNode.destroy === "function") {
5478 patch[index] = appendPatch(
5479 patch[index],
5480 new VPatch(VPatch.REMOVE, vNode, null)
5481 )
5482 }
5483 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
5484 var children = vNode.children
5485 var len = children.length
5486 for (var i = 0; i < len; i++) {
5487 var child = children[i]
5488 index += 1
5489
5490 destroyWidgets(child, patch, index)
5491
5492 if (isVNode(child) && child.count) {
5493 index += child.count
5494 }
5495 }
5496 } else if (isThunk(vNode)) {
5497 thunks(vNode, null, patch, index)
5498 }
5499}
5500
5501// Create a sub-patch for thunks
5502function thunks(a, b, patch, index) {
5503 var nodes = handleThunk(a, b)
5504 var thunkPatch = diff(nodes.a, nodes.b)
5505 if (hasPatches(thunkPatch)) {
5506 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
5507 }
5508}
5509
5510function hasPatches(patch) {
5511 for (var index in patch) {
5512 if (index !== "a") {
5513 return true
5514 }
5515 }
5516
5517 return false
5518}
5519
5520// Execute hooks when two nodes are identical
5521function unhook(vNode, patch, index) {
5522 if (isVNode(vNode)) {
5523 if (vNode.hooks) {
5524 patch[index] = appendPatch(
5525 patch[index],
5526 new VPatch(
5527 VPatch.PROPS,
5528 vNode,
5529 undefinedKeys(vNode.hooks)
5530 )
5531 )
5532 }
5533
5534 if (vNode.descendantHooks || vNode.hasThunks) {
5535 var children = vNode.children
5536 var len = children.length
5537 for (var i = 0; i < len; i++) {
5538 var child = children[i]
5539 index += 1
5540
5541 unhook(child, patch, index)
5542
5543 if (isVNode(child) && child.count) {
5544 index += child.count
5545 }
5546 }
5547 }
5548 } else if (isThunk(vNode)) {
5549 thunks(vNode, null, patch, index)
5550 }
5551}
5552
5553function undefinedKeys(obj) {
5554 var result = {}
5555
5556 for (var key in obj) {
5557 result[key] = undefined
5558 }
5559
5560 return result
5561}
5562
5563// List diff, naive left to right reordering
5564function reorder(aChildren, bChildren) {
5565 // O(M) time, O(M) memory
5566 var bChildIndex = keyIndex(bChildren)
5567 var bKeys = bChildIndex.keys
5568 var bFree = bChildIndex.free
5569
5570 if (bFree.length === bChildren.length) {
5571 return {
5572 children: bChildren,
5573 moves: null
5574 }
5575 }
5576
5577 // O(N) time, O(N) memory
5578 var aChildIndex = keyIndex(aChildren)
5579 var aKeys = aChildIndex.keys
5580 var aFree = aChildIndex.free
5581
5582 if (aFree.length === aChildren.length) {
5583 return {
5584 children: bChildren,
5585 moves: null
5586 }
5587 }
5588
5589 // O(MAX(N, M)) memory
5590 var newChildren = []
5591
5592 var freeIndex = 0
5593 var freeCount = bFree.length
5594 var deletedItems = 0
5595
5596 // Iterate through a and match a node in b
5597 // O(N) time,
5598 for (var i = 0 ; i < aChildren.length; i++) {
5599 var aItem = aChildren[i]
5600 var itemIndex
5601
5602 if (aItem.key) {
5603 if (bKeys.hasOwnProperty(aItem.key)) {
5604 // Match up the old keys
5605 itemIndex = bKeys[aItem.key]
5606 newChildren.push(bChildren[itemIndex])
5607
5608 } else {
5609 // Remove old keyed items
5610 itemIndex = i - deletedItems++
5611 newChildren.push(null)
5612 }
5613 } else {
5614 // Match the item in a with the next free item in b
5615 if (freeIndex < freeCount) {
5616 itemIndex = bFree[freeIndex++]
5617 newChildren.push(bChildren[itemIndex])
5618 } else {
5619 // There are no free items in b to match with
5620 // the free items in a, so the extra free nodes
5621 // are deleted.
5622 itemIndex = i - deletedItems++
5623 newChildren.push(null)
5624 }
5625 }
5626 }
5627
5628 var lastFreeIndex = freeIndex >= bFree.length ?
5629 bChildren.length :
5630 bFree[freeIndex]
5631
5632 // Iterate through b and append any new keys
5633 // O(M) time
5634 for (var j = 0; j < bChildren.length; j++) {
5635 var newItem = bChildren[j]
5636
5637 if (newItem.key) {
5638 if (!aKeys.hasOwnProperty(newItem.key)) {
5639 // Add any new keyed items
5640 // We are adding new items to the end and then sorting them
5641 // in place. In future we should insert new items in place.
5642 newChildren.push(newItem)
5643 }
5644 } else if (j >= lastFreeIndex) {
5645 // Add any leftover non-keyed items
5646 newChildren.push(newItem)
5647 }
5648 }
5649
5650 var simulate = newChildren.slice()
5651 var simulateIndex = 0
5652 var removes = []
5653 var inserts = []
5654 var simulateItem
5655
5656 for (var k = 0; k < bChildren.length;) {
5657 var wantedItem = bChildren[k]
5658 simulateItem = simulate[simulateIndex]
5659
5660 // remove items
5661 while (simulateItem === null && simulate.length) {
5662 removes.push(remove(simulate, simulateIndex, null))
5663 simulateItem = simulate[simulateIndex]
5664 }
5665
5666 if (!simulateItem || simulateItem.key !== wantedItem.key) {
5667 // if we need a key in this position...
5668 if (wantedItem.key) {
5669 if (simulateItem && simulateItem.key) {
5670 // if an insert doesn't put this key in place, it needs to move
5671 if (bKeys[simulateItem.key] !== k + 1) {
5672 removes.push(remove(simulate, simulateIndex, simulateItem.key))
5673 simulateItem = simulate[simulateIndex]
5674 // if the remove didn't put the wanted item in place, we need to insert it
5675 if (!simulateItem || simulateItem.key !== wantedItem.key) {
5676 inserts.push({key: wantedItem.key, to: k})
5677 }
5678 // items are matching, so skip ahead
5679 else {
5680 simulateIndex++
5681 }
5682 }
5683 else {
5684 inserts.push({key: wantedItem.key, to: k})
5685 }
5686 }
5687 else {
5688 inserts.push({key: wantedItem.key, to: k})
5689 }
5690 k++
5691 }
5692 // a key in simulate has no matching wanted key, remove it
5693 else if (simulateItem && simulateItem.key) {
5694 removes.push(remove(simulate, simulateIndex, simulateItem.key))
5695 }
5696 }
5697 else {
5698 simulateIndex++
5699 k++
5700 }
5701 }
5702
5703 // remove all the remaining nodes from simulate
5704 while(simulateIndex < simulate.length) {
5705 simulateItem = simulate[simulateIndex]
5706 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
5707 }
5708
5709 // If the only moves we have are deletes then we can just
5710 // let the delete patch remove these items.
5711 if (removes.length === deletedItems && !inserts.length) {
5712 return {
5713 children: newChildren,
5714 moves: null
5715 }
5716 }
5717
5718 return {
5719 children: newChildren,
5720 moves: {
5721 removes: removes,
5722 inserts: inserts
5723 }
5724 }
5725}
5726
5727function remove(arr, index, key) {
5728 arr.splice(index, 1)
5729
5730 return {
5731 from: index,
5732 key: key
5733 }
5734}
5735
5736function keyIndex(children) {
5737 var keys = {}
5738 var free = []
5739 var length = children.length
5740
5741 for (var i = 0; i < length; i++) {
5742 var child = children[i]
5743
5744 if (child.key) {
5745 keys[child.key] = i
5746 } else {
5747 free.push(i)
5748 }
5749 }
5750
5751 return {
5752 keys: keys, // A hash of key name to index
5753 free: free // An array of unkeyed item indices
5754 }
5755}
5756
5757function appendPatch(apply, patch) {
5758 if (apply) {
5759 if (isArray(apply)) {
5760 apply.push(patch)
5761 } else {
5762 apply = [apply, patch]
5763 }
5764
5765 return apply
5766 } else {
5767 return patch
5768 }
5769}
5770
5771
5772/***/ }),
5773
5774/***/ 4991:
5775/***/ ((module) => {
5776
5777"use strict";
5778
5779
5780/**
5781 * @param {TypedArray} array - Subarray of audio to calculate peaks from.
5782 */
5783function findMinMax(array) {
5784 var min = Infinity;
5785 var max = -Infinity;
5786 var i = 0;
5787 var len = array.length;
5788 var curr;
5789
5790 for (; i < len; i++) {
5791 curr = array[i];
5792 if (min > curr) {
5793 min = curr;
5794 }
5795 if (max < curr) {
5796 max = curr;
5797 }
5798 }
5799
5800 return {
5801 min: min,
5802 max: max
5803 };
5804}
5805
5806/**
5807 * @param {Number} n - peak to convert from float to Int8, Int16 etc.
5808 * @param {Number} bits - convert to #bits two's complement signed integer
5809 */
5810function convert(n, bits) {
5811 var max = Math.pow(2, bits - 1);
5812 var v = n < 0 ? n * max : n * (max - 1);
5813 return Math.max(-max, Math.min(max - 1, v));
5814}
5815
5816/**
5817 * @param {TypedArray} channel - Audio track frames to calculate peaks from.
5818 * @param {Number} samplesPerPixel - Audio frames per peak
5819 */
5820function extractPeaks(channel, samplesPerPixel, bits) {
5821 var i;
5822 var chanLength = channel.length;
5823 var numPeaks = Math.ceil(chanLength / samplesPerPixel);
5824 var start;
5825 var end;
5826 var segment;
5827 var max;
5828 var min;
5829 var extrema;
5830
5831 //create interleaved array of min,max
5832 var peaks = makeTypedArray(bits, numPeaks * 2);
5833
5834 for (i = 0; i < numPeaks; i++) {
5835 start = i * samplesPerPixel;
5836 end =
5837 (i + 1) * samplesPerPixel > chanLength
5838 ? chanLength
5839 : (i + 1) * samplesPerPixel;
5840
5841 segment = channel.subarray(start, end);
5842 extrema = findMinMax(segment);
5843 min = convert(extrema.min, bits);
5844 max = convert(extrema.max, bits);
5845
5846 peaks[i * 2] = min;
5847 peaks[i * 2 + 1] = max;
5848 }
5849
5850 return peaks;
5851}
5852
5853function makeTypedArray(bits, length) {
5854 return new (new Function(`return Int${bits}Array`)())(length);
5855}
5856
5857function makeMono(channelPeaks, bits) {
5858 var numChan = channelPeaks.length;
5859 var weight = 1 / numChan;
5860 var numPeaks = channelPeaks[0].length / 2;
5861 var c = 0;
5862 var i = 0;
5863 var min;
5864 var max;
5865 var peaks = makeTypedArray(bits, numPeaks * 2);
5866
5867 for (i = 0; i < numPeaks; i++) {
5868 min = 0;
5869 max = 0;
5870
5871 for (c = 0; c < numChan; c++) {
5872 min += weight * channelPeaks[c][i * 2];
5873 max += weight * channelPeaks[c][i * 2 + 1];
5874 }
5875
5876 peaks[i * 2] = min;
5877 peaks[i * 2 + 1] = max;
5878 }
5879
5880 //return in array so channel number counts still work.
5881 return [peaks];
5882}
5883
5884function defaultNumber(value, defaultNumber) {
5885 if (typeof value === "number") {
5886 return value;
5887 } else {
5888 return defaultNumber;
5889 }
5890}
5891
5892/**
5893 * @param {AudioBuffer,TypedArray} source - Source of audio samples for peak calculations.
5894 * @param {Number} samplesPerPixel - Number of audio samples per peak.
5895 * @param {Boolean} isMono - Whether to render the channels to a single array.
5896 * @param {Number} cueIn - index in channel to start peak calculations from.
5897 * @param {Number} cueOut - index in channel to end peak calculations from (non-inclusive).
5898 * @param {Number} bits - number of bits for a peak.
5899 */
5900module.exports = function (
5901 source,
5902 samplesPerPixel,
5903 isMono,
5904 cueIn,
5905 cueOut,
5906 bits
5907) {
5908 samplesPerPixel = defaultNumber(samplesPerPixel, 1000);
5909 bits = defaultNumber(bits, 16);
5910
5911 if (isMono === null || isMono === undefined) {
5912 isMono = true;
5913 }
5914
5915 if ([8, 16, 32].indexOf(bits) < 0) {
5916 throw new Error("Invalid number of bits specified for peaks.");
5917 }
5918
5919 var numChan = source.numberOfChannels;
5920 var peaks = [];
5921 var c;
5922 var numPeaks;
5923 var channel;
5924 var slice;
5925
5926 cueIn = defaultNumber(cueIn, 0);
5927 cueOut = defaultNumber(cueOut, source.length);
5928
5929 if (typeof source.subarray === "undefined") {
5930 for (c = 0; c < numChan; c++) {
5931 channel = source.getChannelData(c);
5932 slice = channel.subarray(cueIn, cueOut);
5933 peaks.push(extractPeaks(slice, samplesPerPixel, bits));
5934 }
5935 } else {
5936 peaks.push(
5937 extractPeaks(source.subarray(cueIn, cueOut), samplesPerPixel, bits)
5938 );
5939 }
5940
5941 if (isMono && peaks.length > 1) {
5942 peaks = makeMono(peaks, bits);
5943 }
5944
5945 numPeaks = peaks[0].length / 2;
5946
5947 return {
5948 length: numPeaks,
5949 data: peaks,
5950 bits: bits
5951 };
5952};
5953
5954
5955/***/ }),
5956
5957/***/ 7362:
5958/***/ ((module) => {
5959
5960var nativeIsArray = Array.isArray
5961var toString = Object.prototype.toString
5962
5963module.exports = nativeIsArray || isArray
5964
5965function isArray(obj) {
5966 return toString.call(obj) === "[object Array]"
5967}
5968
5969
5970/***/ }),
5971
5972/***/ 5893:
5973/***/ (() => {
5974
5975/* (ignored) */
5976
5977/***/ })
5978
5979/******/ });
5980/************************************************************************/
5981/******/ // The module cache
5982/******/ var __webpack_module_cache__ = {};
5983/******/
5984/******/ // The require function
5985/******/ function __webpack_require__(moduleId) {
5986/******/ // Check if module is in cache
5987/******/ var cachedModule = __webpack_module_cache__[moduleId];
5988/******/ if (cachedModule !== undefined) {
5989/******/ return cachedModule.exports;
5990/******/ }
5991/******/ // Create a new module (and put it into the cache)
5992/******/ var module = __webpack_module_cache__[moduleId] = {
5993/******/ id: moduleId,
5994/******/ loaded: false,
5995/******/ exports: {}
5996/******/ };
5997/******/
5998/******/ // Execute the module function
5999/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
6000/******/
6001/******/ // Flag the module as loaded
6002/******/ module.loaded = true;
6003/******/
6004/******/ // Return the exports of the module
6005/******/ return module.exports;
6006/******/ }
6007/******/
6008/************************************************************************/
6009/******/ /* webpack/runtime/compat get default export */
6010/******/ (() => {
6011/******/ // getDefaultExport function for compatibility with non-harmony modules
6012/******/ __webpack_require__.n = (module) => {
6013/******/ var getter = module && module.__esModule ?
6014/******/ () => (module['default']) :
6015/******/ () => (module);
6016/******/ __webpack_require__.d(getter, { a: getter });
6017/******/ return getter;
6018/******/ };
6019/******/ })();
6020/******/
6021/******/ /* webpack/runtime/define property getters */
6022/******/ (() => {
6023/******/ // define getter functions for harmony exports
6024/******/ __webpack_require__.d = (exports, definition) => {
6025/******/ for(var key in definition) {
6026/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
6027/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
6028/******/ }
6029/******/ }
6030/******/ };
6031/******/ })();
6032/******/
6033/******/ /* webpack/runtime/global */
6034/******/ (() => {
6035/******/ __webpack_require__.g = (function() {
6036/******/ if (typeof globalThis === 'object') return globalThis;
6037/******/ try {
6038/******/ return this || new Function('return this')();
6039/******/ } catch (e) {
6040/******/ if (typeof window === 'object') return window;
6041/******/ }
6042/******/ })();
6043/******/ })();
6044/******/
6045/******/ /* webpack/runtime/hasOwnProperty shorthand */
6046/******/ (() => {
6047/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
6048/******/ })();
6049/******/
6050/******/ /* webpack/runtime/make namespace object */
6051/******/ (() => {
6052/******/ // define __esModule on exports
6053/******/ __webpack_require__.r = (exports) => {
6054/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
6055/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
6056/******/ }
6057/******/ Object.defineProperty(exports, '__esModule', { value: true });
6058/******/ };
6059/******/ })();
6060/******/
6061/******/ /* webpack/runtime/node module decorator */
6062/******/ (() => {
6063/******/ __webpack_require__.nmd = (module) => {
6064/******/ module.paths = [];
6065/******/ if (!module.children) module.children = [];
6066/******/ return module;
6067/******/ };
6068/******/ })();
6069/******/
6070/************************************************************************/
6071var __webpack_exports__ = {};
6072// This entry need to be wrapped in an IIFE because it need to be in strict mode.
6073(() => {
6074"use strict";
6075// ESM COMPAT FLAG
6076__webpack_require__.r(__webpack_exports__);
6077
6078// EXPORTS
6079__webpack_require__.d(__webpack_exports__, {
6080 "default": () => (/* binding */ app),
6081 "init": () => (/* binding */ init)
6082});
6083
6084// EXTERNAL MODULE: ./node_modules/lodash.defaultsdeep/index.js
6085var lodash_defaultsdeep = __webpack_require__(2098);
6086var lodash_defaultsdeep_default = /*#__PURE__*/__webpack_require__.n(lodash_defaultsdeep);
6087// EXTERNAL MODULE: ./node_modules/virtual-dom/create-element.js
6088var create_element = __webpack_require__(4935);
6089var create_element_default = /*#__PURE__*/__webpack_require__.n(create_element);
6090// EXTERNAL MODULE: ./node_modules/event-emitter/index.js
6091var event_emitter = __webpack_require__(8370);
6092var event_emitter_default = /*#__PURE__*/__webpack_require__.n(event_emitter);
6093// EXTERNAL MODULE: ./node_modules/virtual-dom/h.js
6094var h = __webpack_require__(347);
6095var h_default = /*#__PURE__*/__webpack_require__.n(h);
6096// EXTERNAL MODULE: ./node_modules/virtual-dom/diff.js
6097var diff = __webpack_require__(7921);
6098var diff_default = /*#__PURE__*/__webpack_require__.n(diff);
6099// EXTERNAL MODULE: ./node_modules/virtual-dom/patch.js
6100var patch = __webpack_require__(9720);
6101var patch_default = /*#__PURE__*/__webpack_require__.n(patch);
6102// EXTERNAL MODULE: ./node_modules/inline-worker/index.js
6103var inline_worker = __webpack_require__(849);
6104var inline_worker_default = /*#__PURE__*/__webpack_require__.n(inline_worker);
6105;// CONCATENATED MODULE: ./src/utils/conversions.js
6106function samplesToSeconds(samples, sampleRate) {
6107 return samples / sampleRate;
6108}
6109
6110function secondsToSamples(seconds, sampleRate) {
6111 return Math.ceil(seconds * sampleRate);
6112}
6113
6114function samplesToPixels(samples, resolution) {
6115 return Math.floor(samples / resolution);
6116}
6117
6118function pixelsToSamples(pixels, resolution) {
6119 return Math.floor(pixels * resolution);
6120}
6121
6122function pixelsToSeconds(pixels, resolution, sampleRate) {
6123 return (pixels * resolution) / sampleRate;
6124}
6125
6126function secondsToPixels(seconds, resolution, sampleRate) {
6127 return Math.ceil((seconds * sampleRate) / resolution);
6128}
6129
6130;// CONCATENATED MODULE: ./src/track/loader/Loader.js
6131
6132
6133const STATE_UNINITIALIZED = 0;
6134const STATE_LOADING = 1;
6135const STATE_DECODING = 2;
6136const STATE_FINISHED = 3;
6137
6138/* harmony default export */ const Loader = (class {
6139 constructor(src, audioContext, ee = event_emitter_default()()) {
6140 this.src = src;
6141 this.ac = audioContext;
6142 this.audioRequestState = STATE_UNINITIALIZED;
6143 this.ee = ee;
6144 }
6145
6146 setStateChange(state) {
6147 this.audioRequestState = state;
6148 this.ee.emit("audiorequeststatechange", this.audioRequestState, this.src);
6149 }
6150
6151 fileProgress(e) {
6152 let percentComplete = 0;
6153
6154 if (this.audioRequestState === STATE_UNINITIALIZED) {
6155 this.setStateChange(STATE_LOADING);
6156 }
6157
6158 if (e.lengthComputable) {
6159 percentComplete = (e.loaded / e.total) * 100;
6160 }
6161
6162 this.ee.emit("loadprogress", percentComplete, this.src);
6163 }
6164
6165 fileLoad(e) {
6166 const audioData = e.target.response || e.target.result;
6167
6168 this.setStateChange(STATE_DECODING);
6169
6170 return new Promise((resolve, reject) => {
6171 this.ac.decodeAudioData(
6172 audioData,
6173 (audioBuffer) => {
6174 this.audioBuffer = audioBuffer;
6175 this.setStateChange(STATE_FINISHED);
6176
6177 resolve(audioBuffer);
6178 },
6179 (err) => {
6180 if (err === null) {
6181 // Safari issues with null error
6182 reject(Error("MediaDecodeAudioDataUnknownContentType"));
6183 } else {
6184 reject(err);
6185 }
6186 }
6187 );
6188 });
6189 }
6190});
6191
6192;// CONCATENATED MODULE: ./src/track/loader/BlobLoader.js
6193
6194
6195/* harmony default export */ const BlobLoader = (class extends Loader {
6196 /*
6197 * Loads an audio file via a FileReader
6198 */
6199 load() {
6200 return new Promise((resolve, reject) => {
6201 if (
6202 this.src.type.match(/audio.*/) ||
6203 // added for problems with Firefox mime types + ogg.
6204 this.src.type.match(/video\/ogg/)
6205 ) {
6206 const fr = new FileReader();
6207
6208 fr.readAsArrayBuffer(this.src);
6209
6210 fr.addEventListener("progress", (e) => {
6211 super.fileProgress(e);
6212 });
6213
6214 fr.addEventListener("load", (e) => {
6215 const decoderPromise = super.fileLoad(e);
6216
6217 decoderPromise
6218 .then((audioBuffer) => {
6219 resolve(audioBuffer);
6220 })
6221 .catch(reject);
6222 });
6223
6224 fr.addEventListener("error", reject);
6225 } else {
6226 reject(Error(`Unsupported file type ${this.src.type}`));
6227 }
6228 });
6229 }
6230});
6231
6232;// CONCATENATED MODULE: ./src/track/loader/IdentityLoader.js
6233
6234
6235class IdentityLoader extends Loader {
6236 load() {
6237 return Promise.resolve(this.src);
6238 }
6239}
6240
6241;// CONCATENATED MODULE: ./src/track/loader/XHRLoader.js
6242
6243
6244/* harmony default export */ const XHRLoader = (class extends Loader {
6245 /**
6246 * Loads an audio file via XHR.
6247 */
6248 load() {
6249 return new Promise((resolve, reject) => {
6250 const xhr = new XMLHttpRequest();
6251
6252 xhr.open("GET", this.src, true);
6253 xhr.responseType = "arraybuffer";
6254 xhr.send();
6255
6256 xhr.addEventListener("progress", (e) => {
6257 super.fileProgress(e);
6258 });
6259
6260 xhr.addEventListener("load", (e) => {
6261 const decoderPromise = super.fileLoad(e);
6262
6263 decoderPromise
6264 .then((audioBuffer) => {
6265 resolve(audioBuffer);
6266 })
6267 .catch(reject);
6268 });
6269
6270 xhr.addEventListener("error", () => {
6271 reject(Error(`Track ${this.src} failed to load`));
6272 });
6273 });
6274 }
6275});
6276
6277;// CONCATENATED MODULE: ./src/track/loader/LoaderFactory.js
6278
6279
6280
6281
6282/* harmony default export */ const LoaderFactory = (class {
6283 static createLoader(src, audioContext, ee) {
6284 if (src instanceof Blob) {
6285 return new BlobLoader(src, audioContext, ee);
6286 } else if (src instanceof AudioBuffer) {
6287 return new IdentityLoader(src, audioContext, ee);
6288 } else if (typeof src === "string") {
6289 return new XHRLoader(src, audioContext, ee);
6290 }
6291
6292 throw new Error("Unsupported src type");
6293 }
6294});
6295
6296;// CONCATENATED MODULE: ./src/render/ScrollHook.js
6297
6298
6299/*
6300 * virtual-dom hook for scrolling the track container.
6301 */
6302/* harmony default export */ const ScrollHook = (class {
6303 constructor(playlist) {
6304 this.playlist = playlist;
6305 }
6306
6307 hook(node) {
6308 const playlist = this.playlist;
6309 if (!playlist.isScrolling) {
6310 const el = node;
6311
6312 if (playlist.isAutomaticScroll) {
6313 const rect = node.getBoundingClientRect();
6314 const controlWidth = playlist.controls.show
6315 ? playlist.controls.width
6316 : 0;
6317 const width = pixelsToSeconds(
6318 rect.width - controlWidth,
6319 playlist.samplesPerPixel,
6320 playlist.sampleRate
6321 );
6322
6323 const timePoint = playlist.isPlaying()
6324 ? playlist.playbackSeconds
6325 : playlist.getTimeSelection().start;
6326
6327 if (
6328 timePoint < playlist.scrollLeft ||
6329 timePoint >= playlist.scrollLeft + width
6330 ) {
6331 playlist.scrollLeft = Math.min(timePoint, playlist.duration - width);
6332 }
6333 }
6334
6335 const left = secondsToPixels(
6336 playlist.scrollLeft,
6337 playlist.samplesPerPixel,
6338 playlist.sampleRate
6339 );
6340
6341 el.scrollLeft = left;
6342 }
6343 }
6344});
6345
6346;// CONCATENATED MODULE: ./src/render/TimeScaleHook.js
6347/*
6348 * virtual-dom hook for rendering the time scale canvas.
6349 */
6350/* harmony default export */ const TimeScaleHook = (class {
6351 constructor(tickInfo, offset, samplesPerPixel, duration, colors) {
6352 this.tickInfo = tickInfo;
6353 this.offset = offset;
6354 this.samplesPerPixel = samplesPerPixel;
6355 this.duration = duration;
6356 this.colors = colors;
6357 }
6358
6359 hook(canvas, prop, prev) {
6360 // canvas is up to date
6361 if (
6362 prev !== undefined &&
6363 prev.offset === this.offset &&
6364 prev.duration === this.duration &&
6365 prev.samplesPerPixel === this.samplesPerPixel
6366 ) {
6367 return;
6368 }
6369
6370 const width = canvas.width;
6371 const height = canvas.height;
6372 const ctx = canvas.getContext("2d");
6373
6374 ctx.clearRect(0, 0, width, height);
6375 ctx.fillStyle = this.colors.timeColor;
6376
6377 Object.keys(this.tickInfo).forEach((x) => {
6378 const scaleHeight = this.tickInfo[x];
6379 const scaleY = height - scaleHeight;
6380 ctx.fillRect(x, scaleY, 1, scaleHeight);
6381 });
6382 }
6383});
6384
6385;// CONCATENATED MODULE: ./src/TimeScale.js
6386
6387
6388
6389
6390
6391class TimeScale {
6392 constructor(
6393 duration,
6394 offset,
6395 samplesPerPixel,
6396 sampleRate,
6397 marginLeft = 0,
6398 colors
6399 ) {
6400 this.duration = duration;
6401 this.offset = offset;
6402 this.samplesPerPixel = samplesPerPixel;
6403 this.sampleRate = sampleRate;
6404 this.marginLeft = marginLeft;
6405 this.colors = colors;
6406
6407 this.timeinfo = {
6408 20000: {
6409 marker: 30000,
6410 bigStep: 10000,
6411 smallStep: 5000,
6412 secondStep: 5,
6413 },
6414 12000: {
6415 marker: 15000,
6416 bigStep: 5000,
6417 smallStep: 1000,
6418 secondStep: 1,
6419 },
6420 10000: {
6421 marker: 10000,
6422 bigStep: 5000,
6423 smallStep: 1000,
6424 secondStep: 1,
6425 },
6426 5000: {
6427 marker: 5000,
6428 bigStep: 1000,
6429 smallStep: 500,
6430 secondStep: 1 / 2,
6431 },
6432 2500: {
6433 marker: 2000,
6434 bigStep: 1000,
6435 smallStep: 500,
6436 secondStep: 1 / 2,
6437 },
6438 1500: {
6439 marker: 2000,
6440 bigStep: 1000,
6441 smallStep: 200,
6442 secondStep: 1 / 5,
6443 },
6444 700: {
6445 marker: 1000,
6446 bigStep: 500,
6447 smallStep: 100,
6448 secondStep: 1 / 10,
6449 },
6450 };
6451 }
6452
6453 getScaleInfo(resolution) {
6454 let keys = Object.keys(this.timeinfo).map((item) => parseInt(item, 10));
6455
6456 // make sure keys are numerically sorted.
6457 keys = keys.sort((a, b) => a - b);
6458
6459 for (let i = 0; i < keys.length; i += 1) {
6460 if (resolution <= keys[i]) {
6461 return this.timeinfo[keys[i]];
6462 }
6463 }
6464
6465 return this.timeinfo[keys[0]];
6466 }
6467
6468 /*
6469 Return time in format mm:ss
6470 */
6471 static formatTime(milliseconds) {
6472 const seconds = milliseconds / 1000;
6473 let s = seconds % 60;
6474 const m = (seconds - s) / 60;
6475
6476 if (s < 10) {
6477 s = `0${s}`;
6478 }
6479
6480 return `${m}:${s}`;
6481 }
6482
6483 render() {
6484 const widthX = secondsToPixels(
6485 this.duration,
6486 this.samplesPerPixel,
6487 this.sampleRate
6488 );
6489 const pixPerSec = this.sampleRate / this.samplesPerPixel;
6490 const pixOffset = secondsToPixels(
6491 this.offset,
6492 this.samplesPerPixel,
6493 this.sampleRate
6494 );
6495 const scaleInfo = this.getScaleInfo(this.samplesPerPixel);
6496 const canvasInfo = {};
6497 const timeMarkers = [];
6498 const end = widthX + pixOffset;
6499 let counter = 0;
6500
6501 for (let i = 0; i < end; i += pixPerSec * scaleInfo.secondStep) {
6502 const pixIndex = Math.floor(i);
6503 const pix = pixIndex - pixOffset;
6504
6505 if (pixIndex >= pixOffset) {
6506 // put a timestamp every 30 seconds.
6507 if (scaleInfo.marker && counter % scaleInfo.marker === 0) {
6508 timeMarkers.push(
6509 h_default()(
6510 "div.time",
6511 {
6512 attributes: {
6513 style: `position: absolute; left: ${pix}px;`,
6514 },
6515 },
6516 [TimeScale.formatTime(counter)]
6517 )
6518 );
6519
6520 canvasInfo[pix] = 10;
6521 } else if (scaleInfo.bigStep && counter % scaleInfo.bigStep === 0) {
6522 canvasInfo[pix] = 5;
6523 } else if (scaleInfo.smallStep && counter % scaleInfo.smallStep === 0) {
6524 canvasInfo[pix] = 2;
6525 }
6526 }
6527
6528 counter += 1000 * scaleInfo.secondStep;
6529 }
6530
6531 return h_default()(
6532 "div.playlist-time-scale",
6533 {
6534 attributes: {
6535 style: `position: relative; left: 0; right: 0; margin-left: ${this.marginLeft}px;`,
6536 },
6537 },
6538 [
6539 timeMarkers,
6540 h_default()("canvas", {
6541 attributes: {
6542 width: widthX,
6543 height: 30,
6544 style: "position: absolute; left: 0; right: 0; top: 0; bottom: 0;",
6545 },
6546 hook: new TimeScaleHook(
6547 canvasInfo,
6548 this.offset,
6549 this.samplesPerPixel,
6550 this.duration,
6551 this.colors
6552 ),
6553 }),
6554 ]
6555 );
6556 }
6557}
6558
6559/* harmony default export */ const src_TimeScale = (TimeScale);
6560
6561// EXTERNAL MODULE: ./node_modules/lodash.assign/index.js
6562var lodash_assign = __webpack_require__(1730);
6563var lodash_assign_default = /*#__PURE__*/__webpack_require__.n(lodash_assign);
6564// EXTERNAL MODULE: ./node_modules/lodash.forown/index.js
6565var lodash_forown = __webpack_require__(3520);
6566var lodash_forown_default = /*#__PURE__*/__webpack_require__.n(lodash_forown);
6567;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
6568// Unique ID creation requires a high quality random # generator. In the browser we therefore
6569// require the crypto API and do not support built-in fallback to lower quality random number
6570// generators (like Math.random()).
6571var getRandomValues;
6572var rnds8 = new Uint8Array(16);
6573function rng() {
6574 // lazy load so that environments that need to polyfill have a chance to do so
6575 if (!getRandomValues) {
6576 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
6577 // find the complete implementation of crypto (msCrypto) on IE11.
6578 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
6579
6580 if (!getRandomValues) {
6581 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
6582 }
6583 }
6584
6585 return getRandomValues(rnds8);
6586}
6587;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
6588/* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
6589;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
6590
6591
6592function validate(uuid) {
6593 return typeof uuid === 'string' && regex.test(uuid);
6594}
6595
6596/* harmony default export */ const esm_browser_validate = (validate);
6597;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
6598
6599/**
6600 * Convert array of 16 byte values to UUID string format of the form:
6601 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6602 */
6603
6604var byteToHex = [];
6605
6606for (var i = 0; i < 256; ++i) {
6607 byteToHex.push((i + 0x100).toString(16).substr(1));
6608}
6609
6610function stringify(arr) {
6611 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
6612 // Note: Be careful editing this code! It's been tuned for performance
6613 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
6614 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
6615 // of the following:
6616 // - One or more input array values don't map to a hex octet (leading to
6617 // "undefined" in the uuid)
6618 // - Invalid input values for the RFC `version` or `variant` fields
6619
6620 if (!esm_browser_validate(uuid)) {
6621 throw TypeError('Stringified UUID is invalid');
6622 }
6623
6624 return uuid;
6625}
6626
6627/* harmony default export */ const esm_browser_stringify = (stringify);
6628;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
6629
6630
6631
6632function v4(options, buf, offset) {
6633 options = options || {};
6634 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
6635
6636 rnds[6] = rnds[6] & 0x0f | 0x40;
6637 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
6638
6639 if (buf) {
6640 offset = offset || 0;
6641
6642 for (var i = 0; i < 16; ++i) {
6643 buf[offset + i] = rnds[i];
6644 }
6645
6646 return buf;
6647 }
6648
6649 return esm_browser_stringify(rnds);
6650}
6651
6652/* harmony default export */ const esm_browser_v4 = (v4);
6653// EXTERNAL MODULE: ./node_modules/webaudio-peaks/index.js
6654var webaudio_peaks = __webpack_require__(4991);
6655var webaudio_peaks_default = /*#__PURE__*/__webpack_require__.n(webaudio_peaks);
6656// EXTERNAL MODULE: ./node_modules/fade-maker/index.js
6657var fade_maker = __webpack_require__(1114);
6658;// CONCATENATED MODULE: ./src/track/states/CursorState.js
6659
6660
6661/* harmony default export */ const CursorState = (class {
6662 constructor(track) {
6663 this.track = track;
6664 }
6665
6666 setup(samplesPerPixel, sampleRate) {
6667 this.samplesPerPixel = samplesPerPixel;
6668 this.sampleRate = sampleRate;
6669 }
6670
6671 click(e) {
6672 e.preventDefault();
6673
6674 const startX = e.offsetX;
6675 const startTime = pixelsToSeconds(
6676 startX,
6677 this.samplesPerPixel,
6678 this.sampleRate
6679 );
6680
6681 this.track.ee.emit("select", startTime, startTime, this.track);
6682 }
6683
6684 static getClass() {
6685 return ".state-cursor";
6686 }
6687
6688 static getEvents() {
6689 return ["click"];
6690 }
6691});
6692
6693;// CONCATENATED MODULE: ./src/track/states/SelectState.js
6694
6695
6696/* harmony default export */ const SelectState = (class {
6697 constructor(track) {
6698 this.track = track;
6699 this.active = false;
6700 }
6701
6702 setup(samplesPerPixel, sampleRate) {
6703 this.samplesPerPixel = samplesPerPixel;
6704 this.sampleRate = sampleRate;
6705 }
6706
6707 emitSelection(x) {
6708 const minX = Math.min(x, this.startX);
6709 const maxX = Math.max(x, this.startX);
6710 const startTime = pixelsToSeconds(
6711 minX,
6712 this.samplesPerPixel,
6713 this.sampleRate
6714 );
6715 const endTime = pixelsToSeconds(
6716 maxX,
6717 this.samplesPerPixel,
6718 this.sampleRate
6719 );
6720
6721 this.track.ee.emit("select", startTime, endTime, this.track);
6722 }
6723
6724 complete(x) {
6725 this.emitSelection(x);
6726 this.active = false;
6727 }
6728
6729 mousedown(e) {
6730 e.preventDefault();
6731 this.active = true;
6732
6733 this.startX = e.offsetX;
6734 const startTime = pixelsToSeconds(
6735 this.startX,
6736 this.samplesPerPixel,
6737 this.sampleRate
6738 );
6739
6740 this.track.ee.emit("select", startTime, startTime, this.track);
6741 }
6742
6743 mousemove(e) {
6744 if (this.active) {
6745 e.preventDefault();
6746 this.emitSelection(e.offsetX);
6747 }
6748 }
6749
6750 mouseup(e) {
6751 if (this.active) {
6752 e.preventDefault();
6753 this.complete(e.offsetX);
6754 }
6755 }
6756
6757 mouseleave(e) {
6758 if (this.active) {
6759 e.preventDefault();
6760 this.complete(e.offsetX);
6761 }
6762 }
6763
6764 static getClass() {
6765 return ".state-select";
6766 }
6767
6768 static getEvents() {
6769 return ["mousedown", "mousemove", "mouseup", "mouseleave"];
6770 }
6771});
6772
6773;// CONCATENATED MODULE: ./src/track/states/ShiftState.js
6774
6775
6776/* harmony default export */ const ShiftState = (class {
6777 constructor(track) {
6778 this.track = track;
6779 this.active = false;
6780 }
6781
6782 setup(samplesPerPixel, sampleRate) {
6783 this.samplesPerPixel = samplesPerPixel;
6784 this.sampleRate = sampleRate;
6785 }
6786
6787 emitShift(x) {
6788 const deltaX = x - this.prevX;
6789 const deltaTime = pixelsToSeconds(
6790 deltaX,
6791 this.samplesPerPixel,
6792 this.sampleRate
6793 );
6794 this.prevX = x;
6795 this.track.ee.emit("shift", deltaTime, this.track);
6796 }
6797
6798 complete(x) {
6799 this.emitShift(x);
6800 this.active = false;
6801 }
6802
6803 mousedown(e) {
6804 e.preventDefault();
6805
6806 this.active = true;
6807 this.el = e.target;
6808 this.prevX = e.offsetX;
6809 }
6810
6811 mousemove(e) {
6812 if (this.active) {
6813 e.preventDefault();
6814 this.emitShift(e.offsetX);
6815 }
6816 }
6817
6818 mouseup(e) {
6819 if (this.active) {
6820 e.preventDefault();
6821 this.complete(e.offsetX);
6822 }
6823 }
6824
6825 mouseleave(e) {
6826 if (this.active) {
6827 e.preventDefault();
6828 this.complete(e.offsetX);
6829 }
6830 }
6831
6832 static getClass() {
6833 return ".state-shift";
6834 }
6835
6836 static getEvents() {
6837 return ["mousedown", "mousemove", "mouseup", "mouseleave"];
6838 }
6839});
6840
6841;// CONCATENATED MODULE: ./src/track/states/FadeInState.js
6842
6843
6844/* harmony default export */ const FadeInState = (class {
6845 constructor(track) {
6846 this.track = track;
6847 }
6848
6849 setup(samplesPerPixel, sampleRate) {
6850 this.samplesPerPixel = samplesPerPixel;
6851 this.sampleRate = sampleRate;
6852 }
6853
6854 click(e) {
6855 const startX = e.offsetX;
6856 const time = pixelsToSeconds(startX, this.samplesPerPixel, this.sampleRate);
6857
6858 if (time > this.track.getStartTime() && time < this.track.getEndTime()) {
6859 this.track.ee.emit(
6860 "fadein",
6861 time - this.track.getStartTime(),
6862 this.track
6863 );
6864 }
6865 }
6866
6867 static getClass() {
6868 return ".state-fadein";
6869 }
6870
6871 static getEvents() {
6872 return ["click"];
6873 }
6874});
6875
6876;// CONCATENATED MODULE: ./src/track/states/FadeOutState.js
6877
6878
6879/* harmony default export */ const FadeOutState = (class {
6880 constructor(track) {
6881 this.track = track;
6882 }
6883
6884 setup(samplesPerPixel, sampleRate) {
6885 this.samplesPerPixel = samplesPerPixel;
6886 this.sampleRate = sampleRate;
6887 }
6888
6889 click(e) {
6890 const startX = e.offsetX;
6891 const time = pixelsToSeconds(startX, this.samplesPerPixel, this.sampleRate);
6892
6893 if (time > this.track.getStartTime() && time < this.track.getEndTime()) {
6894 this.track.ee.emit("fadeout", this.track.getEndTime() - time, this.track);
6895 }
6896 }
6897
6898 static getClass() {
6899 return ".state-fadeout";
6900 }
6901
6902 static getEvents() {
6903 return ["click"];
6904 }
6905});
6906
6907;// CONCATENATED MODULE: ./src/track/states.js
6908
6909
6910
6911
6912
6913
6914/* harmony default export */ const states = ({
6915 cursor: CursorState,
6916 select: SelectState,
6917 shift: ShiftState,
6918 fadein: FadeInState,
6919 fadeout: FadeOutState,
6920});
6921
6922;// CONCATENATED MODULE: ./src/render/CanvasHook.js
6923/*
6924 * virtual-dom hook for drawing to the canvas element.
6925 */
6926class CanvasHook {
6927 constructor(peaks, offset, bits, color, scale, height, barWidth, barGap) {
6928 this.peaks = peaks;
6929 // http://stackoverflow.com/questions/6081483/maximum-size-of-a-canvas-element
6930 this.offset = offset;
6931 this.color = color;
6932 this.bits = bits;
6933 this.scale = scale;
6934 this.height = height;
6935 this.barWidth = barWidth;
6936 this.barGap = barGap;
6937 }
6938
6939 static drawFrame(cc, h2, x, minPeak, maxPeak, width, gap) {
6940 const min = Math.abs(minPeak * h2);
6941 const max = Math.abs(maxPeak * h2);
6942
6943 // draw max
6944 cc.fillRect(x, 0, width, h2 - max);
6945 // draw min
6946 cc.fillRect(x, h2 + min, width, h2 - min);
6947 // draw gap
6948 if (gap !== 0) {
6949 cc.fillRect(x + width, 0, gap, h2 * 2);
6950 }
6951 }
6952
6953 hook(canvas, prop, prev) {
6954 // canvas is up to date
6955 if (
6956 prev !== undefined &&
6957 prev.peaks === this.peaks &&
6958 prev.scale === this.scale &&
6959 prev.height === this.height
6960 ) {
6961 return;
6962 }
6963
6964 const scale = this.scale;
6965 const len = canvas.width / scale;
6966 const cc = canvas.getContext("2d");
6967 const h2 = canvas.height / scale / 2;
6968 const maxValue = 2 ** (this.bits - 1);
6969 const width = this.barWidth;
6970 const gap = this.barGap;
6971 const barStart = width + gap;
6972
6973 cc.clearRect(0, 0, canvas.width, canvas.height);
6974
6975 cc.save();
6976 cc.fillStyle = this.color;
6977 cc.scale(scale, scale);
6978
6979 for (let pixel = 0; pixel < len; pixel += barStart) {
6980 const minPeak = this.peaks[(pixel + this.offset) * 2] / maxValue;
6981 const maxPeak = this.peaks[(pixel + this.offset) * 2 + 1] / maxValue;
6982 CanvasHook.drawFrame(cc, h2, pixel, minPeak, maxPeak, width, gap);
6983 }
6984
6985 cc.restore();
6986 }
6987}
6988
6989/* harmony default export */ const render_CanvasHook = (CanvasHook);
6990
6991// EXTERNAL MODULE: ./node_modules/fade-curves/index.js
6992var fade_curves = __webpack_require__(6226);
6993;// CONCATENATED MODULE: ./src/render/FadeCanvasHook.js
6994
6995
6996
6997/*
6998 * virtual-dom hook for drawing the fade curve to the canvas element.
6999 */
7000class FadeCanvasHook {
7001 constructor(type, shape, duration, samplesPerPixel) {
7002 this.type = type;
7003 this.shape = shape;
7004 this.duration = duration;
7005 this.samplesPerPixel = samplesPerPixel;
7006 }
7007
7008 static createCurve(shape, type, width) {
7009 let reflection;
7010 let curve;
7011
7012 switch (type) {
7013 case fade_maker/* FADEIN */.Y1: {
7014 reflection = 1;
7015 break;
7016 }
7017 case fade_maker/* FADEOUT */.h7: {
7018 reflection = -1;
7019 break;
7020 }
7021 default: {
7022 throw new Error("Unsupported fade type.");
7023 }
7024 }
7025
7026 switch (shape) {
7027 case fade_maker/* SCURVE */._h: {
7028 curve = (0,fade_curves.sCurve)(width, reflection);
7029 break;
7030 }
7031 case fade_maker/* LINEAR */.t$: {
7032 curve = (0,fade_curves.linear)(width, reflection);
7033 break;
7034 }
7035 case fade_maker/* EXPONENTIAL */.Jl: {
7036 curve = (0,fade_curves.exponential)(width, reflection);
7037 break;
7038 }
7039 case fade_maker/* LOGARITHMIC */.Hp: {
7040 curve = (0,fade_curves.logarithmic)(width, 10, reflection);
7041 break;
7042 }
7043 default: {
7044 throw new Error("Unsupported fade shape");
7045 }
7046 }
7047
7048 return curve;
7049 }
7050
7051 hook(canvas, prop, prev) {
7052 // node is up to date.
7053 if (
7054 prev !== undefined &&
7055 prev.shape === this.shape &&
7056 prev.type === this.type &&
7057 prev.duration === this.duration &&
7058 prev.samplesPerPixel === this.samplesPerPixel
7059 ) {
7060 return;
7061 }
7062
7063 const ctx = canvas.getContext("2d");
7064 const width = canvas.width;
7065 const height = canvas.height;
7066 const curve = FadeCanvasHook.createCurve(this.shape, this.type, width);
7067 const len = curve.length;
7068 let y = height - curve[0] * height;
7069
7070 ctx.clearRect(0, 0, canvas.width, canvas.height);
7071 ctx.save();
7072
7073 ctx.strokeStyle = "black";
7074 ctx.beginPath();
7075 ctx.moveTo(0, y);
7076
7077 for (let i = 1; i < len; i += 1) {
7078 y = height - curve[i] * height;
7079 ctx.lineTo(i, y);
7080 }
7081 ctx.stroke();
7082 ctx.restore();
7083 }
7084}
7085
7086/* harmony default export */ const render_FadeCanvasHook = (FadeCanvasHook);
7087
7088;// CONCATENATED MODULE: ./src/render/VolumeSliderHook.js
7089/* eslint-disable no-param-reassign */
7090/*
7091 * virtual-dom hook for setting the volume input programmatically.
7092 */
7093/* harmony default export */ const VolumeSliderHook = (class {
7094 constructor(gain) {
7095 this.gain = gain;
7096 }
7097
7098 hook(volumeInput) {
7099 volumeInput.value = this.gain * 100;
7100 volumeInput.title = `${Math.round(this.gain * 100)}% volume`;
7101 }
7102});
7103
7104;// CONCATENATED MODULE: ./src/render/StereoPanSliderHook.js
7105/* eslint-disable no-param-reassign */
7106/*
7107 * virtual-dom hook for setting the stereoPan input programmatically.
7108 */
7109/* harmony default export */ const StereoPanSliderHook = (class {
7110 constructor(stereoPan) {
7111 this.stereoPan = stereoPan;
7112 }
7113
7114 hook(stereoPanInput) {
7115 stereoPanInput.value = this.stereoPan * 100;
7116
7117 let panOrientation;
7118 if (this.stereoPan === 0) {
7119 panOrientation = "Center";
7120 } else if (this.stereoPan < 0) {
7121 panOrientation = "Left";
7122 } else {
7123 panOrientation = "Right";
7124 }
7125 const percentage = `${Math.abs(Math.round(this.stereoPan * 100))}% `;
7126 stereoPanInput.title = `Pan: ${
7127 this.stereoPan !== 0 ? percentage : ""
7128 }${panOrientation}`;
7129 }
7130});
7131
7132;// CONCATENATED MODULE: ./src/Track.js
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150const MAX_CANVAS_WIDTH = 1000;
7151
7152/* harmony default export */ const Track = (class {
7153 constructor() {
7154 this.name = "Untitled";
7155 this.customClass = undefined;
7156 this.waveOutlineColor = undefined;
7157 this.gain = 1;
7158 this.fades = {};
7159 this.peakData = {
7160 type: "WebAudio",
7161 mono: false,
7162 };
7163
7164 this.cueIn = 0;
7165 this.cueOut = 0;
7166 this.duration = 0;
7167 this.startTime = 0;
7168 this.endTime = 0;
7169 this.stereoPan = 0;
7170 }
7171
7172 setEventEmitter(ee) {
7173 this.ee = ee;
7174 }
7175
7176 setName(name) {
7177 this.name = name;
7178 }
7179
7180 setCustomClass(className) {
7181 this.customClass = className;
7182 }
7183
7184 setWaveOutlineColor(color) {
7185 this.waveOutlineColor = color;
7186 }
7187
7188 setCues(cueIn, cueOut) {
7189 if (cueOut < cueIn) {
7190 throw new Error("cue out cannot be less than cue in");
7191 }
7192
7193 this.cueIn = cueIn;
7194 this.cueOut = cueOut;
7195 this.duration = this.cueOut - this.cueIn;
7196 this.endTime = this.startTime + this.duration;
7197 }
7198
7199 /*
7200 * start, end in seconds relative to the entire playlist.
7201 */
7202 trim(start, end) {
7203 const trackStart = this.getStartTime();
7204 const trackEnd = this.getEndTime();
7205 const offset = this.cueIn - trackStart;
7206
7207 if (
7208 (trackStart <= start && trackEnd >= start) ||
7209 (trackStart <= end && trackEnd >= end)
7210 ) {
7211 const cueIn = start < trackStart ? trackStart : start;
7212 const cueOut = end > trackEnd ? trackEnd : end;
7213
7214 this.setCues(cueIn + offset, cueOut + offset);
7215 if (start > trackStart) {
7216 this.setStartTime(start);
7217 }
7218 }
7219 }
7220
7221 setStartTime(start) {
7222 this.startTime = start;
7223 this.endTime = start + this.duration;
7224 }
7225
7226 setPlayout(playout) {
7227 this.playout = playout;
7228 }
7229
7230 setOfflinePlayout(playout) {
7231 this.offlinePlayout = playout;
7232 }
7233
7234 setEnabledStates(enabledStates = {}) {
7235 const defaultStatesEnabled = {
7236 cursor: true,
7237 fadein: true,
7238 fadeout: true,
7239 select: true,
7240 shift: true,
7241 };
7242
7243 this.enabledStates = lodash_assign_default()({}, defaultStatesEnabled, enabledStates);
7244 }
7245
7246 setFadeIn(duration, shape = "logarithmic") {
7247 if (duration > this.duration) {
7248 throw new Error("Invalid Fade In");
7249 }
7250
7251 const fade = {
7252 shape,
7253 start: 0,
7254 end: duration,
7255 };
7256
7257 if (this.fadeIn) {
7258 this.removeFade(this.fadeIn);
7259 this.fadeIn = undefined;
7260 }
7261
7262 this.fadeIn = this.saveFade(fade_maker/* FADEIN */.Y1, fade.shape, fade.start, fade.end);
7263 }
7264
7265 setFadeOut(duration, shape = "logarithmic") {
7266 if (duration > this.duration) {
7267 throw new Error("Invalid Fade Out");
7268 }
7269
7270 const fade = {
7271 shape,
7272 start: this.duration - duration,
7273 end: this.duration,
7274 };
7275
7276 if (this.fadeOut) {
7277 this.removeFade(this.fadeOut);
7278 this.fadeOut = undefined;
7279 }
7280
7281 this.fadeOut = this.saveFade(fade_maker/* FADEOUT */.h7, fade.shape, fade.start, fade.end);
7282 }
7283
7284 saveFade(type, shape, start, end) {
7285 const id = esm_browser_v4();
7286
7287 this.fades[id] = {
7288 type,
7289 shape,
7290 start,
7291 end,
7292 };
7293
7294 return id;
7295 }
7296
7297 removeFade(id) {
7298 delete this.fades[id];
7299 }
7300
7301 setBuffer(buffer) {
7302 this.buffer = buffer;
7303 }
7304
7305 setPeakData(data) {
7306 this.peakData = data;
7307 }
7308
7309 calculatePeaks(samplesPerPixel, sampleRate) {
7310 const cueIn = secondsToSamples(this.cueIn, sampleRate);
7311 const cueOut = secondsToSamples(this.cueOut, sampleRate);
7312
7313 this.setPeaks(
7314 webaudio_peaks_default()(
7315 this.buffer,
7316 samplesPerPixel,
7317 this.peakData.mono,
7318 cueIn,
7319 cueOut
7320 )
7321 );
7322 }
7323
7324 setPeaks(peaks) {
7325 this.peaks = peaks;
7326 }
7327
7328 setState(state) {
7329 this.state = state;
7330
7331 if (this.state && this.enabledStates[this.state]) {
7332 const StateClass = states[this.state];
7333 this.stateObj = new StateClass(this);
7334 } else {
7335 this.stateObj = undefined;
7336 }
7337 }
7338
7339 getStartTime() {
7340 return this.startTime;
7341 }
7342
7343 getEndTime() {
7344 return this.endTime;
7345 }
7346
7347 getDuration() {
7348 return this.duration;
7349 }
7350
7351 isPlaying() {
7352 return this.playout.isPlaying();
7353 }
7354
7355 setShouldPlay(bool) {
7356 this.playout.setShouldPlay(bool);
7357 }
7358
7359 setGainLevel(level) {
7360 this.gain = level;
7361 this.playout.setVolumeGainLevel(level);
7362 }
7363
7364 setMasterGainLevel(level) {
7365 this.playout.setMasterGainLevel(level);
7366 }
7367
7368 setStereoPanValue(value) {
7369 this.stereoPan = value;
7370 this.playout.setStereoPanValue(value);
7371 }
7372
7373 /*
7374 startTime, endTime in seconds (float).
7375 segment is for a highlighted section in the UI.
7376
7377 returns a Promise that will resolve when the AudioBufferSource
7378 is either stopped or plays out naturally.
7379 */
7380 schedulePlay(now, startTime, endTime, config) {
7381 let start;
7382 let duration;
7383 let when = now;
7384 let segment = endTime ? endTime - startTime : undefined;
7385
7386 const defaultOptions = {
7387 shouldPlay: true,
7388 masterGain: 1,
7389 isOffline: false,
7390 };
7391
7392 const options = lodash_assign_default()({}, defaultOptions, config);
7393 const playoutSystem = options.isOffline
7394 ? this.offlinePlayout
7395 : this.playout;
7396
7397 // 1) track has no content to play.
7398 // 2) track does not play in this selection.
7399 if (
7400 this.endTime <= startTime ||
7401 (segment && startTime + segment < this.startTime)
7402 ) {
7403 // return a resolved promise since this track is technically "stopped".
7404 return Promise.resolve();
7405 }
7406
7407 // track should have something to play if it gets here.
7408
7409 // the track starts in the future or on the cursor position
7410 if (this.startTime >= startTime) {
7411 start = 0;
7412 // schedule additional delay for this audio node.
7413 when += this.startTime - startTime;
7414
7415 if (endTime) {
7416 segment -= this.startTime - startTime;
7417 duration = Math.min(segment, this.duration);
7418 } else {
7419 duration = this.duration;
7420 }
7421 } else {
7422 start = startTime - this.startTime;
7423
7424 if (endTime) {
7425 duration = Math.min(segment, this.duration - start);
7426 } else {
7427 duration = this.duration - start;
7428 }
7429 }
7430
7431 start += this.cueIn;
7432 const relPos = startTime - this.startTime;
7433 const sourcePromise = playoutSystem.setUpSource();
7434
7435 // param relPos: cursor position in seconds relative to this track.
7436 // can be negative if the cursor is placed before the start of this track etc.
7437 lodash_forown_default()(this.fades, (fade) => {
7438 let fadeStart;
7439 let fadeDuration;
7440
7441 // only apply fade if it's ahead of the cursor.
7442 if (relPos < fade.end) {
7443 if (relPos <= fade.start) {
7444 fadeStart = now + (fade.start - relPos);
7445 fadeDuration = fade.end - fade.start;
7446 } else if (relPos > fade.start && relPos < fade.end) {
7447 fadeStart = now - (relPos - fade.start);
7448 fadeDuration = fade.end - fade.start;
7449 }
7450
7451 switch (fade.type) {
7452 case fade_maker/* FADEIN */.Y1: {
7453 playoutSystem.applyFadeIn(fadeStart, fadeDuration, fade.shape);
7454 break;
7455 }
7456 case fade_maker/* FADEOUT */.h7: {
7457 playoutSystem.applyFadeOut(fadeStart, fadeDuration, fade.shape);
7458 break;
7459 }
7460 default: {
7461 throw new Error("Invalid fade type saved on track.");
7462 }
7463 }
7464 }
7465 });
7466
7467 playoutSystem.setVolumeGainLevel(this.gain);
7468 playoutSystem.setShouldPlay(options.shouldPlay);
7469 playoutSystem.setMasterGainLevel(options.masterGain);
7470 playoutSystem.setStereoPanValue(this.stereoPan);
7471 playoutSystem.play(when, start, duration);
7472
7473 return sourcePromise;
7474 }
7475
7476 scheduleStop(when = 0) {
7477 this.playout.stop(when);
7478 }
7479
7480 renderOverlay(data) {
7481 const channelPixels = secondsToPixels(
7482 data.playlistLength,
7483 data.resolution,
7484 data.sampleRate
7485 );
7486
7487 const config = {
7488 attributes: {
7489 style: `position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: ${channelPixels}px; z-index: 9;`,
7490 },
7491 };
7492
7493 let overlayClass = "";
7494
7495 if (this.stateObj) {
7496 this.stateObj.setup(data.resolution, data.sampleRate);
7497 const StateClass = states[this.state];
7498 const events = StateClass.getEvents();
7499
7500 events.forEach((event) => {
7501 config[`on${event}`] = this.stateObj[event].bind(this.stateObj);
7502 });
7503
7504 overlayClass = StateClass.getClass();
7505 }
7506 // use this overlay for track event cursor position calculations.
7507 return h_default()(`div.playlist-overlay${overlayClass}`, config);
7508 }
7509
7510 renderControls(data) {
7511 const muteClass = data.muted ? ".active" : "";
7512 const soloClass = data.soloed ? ".active" : "";
7513 const isCollapsed = data.collapsed;
7514 const numChan = this.peaks.data.length;
7515 const widgets = data.controls.widgets;
7516
7517 const removeTrack = h_default()(
7518 "button.btn.btn-danger.btn-xs.track-remove",
7519 {
7520 attributes: {
7521 type: "button",
7522 title: "Remove track",
7523 },
7524 onclick: () => {
7525 this.ee.emit("removeTrack", this);
7526 },
7527 },
7528 [h_default()("i.fas.fa-times")]
7529 );
7530
7531 const trackName = h_default()("span", [this.name]);
7532
7533 const collapseTrack = h_default()(
7534 "button.btn.btn-info.btn-xs.track-collapse",
7535 {
7536 attributes: {
7537 type: "button",
7538 title: isCollapsed ? "Expand track" : "Collapse track",
7539 },
7540 onclick: () => {
7541 this.ee.emit("changeTrackView", this, {
7542 collapsed: !isCollapsed,
7543 });
7544 },
7545 },
7546 [h_default()(`i.fas.${isCollapsed ? "fa-caret-down" : "fa-caret-up"}`)]
7547 );
7548
7549 const headerChildren = [];
7550
7551 if (widgets.remove) {
7552 headerChildren.push(removeTrack);
7553 }
7554 headerChildren.push(trackName);
7555 if (widgets.collapse) {
7556 headerChildren.push(collapseTrack);
7557 }
7558
7559 const controls = [h_default()("div.track-header", headerChildren)];
7560
7561 if (!isCollapsed) {
7562 if (widgets.muteOrSolo) {
7563 controls.push(
7564 h_default()("div.btn-group", [
7565 h_default()(
7566 `button.btn.btn-outline-dark.btn-xs.btn-mute${muteClass}`,
7567 {
7568 attributes: {
7569 type: "button",
7570 },
7571 onclick: () => {
7572 this.ee.emit("mute", this);
7573 },
7574 },
7575 ["Mute"]
7576 ),
7577 h_default()(
7578 `button.btn.btn-outline-dark.btn-xs.btn-solo${soloClass}`,
7579 {
7580 onclick: () => {
7581 this.ee.emit("solo", this);
7582 },
7583 },
7584 ["Solo"]
7585 ),
7586 ])
7587 );
7588 }
7589
7590 if (widgets.volume) {
7591 controls.push(
7592 h_default()("label.volume", [
7593 h_default()("input.volume-slider", {
7594 attributes: {
7595 "aria-label": "Track volume control",
7596 type: "range",
7597 min: 0,
7598 max: 100,
7599 value: 100,
7600 },
7601 hook: new VolumeSliderHook(this.gain),
7602 oninput: (e) => {
7603 this.ee.emit("volumechange", e.target.value, this);
7604 },
7605 }),
7606 ])
7607 );
7608 }
7609
7610 if (widgets.stereoPan) {
7611 controls.push(
7612 h_default()("label.stereopan", [
7613 h_default()("input.stereopan-slider", {
7614 attributes: {
7615 "aria-label": "Track stereo pan control",
7616 type: "range",
7617 min: -100,
7618 max: 100,
7619 value: 100,
7620 },
7621 hook: new StereoPanSliderHook(this.stereoPan),
7622 oninput: (e) => {
7623 this.ee.emit("stereopan", e.target.value / 100, this);
7624 },
7625 }),
7626 ])
7627 );
7628 }
7629 }
7630
7631 return h_default()(
7632 "div.controls",
7633 {
7634 attributes: {
7635 style: `height: ${numChan * data.height}px; width: ${
7636 data.controls.width
7637 }px; position: absolute; left: 0; z-index: 10;`,
7638 },
7639 },
7640 controls
7641 );
7642 }
7643
7644 render(data) {
7645 const width = this.peaks.length;
7646 const playbackX = secondsToPixels(
7647 data.playbackSeconds,
7648 data.resolution,
7649 data.sampleRate
7650 );
7651 const startX = secondsToPixels(
7652 this.startTime,
7653 data.resolution,
7654 data.sampleRate
7655 );
7656 const endX = secondsToPixels(
7657 this.endTime,
7658 data.resolution,
7659 data.sampleRate
7660 );
7661 let progressWidth = 0;
7662 const numChan = this.peaks.data.length;
7663 const scale = Math.floor(window.devicePixelRatio);
7664
7665 if (playbackX > 0 && playbackX > startX) {
7666 if (playbackX < endX) {
7667 progressWidth = playbackX - startX;
7668 } else {
7669 progressWidth = width;
7670 }
7671 }
7672
7673 const waveformChildren = [
7674 h_default()("div.cursor", {
7675 attributes: {
7676 style: `position: absolute; width: 1px; margin: 0; padding: 0; top: 0; left: ${playbackX}px; bottom: 0; z-index: 5;`,
7677 },
7678 }),
7679 ];
7680
7681 const channels = Object.keys(this.peaks.data).map((channelNum) => {
7682 const channelChildren = [
7683 h_default()("div.channel-progress", {
7684 attributes: {
7685 style: `position: absolute; width: ${progressWidth}px; height: ${data.height}px; z-index: 2;`,
7686 },
7687 }),
7688 ];
7689 let offset = 0;
7690 let totalWidth = width;
7691 const peaks = this.peaks.data[channelNum];
7692
7693 while (totalWidth > 0) {
7694 const currentWidth = Math.min(totalWidth, MAX_CANVAS_WIDTH);
7695 const canvasColor = this.waveOutlineColor
7696 ? this.waveOutlineColor
7697 : data.colors.waveOutlineColor;
7698
7699 channelChildren.push(
7700 h_default()("canvas", {
7701 attributes: {
7702 width: currentWidth * scale,
7703 height: data.height * scale,
7704 style: `float: left; position: relative; margin: 0; padding: 0; z-index: 3; width: ${currentWidth}px; height: ${data.height}px;`,
7705 },
7706 hook: new render_CanvasHook(
7707 peaks,
7708 offset,
7709 this.peaks.bits,
7710 canvasColor,
7711 scale,
7712 data.height,
7713 data.barWidth,
7714 data.barGap
7715 ),
7716 })
7717 );
7718
7719 totalWidth -= currentWidth;
7720 offset += MAX_CANVAS_WIDTH;
7721 }
7722
7723 // if there are fades, display them.
7724 if (this.fadeIn) {
7725 const fadeIn = this.fades[this.fadeIn];
7726 const fadeWidth = secondsToPixels(
7727 fadeIn.end - fadeIn.start,
7728 data.resolution,
7729 data.sampleRate
7730 );
7731
7732 channelChildren.push(
7733 h_default()(
7734 "div.wp-fade.wp-fadein",
7735 {
7736 attributes: {
7737 style: `position: absolute; height: ${data.height}px; width: ${fadeWidth}px; top: 0; left: 0; z-index: 4;`,
7738 },
7739 },
7740 [
7741 h_default()("canvas", {
7742 attributes: {
7743 width: fadeWidth,
7744 height: data.height,
7745 },
7746 hook: new render_FadeCanvasHook(
7747 fadeIn.type,
7748 fadeIn.shape,
7749 fadeIn.end - fadeIn.start,
7750 data.resolution
7751 ),
7752 }),
7753 ]
7754 )
7755 );
7756 }
7757
7758 if (this.fadeOut) {
7759 const fadeOut = this.fades[this.fadeOut];
7760 const fadeWidth = secondsToPixels(
7761 fadeOut.end - fadeOut.start,
7762 data.resolution,
7763 data.sampleRate
7764 );
7765
7766 channelChildren.push(
7767 h_default()(
7768 "div.wp-fade.wp-fadeout",
7769 {
7770 attributes: {
7771 style: `position: absolute; height: ${data.height}px; width: ${fadeWidth}px; top: 0; right: 0; z-index: 4;`,
7772 },
7773 },
7774 [
7775 h_default()("canvas", {
7776 attributes: {
7777 width: fadeWidth,
7778 height: data.height,
7779 },
7780 hook: new render_FadeCanvasHook(
7781 fadeOut.type,
7782 fadeOut.shape,
7783 fadeOut.end - fadeOut.start,
7784 data.resolution
7785 ),
7786 }),
7787 ]
7788 )
7789 );
7790 }
7791
7792 return h_default()(
7793 `div.channel.channel-${channelNum}`,
7794 {
7795 attributes: {
7796 style: `height: ${data.height}px; width: ${width}px; top: ${
7797 channelNum * data.height
7798 }px; left: ${startX}px; position: absolute; margin: 0; padding: 0; z-index: 1;`,
7799 },
7800 },
7801 channelChildren
7802 );
7803 });
7804
7805 waveformChildren.push(channels);
7806 waveformChildren.push(this.renderOverlay(data));
7807
7808 // draw cursor selection on active track.
7809 if (data.isActive === true) {
7810 const cStartX = secondsToPixels(
7811 data.timeSelection.start,
7812 data.resolution,
7813 data.sampleRate
7814 );
7815 const cEndX = secondsToPixels(
7816 data.timeSelection.end,
7817 data.resolution,
7818 data.sampleRate
7819 );
7820 const cWidth = cEndX - cStartX + 1;
7821 const cClassName = cWidth > 1 ? ".segment" : ".point";
7822
7823 waveformChildren.push(
7824 h_default()(`div.selection${cClassName}`, {
7825 attributes: {
7826 style: `position: absolute; width: ${cWidth}px; bottom: 0; top: 0; left: ${cStartX}px; z-index: 4;`,
7827 },
7828 })
7829 );
7830 }
7831
7832 const waveform = h_default()(
7833 "div.waveform",
7834 {
7835 attributes: {
7836 style: `height: ${numChan * data.height}px; position: relative;`,
7837 },
7838 },
7839 waveformChildren
7840 );
7841
7842 const channelChildren = [];
7843 let channelMargin = 0;
7844
7845 if (data.controls.show) {
7846 channelChildren.push(this.renderControls(data));
7847 channelMargin = data.controls.width;
7848 }
7849
7850 channelChildren.push(waveform);
7851
7852 const audibleClass = data.shouldPlay ? "" : ".silent";
7853 const customClass =
7854 this.customClass === undefined ? "" : `.${this.customClass}`;
7855
7856 return h_default()(
7857 `div.channel-wrapper${audibleClass}${customClass}`,
7858 {
7859 attributes: {
7860 style: `margin-left: ${channelMargin}px; height: ${
7861 data.height * numChan
7862 }px;`,
7863 },
7864 },
7865 channelChildren
7866 );
7867 }
7868
7869 getTrackDetails() {
7870 const info = {
7871 src: this.src,
7872 start: this.startTime,
7873 end: this.endTime,
7874 name: this.name,
7875 customClass: this.customClass,
7876 cuein: this.cueIn,
7877 cueout: this.cueOut,
7878 stereoPan: this.stereoPan,
7879 gain: this.gain,
7880 };
7881
7882 if (this.fadeIn) {
7883 const fadeIn = this.fades[this.fadeIn];
7884
7885 info.fadeIn = {
7886 shape: fadeIn.shape,
7887 duration: fadeIn.end - fadeIn.start,
7888 };
7889 }
7890
7891 if (this.fadeOut) {
7892 const fadeOut = this.fades[this.fadeOut];
7893
7894 info.fadeOut = {
7895 shape: fadeOut.shape,
7896 duration: fadeOut.end - fadeOut.start,
7897 };
7898 }
7899
7900 return info;
7901 }
7902});
7903
7904;// CONCATENATED MODULE: ./src/Playout.js
7905
7906
7907/* harmony default export */ const Playout = (class {
7908 constructor(ac, buffer) {
7909 this.ac = ac;
7910 this.gain = 1;
7911 this.buffer = buffer;
7912 this.destination = this.ac.destination;
7913 this.ac.createStereoPanner = ac.createStereoPanner || ac.createPanner;
7914 }
7915
7916 applyFade(type, start, duration, shape = "logarithmic") {
7917 if (type === fade_maker/* FADEIN */.Y1) {
7918 (0,fade_maker/* createFadeIn */.L7)(this.fadeGain.gain, shape, start, duration);
7919 } else if (type === fade_maker/* FADEOUT */.h7) {
7920 (0,fade_maker/* createFadeOut */.Mt)(this.fadeGain.gain, shape, start, duration);
7921 } else {
7922 throw new Error("Unsupported fade type");
7923 }
7924 }
7925
7926 applyFadeIn(start, duration, shape = "logarithmic") {
7927 this.applyFade(fade_maker/* FADEIN */.Y1, start, duration, shape);
7928 }
7929
7930 applyFadeOut(start, duration, shape = "logarithmic") {
7931 this.applyFade(fade_maker/* FADEOUT */.h7, start, duration, shape);
7932 }
7933
7934 isPlaying() {
7935 return this.source !== undefined;
7936 }
7937
7938 getDuration() {
7939 return this.buffer.duration;
7940 }
7941
7942 setAudioContext(ac) {
7943 this.ac = ac;
7944 this.ac.createStereoPanner = ac.createStereoPanner || ac.createPanner;
7945 this.destination = this.ac.destination;
7946 }
7947
7948 setUpSource() {
7949 this.source = this.ac.createBufferSource();
7950 this.source.buffer = this.buffer;
7951
7952 const sourcePromise = new Promise((resolve) => {
7953 // keep track of the buffer state.
7954 this.source.onended = () => {
7955 this.source.disconnect();
7956 this.fadeGain.disconnect();
7957 this.volumeGain.disconnect();
7958 this.shouldPlayGain.disconnect();
7959 this.panner.disconnect();
7960 this.masterGain.disconnect();
7961
7962 this.source = undefined;
7963 this.fadeGain = undefined;
7964 this.volumeGain = undefined;
7965 this.shouldPlayGain = undefined;
7966 this.panner = undefined;
7967 this.masterGain = undefined;
7968
7969 resolve();
7970 };
7971 });
7972
7973 this.fadeGain = this.ac.createGain();
7974 // used for track volume slider
7975 this.volumeGain = this.ac.createGain();
7976 // used for solo/mute
7977 this.shouldPlayGain = this.ac.createGain();
7978 this.masterGain = this.ac.createGain();
7979
7980 this.panner = this.ac.createStereoPanner();
7981
7982 this.source.connect(this.fadeGain);
7983 this.fadeGain.connect(this.volumeGain);
7984 this.volumeGain.connect(this.shouldPlayGain);
7985 this.shouldPlayGain.connect(this.masterGain);
7986 this.masterGain.connect(this.panner);
7987 this.panner.connect(this.destination);
7988
7989 return sourcePromise;
7990 }
7991
7992 setVolumeGainLevel(level) {
7993 if (this.volumeGain) {
7994 this.volumeGain.gain.value = level;
7995 }
7996 }
7997
7998 setShouldPlay(bool) {
7999 if (this.shouldPlayGain) {
8000 this.shouldPlayGain.gain.value = bool ? 1 : 0;
8001 }
8002 }
8003
8004 setMasterGainLevel(level) {
8005 if (this.masterGain) {
8006 this.masterGain.gain.value = level;
8007 }
8008 }
8009
8010 setStereoPanValue(value) {
8011 const pan = value === undefined ? 0 : value;
8012
8013 if (this.panner) {
8014 if (this.panner.pan !== undefined) {
8015 this.panner.pan.value = pan;
8016 } else {
8017 this.panner.panningModel = "equalpower";
8018 this.panner.setPosition(pan, 0, 1 - Math.abs(pan));
8019 }
8020 }
8021 }
8022
8023 /*
8024 source.start is picky when passing the end time.
8025 If rounding error causes a number to make the source think
8026 it is playing slightly more samples than it has it won't play at all.
8027 Unfortunately it doesn't seem to work if you just give it a start time.
8028 */
8029 play(when, start, duration) {
8030 this.source.start(when, start, duration);
8031 }
8032
8033 stop(when = 0) {
8034 if (this.source) {
8035 this.source.stop(when);
8036 }
8037 }
8038});
8039
8040;// CONCATENATED MODULE: ./src/annotation/input/aeneas.js
8041/*
8042{
8043 "begin": "5.759",
8044 "end": "9.155",
8045 "id": "002",
8046 "language": "en",
8047 "lines": [
8048 "I just wanted to hold"
8049 ]
8050},
8051 */
8052
8053
8054
8055/* harmony default export */ function aeneas(aeneas) {
8056 const annotation = {
8057 id: aeneas.id || esm_browser_v4(),
8058 start: Number(aeneas.begin) || 0,
8059 end: Number(aeneas.end) || 0,
8060 lines: aeneas.lines || [""],
8061 lang: aeneas.language || "en",
8062 };
8063
8064 return annotation;
8065}
8066
8067;// CONCATENATED MODULE: ./src/annotation/output/aeneas.js
8068/*
8069{
8070 "begin": "5.759",
8071 "end": "9.155",
8072 "id": "002",
8073 "language": "en",
8074 "lines": [
8075 "I just wanted to hold"
8076 ]
8077},
8078 */
8079
8080/* harmony default export */ function output_aeneas(annotation) {
8081 return {
8082 begin: String(annotation.start.toFixed(3)),
8083 end: String(annotation.end.toFixed(3)),
8084 id: String(annotation.id),
8085 language: annotation.lang,
8086 lines: annotation.lines,
8087 };
8088}
8089
8090;// CONCATENATED MODULE: ./src/interaction/DragInteraction.js
8091
8092
8093/* harmony default export */ const DragInteraction = (class {
8094 constructor(playlist, data = {}) {
8095 this.playlist = playlist;
8096 this.data = data;
8097 this.active = false;
8098
8099 this.ondragover = (e) => {
8100 if (this.active) {
8101 e.preventDefault();
8102 this.emitDrag(e.clientX);
8103 }
8104 };
8105 }
8106
8107 emitDrag(x) {
8108 const deltaX = x - this.prevX;
8109
8110 // emit shift event if not 0
8111 if (deltaX) {
8112 const deltaTime = pixelsToSeconds(
8113 deltaX,
8114 this.playlist.samplesPerPixel,
8115 this.playlist.sampleRate
8116 );
8117 this.prevX = x;
8118 this.playlist.ee.emit("dragged", deltaTime, this.data);
8119 }
8120 }
8121
8122 complete() {
8123 this.active = false;
8124 document.removeEventListener("dragover", this.ondragover);
8125 }
8126
8127 dragstart(e) {
8128 const ev = e;
8129 this.active = true;
8130 this.prevX = e.clientX;
8131
8132 ev.dataTransfer.dropEffect = "move";
8133 ev.dataTransfer.effectAllowed = "move";
8134 ev.dataTransfer.setData("text/plain", "");
8135 document.addEventListener("dragover", this.ondragover);
8136 }
8137
8138 dragend(e) {
8139 if (this.active) {
8140 e.preventDefault();
8141 this.complete();
8142 }
8143 }
8144
8145 static getClass() {
8146 return ".shift";
8147 }
8148
8149 static getEvents() {
8150 return ["dragstart", "dragend"];
8151 }
8152});
8153
8154;// CONCATENATED MODULE: ./src/annotation/render/ScrollTopHook.js
8155/*
8156 * virtual-dom hook for scrolling to the text annotation.
8157 */
8158const Hook = function ScrollTopHook() {};
8159Hook.prototype.hook = function hook(node) {
8160 const el = node.querySelector(".current");
8161 if (el) {
8162 const box = node.getBoundingClientRect();
8163 const row = el.getBoundingClientRect();
8164 const diff = row.top - box.top;
8165 const list = node;
8166 list.scrollTop += diff;
8167 }
8168};
8169
8170/* harmony default export */ const ScrollTopHook = (Hook);
8171
8172;// CONCATENATED MODULE: ./src/utils/timeformat.js
8173/* harmony default export */ function timeformat(format) {
8174 function clockFormat(seconds, decimals) {
8175 const hours = parseInt(seconds / 3600, 10) % 24;
8176 const minutes = parseInt(seconds / 60, 10) % 60;
8177 const secs = (seconds % 60).toFixed(decimals);
8178
8179 const sHours = hours < 10 ? `0${hours}` : hours;
8180 const sMinutes = minutes < 10 ? `0${minutes}` : minutes;
8181 const sSeconds = secs < 10 ? `0${secs}` : secs;
8182
8183 return `${sHours}:${sMinutes}:${sSeconds}`;
8184 }
8185
8186 const formats = {
8187 seconds(seconds) {
8188 return seconds.toFixed(0);
8189 },
8190 thousandths(seconds) {
8191 return seconds.toFixed(3);
8192 },
8193 "hh:mm:ss": function hhmmss(seconds) {
8194 return clockFormat(seconds, 0);
8195 },
8196 "hh:mm:ss.u": function hhmmssu(seconds) {
8197 return clockFormat(seconds, 1);
8198 },
8199 "hh:mm:ss.uu": function hhmmssuu(seconds) {
8200 return clockFormat(seconds, 2);
8201 },
8202 "hh:mm:ss.uuu": function hhmmssuuu(seconds) {
8203 return clockFormat(seconds, 3);
8204 },
8205 };
8206
8207 return formats[format];
8208}
8209
8210;// CONCATENATED MODULE: ./src/annotation/AnnotationList.js
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220class AnnotationList {
8221 constructor(
8222 playlist,
8223 annotations,
8224 controls = [],
8225 editable = false,
8226 linkEndpoints = false,
8227 isContinuousPlay = false,
8228 marginLeft = 0
8229 ) {
8230 this.playlist = playlist;
8231 this.marginLeft = marginLeft;
8232 this.resizeHandlers = [];
8233 this.editable = editable;
8234 this.annotations = annotations.map((a) =>
8235 // TODO support different formats later on.
8236 aeneas(a)
8237 );
8238 this.setupInteractions();
8239
8240 this.controls = controls;
8241 this.setupEE(playlist.ee);
8242
8243 // TODO actually make a real plugin system that's not terrible.
8244 this.playlist.isContinuousPlay = isContinuousPlay;
8245 this.playlist.linkEndpoints = linkEndpoints;
8246 this.length = this.annotations.length;
8247 }
8248
8249 setupInteractions() {
8250 this.annotations.forEach((a, i) => {
8251 const leftShift = new DragInteraction(this.playlist, {
8252 direction: "left",
8253 index: i,
8254 });
8255 const rightShift = new DragInteraction(this.playlist, {
8256 direction: "right",
8257 index: i,
8258 });
8259
8260 this.resizeHandlers.push(leftShift);
8261 this.resizeHandlers.push(rightShift);
8262 });
8263 }
8264
8265 setupEE(ee) {
8266 ee.on("dragged", (deltaTime, data) => {
8267 const annotationIndex = data.index;
8268 const annotations = this.annotations;
8269 const note = annotations[annotationIndex];
8270
8271 // resizing to the left
8272 if (data.direction === "left") {
8273 const originalVal = note.start;
8274 note.start += deltaTime;
8275
8276 if (note.start < 0) {
8277 note.start = 0;
8278 }
8279
8280 if (
8281 annotationIndex &&
8282 annotations[annotationIndex - 1].end > note.start
8283 ) {
8284 annotations[annotationIndex - 1].end = note.start;
8285 }
8286
8287 if (
8288 this.playlist.linkEndpoints &&
8289 annotationIndex &&
8290 annotations[annotationIndex - 1].end === originalVal
8291 ) {
8292 annotations[annotationIndex - 1].end = note.start;
8293 }
8294 } else {
8295 // resizing to the right
8296 const originalVal = note.end;
8297 note.end += deltaTime;
8298
8299 if (note.end > this.playlist.duration) {
8300 note.end = this.playlist.duration;
8301 }
8302
8303 if (
8304 annotationIndex < annotations.length - 1 &&
8305 annotations[annotationIndex + 1].start < note.end
8306 ) {
8307 annotations[annotationIndex + 1].start = note.end;
8308 }
8309
8310 if (
8311 this.playlist.linkEndpoints &&
8312 annotationIndex < annotations.length - 1 &&
8313 annotations[annotationIndex + 1].start === originalVal
8314 ) {
8315 annotations[annotationIndex + 1].start = note.end;
8316 }
8317 }
8318
8319 this.playlist.drawRequest();
8320 });
8321
8322 ee.on("continuousplay", (val) => {
8323 this.playlist.isContinuousPlay = val;
8324 });
8325
8326 ee.on("linkendpoints", (val) => {
8327 this.playlist.linkEndpoints = val;
8328 });
8329
8330 ee.on("annotationsrequest", () => {
8331 this.export();
8332 });
8333
8334 return ee;
8335 }
8336
8337 export() {
8338 const output = this.annotations.map((a) => output_aeneas(a));
8339 const dataStr = `data:text/json;charset=utf-8,${encodeURIComponent(
8340 JSON.stringify(output)
8341 )}`;
8342 const a = document.createElement("a");
8343
8344 document.body.appendChild(a);
8345 a.href = dataStr;
8346 a.download = "annotations.json";
8347 a.click();
8348 document.body.removeChild(a);
8349 }
8350
8351 renderResizeLeft(i) {
8352 const events = DragInteraction.getEvents();
8353 const config = {
8354 attributes: {
8355 style:
8356 "position: absolute; height: 30px; width: 10px; top: 0; left: -2px",
8357 draggable: true,
8358 },
8359 };
8360 const handler = this.resizeHandlers[i * 2];
8361
8362 events.forEach((event) => {
8363 config[`on${event}`] = handler[event].bind(handler);
8364 });
8365
8366 return h_default()("div.resize-handle.resize-w", config);
8367 }
8368
8369 renderResizeRight(i) {
8370 const events = DragInteraction.getEvents();
8371 const config = {
8372 attributes: {
8373 style:
8374 "position: absolute; height: 30px; width: 10px; top: 0; right: -2px",
8375 draggable: true,
8376 },
8377 };
8378 const handler = this.resizeHandlers[i * 2 + 1];
8379
8380 events.forEach((event) => {
8381 config[`on${event}`] = handler[event].bind(handler);
8382 });
8383
8384 return h_default()("div.resize-handle.resize-e", config);
8385 }
8386
8387 renderControls(note, i) {
8388 // seems to be a bug with references, or I'm missing something.
8389 const that = this;
8390 return this.controls.map((ctrl) =>
8391 h_default()(`i.${ctrl.class}`, {
8392 attributes: {
8393 title: ctrl.title,
8394 },
8395 onclick: () => {
8396 ctrl.action(note, i, that.annotations, {
8397 linkEndpoints: that.playlist.linkEndpoints,
8398 });
8399 this.setupInteractions();
8400 that.playlist.drawRequest();
8401 },
8402 })
8403 );
8404 }
8405
8406 render() {
8407 const boxes = h_default()(
8408 "div.annotations-boxes",
8409 {
8410 attributes: {
8411 style: `height: 30px; position: relative; margin-left: ${this.marginLeft}px;`,
8412 },
8413 },
8414 this.annotations.map((note, i) => {
8415 const samplesPerPixel = this.playlist.samplesPerPixel;
8416 const sampleRate = this.playlist.sampleRate;
8417 const pixPerSec = sampleRate / samplesPerPixel;
8418 const pixOffset = secondsToPixels(
8419 this.playlist.scrollLeft,
8420 samplesPerPixel,
8421 sampleRate
8422 );
8423 const left = Math.floor(note.start * pixPerSec - pixOffset);
8424 const width = Math.ceil(note.end * pixPerSec - note.start * pixPerSec);
8425
8426 return h_default()(
8427 "div.annotation-box",
8428 {
8429 attributes: {
8430 style: `position: absolute; height: 30px; width: ${width}px; left: ${left}px`,
8431 "data-id": note.id,
8432 },
8433 },
8434 [
8435 this.renderResizeLeft(i),
8436 h_default()(
8437 "span.id",
8438 {
8439 onclick: () => {
8440 const start = this.annotations[i].start;
8441 const end = this.annotations[i].end;
8442
8443 if (this.playlist.isContinuousPlay) {
8444 this.playlist.seek(start, start);
8445 this.playlist.ee.emit("play", start);
8446 } else {
8447 this.playlist.seek(start, end);
8448 this.playlist.ee.emit("play", start, end);
8449 }
8450 },
8451 },
8452 [note.id]
8453 ),
8454 this.renderResizeRight(i),
8455 ]
8456 );
8457 })
8458 );
8459
8460 const boxesWrapper = h_default()(
8461 "div.annotations-boxes-wrapper",
8462 {
8463 attributes: {
8464 style: "overflow: hidden;",
8465 },
8466 },
8467 [boxes]
8468 );
8469
8470 const text = h_default()(
8471 "div.annotations-text",
8472 {
8473 hook: new ScrollTopHook(),
8474 },
8475 this.annotations.map((note, i) => {
8476 const format = timeformat(this.playlist.durationFormat);
8477 const start = format(note.start);
8478 const end = format(note.end);
8479
8480 let segmentClass = "";
8481 if (
8482 this.playlist.isPlaying() &&
8483 this.playlist.playbackSeconds >= note.start &&
8484 this.playlist.playbackSeconds <= note.end
8485 ) {
8486 segmentClass = ".current";
8487 }
8488
8489 const editableConfig = {
8490 attributes: {
8491 contenteditable: true,
8492 },
8493 oninput: (e) => {
8494 // needed currently for references
8495 // eslint-disable-next-line no-param-reassign
8496 note.lines = [e.target.innerText];
8497 },
8498 onkeypress: (e) => {
8499 if (e.which === 13 || e.keyCode === 13) {
8500 e.target.blur();
8501 e.preventDefault();
8502 }
8503 },
8504 };
8505
8506 const linesConfig = this.editable ? editableConfig : {};
8507
8508 return h_default()(`div.annotation${segmentClass}`, [
8509 h_default()("span.annotation-id", [note.id]),
8510 h_default()("span.annotation-start", [start]),
8511 h_default()("span.annotation-end", [end]),
8512 h_default()("span.annotation-lines", linesConfig, [note.lines]),
8513 h_default()("span.annotation-actions", this.renderControls(note, i)),
8514 ]);
8515 })
8516 );
8517
8518 return h_default()("div.annotations", [boxesWrapper, text]);
8519 }
8520}
8521
8522/* harmony default export */ const annotation_AnnotationList = (AnnotationList);
8523
8524;// CONCATENATED MODULE: ./src/utils/recorderWorker.js
8525/* harmony default export */ function recorderWorker() {
8526 // http://jsperf.com/typed-array-min-max/2
8527 // plain for loop for finding min/max is way faster than anything else.
8528 /**
8529 * @param {TypedArray} array - Subarray of audio to calculate peaks from.
8530 */
8531 function findMinMax(array) {
8532 let min = Infinity;
8533 let max = -Infinity;
8534 let curr;
8535
8536 for (let i = 0; i < array.length; i += 1) {
8537 curr = array[i];
8538 if (min > curr) {
8539 min = curr;
8540 }
8541 if (max < curr) {
8542 max = curr;
8543 }
8544 }
8545
8546 return {
8547 min,
8548 max,
8549 };
8550 }
8551
8552 /**
8553 * @param {Number} n - peak to convert from float to Int8, Int16 etc.
8554 * @param {Number} bits - convert to #bits two's complement signed integer
8555 */
8556 function convert(n, bits) {
8557 const max = 2 ** (bits - 1);
8558 const v = n < 0 ? n * max : n * max - 1;
8559 return Math.max(-max, Math.min(max - 1, v));
8560 }
8561
8562 /**
8563 * @param {TypedArray} channel - Audio track frames to calculate peaks from.
8564 * @param {Number} samplesPerPixel - Audio frames per peak
8565 */
8566 function extractPeaks(channel, samplesPerPixel, bits) {
8567 const chanLength = channel.length;
8568 const numPeaks = Math.ceil(chanLength / samplesPerPixel);
8569 let start;
8570 let end;
8571 let segment;
8572 let max;
8573 let min;
8574 let extrema;
8575
8576 // create interleaved array of min,max
8577 const peaks = new self[`Int${bits}Array`](numPeaks * 2);
8578
8579 for (let i = 0; i < numPeaks; i += 1) {
8580 start = i * samplesPerPixel;
8581 end =
8582 (i + 1) * samplesPerPixel > chanLength
8583 ? chanLength
8584 : (i + 1) * samplesPerPixel;
8585
8586 segment = channel.subarray(start, end);
8587 extrema = findMinMax(segment);
8588 min = convert(extrema.min, bits);
8589 max = convert(extrema.max, bits);
8590
8591 peaks[i * 2] = min;
8592 peaks[i * 2 + 1] = max;
8593 }
8594
8595 return peaks;
8596 }
8597
8598 /**
8599 * @param {TypedArray} source - Source of audio samples for peak calculations.
8600 * @param {Number} samplesPerPixel - Number of audio samples per peak.
8601 * @param {Number} cueIn - index in channel to start peak calculations from.
8602 * @param {Number} cueOut - index in channel to end peak calculations from (non-inclusive).
8603 */
8604 function audioPeaks(source, samplesPerPixel = 10000, bits = 8) {
8605 if ([8, 16, 32].indexOf(bits) < 0) {
8606 throw new Error("Invalid number of bits specified for peaks.");
8607 }
8608
8609 const peaks = [];
8610 const start = 0;
8611 const end = source.length;
8612 peaks.push(
8613 extractPeaks(source.subarray(start, end), samplesPerPixel, bits)
8614 );
8615
8616 const length = peaks[0].length / 2;
8617
8618 return {
8619 bits,
8620 length,
8621 data: peaks,
8622 };
8623 }
8624
8625 onmessage = function onmessage(e) {
8626 const peaks = audioPeaks(e.data.samples, e.data.samplesPerPixel);
8627
8628 postMessage(peaks);
8629 };
8630}
8631
8632;// CONCATENATED MODULE: ./src/utils/exportWavWorker.js
8633/* harmony default export */ function exportWavWorker() {
8634 let recLength = 0;
8635 let recBuffersL = [];
8636 let recBuffersR = [];
8637 let sampleRate;
8638
8639 function init(config) {
8640 sampleRate = config.sampleRate;
8641 }
8642
8643 function record(inputBuffer) {
8644 recBuffersL.push(inputBuffer[0]);
8645 recBuffersR.push(inputBuffer[1]);
8646 recLength += inputBuffer[0].length;
8647 }
8648
8649 function writeString(view, offset, string) {
8650 for (let i = 0; i < string.length; i += 1) {
8651 view.setUint8(offset + i, string.charCodeAt(i));
8652 }
8653 }
8654
8655 function floatTo16BitPCM(output, offset, input) {
8656 let writeOffset = offset;
8657 for (let i = 0; i < input.length; i += 1, writeOffset += 2) {
8658 const s = Math.max(-1, Math.min(1, input[i]));
8659 output.setInt16(writeOffset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
8660 }
8661 }
8662
8663 function encodeWAV(samples, mono = false) {
8664 const buffer = new ArrayBuffer(44 + samples.length * 2);
8665 const view = new DataView(buffer);
8666
8667 /* RIFF identifier */
8668 writeString(view, 0, "RIFF");
8669 /* file length */
8670 view.setUint32(4, 32 + samples.length * 2, true);
8671 /* RIFF type */
8672 writeString(view, 8, "WAVE");
8673 /* format chunk identifier */
8674 writeString(view, 12, "fmt ");
8675 /* format chunk length */
8676 view.setUint32(16, 16, true);
8677 /* sample format (raw) */
8678 view.setUint16(20, 1, true);
8679 /* channel count */
8680 view.setUint16(22, mono ? 1 : 2, true);
8681 /* sample rate */
8682 view.setUint32(24, sampleRate, true);
8683 /* byte rate (sample rate * block align) */
8684 view.setUint32(28, sampleRate * 4, true);
8685 /* block align (channel count * bytes per sample) */
8686 view.setUint16(32, 4, true);
8687 /* bits per sample */
8688 view.setUint16(34, 16, true);
8689 /* data chunk identifier */
8690 writeString(view, 36, "data");
8691 /* data chunk length */
8692 view.setUint32(40, samples.length * 2, true);
8693
8694 floatTo16BitPCM(view, 44, samples);
8695
8696 return view;
8697 }
8698
8699 function mergeBuffers(recBuffers, length) {
8700 const result = new Float32Array(length);
8701 let offset = 0;
8702
8703 for (let i = 0; i < recBuffers.length; i += 1) {
8704 result.set(recBuffers[i], offset);
8705 offset += recBuffers[i].length;
8706 }
8707 return result;
8708 }
8709
8710 function interleave(inputL, inputR) {
8711 const length = inputL.length + inputR.length;
8712 const result = new Float32Array(length);
8713
8714 let index = 0;
8715 let inputIndex = 0;
8716
8717 while (index < length) {
8718 result[(index += 1)] = inputL[inputIndex];
8719 result[(index += 1)] = inputR[inputIndex];
8720 inputIndex += 1;
8721 }
8722
8723 return result;
8724 }
8725
8726 function exportWAV(type) {
8727 const bufferL = mergeBuffers(recBuffersL, recLength);
8728 const bufferR = mergeBuffers(recBuffersR, recLength);
8729 const interleaved = interleave(bufferL, bufferR);
8730 const dataview = encodeWAV(interleaved);
8731 const audioBlob = new Blob([dataview], { type });
8732
8733 postMessage(audioBlob);
8734 }
8735
8736 function clear() {
8737 recLength = 0;
8738 recBuffersL = [];
8739 recBuffersR = [];
8740 }
8741
8742 onmessage = function onmessage(e) {
8743 switch (e.data.command) {
8744 case "init": {
8745 init(e.data.config);
8746 break;
8747 }
8748 case "record": {
8749 record(e.data.buffer);
8750 break;
8751 }
8752 case "exportWAV": {
8753 exportWAV(e.data.type);
8754 break;
8755 }
8756 case "clear": {
8757 clear();
8758 break;
8759 }
8760 default: {
8761 throw new Error("Unknown export worker command");
8762 }
8763 }
8764 };
8765}
8766
8767;// CONCATENATED MODULE: ./src/Playlist.js
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786/* harmony default export */ const Playlist = (class {
8787 constructor() {
8788 this.tracks = [];
8789 this.soloedTracks = [];
8790 this.mutedTracks = [];
8791 this.collapsedTracks = [];
8792 this.playoutPromises = [];
8793
8794 this.cursor = 0;
8795 this.playbackSeconds = 0;
8796 this.duration = 0;
8797 this.scrollLeft = 0;
8798 this.scrollTimer = undefined;
8799 this.showTimescale = false;
8800 // whether a user is scrolling the waveform
8801 this.isScrolling = false;
8802
8803 this.fadeType = "logarithmic";
8804 this.masterGain = 1;
8805 this.annotations = [];
8806 this.durationFormat = "hh:mm:ss.uuu";
8807 this.isAutomaticScroll = false;
8808 this.resetDrawTimer = undefined;
8809 }
8810
8811 // TODO extract into a plugin
8812 initExporter() {
8813 this.exportWorker = new (inline_worker_default())(exportWavWorker);
8814 }
8815
8816 // TODO extract into a plugin
8817 initRecorder(stream) {
8818 this.mediaRecorder = new MediaRecorder(stream);
8819
8820 this.mediaRecorder.onstart = () => {
8821 const track = new Track();
8822 track.setName("Recording");
8823 track.setEnabledStates();
8824 track.setEventEmitter(this.ee);
8825
8826 this.recordingTrack = track;
8827 this.tracks.push(track);
8828
8829 this.chunks = [];
8830 this.working = false;
8831 };
8832
8833 this.mediaRecorder.ondataavailable = (e) => {
8834 this.chunks.push(e.data);
8835
8836 // throttle peaks calculation
8837 if (!this.working) {
8838 const recording = new Blob(this.chunks, {
8839 type: "audio/ogg; codecs=opus",
8840 });
8841 const loader = LoaderFactory.createLoader(recording, this.ac);
8842 loader
8843 .load()
8844 .then((audioBuffer) => {
8845 // ask web worker for peaks.
8846 this.recorderWorker.postMessage({
8847 samples: audioBuffer.getChannelData(0),
8848 samplesPerPixel: this.samplesPerPixel,
8849 });
8850 this.recordingTrack.setCues(0, audioBuffer.duration);
8851 this.recordingTrack.setBuffer(audioBuffer);
8852 this.recordingTrack.setPlayout(new Playout(this.ac, audioBuffer));
8853 this.adjustDuration();
8854 })
8855 .catch(() => {
8856 this.working = false;
8857 });
8858 this.working = true;
8859 }
8860 };
8861
8862 this.mediaRecorder.onstop = () => {
8863 this.chunks = [];
8864 this.working = false;
8865 };
8866
8867 this.recorderWorker = new (inline_worker_default())(recorderWorker);
8868 // use a worker for calculating recording peaks.
8869 this.recorderWorker.onmessage = (e) => {
8870 this.recordingTrack.setPeaks(e.data);
8871 this.working = false;
8872 this.drawRequest();
8873 };
8874 }
8875
8876 setShowTimeScale(show) {
8877 this.showTimescale = show;
8878 }
8879
8880 setMono(mono) {
8881 this.mono = mono;
8882 }
8883
8884 setExclSolo(exclSolo) {
8885 this.exclSolo = exclSolo;
8886 }
8887
8888 setSeekStyle(style) {
8889 this.seekStyle = style;
8890 }
8891
8892 getSeekStyle() {
8893 return this.seekStyle;
8894 }
8895
8896 setSampleRate(sampleRate) {
8897 this.sampleRate = sampleRate;
8898 }
8899
8900 setSamplesPerPixel(samplesPerPixel) {
8901 this.samplesPerPixel = samplesPerPixel;
8902 }
8903
8904 setAudioContext(ac) {
8905 this.ac = ac;
8906 }
8907
8908 setControlOptions(controlOptions) {
8909 this.controls = controlOptions;
8910 }
8911
8912 setWaveHeight(height) {
8913 this.waveHeight = height;
8914 }
8915
8916 setCollapsedWaveHeight(height) {
8917 this.collapsedWaveHeight = height;
8918 }
8919
8920 setColors(colors) {
8921 this.colors = colors;
8922 }
8923
8924 setBarWidth(width) {
8925 this.barWidth = width;
8926 }
8927
8928 setBarGap(width) {
8929 this.barGap = width;
8930 }
8931
8932 setAnnotations(config) {
8933 const controlWidth = this.controls.show ? this.controls.width : 0;
8934 this.annotationList = new annotation_AnnotationList(
8935 this,
8936 config.annotations,
8937 config.controls,
8938 config.editable,
8939 config.linkEndpoints,
8940 config.isContinuousPlay,
8941 controlWidth
8942 );
8943 }
8944
8945 setEventEmitter(ee) {
8946 this.ee = ee;
8947 }
8948
8949 getEventEmitter() {
8950 return this.ee;
8951 }
8952
8953 setUpEventEmitter() {
8954 const ee = this.ee;
8955
8956 ee.on("automaticscroll", (val) => {
8957 this.isAutomaticScroll = val;
8958 });
8959
8960 ee.on("durationformat", (format) => {
8961 this.durationFormat = format;
8962 this.drawRequest();
8963 });
8964
8965 ee.on("select", (start, end, track) => {
8966 if (this.isPlaying()) {
8967 this.lastSeeked = start;
8968 this.pausedAt = undefined;
8969 this.restartPlayFrom(start);
8970 } else {
8971 // reset if it was paused.
8972 this.seek(start, end, track);
8973 this.ee.emit("timeupdate", start);
8974 this.drawRequest();
8975 }
8976 });
8977
8978 ee.on("startaudiorendering", (type) => {
8979 this.startOfflineRender(type);
8980 });
8981
8982 ee.on("statechange", (state) => {
8983 this.setState(state);
8984 this.drawRequest();
8985 });
8986
8987 ee.on("shift", (deltaTime, track) => {
8988 track.setStartTime(track.getStartTime() + deltaTime);
8989 this.adjustDuration();
8990 this.drawRequest();
8991 });
8992
8993 ee.on("record", () => {
8994 this.record();
8995 });
8996
8997 ee.on("play", (start, end) => {
8998 this.play(start, end);
8999 });
9000
9001 ee.on("pause", () => {
9002 this.pause();
9003 });
9004
9005 ee.on("stop", () => {
9006 this.stop();
9007 });
9008
9009 ee.on("rewind", () => {
9010 this.rewind();
9011 });
9012
9013 ee.on("fastforward", () => {
9014 this.fastForward();
9015 });
9016
9017 ee.on("clear", () => {
9018 this.clear().then(() => {
9019 this.drawRequest();
9020 });
9021 });
9022
9023 ee.on("solo", (track) => {
9024 this.soloTrack(track);
9025 this.adjustTrackPlayout();
9026 this.drawRequest();
9027 });
9028
9029 ee.on("mute", (track) => {
9030 this.muteTrack(track);
9031 this.adjustTrackPlayout();
9032 this.drawRequest();
9033 });
9034
9035 ee.on("removeTrack", (track) => {
9036 this.removeTrack(track);
9037 this.adjustTrackPlayout();
9038 this.drawRequest();
9039 });
9040
9041 ee.on("changeTrackView", (track, opts) => {
9042 this.collapseTrack(track, opts);
9043 this.drawRequest();
9044 });
9045
9046 ee.on("volumechange", (volume, track) => {
9047 track.setGainLevel(volume / 100);
9048 this.drawRequest();
9049 });
9050
9051 ee.on("mastervolumechange", (volume) => {
9052 this.masterGain = volume / 100;
9053 this.tracks.forEach((track) => {
9054 track.setMasterGainLevel(this.masterGain);
9055 });
9056 });
9057
9058 ee.on("fadein", (duration, track) => {
9059 track.setFadeIn(duration, this.fadeType);
9060 this.drawRequest();
9061 });
9062
9063 ee.on("fadeout", (duration, track) => {
9064 track.setFadeOut(duration, this.fadeType);
9065 this.drawRequest();
9066 });
9067
9068 ee.on("stereopan", (panvalue, track) => {
9069 track.setStereoPanValue(panvalue);
9070 this.drawRequest();
9071 });
9072
9073 ee.on("fadetype", (type) => {
9074 this.fadeType = type;
9075 });
9076
9077 ee.on("newtrack", (file) => {
9078 this.load([
9079 {
9080 src: file,
9081 name: file.name,
9082 },
9083 ]);
9084 });
9085
9086 ee.on("trim", () => {
9087 const track = this.getActiveTrack();
9088 const timeSelection = this.getTimeSelection();
9089
9090 track.trim(timeSelection.start, timeSelection.end);
9091 track.calculatePeaks(this.samplesPerPixel, this.sampleRate);
9092
9093 this.setTimeSelection(0, 0);
9094 this.drawRequest();
9095 });
9096
9097 ee.on("zoomin", () => {
9098 const zoomIndex = Math.max(0, this.zoomIndex - 1);
9099 const zoom = this.zoomLevels[zoomIndex];
9100
9101 if (zoom !== this.samplesPerPixel) {
9102 this.setZoom(zoom);
9103 this.drawRequest();
9104 }
9105 });
9106
9107 ee.on("zoomout", () => {
9108 const zoomIndex = Math.min(
9109 this.zoomLevels.length - 1,
9110 this.zoomIndex + 1
9111 );
9112 const zoom = this.zoomLevels[zoomIndex];
9113
9114 if (zoom !== this.samplesPerPixel) {
9115 this.setZoom(zoom);
9116 this.drawRequest();
9117 }
9118 });
9119
9120 ee.on("scroll", () => {
9121 this.isScrolling = true;
9122 this.drawRequest();
9123 clearTimeout(this.scrollTimer);
9124 this.scrollTimer = setTimeout(() => {
9125 this.isScrolling = false;
9126 }, 200);
9127 });
9128 }
9129
9130 load(trackList) {
9131 const loadPromises = trackList.map((trackInfo) => {
9132 const loader = LoaderFactory.createLoader(
9133 trackInfo.src,
9134 this.ac,
9135 this.ee
9136 );
9137 return loader.load();
9138 });
9139
9140 return Promise.all(loadPromises)
9141 .then((audioBuffers) => {
9142 this.ee.emit("audiosourcesloaded");
9143
9144 const tracks = audioBuffers.map((audioBuffer, index) => {
9145 const info = trackList[index];
9146 const name = info.name || "Untitled";
9147 const start = info.start || 0;
9148 const states = info.states || {};
9149 const fadeIn = info.fadeIn;
9150 const fadeOut = info.fadeOut;
9151 const cueIn = info.cuein || 0;
9152 const cueOut = info.cueout || audioBuffer.duration;
9153 const gain = info.gain || 1;
9154 const muted = info.muted || false;
9155 const soloed = info.soloed || false;
9156 const selection = info.selected;
9157 const peaks = info.peaks || { type: "WebAudio", mono: this.mono };
9158 const customClass = info.customClass || undefined;
9159 const waveOutlineColor = info.waveOutlineColor || undefined;
9160 const stereoPan = info.stereoPan || 0;
9161
9162 // webaudio specific playout for now.
9163 const playout = new Playout(this.ac, audioBuffer);
9164
9165 const track = new Track();
9166 track.src = info.src;
9167 track.setBuffer(audioBuffer);
9168 track.setName(name);
9169 track.setEventEmitter(this.ee);
9170 track.setEnabledStates(states);
9171 track.setCues(cueIn, cueOut);
9172 track.setCustomClass(customClass);
9173 track.setWaveOutlineColor(waveOutlineColor);
9174
9175 if (fadeIn !== undefined) {
9176 track.setFadeIn(fadeIn.duration, fadeIn.shape);
9177 }
9178
9179 if (fadeOut !== undefined) {
9180 track.setFadeOut(fadeOut.duration, fadeOut.shape);
9181 }
9182
9183 if (selection !== undefined) {
9184 this.setActiveTrack(track);
9185 this.setTimeSelection(selection.start, selection.end);
9186 }
9187
9188 if (peaks !== undefined) {
9189 track.setPeakData(peaks);
9190 }
9191
9192 track.setState(this.getState());
9193 track.setStartTime(start);
9194 track.setPlayout(playout);
9195
9196 track.setGainLevel(gain);
9197 track.setStereoPanValue(stereoPan);
9198
9199 if (muted) {
9200 this.muteTrack(track);
9201 }
9202
9203 if (soloed) {
9204 this.soloTrack(track);
9205 }
9206
9207 // extract peaks with AudioContext for now.
9208 track.calculatePeaks(this.samplesPerPixel, this.sampleRate);
9209
9210 return track;
9211 });
9212
9213 this.tracks = this.tracks.concat(tracks);
9214 this.adjustDuration();
9215 this.draw(this.render());
9216
9217 this.ee.emit("audiosourcesrendered");
9218 })
9219 .catch((e) => {
9220 this.ee.emit("audiosourceserror", e);
9221 });
9222 }
9223
9224 /*
9225 track instance of Track.
9226 */
9227 setActiveTrack(track) {
9228 this.activeTrack = track;
9229 }
9230
9231 getActiveTrack() {
9232 return this.activeTrack;
9233 }
9234
9235 isSegmentSelection() {
9236 return this.timeSelection.start !== this.timeSelection.end;
9237 }
9238
9239 /*
9240 start, end in seconds.
9241 */
9242 setTimeSelection(start = 0, end) {
9243 this.timeSelection = {
9244 start,
9245 end: end === undefined ? start : end,
9246 };
9247
9248 this.cursor = start;
9249 }
9250
9251 startOfflineRender(type) {
9252 if (this.isRendering) {
9253 return;
9254 }
9255
9256 this.isRendering = true;
9257 this.offlineAudioContext = new OfflineAudioContext(
9258 2,
9259 44100 * this.duration,
9260 44100
9261 );
9262
9263 const currentTime = this.offlineAudioContext.currentTime;
9264
9265 this.tracks.forEach((track) => {
9266 track.setOfflinePlayout(
9267 new Playout(this.offlineAudioContext, track.buffer)
9268 );
9269 track.schedulePlay(currentTime, 0, 0, {
9270 shouldPlay: this.shouldTrackPlay(track),
9271 masterGain: 1,
9272 isOffline: true,
9273 });
9274 });
9275
9276 /*
9277 TODO cleanup of different audio playouts handling.
9278 */
9279 this.offlineAudioContext
9280 .startRendering()
9281 .then((audioBuffer) => {
9282 if (type === "buffer") {
9283 this.ee.emit("audiorenderingfinished", type, audioBuffer);
9284 this.isRendering = false;
9285 return;
9286 }
9287
9288 if (type === "wav") {
9289 this.exportWorker.postMessage({
9290 command: "init",
9291 config: {
9292 sampleRate: 44100,
9293 },
9294 });
9295
9296 // callback for `exportWAV`
9297 this.exportWorker.onmessage = (e) => {
9298 this.ee.emit("audiorenderingfinished", type, e.data);
9299 this.isRendering = false;
9300
9301 // clear out the buffer for next renderings.
9302 this.exportWorker.postMessage({
9303 command: "clear",
9304 });
9305 };
9306
9307 // send the channel data from our buffer to the worker
9308 this.exportWorker.postMessage({
9309 command: "record",
9310 buffer: [
9311 audioBuffer.getChannelData(0),
9312 audioBuffer.getChannelData(1),
9313 ],
9314 });
9315
9316 // ask the worker for a WAV
9317 this.exportWorker.postMessage({
9318 command: "exportWAV",
9319 type: "audio/wav",
9320 });
9321 }
9322 })
9323 .catch((e) => {
9324 throw e;
9325 });
9326 }
9327
9328 getTimeSelection() {
9329 return this.timeSelection;
9330 }
9331
9332 setState(state) {
9333 this.state = state;
9334
9335 this.tracks.forEach((track) => {
9336 track.setState(state);
9337 });
9338 }
9339
9340 getState() {
9341 return this.state;
9342 }
9343
9344 setZoomIndex(index) {
9345 this.zoomIndex = index;
9346 }
9347
9348 setZoomLevels(levels) {
9349 this.zoomLevels = levels;
9350 }
9351
9352 setZoom(zoom) {
9353 this.samplesPerPixel = zoom;
9354 this.zoomIndex = this.zoomLevels.indexOf(zoom);
9355 this.tracks.forEach((track) => {
9356 track.calculatePeaks(zoom, this.sampleRate);
9357 });
9358 }
9359
9360 muteTrack(track) {
9361 const index = this.mutedTracks.indexOf(track);
9362
9363 if (index > -1) {
9364 this.mutedTracks.splice(index, 1);
9365 } else {
9366 this.mutedTracks.push(track);
9367 }
9368 }
9369
9370 soloTrack(track) {
9371 const index = this.soloedTracks.indexOf(track);
9372
9373 if (index > -1) {
9374 this.soloedTracks.splice(index, 1);
9375 } else if (this.exclSolo) {
9376 this.soloedTracks = [track];
9377 } else {
9378 this.soloedTracks.push(track);
9379 }
9380 }
9381
9382 collapseTrack(track, opts) {
9383 if (opts.collapsed) {
9384 this.collapsedTracks.push(track);
9385 } else {
9386 const index = this.collapsedTracks.indexOf(track);
9387
9388 if (index > -1) {
9389 this.collapsedTracks.splice(index, 1);
9390 }
9391 }
9392 }
9393
9394 removeTrack(track) {
9395 if (track.isPlaying()) {
9396 track.scheduleStop();
9397 }
9398
9399 const trackLists = [
9400 this.mutedTracks,
9401 this.soloedTracks,
9402 this.collapsedTracks,
9403 this.tracks,
9404 ];
9405 trackLists.forEach((list) => {
9406 const index = list.indexOf(track);
9407 if (index > -1) {
9408 list.splice(index, 1);
9409 }
9410 });
9411 }
9412
9413 adjustTrackPlayout() {
9414 this.tracks.forEach((track) => {
9415 track.setShouldPlay(this.shouldTrackPlay(track));
9416 });
9417 }
9418
9419 adjustDuration() {
9420 this.duration = this.tracks.reduce(
9421 (duration, track) => Math.max(duration, track.getEndTime()),
9422 0
9423 );
9424 }
9425
9426 shouldTrackPlay(track) {
9427 let shouldPlay;
9428 // if there are solo tracks, only they should play.
9429 if (this.soloedTracks.length > 0) {
9430 shouldPlay = false;
9431 if (this.soloedTracks.indexOf(track) > -1) {
9432 shouldPlay = true;
9433 }
9434 } else {
9435 // play all tracks except any muted tracks.
9436 shouldPlay = true;
9437 if (this.mutedTracks.indexOf(track) > -1) {
9438 shouldPlay = false;
9439 }
9440 }
9441
9442 return shouldPlay;
9443 }
9444
9445 isPlaying() {
9446 return this.tracks.reduce(
9447 (isPlaying, track) => isPlaying || track.isPlaying(),
9448 false
9449 );
9450 }
9451
9452 /*
9453 * returns the current point of time in the playlist in seconds.
9454 */
9455 getCurrentTime() {
9456 const cursorPos = this.lastSeeked || this.pausedAt || this.cursor;
9457
9458 return cursorPos + this.getElapsedTime();
9459 }
9460
9461 getElapsedTime() {
9462 return this.ac.currentTime - this.lastPlay;
9463 }
9464
9465 setMasterGain(gain) {
9466 this.ee.emit("mastervolumechange", gain);
9467 }
9468
9469 restartPlayFrom(start, end) {
9470 this.stopAnimation();
9471
9472 this.tracks.forEach((editor) => {
9473 editor.scheduleStop();
9474 });
9475
9476 return Promise.all(this.playoutPromises).then(
9477 this.play.bind(this, start, end)
9478 );
9479 }
9480
9481 play(startTime, endTime) {
9482 clearTimeout(this.resetDrawTimer);
9483
9484 const currentTime = this.ac.currentTime;
9485 const selected = this.getTimeSelection();
9486 const playoutPromises = [];
9487
9488 const start = startTime || this.pausedAt || this.cursor;
9489 let end = endTime;
9490
9491 if (!end && selected.end !== selected.start && selected.end > start) {
9492 end = selected.end;
9493 }
9494
9495 if (this.isPlaying()) {
9496 return this.restartPlayFrom(start, end);
9497 }
9498
9499 this.tracks.forEach((track) => {
9500 track.setState("cursor");
9501 playoutPromises.push(
9502 track.schedulePlay(currentTime, start, end, {
9503 shouldPlay: this.shouldTrackPlay(track),
9504 masterGain: this.masterGain,
9505 })
9506 );
9507 });
9508
9509 this.lastPlay = currentTime;
9510 // use these to track when the playlist has fully stopped.
9511 this.playoutPromises = playoutPromises;
9512 this.startAnimation(start);
9513
9514 return Promise.all(this.playoutPromises);
9515 }
9516
9517 pause() {
9518 if (!this.isPlaying()) {
9519 return Promise.all(this.playoutPromises);
9520 }
9521
9522 this.pausedAt = this.getCurrentTime();
9523 return this.playbackReset();
9524 }
9525
9526 stop() {
9527 if (this.mediaRecorder && this.mediaRecorder.state === "recording") {
9528 this.mediaRecorder.stop();
9529 }
9530
9531 this.pausedAt = undefined;
9532 this.playbackSeconds = 0;
9533 return this.playbackReset();
9534 }
9535
9536 playbackReset() {
9537 this.lastSeeked = undefined;
9538 this.stopAnimation();
9539
9540 this.tracks.forEach((track) => {
9541 track.scheduleStop();
9542 track.setState(this.getState());
9543 });
9544
9545 this.drawRequest();
9546 return Promise.all(this.playoutPromises);
9547 }
9548
9549 rewind() {
9550 return this.stop().then(() => {
9551 this.scrollLeft = 0;
9552 this.ee.emit("select", 0, 0);
9553 });
9554 }
9555
9556 fastForward() {
9557 return this.stop().then(() => {
9558 if (this.viewDuration < this.duration) {
9559 this.scrollLeft = this.duration - this.viewDuration;
9560 } else {
9561 this.scrollLeft = 0;
9562 }
9563
9564 this.ee.emit("select", this.duration, this.duration);
9565 });
9566 }
9567
9568 clear() {
9569 return this.stop().then(() => {
9570 this.tracks = [];
9571 this.soloedTracks = [];
9572 this.mutedTracks = [];
9573 this.playoutPromises = [];
9574
9575 this.cursor = 0;
9576 this.playbackSeconds = 0;
9577 this.duration = 0;
9578 this.scrollLeft = 0;
9579
9580 this.seek(0, 0, undefined);
9581 });
9582 }
9583
9584 record() {
9585 const playoutPromises = [];
9586 this.mediaRecorder.start(300);
9587
9588 this.tracks.forEach((track) => {
9589 track.setState("none");
9590 playoutPromises.push(
9591 track.schedulePlay(this.ac.currentTime, 0, undefined, {
9592 shouldPlay: this.shouldTrackPlay(track),
9593 })
9594 );
9595 });
9596
9597 this.playoutPromises = playoutPromises;
9598 }
9599
9600 startAnimation(startTime) {
9601 this.lastDraw = this.ac.currentTime;
9602 this.animationRequest = window.requestAnimationFrame(() => {
9603 this.updateEditor(startTime);
9604 });
9605 }
9606
9607 stopAnimation() {
9608 window.cancelAnimationFrame(this.animationRequest);
9609 this.lastDraw = undefined;
9610 }
9611
9612 seek(start, end, track) {
9613 if (this.isPlaying()) {
9614 this.lastSeeked = start;
9615 this.pausedAt = undefined;
9616 this.restartPlayFrom(start);
9617 } else {
9618 // reset if it was paused.
9619 this.setActiveTrack(track || this.tracks[0]);
9620 this.pausedAt = start;
9621 this.setTimeSelection(start, end);
9622 if (this.getSeekStyle() === "fill") {
9623 this.playbackSeconds = start;
9624 }
9625 }
9626 }
9627
9628 /*
9629 * Animation function for the playlist.
9630 * Keep under 16.7 milliseconds based on a typical screen refresh rate of 60fps.
9631 */
9632 updateEditor(cursor) {
9633 const currentTime = this.ac.currentTime;
9634 const selection = this.getTimeSelection();
9635 const cursorPos = cursor || this.cursor;
9636 const elapsed = currentTime - this.lastDraw;
9637
9638 if (this.isPlaying()) {
9639 const playbackSeconds = cursorPos + elapsed;
9640 this.ee.emit("timeupdate", playbackSeconds);
9641 this.animationRequest = window.requestAnimationFrame(() => {
9642 this.updateEditor(playbackSeconds);
9643 });
9644
9645 this.playbackSeconds = playbackSeconds;
9646 this.draw(this.render());
9647 this.lastDraw = currentTime;
9648 } else {
9649 if (
9650 cursorPos + elapsed >=
9651 (this.isSegmentSelection() ? selection.end : this.duration)
9652 ) {
9653 this.ee.emit("finished");
9654 }
9655
9656 this.stopAnimation();
9657
9658 this.resetDrawTimer = setTimeout(() => {
9659 this.pausedAt = undefined;
9660 this.lastSeeked = undefined;
9661 this.setState(this.getState());
9662
9663 this.playbackSeconds = 0;
9664 this.draw(this.render());
9665 }, 0);
9666 }
9667 }
9668
9669 drawRequest() {
9670 window.requestAnimationFrame(() => {
9671 this.draw(this.render());
9672 });
9673 }
9674
9675 draw(newTree) {
9676 const patches = diff_default()(this.tree, newTree);
9677 this.rootNode = patch_default()(this.rootNode, patches);
9678 this.tree = newTree;
9679
9680 // use for fast forwarding.
9681 this.viewDuration = pixelsToSeconds(
9682 this.rootNode.clientWidth - this.controls.width,
9683 this.samplesPerPixel,
9684 this.sampleRate
9685 );
9686 }
9687
9688 getTrackRenderData(data = {}) {
9689 const defaults = {
9690 height: this.waveHeight,
9691 resolution: this.samplesPerPixel,
9692 sampleRate: this.sampleRate,
9693 controls: this.controls,
9694 isActive: false,
9695 timeSelection: this.getTimeSelection(),
9696 playlistLength: this.duration,
9697 playbackSeconds: this.playbackSeconds,
9698 colors: this.colors,
9699 barWidth: this.barWidth,
9700 barGap: this.barGap,
9701 };
9702
9703 return lodash_defaultsdeep_default()({}, data, defaults);
9704 }
9705
9706 isActiveTrack(track) {
9707 const activeTrack = this.getActiveTrack();
9708
9709 if (this.isSegmentSelection()) {
9710 return activeTrack === track;
9711 }
9712
9713 return true;
9714 }
9715
9716 renderAnnotations() {
9717 return this.annotationList.render();
9718 }
9719
9720 renderTimeScale() {
9721 const controlWidth = this.controls.show ? this.controls.width : 0;
9722 const timeScale = new src_TimeScale(
9723 this.duration,
9724 this.scrollLeft,
9725 this.samplesPerPixel,
9726 this.sampleRate,
9727 controlWidth,
9728 this.colors
9729 );
9730
9731 return timeScale.render();
9732 }
9733
9734 renderTrackSection() {
9735 const trackElements = this.tracks.map((track) => {
9736 const collapsed = this.collapsedTracks.indexOf(track) > -1;
9737 return track.render(
9738 this.getTrackRenderData({
9739 isActive: this.isActiveTrack(track),
9740 shouldPlay: this.shouldTrackPlay(track),
9741 soloed: this.soloedTracks.indexOf(track) > -1,
9742 muted: this.mutedTracks.indexOf(track) > -1,
9743 collapsed,
9744 height: collapsed ? this.collapsedWaveHeight : this.waveHeight,
9745 barGap: this.barGap,
9746 barWidth: this.barWidth,
9747 })
9748 );
9749 });
9750
9751 return h_default()(
9752 "div.playlist-tracks",
9753 {
9754 attributes: {
9755 style: "overflow: auto;",
9756 },
9757 onscroll: (e) => {
9758 this.scrollLeft = pixelsToSeconds(
9759 e.target.scrollLeft,
9760 this.samplesPerPixel,
9761 this.sampleRate
9762 );
9763
9764 this.ee.emit("scroll");
9765 },
9766 hook: new ScrollHook(this),
9767 },
9768 trackElements
9769 );
9770 }
9771
9772 render() {
9773 const containerChildren = [];
9774
9775 if (this.showTimescale) {
9776 containerChildren.push(this.renderTimeScale());
9777 }
9778
9779 containerChildren.push(this.renderTrackSection());
9780
9781 if (this.annotationList.length) {
9782 containerChildren.push(this.renderAnnotations());
9783 }
9784
9785 return h_default()(
9786 "div.playlist",
9787 {
9788 attributes: {
9789 style: "overflow: hidden; position: relative;",
9790 },
9791 },
9792 containerChildren
9793 );
9794 }
9795
9796 getInfo() {
9797 const info = [];
9798
9799 this.tracks.forEach((track) => {
9800 info.push(track.getTrackDetails());
9801 });
9802
9803 return info;
9804 }
9805});
9806
9807;// CONCATENATED MODULE: ./src/app.js
9808
9809
9810
9811
9812
9813function init(options = {}, ee = event_emitter_default()()) {
9814 if (options.container === undefined) {
9815 throw new Error("DOM element container must be given.");
9816 }
9817
9818 window.OfflineAudioContext =
9819 window.OfflineAudioContext || window.webkitOfflineAudioContext;
9820 window.AudioContext = window.AudioContext || window.webkitAudioContext;
9821
9822 const audioContext = new window.AudioContext();
9823
9824 const defaults = {
9825 ac: audioContext,
9826 sampleRate: audioContext.sampleRate,
9827 samplesPerPixel: 4096,
9828 mono: true,
9829 fadeType: "logarithmic",
9830 exclSolo: false,
9831 timescale: false,
9832 controls: {
9833 show: false,
9834 width: 150,
9835 widgets: {
9836 muteOrSolo: true,
9837 volume: true,
9838 stereoPan: true,
9839 collapse: true,
9840 remove: true,
9841 },
9842 },
9843 colors: {
9844 waveOutlineColor: "white",
9845 timeColor: "grey",
9846 fadeColor: "black",
9847 },
9848 seekStyle: "line",
9849 waveHeight: 128,
9850 collapsedWaveHeight: 30,
9851 barWidth: 1,
9852 barGap: 0,
9853 state: "cursor",
9854 zoomLevels: [512, 1024, 2048, 4096],
9855 annotationList: {
9856 annotations: [],
9857 controls: [],
9858 editable: false,
9859 linkEndpoints: false,
9860 isContinuousPlay: false,
9861 },
9862 isAutomaticScroll: false,
9863 };
9864
9865 const config = lodash_defaultsdeep_default()({}, options, defaults);
9866 const zoomIndex = config.zoomLevels.indexOf(config.samplesPerPixel);
9867
9868 if (zoomIndex === -1) {
9869 throw new Error(
9870 "initial samplesPerPixel must be included in array zoomLevels"
9871 );
9872 }
9873
9874 const playlist = new Playlist();
9875 playlist.setSampleRate(config.sampleRate);
9876 playlist.setSamplesPerPixel(config.samplesPerPixel);
9877 playlist.setAudioContext(config.ac);
9878 playlist.setEventEmitter(ee);
9879 playlist.setUpEventEmitter();
9880 playlist.setTimeSelection(0, 0);
9881 playlist.setState(config.state);
9882 playlist.setControlOptions(config.controls);
9883 playlist.setWaveHeight(config.waveHeight);
9884 playlist.setCollapsedWaveHeight(config.collapsedWaveHeight);
9885 playlist.setColors(config.colors);
9886 playlist.setZoomLevels(config.zoomLevels);
9887 playlist.setZoomIndex(zoomIndex);
9888 playlist.setMono(config.mono);
9889 playlist.setExclSolo(config.exclSolo);
9890 playlist.setShowTimeScale(config.timescale);
9891 playlist.setSeekStyle(config.seekStyle);
9892 playlist.setAnnotations(config.annotationList);
9893 playlist.setBarGap(config.barGap);
9894 playlist.setBarWidth(config.barWidth);
9895 playlist.isAutomaticScroll = config.isAutomaticScroll;
9896 playlist.isContinuousPlay = config.isContinuousPlay;
9897 playlist.linkedEndpoints = config.linkedEndpoints;
9898
9899 // take care of initial virtual dom rendering.
9900
9901 const tree = playlist.render();
9902 const rootNode = create_element_default()(tree);
9903
9904 config.container.appendChild(rootNode);
9905 playlist.tree = tree;
9906 playlist.rootNode = rootNode;
9907
9908 return playlist;
9909}
9910
9911/* harmony default export */ function app(options = {}, ee = event_emitter_default()()) {
9912 return init(options, ee);
9913}
9914
9915})();
9916
9917/******/ return __webpack_exports__;
9918/******/ })()
9919;
9920});
\No newline at end of file