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