@mjhls/mjh-framework 1.0.11 → 1.0.12

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.es.js CHANGED
@@ -13,7 +13,11 @@ import Form from 'react-bootstrap/Form';
13
13
  import FormControl from 'react-bootstrap/FormControl';
14
14
  import Button from 'react-bootstrap/Button';
15
15
  import events from 'events';
16
- import propTypes from 'prop-types';
16
+ import PropTypes from 'prop-types';
17
+ import tty from 'tty';
18
+ import util from 'util';
19
+ import fs from 'fs';
20
+ import net from 'net';
17
21
 
18
22
  /*! *****************************************************************************
19
23
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1429,6 +1433,8 @@ var NavNormal = function NavNormal(props) {
1429
1433
  );
1430
1434
  };
1431
1435
 
1436
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1437
+
1432
1438
  function unwrapExports (x) {
1433
1439
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1434
1440
  }
@@ -1991,7 +1997,7 @@ exports.default = exports.Context = void 0;
1991
1997
 
1992
1998
  var _react = _interopRequireDefault(React__default);
1993
1999
 
1994
- var _propTypes = _interopRequireDefault(propTypes);
2000
+ var _propTypes = _interopRequireDefault(PropTypes);
1995
2001
 
1996
2002
  var _manager = _interopRequireDefault(manager);
1997
2003
 
@@ -2299,7 +2305,7 @@ exports.default = exports.AdSlot = void 0;
2299
2305
 
2300
2306
  var _react = _interopRequireDefault(React__default);
2301
2307
 
2302
- var _propTypes = _interopRequireDefault(propTypes);
2308
+ var _propTypes = _interopRequireDefault(PropTypes);
2303
2309
 
2304
2310
  var _manager = _interopRequireDefault(manager);
2305
2311
 
@@ -2787,5 +2793,1866 @@ var AD300x250x600 = function (_Component) {
2787
2793
  return AD300x250x600;
2788
2794
  }(Component);
2789
2795
 
2790
- export { DeckContent, DeckQueue, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, TemplateNormal, AD300x250, AD300x250x600, AD728x90 };
2796
+ var getYoutubeId = createCommonjsModule(function (module, exports) {
2797
+ (function (root, factory) {
2798
+ {
2799
+ module.exports = factory();
2800
+ }
2801
+ }(commonjsGlobal, function (exports) {
2802
+
2803
+ return function (url, opts) {
2804
+ if (opts == undefined) {
2805
+ opts = {fuzzy: true};
2806
+ }
2807
+
2808
+ if (/youtu\.?be/.test(url)) {
2809
+
2810
+ // Look first for known patterns
2811
+ var i;
2812
+ var patterns = [
2813
+ /youtu\.be\/([^#\&\?]{11})/, // youtu.be/<id>
2814
+ /\?v=([^#\&\?]{11})/, // ?v=<id>
2815
+ /\&v=([^#\&\?]{11})/, // &v=<id>
2816
+ /embed\/([^#\&\?]{11})/, // embed/<id>
2817
+ /\/v\/([^#\&\?]{11})/ // /v/<id>
2818
+ ];
2819
+
2820
+ // If any pattern matches, return the ID
2821
+ for (i = 0; i < patterns.length; ++i) {
2822
+ if (patterns[i].test(url)) {
2823
+ return patterns[i].exec(url)[1];
2824
+ }
2825
+ }
2826
+
2827
+ if (opts.fuzzy) {
2828
+ // If that fails, break it apart by certain characters and look
2829
+ // for the 11 character key
2830
+ var tokens = url.split(/[\/\&\?=#\.\s]/g);
2831
+ for (i = 0; i < tokens.length; ++i) {
2832
+ if (/^[^#\&\?]{11}$/.test(tokens[i])) {
2833
+ return tokens[i];
2834
+ }
2835
+ }
2836
+ }
2837
+ }
2838
+
2839
+ return null;
2840
+ };
2841
+
2842
+ }));
2843
+ });
2844
+
2845
+ var isArray = Array.isArray;
2846
+ var keyList = Object.keys;
2847
+ var hasProp = Object.prototype.hasOwnProperty;
2848
+
2849
+ var fastDeepEqual = function equal(a, b) {
2850
+ if (a === b) return true;
2851
+
2852
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
2853
+ var arrA = isArray(a)
2854
+ , arrB = isArray(b)
2855
+ , i
2856
+ , length
2857
+ , key;
2858
+
2859
+ if (arrA && arrB) {
2860
+ length = a.length;
2861
+ if (length != b.length) return false;
2862
+ for (i = length; i-- !== 0;)
2863
+ if (!equal(a[i], b[i])) return false;
2864
+ return true;
2865
+ }
2866
+
2867
+ if (arrA != arrB) return false;
2868
+
2869
+ var dateA = a instanceof Date
2870
+ , dateB = b instanceof Date;
2871
+ if (dateA != dateB) return false;
2872
+ if (dateA && dateB) return a.getTime() == b.getTime();
2873
+
2874
+ var regexpA = a instanceof RegExp
2875
+ , regexpB = b instanceof RegExp;
2876
+ if (regexpA != regexpB) return false;
2877
+ if (regexpA && regexpB) return a.toString() == b.toString();
2878
+
2879
+ var keys = keyList(a);
2880
+ length = keys.length;
2881
+
2882
+ if (length !== keyList(b).length)
2883
+ return false;
2884
+
2885
+ for (i = length; i-- !== 0;)
2886
+ if (!hasProp.call(b, keys[i])) return false;
2887
+
2888
+ for (i = length; i-- !== 0;) {
2889
+ key = keys[i];
2890
+ if (!equal(a[key], b[key])) return false;
2891
+ }
2892
+
2893
+ return true;
2894
+ }
2895
+
2896
+ return a!==a && b!==b;
2897
+ };
2898
+
2899
+ var Sister;
2900
+
2901
+ /**
2902
+ * @link https://github.com/gajus/sister for the canonical source repository
2903
+ * @license https://github.com/gajus/sister/blob/master/LICENSE BSD 3-Clause
2904
+ */
2905
+ Sister = function () {
2906
+ var sister = {},
2907
+ events$$1 = {};
2908
+
2909
+ /**
2910
+ * @name handler
2911
+ * @function
2912
+ * @param {Object} data Event data.
2913
+ */
2914
+
2915
+ /**
2916
+ * @param {String} name Event name.
2917
+ * @param {handler} handler
2918
+ * @return {listener}
2919
+ */
2920
+ sister.on = function (name, handler) {
2921
+ var listener = {name: name, handler: handler};
2922
+ events$$1[name] = events$$1[name] || [];
2923
+ events$$1[name].unshift(listener);
2924
+ return listener;
2925
+ };
2926
+
2927
+ /**
2928
+ * @param {listener}
2929
+ */
2930
+ sister.off = function (listener) {
2931
+ var index = events$$1[listener.name].indexOf(listener);
2932
+
2933
+ if (index !== -1) {
2934
+ events$$1[listener.name].splice(index, 1);
2935
+ }
2936
+ };
2937
+
2938
+ /**
2939
+ * @param {String} name Event name.
2940
+ * @param {Object} data Event data.
2941
+ */
2942
+ sister.trigger = function (name, data) {
2943
+ var listeners = events$$1[name],
2944
+ i;
2945
+
2946
+ if (listeners) {
2947
+ i = listeners.length;
2948
+ while (i--) {
2949
+ listeners[i].handler(data);
2950
+ }
2951
+ }
2952
+ };
2953
+
2954
+ return sister;
2955
+ };
2956
+
2957
+ var sister = Sister;
2958
+
2959
+ var loadScript = function load (src, opts, cb) {
2960
+ var head = document.head || document.getElementsByTagName('head')[0];
2961
+ var script = document.createElement('script');
2962
+
2963
+ if (typeof opts === 'function') {
2964
+ cb = opts;
2965
+ opts = {};
2966
+ }
2967
+
2968
+ opts = opts || {};
2969
+ cb = cb || function() {};
2970
+
2971
+ script.type = opts.type || 'text/javascript';
2972
+ script.charset = opts.charset || 'utf8';
2973
+ script.async = 'async' in opts ? !!opts.async : true;
2974
+ script.src = src;
2975
+
2976
+ if (opts.attrs) {
2977
+ setAttributes(script, opts.attrs);
2978
+ }
2979
+
2980
+ if (opts.text) {
2981
+ script.text = '' + opts.text;
2982
+ }
2983
+
2984
+ var onend = 'onload' in script ? stdOnEnd : ieOnEnd;
2985
+ onend(script, cb);
2986
+
2987
+ // some good legacy browsers (firefox) fail the 'in' detection above
2988
+ // so as a fallback we always set onload
2989
+ // old IE will ignore this and new IE will set onload
2990
+ if (!script.onload) {
2991
+ stdOnEnd(script, cb);
2992
+ }
2993
+
2994
+ head.appendChild(script);
2995
+ };
2996
+
2997
+ function setAttributes(script, attrs) {
2998
+ for (var attr in attrs) {
2999
+ script.setAttribute(attr, attrs[attr]);
3000
+ }
3001
+ }
3002
+
3003
+ function stdOnEnd (script, cb) {
3004
+ script.onload = function () {
3005
+ this.onerror = this.onload = null;
3006
+ cb(null, script);
3007
+ };
3008
+ script.onerror = function () {
3009
+ // this.onload = null here is necessary
3010
+ // because even IE9 works not like others
3011
+ this.onerror = this.onload = null;
3012
+ cb(new Error('Failed to load ' + this.src), script);
3013
+ };
3014
+ }
3015
+
3016
+ function ieOnEnd (script, cb) {
3017
+ script.onreadystatechange = function () {
3018
+ if (this.readyState != 'complete' && this.readyState != 'loaded') return
3019
+ this.onreadystatechange = null;
3020
+ cb(null, script); // there is no way to catch loading errors in IE8
3021
+ };
3022
+ }
3023
+
3024
+ var loadYouTubeIframeApi = createCommonjsModule(function (module, exports) {
3025
+
3026
+ Object.defineProperty(exports, "__esModule", {
3027
+ value: true
3028
+ });
3029
+
3030
+
3031
+
3032
+ var _loadScript2 = _interopRequireDefault(loadScript);
3033
+
3034
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3035
+
3036
+ exports.default = function (emitter) {
3037
+ /**
3038
+ * A promise that is resolved when window.onYouTubeIframeAPIReady is called.
3039
+ * The promise is resolved with a reference to window.YT object.
3040
+ */
3041
+ var iframeAPIReady = new Promise(function (resolve) {
3042
+ if (window.YT && window.YT.Player && window.YT.Player instanceof Function) {
3043
+ resolve(window.YT);
3044
+
3045
+ return;
3046
+ } else {
3047
+ var protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
3048
+
3049
+ (0, _loadScript2.default)(protocol + '//www.youtube.com/iframe_api', function (error) {
3050
+ if (error) {
3051
+ emitter.trigger('error', error);
3052
+ }
3053
+ });
3054
+ }
3055
+
3056
+ var previous = window.onYouTubeIframeAPIReady;
3057
+
3058
+ // The API will call this function when page has finished downloading
3059
+ // the JavaScript for the player API.
3060
+ window.onYouTubeIframeAPIReady = function () {
3061
+ if (previous) {
3062
+ previous();
3063
+ }
3064
+
3065
+ resolve(window.YT);
3066
+ };
3067
+ });
3068
+
3069
+ return iframeAPIReady;
3070
+ };
3071
+
3072
+ module.exports = exports['default'];
3073
+ });
3074
+
3075
+ unwrapExports(loadYouTubeIframeApi);
3076
+
3077
+ /**
3078
+ * Helpers.
3079
+ */
3080
+
3081
+ var s = 1000;
3082
+ var m = s * 60;
3083
+ var h = m * 60;
3084
+ var d = h * 24;
3085
+ var y = d * 365.25;
3086
+
3087
+ /**
3088
+ * Parse or format the given `val`.
3089
+ *
3090
+ * Options:
3091
+ *
3092
+ * - `long` verbose formatting [false]
3093
+ *
3094
+ * @param {String|Number} val
3095
+ * @param {Object} [options]
3096
+ * @throws {Error} throw an error if val is not a non-empty string or a number
3097
+ * @return {String|Number}
3098
+ * @api public
3099
+ */
3100
+
3101
+ var ms = function(val, options) {
3102
+ options = options || {};
3103
+ var type = typeof val;
3104
+ if (type === 'string' && val.length > 0) {
3105
+ return parse(val);
3106
+ } else if (type === 'number' && isNaN(val) === false) {
3107
+ return options.long ? fmtLong(val) : fmtShort(val);
3108
+ }
3109
+ throw new Error(
3110
+ 'val is not a non-empty string or a valid number. val=' +
3111
+ JSON.stringify(val)
3112
+ );
3113
+ };
3114
+
3115
+ /**
3116
+ * Parse the given `str` and return milliseconds.
3117
+ *
3118
+ * @param {String} str
3119
+ * @return {Number}
3120
+ * @api private
3121
+ */
3122
+
3123
+ function parse(str) {
3124
+ str = String(str);
3125
+ if (str.length > 100) {
3126
+ return;
3127
+ }
3128
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
3129
+ str
3130
+ );
3131
+ if (!match) {
3132
+ return;
3133
+ }
3134
+ var n = parseFloat(match[1]);
3135
+ var type = (match[2] || 'ms').toLowerCase();
3136
+ switch (type) {
3137
+ case 'years':
3138
+ case 'year':
3139
+ case 'yrs':
3140
+ case 'yr':
3141
+ case 'y':
3142
+ return n * y;
3143
+ case 'days':
3144
+ case 'day':
3145
+ case 'd':
3146
+ return n * d;
3147
+ case 'hours':
3148
+ case 'hour':
3149
+ case 'hrs':
3150
+ case 'hr':
3151
+ case 'h':
3152
+ return n * h;
3153
+ case 'minutes':
3154
+ case 'minute':
3155
+ case 'mins':
3156
+ case 'min':
3157
+ case 'm':
3158
+ return n * m;
3159
+ case 'seconds':
3160
+ case 'second':
3161
+ case 'secs':
3162
+ case 'sec':
3163
+ case 's':
3164
+ return n * s;
3165
+ case 'milliseconds':
3166
+ case 'millisecond':
3167
+ case 'msecs':
3168
+ case 'msec':
3169
+ case 'ms':
3170
+ return n;
3171
+ default:
3172
+ return undefined;
3173
+ }
3174
+ }
3175
+
3176
+ /**
3177
+ * Short format for `ms`.
3178
+ *
3179
+ * @param {Number} ms
3180
+ * @return {String}
3181
+ * @api private
3182
+ */
3183
+
3184
+ function fmtShort(ms) {
3185
+ if (ms >= d) {
3186
+ return Math.round(ms / d) + 'd';
3187
+ }
3188
+ if (ms >= h) {
3189
+ return Math.round(ms / h) + 'h';
3190
+ }
3191
+ if (ms >= m) {
3192
+ return Math.round(ms / m) + 'm';
3193
+ }
3194
+ if (ms >= s) {
3195
+ return Math.round(ms / s) + 's';
3196
+ }
3197
+ return ms + 'ms';
3198
+ }
3199
+
3200
+ /**
3201
+ * Long format for `ms`.
3202
+ *
3203
+ * @param {Number} ms
3204
+ * @return {String}
3205
+ * @api private
3206
+ */
3207
+
3208
+ function fmtLong(ms) {
3209
+ return plural(ms, d, 'day') ||
3210
+ plural(ms, h, 'hour') ||
3211
+ plural(ms, m, 'minute') ||
3212
+ plural(ms, s, 'second') ||
3213
+ ms + ' ms';
3214
+ }
3215
+
3216
+ /**
3217
+ * Pluralization helper.
3218
+ */
3219
+
3220
+ function plural(ms, n, name) {
3221
+ if (ms < n) {
3222
+ return;
3223
+ }
3224
+ if (ms < n * 1.5) {
3225
+ return Math.floor(ms / n) + ' ' + name;
3226
+ }
3227
+ return Math.ceil(ms / n) + ' ' + name + 's';
3228
+ }
3229
+
3230
+ var debug = createCommonjsModule(function (module, exports) {
3231
+ /**
3232
+ * This is the common logic for both the Node.js and web browser
3233
+ * implementations of `debug()`.
3234
+ *
3235
+ * Expose `debug()` as the module.
3236
+ */
3237
+
3238
+ exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
3239
+ exports.coerce = coerce;
3240
+ exports.disable = disable;
3241
+ exports.enable = enable;
3242
+ exports.enabled = enabled;
3243
+ exports.humanize = ms;
3244
+
3245
+ /**
3246
+ * The currently active debug mode names, and names to skip.
3247
+ */
3248
+
3249
+ exports.names = [];
3250
+ exports.skips = [];
3251
+
3252
+ /**
3253
+ * Map of special "%n" handling functions, for the debug "format" argument.
3254
+ *
3255
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3256
+ */
3257
+
3258
+ exports.formatters = {};
3259
+
3260
+ /**
3261
+ * Previous log timestamp.
3262
+ */
3263
+
3264
+ var prevTime;
3265
+
3266
+ /**
3267
+ * Select a color.
3268
+ * @param {String} namespace
3269
+ * @return {Number}
3270
+ * @api private
3271
+ */
3272
+
3273
+ function selectColor(namespace) {
3274
+ var hash = 0, i;
3275
+
3276
+ for (i in namespace) {
3277
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
3278
+ hash |= 0; // Convert to 32bit integer
3279
+ }
3280
+
3281
+ return exports.colors[Math.abs(hash) % exports.colors.length];
3282
+ }
3283
+
3284
+ /**
3285
+ * Create a debugger with the given `namespace`.
3286
+ *
3287
+ * @param {String} namespace
3288
+ * @return {Function}
3289
+ * @api public
3290
+ */
3291
+
3292
+ function createDebug(namespace) {
3293
+
3294
+ function debug() {
3295
+ // disabled?
3296
+ if (!debug.enabled) return;
3297
+
3298
+ var self = debug;
3299
+
3300
+ // set `diff` timestamp
3301
+ var curr = +new Date();
3302
+ var ms$$1 = curr - (prevTime || curr);
3303
+ self.diff = ms$$1;
3304
+ self.prev = prevTime;
3305
+ self.curr = curr;
3306
+ prevTime = curr;
3307
+
3308
+ // turn the `arguments` into a proper Array
3309
+ var args = new Array(arguments.length);
3310
+ for (var i = 0; i < args.length; i++) {
3311
+ args[i] = arguments[i];
3312
+ }
3313
+
3314
+ args[0] = exports.coerce(args[0]);
3315
+
3316
+ if ('string' !== typeof args[0]) {
3317
+ // anything else let's inspect with %O
3318
+ args.unshift('%O');
3319
+ }
3320
+
3321
+ // apply any `formatters` transformations
3322
+ var index = 0;
3323
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
3324
+ // if we encounter an escaped % then don't increase the array index
3325
+ if (match === '%%') return match;
3326
+ index++;
3327
+ var formatter = exports.formatters[format];
3328
+ if ('function' === typeof formatter) {
3329
+ var val = args[index];
3330
+ match = formatter.call(self, val);
3331
+
3332
+ // now we need to remove `args[index]` since it's inlined in the `format`
3333
+ args.splice(index, 1);
3334
+ index--;
3335
+ }
3336
+ return match;
3337
+ });
3338
+
3339
+ // apply env-specific formatting (colors, etc.)
3340
+ exports.formatArgs.call(self, args);
3341
+
3342
+ var logFn = debug.log || exports.log || console.log.bind(console);
3343
+ logFn.apply(self, args);
3344
+ }
3345
+
3346
+ debug.namespace = namespace;
3347
+ debug.enabled = exports.enabled(namespace);
3348
+ debug.useColors = exports.useColors();
3349
+ debug.color = selectColor(namespace);
3350
+
3351
+ // env-specific initialization logic for debug instances
3352
+ if ('function' === typeof exports.init) {
3353
+ exports.init(debug);
3354
+ }
3355
+
3356
+ return debug;
3357
+ }
3358
+
3359
+ /**
3360
+ * Enables a debug mode by namespaces. This can include modes
3361
+ * separated by a colon and wildcards.
3362
+ *
3363
+ * @param {String} namespaces
3364
+ * @api public
3365
+ */
3366
+
3367
+ function enable(namespaces) {
3368
+ exports.save(namespaces);
3369
+
3370
+ exports.names = [];
3371
+ exports.skips = [];
3372
+
3373
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3374
+ var len = split.length;
3375
+
3376
+ for (var i = 0; i < len; i++) {
3377
+ if (!split[i]) continue; // ignore empty strings
3378
+ namespaces = split[i].replace(/\*/g, '.*?');
3379
+ if (namespaces[0] === '-') {
3380
+ exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
3381
+ } else {
3382
+ exports.names.push(new RegExp('^' + namespaces + '$'));
3383
+ }
3384
+ }
3385
+ }
3386
+
3387
+ /**
3388
+ * Disable debug output.
3389
+ *
3390
+ * @api public
3391
+ */
3392
+
3393
+ function disable() {
3394
+ exports.enable('');
3395
+ }
3396
+
3397
+ /**
3398
+ * Returns true if the given mode name is enabled, false otherwise.
3399
+ *
3400
+ * @param {String} name
3401
+ * @return {Boolean}
3402
+ * @api public
3403
+ */
3404
+
3405
+ function enabled(name) {
3406
+ var i, len;
3407
+ for (i = 0, len = exports.skips.length; i < len; i++) {
3408
+ if (exports.skips[i].test(name)) {
3409
+ return false;
3410
+ }
3411
+ }
3412
+ for (i = 0, len = exports.names.length; i < len; i++) {
3413
+ if (exports.names[i].test(name)) {
3414
+ return true;
3415
+ }
3416
+ }
3417
+ return false;
3418
+ }
3419
+
3420
+ /**
3421
+ * Coerce `val`.
3422
+ *
3423
+ * @param {Mixed} val
3424
+ * @return {Mixed}
3425
+ * @api private
3426
+ */
3427
+
3428
+ function coerce(val) {
3429
+ if (val instanceof Error) return val.stack || val.message;
3430
+ return val;
3431
+ }
3432
+ });
3433
+ var debug_1 = debug.coerce;
3434
+ var debug_2 = debug.disable;
3435
+ var debug_3 = debug.enable;
3436
+ var debug_4 = debug.enabled;
3437
+ var debug_5 = debug.humanize;
3438
+ var debug_6 = debug.names;
3439
+ var debug_7 = debug.skips;
3440
+ var debug_8 = debug.formatters;
3441
+
3442
+ var browser = createCommonjsModule(function (module, exports) {
3443
+ /**
3444
+ * This is the web browser implementation of `debug()`.
3445
+ *
3446
+ * Expose `debug()` as the module.
3447
+ */
3448
+
3449
+ exports = module.exports = debug;
3450
+ exports.log = log;
3451
+ exports.formatArgs = formatArgs;
3452
+ exports.save = save;
3453
+ exports.load = load;
3454
+ exports.useColors = useColors;
3455
+ exports.storage = 'undefined' != typeof chrome
3456
+ && 'undefined' != typeof chrome.storage
3457
+ ? chrome.storage.local
3458
+ : localstorage();
3459
+
3460
+ /**
3461
+ * Colors.
3462
+ */
3463
+
3464
+ exports.colors = [
3465
+ 'lightseagreen',
3466
+ 'forestgreen',
3467
+ 'goldenrod',
3468
+ 'dodgerblue',
3469
+ 'darkorchid',
3470
+ 'crimson'
3471
+ ];
3472
+
3473
+ /**
3474
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
3475
+ * and the Firebug extension (any Firefox version) are known
3476
+ * to support "%c" CSS customizations.
3477
+ *
3478
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
3479
+ */
3480
+
3481
+ function useColors() {
3482
+ // NB: In an Electron preload script, document will be defined but not fully
3483
+ // initialized. Since we know we're in Chrome, we'll just detect this case
3484
+ // explicitly
3485
+ if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
3486
+ return true;
3487
+ }
3488
+
3489
+ // is webkit? http://stackoverflow.com/a/16459606/376773
3490
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
3491
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
3492
+ // is firebug? http://stackoverflow.com/a/398120/376773
3493
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
3494
+ // is firefox >= v31?
3495
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
3496
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
3497
+ // double check webkit in userAgent just in case we are in a worker
3498
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
3499
+ }
3500
+
3501
+ /**
3502
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3503
+ */
3504
+
3505
+ exports.formatters.j = function(v) {
3506
+ try {
3507
+ return JSON.stringify(v);
3508
+ } catch (err) {
3509
+ return '[UnexpectedJSONParseError]: ' + err.message;
3510
+ }
3511
+ };
3512
+
3513
+
3514
+ /**
3515
+ * Colorize log arguments if enabled.
3516
+ *
3517
+ * @api public
3518
+ */
3519
+
3520
+ function formatArgs(args) {
3521
+ var useColors = this.useColors;
3522
+
3523
+ args[0] = (useColors ? '%c' : '')
3524
+ + this.namespace
3525
+ + (useColors ? ' %c' : ' ')
3526
+ + args[0]
3527
+ + (useColors ? '%c ' : ' ')
3528
+ + '+' + exports.humanize(this.diff);
3529
+
3530
+ if (!useColors) return;
3531
+
3532
+ var c = 'color: ' + this.color;
3533
+ args.splice(1, 0, c, 'color: inherit');
3534
+
3535
+ // the final "%c" is somewhat tricky, because there could be other
3536
+ // arguments passed either before or after the %c, so we need to
3537
+ // figure out the correct index to insert the CSS into
3538
+ var index = 0;
3539
+ var lastC = 0;
3540
+ args[0].replace(/%[a-zA-Z%]/g, function(match) {
3541
+ if ('%%' === match) return;
3542
+ index++;
3543
+ if ('%c' === match) {
3544
+ // we only are interested in the *last* %c
3545
+ // (the user may have provided their own)
3546
+ lastC = index;
3547
+ }
3548
+ });
3549
+
3550
+ args.splice(lastC, 0, c);
3551
+ }
3552
+
3553
+ /**
3554
+ * Invokes `console.log()` when available.
3555
+ * No-op when `console.log` is not a "function".
3556
+ *
3557
+ * @api public
3558
+ */
3559
+
3560
+ function log() {
3561
+ // this hackery is required for IE8/9, where
3562
+ // the `console.log` function doesn't have 'apply'
3563
+ return 'object' === typeof console
3564
+ && console.log
3565
+ && Function.prototype.apply.call(console.log, console, arguments);
3566
+ }
3567
+
3568
+ /**
3569
+ * Save `namespaces`.
3570
+ *
3571
+ * @param {String} namespaces
3572
+ * @api private
3573
+ */
3574
+
3575
+ function save(namespaces) {
3576
+ try {
3577
+ if (null == namespaces) {
3578
+ exports.storage.removeItem('debug');
3579
+ } else {
3580
+ exports.storage.debug = namespaces;
3581
+ }
3582
+ } catch(e) {}
3583
+ }
3584
+
3585
+ /**
3586
+ * Load `namespaces`.
3587
+ *
3588
+ * @return {String} returns the previously persisted debug modes
3589
+ * @api private
3590
+ */
3591
+
3592
+ function load() {
3593
+ var r;
3594
+ try {
3595
+ r = exports.storage.debug;
3596
+ } catch(e) {}
3597
+
3598
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
3599
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
3600
+ r = process.env.DEBUG;
3601
+ }
3602
+
3603
+ return r;
3604
+ }
3605
+
3606
+ /**
3607
+ * Enable namespaces listed in `localStorage.debug` initially.
3608
+ */
3609
+
3610
+ exports.enable(load());
3611
+
3612
+ /**
3613
+ * Localstorage attempts to return the localstorage.
3614
+ *
3615
+ * This is necessary because safari throws
3616
+ * when a user disables cookies/localstorage
3617
+ * and you attempt to access it.
3618
+ *
3619
+ * @return {LocalStorage}
3620
+ * @api private
3621
+ */
3622
+
3623
+ function localstorage() {
3624
+ try {
3625
+ return window.localStorage;
3626
+ } catch (e) {}
3627
+ }
3628
+ });
3629
+ var browser_1 = browser.log;
3630
+ var browser_2 = browser.formatArgs;
3631
+ var browser_3 = browser.save;
3632
+ var browser_4 = browser.load;
3633
+ var browser_5 = browser.useColors;
3634
+ var browser_6 = browser.storage;
3635
+ var browser_7 = browser.colors;
3636
+
3637
+ var node = createCommonjsModule(function (module, exports) {
3638
+ /**
3639
+ * Module dependencies.
3640
+ */
3641
+
3642
+
3643
+
3644
+
3645
+ /**
3646
+ * This is the Node.js implementation of `debug()`.
3647
+ *
3648
+ * Expose `debug()` as the module.
3649
+ */
3650
+
3651
+ exports = module.exports = debug;
3652
+ exports.init = init;
3653
+ exports.log = log;
3654
+ exports.formatArgs = formatArgs;
3655
+ exports.save = save;
3656
+ exports.load = load;
3657
+ exports.useColors = useColors;
3658
+
3659
+ /**
3660
+ * Colors.
3661
+ */
3662
+
3663
+ exports.colors = [6, 2, 3, 4, 5, 1];
3664
+
3665
+ /**
3666
+ * Build up the default `inspectOpts` object from the environment variables.
3667
+ *
3668
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
3669
+ */
3670
+
3671
+ exports.inspectOpts = Object.keys(process.env).filter(function (key) {
3672
+ return /^debug_/i.test(key);
3673
+ }).reduce(function (obj, key) {
3674
+ // camel-case
3675
+ var prop = key
3676
+ .substring(6)
3677
+ .toLowerCase()
3678
+ .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
3679
+
3680
+ // coerce string value into JS value
3681
+ var val = process.env[key];
3682
+ if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
3683
+ else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
3684
+ else if (val === 'null') val = null;
3685
+ else val = Number(val);
3686
+
3687
+ obj[prop] = val;
3688
+ return obj;
3689
+ }, {});
3690
+
3691
+ /**
3692
+ * The file descriptor to write the `debug()` calls to.
3693
+ * Set the `DEBUG_FD` env variable to override with another value. i.e.:
3694
+ *
3695
+ * $ DEBUG_FD=3 node script.js 3>debug.log
3696
+ */
3697
+
3698
+ var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
3699
+
3700
+ if (1 !== fd && 2 !== fd) {
3701
+ 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)')();
3702
+ }
3703
+
3704
+ var stream = 1 === fd ? process.stdout :
3705
+ 2 === fd ? process.stderr :
3706
+ createWritableStdioStream(fd);
3707
+
3708
+ /**
3709
+ * Is stdout a TTY? Colored output is enabled when `true`.
3710
+ */
3711
+
3712
+ function useColors() {
3713
+ return 'colors' in exports.inspectOpts
3714
+ ? Boolean(exports.inspectOpts.colors)
3715
+ : tty.isatty(fd);
3716
+ }
3717
+
3718
+ /**
3719
+ * Map %o to `util.inspect()`, all on a single line.
3720
+ */
3721
+
3722
+ exports.formatters.o = function(v) {
3723
+ this.inspectOpts.colors = this.useColors;
3724
+ return util.inspect(v, this.inspectOpts)
3725
+ .split('\n').map(function(str) {
3726
+ return str.trim()
3727
+ }).join(' ');
3728
+ };
3729
+
3730
+ /**
3731
+ * Map %o to `util.inspect()`, allowing multiple lines if needed.
3732
+ */
3733
+
3734
+ exports.formatters.O = function(v) {
3735
+ this.inspectOpts.colors = this.useColors;
3736
+ return util.inspect(v, this.inspectOpts);
3737
+ };
3738
+
3739
+ /**
3740
+ * Adds ANSI color escape codes if enabled.
3741
+ *
3742
+ * @api public
3743
+ */
3744
+
3745
+ function formatArgs(args) {
3746
+ var name = this.namespace;
3747
+ var useColors = this.useColors;
3748
+
3749
+ if (useColors) {
3750
+ var c = this.color;
3751
+ var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
3752
+
3753
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
3754
+ args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
3755
+ } else {
3756
+ args[0] = new Date().toUTCString()
3757
+ + ' ' + name + ' ' + args[0];
3758
+ }
3759
+ }
3760
+
3761
+ /**
3762
+ * Invokes `util.format()` with the specified arguments and writes to `stream`.
3763
+ */
3764
+
3765
+ function log() {
3766
+ return stream.write(util.format.apply(util, arguments) + '\n');
3767
+ }
3768
+
3769
+ /**
3770
+ * Save `namespaces`.
3771
+ *
3772
+ * @param {String} namespaces
3773
+ * @api private
3774
+ */
3775
+
3776
+ function save(namespaces) {
3777
+ if (null == namespaces) {
3778
+ // If you set a process.env field to null or undefined, it gets cast to the
3779
+ // string 'null' or 'undefined'. Just delete instead.
3780
+ delete process.env.DEBUG;
3781
+ } else {
3782
+ process.env.DEBUG = namespaces;
3783
+ }
3784
+ }
3785
+
3786
+ /**
3787
+ * Load `namespaces`.
3788
+ *
3789
+ * @return {String} returns the previously persisted debug modes
3790
+ * @api private
3791
+ */
3792
+
3793
+ function load() {
3794
+ return process.env.DEBUG;
3795
+ }
3796
+
3797
+ /**
3798
+ * Copied from `node/src/node.js`.
3799
+ *
3800
+ * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
3801
+ * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
3802
+ */
3803
+
3804
+ function createWritableStdioStream (fd) {
3805
+ var stream;
3806
+ var tty_wrap = process.binding('tty_wrap');
3807
+
3808
+ // Note stream._type is used for test-module-load-list.js
3809
+
3810
+ switch (tty_wrap.guessHandleType(fd)) {
3811
+ case 'TTY':
3812
+ stream = new tty.WriteStream(fd);
3813
+ stream._type = 'tty';
3814
+
3815
+ // Hack to have stream not keep the event loop alive.
3816
+ // See https://github.com/joyent/node/issues/1726
3817
+ if (stream._handle && stream._handle.unref) {
3818
+ stream._handle.unref();
3819
+ }
3820
+ break;
3821
+
3822
+ case 'FILE':
3823
+ var fs$$1 = fs;
3824
+ stream = new fs$$1.SyncWriteStream(fd, { autoClose: false });
3825
+ stream._type = 'fs';
3826
+ break;
3827
+
3828
+ case 'PIPE':
3829
+ case 'TCP':
3830
+ var net$$1 = net;
3831
+ stream = new net$$1.Socket({
3832
+ fd: fd,
3833
+ readable: false,
3834
+ writable: true
3835
+ });
3836
+
3837
+ // FIXME Should probably have an option in net.Socket to create a
3838
+ // stream from an existing fd which is writable only. But for now
3839
+ // we'll just add this hack and set the `readable` member to false.
3840
+ // Test: ./node test/fixtures/echo.js < /etc/passwd
3841
+ stream.readable = false;
3842
+ stream.read = null;
3843
+ stream._type = 'pipe';
3844
+
3845
+ // FIXME Hack to have stream not keep the event loop alive.
3846
+ // See https://github.com/joyent/node/issues/1726
3847
+ if (stream._handle && stream._handle.unref) {
3848
+ stream._handle.unref();
3849
+ }
3850
+ break;
3851
+
3852
+ default:
3853
+ // Probably an error on in uv_guess_handle()
3854
+ throw new Error('Implement me. Unknown stream file type!');
3855
+ }
3856
+
3857
+ // For supporting legacy API we put the FD here.
3858
+ stream.fd = fd;
3859
+
3860
+ stream._isStdio = true;
3861
+
3862
+ return stream;
3863
+ }
3864
+
3865
+ /**
3866
+ * Init logic for `debug` instances.
3867
+ *
3868
+ * Create a new `inspectOpts` object in case `useColors` is set
3869
+ * differently for a particular `debug` instance.
3870
+ */
3871
+
3872
+ function init (debug$$1) {
3873
+ debug$$1.inspectOpts = {};
3874
+
3875
+ var keys = Object.keys(exports.inspectOpts);
3876
+ for (var i = 0; i < keys.length; i++) {
3877
+ debug$$1.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
3878
+ }
3879
+ }
3880
+
3881
+ /**
3882
+ * Enable namespaces listed in `process.env.DEBUG` initially.
3883
+ */
3884
+
3885
+ exports.enable(load());
3886
+ });
3887
+ var node_1 = node.init;
3888
+ var node_2 = node.log;
3889
+ var node_3 = node.formatArgs;
3890
+ var node_4 = node.save;
3891
+ var node_5 = node.load;
3892
+ var node_6 = node.useColors;
3893
+ var node_7 = node.colors;
3894
+ var node_8 = node.inspectOpts;
3895
+
3896
+ var src = createCommonjsModule(function (module) {
3897
+ /**
3898
+ * Detect Electron renderer process, which is node, but we should
3899
+ * treat as a browser.
3900
+ */
3901
+
3902
+ if (typeof process !== 'undefined' && process.type === 'renderer') {
3903
+ module.exports = browser;
3904
+ } else {
3905
+ module.exports = node;
3906
+ }
3907
+ });
3908
+
3909
+ var functionNames = createCommonjsModule(function (module, exports) {
3910
+
3911
+ Object.defineProperty(exports, "__esModule", {
3912
+ value: true
3913
+ });
3914
+
3915
+
3916
+ /**
3917
+ * @see https://developers.google.com/youtube/iframe_api_reference#Functions
3918
+ */
3919
+ 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'];
3920
+ module.exports = exports['default'];
3921
+ });
3922
+
3923
+ unwrapExports(functionNames);
3924
+
3925
+ var eventNames = createCommonjsModule(function (module, exports) {
3926
+
3927
+ Object.defineProperty(exports, "__esModule", {
3928
+ value: true
3929
+ });
3930
+
3931
+
3932
+ /**
3933
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
3934
+ * `volumeChange` is not officially supported but seems to work
3935
+ * it emits an object: `{volume: 82.6923076923077, muted: false}`
3936
+ */
3937
+ exports.default = ['ready', 'stateChange', 'playbackQualityChange', 'playbackRateChange', 'error', 'apiChange', 'volumeChange'];
3938
+ module.exports = exports['default'];
3939
+ });
3940
+
3941
+ unwrapExports(eventNames);
3942
+
3943
+ var PlayerStates = createCommonjsModule(function (module, exports) {
3944
+
3945
+ Object.defineProperty(exports, "__esModule", {
3946
+ value: true
3947
+ });
3948
+ exports.default = {
3949
+ BUFFERING: 3,
3950
+ ENDED: 0,
3951
+ PAUSED: 2,
3952
+ PLAYING: 1,
3953
+ UNSTARTED: -1,
3954
+ VIDEO_CUED: 5
3955
+ };
3956
+ module.exports = exports["default"];
3957
+ });
3958
+
3959
+ unwrapExports(PlayerStates);
3960
+
3961
+ var FunctionStateMap = createCommonjsModule(function (module, exports) {
3962
+
3963
+ Object.defineProperty(exports, "__esModule", {
3964
+ value: true
3965
+ });
3966
+
3967
+
3968
+
3969
+ var _PlayerStates2 = _interopRequireDefault(PlayerStates);
3970
+
3971
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3972
+
3973
+ exports.default = {
3974
+ pauseVideo: {
3975
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PAUSED],
3976
+ stateChangeRequired: false
3977
+ },
3978
+ playVideo: {
3979
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING],
3980
+ stateChangeRequired: false
3981
+ },
3982
+ seekTo: {
3983
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING, _PlayerStates2.default.PAUSED],
3984
+ stateChangeRequired: true,
3985
+
3986
+ // TRICKY: `seekTo` may not cause a state change if no buffering is
3987
+ // required.
3988
+ timeout: 3000
3989
+ }
3990
+ };
3991
+ module.exports = exports['default'];
3992
+ });
3993
+
3994
+ unwrapExports(FunctionStateMap);
3995
+
3996
+ var YouTubePlayer_1 = createCommonjsModule(function (module, exports) {
3997
+
3998
+ Object.defineProperty(exports, "__esModule", {
3999
+ value: true
4000
+ });
4001
+
4002
+
4003
+
4004
+ var _debug2 = _interopRequireDefault(src);
4005
+
4006
+
4007
+
4008
+ var _functionNames2 = _interopRequireDefault(functionNames);
4009
+
4010
+
4011
+
4012
+ var _eventNames2 = _interopRequireDefault(eventNames);
4013
+
4014
+
4015
+
4016
+ var _FunctionStateMap2 = _interopRequireDefault(FunctionStateMap);
4017
+
4018
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4019
+
4020
+ /* eslint-disable promise/prefer-await-to-then */
4021
+
4022
+ var debug = (0, _debug2.default)('youtube-player');
4023
+
4024
+ var YouTubePlayer = {};
4025
+
4026
+ /**
4027
+ * Construct an object that defines an event handler for all of the YouTube
4028
+ * player events. Proxy captured events through an event emitter.
4029
+ *
4030
+ * @todo Capture event parameters.
4031
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
4032
+ */
4033
+ YouTubePlayer.proxyEvents = function (emitter) {
4034
+ var events$$1 = {};
4035
+
4036
+ var _loop = function _loop(eventName) {
4037
+ var onEventName = 'on' + eventName.slice(0, 1).toUpperCase() + eventName.slice(1);
4038
+
4039
+ events$$1[onEventName] = function (event) {
4040
+ debug('event "%s"', onEventName, event);
4041
+
4042
+ emitter.trigger(eventName, event);
4043
+ };
4044
+ };
4045
+
4046
+ var _iteratorNormalCompletion = true;
4047
+ var _didIteratorError = false;
4048
+ var _iteratorError = undefined;
4049
+
4050
+ try {
4051
+ for (var _iterator = _eventNames2.default[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
4052
+ var eventName = _step.value;
4053
+
4054
+ _loop(eventName);
4055
+ }
4056
+ } catch (err) {
4057
+ _didIteratorError = true;
4058
+ _iteratorError = err;
4059
+ } finally {
4060
+ try {
4061
+ if (!_iteratorNormalCompletion && _iterator.return) {
4062
+ _iterator.return();
4063
+ }
4064
+ } finally {
4065
+ if (_didIteratorError) {
4066
+ throw _iteratorError;
4067
+ }
4068
+ }
4069
+ }
4070
+
4071
+ return events$$1;
4072
+ };
4073
+
4074
+ /**
4075
+ * Delays player API method execution until player state is ready.
4076
+ *
4077
+ * @todo Proxy all of the methods using Object.keys.
4078
+ * @todo See TRICKY below.
4079
+ * @param playerAPIReady Promise that resolves when player is ready.
4080
+ * @param strictState A flag designating whether or not to wait for
4081
+ * an acceptable state when calling supported functions.
4082
+ * @returns {Object}
4083
+ */
4084
+ YouTubePlayer.promisifyPlayer = function (playerAPIReady) {
4085
+ var strictState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4086
+
4087
+ var functions = {};
4088
+
4089
+ var _loop2 = function _loop2(functionName) {
4090
+ if (strictState && _FunctionStateMap2.default[functionName]) {
4091
+ functions[functionName] = function () {
4092
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
4093
+ args[_key] = arguments[_key];
4094
+ }
4095
+
4096
+ return playerAPIReady.then(function (player) {
4097
+ var stateInfo = _FunctionStateMap2.default[functionName];
4098
+ var playerState = player.getPlayerState();
4099
+
4100
+ // eslint-disable-next-line no-warning-comments
4101
+ // TODO: Just spread the args into the function once Babel is fixed:
4102
+ // https://github.com/babel/babel/issues/4270
4103
+ //
4104
+ // eslint-disable-next-line prefer-spread
4105
+ var value = player[functionName].apply(player, args);
4106
+
4107
+ // TRICKY: For functions like `seekTo`, a change in state must be
4108
+ // triggered given that the resulting state could match the initial
4109
+ // state.
4110
+ if (stateInfo.stateChangeRequired ||
4111
+
4112
+ // eslint-disable-next-line no-extra-parens
4113
+ Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerState) === -1) {
4114
+ return new Promise(function (resolve) {
4115
+ var onPlayerStateChange = function onPlayerStateChange() {
4116
+ var playerStateAfterChange = player.getPlayerState();
4117
+
4118
+ var timeout = void 0;
4119
+
4120
+ if (typeof stateInfo.timeout === 'number') {
4121
+ timeout = setTimeout(function () {
4122
+ player.removeEventListener('onStateChange', onPlayerStateChange);
4123
+
4124
+ resolve();
4125
+ }, stateInfo.timeout);
4126
+ }
4127
+
4128
+ if (Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerStateAfterChange) !== -1) {
4129
+ player.removeEventListener('onStateChange', onPlayerStateChange);
4130
+
4131
+ clearTimeout(timeout);
4132
+
4133
+ resolve();
4134
+ }
4135
+ };
4136
+
4137
+ player.addEventListener('onStateChange', onPlayerStateChange);
4138
+ }).then(function () {
4139
+ return value;
4140
+ });
4141
+ }
4142
+
4143
+ return value;
4144
+ });
4145
+ };
4146
+ } else {
4147
+ functions[functionName] = function () {
4148
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4149
+ args[_key2] = arguments[_key2];
4150
+ }
4151
+
4152
+ return playerAPIReady.then(function (player) {
4153
+ // eslint-disable-next-line no-warning-comments
4154
+ // TODO: Just spread the args into the function once Babel is fixed:
4155
+ // https://github.com/babel/babel/issues/4270
4156
+ //
4157
+ // eslint-disable-next-line prefer-spread
4158
+ return player[functionName].apply(player, args);
4159
+ });
4160
+ };
4161
+ }
4162
+ };
4163
+
4164
+ var _iteratorNormalCompletion2 = true;
4165
+ var _didIteratorError2 = false;
4166
+ var _iteratorError2 = undefined;
4167
+
4168
+ try {
4169
+ for (var _iterator2 = _functionNames2.default[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
4170
+ var functionName = _step2.value;
4171
+
4172
+ _loop2(functionName);
4173
+ }
4174
+ } catch (err) {
4175
+ _didIteratorError2 = true;
4176
+ _iteratorError2 = err;
4177
+ } finally {
4178
+ try {
4179
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
4180
+ _iterator2.return();
4181
+ }
4182
+ } finally {
4183
+ if (_didIteratorError2) {
4184
+ throw _iteratorError2;
4185
+ }
4186
+ }
4187
+ }
4188
+
4189
+ return functions;
4190
+ };
4191
+
4192
+ exports.default = YouTubePlayer;
4193
+ module.exports = exports['default'];
4194
+ });
4195
+
4196
+ unwrapExports(YouTubePlayer_1);
4197
+
4198
+ var dist = createCommonjsModule(function (module, exports) {
4199
+
4200
+ Object.defineProperty(exports, "__esModule", {
4201
+ value: true
4202
+ });
4203
+
4204
+ 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; };
4205
+
4206
+
4207
+
4208
+ var _sister2 = _interopRequireDefault(sister);
4209
+
4210
+
4211
+
4212
+ var _loadYouTubeIframeApi2 = _interopRequireDefault(loadYouTubeIframeApi);
4213
+
4214
+
4215
+
4216
+ var _YouTubePlayer2 = _interopRequireDefault(YouTubePlayer_1);
4217
+
4218
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4219
+
4220
+ /**
4221
+ * @typedef YT.Player
4222
+ * @see https://developers.google.com/youtube/iframe_api_reference
4223
+ * */
4224
+
4225
+ /**
4226
+ * @see https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
4227
+ */
4228
+ var youtubeIframeAPI = void 0;
4229
+
4230
+ /**
4231
+ * A factory function used to produce an instance of YT.Player and queue function calls and proxy events of the resulting object.
4232
+ *
4233
+ * @param maybeElementId Either An existing YT.Player instance,
4234
+ * the DOM element or the id of the HTML element where the API will insert an <iframe>.
4235
+ * @param options See `options` (Ignored when using an existing YT.Player instance).
4236
+ * @param strictState A flag designating whether or not to wait for
4237
+ * an acceptable state when calling supported functions. Default: `false`.
4238
+ * See `FunctionStateMap.js` for supported functions and acceptable states.
4239
+ */
4240
+
4241
+ exports.default = function (maybeElementId) {
4242
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4243
+ var strictState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4244
+
4245
+ var emitter = (0, _sister2.default)();
4246
+
4247
+ if (!youtubeIframeAPI) {
4248
+ youtubeIframeAPI = (0, _loadYouTubeIframeApi2.default)(emitter);
4249
+ }
4250
+
4251
+ if (options.events) {
4252
+ throw new Error('Event handlers cannot be overwritten.');
4253
+ }
4254
+
4255
+ if (typeof maybeElementId === 'string' && !document.getElementById(maybeElementId)) {
4256
+ throw new Error('Element "' + maybeElementId + '" does not exist.');
4257
+ }
4258
+
4259
+ options.events = _YouTubePlayer2.default.proxyEvents(emitter);
4260
+
4261
+ var playerAPIReady = new Promise(function (resolve) {
4262
+ if ((typeof maybeElementId === 'undefined' ? 'undefined' : _typeof(maybeElementId)) === 'object' && maybeElementId.playVideo instanceof Function) {
4263
+ var player = maybeElementId;
4264
+
4265
+ resolve(player);
4266
+ } else {
4267
+ // asume maybeElementId can be rendered inside
4268
+ // eslint-disable-next-line promise/catch-or-return
4269
+ youtubeIframeAPI.then(function (YT) {
4270
+ // eslint-disable-line promise/prefer-await-to-then
4271
+ var player = new YT.Player(maybeElementId, options);
4272
+
4273
+ emitter.on('ready', function () {
4274
+ resolve(player);
4275
+ });
4276
+
4277
+ return null;
4278
+ });
4279
+ }
4280
+ });
4281
+
4282
+ var playerApi = _YouTubePlayer2.default.promisifyPlayer(playerAPIReady, strictState);
4283
+
4284
+ playerApi.on = emitter.on;
4285
+ playerApi.off = emitter.off;
4286
+
4287
+ return playerApi;
4288
+ };
4289
+
4290
+ module.exports = exports['default'];
4291
+ });
4292
+
4293
+ var youTubePlayer = unwrapExports(dist);
4294
+
4295
+ 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; }; }();
4296
+
4297
+ 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; };
4298
+
4299
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4300
+
4301
+ 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; }
4302
+
4303
+ 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; }
4304
+
4305
+ /**
4306
+ * Check whether a `props` change should result in the video being updated.
4307
+ *
4308
+ * @param {Object} prevProps
4309
+ * @param {Object} props
4310
+ */
4311
+ function shouldUpdateVideo(prevProps, props) {
4312
+ // A changing video should always trigger an update
4313
+ if (prevProps.videoId !== props.videoId) {
4314
+ return true;
4315
+ }
4316
+
4317
+ // Otherwise, a change in the start/end time playerVars also requires a player
4318
+ // update.
4319
+ var prevVars = prevProps.opts.playerVars || {};
4320
+ var vars = props.opts.playerVars || {};
4321
+
4322
+ return prevVars.start !== vars.start || prevVars.end !== vars.end;
4323
+ }
4324
+
4325
+ /**
4326
+ * Neutralise API options that only require a video update, leaving only options
4327
+ * that require a player reset. The results can then be compared to see if a
4328
+ * player reset is necessary.
4329
+ *
4330
+ * @param {Object} opts
4331
+ */
4332
+ function filterResetOptions(opts) {
4333
+ return _extends$1({}, opts, {
4334
+ playerVars: _extends$1({}, opts.playerVars, {
4335
+ autoplay: 0,
4336
+ start: 0,
4337
+ end: 0
4338
+ })
4339
+ });
4340
+ }
4341
+
4342
+ /**
4343
+ * Check whether a `props` change should result in the player being reset.
4344
+ * The player is reset when the `props.opts` change, except if the only change
4345
+ * is in the `start` and `end` playerVars, because a video update can deal with
4346
+ * those.
4347
+ *
4348
+ * @param {Object} prevProps
4349
+ * @param {Object} props
4350
+ */
4351
+ function shouldResetPlayer(prevProps, props) {
4352
+ return !fastDeepEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts));
4353
+ }
4354
+
4355
+ /**
4356
+ * Check whether a props change should result in an id or className update.
4357
+ *
4358
+ * @param {Object} prevProps
4359
+ * @param {Object} props
4360
+ */
4361
+ function shouldUpdatePlayer(prevProps, props) {
4362
+ return prevProps.id !== props.id || prevProps.className !== props.className;
4363
+ }
4364
+
4365
+ var YouTube = function (_React$Component) {
4366
+ _inherits(YouTube, _React$Component);
4367
+
4368
+ function YouTube(props) {
4369
+ _classCallCheck(this, YouTube);
4370
+
4371
+ var _this = _possibleConstructorReturn(this, (YouTube.__proto__ || Object.getPrototypeOf(YouTube)).call(this, props));
4372
+
4373
+ _this.onPlayerReady = function (event) {
4374
+ return _this.props.onReady(event);
4375
+ };
4376
+
4377
+ _this.onPlayerError = function (event) {
4378
+ return _this.props.onError(event);
4379
+ };
4380
+
4381
+ _this.onPlayerStateChange = function (event) {
4382
+ _this.props.onStateChange(event);
4383
+ switch (event.data) {
4384
+
4385
+ case YouTube.PlayerState.ENDED:
4386
+ _this.props.onEnd(event);
4387
+ break;
4388
+
4389
+ case YouTube.PlayerState.PLAYING:
4390
+ _this.props.onPlay(event);
4391
+ break;
4392
+
4393
+ case YouTube.PlayerState.PAUSED:
4394
+ _this.props.onPause(event);
4395
+ break;
4396
+
4397
+ default:
4398
+ }
4399
+ };
4400
+
4401
+ _this.onPlayerPlaybackRateChange = function (event) {
4402
+ return _this.props.onPlaybackRateChange(event);
4403
+ };
4404
+
4405
+ _this.onPlayerPlaybackQualityChange = function (event) {
4406
+ return _this.props.onPlaybackQualityChange(event);
4407
+ };
4408
+
4409
+ _this.createPlayer = function () {
4410
+ // do not attempt to create a player server-side, it won't work
4411
+ if (typeof document === 'undefined') return;
4412
+ // create player
4413
+ var playerOpts = _extends$1({}, _this.props.opts, {
4414
+ // preload the `videoId` video if one is already given
4415
+ videoId: _this.props.videoId
4416
+ });
4417
+ _this.internalPlayer = youTubePlayer(_this.container, playerOpts);
4418
+ // attach event handlers
4419
+ _this.internalPlayer.on('ready', _this.onPlayerReady);
4420
+ _this.internalPlayer.on('error', _this.onPlayerError);
4421
+ _this.internalPlayer.on('stateChange', _this.onPlayerStateChange);
4422
+ _this.internalPlayer.on('playbackRateChange', _this.onPlayerPlaybackRateChange);
4423
+ _this.internalPlayer.on('playbackQualityChange', _this.onPlayerPlaybackQualityChange);
4424
+ };
4425
+
4426
+ _this.resetPlayer = function () {
4427
+ return _this.internalPlayer.destroy().then(_this.createPlayer);
4428
+ };
4429
+
4430
+ _this.updatePlayer = function () {
4431
+ _this.internalPlayer.getIframe().then(function (iframe) {
4432
+ if (_this.props.id) iframe.setAttribute('id', _this.props.id);else iframe.removeAttribute('id');
4433
+ if (_this.props.className) iframe.setAttribute('class', _this.props.className);else iframe.removeAttribute('class');
4434
+ });
4435
+ };
4436
+
4437
+ _this.updateVideo = function () {
4438
+ if (typeof _this.props.videoId === 'undefined' || _this.props.videoId === null) {
4439
+ _this.internalPlayer.stopVideo();
4440
+ return;
4441
+ }
4442
+
4443
+ // set queueing options
4444
+ var autoplay = false;
4445
+ var opts = {
4446
+ videoId: _this.props.videoId
4447
+ };
4448
+ if ('playerVars' in _this.props.opts) {
4449
+ autoplay = _this.props.opts.playerVars.autoplay === 1;
4450
+ if ('start' in _this.props.opts.playerVars) {
4451
+ opts.startSeconds = _this.props.opts.playerVars.start;
4452
+ }
4453
+ if ('end' in _this.props.opts.playerVars) {
4454
+ opts.endSeconds = _this.props.opts.playerVars.end;
4455
+ }
4456
+ }
4457
+
4458
+ // if autoplay is enabled loadVideoById
4459
+ if (autoplay) {
4460
+ _this.internalPlayer.loadVideoById(opts);
4461
+ return;
4462
+ }
4463
+ // default behaviour just cues the video
4464
+ _this.internalPlayer.cueVideoById(opts);
4465
+ };
4466
+
4467
+ _this.refContainer = function (container) {
4468
+ _this.container = container;
4469
+ };
4470
+
4471
+ _this.container = null;
4472
+ _this.internalPlayer = null;
4473
+ return _this;
4474
+ }
4475
+
4476
+ /**
4477
+ * Expose PlayerState constants for convenience. These constants can also be
4478
+ * accessed through the global YT object after the YouTube IFrame API is instantiated.
4479
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
4480
+ */
4481
+
4482
+
4483
+ _createClass(YouTube, [{
4484
+ key: 'componentDidMount',
4485
+ value: function componentDidMount() {
4486
+ this.createPlayer();
4487
+ }
4488
+ }, {
4489
+ key: 'componentDidUpdate',
4490
+ value: function componentDidUpdate(prevProps) {
4491
+ if (shouldUpdatePlayer(prevProps, this.props)) {
4492
+ this.updatePlayer();
4493
+ }
4494
+
4495
+ if (shouldResetPlayer(prevProps, this.props)) {
4496
+ this.resetPlayer();
4497
+ }
4498
+
4499
+ if (shouldUpdateVideo(prevProps, this.props)) {
4500
+ this.updateVideo();
4501
+ }
4502
+ }
4503
+ }, {
4504
+ key: 'componentWillUnmount',
4505
+ value: function componentWillUnmount() {
4506
+ /**
4507
+ * Note: The `youtube-player` package that is used promisifies all Youtube
4508
+ * Player API calls, which introduces a delay of a tick before it actually
4509
+ * gets destroyed. Since React attempts to remove the element instantly
4510
+ * this method isn't quick enough to reset the container element.
4511
+ */
4512
+ this.internalPlayer.destroy();
4513
+ }
4514
+
4515
+ /**
4516
+ * https://developers.google.com/youtube/iframe_api_reference#onReady
4517
+ *
4518
+ * @param {Object} event
4519
+ * @param {Object} target - player object
4520
+ */
4521
+
4522
+
4523
+ /**
4524
+ * https://developers.google.com/youtube/iframe_api_reference#onError
4525
+ *
4526
+ * @param {Object} event
4527
+ * @param {Integer} data - error type
4528
+ * @param {Object} target - player object
4529
+ */
4530
+
4531
+
4532
+ /**
4533
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
4534
+ *
4535
+ * @param {Object} event
4536
+ * @param {Integer} data - status change type
4537
+ * @param {Object} target - actual YT player
4538
+ */
4539
+
4540
+
4541
+ /**
4542
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackRateChange
4543
+ *
4544
+ * @param {Object} event
4545
+ * @param {Float} data - playback rate
4546
+ * @param {Object} target - actual YT player
4547
+ */
4548
+
4549
+
4550
+ /**
4551
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackQualityChange
4552
+ *
4553
+ * @param {Object} event
4554
+ * @param {String} data - playback quality
4555
+ * @param {Object} target - actual YT player
4556
+ */
4557
+
4558
+
4559
+ /**
4560
+ * Initialize the Youtube Player API on the container and attach event handlers
4561
+ */
4562
+
4563
+
4564
+ /**
4565
+ * Shorthand for destroying and then re-creating the Youtube Player
4566
+ */
4567
+
4568
+
4569
+ /**
4570
+ * Method to update the id and class of the Youtube Player iframe.
4571
+ * React should update this automatically but since the Youtube Player API
4572
+ * replaced the DIV that is mounted by React we need to do this manually.
4573
+ */
4574
+
4575
+
4576
+ /**
4577
+ * Call Youtube Player API methods to update the currently playing video.
4578
+ * Depeding on the `opts.playerVars.autoplay` this function uses one of two
4579
+ * Youtube Player API methods to update the video.
4580
+ */
4581
+
4582
+ }, {
4583
+ key: 'render',
4584
+ value: function render() {
4585
+ return React__default.createElement(
4586
+ 'div',
4587
+ { className: this.props.containerClassName },
4588
+ React__default.createElement('div', { id: this.props.id, className: this.props.className, ref: this.refContainer })
4589
+ );
4590
+ }
4591
+ }]);
4592
+
4593
+ return YouTube;
4594
+ }(React__default.Component);
4595
+
4596
+ YouTube.propTypes = {
4597
+ videoId: PropTypes.string,
4598
+
4599
+ // custom ID for player element
4600
+ id: PropTypes.string,
4601
+
4602
+ // custom class name for player element
4603
+ className: PropTypes.string,
4604
+ // custom class name for player container element
4605
+ containerClassName: PropTypes.string,
4606
+
4607
+ // https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
4608
+ opts: PropTypes.objectOf(PropTypes.any),
4609
+
4610
+ // event subscriptions
4611
+ onReady: PropTypes.func,
4612
+ onError: PropTypes.func,
4613
+ onPlay: PropTypes.func,
4614
+ onPause: PropTypes.func,
4615
+ onEnd: PropTypes.func,
4616
+ onStateChange: PropTypes.func,
4617
+ onPlaybackRateChange: PropTypes.func,
4618
+ onPlaybackQualityChange: PropTypes.func
4619
+ };
4620
+ YouTube.defaultProps = {
4621
+ id: null,
4622
+ className: null,
4623
+ opts: {},
4624
+ containerClassName: '',
4625
+ onReady: function onReady() {},
4626
+ onError: function onError() {},
4627
+ onPlay: function onPlay() {},
4628
+ onPause: function onPause() {},
4629
+ onEnd: function onEnd() {},
4630
+ onStateChange: function onStateChange() {},
4631
+ onPlaybackRateChange: function onPlaybackRateChange() {},
4632
+ onPlaybackQualityChange: function onPlaybackQualityChange() {}
4633
+ };
4634
+ YouTube.PlayerState = {
4635
+ UNSTARTED: -1,
4636
+ ENDED: 0,
4637
+ PLAYING: 1,
4638
+ PAUSED: 2,
4639
+ BUFFERING: 3,
4640
+ CUED: 5
4641
+ };
4642
+
4643
+ var getSerializers = function getSerializers() {
4644
+ return {
4645
+ types: {
4646
+ youtube: function youtube(_ref) {
4647
+ var node = _ref.node;
4648
+ var url = node.url;
4649
+
4650
+ var id = getYoutubeId(url);
4651
+ return React__default.createElement(YouTube, { videoId: id, className: 'youtube' });
4652
+ }
4653
+ }
4654
+ };
4655
+ };
4656
+
4657
+ export { DeckContent, DeckQueue, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
2791
4658
  //# sourceMappingURL=index.es.js.map