@mjhls/mjh-framework 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,8 +19,7 @@ var NavDropdown = _interopDefault(require('react-bootstrap/NavDropdown'));
19
19
  var Form = _interopDefault(require('react-bootstrap/Form'));
20
20
  var FormControl = _interopDefault(require('react-bootstrap/FormControl'));
21
21
  var Button = _interopDefault(require('react-bootstrap/Button'));
22
- var events = _interopDefault(require('events'));
23
- var propTypes = _interopDefault(require('prop-types'));
22
+ var PropTypes = _interopDefault(require('prop-types'));
24
23
 
25
24
  /*! *****************************************************************************
26
25
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1436,6 +1435,8 @@ var NavNormal = function NavNormal(props) {
1436
1435
  );
1437
1436
  };
1438
1437
 
1438
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1439
+
1439
1440
  function unwrapExports (x) {
1440
1441
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1441
1442
  }
@@ -1444,6 +1445,472 @@ function createCommonjsModule(fn, module) {
1444
1445
  return module = { exports: {} }, fn(module, module.exports), module.exports;
1445
1446
  }
1446
1447
 
1448
+ var domain;
1449
+
1450
+ // This constructor is used to store event handlers. Instantiating this is
1451
+ // faster than explicitly calling `Object.create(null)` to get a "clean" empty
1452
+ // object (tested with v8 v4.9).
1453
+ function EventHandlers() {}
1454
+ EventHandlers.prototype = Object.create(null);
1455
+
1456
+ function EventEmitter() {
1457
+ EventEmitter.init.call(this);
1458
+ }
1459
+
1460
+ // nodejs oddity
1461
+ // require('events') === require('events').EventEmitter
1462
+ EventEmitter.EventEmitter = EventEmitter;
1463
+
1464
+ EventEmitter.usingDomains = false;
1465
+
1466
+ EventEmitter.prototype.domain = undefined;
1467
+ EventEmitter.prototype._events = undefined;
1468
+ EventEmitter.prototype._maxListeners = undefined;
1469
+
1470
+ // By default EventEmitters will print a warning if more than 10 listeners are
1471
+ // added to it. This is a useful default which helps finding memory leaks.
1472
+ EventEmitter.defaultMaxListeners = 10;
1473
+
1474
+ EventEmitter.init = function() {
1475
+ this.domain = null;
1476
+ if (EventEmitter.usingDomains) {
1477
+ // if there is an active domain, then attach to it.
1478
+ if (domain.active && !(this instanceof domain.Domain)) ;
1479
+ }
1480
+
1481
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
1482
+ this._events = new EventHandlers();
1483
+ this._eventsCount = 0;
1484
+ }
1485
+
1486
+ this._maxListeners = this._maxListeners || undefined;
1487
+ };
1488
+
1489
+ // Obviously not all Emitters should be limited to 10. This function allows
1490
+ // that to be increased. Set to zero for unlimited.
1491
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
1492
+ if (typeof n !== 'number' || n < 0 || isNaN(n))
1493
+ throw new TypeError('"n" argument must be a positive number');
1494
+ this._maxListeners = n;
1495
+ return this;
1496
+ };
1497
+
1498
+ function $getMaxListeners(that) {
1499
+ if (that._maxListeners === undefined)
1500
+ return EventEmitter.defaultMaxListeners;
1501
+ return that._maxListeners;
1502
+ }
1503
+
1504
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
1505
+ return $getMaxListeners(this);
1506
+ };
1507
+
1508
+ // These standalone emit* functions are used to optimize calling of event
1509
+ // handlers for fast cases because emit() itself often has a variable number of
1510
+ // arguments and can be deoptimized because of that. These functions always have
1511
+ // the same number of arguments and thus do not get deoptimized, so the code
1512
+ // inside them can execute faster.
1513
+ function emitNone(handler, isFn, self) {
1514
+ if (isFn)
1515
+ handler.call(self);
1516
+ else {
1517
+ var len = handler.length;
1518
+ var listeners = arrayClone(handler, len);
1519
+ for (var i = 0; i < len; ++i)
1520
+ listeners[i].call(self);
1521
+ }
1522
+ }
1523
+ function emitOne(handler, isFn, self, arg1) {
1524
+ if (isFn)
1525
+ handler.call(self, arg1);
1526
+ else {
1527
+ var len = handler.length;
1528
+ var listeners = arrayClone(handler, len);
1529
+ for (var i = 0; i < len; ++i)
1530
+ listeners[i].call(self, arg1);
1531
+ }
1532
+ }
1533
+ function emitTwo(handler, isFn, self, arg1, arg2) {
1534
+ if (isFn)
1535
+ handler.call(self, arg1, arg2);
1536
+ else {
1537
+ var len = handler.length;
1538
+ var listeners = arrayClone(handler, len);
1539
+ for (var i = 0; i < len; ++i)
1540
+ listeners[i].call(self, arg1, arg2);
1541
+ }
1542
+ }
1543
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
1544
+ if (isFn)
1545
+ handler.call(self, arg1, arg2, arg3);
1546
+ else {
1547
+ var len = handler.length;
1548
+ var listeners = arrayClone(handler, len);
1549
+ for (var i = 0; i < len; ++i)
1550
+ listeners[i].call(self, arg1, arg2, arg3);
1551
+ }
1552
+ }
1553
+
1554
+ function emitMany(handler, isFn, self, args) {
1555
+ if (isFn)
1556
+ handler.apply(self, args);
1557
+ else {
1558
+ var len = handler.length;
1559
+ var listeners = arrayClone(handler, len);
1560
+ for (var i = 0; i < len; ++i)
1561
+ listeners[i].apply(self, args);
1562
+ }
1563
+ }
1564
+
1565
+ EventEmitter.prototype.emit = function emit(type) {
1566
+ var er, handler, len, args, i, events, domain;
1567
+ var doError = (type === 'error');
1568
+
1569
+ events = this._events;
1570
+ if (events)
1571
+ doError = (doError && events.error == null);
1572
+ else if (!doError)
1573
+ return false;
1574
+
1575
+ domain = this.domain;
1576
+
1577
+ // If there is no 'error' event listener then throw.
1578
+ if (doError) {
1579
+ er = arguments[1];
1580
+ if (domain) {
1581
+ if (!er)
1582
+ er = new Error('Uncaught, unspecified "error" event');
1583
+ er.domainEmitter = this;
1584
+ er.domain = domain;
1585
+ er.domainThrown = false;
1586
+ domain.emit('error', er);
1587
+ } else if (er instanceof Error) {
1588
+ throw er; // Unhandled 'error' event
1589
+ } else {
1590
+ // At least give some kind of context to the user
1591
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
1592
+ err.context = er;
1593
+ throw err;
1594
+ }
1595
+ return false;
1596
+ }
1597
+
1598
+ handler = events[type];
1599
+
1600
+ if (!handler)
1601
+ return false;
1602
+
1603
+ var isFn = typeof handler === 'function';
1604
+ len = arguments.length;
1605
+ switch (len) {
1606
+ // fast cases
1607
+ case 1:
1608
+ emitNone(handler, isFn, this);
1609
+ break;
1610
+ case 2:
1611
+ emitOne(handler, isFn, this, arguments[1]);
1612
+ break;
1613
+ case 3:
1614
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
1615
+ break;
1616
+ case 4:
1617
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
1618
+ break;
1619
+ // slower
1620
+ default:
1621
+ args = new Array(len - 1);
1622
+ for (i = 1; i < len; i++)
1623
+ args[i - 1] = arguments[i];
1624
+ emitMany(handler, isFn, this, args);
1625
+ }
1626
+
1627
+ return true;
1628
+ };
1629
+
1630
+ function _addListener(target, type, listener, prepend) {
1631
+ var m;
1632
+ var events;
1633
+ var existing;
1634
+
1635
+ if (typeof listener !== 'function')
1636
+ throw new TypeError('"listener" argument must be a function');
1637
+
1638
+ events = target._events;
1639
+ if (!events) {
1640
+ events = target._events = new EventHandlers();
1641
+ target._eventsCount = 0;
1642
+ } else {
1643
+ // To avoid recursion in the case that type === "newListener"! Before
1644
+ // adding it to the listeners, first emit "newListener".
1645
+ if (events.newListener) {
1646
+ target.emit('newListener', type,
1647
+ listener.listener ? listener.listener : listener);
1648
+
1649
+ // Re-assign `events` because a newListener handler could have caused the
1650
+ // this._events to be assigned to a new object
1651
+ events = target._events;
1652
+ }
1653
+ existing = events[type];
1654
+ }
1655
+
1656
+ if (!existing) {
1657
+ // Optimize the case of one listener. Don't need the extra array object.
1658
+ existing = events[type] = listener;
1659
+ ++target._eventsCount;
1660
+ } else {
1661
+ if (typeof existing === 'function') {
1662
+ // Adding the second element, need to change to array.
1663
+ existing = events[type] = prepend ? [listener, existing] :
1664
+ [existing, listener];
1665
+ } else {
1666
+ // If we've already got an array, just append.
1667
+ if (prepend) {
1668
+ existing.unshift(listener);
1669
+ } else {
1670
+ existing.push(listener);
1671
+ }
1672
+ }
1673
+
1674
+ // Check for listener leak
1675
+ if (!existing.warned) {
1676
+ m = $getMaxListeners(target);
1677
+ if (m && m > 0 && existing.length > m) {
1678
+ existing.warned = true;
1679
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
1680
+ existing.length + ' ' + type + ' listeners added. ' +
1681
+ 'Use emitter.setMaxListeners() to increase limit');
1682
+ w.name = 'MaxListenersExceededWarning';
1683
+ w.emitter = target;
1684
+ w.type = type;
1685
+ w.count = existing.length;
1686
+ emitWarning(w);
1687
+ }
1688
+ }
1689
+ }
1690
+
1691
+ return target;
1692
+ }
1693
+ function emitWarning(e) {
1694
+ typeof console.warn === 'function' ? console.warn(e) : console.log(e);
1695
+ }
1696
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
1697
+ return _addListener(this, type, listener, false);
1698
+ };
1699
+
1700
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
1701
+
1702
+ EventEmitter.prototype.prependListener =
1703
+ function prependListener(type, listener) {
1704
+ return _addListener(this, type, listener, true);
1705
+ };
1706
+
1707
+ function _onceWrap(target, type, listener) {
1708
+ var fired = false;
1709
+ function g() {
1710
+ target.removeListener(type, g);
1711
+ if (!fired) {
1712
+ fired = true;
1713
+ listener.apply(target, arguments);
1714
+ }
1715
+ }
1716
+ g.listener = listener;
1717
+ return g;
1718
+ }
1719
+
1720
+ EventEmitter.prototype.once = function once(type, listener) {
1721
+ if (typeof listener !== 'function')
1722
+ throw new TypeError('"listener" argument must be a function');
1723
+ this.on(type, _onceWrap(this, type, listener));
1724
+ return this;
1725
+ };
1726
+
1727
+ EventEmitter.prototype.prependOnceListener =
1728
+ function prependOnceListener(type, listener) {
1729
+ if (typeof listener !== 'function')
1730
+ throw new TypeError('"listener" argument must be a function');
1731
+ this.prependListener(type, _onceWrap(this, type, listener));
1732
+ return this;
1733
+ };
1734
+
1735
+ // emits a 'removeListener' event iff the listener was removed
1736
+ EventEmitter.prototype.removeListener =
1737
+ function removeListener(type, listener) {
1738
+ var list, events, position, i, originalListener;
1739
+
1740
+ if (typeof listener !== 'function')
1741
+ throw new TypeError('"listener" argument must be a function');
1742
+
1743
+ events = this._events;
1744
+ if (!events)
1745
+ return this;
1746
+
1747
+ list = events[type];
1748
+ if (!list)
1749
+ return this;
1750
+
1751
+ if (list === listener || (list.listener && list.listener === listener)) {
1752
+ if (--this._eventsCount === 0)
1753
+ this._events = new EventHandlers();
1754
+ else {
1755
+ delete events[type];
1756
+ if (events.removeListener)
1757
+ this.emit('removeListener', type, list.listener || listener);
1758
+ }
1759
+ } else if (typeof list !== 'function') {
1760
+ position = -1;
1761
+
1762
+ for (i = list.length; i-- > 0;) {
1763
+ if (list[i] === listener ||
1764
+ (list[i].listener && list[i].listener === listener)) {
1765
+ originalListener = list[i].listener;
1766
+ position = i;
1767
+ break;
1768
+ }
1769
+ }
1770
+
1771
+ if (position < 0)
1772
+ return this;
1773
+
1774
+ if (list.length === 1) {
1775
+ list[0] = undefined;
1776
+ if (--this._eventsCount === 0) {
1777
+ this._events = new EventHandlers();
1778
+ return this;
1779
+ } else {
1780
+ delete events[type];
1781
+ }
1782
+ } else {
1783
+ spliceOne(list, position);
1784
+ }
1785
+
1786
+ if (events.removeListener)
1787
+ this.emit('removeListener', type, originalListener || listener);
1788
+ }
1789
+
1790
+ return this;
1791
+ };
1792
+
1793
+ EventEmitter.prototype.removeAllListeners =
1794
+ function removeAllListeners(type) {
1795
+ var listeners, events;
1796
+
1797
+ events = this._events;
1798
+ if (!events)
1799
+ return this;
1800
+
1801
+ // not listening for removeListener, no need to emit
1802
+ if (!events.removeListener) {
1803
+ if (arguments.length === 0) {
1804
+ this._events = new EventHandlers();
1805
+ this._eventsCount = 0;
1806
+ } else if (events[type]) {
1807
+ if (--this._eventsCount === 0)
1808
+ this._events = new EventHandlers();
1809
+ else
1810
+ delete events[type];
1811
+ }
1812
+ return this;
1813
+ }
1814
+
1815
+ // emit removeListener for all listeners on all events
1816
+ if (arguments.length === 0) {
1817
+ var keys = Object.keys(events);
1818
+ for (var i = 0, key; i < keys.length; ++i) {
1819
+ key = keys[i];
1820
+ if (key === 'removeListener') continue;
1821
+ this.removeAllListeners(key);
1822
+ }
1823
+ this.removeAllListeners('removeListener');
1824
+ this._events = new EventHandlers();
1825
+ this._eventsCount = 0;
1826
+ return this;
1827
+ }
1828
+
1829
+ listeners = events[type];
1830
+
1831
+ if (typeof listeners === 'function') {
1832
+ this.removeListener(type, listeners);
1833
+ } else if (listeners) {
1834
+ // LIFO order
1835
+ do {
1836
+ this.removeListener(type, listeners[listeners.length - 1]);
1837
+ } while (listeners[0]);
1838
+ }
1839
+
1840
+ return this;
1841
+ };
1842
+
1843
+ EventEmitter.prototype.listeners = function listeners(type) {
1844
+ var evlistener;
1845
+ var ret;
1846
+ var events = this._events;
1847
+
1848
+ if (!events)
1849
+ ret = [];
1850
+ else {
1851
+ evlistener = events[type];
1852
+ if (!evlistener)
1853
+ ret = [];
1854
+ else if (typeof evlistener === 'function')
1855
+ ret = [evlistener.listener || evlistener];
1856
+ else
1857
+ ret = unwrapListeners(evlistener);
1858
+ }
1859
+
1860
+ return ret;
1861
+ };
1862
+
1863
+ EventEmitter.listenerCount = function(emitter, type) {
1864
+ if (typeof emitter.listenerCount === 'function') {
1865
+ return emitter.listenerCount(type);
1866
+ } else {
1867
+ return listenerCount.call(emitter, type);
1868
+ }
1869
+ };
1870
+
1871
+ EventEmitter.prototype.listenerCount = listenerCount;
1872
+ function listenerCount(type) {
1873
+ var events = this._events;
1874
+
1875
+ if (events) {
1876
+ var evlistener = events[type];
1877
+
1878
+ if (typeof evlistener === 'function') {
1879
+ return 1;
1880
+ } else if (evlistener) {
1881
+ return evlistener.length;
1882
+ }
1883
+ }
1884
+
1885
+ return 0;
1886
+ }
1887
+
1888
+ EventEmitter.prototype.eventNames = function eventNames() {
1889
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
1890
+ };
1891
+
1892
+ // About 1.5x faster than the two-arg version of Array#splice().
1893
+ function spliceOne(list, index) {
1894
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
1895
+ list[i] = list[k];
1896
+ list.pop();
1897
+ }
1898
+
1899
+ function arrayClone(arr, i) {
1900
+ var copy = new Array(i);
1901
+ while (i--)
1902
+ copy[i] = arr[i];
1903
+ return copy;
1904
+ }
1905
+
1906
+ function unwrapListeners(arr) {
1907
+ var ret = new Array(arr.length);
1908
+ for (var i = 0; i < ret.length; ++i) {
1909
+ ret[i] = arr[i].listener || arr[i];
1910
+ }
1911
+ return ret;
1912
+ }
1913
+
1447
1914
  var utils = createCommonjsModule(function (module, exports) {
1448
1915
 
1449
1916
  Object.defineProperty(exports, "__esModule", {
@@ -1510,7 +1977,7 @@ var registeredSlots = {};
1510
1977
  var managerAlreadyInitialized = false;
1511
1978
  var globalTargetingArguments = {};
1512
1979
  var globalAdSenseAttributes = {};
1513
- var DFPManager = Object.assign(new events.EventEmitter().setMaxListeners(0), {
1980
+ var DFPManager = Object.assign(new EventEmitter.EventEmitter().setMaxListeners(0), {
1514
1981
  singleRequestIsEnabled: function singleRequestIsEnabled() {
1515
1982
  return singleRequestEnabled;
1516
1983
  },
@@ -1998,7 +2465,7 @@ exports.default = exports.Context = void 0;
1998
2465
 
1999
2466
  var _react = _interopRequireDefault(React__default);
2000
2467
 
2001
- var _propTypes = _interopRequireDefault(propTypes);
2468
+ var _propTypes = _interopRequireDefault(PropTypes);
2002
2469
 
2003
2470
  var _manager = _interopRequireDefault(manager);
2004
2471
 
@@ -2306,7 +2773,7 @@ exports.default = exports.AdSlot = void 0;
2306
2773
 
2307
2774
  var _react = _interopRequireDefault(React__default);
2308
2775
 
2309
- var _propTypes = _interopRequireDefault(propTypes);
2776
+ var _propTypes = _interopRequireDefault(PropTypes);
2310
2777
 
2311
2778
  var _manager = _interopRequireDefault(manager);
2312
2779
 
@@ -2794,6 +3261,2685 @@ var AD300x250x600 = function (_Component) {
2794
3261
  return AD300x250x600;
2795
3262
  }(React.Component);
2796
3263
 
3264
+ var getYoutubeId = createCommonjsModule(function (module, exports) {
3265
+ (function (root, factory) {
3266
+ {
3267
+ module.exports = factory();
3268
+ }
3269
+ }(commonjsGlobal, function (exports) {
3270
+
3271
+ return function (url, opts) {
3272
+ if (opts == undefined) {
3273
+ opts = {fuzzy: true};
3274
+ }
3275
+
3276
+ if (/youtu\.?be/.test(url)) {
3277
+
3278
+ // Look first for known patterns
3279
+ var i;
3280
+ var patterns = [
3281
+ /youtu\.be\/([^#\&\?]{11})/, // youtu.be/<id>
3282
+ /\?v=([^#\&\?]{11})/, // ?v=<id>
3283
+ /\&v=([^#\&\?]{11})/, // &v=<id>
3284
+ /embed\/([^#\&\?]{11})/, // embed/<id>
3285
+ /\/v\/([^#\&\?]{11})/ // /v/<id>
3286
+ ];
3287
+
3288
+ // If any pattern matches, return the ID
3289
+ for (i = 0; i < patterns.length; ++i) {
3290
+ if (patterns[i].test(url)) {
3291
+ return patterns[i].exec(url)[1];
3292
+ }
3293
+ }
3294
+
3295
+ if (opts.fuzzy) {
3296
+ // If that fails, break it apart by certain characters and look
3297
+ // for the 11 character key
3298
+ var tokens = url.split(/[\/\&\?=#\.\s]/g);
3299
+ for (i = 0; i < tokens.length; ++i) {
3300
+ if (/^[^#\&\?]{11}$/.test(tokens[i])) {
3301
+ return tokens[i];
3302
+ }
3303
+ }
3304
+ }
3305
+ }
3306
+
3307
+ return null;
3308
+ };
3309
+
3310
+ }));
3311
+ });
3312
+
3313
+ var isArray = Array.isArray;
3314
+ var keyList = Object.keys;
3315
+ var hasProp = Object.prototype.hasOwnProperty;
3316
+
3317
+ var fastDeepEqual = function equal(a, b) {
3318
+ if (a === b) return true;
3319
+
3320
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
3321
+ var arrA = isArray(a)
3322
+ , arrB = isArray(b)
3323
+ , i
3324
+ , length
3325
+ , key;
3326
+
3327
+ if (arrA && arrB) {
3328
+ length = a.length;
3329
+ if (length != b.length) return false;
3330
+ for (i = length; i-- !== 0;)
3331
+ if (!equal(a[i], b[i])) return false;
3332
+ return true;
3333
+ }
3334
+
3335
+ if (arrA != arrB) return false;
3336
+
3337
+ var dateA = a instanceof Date
3338
+ , dateB = b instanceof Date;
3339
+ if (dateA != dateB) return false;
3340
+ if (dateA && dateB) return a.getTime() == b.getTime();
3341
+
3342
+ var regexpA = a instanceof RegExp
3343
+ , regexpB = b instanceof RegExp;
3344
+ if (regexpA != regexpB) return false;
3345
+ if (regexpA && regexpB) return a.toString() == b.toString();
3346
+
3347
+ var keys = keyList(a);
3348
+ length = keys.length;
3349
+
3350
+ if (length !== keyList(b).length)
3351
+ return false;
3352
+
3353
+ for (i = length; i-- !== 0;)
3354
+ if (!hasProp.call(b, keys[i])) return false;
3355
+
3356
+ for (i = length; i-- !== 0;) {
3357
+ key = keys[i];
3358
+ if (!equal(a[key], b[key])) return false;
3359
+ }
3360
+
3361
+ return true;
3362
+ }
3363
+
3364
+ return a!==a && b!==b;
3365
+ };
3366
+
3367
+ var Sister;
3368
+
3369
+ /**
3370
+ * @link https://github.com/gajus/sister for the canonical source repository
3371
+ * @license https://github.com/gajus/sister/blob/master/LICENSE BSD 3-Clause
3372
+ */
3373
+ Sister = function () {
3374
+ var sister = {},
3375
+ events = {};
3376
+
3377
+ /**
3378
+ * @name handler
3379
+ * @function
3380
+ * @param {Object} data Event data.
3381
+ */
3382
+
3383
+ /**
3384
+ * @param {String} name Event name.
3385
+ * @param {handler} handler
3386
+ * @return {listener}
3387
+ */
3388
+ sister.on = function (name, handler) {
3389
+ var listener = {name: name, handler: handler};
3390
+ events[name] = events[name] || [];
3391
+ events[name].unshift(listener);
3392
+ return listener;
3393
+ };
3394
+
3395
+ /**
3396
+ * @param {listener}
3397
+ */
3398
+ sister.off = function (listener) {
3399
+ var index = events[listener.name].indexOf(listener);
3400
+
3401
+ if (index !== -1) {
3402
+ events[listener.name].splice(index, 1);
3403
+ }
3404
+ };
3405
+
3406
+ /**
3407
+ * @param {String} name Event name.
3408
+ * @param {Object} data Event data.
3409
+ */
3410
+ sister.trigger = function (name, data) {
3411
+ var listeners = events[name],
3412
+ i;
3413
+
3414
+ if (listeners) {
3415
+ i = listeners.length;
3416
+ while (i--) {
3417
+ listeners[i].handler(data);
3418
+ }
3419
+ }
3420
+ };
3421
+
3422
+ return sister;
3423
+ };
3424
+
3425
+ var sister = Sister;
3426
+
3427
+ var loadScript = function load (src, opts, cb) {
3428
+ var head = document.head || document.getElementsByTagName('head')[0];
3429
+ var script = document.createElement('script');
3430
+
3431
+ if (typeof opts === 'function') {
3432
+ cb = opts;
3433
+ opts = {};
3434
+ }
3435
+
3436
+ opts = opts || {};
3437
+ cb = cb || function() {};
3438
+
3439
+ script.type = opts.type || 'text/javascript';
3440
+ script.charset = opts.charset || 'utf8';
3441
+ script.async = 'async' in opts ? !!opts.async : true;
3442
+ script.src = src;
3443
+
3444
+ if (opts.attrs) {
3445
+ setAttributes(script, opts.attrs);
3446
+ }
3447
+
3448
+ if (opts.text) {
3449
+ script.text = '' + opts.text;
3450
+ }
3451
+
3452
+ var onend = 'onload' in script ? stdOnEnd : ieOnEnd;
3453
+ onend(script, cb);
3454
+
3455
+ // some good legacy browsers (firefox) fail the 'in' detection above
3456
+ // so as a fallback we always set onload
3457
+ // old IE will ignore this and new IE will set onload
3458
+ if (!script.onload) {
3459
+ stdOnEnd(script, cb);
3460
+ }
3461
+
3462
+ head.appendChild(script);
3463
+ };
3464
+
3465
+ function setAttributes(script, attrs) {
3466
+ for (var attr in attrs) {
3467
+ script.setAttribute(attr, attrs[attr]);
3468
+ }
3469
+ }
3470
+
3471
+ function stdOnEnd (script, cb) {
3472
+ script.onload = function () {
3473
+ this.onerror = this.onload = null;
3474
+ cb(null, script);
3475
+ };
3476
+ script.onerror = function () {
3477
+ // this.onload = null here is necessary
3478
+ // because even IE9 works not like others
3479
+ this.onerror = this.onload = null;
3480
+ cb(new Error('Failed to load ' + this.src), script);
3481
+ };
3482
+ }
3483
+
3484
+ function ieOnEnd (script, cb) {
3485
+ script.onreadystatechange = function () {
3486
+ if (this.readyState != 'complete' && this.readyState != 'loaded') return
3487
+ this.onreadystatechange = null;
3488
+ cb(null, script); // there is no way to catch loading errors in IE8
3489
+ };
3490
+ }
3491
+
3492
+ var loadYouTubeIframeApi = createCommonjsModule(function (module, exports) {
3493
+
3494
+ Object.defineProperty(exports, "__esModule", {
3495
+ value: true
3496
+ });
3497
+
3498
+
3499
+
3500
+ var _loadScript2 = _interopRequireDefault(loadScript);
3501
+
3502
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3503
+
3504
+ exports.default = function (emitter) {
3505
+ /**
3506
+ * A promise that is resolved when window.onYouTubeIframeAPIReady is called.
3507
+ * The promise is resolved with a reference to window.YT object.
3508
+ */
3509
+ var iframeAPIReady = new Promise(function (resolve) {
3510
+ if (window.YT && window.YT.Player && window.YT.Player instanceof Function) {
3511
+ resolve(window.YT);
3512
+
3513
+ return;
3514
+ } else {
3515
+ var protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
3516
+
3517
+ (0, _loadScript2.default)(protocol + '//www.youtube.com/iframe_api', function (error) {
3518
+ if (error) {
3519
+ emitter.trigger('error', error);
3520
+ }
3521
+ });
3522
+ }
3523
+
3524
+ var previous = window.onYouTubeIframeAPIReady;
3525
+
3526
+ // The API will call this function when page has finished downloading
3527
+ // the JavaScript for the player API.
3528
+ window.onYouTubeIframeAPIReady = function () {
3529
+ if (previous) {
3530
+ previous();
3531
+ }
3532
+
3533
+ resolve(window.YT);
3534
+ };
3535
+ });
3536
+
3537
+ return iframeAPIReady;
3538
+ };
3539
+
3540
+ module.exports = exports['default'];
3541
+ });
3542
+
3543
+ unwrapExports(loadYouTubeIframeApi);
3544
+
3545
+ /**
3546
+ * Helpers.
3547
+ */
3548
+
3549
+ var s = 1000;
3550
+ var m = s * 60;
3551
+ var h = m * 60;
3552
+ var d = h * 24;
3553
+ var y = d * 365.25;
3554
+
3555
+ /**
3556
+ * Parse or format the given `val`.
3557
+ *
3558
+ * Options:
3559
+ *
3560
+ * - `long` verbose formatting [false]
3561
+ *
3562
+ * @param {String|Number} val
3563
+ * @param {Object} [options]
3564
+ * @throws {Error} throw an error if val is not a non-empty string or a number
3565
+ * @return {String|Number}
3566
+ * @api public
3567
+ */
3568
+
3569
+ var ms = function(val, options) {
3570
+ options = options || {};
3571
+ var type = typeof val;
3572
+ if (type === 'string' && val.length > 0) {
3573
+ return parse(val);
3574
+ } else if (type === 'number' && isNaN(val) === false) {
3575
+ return options.long ? fmtLong(val) : fmtShort(val);
3576
+ }
3577
+ throw new Error(
3578
+ 'val is not a non-empty string or a valid number. val=' +
3579
+ JSON.stringify(val)
3580
+ );
3581
+ };
3582
+
3583
+ /**
3584
+ * Parse the given `str` and return milliseconds.
3585
+ *
3586
+ * @param {String} str
3587
+ * @return {Number}
3588
+ * @api private
3589
+ */
3590
+
3591
+ function parse(str) {
3592
+ str = String(str);
3593
+ if (str.length > 100) {
3594
+ return;
3595
+ }
3596
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
3597
+ str
3598
+ );
3599
+ if (!match) {
3600
+ return;
3601
+ }
3602
+ var n = parseFloat(match[1]);
3603
+ var type = (match[2] || 'ms').toLowerCase();
3604
+ switch (type) {
3605
+ case 'years':
3606
+ case 'year':
3607
+ case 'yrs':
3608
+ case 'yr':
3609
+ case 'y':
3610
+ return n * y;
3611
+ case 'days':
3612
+ case 'day':
3613
+ case 'd':
3614
+ return n * d;
3615
+ case 'hours':
3616
+ case 'hour':
3617
+ case 'hrs':
3618
+ case 'hr':
3619
+ case 'h':
3620
+ return n * h;
3621
+ case 'minutes':
3622
+ case 'minute':
3623
+ case 'mins':
3624
+ case 'min':
3625
+ case 'm':
3626
+ return n * m;
3627
+ case 'seconds':
3628
+ case 'second':
3629
+ case 'secs':
3630
+ case 'sec':
3631
+ case 's':
3632
+ return n * s;
3633
+ case 'milliseconds':
3634
+ case 'millisecond':
3635
+ case 'msecs':
3636
+ case 'msec':
3637
+ case 'ms':
3638
+ return n;
3639
+ default:
3640
+ return undefined;
3641
+ }
3642
+ }
3643
+
3644
+ /**
3645
+ * Short format for `ms`.
3646
+ *
3647
+ * @param {Number} ms
3648
+ * @return {String}
3649
+ * @api private
3650
+ */
3651
+
3652
+ function fmtShort(ms) {
3653
+ if (ms >= d) {
3654
+ return Math.round(ms / d) + 'd';
3655
+ }
3656
+ if (ms >= h) {
3657
+ return Math.round(ms / h) + 'h';
3658
+ }
3659
+ if (ms >= m) {
3660
+ return Math.round(ms / m) + 'm';
3661
+ }
3662
+ if (ms >= s) {
3663
+ return Math.round(ms / s) + 's';
3664
+ }
3665
+ return ms + 'ms';
3666
+ }
3667
+
3668
+ /**
3669
+ * Long format for `ms`.
3670
+ *
3671
+ * @param {Number} ms
3672
+ * @return {String}
3673
+ * @api private
3674
+ */
3675
+
3676
+ function fmtLong(ms) {
3677
+ return plural(ms, d, 'day') ||
3678
+ plural(ms, h, 'hour') ||
3679
+ plural(ms, m, 'minute') ||
3680
+ plural(ms, s, 'second') ||
3681
+ ms + ' ms';
3682
+ }
3683
+
3684
+ /**
3685
+ * Pluralization helper.
3686
+ */
3687
+
3688
+ function plural(ms, n, name) {
3689
+ if (ms < n) {
3690
+ return;
3691
+ }
3692
+ if (ms < n * 1.5) {
3693
+ return Math.floor(ms / n) + ' ' + name;
3694
+ }
3695
+ return Math.ceil(ms / n) + ' ' + name + 's';
3696
+ }
3697
+
3698
+ var debug = createCommonjsModule(function (module, exports) {
3699
+ /**
3700
+ * This is the common logic for both the Node.js and web browser
3701
+ * implementations of `debug()`.
3702
+ *
3703
+ * Expose `debug()` as the module.
3704
+ */
3705
+
3706
+ exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
3707
+ exports.coerce = coerce;
3708
+ exports.disable = disable;
3709
+ exports.enable = enable;
3710
+ exports.enabled = enabled;
3711
+ exports.humanize = ms;
3712
+
3713
+ /**
3714
+ * The currently active debug mode names, and names to skip.
3715
+ */
3716
+
3717
+ exports.names = [];
3718
+ exports.skips = [];
3719
+
3720
+ /**
3721
+ * Map of special "%n" handling functions, for the debug "format" argument.
3722
+ *
3723
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3724
+ */
3725
+
3726
+ exports.formatters = {};
3727
+
3728
+ /**
3729
+ * Previous log timestamp.
3730
+ */
3731
+
3732
+ var prevTime;
3733
+
3734
+ /**
3735
+ * Select a color.
3736
+ * @param {String} namespace
3737
+ * @return {Number}
3738
+ * @api private
3739
+ */
3740
+
3741
+ function selectColor(namespace) {
3742
+ var hash = 0, i;
3743
+
3744
+ for (i in namespace) {
3745
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
3746
+ hash |= 0; // Convert to 32bit integer
3747
+ }
3748
+
3749
+ return exports.colors[Math.abs(hash) % exports.colors.length];
3750
+ }
3751
+
3752
+ /**
3753
+ * Create a debugger with the given `namespace`.
3754
+ *
3755
+ * @param {String} namespace
3756
+ * @return {Function}
3757
+ * @api public
3758
+ */
3759
+
3760
+ function createDebug(namespace) {
3761
+
3762
+ function debug() {
3763
+ // disabled?
3764
+ if (!debug.enabled) return;
3765
+
3766
+ var self = debug;
3767
+
3768
+ // set `diff` timestamp
3769
+ var curr = +new Date();
3770
+ var ms$$1 = curr - (prevTime || curr);
3771
+ self.diff = ms$$1;
3772
+ self.prev = prevTime;
3773
+ self.curr = curr;
3774
+ prevTime = curr;
3775
+
3776
+ // turn the `arguments` into a proper Array
3777
+ var args = new Array(arguments.length);
3778
+ for (var i = 0; i < args.length; i++) {
3779
+ args[i] = arguments[i];
3780
+ }
3781
+
3782
+ args[0] = exports.coerce(args[0]);
3783
+
3784
+ if ('string' !== typeof args[0]) {
3785
+ // anything else let's inspect with %O
3786
+ args.unshift('%O');
3787
+ }
3788
+
3789
+ // apply any `formatters` transformations
3790
+ var index = 0;
3791
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
3792
+ // if we encounter an escaped % then don't increase the array index
3793
+ if (match === '%%') return match;
3794
+ index++;
3795
+ var formatter = exports.formatters[format];
3796
+ if ('function' === typeof formatter) {
3797
+ var val = args[index];
3798
+ match = formatter.call(self, val);
3799
+
3800
+ // now we need to remove `args[index]` since it's inlined in the `format`
3801
+ args.splice(index, 1);
3802
+ index--;
3803
+ }
3804
+ return match;
3805
+ });
3806
+
3807
+ // apply env-specific formatting (colors, etc.)
3808
+ exports.formatArgs.call(self, args);
3809
+
3810
+ var logFn = debug.log || exports.log || console.log.bind(console);
3811
+ logFn.apply(self, args);
3812
+ }
3813
+
3814
+ debug.namespace = namespace;
3815
+ debug.enabled = exports.enabled(namespace);
3816
+ debug.useColors = exports.useColors();
3817
+ debug.color = selectColor(namespace);
3818
+
3819
+ // env-specific initialization logic for debug instances
3820
+ if ('function' === typeof exports.init) {
3821
+ exports.init(debug);
3822
+ }
3823
+
3824
+ return debug;
3825
+ }
3826
+
3827
+ /**
3828
+ * Enables a debug mode by namespaces. This can include modes
3829
+ * separated by a colon and wildcards.
3830
+ *
3831
+ * @param {String} namespaces
3832
+ * @api public
3833
+ */
3834
+
3835
+ function enable(namespaces) {
3836
+ exports.save(namespaces);
3837
+
3838
+ exports.names = [];
3839
+ exports.skips = [];
3840
+
3841
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3842
+ var len = split.length;
3843
+
3844
+ for (var i = 0; i < len; i++) {
3845
+ if (!split[i]) continue; // ignore empty strings
3846
+ namespaces = split[i].replace(/\*/g, '.*?');
3847
+ if (namespaces[0] === '-') {
3848
+ exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
3849
+ } else {
3850
+ exports.names.push(new RegExp('^' + namespaces + '$'));
3851
+ }
3852
+ }
3853
+ }
3854
+
3855
+ /**
3856
+ * Disable debug output.
3857
+ *
3858
+ * @api public
3859
+ */
3860
+
3861
+ function disable() {
3862
+ exports.enable('');
3863
+ }
3864
+
3865
+ /**
3866
+ * Returns true if the given mode name is enabled, false otherwise.
3867
+ *
3868
+ * @param {String} name
3869
+ * @return {Boolean}
3870
+ * @api public
3871
+ */
3872
+
3873
+ function enabled(name) {
3874
+ var i, len;
3875
+ for (i = 0, len = exports.skips.length; i < len; i++) {
3876
+ if (exports.skips[i].test(name)) {
3877
+ return false;
3878
+ }
3879
+ }
3880
+ for (i = 0, len = exports.names.length; i < len; i++) {
3881
+ if (exports.names[i].test(name)) {
3882
+ return true;
3883
+ }
3884
+ }
3885
+ return false;
3886
+ }
3887
+
3888
+ /**
3889
+ * Coerce `val`.
3890
+ *
3891
+ * @param {Mixed} val
3892
+ * @return {Mixed}
3893
+ * @api private
3894
+ */
3895
+
3896
+ function coerce(val) {
3897
+ if (val instanceof Error) return val.stack || val.message;
3898
+ return val;
3899
+ }
3900
+ });
3901
+ var debug_1 = debug.coerce;
3902
+ var debug_2 = debug.disable;
3903
+ var debug_3 = debug.enable;
3904
+ var debug_4 = debug.enabled;
3905
+ var debug_5 = debug.humanize;
3906
+ var debug_6 = debug.names;
3907
+ var debug_7 = debug.skips;
3908
+ var debug_8 = debug.formatters;
3909
+
3910
+ var browser = createCommonjsModule(function (module, exports) {
3911
+ /**
3912
+ * This is the web browser implementation of `debug()`.
3913
+ *
3914
+ * Expose `debug()` as the module.
3915
+ */
3916
+
3917
+ exports = module.exports = debug;
3918
+ exports.log = log;
3919
+ exports.formatArgs = formatArgs;
3920
+ exports.save = save;
3921
+ exports.load = load;
3922
+ exports.useColors = useColors;
3923
+ exports.storage = 'undefined' != typeof chrome
3924
+ && 'undefined' != typeof chrome.storage
3925
+ ? chrome.storage.local
3926
+ : localstorage();
3927
+
3928
+ /**
3929
+ * Colors.
3930
+ */
3931
+
3932
+ exports.colors = [
3933
+ 'lightseagreen',
3934
+ 'forestgreen',
3935
+ 'goldenrod',
3936
+ 'dodgerblue',
3937
+ 'darkorchid',
3938
+ 'crimson'
3939
+ ];
3940
+
3941
+ /**
3942
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
3943
+ * and the Firebug extension (any Firefox version) are known
3944
+ * to support "%c" CSS customizations.
3945
+ *
3946
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
3947
+ */
3948
+
3949
+ function useColors() {
3950
+ // NB: In an Electron preload script, document will be defined but not fully
3951
+ // initialized. Since we know we're in Chrome, we'll just detect this case
3952
+ // explicitly
3953
+ if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
3954
+ return true;
3955
+ }
3956
+
3957
+ // is webkit? http://stackoverflow.com/a/16459606/376773
3958
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
3959
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
3960
+ // is firebug? http://stackoverflow.com/a/398120/376773
3961
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
3962
+ // is firefox >= v31?
3963
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
3964
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
3965
+ // double check webkit in userAgent just in case we are in a worker
3966
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
3967
+ }
3968
+
3969
+ /**
3970
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3971
+ */
3972
+
3973
+ exports.formatters.j = function(v) {
3974
+ try {
3975
+ return JSON.stringify(v);
3976
+ } catch (err) {
3977
+ return '[UnexpectedJSONParseError]: ' + err.message;
3978
+ }
3979
+ };
3980
+
3981
+
3982
+ /**
3983
+ * Colorize log arguments if enabled.
3984
+ *
3985
+ * @api public
3986
+ */
3987
+
3988
+ function formatArgs(args) {
3989
+ var useColors = this.useColors;
3990
+
3991
+ args[0] = (useColors ? '%c' : '')
3992
+ + this.namespace
3993
+ + (useColors ? ' %c' : ' ')
3994
+ + args[0]
3995
+ + (useColors ? '%c ' : ' ')
3996
+ + '+' + exports.humanize(this.diff);
3997
+
3998
+ if (!useColors) return;
3999
+
4000
+ var c = 'color: ' + this.color;
4001
+ args.splice(1, 0, c, 'color: inherit');
4002
+
4003
+ // the final "%c" is somewhat tricky, because there could be other
4004
+ // arguments passed either before or after the %c, so we need to
4005
+ // figure out the correct index to insert the CSS into
4006
+ var index = 0;
4007
+ var lastC = 0;
4008
+ args[0].replace(/%[a-zA-Z%]/g, function(match) {
4009
+ if ('%%' === match) return;
4010
+ index++;
4011
+ if ('%c' === match) {
4012
+ // we only are interested in the *last* %c
4013
+ // (the user may have provided their own)
4014
+ lastC = index;
4015
+ }
4016
+ });
4017
+
4018
+ args.splice(lastC, 0, c);
4019
+ }
4020
+
4021
+ /**
4022
+ * Invokes `console.log()` when available.
4023
+ * No-op when `console.log` is not a "function".
4024
+ *
4025
+ * @api public
4026
+ */
4027
+
4028
+ function log() {
4029
+ // this hackery is required for IE8/9, where
4030
+ // the `console.log` function doesn't have 'apply'
4031
+ return 'object' === typeof console
4032
+ && console.log
4033
+ && Function.prototype.apply.call(console.log, console, arguments);
4034
+ }
4035
+
4036
+ /**
4037
+ * Save `namespaces`.
4038
+ *
4039
+ * @param {String} namespaces
4040
+ * @api private
4041
+ */
4042
+
4043
+ function save(namespaces) {
4044
+ try {
4045
+ if (null == namespaces) {
4046
+ exports.storage.removeItem('debug');
4047
+ } else {
4048
+ exports.storage.debug = namespaces;
4049
+ }
4050
+ } catch(e) {}
4051
+ }
4052
+
4053
+ /**
4054
+ * Load `namespaces`.
4055
+ *
4056
+ * @return {String} returns the previously persisted debug modes
4057
+ * @api private
4058
+ */
4059
+
4060
+ function load() {
4061
+ var r;
4062
+ try {
4063
+ r = exports.storage.debug;
4064
+ } catch(e) {}
4065
+
4066
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
4067
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
4068
+ r = process.env.DEBUG;
4069
+ }
4070
+
4071
+ return r;
4072
+ }
4073
+
4074
+ /**
4075
+ * Enable namespaces listed in `localStorage.debug` initially.
4076
+ */
4077
+
4078
+ exports.enable(load());
4079
+
4080
+ /**
4081
+ * Localstorage attempts to return the localstorage.
4082
+ *
4083
+ * This is necessary because safari throws
4084
+ * when a user disables cookies/localstorage
4085
+ * and you attempt to access it.
4086
+ *
4087
+ * @return {LocalStorage}
4088
+ * @api private
4089
+ */
4090
+
4091
+ function localstorage() {
4092
+ try {
4093
+ return window.localStorage;
4094
+ } catch (e) {}
4095
+ }
4096
+ });
4097
+ var browser_1 = browser.log;
4098
+ var browser_2 = browser.formatArgs;
4099
+ var browser_3 = browser.save;
4100
+ var browser_4 = browser.load;
4101
+ var browser_5 = browser.useColors;
4102
+ var browser_6 = browser.storage;
4103
+ var browser_7 = browser.colors;
4104
+
4105
+ // MIT lisence
4106
+ // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
4107
+
4108
+ function isatty() {
4109
+ return false;
4110
+ }
4111
+
4112
+ function ReadStream() {
4113
+ throw new Error('tty.ReadStream is not implemented');
4114
+ }
4115
+
4116
+ function WriteStream() {
4117
+ throw new Error('tty.ReadStream is not implemented');
4118
+ }
4119
+
4120
+ var tty = {
4121
+ isatty: isatty,
4122
+ ReadStream: ReadStream,
4123
+ WriteStream: WriteStream
4124
+ };
4125
+
4126
+ // shim for using process in browser
4127
+ // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
4128
+
4129
+ function defaultSetTimout() {
4130
+ throw new Error('setTimeout has not been defined');
4131
+ }
4132
+ function defaultClearTimeout () {
4133
+ throw new Error('clearTimeout has not been defined');
4134
+ }
4135
+ var cachedSetTimeout = defaultSetTimout;
4136
+ var cachedClearTimeout = defaultClearTimeout;
4137
+ if (typeof global.setTimeout === 'function') {
4138
+ cachedSetTimeout = setTimeout;
4139
+ }
4140
+ if (typeof global.clearTimeout === 'function') {
4141
+ cachedClearTimeout = clearTimeout;
4142
+ }
4143
+
4144
+ function runTimeout(fun) {
4145
+ if (cachedSetTimeout === setTimeout) {
4146
+ //normal enviroments in sane situations
4147
+ return setTimeout(fun, 0);
4148
+ }
4149
+ // if setTimeout wasn't available but was latter defined
4150
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
4151
+ cachedSetTimeout = setTimeout;
4152
+ return setTimeout(fun, 0);
4153
+ }
4154
+ try {
4155
+ // when when somebody has screwed with setTimeout but no I.E. maddness
4156
+ return cachedSetTimeout(fun, 0);
4157
+ } catch(e){
4158
+ try {
4159
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
4160
+ return cachedSetTimeout.call(null, fun, 0);
4161
+ } catch(e){
4162
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
4163
+ return cachedSetTimeout.call(this, fun, 0);
4164
+ }
4165
+ }
4166
+
4167
+
4168
+ }
4169
+ function runClearTimeout(marker) {
4170
+ if (cachedClearTimeout === clearTimeout) {
4171
+ //normal enviroments in sane situations
4172
+ return clearTimeout(marker);
4173
+ }
4174
+ // if clearTimeout wasn't available but was latter defined
4175
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
4176
+ cachedClearTimeout = clearTimeout;
4177
+ return clearTimeout(marker);
4178
+ }
4179
+ try {
4180
+ // when when somebody has screwed with setTimeout but no I.E. maddness
4181
+ return cachedClearTimeout(marker);
4182
+ } catch (e){
4183
+ try {
4184
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
4185
+ return cachedClearTimeout.call(null, marker);
4186
+ } catch (e){
4187
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
4188
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
4189
+ return cachedClearTimeout.call(this, marker);
4190
+ }
4191
+ }
4192
+
4193
+
4194
+
4195
+ }
4196
+ var queue = [];
4197
+ var draining = false;
4198
+ var currentQueue;
4199
+ var queueIndex = -1;
4200
+
4201
+ function cleanUpNextTick() {
4202
+ if (!draining || !currentQueue) {
4203
+ return;
4204
+ }
4205
+ draining = false;
4206
+ if (currentQueue.length) {
4207
+ queue = currentQueue.concat(queue);
4208
+ } else {
4209
+ queueIndex = -1;
4210
+ }
4211
+ if (queue.length) {
4212
+ drainQueue();
4213
+ }
4214
+ }
4215
+
4216
+ function drainQueue() {
4217
+ if (draining) {
4218
+ return;
4219
+ }
4220
+ var timeout = runTimeout(cleanUpNextTick);
4221
+ draining = true;
4222
+
4223
+ var len = queue.length;
4224
+ while(len) {
4225
+ currentQueue = queue;
4226
+ queue = [];
4227
+ while (++queueIndex < len) {
4228
+ if (currentQueue) {
4229
+ currentQueue[queueIndex].run();
4230
+ }
4231
+ }
4232
+ queueIndex = -1;
4233
+ len = queue.length;
4234
+ }
4235
+ currentQueue = null;
4236
+ draining = false;
4237
+ runClearTimeout(timeout);
4238
+ }
4239
+ function nextTick(fun) {
4240
+ var args = new Array(arguments.length - 1);
4241
+ if (arguments.length > 1) {
4242
+ for (var i = 1; i < arguments.length; i++) {
4243
+ args[i - 1] = arguments[i];
4244
+ }
4245
+ }
4246
+ queue.push(new Item(fun, args));
4247
+ if (queue.length === 1 && !draining) {
4248
+ runTimeout(drainQueue);
4249
+ }
4250
+ }
4251
+ // v8 likes predictible objects
4252
+ function Item(fun, array) {
4253
+ this.fun = fun;
4254
+ this.array = array;
4255
+ }
4256
+ Item.prototype.run = function () {
4257
+ this.fun.apply(null, this.array);
4258
+ };
4259
+ var title = 'browser';
4260
+ var platform = 'browser';
4261
+ var browser$1 = true;
4262
+ var env = {};
4263
+ var argv = [];
4264
+ var version = ''; // empty string to avoid regexp issues
4265
+ var versions = {};
4266
+ var release = {};
4267
+ var config = {};
4268
+
4269
+ function noop() {}
4270
+
4271
+ var on = noop;
4272
+ var addListener = noop;
4273
+ var once = noop;
4274
+ var off = noop;
4275
+ var removeListener = noop;
4276
+ var removeAllListeners = noop;
4277
+ var emit = noop;
4278
+
4279
+ function binding(name) {
4280
+ throw new Error('process.binding is not supported');
4281
+ }
4282
+
4283
+ function cwd () { return '/' }
4284
+ function chdir (dir) {
4285
+ throw new Error('process.chdir is not supported');
4286
+ }function umask() { return 0; }
4287
+
4288
+ // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
4289
+ var performance = global.performance || {};
4290
+ var performanceNow =
4291
+ performance.now ||
4292
+ performance.mozNow ||
4293
+ performance.msNow ||
4294
+ performance.oNow ||
4295
+ performance.webkitNow ||
4296
+ function(){ return (new Date()).getTime() };
4297
+
4298
+ // generate timestamp or delta
4299
+ // see http://nodejs.org/api/process.html#process_process_hrtime
4300
+ function hrtime(previousTimestamp){
4301
+ var clocktime = performanceNow.call(performance)*1e-3;
4302
+ var seconds = Math.floor(clocktime);
4303
+ var nanoseconds = Math.floor((clocktime%1)*1e9);
4304
+ if (previousTimestamp) {
4305
+ seconds = seconds - previousTimestamp[0];
4306
+ nanoseconds = nanoseconds - previousTimestamp[1];
4307
+ if (nanoseconds<0) {
4308
+ seconds--;
4309
+ nanoseconds += 1e9;
4310
+ }
4311
+ }
4312
+ return [seconds,nanoseconds]
4313
+ }
4314
+
4315
+ var startTime = new Date();
4316
+ function uptime() {
4317
+ var currentTime = new Date();
4318
+ var dif = currentTime - startTime;
4319
+ return dif / 1000;
4320
+ }
4321
+
4322
+ var process$1 = {
4323
+ nextTick: nextTick,
4324
+ title: title,
4325
+ browser: browser$1,
4326
+ env: env,
4327
+ argv: argv,
4328
+ version: version,
4329
+ versions: versions,
4330
+ on: on,
4331
+ addListener: addListener,
4332
+ once: once,
4333
+ off: off,
4334
+ removeListener: removeListener,
4335
+ removeAllListeners: removeAllListeners,
4336
+ emit: emit,
4337
+ binding: binding,
4338
+ cwd: cwd,
4339
+ chdir: chdir,
4340
+ umask: umask,
4341
+ hrtime: hrtime,
4342
+ platform: platform,
4343
+ release: release,
4344
+ config: config,
4345
+ uptime: uptime
4346
+ };
4347
+
4348
+ var inherits$1;
4349
+ if (typeof Object.create === 'function'){
4350
+ inherits$1 = function inherits(ctor, superCtor) {
4351
+ // implementation from standard node.js 'util' module
4352
+ ctor.super_ = superCtor;
4353
+ ctor.prototype = Object.create(superCtor.prototype, {
4354
+ constructor: {
4355
+ value: ctor,
4356
+ enumerable: false,
4357
+ writable: true,
4358
+ configurable: true
4359
+ }
4360
+ });
4361
+ };
4362
+ } else {
4363
+ inherits$1 = function inherits(ctor, superCtor) {
4364
+ ctor.super_ = superCtor;
4365
+ var TempCtor = function () {};
4366
+ TempCtor.prototype = superCtor.prototype;
4367
+ ctor.prototype = new TempCtor();
4368
+ ctor.prototype.constructor = ctor;
4369
+ };
4370
+ }
4371
+ var inherits$2 = inherits$1;
4372
+
4373
+ // Copyright Joyent, Inc. and other Node contributors.
4374
+ var formatRegExp = /%[sdj%]/g;
4375
+ function format(f) {
4376
+ if (!isString(f)) {
4377
+ var objects = [];
4378
+ for (var i = 0; i < arguments.length; i++) {
4379
+ objects.push(inspect(arguments[i]));
4380
+ }
4381
+ return objects.join(' ');
4382
+ }
4383
+
4384
+ var i = 1;
4385
+ var args = arguments;
4386
+ var len = args.length;
4387
+ var str = String(f).replace(formatRegExp, function(x) {
4388
+ if (x === '%%') return '%';
4389
+ if (i >= len) return x;
4390
+ switch (x) {
4391
+ case '%s': return String(args[i++]);
4392
+ case '%d': return Number(args[i++]);
4393
+ case '%j':
4394
+ try {
4395
+ return JSON.stringify(args[i++]);
4396
+ } catch (_) {
4397
+ return '[Circular]';
4398
+ }
4399
+ default:
4400
+ return x;
4401
+ }
4402
+ });
4403
+ for (var x = args[i]; i < len; x = args[++i]) {
4404
+ if (isNull(x) || !isObject(x)) {
4405
+ str += ' ' + x;
4406
+ } else {
4407
+ str += ' ' + inspect(x);
4408
+ }
4409
+ }
4410
+ return str;
4411
+ }
4412
+
4413
+ // Mark that a method should not be used.
4414
+ // Returns a modified function which warns once by default.
4415
+ // If --no-deprecation is set, then it is a no-op.
4416
+ function deprecate(fn, msg) {
4417
+ // Allow for deprecating things in the process of starting up.
4418
+ if (isUndefined(global.process)) {
4419
+ return function() {
4420
+ return deprecate(fn, msg).apply(this, arguments);
4421
+ };
4422
+ }
4423
+
4424
+ var warned = false;
4425
+ function deprecated() {
4426
+ if (!warned) {
4427
+ {
4428
+ console.error(msg);
4429
+ }
4430
+ warned = true;
4431
+ }
4432
+ return fn.apply(this, arguments);
4433
+ }
4434
+
4435
+ return deprecated;
4436
+ }
4437
+
4438
+ var debugs = {};
4439
+ var debugEnviron;
4440
+ function debuglog(set) {
4441
+ if (isUndefined(debugEnviron))
4442
+ debugEnviron = process$1.env.NODE_DEBUG || '';
4443
+ set = set.toUpperCase();
4444
+ if (!debugs[set]) {
4445
+ if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
4446
+ var pid = 0;
4447
+ debugs[set] = function() {
4448
+ var msg = format.apply(null, arguments);
4449
+ console.error('%s %d: %s', set, pid, msg);
4450
+ };
4451
+ } else {
4452
+ debugs[set] = function() {};
4453
+ }
4454
+ }
4455
+ return debugs[set];
4456
+ }
4457
+
4458
+ /**
4459
+ * Echos the value of a value. Trys to print the value out
4460
+ * in the best way possible given the different types.
4461
+ *
4462
+ * @param {Object} obj The object to print out.
4463
+ * @param {Object} opts Optional options object that alters the output.
4464
+ */
4465
+ /* legacy: obj, showHidden, depth, colors*/
4466
+ function inspect(obj, opts) {
4467
+ // default options
4468
+ var ctx = {
4469
+ seen: [],
4470
+ stylize: stylizeNoColor
4471
+ };
4472
+ // legacy...
4473
+ if (arguments.length >= 3) ctx.depth = arguments[2];
4474
+ if (arguments.length >= 4) ctx.colors = arguments[3];
4475
+ if (isBoolean(opts)) {
4476
+ // legacy...
4477
+ ctx.showHidden = opts;
4478
+ } else if (opts) {
4479
+ // got an "options" object
4480
+ _extend(ctx, opts);
4481
+ }
4482
+ // set default options
4483
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
4484
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
4485
+ if (isUndefined(ctx.colors)) ctx.colors = false;
4486
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
4487
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
4488
+ return formatValue(ctx, obj, ctx.depth);
4489
+ }
4490
+
4491
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
4492
+ inspect.colors = {
4493
+ 'bold' : [1, 22],
4494
+ 'italic' : [3, 23],
4495
+ 'underline' : [4, 24],
4496
+ 'inverse' : [7, 27],
4497
+ 'white' : [37, 39],
4498
+ 'grey' : [90, 39],
4499
+ 'black' : [30, 39],
4500
+ 'blue' : [34, 39],
4501
+ 'cyan' : [36, 39],
4502
+ 'green' : [32, 39],
4503
+ 'magenta' : [35, 39],
4504
+ 'red' : [31, 39],
4505
+ 'yellow' : [33, 39]
4506
+ };
4507
+
4508
+ // Don't use 'blue' not visible on cmd.exe
4509
+ inspect.styles = {
4510
+ 'special': 'cyan',
4511
+ 'number': 'yellow',
4512
+ 'boolean': 'yellow',
4513
+ 'undefined': 'grey',
4514
+ 'null': 'bold',
4515
+ 'string': 'green',
4516
+ 'date': 'magenta',
4517
+ // "name": intentionally not styling
4518
+ 'regexp': 'red'
4519
+ };
4520
+
4521
+
4522
+ function stylizeWithColor(str, styleType) {
4523
+ var style = inspect.styles[styleType];
4524
+
4525
+ if (style) {
4526
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str +
4527
+ '\u001b[' + inspect.colors[style][1] + 'm';
4528
+ } else {
4529
+ return str;
4530
+ }
4531
+ }
4532
+
4533
+
4534
+ function stylizeNoColor(str, styleType) {
4535
+ return str;
4536
+ }
4537
+
4538
+
4539
+ function arrayToHash(array) {
4540
+ var hash = {};
4541
+
4542
+ array.forEach(function(val, idx) {
4543
+ hash[val] = true;
4544
+ });
4545
+
4546
+ return hash;
4547
+ }
4548
+
4549
+
4550
+ function formatValue(ctx, value, recurseTimes) {
4551
+ // Provide a hook for user-specified inspect functions.
4552
+ // Check that value is an object with an inspect function on it
4553
+ if (ctx.customInspect &&
4554
+ value &&
4555
+ isFunction(value.inspect) &&
4556
+ // Filter out the util module, it's inspect function is special
4557
+ value.inspect !== inspect &&
4558
+ // Also filter out any prototype objects using the circular check.
4559
+ !(value.constructor && value.constructor.prototype === value)) {
4560
+ var ret = value.inspect(recurseTimes, ctx);
4561
+ if (!isString(ret)) {
4562
+ ret = formatValue(ctx, ret, recurseTimes);
4563
+ }
4564
+ return ret;
4565
+ }
4566
+
4567
+ // Primitive types cannot have properties
4568
+ var primitive = formatPrimitive(ctx, value);
4569
+ if (primitive) {
4570
+ return primitive;
4571
+ }
4572
+
4573
+ // Look up the keys of the object.
4574
+ var keys = Object.keys(value);
4575
+ var visibleKeys = arrayToHash(keys);
4576
+
4577
+ if (ctx.showHidden) {
4578
+ keys = Object.getOwnPropertyNames(value);
4579
+ }
4580
+
4581
+ // IE doesn't make error fields non-enumerable
4582
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
4583
+ if (isError(value)
4584
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
4585
+ return formatError(value);
4586
+ }
4587
+
4588
+ // Some type of object without properties can be shortcutted.
4589
+ if (keys.length === 0) {
4590
+ if (isFunction(value)) {
4591
+ var name = value.name ? ': ' + value.name : '';
4592
+ return ctx.stylize('[Function' + name + ']', 'special');
4593
+ }
4594
+ if (isRegExp(value)) {
4595
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4596
+ }
4597
+ if (isDate(value)) {
4598
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
4599
+ }
4600
+ if (isError(value)) {
4601
+ return formatError(value);
4602
+ }
4603
+ }
4604
+
4605
+ var base = '', array = false, braces = ['{', '}'];
4606
+
4607
+ // Make Array say that they are Array
4608
+ if (isArray$1(value)) {
4609
+ array = true;
4610
+ braces = ['[', ']'];
4611
+ }
4612
+
4613
+ // Make functions say that they are functions
4614
+ if (isFunction(value)) {
4615
+ var n = value.name ? ': ' + value.name : '';
4616
+ base = ' [Function' + n + ']';
4617
+ }
4618
+
4619
+ // Make RegExps say that they are RegExps
4620
+ if (isRegExp(value)) {
4621
+ base = ' ' + RegExp.prototype.toString.call(value);
4622
+ }
4623
+
4624
+ // Make dates with properties first say the date
4625
+ if (isDate(value)) {
4626
+ base = ' ' + Date.prototype.toUTCString.call(value);
4627
+ }
4628
+
4629
+ // Make error with message first say the error
4630
+ if (isError(value)) {
4631
+ base = ' ' + formatError(value);
4632
+ }
4633
+
4634
+ if (keys.length === 0 && (!array || value.length == 0)) {
4635
+ return braces[0] + base + braces[1];
4636
+ }
4637
+
4638
+ if (recurseTimes < 0) {
4639
+ if (isRegExp(value)) {
4640
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4641
+ } else {
4642
+ return ctx.stylize('[Object]', 'special');
4643
+ }
4644
+ }
4645
+
4646
+ ctx.seen.push(value);
4647
+
4648
+ var output;
4649
+ if (array) {
4650
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
4651
+ } else {
4652
+ output = keys.map(function(key) {
4653
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
4654
+ });
4655
+ }
4656
+
4657
+ ctx.seen.pop();
4658
+
4659
+ return reduceToSingleString(output, base, braces);
4660
+ }
4661
+
4662
+
4663
+ function formatPrimitive(ctx, value) {
4664
+ if (isUndefined(value))
4665
+ return ctx.stylize('undefined', 'undefined');
4666
+ if (isString(value)) {
4667
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
4668
+ .replace(/'/g, "\\'")
4669
+ .replace(/\\"/g, '"') + '\'';
4670
+ return ctx.stylize(simple, 'string');
4671
+ }
4672
+ if (isNumber(value))
4673
+ return ctx.stylize('' + value, 'number');
4674
+ if (isBoolean(value))
4675
+ return ctx.stylize('' + value, 'boolean');
4676
+ // For some reason typeof null is "object", so special case here.
4677
+ if (isNull(value))
4678
+ return ctx.stylize('null', 'null');
4679
+ }
4680
+
4681
+
4682
+ function formatError(value) {
4683
+ return '[' + Error.prototype.toString.call(value) + ']';
4684
+ }
4685
+
4686
+
4687
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
4688
+ var output = [];
4689
+ for (var i = 0, l = value.length; i < l; ++i) {
4690
+ if (hasOwnProperty(value, String(i))) {
4691
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4692
+ String(i), true));
4693
+ } else {
4694
+ output.push('');
4695
+ }
4696
+ }
4697
+ keys.forEach(function(key) {
4698
+ if (!key.match(/^\d+$/)) {
4699
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4700
+ key, true));
4701
+ }
4702
+ });
4703
+ return output;
4704
+ }
4705
+
4706
+
4707
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
4708
+ var name, str, desc;
4709
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
4710
+ if (desc.get) {
4711
+ if (desc.set) {
4712
+ str = ctx.stylize('[Getter/Setter]', 'special');
4713
+ } else {
4714
+ str = ctx.stylize('[Getter]', 'special');
4715
+ }
4716
+ } else {
4717
+ if (desc.set) {
4718
+ str = ctx.stylize('[Setter]', 'special');
4719
+ }
4720
+ }
4721
+ if (!hasOwnProperty(visibleKeys, key)) {
4722
+ name = '[' + key + ']';
4723
+ }
4724
+ if (!str) {
4725
+ if (ctx.seen.indexOf(desc.value) < 0) {
4726
+ if (isNull(recurseTimes)) {
4727
+ str = formatValue(ctx, desc.value, null);
4728
+ } else {
4729
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
4730
+ }
4731
+ if (str.indexOf('\n') > -1) {
4732
+ if (array) {
4733
+ str = str.split('\n').map(function(line) {
4734
+ return ' ' + line;
4735
+ }).join('\n').substr(2);
4736
+ } else {
4737
+ str = '\n' + str.split('\n').map(function(line) {
4738
+ return ' ' + line;
4739
+ }).join('\n');
4740
+ }
4741
+ }
4742
+ } else {
4743
+ str = ctx.stylize('[Circular]', 'special');
4744
+ }
4745
+ }
4746
+ if (isUndefined(name)) {
4747
+ if (array && key.match(/^\d+$/)) {
4748
+ return str;
4749
+ }
4750
+ name = JSON.stringify('' + key);
4751
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
4752
+ name = name.substr(1, name.length - 2);
4753
+ name = ctx.stylize(name, 'name');
4754
+ } else {
4755
+ name = name.replace(/'/g, "\\'")
4756
+ .replace(/\\"/g, '"')
4757
+ .replace(/(^"|"$)/g, "'");
4758
+ name = ctx.stylize(name, 'string');
4759
+ }
4760
+ }
4761
+
4762
+ return name + ': ' + str;
4763
+ }
4764
+
4765
+
4766
+ function reduceToSingleString(output, base, braces) {
4767
+ var length = output.reduce(function(prev, cur) {
4768
+ if (cur.indexOf('\n') >= 0) ;
4769
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
4770
+ }, 0);
4771
+
4772
+ if (length > 60) {
4773
+ return braces[0] +
4774
+ (base === '' ? '' : base + '\n ') +
4775
+ ' ' +
4776
+ output.join(',\n ') +
4777
+ ' ' +
4778
+ braces[1];
4779
+ }
4780
+
4781
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
4782
+ }
4783
+
4784
+
4785
+ // NOTE: These type checking functions intentionally don't use `instanceof`
4786
+ // because it is fragile and can be easily faked with `Object.create()`.
4787
+ function isArray$1(ar) {
4788
+ return Array.isArray(ar);
4789
+ }
4790
+
4791
+ function isBoolean(arg) {
4792
+ return typeof arg === 'boolean';
4793
+ }
4794
+
4795
+ function isNull(arg) {
4796
+ return arg === null;
4797
+ }
4798
+
4799
+ function isNullOrUndefined(arg) {
4800
+ return arg == null;
4801
+ }
4802
+
4803
+ function isNumber(arg) {
4804
+ return typeof arg === 'number';
4805
+ }
4806
+
4807
+ function isString(arg) {
4808
+ return typeof arg === 'string';
4809
+ }
4810
+
4811
+ function isSymbol(arg) {
4812
+ return typeof arg === 'symbol';
4813
+ }
4814
+
4815
+ function isUndefined(arg) {
4816
+ return arg === void 0;
4817
+ }
4818
+
4819
+ function isRegExp(re) {
4820
+ return isObject(re) && objectToString(re) === '[object RegExp]';
4821
+ }
4822
+
4823
+ function isObject(arg) {
4824
+ return typeof arg === 'object' && arg !== null;
4825
+ }
4826
+
4827
+ function isDate(d) {
4828
+ return isObject(d) && objectToString(d) === '[object Date]';
4829
+ }
4830
+
4831
+ function isError(e) {
4832
+ return isObject(e) &&
4833
+ (objectToString(e) === '[object Error]' || e instanceof Error);
4834
+ }
4835
+
4836
+ function isFunction(arg) {
4837
+ return typeof arg === 'function';
4838
+ }
4839
+
4840
+ function isPrimitive(arg) {
4841
+ return arg === null ||
4842
+ typeof arg === 'boolean' ||
4843
+ typeof arg === 'number' ||
4844
+ typeof arg === 'string' ||
4845
+ typeof arg === 'symbol' || // ES6 symbol
4846
+ typeof arg === 'undefined';
4847
+ }
4848
+
4849
+ function isBuffer(maybeBuf) {
4850
+ return Buffer.isBuffer(maybeBuf);
4851
+ }
4852
+
4853
+ function objectToString(o) {
4854
+ return Object.prototype.toString.call(o);
4855
+ }
4856
+
4857
+
4858
+ function pad(n) {
4859
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
4860
+ }
4861
+
4862
+
4863
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
4864
+ 'Oct', 'Nov', 'Dec'];
4865
+
4866
+ // 26 Feb 16:19:34
4867
+ function timestamp() {
4868
+ var d = new Date();
4869
+ var time = [pad(d.getHours()),
4870
+ pad(d.getMinutes()),
4871
+ pad(d.getSeconds())].join(':');
4872
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
4873
+ }
4874
+
4875
+
4876
+ // log is just a thin wrapper to console.log that prepends a timestamp
4877
+ function log() {
4878
+ console.log('%s - %s', timestamp(), format.apply(null, arguments));
4879
+ }
4880
+
4881
+ function _extend(origin, add) {
4882
+ // Don't do anything if add isn't an object
4883
+ if (!add || !isObject(add)) return origin;
4884
+
4885
+ var keys = Object.keys(add);
4886
+ var i = keys.length;
4887
+ while (i--) {
4888
+ origin[keys[i]] = add[keys[i]];
4889
+ }
4890
+ return origin;
4891
+ }
4892
+ function hasOwnProperty(obj, prop) {
4893
+ return Object.prototype.hasOwnProperty.call(obj, prop);
4894
+ }
4895
+
4896
+ var util = {
4897
+ inherits: inherits$2,
4898
+ _extend: _extend,
4899
+ log: log,
4900
+ isBuffer: isBuffer,
4901
+ isPrimitive: isPrimitive,
4902
+ isFunction: isFunction,
4903
+ isError: isError,
4904
+ isDate: isDate,
4905
+ isObject: isObject,
4906
+ isRegExp: isRegExp,
4907
+ isUndefined: isUndefined,
4908
+ isSymbol: isSymbol,
4909
+ isString: isString,
4910
+ isNumber: isNumber,
4911
+ isNullOrUndefined: isNullOrUndefined,
4912
+ isNull: isNull,
4913
+ isBoolean: isBoolean,
4914
+ isArray: isArray$1,
4915
+ inspect: inspect,
4916
+ deprecate: deprecate,
4917
+ format: format,
4918
+ debuglog: debuglog
4919
+ };
4920
+
4921
+ var require$$2 = {};
4922
+
4923
+ var node = createCommonjsModule(function (module, exports) {
4924
+ /**
4925
+ * Module dependencies.
4926
+ */
4927
+
4928
+
4929
+
4930
+
4931
+ /**
4932
+ * This is the Node.js implementation of `debug()`.
4933
+ *
4934
+ * Expose `debug()` as the module.
4935
+ */
4936
+
4937
+ exports = module.exports = debug;
4938
+ exports.init = init;
4939
+ exports.log = log;
4940
+ exports.formatArgs = formatArgs;
4941
+ exports.save = save;
4942
+ exports.load = load;
4943
+ exports.useColors = useColors;
4944
+
4945
+ /**
4946
+ * Colors.
4947
+ */
4948
+
4949
+ exports.colors = [6, 2, 3, 4, 5, 1];
4950
+
4951
+ /**
4952
+ * Build up the default `inspectOpts` object from the environment variables.
4953
+ *
4954
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
4955
+ */
4956
+
4957
+ exports.inspectOpts = Object.keys(process.env).filter(function (key) {
4958
+ return /^debug_/i.test(key);
4959
+ }).reduce(function (obj, key) {
4960
+ // camel-case
4961
+ var prop = key
4962
+ .substring(6)
4963
+ .toLowerCase()
4964
+ .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
4965
+
4966
+ // coerce string value into JS value
4967
+ var val = process.env[key];
4968
+ if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
4969
+ else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
4970
+ else if (val === 'null') val = null;
4971
+ else val = Number(val);
4972
+
4973
+ obj[prop] = val;
4974
+ return obj;
4975
+ }, {});
4976
+
4977
+ /**
4978
+ * The file descriptor to write the `debug()` calls to.
4979
+ * Set the `DEBUG_FD` env variable to override with another value. i.e.:
4980
+ *
4981
+ * $ DEBUG_FD=3 node script.js 3>debug.log
4982
+ */
4983
+
4984
+ var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
4985
+
4986
+ if (1 !== fd && 2 !== fd) {
4987
+ util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
4988
+ }
4989
+
4990
+ var stream = 1 === fd ? process.stdout :
4991
+ 2 === fd ? process.stderr :
4992
+ createWritableStdioStream(fd);
4993
+
4994
+ /**
4995
+ * Is stdout a TTY? Colored output is enabled when `true`.
4996
+ */
4997
+
4998
+ function useColors() {
4999
+ return 'colors' in exports.inspectOpts
5000
+ ? Boolean(exports.inspectOpts.colors)
5001
+ : tty.isatty(fd);
5002
+ }
5003
+
5004
+ /**
5005
+ * Map %o to `util.inspect()`, all on a single line.
5006
+ */
5007
+
5008
+ exports.formatters.o = function(v) {
5009
+ this.inspectOpts.colors = this.useColors;
5010
+ return util.inspect(v, this.inspectOpts)
5011
+ .split('\n').map(function(str) {
5012
+ return str.trim()
5013
+ }).join(' ');
5014
+ };
5015
+
5016
+ /**
5017
+ * Map %o to `util.inspect()`, allowing multiple lines if needed.
5018
+ */
5019
+
5020
+ exports.formatters.O = function(v) {
5021
+ this.inspectOpts.colors = this.useColors;
5022
+ return util.inspect(v, this.inspectOpts);
5023
+ };
5024
+
5025
+ /**
5026
+ * Adds ANSI color escape codes if enabled.
5027
+ *
5028
+ * @api public
5029
+ */
5030
+
5031
+ function formatArgs(args) {
5032
+ var name = this.namespace;
5033
+ var useColors = this.useColors;
5034
+
5035
+ if (useColors) {
5036
+ var c = this.color;
5037
+ var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
5038
+
5039
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
5040
+ args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
5041
+ } else {
5042
+ args[0] = new Date().toUTCString()
5043
+ + ' ' + name + ' ' + args[0];
5044
+ }
5045
+ }
5046
+
5047
+ /**
5048
+ * Invokes `util.format()` with the specified arguments and writes to `stream`.
5049
+ */
5050
+
5051
+ function log() {
5052
+ return stream.write(util.format.apply(util, arguments) + '\n');
5053
+ }
5054
+
5055
+ /**
5056
+ * Save `namespaces`.
5057
+ *
5058
+ * @param {String} namespaces
5059
+ * @api private
5060
+ */
5061
+
5062
+ function save(namespaces) {
5063
+ if (null == namespaces) {
5064
+ // If you set a process.env field to null or undefined, it gets cast to the
5065
+ // string 'null' or 'undefined'. Just delete instead.
5066
+ delete process.env.DEBUG;
5067
+ } else {
5068
+ process.env.DEBUG = namespaces;
5069
+ }
5070
+ }
5071
+
5072
+ /**
5073
+ * Load `namespaces`.
5074
+ *
5075
+ * @return {String} returns the previously persisted debug modes
5076
+ * @api private
5077
+ */
5078
+
5079
+ function load() {
5080
+ return process.env.DEBUG;
5081
+ }
5082
+
5083
+ /**
5084
+ * Copied from `node/src/node.js`.
5085
+ *
5086
+ * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
5087
+ * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
5088
+ */
5089
+
5090
+ function createWritableStdioStream (fd) {
5091
+ var stream;
5092
+ var tty_wrap = process.binding('tty_wrap');
5093
+
5094
+ // Note stream._type is used for test-module-load-list.js
5095
+
5096
+ switch (tty_wrap.guessHandleType(fd)) {
5097
+ case 'TTY':
5098
+ stream = new tty.WriteStream(fd);
5099
+ stream._type = 'tty';
5100
+
5101
+ // Hack to have stream not keep the event loop alive.
5102
+ // See https://github.com/joyent/node/issues/1726
5103
+ if (stream._handle && stream._handle.unref) {
5104
+ stream._handle.unref();
5105
+ }
5106
+ break;
5107
+
5108
+ case 'FILE':
5109
+ var fs = require$$2;
5110
+ stream = new fs.SyncWriteStream(fd, { autoClose: false });
5111
+ stream._type = 'fs';
5112
+ break;
5113
+
5114
+ case 'PIPE':
5115
+ case 'TCP':
5116
+ var net = require$$2;
5117
+ stream = new net.Socket({
5118
+ fd: fd,
5119
+ readable: false,
5120
+ writable: true
5121
+ });
5122
+
5123
+ // FIXME Should probably have an option in net.Socket to create a
5124
+ // stream from an existing fd which is writable only. But for now
5125
+ // we'll just add this hack and set the `readable` member to false.
5126
+ // Test: ./node test/fixtures/echo.js < /etc/passwd
5127
+ stream.readable = false;
5128
+ stream.read = null;
5129
+ stream._type = 'pipe';
5130
+
5131
+ // FIXME Hack to have stream not keep the event loop alive.
5132
+ // See https://github.com/joyent/node/issues/1726
5133
+ if (stream._handle && stream._handle.unref) {
5134
+ stream._handle.unref();
5135
+ }
5136
+ break;
5137
+
5138
+ default:
5139
+ // Probably an error on in uv_guess_handle()
5140
+ throw new Error('Implement me. Unknown stream file type!');
5141
+ }
5142
+
5143
+ // For supporting legacy API we put the FD here.
5144
+ stream.fd = fd;
5145
+
5146
+ stream._isStdio = true;
5147
+
5148
+ return stream;
5149
+ }
5150
+
5151
+ /**
5152
+ * Init logic for `debug` instances.
5153
+ *
5154
+ * Create a new `inspectOpts` object in case `useColors` is set
5155
+ * differently for a particular `debug` instance.
5156
+ */
5157
+
5158
+ function init (debug$$1) {
5159
+ debug$$1.inspectOpts = {};
5160
+
5161
+ var keys = Object.keys(exports.inspectOpts);
5162
+ for (var i = 0; i < keys.length; i++) {
5163
+ debug$$1.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
5164
+ }
5165
+ }
5166
+
5167
+ /**
5168
+ * Enable namespaces listed in `process.env.DEBUG` initially.
5169
+ */
5170
+
5171
+ exports.enable(load());
5172
+ });
5173
+ var node_1 = node.init;
5174
+ var node_2 = node.log;
5175
+ var node_3 = node.formatArgs;
5176
+ var node_4 = node.save;
5177
+ var node_5 = node.load;
5178
+ var node_6 = node.useColors;
5179
+ var node_7 = node.colors;
5180
+ var node_8 = node.inspectOpts;
5181
+
5182
+ var src = createCommonjsModule(function (module) {
5183
+ /**
5184
+ * Detect Electron renderer process, which is node, but we should
5185
+ * treat as a browser.
5186
+ */
5187
+
5188
+ if (typeof process !== 'undefined' && process.type === 'renderer') {
5189
+ module.exports = browser;
5190
+ } else {
5191
+ module.exports = node;
5192
+ }
5193
+ });
5194
+
5195
+ var functionNames = createCommonjsModule(function (module, exports) {
5196
+
5197
+ Object.defineProperty(exports, "__esModule", {
5198
+ value: true
5199
+ });
5200
+
5201
+
5202
+ /**
5203
+ * @see https://developers.google.com/youtube/iframe_api_reference#Functions
5204
+ */
5205
+ exports.default = ['cueVideoById', 'loadVideoById', 'cueVideoByUrl', 'loadVideoByUrl', 'playVideo', 'pauseVideo', 'stopVideo', 'getVideoLoadedFraction', 'cuePlaylist', 'loadPlaylist', 'nextVideo', 'previousVideo', 'playVideoAt', 'setShuffle', 'setLoop', 'getPlaylist', 'getPlaylistIndex', 'setOption', 'mute', 'unMute', 'isMuted', 'setVolume', 'getVolume', 'seekTo', 'getPlayerState', 'getPlaybackRate', 'setPlaybackRate', 'getAvailablePlaybackRates', 'getPlaybackQuality', 'setPlaybackQuality', 'getAvailableQualityLevels', 'getCurrentTime', 'getDuration', 'removeEventListener', 'getVideoUrl', 'getVideoEmbedCode', 'getOptions', 'getOption', 'addEventListener', 'destroy', 'setSize', 'getIframe'];
5206
+ module.exports = exports['default'];
5207
+ });
5208
+
5209
+ unwrapExports(functionNames);
5210
+
5211
+ var eventNames = createCommonjsModule(function (module, exports) {
5212
+
5213
+ Object.defineProperty(exports, "__esModule", {
5214
+ value: true
5215
+ });
5216
+
5217
+
5218
+ /**
5219
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
5220
+ * `volumeChange` is not officially supported but seems to work
5221
+ * it emits an object: `{volume: 82.6923076923077, muted: false}`
5222
+ */
5223
+ exports.default = ['ready', 'stateChange', 'playbackQualityChange', 'playbackRateChange', 'error', 'apiChange', 'volumeChange'];
5224
+ module.exports = exports['default'];
5225
+ });
5226
+
5227
+ unwrapExports(eventNames);
5228
+
5229
+ var PlayerStates = createCommonjsModule(function (module, exports) {
5230
+
5231
+ Object.defineProperty(exports, "__esModule", {
5232
+ value: true
5233
+ });
5234
+ exports.default = {
5235
+ BUFFERING: 3,
5236
+ ENDED: 0,
5237
+ PAUSED: 2,
5238
+ PLAYING: 1,
5239
+ UNSTARTED: -1,
5240
+ VIDEO_CUED: 5
5241
+ };
5242
+ module.exports = exports["default"];
5243
+ });
5244
+
5245
+ unwrapExports(PlayerStates);
5246
+
5247
+ var FunctionStateMap = createCommonjsModule(function (module, exports) {
5248
+
5249
+ Object.defineProperty(exports, "__esModule", {
5250
+ value: true
5251
+ });
5252
+
5253
+
5254
+
5255
+ var _PlayerStates2 = _interopRequireDefault(PlayerStates);
5256
+
5257
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5258
+
5259
+ exports.default = {
5260
+ pauseVideo: {
5261
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PAUSED],
5262
+ stateChangeRequired: false
5263
+ },
5264
+ playVideo: {
5265
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING],
5266
+ stateChangeRequired: false
5267
+ },
5268
+ seekTo: {
5269
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING, _PlayerStates2.default.PAUSED],
5270
+ stateChangeRequired: true,
5271
+
5272
+ // TRICKY: `seekTo` may not cause a state change if no buffering is
5273
+ // required.
5274
+ timeout: 3000
5275
+ }
5276
+ };
5277
+ module.exports = exports['default'];
5278
+ });
5279
+
5280
+ unwrapExports(FunctionStateMap);
5281
+
5282
+ var YouTubePlayer_1 = createCommonjsModule(function (module, exports) {
5283
+
5284
+ Object.defineProperty(exports, "__esModule", {
5285
+ value: true
5286
+ });
5287
+
5288
+
5289
+
5290
+ var _debug2 = _interopRequireDefault(src);
5291
+
5292
+
5293
+
5294
+ var _functionNames2 = _interopRequireDefault(functionNames);
5295
+
5296
+
5297
+
5298
+ var _eventNames2 = _interopRequireDefault(eventNames);
5299
+
5300
+
5301
+
5302
+ var _FunctionStateMap2 = _interopRequireDefault(FunctionStateMap);
5303
+
5304
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5305
+
5306
+ /* eslint-disable promise/prefer-await-to-then */
5307
+
5308
+ var debug = (0, _debug2.default)('youtube-player');
5309
+
5310
+ var YouTubePlayer = {};
5311
+
5312
+ /**
5313
+ * Construct an object that defines an event handler for all of the YouTube
5314
+ * player events. Proxy captured events through an event emitter.
5315
+ *
5316
+ * @todo Capture event parameters.
5317
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
5318
+ */
5319
+ YouTubePlayer.proxyEvents = function (emitter) {
5320
+ var events = {};
5321
+
5322
+ var _loop = function _loop(eventName) {
5323
+ var onEventName = 'on' + eventName.slice(0, 1).toUpperCase() + eventName.slice(1);
5324
+
5325
+ events[onEventName] = function (event) {
5326
+ debug('event "%s"', onEventName, event);
5327
+
5328
+ emitter.trigger(eventName, event);
5329
+ };
5330
+ };
5331
+
5332
+ var _iteratorNormalCompletion = true;
5333
+ var _didIteratorError = false;
5334
+ var _iteratorError = undefined;
5335
+
5336
+ try {
5337
+ for (var _iterator = _eventNames2.default[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
5338
+ var eventName = _step.value;
5339
+
5340
+ _loop(eventName);
5341
+ }
5342
+ } catch (err) {
5343
+ _didIteratorError = true;
5344
+ _iteratorError = err;
5345
+ } finally {
5346
+ try {
5347
+ if (!_iteratorNormalCompletion && _iterator.return) {
5348
+ _iterator.return();
5349
+ }
5350
+ } finally {
5351
+ if (_didIteratorError) {
5352
+ throw _iteratorError;
5353
+ }
5354
+ }
5355
+ }
5356
+
5357
+ return events;
5358
+ };
5359
+
5360
+ /**
5361
+ * Delays player API method execution until player state is ready.
5362
+ *
5363
+ * @todo Proxy all of the methods using Object.keys.
5364
+ * @todo See TRICKY below.
5365
+ * @param playerAPIReady Promise that resolves when player is ready.
5366
+ * @param strictState A flag designating whether or not to wait for
5367
+ * an acceptable state when calling supported functions.
5368
+ * @returns {Object}
5369
+ */
5370
+ YouTubePlayer.promisifyPlayer = function (playerAPIReady) {
5371
+ var strictState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5372
+
5373
+ var functions = {};
5374
+
5375
+ var _loop2 = function _loop2(functionName) {
5376
+ if (strictState && _FunctionStateMap2.default[functionName]) {
5377
+ functions[functionName] = function () {
5378
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
5379
+ args[_key] = arguments[_key];
5380
+ }
5381
+
5382
+ return playerAPIReady.then(function (player) {
5383
+ var stateInfo = _FunctionStateMap2.default[functionName];
5384
+ var playerState = player.getPlayerState();
5385
+
5386
+ // eslint-disable-next-line no-warning-comments
5387
+ // TODO: Just spread the args into the function once Babel is fixed:
5388
+ // https://github.com/babel/babel/issues/4270
5389
+ //
5390
+ // eslint-disable-next-line prefer-spread
5391
+ var value = player[functionName].apply(player, args);
5392
+
5393
+ // TRICKY: For functions like `seekTo`, a change in state must be
5394
+ // triggered given that the resulting state could match the initial
5395
+ // state.
5396
+ if (stateInfo.stateChangeRequired ||
5397
+
5398
+ // eslint-disable-next-line no-extra-parens
5399
+ Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerState) === -1) {
5400
+ return new Promise(function (resolve) {
5401
+ var onPlayerStateChange = function onPlayerStateChange() {
5402
+ var playerStateAfterChange = player.getPlayerState();
5403
+
5404
+ var timeout = void 0;
5405
+
5406
+ if (typeof stateInfo.timeout === 'number') {
5407
+ timeout = setTimeout(function () {
5408
+ player.removeEventListener('onStateChange', onPlayerStateChange);
5409
+
5410
+ resolve();
5411
+ }, stateInfo.timeout);
5412
+ }
5413
+
5414
+ if (Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerStateAfterChange) !== -1) {
5415
+ player.removeEventListener('onStateChange', onPlayerStateChange);
5416
+
5417
+ clearTimeout(timeout);
5418
+
5419
+ resolve();
5420
+ }
5421
+ };
5422
+
5423
+ player.addEventListener('onStateChange', onPlayerStateChange);
5424
+ }).then(function () {
5425
+ return value;
5426
+ });
5427
+ }
5428
+
5429
+ return value;
5430
+ });
5431
+ };
5432
+ } else {
5433
+ functions[functionName] = function () {
5434
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5435
+ args[_key2] = arguments[_key2];
5436
+ }
5437
+
5438
+ return playerAPIReady.then(function (player) {
5439
+ // eslint-disable-next-line no-warning-comments
5440
+ // TODO: Just spread the args into the function once Babel is fixed:
5441
+ // https://github.com/babel/babel/issues/4270
5442
+ //
5443
+ // eslint-disable-next-line prefer-spread
5444
+ return player[functionName].apply(player, args);
5445
+ });
5446
+ };
5447
+ }
5448
+ };
5449
+
5450
+ var _iteratorNormalCompletion2 = true;
5451
+ var _didIteratorError2 = false;
5452
+ var _iteratorError2 = undefined;
5453
+
5454
+ try {
5455
+ for (var _iterator2 = _functionNames2.default[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
5456
+ var functionName = _step2.value;
5457
+
5458
+ _loop2(functionName);
5459
+ }
5460
+ } catch (err) {
5461
+ _didIteratorError2 = true;
5462
+ _iteratorError2 = err;
5463
+ } finally {
5464
+ try {
5465
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
5466
+ _iterator2.return();
5467
+ }
5468
+ } finally {
5469
+ if (_didIteratorError2) {
5470
+ throw _iteratorError2;
5471
+ }
5472
+ }
5473
+ }
5474
+
5475
+ return functions;
5476
+ };
5477
+
5478
+ exports.default = YouTubePlayer;
5479
+ module.exports = exports['default'];
5480
+ });
5481
+
5482
+ unwrapExports(YouTubePlayer_1);
5483
+
5484
+ var dist = createCommonjsModule(function (module, exports) {
5485
+
5486
+ Object.defineProperty(exports, "__esModule", {
5487
+ value: true
5488
+ });
5489
+
5490
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
5491
+
5492
+
5493
+
5494
+ var _sister2 = _interopRequireDefault(sister);
5495
+
5496
+
5497
+
5498
+ var _loadYouTubeIframeApi2 = _interopRequireDefault(loadYouTubeIframeApi);
5499
+
5500
+
5501
+
5502
+ var _YouTubePlayer2 = _interopRequireDefault(YouTubePlayer_1);
5503
+
5504
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5505
+
5506
+ /**
5507
+ * @typedef YT.Player
5508
+ * @see https://developers.google.com/youtube/iframe_api_reference
5509
+ * */
5510
+
5511
+ /**
5512
+ * @see https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
5513
+ */
5514
+ var youtubeIframeAPI = void 0;
5515
+
5516
+ /**
5517
+ * A factory function used to produce an instance of YT.Player and queue function calls and proxy events of the resulting object.
5518
+ *
5519
+ * @param maybeElementId Either An existing YT.Player instance,
5520
+ * the DOM element or the id of the HTML element where the API will insert an <iframe>.
5521
+ * @param options See `options` (Ignored when using an existing YT.Player instance).
5522
+ * @param strictState A flag designating whether or not to wait for
5523
+ * an acceptable state when calling supported functions. Default: `false`.
5524
+ * See `FunctionStateMap.js` for supported functions and acceptable states.
5525
+ */
5526
+
5527
+ exports.default = function (maybeElementId) {
5528
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5529
+ var strictState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5530
+
5531
+ var emitter = (0, _sister2.default)();
5532
+
5533
+ if (!youtubeIframeAPI) {
5534
+ youtubeIframeAPI = (0, _loadYouTubeIframeApi2.default)(emitter);
5535
+ }
5536
+
5537
+ if (options.events) {
5538
+ throw new Error('Event handlers cannot be overwritten.');
5539
+ }
5540
+
5541
+ if (typeof maybeElementId === 'string' && !document.getElementById(maybeElementId)) {
5542
+ throw new Error('Element "' + maybeElementId + '" does not exist.');
5543
+ }
5544
+
5545
+ options.events = _YouTubePlayer2.default.proxyEvents(emitter);
5546
+
5547
+ var playerAPIReady = new Promise(function (resolve) {
5548
+ if ((typeof maybeElementId === 'undefined' ? 'undefined' : _typeof(maybeElementId)) === 'object' && maybeElementId.playVideo instanceof Function) {
5549
+ var player = maybeElementId;
5550
+
5551
+ resolve(player);
5552
+ } else {
5553
+ // asume maybeElementId can be rendered inside
5554
+ // eslint-disable-next-line promise/catch-or-return
5555
+ youtubeIframeAPI.then(function (YT) {
5556
+ // eslint-disable-line promise/prefer-await-to-then
5557
+ var player = new YT.Player(maybeElementId, options);
5558
+
5559
+ emitter.on('ready', function () {
5560
+ resolve(player);
5561
+ });
5562
+
5563
+ return null;
5564
+ });
5565
+ }
5566
+ });
5567
+
5568
+ var playerApi = _YouTubePlayer2.default.promisifyPlayer(playerAPIReady, strictState);
5569
+
5570
+ playerApi.on = emitter.on;
5571
+ playerApi.off = emitter.off;
5572
+
5573
+ return playerApi;
5574
+ };
5575
+
5576
+ module.exports = exports['default'];
5577
+ });
5578
+
5579
+ var youTubePlayer = unwrapExports(dist);
5580
+
5581
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5582
+
5583
+ var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
5584
+
5585
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5586
+
5587
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
5588
+
5589
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
5590
+
5591
+ /**
5592
+ * Check whether a `props` change should result in the video being updated.
5593
+ *
5594
+ * @param {Object} prevProps
5595
+ * @param {Object} props
5596
+ */
5597
+ function shouldUpdateVideo(prevProps, props) {
5598
+ // A changing video should always trigger an update
5599
+ if (prevProps.videoId !== props.videoId) {
5600
+ return true;
5601
+ }
5602
+
5603
+ // Otherwise, a change in the start/end time playerVars also requires a player
5604
+ // update.
5605
+ var prevVars = prevProps.opts.playerVars || {};
5606
+ var vars = props.opts.playerVars || {};
5607
+
5608
+ return prevVars.start !== vars.start || prevVars.end !== vars.end;
5609
+ }
5610
+
5611
+ /**
5612
+ * Neutralise API options that only require a video update, leaving only options
5613
+ * that require a player reset. The results can then be compared to see if a
5614
+ * player reset is necessary.
5615
+ *
5616
+ * @param {Object} opts
5617
+ */
5618
+ function filterResetOptions(opts) {
5619
+ return _extends$1({}, opts, {
5620
+ playerVars: _extends$1({}, opts.playerVars, {
5621
+ autoplay: 0,
5622
+ start: 0,
5623
+ end: 0
5624
+ })
5625
+ });
5626
+ }
5627
+
5628
+ /**
5629
+ * Check whether a `props` change should result in the player being reset.
5630
+ * The player is reset when the `props.opts` change, except if the only change
5631
+ * is in the `start` and `end` playerVars, because a video update can deal with
5632
+ * those.
5633
+ *
5634
+ * @param {Object} prevProps
5635
+ * @param {Object} props
5636
+ */
5637
+ function shouldResetPlayer(prevProps, props) {
5638
+ return !fastDeepEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts));
5639
+ }
5640
+
5641
+ /**
5642
+ * Check whether a props change should result in an id or className update.
5643
+ *
5644
+ * @param {Object} prevProps
5645
+ * @param {Object} props
5646
+ */
5647
+ function shouldUpdatePlayer(prevProps, props) {
5648
+ return prevProps.id !== props.id || prevProps.className !== props.className;
5649
+ }
5650
+
5651
+ var YouTube = function (_React$Component) {
5652
+ _inherits(YouTube, _React$Component);
5653
+
5654
+ function YouTube(props) {
5655
+ _classCallCheck(this, YouTube);
5656
+
5657
+ var _this = _possibleConstructorReturn(this, (YouTube.__proto__ || Object.getPrototypeOf(YouTube)).call(this, props));
5658
+
5659
+ _this.onPlayerReady = function (event) {
5660
+ return _this.props.onReady(event);
5661
+ };
5662
+
5663
+ _this.onPlayerError = function (event) {
5664
+ return _this.props.onError(event);
5665
+ };
5666
+
5667
+ _this.onPlayerStateChange = function (event) {
5668
+ _this.props.onStateChange(event);
5669
+ switch (event.data) {
5670
+
5671
+ case YouTube.PlayerState.ENDED:
5672
+ _this.props.onEnd(event);
5673
+ break;
5674
+
5675
+ case YouTube.PlayerState.PLAYING:
5676
+ _this.props.onPlay(event);
5677
+ break;
5678
+
5679
+ case YouTube.PlayerState.PAUSED:
5680
+ _this.props.onPause(event);
5681
+ break;
5682
+
5683
+ default:
5684
+ }
5685
+ };
5686
+
5687
+ _this.onPlayerPlaybackRateChange = function (event) {
5688
+ return _this.props.onPlaybackRateChange(event);
5689
+ };
5690
+
5691
+ _this.onPlayerPlaybackQualityChange = function (event) {
5692
+ return _this.props.onPlaybackQualityChange(event);
5693
+ };
5694
+
5695
+ _this.createPlayer = function () {
5696
+ // do not attempt to create a player server-side, it won't work
5697
+ if (typeof document === 'undefined') return;
5698
+ // create player
5699
+ var playerOpts = _extends$1({}, _this.props.opts, {
5700
+ // preload the `videoId` video if one is already given
5701
+ videoId: _this.props.videoId
5702
+ });
5703
+ _this.internalPlayer = youTubePlayer(_this.container, playerOpts);
5704
+ // attach event handlers
5705
+ _this.internalPlayer.on('ready', _this.onPlayerReady);
5706
+ _this.internalPlayer.on('error', _this.onPlayerError);
5707
+ _this.internalPlayer.on('stateChange', _this.onPlayerStateChange);
5708
+ _this.internalPlayer.on('playbackRateChange', _this.onPlayerPlaybackRateChange);
5709
+ _this.internalPlayer.on('playbackQualityChange', _this.onPlayerPlaybackQualityChange);
5710
+ };
5711
+
5712
+ _this.resetPlayer = function () {
5713
+ return _this.internalPlayer.destroy().then(_this.createPlayer);
5714
+ };
5715
+
5716
+ _this.updatePlayer = function () {
5717
+ _this.internalPlayer.getIframe().then(function (iframe) {
5718
+ if (_this.props.id) iframe.setAttribute('id', _this.props.id);else iframe.removeAttribute('id');
5719
+ if (_this.props.className) iframe.setAttribute('class', _this.props.className);else iframe.removeAttribute('class');
5720
+ });
5721
+ };
5722
+
5723
+ _this.updateVideo = function () {
5724
+ if (typeof _this.props.videoId === 'undefined' || _this.props.videoId === null) {
5725
+ _this.internalPlayer.stopVideo();
5726
+ return;
5727
+ }
5728
+
5729
+ // set queueing options
5730
+ var autoplay = false;
5731
+ var opts = {
5732
+ videoId: _this.props.videoId
5733
+ };
5734
+ if ('playerVars' in _this.props.opts) {
5735
+ autoplay = _this.props.opts.playerVars.autoplay === 1;
5736
+ if ('start' in _this.props.opts.playerVars) {
5737
+ opts.startSeconds = _this.props.opts.playerVars.start;
5738
+ }
5739
+ if ('end' in _this.props.opts.playerVars) {
5740
+ opts.endSeconds = _this.props.opts.playerVars.end;
5741
+ }
5742
+ }
5743
+
5744
+ // if autoplay is enabled loadVideoById
5745
+ if (autoplay) {
5746
+ _this.internalPlayer.loadVideoById(opts);
5747
+ return;
5748
+ }
5749
+ // default behaviour just cues the video
5750
+ _this.internalPlayer.cueVideoById(opts);
5751
+ };
5752
+
5753
+ _this.refContainer = function (container) {
5754
+ _this.container = container;
5755
+ };
5756
+
5757
+ _this.container = null;
5758
+ _this.internalPlayer = null;
5759
+ return _this;
5760
+ }
5761
+
5762
+ /**
5763
+ * Expose PlayerState constants for convenience. These constants can also be
5764
+ * accessed through the global YT object after the YouTube IFrame API is instantiated.
5765
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
5766
+ */
5767
+
5768
+
5769
+ _createClass(YouTube, [{
5770
+ key: 'componentDidMount',
5771
+ value: function componentDidMount() {
5772
+ this.createPlayer();
5773
+ }
5774
+ }, {
5775
+ key: 'componentDidUpdate',
5776
+ value: function componentDidUpdate(prevProps) {
5777
+ if (shouldUpdatePlayer(prevProps, this.props)) {
5778
+ this.updatePlayer();
5779
+ }
5780
+
5781
+ if (shouldResetPlayer(prevProps, this.props)) {
5782
+ this.resetPlayer();
5783
+ }
5784
+
5785
+ if (shouldUpdateVideo(prevProps, this.props)) {
5786
+ this.updateVideo();
5787
+ }
5788
+ }
5789
+ }, {
5790
+ key: 'componentWillUnmount',
5791
+ value: function componentWillUnmount() {
5792
+ /**
5793
+ * Note: The `youtube-player` package that is used promisifies all Youtube
5794
+ * Player API calls, which introduces a delay of a tick before it actually
5795
+ * gets destroyed. Since React attempts to remove the element instantly
5796
+ * this method isn't quick enough to reset the container element.
5797
+ */
5798
+ this.internalPlayer.destroy();
5799
+ }
5800
+
5801
+ /**
5802
+ * https://developers.google.com/youtube/iframe_api_reference#onReady
5803
+ *
5804
+ * @param {Object} event
5805
+ * @param {Object} target - player object
5806
+ */
5807
+
5808
+
5809
+ /**
5810
+ * https://developers.google.com/youtube/iframe_api_reference#onError
5811
+ *
5812
+ * @param {Object} event
5813
+ * @param {Integer} data - error type
5814
+ * @param {Object} target - player object
5815
+ */
5816
+
5817
+
5818
+ /**
5819
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
5820
+ *
5821
+ * @param {Object} event
5822
+ * @param {Integer} data - status change type
5823
+ * @param {Object} target - actual YT player
5824
+ */
5825
+
5826
+
5827
+ /**
5828
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackRateChange
5829
+ *
5830
+ * @param {Object} event
5831
+ * @param {Float} data - playback rate
5832
+ * @param {Object} target - actual YT player
5833
+ */
5834
+
5835
+
5836
+ /**
5837
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackQualityChange
5838
+ *
5839
+ * @param {Object} event
5840
+ * @param {String} data - playback quality
5841
+ * @param {Object} target - actual YT player
5842
+ */
5843
+
5844
+
5845
+ /**
5846
+ * Initialize the Youtube Player API on the container and attach event handlers
5847
+ */
5848
+
5849
+
5850
+ /**
5851
+ * Shorthand for destroying and then re-creating the Youtube Player
5852
+ */
5853
+
5854
+
5855
+ /**
5856
+ * Method to update the id and class of the Youtube Player iframe.
5857
+ * React should update this automatically but since the Youtube Player API
5858
+ * replaced the DIV that is mounted by React we need to do this manually.
5859
+ */
5860
+
5861
+
5862
+ /**
5863
+ * Call Youtube Player API methods to update the currently playing video.
5864
+ * Depeding on the `opts.playerVars.autoplay` this function uses one of two
5865
+ * Youtube Player API methods to update the video.
5866
+ */
5867
+
5868
+ }, {
5869
+ key: 'render',
5870
+ value: function render() {
5871
+ return React__default.createElement(
5872
+ 'div',
5873
+ { className: this.props.containerClassName },
5874
+ React__default.createElement('div', { id: this.props.id, className: this.props.className, ref: this.refContainer })
5875
+ );
5876
+ }
5877
+ }]);
5878
+
5879
+ return YouTube;
5880
+ }(React__default.Component);
5881
+
5882
+ YouTube.propTypes = {
5883
+ videoId: PropTypes.string,
5884
+
5885
+ // custom ID for player element
5886
+ id: PropTypes.string,
5887
+
5888
+ // custom class name for player element
5889
+ className: PropTypes.string,
5890
+ // custom class name for player container element
5891
+ containerClassName: PropTypes.string,
5892
+
5893
+ // https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
5894
+ opts: PropTypes.objectOf(PropTypes.any),
5895
+
5896
+ // event subscriptions
5897
+ onReady: PropTypes.func,
5898
+ onError: PropTypes.func,
5899
+ onPlay: PropTypes.func,
5900
+ onPause: PropTypes.func,
5901
+ onEnd: PropTypes.func,
5902
+ onStateChange: PropTypes.func,
5903
+ onPlaybackRateChange: PropTypes.func,
5904
+ onPlaybackQualityChange: PropTypes.func
5905
+ };
5906
+ YouTube.defaultProps = {
5907
+ id: null,
5908
+ className: null,
5909
+ opts: {},
5910
+ containerClassName: '',
5911
+ onReady: function onReady() {},
5912
+ onError: function onError() {},
5913
+ onPlay: function onPlay() {},
5914
+ onPause: function onPause() {},
5915
+ onEnd: function onEnd() {},
5916
+ onStateChange: function onStateChange() {},
5917
+ onPlaybackRateChange: function onPlaybackRateChange() {},
5918
+ onPlaybackQualityChange: function onPlaybackQualityChange() {}
5919
+ };
5920
+ YouTube.PlayerState = {
5921
+ UNSTARTED: -1,
5922
+ ENDED: 0,
5923
+ PLAYING: 1,
5924
+ PAUSED: 2,
5925
+ BUFFERING: 3,
5926
+ CUED: 5
5927
+ };
5928
+
5929
+ var getSerializers = function getSerializers() {
5930
+ return {
5931
+ types: {
5932
+ youtube: function youtube(_ref) {
5933
+ var node = _ref.node;
5934
+ var url = node.url;
5935
+
5936
+ var id = getYoutubeId(url);
5937
+ return React__default.createElement(YouTube, { videoId: id, className: 'youtube' });
5938
+ }
5939
+ }
5940
+ };
5941
+ };
5942
+
2797
5943
  exports.DeckContent = DeckContent;
2798
5944
  exports.DeckQueue = DeckQueue;
2799
5945
  exports.Column2 = Column2;
@@ -2807,4 +5953,5 @@ exports.TemplateNormal = TemplateNormal;
2807
5953
  exports.AD300x250 = AD300x250;
2808
5954
  exports.AD300x250x600 = AD300x250x600;
2809
5955
  exports.AD728x90 = AD728x90;
5956
+ exports.getSerializers = getSerializers;
2810
5957
  //# sourceMappingURL=index.js.map