From 7d102fab75376e6a657b909cf71df104c35abdc2 Mon Sep 17 00:00:00 2001 From: toxic-johann <353904974@qq.com> Date: Sun, 12 Aug 2018 23:16:06 +0800 Subject: [PATCH] build: 0.10.6 add index.esm.js to fix https://github.com/Chimeejs/chimee/issues/142 https://github.com/Chimeejs/chimee/issues/142 --- README.md | 1 + build/rollup.config.base.js | 25 +- build/rollup.config.esm.js | 13 + bundle-size/common.html | 201 +- bundle-size/es.html | 201 +- bundle-size/esm.html | 4429 +++++++++++++ bundle-size/min.html | 203 +- bundle-size/umd.html | 203 +- demo/esm-import/index.html | 21 + doc/zh-cn/README.md | 13 +- lib/index.browser.js | 20 +- lib/index.esm.js | 11315 ++++++++++++++++++++++++++++++++++ lib/index.js | 6 +- lib/index.min.js | 2 +- lib/index.mjs | 6 +- package.json | 23 +- 16 files changed, 16289 insertions(+), 393 deletions(-) create mode 100644 build/rollup.config.esm.js create mode 100644 bundle-size/esm.html create mode 100644 demo/esm-import/index.html create mode 100644 lib/index.esm.js diff --git a/README.md b/README.md index a288dbe9..a0ba531c 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ You will find four different builds in the lib. | index.mjs | esmodule | An es module, mostly used in Webpack 2 and rollup. | Yes | | index.browser.js | umd | Can be used directly in browser | No (It's in development) | | index.min.js | umd | Can be used directly in browser | No (It's in production) | +| Index.esm.js | esmodule | An es module, mostly used in browser es module | No (It's in development) | ## Development diff --git a/build/rollup.config.base.js b/build/rollup.config.base.js index 2ef97e9f..387ac10f 100644 --- a/build/rollup.config.base.js +++ b/build/rollup.config.base.js @@ -55,6 +55,27 @@ const babelConfig = { runtimeHelpers: true, babelrc: false, }, + esm: { + presets: [ + 'flow', + [ 'env', { + modules: false, + targets: { + browsers: [ 'last 2 versions', 'not ie <= 8' ], + }, + }], + 'stage-0', + ], + exclude: 'node_modules/**', + plugins: [ + 'external-helpers', + 'transform-decorators-legacy', + 'transform-runtime', + ], + externalHelpers: true, + runtimeHelpers: true, + babelrc: false, + }, umd: { presets: [ 'flow', @@ -122,7 +143,7 @@ export default function(mode) { return { input: 'src/index.js', external(id) { - return !/min|umd|iife/.test(mode) && externalRegExp.test(id); + return !/min|umd|iife|esm/.test(mode) && externalRegExp.test(id); }, plugins: [ babel(babelConfig[mode]), @@ -133,7 +154,7 @@ export default function(mode) { }), resolve({ customResolveOptions: { - moduleDirectory: /min|umd|iife/.test(mode) ? [ 'src', 'node_modules' ] : [ 'src' ], + moduleDirectory: /min|umd|iife|esm/.test(mode) ? [ 'src', 'node_modules' ] : [ 'src' ], }, }), visualizer({ diff --git a/build/rollup.config.esm.js b/build/rollup.config.esm.js new file mode 100644 index 00000000..18a708d3 --- /dev/null +++ b/build/rollup.config.esm.js @@ -0,0 +1,13 @@ +import base, { banner } from './rollup.config.base'; +import replace from 'rollup-plugin-replace'; +const config = base('esm'); +config.plugins.unshift(replace({ + 'process.env.NODE_ENV': '"development"', +})); +export default Object.assign(config, { + output: { + format: 'es', + file: 'lib/index.esm.js', + banner, + }, +}); diff --git a/bundle-size/common.html b/bundle-size/common.html index f9517f44..f15d1f9d 100644 --- a/bundle-size/common.html +++ b/bundle-size/common.html @@ -2163,6 +2163,9 @@

RollUp Visualizer

displayable: function() { return this.rgb().displayable(); }, + hex: function() { + return this.rgb().hex(); + }, toString: function() { return this.rgb() + ""; } @@ -2229,6 +2232,9 @@

RollUp Visualizer

&& (0 <= this.b && this.b <= 255) && (0 <= this.opacity && this.opacity <= 1); }, + hex: function() { + return "#" + hex(this.r) + hex(this.g) + hex(this.b); + }, toString: function() { var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); return (a === 1 ? "rgb(" : "rgba(") @@ -2239,6 +2245,11 @@

RollUp Visualizer

} })); + function hex(value) { + value = Math.max(0, Math.min(255, Math.round(value) || 0)); + return (value < 16 ? "0" : "") + value.toString(16); + } + function hsla(h, s, l, a) { if (a <= 0) h = s = l = NaN; else if (l <= 0 || l >= 1) h = s = NaN; @@ -2323,10 +2334,11 @@

RollUp Visualizer

var deg2rad = Math.PI / 180; var rad2deg = 180 / Math.PI; - var Kn = 18, - Xn = 0.950470, // D65 standard referent + // https://beta.observablehq.com/@mbostock/lab-and-rgb + var K = 18, + Xn = 0.96422, Yn = 1, - Zn = 1.088830, + Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, @@ -2335,16 +2347,19 @@

RollUp Visualizer

function labConvert(o) { if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); if (o instanceof Hcl) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); var h = o.h * deg2rad; return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); } if (!(o instanceof Rgb)) o = rgbConvert(o); - var b = rgb2xyz(o.r), - a = rgb2xyz(o.g), - l = rgb2xyz(o.b), - x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn), - y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn), - z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); } @@ -2361,22 +2376,22 @@

RollUp Visualizer

define(Lab, lab, extend(Color, { brighter: function(k) { - return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, darker: function(k) { - return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, rgb: function() { var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200; - y = Yn * lab2xyz(y); x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); z = Zn * lab2xyz(z); return new Rgb( - xyz2rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB - xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), - xyz2rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z), + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity ); } @@ -2390,17 +2405,18 @@

RollUp Visualizer

return t > t1 ? t * t * t : t2 * (t - t0); } - function xyz2rgb(x) { + function lrgb2rgb(x) { return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); } - function rgb2xyz(x) { + function rgb2lrgb(x) { return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); } function hclConvert(o) { if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity); var h = Math.atan2(o.b, o.a) * rad2deg; return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); } @@ -2418,10 +2434,10 @@

RollUp Visualizer

define(Hcl, hcl, extend(Color, { brighter: function(k) { - return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity); + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); }, darker: function(k) { - return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity); + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); }, rgb: function() { return labConvert(this).rgb(); @@ -2750,22 +2766,22 @@

RollUp Visualizer

range$$1 = unit, interpolate$$1 = value, clamp = false, - piecewise, + piecewise$$1, output, input; function rescale() { - piecewise = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap; + piecewise$$1 = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap; output = input = null; return scale; } function scale(x) { - return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x); + return (output || (output = piecewise$$1(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x); } scale.invert = function(y) { - return (input || (input = piecewise(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y); + return (input || (input = piecewise$$1(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y); }; scale.domain = function(_) { @@ -2837,19 +2853,53 @@

RollUp Visualizer

}; } - function formatDefault(x, p) { - x = x.toPrecision(p); + // [[fill]align][sign][symbol][0][width][,][.precision][~][type] + var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + + function formatSpecifier(specifier) { + return new FormatSpecifier(specifier); + } + + formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + + function FormatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + this.fill = match[1] || " "; + this.align = match[2] || ">"; + this.sign = match[3] || "-"; + this.symbol = match[4] || ""; + this.zero = !!match[5]; + this.width = match[6] && +match[6]; + this.comma = !!match[7]; + this.precision = match[8] && +match[8].slice(1); + this.trim = !!match[9]; + this.type = match[10] || ""; + } + + FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width == null ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; + }; - out: for (var n = x.length, i = 1, i0 = -1, i1; i < n; ++i) { - switch (x[i]) { + // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. + function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { case ".": i0 = i1 = i; break; case "0": if (i0 === 0) i0 = i; i1 = i; break; - case "e": break out; - default: if (i0 > 0) i0 = 0; break; + default: if (i0 > 0) { if (!+s[i]) break out; i0 = 0; } break; } } - - return i0 > 0 ? x.slice(0, i0) + x.slice(i1 + 1) : x; + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; } var prefixExponent; @@ -2878,7 +2928,6 @@

RollUp Visualizer

} var formatTypes = { - "": formatDefault, "%": function(x, p) { return (x * 100).toFixed(p); }, "b": function(x) { return Math.round(x).toString(2); }, "c": function(x) { return x + ""; }, @@ -2894,61 +2943,6 @@

RollUp Visualizer

"x": function(x) { return Math.round(x).toString(16); } }; - // [[fill]align][sign][symbol][0][width][,][.precision][type] - var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i; - - function formatSpecifier(specifier) { - return new FormatSpecifier(specifier); - } - - formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof - - function FormatSpecifier(specifier) { - if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); - - var match, - fill = match[1] || " ", - align = match[2] || ">", - sign = match[3] || "-", - symbol = match[4] || "", - zero = !!match[5], - width = match[6] && +match[6], - comma = !!match[7], - precision = match[8] && +match[8].slice(1), - type = match[9] || ""; - - // The "n" type is an alias for ",g". - if (type === "n") comma = true, type = "g"; - - // Map invalid types to the default format. - else if (!formatTypes[type]) type = ""; - - // If zero fill is specified, padding goes after sign and before digits. - if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; - - this.fill = fill; - this.align = align; - this.sign = sign; - this.symbol = symbol; - this.zero = zero; - this.width = width; - this.comma = comma; - this.precision = precision; - this.type = type; - } - - FormatSpecifier.prototype.toString = function() { - return this.fill - + this.align - + this.sign - + this.symbol - + (this.zero ? "0" : "") - + (this.width == null ? "" : Math.max(1, this.width | 0)) - + (this.comma ? "," : "") - + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0)) - + this.type; - }; - function identity$3(x) { return x; } @@ -2973,8 +2967,18 @@

RollUp Visualizer

width = specifier.width, comma = specifier.comma, precision = specifier.precision, + trim = specifier.trim, type = specifier.type; + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision == null && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + // Compute the prefix and suffix. // For SI-prefix, the suffix is lazily computed. var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", @@ -2984,13 +2988,13 @@

RollUp Visualizer

// Is this an integer type? // Can this type generate exponential notation? var formatType = formatTypes[type], - maybeSuffix = !type || /[defgprs%]/.test(type); + maybeSuffix = /[defgprs%]/.test(type); // Set the default precision if not specified, // or clamp the specified precision to the supported range. // For significant precision, it must be in [1, 21]. // For fixed precision, it must be in [0, 20]. - precision = precision == null ? (type ? 6 : 12) + precision = precision == null ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); @@ -3009,6 +3013,9 @@

RollUp Visualizer

var valueNegative = value < 0; value = formatType(Math.abs(value), precision); + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + // If a negative value rounds to zero during formatting, treat as positive. if (valueNegative && +value === 0) valueNegative = false; @@ -3324,6 +3331,7 @@

RollUp Visualizer

return (end - start) / k; }); }; + var milliseconds = millisecond.range; var durationSecond = 1e3; var durationMinute = 6e4; @@ -3340,6 +3348,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCSeconds(); }); + var seconds = second.range; var minute = newInterval(function(date) { date.setTime(Math.floor(date / durationMinute) * durationMinute); @@ -3350,6 +3359,7 @@

RollUp Visualizer

}, function(date) { return date.getMinutes(); }); + var minutes = minute.range; var hour = newInterval(function(date) { var offset = date.getTimezoneOffset() * durationMinute % durationHour; @@ -3362,6 +3372,7 @@

RollUp Visualizer

}, function(date) { return date.getHours(); }); + var hours = hour.range; var day = newInterval(function(date) { date.setHours(0, 0, 0, 0); @@ -3372,6 +3383,7 @@

RollUp Visualizer

}, function(date) { return date.getDate() - 1; }); + var days = day.range; function weekday(i) { return newInterval(function(date) { @@ -3392,6 +3404,8 @@

RollUp Visualizer

var friday = weekday(5); var saturday = weekday(6); + var sundays = sunday.range; + var month = newInterval(function(date) { date.setDate(1); date.setHours(0, 0, 0, 0); @@ -3402,6 +3416,7 @@

RollUp Visualizer

}, function(date) { return date.getMonth(); }); + var months = month.range; var year = newInterval(function(date) { date.setMonth(0, 1); @@ -3424,6 +3439,7 @@

RollUp Visualizer

date.setFullYear(date.getFullYear() + step * k); }); }; + var years = year.range; var utcMinute = newInterval(function(date) { date.setUTCSeconds(0, 0); @@ -3434,6 +3450,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCMinutes(); }); + var utcMinutes = utcMinute.range; var utcHour = newInterval(function(date) { date.setUTCMinutes(0, 0, 0); @@ -3444,6 +3461,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCHours(); }); + var utcHours = utcHour.range; var utcDay = newInterval(function(date) { date.setUTCHours(0, 0, 0, 0); @@ -3454,6 +3472,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCDate() - 1; }); + var utcDays = utcDay.range; function utcWeekday(i) { return newInterval(function(date) { @@ -3474,6 +3493,8 @@

RollUp Visualizer

var utcFriday = utcWeekday(5); var utcSaturday = utcWeekday(6); + var utcSundays = utcSunday.range; + var utcMonth = newInterval(function(date) { date.setUTCDate(1); date.setUTCHours(0, 0, 0, 0); @@ -3484,6 +3505,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCMonth(); }); + var utcMonths = utcMonth.range; var utcYear = newInterval(function(date) { date.setUTCMonth(0, 1); @@ -3506,6 +3528,7 @@

RollUp Visualizer

date.setUTCFullYear(date.getUTCFullYear() + step * k); }); }; + var utcYears = utcYear.range; function localDate(d) { if (0 <= d.y && d.y < 100) { diff --git a/bundle-size/es.html b/bundle-size/es.html index 7e289266..806ea673 100644 --- a/bundle-size/es.html +++ b/bundle-size/es.html @@ -2163,6 +2163,9 @@

RollUp Visualizer

displayable: function() { return this.rgb().displayable(); }, + hex: function() { + return this.rgb().hex(); + }, toString: function() { return this.rgb() + ""; } @@ -2229,6 +2232,9 @@

RollUp Visualizer

&& (0 <= this.b && this.b <= 255) && (0 <= this.opacity && this.opacity <= 1); }, + hex: function() { + return "#" + hex(this.r) + hex(this.g) + hex(this.b); + }, toString: function() { var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); return (a === 1 ? "rgb(" : "rgba(") @@ -2239,6 +2245,11 @@

RollUp Visualizer

} })); + function hex(value) { + value = Math.max(0, Math.min(255, Math.round(value) || 0)); + return (value < 16 ? "0" : "") + value.toString(16); + } + function hsla(h, s, l, a) { if (a <= 0) h = s = l = NaN; else if (l <= 0 || l >= 1) h = s = NaN; @@ -2323,10 +2334,11 @@

RollUp Visualizer

var deg2rad = Math.PI / 180; var rad2deg = 180 / Math.PI; - var Kn = 18, - Xn = 0.950470, // D65 standard referent + // https://beta.observablehq.com/@mbostock/lab-and-rgb + var K = 18, + Xn = 0.96422, Yn = 1, - Zn = 1.088830, + Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, @@ -2335,16 +2347,19 @@

RollUp Visualizer

function labConvert(o) { if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); if (o instanceof Hcl) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); var h = o.h * deg2rad; return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); } if (!(o instanceof Rgb)) o = rgbConvert(o); - var b = rgb2xyz(o.r), - a = rgb2xyz(o.g), - l = rgb2xyz(o.b), - x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn), - y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn), - z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); } @@ -2361,22 +2376,22 @@

RollUp Visualizer

define(Lab, lab, extend(Color, { brighter: function(k) { - return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, darker: function(k) { - return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, rgb: function() { var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200; - y = Yn * lab2xyz(y); x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); z = Zn * lab2xyz(z); return new Rgb( - xyz2rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB - xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), - xyz2rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z), + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity ); } @@ -2390,17 +2405,18 @@

RollUp Visualizer

return t > t1 ? t * t * t : t2 * (t - t0); } - function xyz2rgb(x) { + function lrgb2rgb(x) { return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); } - function rgb2xyz(x) { + function rgb2lrgb(x) { return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); } function hclConvert(o) { if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity); var h = Math.atan2(o.b, o.a) * rad2deg; return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); } @@ -2418,10 +2434,10 @@

RollUp Visualizer

define(Hcl, hcl, extend(Color, { brighter: function(k) { - return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity); + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); }, darker: function(k) { - return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity); + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); }, rgb: function() { return labConvert(this).rgb(); @@ -2750,22 +2766,22 @@

RollUp Visualizer

range$$1 = unit, interpolate$$1 = value, clamp = false, - piecewise, + piecewise$$1, output, input; function rescale() { - piecewise = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap; + piecewise$$1 = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap; output = input = null; return scale; } function scale(x) { - return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x); + return (output || (output = piecewise$$1(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x); } scale.invert = function(y) { - return (input || (input = piecewise(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y); + return (input || (input = piecewise$$1(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y); }; scale.domain = function(_) { @@ -2837,19 +2853,53 @@

RollUp Visualizer

}; } - function formatDefault(x, p) { - x = x.toPrecision(p); + // [[fill]align][sign][symbol][0][width][,][.precision][~][type] + var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + + function formatSpecifier(specifier) { + return new FormatSpecifier(specifier); + } + + formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + + function FormatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + this.fill = match[1] || " "; + this.align = match[2] || ">"; + this.sign = match[3] || "-"; + this.symbol = match[4] || ""; + this.zero = !!match[5]; + this.width = match[6] && +match[6]; + this.comma = !!match[7]; + this.precision = match[8] && +match[8].slice(1); + this.trim = !!match[9]; + this.type = match[10] || ""; + } + + FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width == null ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; + }; - out: for (var n = x.length, i = 1, i0 = -1, i1; i < n; ++i) { - switch (x[i]) { + // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. + function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { case ".": i0 = i1 = i; break; case "0": if (i0 === 0) i0 = i; i1 = i; break; - case "e": break out; - default: if (i0 > 0) i0 = 0; break; + default: if (i0 > 0) { if (!+s[i]) break out; i0 = 0; } break; } } - - return i0 > 0 ? x.slice(0, i0) + x.slice(i1 + 1) : x; + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; } var prefixExponent; @@ -2878,7 +2928,6 @@

RollUp Visualizer

} var formatTypes = { - "": formatDefault, "%": function(x, p) { return (x * 100).toFixed(p); }, "b": function(x) { return Math.round(x).toString(2); }, "c": function(x) { return x + ""; }, @@ -2894,61 +2943,6 @@

RollUp Visualizer

"x": function(x) { return Math.round(x).toString(16); } }; - // [[fill]align][sign][symbol][0][width][,][.precision][type] - var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i; - - function formatSpecifier(specifier) { - return new FormatSpecifier(specifier); - } - - formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof - - function FormatSpecifier(specifier) { - if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); - - var match, - fill = match[1] || " ", - align = match[2] || ">", - sign = match[3] || "-", - symbol = match[4] || "", - zero = !!match[5], - width = match[6] && +match[6], - comma = !!match[7], - precision = match[8] && +match[8].slice(1), - type = match[9] || ""; - - // The "n" type is an alias for ",g". - if (type === "n") comma = true, type = "g"; - - // Map invalid types to the default format. - else if (!formatTypes[type]) type = ""; - - // If zero fill is specified, padding goes after sign and before digits. - if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; - - this.fill = fill; - this.align = align; - this.sign = sign; - this.symbol = symbol; - this.zero = zero; - this.width = width; - this.comma = comma; - this.precision = precision; - this.type = type; - } - - FormatSpecifier.prototype.toString = function() { - return this.fill - + this.align - + this.sign - + this.symbol - + (this.zero ? "0" : "") - + (this.width == null ? "" : Math.max(1, this.width | 0)) - + (this.comma ? "," : "") - + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0)) - + this.type; - }; - function identity$3(x) { return x; } @@ -2973,8 +2967,18 @@

RollUp Visualizer

width = specifier.width, comma = specifier.comma, precision = specifier.precision, + trim = specifier.trim, type = specifier.type; + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision == null && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + // Compute the prefix and suffix. // For SI-prefix, the suffix is lazily computed. var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", @@ -2984,13 +2988,13 @@

RollUp Visualizer

// Is this an integer type? // Can this type generate exponential notation? var formatType = formatTypes[type], - maybeSuffix = !type || /[defgprs%]/.test(type); + maybeSuffix = /[defgprs%]/.test(type); // Set the default precision if not specified, // or clamp the specified precision to the supported range. // For significant precision, it must be in [1, 21]. // For fixed precision, it must be in [0, 20]. - precision = precision == null ? (type ? 6 : 12) + precision = precision == null ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); @@ -3009,6 +3013,9 @@

RollUp Visualizer

var valueNegative = value < 0; value = formatType(Math.abs(value), precision); + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + // If a negative value rounds to zero during formatting, treat as positive. if (valueNegative && +value === 0) valueNegative = false; @@ -3324,6 +3331,7 @@

RollUp Visualizer

return (end - start) / k; }); }; + var milliseconds = millisecond.range; var durationSecond = 1e3; var durationMinute = 6e4; @@ -3340,6 +3348,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCSeconds(); }); + var seconds = second.range; var minute = newInterval(function(date) { date.setTime(Math.floor(date / durationMinute) * durationMinute); @@ -3350,6 +3359,7 @@

RollUp Visualizer

}, function(date) { return date.getMinutes(); }); + var minutes = minute.range; var hour = newInterval(function(date) { var offset = date.getTimezoneOffset() * durationMinute % durationHour; @@ -3362,6 +3372,7 @@

RollUp Visualizer

}, function(date) { return date.getHours(); }); + var hours = hour.range; var day = newInterval(function(date) { date.setHours(0, 0, 0, 0); @@ -3372,6 +3383,7 @@

RollUp Visualizer

}, function(date) { return date.getDate() - 1; }); + var days = day.range; function weekday(i) { return newInterval(function(date) { @@ -3392,6 +3404,8 @@

RollUp Visualizer

var friday = weekday(5); var saturday = weekday(6); + var sundays = sunday.range; + var month = newInterval(function(date) { date.setDate(1); date.setHours(0, 0, 0, 0); @@ -3402,6 +3416,7 @@

RollUp Visualizer

}, function(date) { return date.getMonth(); }); + var months = month.range; var year = newInterval(function(date) { date.setMonth(0, 1); @@ -3424,6 +3439,7 @@

RollUp Visualizer

date.setFullYear(date.getFullYear() + step * k); }); }; + var years = year.range; var utcMinute = newInterval(function(date) { date.setUTCSeconds(0, 0); @@ -3434,6 +3450,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCMinutes(); }); + var utcMinutes = utcMinute.range; var utcHour = newInterval(function(date) { date.setUTCMinutes(0, 0, 0); @@ -3444,6 +3461,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCHours(); }); + var utcHours = utcHour.range; var utcDay = newInterval(function(date) { date.setUTCHours(0, 0, 0, 0); @@ -3454,6 +3472,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCDate() - 1; }); + var utcDays = utcDay.range; function utcWeekday(i) { return newInterval(function(date) { @@ -3474,6 +3493,8 @@

RollUp Visualizer

var utcFriday = utcWeekday(5); var utcSaturday = utcWeekday(6); + var utcSundays = utcSunday.range; + var utcMonth = newInterval(function(date) { date.setUTCDate(1); date.setUTCHours(0, 0, 0, 0); @@ -3484,6 +3505,7 @@

RollUp Visualizer

}, function(date) { return date.getUTCMonth(); }); + var utcMonths = utcMonth.range; var utcYear = newInterval(function(date) { date.setUTCMonth(0, 1); @@ -3506,6 +3528,7 @@

RollUp Visualizer

date.setUTCFullYear(date.getUTCFullYear() + step * k); }); }; + var utcYears = utcYear.range; function localDate(d) { if (0 <= d.y && d.y < 100) { diff --git a/bundle-size/esm.html b/bundle-size/esm.html new file mode 100644 index 00000000..0edc9c5c --- /dev/null +++ b/bundle-size/esm.html @@ -0,0 +1,4429 @@ + + RollUp Visualizer + + +
+
+

RollUp Visualizer

+ +
+
+
+
+ + + \ No newline at end of file diff --git a/bundle-size/min.html b/bundle-size/min.html index 08663cf6..07c6351f 100644 --- a/bundle-size/min.html +++ b/bundle-size/min.html @@ -121,7 +121,7 @@

RollUp Visualizer

- + + + + +
+ + \ No newline at end of file diff --git a/doc/zh-cn/README.md b/doc/zh-cn/README.md index a92d05f0..13c65516 100644 --- a/doc/zh-cn/README.md +++ b/doc/zh-cn/README.md @@ -204,12 +204,13 @@ const player = new ChimeeMobilePlayer({ 你会发现我们有四种构建的版本。 -| 名称 | 种类 | 用处 | 是否需要定义环境 | -| ---------------- | -------- | ------------------------------------ | -------------------- | -| index.js | commonjs | Common js, 常用于 Webpack 1. | 是 | -| index.mjs | esmodule | in es module, 常用于 webpack 2 和 rollup | 是 | -| index.browser.js | umd | 常直接用于浏览器 | 否,构建为 development 环境 | -| index.min.js | umd | 常直接用于浏览器 | 否,构建为 production 环境 | +| 名称 | 种类 | 用处 | 是否需要定义环境 | +| ---------------- | -------- | ---------------------------------------- | --------------------------- | +| index.js | commonjs | Common js, 常用于 Webpack 1. | 是 | +| index.mjs | esmodule | in es module, 常用于 webpack 2 和 rollup | 是 | +| index.browser.js | umd | 常直接用于浏览器 | 否,构建为 development 环境 | +| index.min.js | umd | 常直接用于浏览器 | 否,构建为 production 环境 | +| index.esm.js | esmodule | 用于浏览器使用 module 的模式引入 | 否,构建为 development 环境 | ## Development vs. Production diff --git a/lib/index.browser.js b/lib/index.browser.js index 19c3822d..325bf119 100644 --- a/lib/index.browser.js +++ b/lib/index.browser.js @@ -1,6 +1,6 @@ /** - * chimee v0.10.5 + * chimee v0.10.6 * (c) 2017-2018 toxic-johann * Released under MIT */ @@ -576,6 +576,8 @@ if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { // Set @@toStringTag to native iterators _setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis); } } // fix Array#{values, @@iterator}.name in V8 / FF @@ -584,7 +586,7 @@ $default = function values() { return $native.call(this); }; } // Define iterator - if ((FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { _hide(proto, ITERATOR, $default); } // Plug for library @@ -3556,13 +3558,13 @@ } }); - var from = _core.Array.from; + var from_1 = _core.Array.from; - var from$1 = createCommonjsModule(function (module) { - module.exports = { "default": from, __esModule: true }; + var from_1$1 = createCommonjsModule(function (module) { + module.exports = { "default": from_1, __esModule: true }; }); - var _Array$from = unwrapExports(from$1); + var _Array$from = unwrapExports(from_1$1); var toConsumableArray = createCommonjsModule(function (module, exports) { @@ -3570,7 +3572,7 @@ - var _from2 = _interopRequireDefault(from$1); + var _from2 = _interopRequireDefault(from_1$1); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -7731,7 +7733,7 @@ var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this)); _this.destroyed = false; - _this.VERSION = '0.10.5'; + _this.VERSION = '0.10.6'; _this.__operable = true; _this.__level = 0; @@ -11242,7 +11244,7 @@ }), _descriptor2$1 = _applyDecoratedDescriptor$8(_class2$2.prototype, 'version', [frozen], { enumerable: true, initializer: function initializer() { - return '0.10.5'; + return '0.10.6'; } }), _descriptor3$1 = _applyDecoratedDescriptor$8(_class2$2.prototype, 'config', [frozen], { enumerable: true, diff --git a/lib/index.esm.js b/lib/index.esm.js new file mode 100644 index 00000000..b03ac2ea --- /dev/null +++ b/lib/index.esm.js @@ -0,0 +1,11315 @@ + +/** + * chimee v0.10.6 + * (c) 2017-2018 toxic-johann + * Released under MIT + */ + +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var _global = createCommonjsModule(function (module) { +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); +if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef +}); + +var _core = createCommonjsModule(function (module) { +var core = module.exports = { version: '2.5.7' }; +if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef +}); +var _core_1 = _core.version; + +var _aFunction = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; +}; + +// optional / simple context binding + +var _ctx = function (fn, that, length) { + _aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; +}; + +var _isObject = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +var _anObject = function (it) { + if (!_isObject(it)) throw TypeError(it + ' is not an object!'); + return it; +}; + +var _fails = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } +}; + +// Thank's IE8 for his funny defineProperty +var _descriptors = !_fails(function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; +}); + +var document$1 = _global.document; +// typeof document.createElement is 'object' in old IE +var is = _isObject(document$1) && _isObject(document$1.createElement); +var _domCreate = function (it) { + return is ? document$1.createElement(it) : {}; +}; + +var _ie8DomDefine = !_descriptors && !_fails(function () { + return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7; +}); + +// 7.1.1 ToPrimitive(input [, PreferredType]) + +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +var _toPrimitive = function (it, S) { + if (!_isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); +}; + +var dP = Object.defineProperty; + +var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { + _anObject(O); + P = _toPrimitive(P, true); + _anObject(Attributes); + if (_ie8DomDefine) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; + +var _objectDp = { + f: f +}; + +var _propertyDesc = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; + +var _hide = _descriptors ? function (object, key, value) { + return _objectDp.f(object, key, _propertyDesc(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; + +var hasOwnProperty = {}.hasOwnProperty; +var _has = function (it, key) { + return hasOwnProperty.call(it, key); +}; + +var PROTOTYPE = 'prototype'; + +var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var IS_WRAP = type & $export.W; + var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); + var expProto = exports[PROTOTYPE]; + var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE]; + var key, own, out; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if (own && _has(exports, key)) continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? _ctx(out, _global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function (C) { + var F = function (a, b, c) { + if (this instanceof C) { + switch (arguments.length) { + case 0: return new C(); + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if (IS_PROTO) { + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out); + } + } +}; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +var _export = $export; + +// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) +_export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f }); + +var $Object = _core.Object; +var defineProperty = function defineProperty(it, key, desc) { + return $Object.defineProperty(it, key, desc); +}; + +var defineProperty$1 = createCommonjsModule(function (module) { +module.exports = { "default": defineProperty, __esModule: true }; +}); + +var _Object$defineProperty = unwrapExports(defineProperty$1); + +var toString = {}.toString; + +var _cof = function (it) { + return toString.call(it).slice(8, -1); +}; + +// fallback for non-array-like ES3 and non-enumerable old V8 strings + +// eslint-disable-next-line no-prototype-builtins +var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return _cof(it) == 'String' ? it.split('') : Object(it); +}; + +// 7.2.1 RequireObjectCoercible(argument) +var _defined = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; +}; + +// to indexed object, toObject with fallback for non-array-like ES3 strings + + +var _toIobject = function (it) { + return _iobject(_defined(it)); +}; + +var f$1 = {}.propertyIsEnumerable; + +var _objectPie = { + f: f$1 +}; + +var gOPD = Object.getOwnPropertyDescriptor; + +var f$2 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { + O = _toIobject(O); + P = _toPrimitive(P, true); + if (_ie8DomDefine) try { + return gOPD(O, P); + } catch (e) { /* empty */ } + if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); +}; + +var _objectGopd = { + f: f$2 +}; + +// most Object methods by ES6 should accept primitives + + + +var _objectSap = function (KEY, exec) { + var fn = (_core.Object || {})[KEY] || Object[KEY]; + var exp = {}; + exp[KEY] = exec(fn); + _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp); +}; + +// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + +var $getOwnPropertyDescriptor = _objectGopd.f; + +_objectSap('getOwnPropertyDescriptor', function () { + return function getOwnPropertyDescriptor(it, key) { + return $getOwnPropertyDescriptor(_toIobject(it), key); + }; +}); + +var $Object$1 = _core.Object; +var getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { + return $Object$1.getOwnPropertyDescriptor(it, key); +}; + +var getOwnPropertyDescriptor$1 = createCommonjsModule(function (module) { +module.exports = { "default": getOwnPropertyDescriptor, __esModule: true }; +}); + +var _Object$getOwnPropertyDescriptor = unwrapExports(getOwnPropertyDescriptor$1); + +// 7.1.13 ToObject(argument) + +var _toObject = function (it) { + return Object(_defined(it)); +}; + +var _library = true; + +var _shared = createCommonjsModule(function (module) { +var SHARED = '__core-js_shared__'; +var store = _global[SHARED] || (_global[SHARED] = {}); + +(module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); +})('versions', []).push({ + version: _core.version, + mode: _library ? 'pure' : 'global', + copyright: '© 2018 Denis Pushkarev (zloirock.ru)' +}); +}); + +var id = 0; +var px = Math.random(); +var _uid = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); +}; + +var shared = _shared('keys'); + +var _sharedKey = function (key) { + return shared[key] || (shared[key] = _uid(key)); +}; + +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) + + +var IE_PROTO = _sharedKey('IE_PROTO'); +var ObjectProto = Object.prototype; + +var _objectGpo = Object.getPrototypeOf || function (O) { + O = _toObject(O); + if (_has(O, IE_PROTO)) return O[IE_PROTO]; + if (typeof O.constructor == 'function' && O instanceof O.constructor) { + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; +}; + +// 19.1.2.9 Object.getPrototypeOf(O) + + + +_objectSap('getPrototypeOf', function () { + return function getPrototypeOf(it) { + return _objectGpo(_toObject(it)); + }; +}); + +var getPrototypeOf = _core.Object.getPrototypeOf; + +var getPrototypeOf$1 = createCommonjsModule(function (module) { +module.exports = { "default": getPrototypeOf, __esModule: true }; +}); + +var _Object$getPrototypeOf = unwrapExports(getPrototypeOf$1); + +// 7.1.4 ToInteger +var ceil = Math.ceil; +var floor = Math.floor; +var _toInteger = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; + +// true -> String#at +// false -> String#codePointAt +var _stringAt = function (TO_STRING) { + return function (that, pos) { + var s = String(_defined(that)); + var i = _toInteger(pos); + var l = s.length; + var a, b; + if (i < 0 || i >= l) return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; +}; + +var _redefine = _hide; + +var _iterators = {}; + +// 7.1.15 ToLength + +var min = Math.min; +var _toLength = function (it) { + return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; + +var max = Math.max; +var min$1 = Math.min; +var _toAbsoluteIndex = function (index, length) { + index = _toInteger(index); + return index < 0 ? max(index + length, 0) : min$1(index, length); +}; + +// false -> Array#indexOf +// true -> Array#includes + + + +var _arrayIncludes = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = _toIobject($this); + var length = _toLength(O.length); + var index = _toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) if (IS_INCLUDES || index in O) { + if (O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; + +var arrayIndexOf = _arrayIncludes(false); +var IE_PROTO$1 = _sharedKey('IE_PROTO'); + +var _objectKeysInternal = function (object, names) { + var O = _toIobject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO$1) _has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (_has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); + } + return result; +}; + +// IE 8- don't enum bug keys +var _enumBugKeys = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); + +// 19.1.2.14 / 15.2.3.14 Object.keys(O) + + + +var _objectKeys = Object.keys || function keys(O) { + return _objectKeysInternal(O, _enumBugKeys); +}; + +var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) { + _anObject(O); + var keys = _objectKeys(Properties); + var length = keys.length; + var i = 0; + var P; + while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]); + return O; +}; + +var document$2 = _global.document; +var _html = document$2 && document$2.documentElement; + +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + + + +var IE_PROTO$2 = _sharedKey('IE_PROTO'); +var Empty = function () { /* empty */ }; +var PROTOTYPE$1 = 'prototype'; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var createDict = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = _domCreate('iframe'); + var i = _enumBugKeys.length; + var lt = '<'; + var gt = '>'; + var iframeDocument; + iframe.style.display = 'none'; + _html.appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]]; + return createDict(); +}; + +var _objectCreate = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + Empty[PROTOTYPE$1] = _anObject(O); + result = new Empty(); + Empty[PROTOTYPE$1] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO$2] = O; + } else result = createDict(); + return Properties === undefined ? result : _objectDps(result, Properties); +}; + +var _wks = createCommonjsModule(function (module) { +var store = _shared('wks'); + +var Symbol = _global.Symbol; +var USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function (name) { + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name)); +}; + +$exports.store = store; +}); + +var def = _objectDp.f; + +var TAG = _wks('toStringTag'); + +var _setToStringTag = function (it, tag, stat) { + if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); +}; + +var IteratorPrototype = {}; + +// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() +_hide(IteratorPrototype, _wks('iterator'), function () { return this; }); + +var _iterCreate = function (Constructor, NAME, next) { + Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) }); + _setToStringTag(Constructor, NAME + ' Iterator'); +}; + +var ITERATOR = _wks('iterator'); +var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` +var FF_ITERATOR = '@@iterator'; +var KEYS = 'keys'; +var VALUES = 'values'; + +var returnThis = function () { return this; }; + +var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { + _iterCreate(Constructor, NAME, next); + var getMethod = function (kind) { + if (!BUGGY && kind in proto) return proto[kind]; + switch (kind) { + case KEYS: return function keys() { return new Constructor(this, kind); }; + case VALUES: return function values() { return new Constructor(this, kind); }; + } return function entries() { return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator'; + var DEF_VALUES = DEFAULT == VALUES; + var VALUES_BUG = false; + var proto = Base.prototype; + var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; + var $default = $native || getMethod(DEFAULT); + var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; + var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; + var methods, key, IteratorPrototype; + // Fix native + if ($anyNative) { + IteratorPrototype = _objectGpo($anyNative.call(new Base())); + if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { + // Set @@toStringTag to native iterators + _setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if (DEF_VALUES && $native && $native.name !== VALUES) { + VALUES_BUG = true; + $default = function values() { return $native.call(this); }; + } + // Define iterator + if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + _hide(proto, ITERATOR, $default); + } + // Plug for library + _iterators[NAME] = $default; + _iterators[TAG] = returnThis; + if (DEFAULT) { + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if (FORCED) for (key in methods) { + if (!(key in proto)) _redefine(proto, key, methods[key]); + } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; +}; + +var $at = _stringAt(true); + +// 21.1.3.27 String.prototype[@@iterator]() +_iterDefine(String, 'String', function (iterated) { + this._t = String(iterated); // target + this._i = 0; // next index +// 21.1.5.2.1 %StringIteratorPrototype%.next() +}, function () { + var O = this._t; + var index = this._i; + var point; + if (index >= O.length) return { value: undefined, done: true }; + point = $at(O, index); + this._i += point.length; + return { value: point, done: false }; +}); + +var _iterStep = function (done, value) { + return { value: value, done: !!done }; +}; + +// 22.1.3.4 Array.prototype.entries() +// 22.1.3.13 Array.prototype.keys() +// 22.1.3.29 Array.prototype.values() +// 22.1.3.30 Array.prototype[@@iterator]() +var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) { + this._t = _toIobject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind +// 22.1.5.2.1 %ArrayIteratorPrototype%.next() +}, function () { + var O = this._t; + var kind = this._k; + var index = this._i++; + if (!O || index >= O.length) { + this._t = undefined; + return _iterStep(1); + } + if (kind == 'keys') return _iterStep(0, index); + if (kind == 'values') return _iterStep(0, O[index]); + return _iterStep(0, [index, O[index]]); +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) +_iterators.Arguments = _iterators.Array; + +var TO_STRING_TAG = _wks('toStringTag'); + +var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + + 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + + 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + + 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + + 'TextTrackList,TouchList').split(','); + +for (var i = 0; i < DOMIterables.length; i++) { + var NAME = DOMIterables[i]; + var Collection = _global[NAME]; + var proto = Collection && Collection.prototype; + if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME); + _iterators[NAME] = _iterators.Array; +} + +var f$3 = _wks; + +var _wksExt = { + f: f$3 +}; + +var iterator = _wksExt.f('iterator'); + +var iterator$1 = createCommonjsModule(function (module) { +module.exports = { "default": iterator, __esModule: true }; +}); + +unwrapExports(iterator$1); + +var _meta = createCommonjsModule(function (module) { +var META = _uid('meta'); + + +var setDesc = _objectDp.f; +var id = 0; +var isExtensible = Object.isExtensible || function () { + return true; +}; +var FREEZE = !_fails(function () { + return isExtensible(Object.preventExtensions({})); +}); +var setMeta = function (it) { + setDesc(it, META, { value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + } }); +}; +var fastKey = function (it, create) { + // return primitive with prefix + if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!_has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; +}; +var getWeak = function (it, create) { + if (!_has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; +}; +// add metadata on freeze-family methods calling +var onFreeze = function (it) { + if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); + return it; +}; +var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze +}; +}); +var _meta_1 = _meta.KEY; +var _meta_2 = _meta.NEED; +var _meta_3 = _meta.fastKey; +var _meta_4 = _meta.getWeak; +var _meta_5 = _meta.onFreeze; + +var defineProperty$2 = _objectDp.f; +var _wksDefine = function (name) { + var $Symbol = _core.Symbol || (_core.Symbol = {}); + if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty$2($Symbol, name, { value: _wksExt.f(name) }); +}; + +var f$4 = Object.getOwnPropertySymbols; + +var _objectGops = { + f: f$4 +}; + +// all enumerable object keys, includes symbols + + + +var _enumKeys = function (it) { + var result = _objectKeys(it); + var getSymbols = _objectGops.f; + if (getSymbols) { + var symbols = getSymbols(it); + var isEnum = _objectPie.f; + var i = 0; + var key; + while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); + } return result; +}; + +// 7.2.2 IsArray(argument) + +var _isArray = Array.isArray || function isArray(arg) { + return _cof(arg) == 'Array'; +}; + +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) + +var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); + +var f$5 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return _objectKeysInternal(O, hiddenKeys); +}; + +var _objectGopn = { + f: f$5 +}; + +// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window + +var gOPN = _objectGopn.f; +var toString$1 = {}.toString; + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function (it) { + try { + return gOPN(it); + } catch (e) { + return windowNames.slice(); + } +}; + +var f$6 = function getOwnPropertyNames(it) { + return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it)); +}; + +var _objectGopnExt = { + f: f$6 +}; + +// ECMAScript 6 symbols shim + + + + + +var META = _meta.KEY; + + + + + + + + + + + + + + + + + + + +var gOPD$1 = _objectGopd.f; +var dP$1 = _objectDp.f; +var gOPN$1 = _objectGopnExt.f; +var $Symbol = _global.Symbol; +var $JSON = _global.JSON; +var _stringify = $JSON && $JSON.stringify; +var PROTOTYPE$2 = 'prototype'; +var HIDDEN = _wks('_hidden'); +var TO_PRIMITIVE = _wks('toPrimitive'); +var isEnum = {}.propertyIsEnumerable; +var SymbolRegistry = _shared('symbol-registry'); +var AllSymbols = _shared('symbols'); +var OPSymbols = _shared('op-symbols'); +var ObjectProto$1 = Object[PROTOTYPE$2]; +var USE_NATIVE = typeof $Symbol == 'function'; +var QObject = _global.QObject; +// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 +var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild; + +// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 +var setSymbolDesc = _descriptors && _fails(function () { + return _objectCreate(dP$1({}, 'a', { + get: function () { return dP$1(this, 'a', { value: 7 }).a; } + })).a != 7; +}) ? function (it, key, D) { + var protoDesc = gOPD$1(ObjectProto$1, key); + if (protoDesc) delete ObjectProto$1[key]; + dP$1(it, key, D); + if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc); +} : dP$1; + +var wrap = function (tag) { + var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]); + sym._k = tag; + return sym; +}; + +var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) { + return typeof it == 'symbol'; +} : function (it) { + return it instanceof $Symbol; +}; + +var $defineProperty = function defineProperty(it, key, D) { + if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D); + _anObject(it); + key = _toPrimitive(key, true); + _anObject(D); + if (_has(AllSymbols, key)) { + if (!D.enumerable) { + if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; + D = _objectCreate(D, { enumerable: _propertyDesc(0, false) }); + } return setSymbolDesc(it, key, D); + } return dP$1(it, key, D); +}; +var $defineProperties = function defineProperties(it, P) { + _anObject(it); + var keys = _enumKeys(P = _toIobject(P)); + var i = 0; + var l = keys.length; + var key; + while (l > i) $defineProperty(it, key = keys[i++], P[key]); + return it; +}; +var $create = function create(it, P) { + return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P); +}; +var $propertyIsEnumerable = function propertyIsEnumerable(key) { + var E = isEnum.call(this, key = _toPrimitive(key, true)); + if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false; + return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true; +}; +var $getOwnPropertyDescriptor$1 = function getOwnPropertyDescriptor(it, key) { + it = _toIobject(it); + key = _toPrimitive(key, true); + if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; + var D = gOPD$1(it, key); + if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; + return D; +}; +var $getOwnPropertyNames = function getOwnPropertyNames(it) { + var names = gOPN$1(_toIobject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); + } return result; +}; +var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { + var IS_OP = it === ObjectProto$1; + var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]); + } return result; +}; + +// 19.4.1.1 Symbol([description]) +if (!USE_NATIVE) { + $Symbol = function Symbol() { + if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); + var tag = _uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function (value) { + if (this === ObjectProto$1) $set.call(OPSymbols, value); + if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, _propertyDesc(1, value)); + }; + if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set }); + return wrap(tag); + }; + _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() { + return this._k; + }); + + _objectGopd.f = $getOwnPropertyDescriptor$1; + _objectDp.f = $defineProperty; + _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames; + _objectPie.f = $propertyIsEnumerable; + _objectGops.f = $getOwnPropertySymbols; + + if (_descriptors && !_library) { + _redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + _wksExt.f = function (name) { + return wrap(_wks(name)); + }; +} + +_export(_export.G + _export.W + _export.F * !USE_NATIVE, { Symbol: $Symbol }); + +for (var es6Symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' +).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]); + +for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]); + +_export(_export.S + _export.F * !USE_NATIVE, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function (key) { + return _has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(sym) { + if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); + for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; + }, + useSetter: function () { setter = true; }, + useSimple: function () { setter = false; } +}); + +_export(_export.S + _export.F * !USE_NATIVE, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor$1, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols +}); + +// 24.3.2 JSON.stringify(value [, replacer [, space]]) +$JSON && _export(_export.S + _export.F * (!USE_NATIVE || _fails(function () { + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; +})), 'JSON', { + stringify: function stringify(it) { + var args = [it]; + var i = 1; + var replacer, $replacer; + while (arguments.length > i) args.push(arguments[i++]); + $replacer = replacer = args[1]; + if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined + if (!_isArray(replacer)) replacer = function (key, value) { + if (typeof $replacer == 'function') value = $replacer.call(this, key, value); + if (!isSymbol(value)) return value; + }; + args[1] = replacer; + return _stringify.apply($JSON, args); + } +}); + +// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) +$Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf); +// 19.4.3.5 Symbol.prototype[@@toStringTag] +_setToStringTag($Symbol, 'Symbol'); +// 20.2.1.9 Math[@@toStringTag] +_setToStringTag(Math, 'Math', true); +// 24.3.3 JSON[@@toStringTag] +_setToStringTag(_global.JSON, 'JSON', true); + +_wksDefine('asyncIterator'); + +_wksDefine('observable'); + +var symbol = _core.Symbol; + +var symbol$1 = createCommonjsModule(function (module) { +module.exports = { "default": symbol, __esModule: true }; +}); + +unwrapExports(symbol$1); + +var _typeof_1 = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _iterator2 = _interopRequireDefault(iterator$1); + + + +var _symbol2 = _interopRequireDefault(symbol$1); + +var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof(obj); +} : function (obj) { + return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); +}; +}); + +var _typeof = unwrapExports(_typeof_1); + +var classCallCheck = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + +exports.default = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; +}); + +var _classCallCheck = unwrapExports(classCallCheck); + +var possibleConstructorReturn = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _typeof3 = _interopRequireDefault(_typeof_1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; +}; +}); + +var _possibleConstructorReturn = unwrapExports(possibleConstructorReturn); + +var get = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf$1); + + + +var _getOwnPropertyDescriptor2 = _interopRequireDefault(getOwnPropertyDescriptor$1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = (0, _getOwnPropertyDescriptor2.default)(object, property); + + if (desc === undefined) { + var parent = (0, _getPrototypeOf2.default)(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } +}; +}); + +var _get = unwrapExports(get); + +var createClass = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _defineProperty2 = _interopRequireDefault(defineProperty$1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = 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; + (0, _defineProperty2.default)(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); +}); + +var _createClass = unwrapExports(createClass); + +// Works with __proto__ only. Old v8 can't work with null proto objects. +/* eslint-disable no-proto */ + + +var check = function (O, proto) { + _anObject(O); + if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); +}; +var _setProto = { + set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line + function (test, buggy, set) { + try { + set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); + set(test, []); + buggy = !(test instanceof Array); + } catch (e) { buggy = true; } + return function setPrototypeOf(O, proto) { + check(O, proto); + if (buggy) O.__proto__ = proto; + else set(O, proto); + return O; + }; + }({}, false) : undefined), + check: check +}; + +// 19.1.3.19 Object.setPrototypeOf(O, proto) + +_export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); + +var setPrototypeOf = _core.Object.setPrototypeOf; + +var setPrototypeOf$1 = createCommonjsModule(function (module) { +module.exports = { "default": setPrototypeOf, __esModule: true }; +}); + +unwrapExports(setPrototypeOf$1); + +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +_export(_export.S, 'Object', { create: _objectCreate }); + +var $Object$2 = _core.Object; +var create = function create(P, D) { + return $Object$2.create(P, D); +}; + +var create$1 = createCommonjsModule(function (module) { +module.exports = { "default": create, __esModule: true }; +}); + +var _Object$create = unwrapExports(create$1); + +var inherits = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _setPrototypeOf2 = _interopRequireDefault(setPrototypeOf$1); + + + +var _create2 = _interopRequireDefault(create$1); + + + +var _typeof3 = _interopRequireDefault(_typeof_1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); + } + + subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; +}; +}); + +var _inherits = unwrapExports(inherits); + +// getting tag from 19.1.3.6 Object.prototype.toString() + +var TAG$1 = _wks('toStringTag'); +// ES3 wrong here +var ARG = _cof(function () { return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function (it, key) { + try { + return it[key]; + } catch (e) { /* empty */ } +}; + +var _classof = function (it) { + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T + // builtinTag case + : ARG ? _cof(O) + // ES3 arguments fallback + : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; +}; + +var ITERATOR$1 = _wks('iterator'); + +var core_isIterable = _core.isIterable = function (it) { + var O = Object(it); + return O[ITERATOR$1] !== undefined + || '@@iterator' in O + // eslint-disable-next-line no-prototype-builtins + || _iterators.hasOwnProperty(_classof(O)); +}; + +var isIterable = core_isIterable; + +var isIterable$1 = createCommonjsModule(function (module) { +module.exports = { "default": isIterable, __esModule: true }; +}); + +unwrapExports(isIterable$1); + +var ITERATOR$2 = _wks('iterator'); + +var core_getIteratorMethod = _core.getIteratorMethod = function (it) { + if (it != undefined) return it[ITERATOR$2] + || it['@@iterator'] + || _iterators[_classof(it)]; +}; + +var core_getIterator = _core.getIterator = function (it) { + var iterFn = core_getIteratorMethod(it); + if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); + return _anObject(iterFn.call(it)); +}; + +var getIterator = core_getIterator; + +var getIterator$1 = createCommonjsModule(function (module) { +module.exports = { "default": getIterator, __esModule: true }; +}); + +var _getIterator = unwrapExports(getIterator$1); + +var slicedToArray = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _isIterable3 = _interopRequireDefault(isIterable$1); + + + +var _getIterator3 = _interopRequireDefault(getIterator$1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if ((0, _isIterable3.default)(Object(arr))) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); +}); + +var _slicedToArray = unwrapExports(slicedToArray); + +var isEnum$1 = _objectPie.f; +var _objectToArray = function (isEntries) { + return function (it) { + var O = _toIobject(it); + var keys = _objectKeys(O); + var length = keys.length; + var i = 0; + var result = []; + var key; + while (length > i) if (isEnum$1.call(O, key = keys[i++])) { + result.push(isEntries ? [key, O[key]] : O[key]); + } return result; + }; +}; + +// https://github.com/tc39/proposal-object-values-entries + +var $entries = _objectToArray(true); + +_export(_export.S, 'Object', { + entries: function entries(it) { + return $entries(it); + } +}); + +var entries = _core.Object.entries; + +var entries$1 = createCommonjsModule(function (module) { +module.exports = { "default": entries, __esModule: true }; +}); + +var _Object$entries = unwrapExports(entries$1); + +// 19.1.2.14 Object.keys(O) + + + +_objectSap('keys', function () { + return function keys(it) { + return _objectKeys(_toObject(it)); + }; +}); + +var keys = _core.Object.keys; + +var keys$1 = createCommonjsModule(function (module) { +module.exports = { "default": keys, __esModule: true }; +}); + +var _Object$keys = unwrapExports(keys$1); + +// 19.1.2.1 Object.assign(target, source, ...) + + + + + +var $assign = Object.assign; + +// should work with symbols and should have deterministic property order (V8 bug) +var _objectAssign = !$assign || _fails(function () { + var A = {}; + var B = {}; + // eslint-disable-next-line no-undef + var S = Symbol(); + var K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function (k) { B[k] = k; }); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; +}) ? function assign(target, source) { // eslint-disable-line no-unused-vars + var T = _toObject(target); + var aLen = arguments.length; + var index = 1; + var getSymbols = _objectGops.f; + var isEnum = _objectPie.f; + while (aLen > index) { + var S = _iobject(arguments[index++]); + var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); + var length = keys.length; + var j = 0; + var key; + while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; + } return T; +} : $assign; + +// 19.1.3.1 Object.assign(target, source) + + +_export(_export.S + _export.F, 'Object', { assign: _objectAssign }); + +var assign = _core.Object.assign; + +var assign$1 = createCommonjsModule(function (module) { +module.exports = { "default": assign, __esModule: true }; +}); + +var _Object$assign = unwrapExports(assign$1); + +var _anInstance = function (it, Constructor, name, forbiddenField) { + if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { + throw TypeError(name + ': incorrect invocation!'); + } return it; +}; + +// call something on iterator step with safe closing on error + +var _iterCall = function (iterator, fn, value, entries) { + try { + return entries ? fn(_anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch (e) { + var ret = iterator['return']; + if (ret !== undefined) _anObject(ret.call(iterator)); + throw e; + } +}; + +// check on default Array iterator + +var ITERATOR$3 = _wks('iterator'); +var ArrayProto = Array.prototype; + +var _isArrayIter = function (it) { + return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$3] === it); +}; + +var _forOf = createCommonjsModule(function (module) { +var BREAK = {}; +var RETURN = {}; +var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { + var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable); + var f = _ctx(fn, that, entries ? 2 : 1); + var index = 0; + var length, step, iterator, result; + if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); + // fast case for arrays with default iterator + if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) { + result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); + if (result === BREAK || result === RETURN) return result; + } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { + result = _iterCall(iterator, f, step.value, entries); + if (result === BREAK || result === RETURN) return result; + } +}; +exports.BREAK = BREAK; +exports.RETURN = RETURN; +}); + +// 7.3.20 SpeciesConstructor(O, defaultConstructor) + + +var SPECIES = _wks('species'); +var _speciesConstructor = function (O, D) { + var C = _anObject(O).constructor; + var S; + return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S); +}; + +// fast apply, http://jsperf.lnkit.com/fast-apply/5 +var _invoke = function (fn, args, that) { + var un = that === undefined; + switch (args.length) { + case 0: return un ? fn() + : fn.call(that); + case 1: return un ? fn(args[0]) + : fn.call(that, args[0]); + case 2: return un ? fn(args[0], args[1]) + : fn.call(that, args[0], args[1]); + case 3: return un ? fn(args[0], args[1], args[2]) + : fn.call(that, args[0], args[1], args[2]); + case 4: return un ? fn(args[0], args[1], args[2], args[3]) + : fn.call(that, args[0], args[1], args[2], args[3]); + } return fn.apply(that, args); +}; + +var process = _global.process; +var setTask = _global.setImmediate; +var clearTask = _global.clearImmediate; +var MessageChannel = _global.MessageChannel; +var Dispatch = _global.Dispatch; +var counter = 0; +var queue = {}; +var ONREADYSTATECHANGE = 'onreadystatechange'; +var defer, channel, port; +var run = function () { + var id = +this; + // eslint-disable-next-line no-prototype-builtins + if (queue.hasOwnProperty(id)) { + var fn = queue[id]; + delete queue[id]; + fn(); + } +}; +var listener = function (event) { + run.call(event.data); +}; +// Node.js 0.9+ & IE10+ has setImmediate, otherwise: +if (!setTask || !clearTask) { + setTask = function setImmediate(fn) { + var args = []; + var i = 1; + while (arguments.length > i) args.push(arguments[i++]); + queue[++counter] = function () { + // eslint-disable-next-line no-new-func + _invoke(typeof fn == 'function' ? fn : Function(fn), args); + }; + defer(counter); + return counter; + }; + clearTask = function clearImmediate(id) { + delete queue[id]; + }; + // Node.js 0.8- + if (_cof(process) == 'process') { + defer = function (id) { + process.nextTick(_ctx(run, id, 1)); + }; + // Sphere (JS game engine) Dispatch API + } else if (Dispatch && Dispatch.now) { + defer = function (id) { + Dispatch.now(_ctx(run, id, 1)); + }; + // Browsers with MessageChannel, includes WebWorkers + } else if (MessageChannel) { + channel = new MessageChannel(); + port = channel.port2; + channel.port1.onmessage = listener; + defer = _ctx(port.postMessage, port, 1); + // Browsers with postMessage, skip WebWorkers + // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' + } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) { + defer = function (id) { + _global.postMessage(id + '', '*'); + }; + _global.addEventListener('message', listener, false); + // IE8- + } else if (ONREADYSTATECHANGE in _domCreate('script')) { + defer = function (id) { + _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () { + _html.removeChild(this); + run.call(id); + }; + }; + // Rest old browsers + } else { + defer = function (id) { + setTimeout(_ctx(run, id, 1), 0); + }; + } +} +var _task = { + set: setTask, + clear: clearTask +}; + +var macrotask = _task.set; +var Observer = _global.MutationObserver || _global.WebKitMutationObserver; +var process$1 = _global.process; +var Promise = _global.Promise; +var isNode = _cof(process$1) == 'process'; + +var _microtask = function () { + var head, last, notify; + + var flush = function () { + var parent, fn; + if (isNode && (parent = process$1.domain)) parent.exit(); + while (head) { + fn = head.fn; + head = head.next; + try { + fn(); + } catch (e) { + if (head) notify(); + else last = undefined; + throw e; + } + } last = undefined; + if (parent) parent.enter(); + }; + + // Node.js + if (isNode) { + notify = function () { + process$1.nextTick(flush); + }; + // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 + } else if (Observer && !(_global.navigator && _global.navigator.standalone)) { + var toggle = true; + var node = document.createTextNode(''); + new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new + notify = function () { + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if (Promise && Promise.resolve) { + // Promise.resolve without an argument throws an error in LG WebOS 2 + var promise = Promise.resolve(undefined); + notify = function () { + promise.then(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessag + // - onreadystatechange + // - setTimeout + } else { + notify = function () { + // strange IE + webpack dev server bug - use .call(global) + macrotask.call(_global, flush); + }; + } + + return function (fn) { + var task = { fn: fn, next: undefined }; + if (last) last.next = task; + if (!head) { + head = task; + notify(); + } last = task; + }; +}; + +// 25.4.1.5 NewPromiseCapability(C) + + +function PromiseCapability(C) { + var resolve, reject; + this.promise = new C(function ($$resolve, $$reject) { + if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); + resolve = $$resolve; + reject = $$reject; + }); + this.resolve = _aFunction(resolve); + this.reject = _aFunction(reject); +} + +var f$7 = function (C) { + return new PromiseCapability(C); +}; + +var _newPromiseCapability = { + f: f$7 +}; + +var _perform = function (exec) { + try { + return { e: false, v: exec() }; + } catch (e) { + return { e: true, v: e }; + } +}; + +var navigator = _global.navigator; + +var _userAgent = navigator && navigator.userAgent || ''; + +var _promiseResolve = function (C, x) { + _anObject(C); + if (_isObject(x) && x.constructor === C) return x; + var promiseCapability = _newPromiseCapability.f(C); + var resolve = promiseCapability.resolve; + resolve(x); + return promiseCapability.promise; +}; + +var _redefineAll = function (target, src, safe) { + for (var key in src) { + if (safe && target[key]) target[key] = src[key]; + else _hide(target, key, src[key]); + } return target; +}; + +var SPECIES$1 = _wks('species'); + +var _setSpecies = function (KEY) { + var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY]; + if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, { + configurable: true, + get: function () { return this; } + }); +}; + +var ITERATOR$4 = _wks('iterator'); +var SAFE_CLOSING = false; + +try { + var riter = [7][ITERATOR$4](); + riter['return'] = function () { SAFE_CLOSING = true; }; +} catch (e) { /* empty */ } + +var _iterDetect = function (exec, skipClosing) { + if (!skipClosing && !SAFE_CLOSING) return false; + var safe = false; + try { + var arr = [7]; + var iter = arr[ITERATOR$4](); + iter.next = function () { return { done: safe = true }; }; + arr[ITERATOR$4] = function () { return iter; }; + exec(arr); + } catch (e) { /* empty */ } + return safe; +}; + +var task = _task.set; +var microtask = _microtask(); + + + + +var PROMISE = 'Promise'; +var TypeError$1 = _global.TypeError; +var process$2 = _global.process; +var versions = process$2 && process$2.versions; +var v8 = versions && versions.v8 || ''; +var $Promise = _global[PROMISE]; +var isNode$1 = _classof(process$2) == 'process'; +var empty = function () { /* empty */ }; +var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; +var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f; + +var USE_NATIVE$1 = !!function () { + try { + // correct subclassing with @@species support + var promise = $Promise.resolve(1); + var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) { + exec(empty, empty); + }; + // unhandled rejections tracking support, NodeJS Promise without it fails @@species test + return (isNode$1 || typeof PromiseRejectionEvent == 'function') + && promise.then(empty) instanceof FakePromise + // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables + // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 + // we can't detect it synchronously, so just check versions + && v8.indexOf('6.6') !== 0 + && _userAgent.indexOf('Chrome/66') === -1; + } catch (e) { /* empty */ } +}(); + +// helpers +var isThenable = function (it) { + var then; + return _isObject(it) && typeof (then = it.then) == 'function' ? then : false; +}; +var notify = function (promise, isReject) { + if (promise._n) return; + promise._n = true; + var chain = promise._c; + microtask(function () { + var value = promise._v; + var ok = promise._s == 1; + var i = 0; + var run = function (reaction) { + var handler = ok ? reaction.ok : reaction.fail; + var resolve = reaction.resolve; + var reject = reaction.reject; + var domain = reaction.domain; + var result, then, exited; + try { + if (handler) { + if (!ok) { + if (promise._h == 2) onHandleUnhandled(promise); + promise._h = 1; + } + if (handler === true) result = value; + else { + if (domain) domain.enter(); + result = handler(value); // may throw + if (domain) { + domain.exit(); + exited = true; + } + } + if (result === reaction.promise) { + reject(TypeError$1('Promise-chain cycle')); + } else if (then = isThenable(result)) { + then.call(result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch (e) { + if (domain && !exited) domain.exit(); + reject(e); + } + }; + while (chain.length > i) run(chain[i++]); // variable length - can't use forEach + promise._c = []; + promise._n = false; + if (isReject && !promise._h) onUnhandled(promise); + }); +}; +var onUnhandled = function (promise) { + task.call(_global, function () { + var value = promise._v; + var unhandled = isUnhandled(promise); + var result, handler, console; + if (unhandled) { + result = _perform(function () { + if (isNode$1) { + process$2.emit('unhandledRejection', value, promise); + } else if (handler = _global.onunhandledrejection) { + handler({ promise: promise, reason: value }); + } else if ((console = _global.console) && console.error) { + console.error('Unhandled promise rejection', value); + } + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1; + } promise._a = undefined; + if (unhandled && result.e) throw result.v; + }); +}; +var isUnhandled = function (promise) { + return promise._h !== 1 && (promise._a || promise._c).length === 0; +}; +var onHandleUnhandled = function (promise) { + task.call(_global, function () { + var handler; + if (isNode$1) { + process$2.emit('rejectionHandled', promise); + } else if (handler = _global.onrejectionhandled) { + handler({ promise: promise, reason: promise._v }); + } + }); +}; +var $reject = function (value) { + var promise = this; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + promise._v = value; + promise._s = 2; + if (!promise._a) promise._a = promise._c.slice(); + notify(promise, true); +}; +var $resolve = function (value) { + var promise = this; + var then; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + try { + if (promise === value) throw TypeError$1("Promise can't be resolved itself"); + if (then = isThenable(value)) { + microtask(function () { + var wrapper = { _w: promise, _d: false }; // wrap + try { + then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1)); + } catch (e) { + $reject.call(wrapper, e); + } + }); + } else { + promise._v = value; + promise._s = 1; + notify(promise, false); + } + } catch (e) { + $reject.call({ _w: promise, _d: false }, e); // wrap + } +}; + +// constructor polyfill +if (!USE_NATIVE$1) { + // 25.4.3.1 Promise(executor) + $Promise = function Promise(executor) { + _anInstance(this, $Promise, PROMISE, '_h'); + _aFunction(executor); + Internal.call(this); + try { + executor(_ctx($resolve, this, 1), _ctx($reject, this, 1)); + } catch (err) { + $reject.call(this, err); + } + }; + // eslint-disable-next-line no-unused-vars + Internal = function Promise(executor) { + this._c = []; // <- awaiting reactions + this._a = undefined; // <- checked in isUnhandled reactions + this._s = 0; // <- state + this._d = false; // <- done + this._v = undefined; // <- value + this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled + this._n = false; // <- notify + }; + Internal.prototype = _redefineAll($Promise.prototype, { + // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) + then: function then(onFulfilled, onRejected) { + var reaction = newPromiseCapability(_speciesConstructor(this, $Promise)); + reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; + reaction.fail = typeof onRejected == 'function' && onRejected; + reaction.domain = isNode$1 ? process$2.domain : undefined; + this._c.push(reaction); + if (this._a) this._a.push(reaction); + if (this._s) notify(this, false); + return reaction.promise; + }, + // 25.4.5.1 Promise.prototype.catch(onRejected) + 'catch': function (onRejected) { + return this.then(undefined, onRejected); + } + }); + OwnPromiseCapability = function () { + var promise = new Internal(); + this.promise = promise; + this.resolve = _ctx($resolve, promise, 1); + this.reject = _ctx($reject, promise, 1); + }; + _newPromiseCapability.f = newPromiseCapability = function (C) { + return C === $Promise || C === Wrapper + ? new OwnPromiseCapability(C) + : newGenericPromiseCapability(C); + }; +} + +_export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Promise: $Promise }); +_setToStringTag($Promise, PROMISE); +_setSpecies(PROMISE); +Wrapper = _core[PROMISE]; + +// statics +_export(_export.S + _export.F * !USE_NATIVE$1, PROMISE, { + // 25.4.4.5 Promise.reject(r) + reject: function reject(r) { + var capability = newPromiseCapability(this); + var $$reject = capability.reject; + $$reject(r); + return capability.promise; + } +}); +_export(_export.S + _export.F * (_library), PROMISE, { + // 25.4.4.6 Promise.resolve(x) + resolve: function resolve(x) { + return _promiseResolve(this === Wrapper ? $Promise : this, x); + } +}); +_export(_export.S + _export.F * !(USE_NATIVE$1 && _iterDetect(function (iter) { + $Promise.all(iter)['catch'](empty); +})), PROMISE, { + // 25.4.4.1 Promise.all(iterable) + all: function all(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = _perform(function () { + var values = []; + var index = 0; + var remaining = 1; + _forOf(iterable, false, function (promise) { + var $index = index++; + var alreadyCalled = false; + values.push(undefined); + remaining++; + C.resolve(promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[$index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if (result.e) reject(result.v); + return capability.promise; + }, + // 25.4.4.4 Promise.race(iterable) + race: function race(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var reject = capability.reject; + var result = _perform(function () { + _forOf(iterable, false, function (promise) { + C.resolve(promise).then(capability.resolve, reject); + }); + }); + if (result.e) reject(result.v); + return capability.promise; + } +}); + +_export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) { + var C = _speciesConstructor(this, _core.Promise || _global.Promise); + var isFunction = typeof onFinally == 'function'; + return this.then( + isFunction ? function (x) { + return _promiseResolve(C, onFinally()).then(function () { return x; }); + } : onFinally, + isFunction ? function (e) { + return _promiseResolve(C, onFinally()).then(function () { throw e; }); + } : onFinally + ); +} }); + +// https://github.com/tc39/proposal-promise-try + + + + +_export(_export.S, 'Promise', { 'try': function (callbackfn) { + var promiseCapability = _newPromiseCapability.f(this); + var result = _perform(callbackfn); + (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); + return promiseCapability.promise; +} }); + +var promise = _core.Promise; + +var promise$1 = createCommonjsModule(function (module) { +module.exports = { "default": promise, __esModule: true }; +}); + +var _Promise = unwrapExports(promise$1); + +// 20.1.2.3 Number.isInteger(number) + +var floor$1 = Math.floor; +var _isInteger = function isInteger(it) { + return !_isObject(it) && isFinite(it) && floor$1(it) === it; +}; + +// 20.1.2.3 Number.isInteger(number) + + +_export(_export.S, 'Number', { isInteger: _isInteger }); + +var isInteger = _core.Number.isInteger; + +var isInteger$1 = createCommonjsModule(function (module) { +module.exports = { "default": isInteger, __esModule: true }; +}); + +var _Number$isInteger = unwrapExports(isInteger$1); + +var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + +var space = '[' + _stringWs + ']'; +var non = '\u200b\u0085'; +var ltrim = RegExp('^' + space + space + '*'); +var rtrim = RegExp(space + space + '*$'); + +var exporter = function (KEY, exec, ALIAS) { + var exp = {}; + var FORCE = _fails(function () { + return !!_stringWs[KEY]() || non[KEY]() != non; + }); + var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY]; + if (ALIAS) exp[ALIAS] = fn; + _export(_export.P + _export.F * FORCE, 'String', exp); +}; + +// 1 -> String#trimLeft +// 2 -> String#trimRight +// 3 -> String#trim +var trim = exporter.trim = function (string, TYPE) { + string = String(_defined(string)); + if (TYPE & 1) string = string.replace(ltrim, ''); + if (TYPE & 2) string = string.replace(rtrim, ''); + return string; +}; + +var _stringTrim = exporter; + +var $parseFloat = _global.parseFloat; +var $trim = _stringTrim.trim; + +var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) { + var string = $trim(String(str), 3); + var result = $parseFloat(string); + return result === 0 && string.charAt(0) == '-' ? -0 : result; +} : $parseFloat; + +// 20.1.2.12 Number.parseFloat(string) +_export(_export.S + _export.F * (Number.parseFloat != _parseFloat), 'Number', { parseFloat: _parseFloat }); + +var _parseFloat$1 = _core.Number.parseFloat; + +var _parseFloat$2 = createCommonjsModule(function (module) { +module.exports = { "default": _parseFloat$1, __esModule: true }; +}); + +var _Number$parseFloat = unwrapExports(_parseFloat$2); + +/** + * to check whether the object is defined or not + */ +function defined(obj) { + return typeof obj !== 'undefined'; +} +/** + * is void element or not ? Means it will return true when val is undefined or null + */ +function isVoid(obj) { + return obj === undefined || obj === null; +} +/** + * to check whether a variable is array + */ +function isArray(arr) { + return Array.isArray(arr); +} + +/** + * is it a function or not + */ +function isFunction(obj) { + return typeof obj === 'function'; +} + +/** + * is it an object or not + */ +function isObject(obj) { + // incase of arrow function and array + return Object(obj) === obj && String(obj) === '[object Object]' && !isFunction(obj) && !isArray(obj); +} +/** + * to tell you if it's a real number + */ +function isNumber(obj) { + return typeof obj === 'number'; +} +/** + * to tell you if the val can be transfer into number + */ +function isNumeric(obj) { + return !isArray(obj) && obj - _Number$parseFloat(obj) + 1 >= 0; +} +/** + * is it an interget or not + */ +function isInteger$2(num) { + return _Number$isInteger(num); +} + +/** + * return true when the value is "", {}, [], 0, null, undefined, false. + */ +function isEmpty(obj) { + if (isArray(obj)) { + return obj.length === 0; + } else if (isObject(obj)) { + return _Object$keys(obj).length === 0; + } else { + return !obj; + } +} +/** + * is it an event or not + */ +function isEvent(obj) { + return obj instanceof Event || (obj && obj.originalEvent) instanceof Event; +} +/** + * is it a string + */ +function isString(str) { + return typeof str === 'string' || str instanceof String; +} +/** + * is Boolean or not + */ +function isBoolean(bool) { + return typeof bool === 'boolean'; +} +/** + * is a promise or not + */ +function isPromise(obj) { + return !!obj && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; +} +/** + * is Primitive type or not, whick means it will return true when data is number/string/boolean/undefined/null + */ +function isPrimitive(val) { + return isVoid(val) || isBoolean(val) || isString(val) || isNumber(val); +} +/** + * to test if a HTML node + */ +function isNode$2(obj) { + return !!((typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? obj instanceof Node : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'); +} +/** + * to test if a HTML element + */ +function isElement(obj) { + return !!((typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? obj instanceof HTMLElement : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'); +} +/** + * check if node B is node A's posterrity or not + */ +function isPosterityNode(parent, child) { + if (!isNode$2(parent) || !isNode$2(child)) { + return false; + } + while (child.parentNode) { + child = child.parentNode; + if (child === parent) { + return true; + } + } + return false; +} +/** + * check if the string is an HTMLString + */ +function isHTMLString(str) { + return (/<[^>]+?>/.test(str) + ); +} +/** + * check if is an error + */ +function isError(val) { + return val instanceof Error; +} + +function formatter(tag, msg) { + if (!isString(tag)) throw new TypeError('Log\'s method only acccept string as argument, but not ' + tag + ' in ' + (typeof tag === 'undefined' ? 'undefined' : _typeof(tag))); + if (!isString(msg)) return '[' + Log.GLOBAL_TAG + '] > ' + tag; + tag = Log.FORCE_GLOBAL_TAG ? Log.GLOBAL_TAG : tag || Log.GLOBAL_TAG; + return '[' + tag + '] > ' + msg; +} +/** + * Log Object + */ + +var Log = function () { + function Log() { + _classCallCheck(this, Log); + } + + _createClass(Log, null, [{ + key: 'error', + + /** + * equal to console.error, output `[${tag}] > {$msg}` + * @param {string} tag optional, the header of log + * @param {string} msg the message + */ + + /** + * @member {boolean} + */ + + /** + * @member {boolean} + */ + + /** + * @member {boolean} + */ + value: function error(tag, msg) { + if (!Log.ENABLE_ERROR) { + return; + } + + (console.error || console.warn || console.log).call(console, formatter(tag, msg)); + } + /** + * equal to console.info, output `[${tag}] > {$msg}` + * @param {string} tag optional, the header of log + * @param {string} msg the message + */ + + /** + * @member {boolean} + */ + + /** + * @member {boolean} + */ + + /** + * @member {boolean} + */ + + /** + * @member {string} + */ + + }, { + key: 'info', + value: function info(tag, msg) { + if (!Log.ENABLE_INFO) { + return; + } + (console.info || console.log).call(console, formatter(tag, msg)); + } + /** + * equal to console.warn, output `[${tag}] > {$msg}` + * @param {string} tag optional, the header of log + * @param {string} msg the message + */ + + }, { + key: 'warn', + value: function warn(tag, msg) { + if (!Log.ENABLE_WARN) { + return; + } + (console.warn || console.log).call(console, formatter(tag, msg)); + } + /** + * equal to console.debug, output `[${tag}] > {$msg}` + * @param {string} tag optional, the header of log + * @param {string} msg the message + */ + + }, { + key: 'debug', + value: function debug(tag, msg) { + if (!Log.ENABLE_DEBUG) { + return; + } + (console.debug || console.log).call(console, formatter(tag, msg)); + } + /** + * equal to console.verbose, output `[${tag}] > {$msg}` + * @param {string} tag optional, the header of log + * @param {string} msg the message + */ + + }, { + key: 'verbose', + value: function verbose(tag, msg) { + if (!Log.ENABLE_VERBOSE) { + return; + } + console.log(formatter(tag, msg)); + } + }]); + + return Log; +}(); + +Log.GLOBAL_TAG = 'chimee'; +Log.FORCE_GLOBAL_TAG = false; +Log.ENABLE_ERROR = true; +Log.ENABLE_INFO = true; +Log.ENABLE_WARN = true; +Log.ENABLE_DEBUG = true; +Log.ENABLE_VERBOSE = true; + +var uaParser = createCommonjsModule(function (module, exports) { +/*! + * UAParser.js v0.7.18 + * Lightweight JavaScript-based User-Agent string parser + * https://github.com/faisalman/ua-parser-js + * + * Copyright © 2012-2016 Faisal Salman + * Dual licensed under GPLv2 or MIT + */ + +(function (window, undefined) { + + ////////////// + // Constants + ///////////// + + + var LIBVERSION = '0.7.18', + EMPTY = '', + UNKNOWN = '?', + FUNC_TYPE = 'function', + UNDEF_TYPE = 'undefined', + OBJ_TYPE = 'object', + STR_TYPE = 'string', + MAJOR = 'major', // deprecated + MODEL = 'model', + NAME = 'name', + TYPE = 'type', + VENDOR = 'vendor', + VERSION = 'version', + ARCHITECTURE= 'architecture', + CONSOLE = 'console', + MOBILE = 'mobile', + TABLET = 'tablet', + SMARTTV = 'smarttv', + WEARABLE = 'wearable', + EMBEDDED = 'embedded'; + + + /////////// + // Helper + ////////// + + + var util = { + extend : function (regexes, extensions) { + var margedRegexes = {}; + for (var i in regexes) { + if (extensions[i] && extensions[i].length % 2 === 0) { + margedRegexes[i] = extensions[i].concat(regexes[i]); + } else { + margedRegexes[i] = regexes[i]; + } + } + return margedRegexes; + }, + has : function (str1, str2) { + if (typeof str1 === "string") { + return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; + } else { + return false; + } + }, + lowerize : function (str) { + return str.toLowerCase(); + }, + major : function (version) { + return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g,'').split(".")[0] : undefined; + }, + trim : function (str) { + return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); + } + }; + + + /////////////// + // Map helper + ////////////// + + + var mapper = { + + rgx : function (ua, arrays) { + + //var result = {}, + var i = 0, j, k, p, q, matches, match;//, args = arguments; + + /*// construct object barebones + for (p = 0; p < args[1].length; p++) { + q = args[1][p]; + result[typeof q === OBJ_TYPE ? q[0] : q] = undefined; + }*/ + + // loop through all regexes maps + while (i < arrays.length && !matches) { + + var regex = arrays[i], // even sequence (0,2,4,..) + props = arrays[i + 1]; // odd sequence (1,3,5,..) + j = k = 0; + + // try matching uastring with regexes + while (j < regex.length && !matches) { + + matches = regex[j++].exec(ua); + + if (!!matches) { + for (p = 0; p < props.length; p++) { + match = matches[++k]; + q = props[p]; + // check if given property is actually array + if (typeof q === OBJ_TYPE && q.length > 0) { + if (q.length == 2) { + if (typeof q[1] == FUNC_TYPE) { + // assign modified match + this[q[0]] = q[1].call(this, match); + } else { + // assign given value, ignore regex match + this[q[0]] = q[1]; + } + } else if (q.length == 3) { + // check whether function or regex + if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) { + // call function (usually string mapper) + this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; + } else { + // sanitize match using given regex + this[q[0]] = match ? match.replace(q[1], q[2]) : undefined; + } + } else if (q.length == 4) { + this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined; + } + } else { + this[q] = match ? match : undefined; + } + } + } + } + i += 2; + } + // console.log(this); + //return this; + }, + + str : function (str, map) { + + for (var i in map) { + // check if array + if (typeof map[i] === OBJ_TYPE && map[i].length > 0) { + for (var j = 0; j < map[i].length; j++) { + if (util.has(map[i][j], str)) { + return (i === UNKNOWN) ? undefined : i; + } + } + } else if (util.has(map[i], str)) { + return (i === UNKNOWN) ? undefined : i; + } + } + return str; + } + }; + + + /////////////// + // String map + ////////////// + + + var maps = { + + browser : { + oldsafari : { + version : { + '1.0' : '/8', + '1.2' : '/1', + '1.3' : '/3', + '2.0' : '/412', + '2.0.2' : '/416', + '2.0.3' : '/417', + '2.0.4' : '/419', + '?' : '/' + } + } + }, + + device : { + amazon : { + model : { + 'Fire Phone' : ['SD', 'KF'] + } + }, + sprint : { + model : { + 'Evo Shift 4G' : '7373KT' + }, + vendor : { + 'HTC' : 'APA', + 'Sprint' : 'Sprint' + } + } + }, + + os : { + windows : { + version : { + 'ME' : '4.90', + 'NT 3.11' : 'NT3.51', + 'NT 4.0' : 'NT4.0', + '2000' : 'NT 5.0', + 'XP' : ['NT 5.1', 'NT 5.2'], + 'Vista' : 'NT 6.0', + '7' : 'NT 6.1', + '8' : 'NT 6.2', + '8.1' : 'NT 6.3', + '10' : ['NT 6.4', 'NT 10.0'], + 'RT' : 'ARM' + } + } + } + }; + + + ////////////// + // Regex map + ///////////// + + + var regexes = { + + browser : [[ + + // Presto based + /(opera\smini)\/([\w\.-]+)/i, // Opera Mini + /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet + /(opera).+version\/([\w\.]+)/i, // Opera > 9.80 + /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80 + ], [NAME, VERSION], [ + + /(opios)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0 + ], [[NAME, 'Opera Mini'], VERSION], [ + + /\s(opr)\/([\w\.]+)/i // Opera Webkit + ], [[NAME, 'Opera'], VERSION], [ + + // Mixed + /(kindle)\/([\w\.]+)/i, // Kindle + /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i, + // Lunascape/Maxthon/Netfront/Jasmine/Blazer + + // Trident based + /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, + // Avant/IEMobile/SlimBrowser/Baidu + /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer + + // Webkit/KHTML based + /(rekonq)\/([\w\.]*)/i, // Rekonq + /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark)\/([\w\.-]+)/i + // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser + ], [NAME, VERSION], [ + + /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11 + ], [[NAME, 'IE'], VERSION], [ + + /(edge|edgios|edgea)\/((\d+)?[\w\.]+)/i // Microsoft Edge + ], [[NAME, 'Edge'], VERSION], [ + + /(yabrowser)\/([\w\.]+)/i // Yandex + ], [[NAME, 'Yandex'], VERSION], [ + + /(puffin)\/([\w\.]+)/i // Puffin + ], [[NAME, 'Puffin'], VERSION], [ + + /((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i + // UCBrowser + ], [[NAME, 'UCBrowser'], VERSION], [ + + /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon + ], [[NAME, /_/g, ' '], VERSION], [ + + /(micromessenger)\/([\w\.]+)/i // WeChat + ], [[NAME, 'WeChat'], VERSION], [ + + /(qqbrowserlite)\/([\w\.]+)/i // QQBrowserLite + ], [NAME, VERSION], [ + + /(QQ)\/([\d\.]+)/i // QQ, aka ShouQ + ], [NAME, VERSION], [ + + /m?(qqbrowser)[\/\s]?([\w\.]+)/i // QQBrowser + ], [NAME, VERSION], [ + + /(BIDUBrowser)[\/\s]?([\w\.]+)/i // Baidu Browser + ], [NAME, VERSION], [ + + /(2345Explorer)[\/\s]?([\w\.]+)/i // 2345 Browser + ], [NAME, VERSION], [ + + /(MetaSr)[\/\s]?([\w\.]+)/i // SouGouBrowser + ], [NAME], [ + + /(LBBROWSER)/i // LieBao Browser + ], [NAME], [ + + /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser + ], [VERSION, [NAME, 'MIUI Browser']], [ + + /;fbav\/([\w\.]+);/i // Facebook App for iOS & Android + ], [VERSION, [NAME, 'Facebook']], [ + + /headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless + ], [VERSION, [NAME, 'Chrome Headless']], [ + + /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView + ], [[NAME, /(.+)/, '$1 WebView'], VERSION], [ + + /((?:oculus|samsung)browser)\/([\w\.]+)/i + ], [[NAME, /(.+(?:g|us))(.+)/, '$1 $2'], VERSION], [ // Oculus / Samsung Browser + + /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i // Android Browser + ], [VERSION, [NAME, 'Android Browser']], [ + + /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i + // Chrome/OmniWeb/Arora/Tizen/Nokia + ], [NAME, VERSION], [ + + /(dolfin)\/([\w\.]+)/i // Dolphin + ], [[NAME, 'Dolphin'], VERSION], [ + + /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS + ], [[NAME, 'Chrome'], VERSION], [ + + /(coast)\/([\w\.]+)/i // Opera Coast + ], [[NAME, 'Opera Coast'], VERSION], [ + + /fxios\/([\w\.-]+)/i // Firefox for iOS + ], [VERSION, [NAME, 'Firefox']], [ + + /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari + ], [VERSION, [NAME, 'Mobile Safari']], [ + + /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile + ], [VERSION, NAME], [ + + /webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS + ], [[NAME, 'GSA'], VERSION], [ + + /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0 + ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [ + + /(konqueror)\/([\w\.]+)/i, // Konqueror + /(webkit|khtml)\/([\w\.]+)/i + ], [NAME, VERSION], [ + + // Gecko based + /(navigator|netscape)\/([\w\.-]+)/i // Netscape + ], [[NAME, 'Netscape'], VERSION], [ + /(swiftfox)/i, // Swiftfox + /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, + // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror + /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i, + + // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix + /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla + + // Other + /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i, + // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir + /(links)\s\(([\w\.]+)/i, // Links + /(gobrowser)\/?([\w\.]*)/i, // GoBrowser + /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser + /(mosaic)[\/\s]([\w\.]+)/i // Mosaic + ], [NAME, VERSION] + + /* ///////////////////// + // Media players BEGIN + //////////////////////// + + , [ + + /(apple(?:coremedia|))\/((\d+)[\w\._]+)/i, // Generic Apple CoreMedia + /(coremedia) v((\d+)[\w\._]+)/i + ], [NAME, VERSION], [ + + /(aqualung|lyssna|bsplayer)\/((\d+)?[\w\.-]+)/i // Aqualung/Lyssna/BSPlayer + ], [NAME, VERSION], [ + + /(ares|ossproxy)\s((\d+)[\w\.-]+)/i // Ares/OSSProxy + ], [NAME, VERSION], [ + + /(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/((\d+)[\w\.-]+)/i, + // Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC + // NSPlayer/PSP-InternetRadioPlayer/Videos + /(clementine|music player daemon)\s((\d+)[\w\.-]+)/i, // Clementine/MPD + /(lg player|nexplayer)\s((\d+)[\d\.]+)/i, + /player\/(nexplayer|lg player)\s((\d+)[\w\.-]+)/i // NexPlayer/LG Player + ], [NAME, VERSION], [ + /(nexplayer)\s((\d+)[\w\.-]+)/i // Nexplayer + ], [NAME, VERSION], [ + + /(flrp)\/((\d+)[\w\.-]+)/i // Flip Player + ], [[NAME, 'Flip Player'], VERSION], [ + + /(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i + // FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit + ], [NAME], [ + + /(gstreamer) souphttpsrc (?:\([^\)]+\)){0,1} libsoup\/((\d+)[\w\.-]+)/i + // Gstreamer + ], [NAME, VERSION], [ + + /(htc streaming player)\s[\w_]+\s\/\s((\d+)[\d\.]+)/i, // HTC Streaming Player + /(java|python-urllib|python-requests|wget|libcurl)\/((\d+)[\w\.-_]+)/i, + // Java/urllib/requests/wget/cURL + /(lavf)((\d+)[\d\.]+)/i // Lavf (FFMPEG) + ], [NAME, VERSION], [ + + /(htc_one_s)\/((\d+)[\d\.]+)/i // HTC One S + ], [[NAME, /_/g, ' '], VERSION], [ + + /(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+){0,1})/i + // MPlayer SVN + ], [NAME, VERSION], [ + + /(mplayer)(?:\s|\/|[unkow-]+)((\d+)[\w\.-]+)/i // MPlayer + ], [NAME, VERSION], [ + + /(mplayer)/i, // MPlayer (no other info) + /(yourmuze)/i, // YourMuze + /(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime + ], [NAME], [ + + /(nero (?:home|scout))\/((\d+)[\w\.-]+)/i // Nero Home/Nero Scout + ], [NAME, VERSION], [ + + /(nokia\d+)\/((\d+)[\w\.-]+)/i // Nokia + ], [NAME, VERSION], [ + + /\s(songbird)\/((\d+)[\w\.-]+)/i // Songbird/Philips-Songbird + ], [NAME, VERSION], [ + + /(winamp)3 version ((\d+)[\w\.-]+)/i, // Winamp + /(winamp)\s((\d+)[\w\.-]+)/i, + /(winamp)mpeg\/((\d+)[\w\.-]+)/i + ], [NAME, VERSION], [ + + /(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info) + // inlight radio + ], [NAME], [ + + /(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/((\d+)[\w\.-]+)/i + // QuickTime/RealMedia/RadioApp/RadioClientApplication/ + // SoundTap/Totem/Stagefright/Streamium + ], [NAME, VERSION], [ + + /(smp)((\d+)[\d\.]+)/i // SMP + ], [NAME, VERSION], [ + + /(vlc) media player - version ((\d+)[\w\.]+)/i, // VLC Videolan + /(vlc)\/((\d+)[\w\.-]+)/i, + /(xbmc|gvfs|xine|xmms|irapp)\/((\d+)[\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp + /(foobar2000)\/((\d+)[\d\.]+)/i, // Foobar2000 + /(itunes)\/((\d+)[\d\.]+)/i // iTunes + ], [NAME, VERSION], [ + + /(wmplayer)\/((\d+)[\w\.-]+)/i, // Windows Media Player + /(windows-media-player)\/((\d+)[\w\.-]+)/i + ], [[NAME, /-/g, ' '], VERSION], [ + + /windows\/((\d+)[\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i + // Windows Media Server + ], [VERSION, [NAME, 'Windows']], [ + + /(com\.riseupradioalarm)\/((\d+)[\d\.]*)/i // RiseUP Radio Alarm + ], [NAME, VERSION], [ + + /(rad.io)\s((\d+)[\d\.]+)/i, // Rad.io + /(radio.(?:de|at|fr))\s((\d+)[\d\.]+)/i + ], [[NAME, 'rad.io'], VERSION] + + ////////////////////// + // Media players END + ////////////////////*/ + + ], + + cpu : [[ + + /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64 + ], [[ARCHITECTURE, 'amd64']], [ + + /(ia32(?=;))/i // IA32 (quicktime) + ], [[ARCHITECTURE, util.lowerize]], [ + + /((?:i[346]|x)86)[;\)]/i // IA32 + ], [[ARCHITECTURE, 'ia32']], [ + + // PocketPC mistakenly identified as PowerPC + /windows\s(ce|mobile);\sppc;/i + ], [[ARCHITECTURE, 'arm']], [ + + /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC + ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [ + + /(sun4\w)[;\)]/i // SPARC + ], [[ARCHITECTURE, 'sparc']], [ + + /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i + // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC + ], [[ARCHITECTURE, util.lowerize]] + ], + + device : [[ + + /\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook + ], [MODEL, VENDOR, [TYPE, TABLET]], [ + + /applecoremedia\/[\w\.]+ \((ipad)/ // iPad + ], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [ + + /(apple\s{0,1}tv)/i // Apple TV + ], [[MODEL, 'Apple TV'], [VENDOR, 'Apple']], [ + + /(archos)\s(gamepad2?)/i, // Archos + /(hp).+(touchpad)/i, // HP TouchPad + /(hp).+(tablet)/i, // HP Tablet + /(kindle)\/([\w\.]+)/i, // Kindle + /\s(nook)[\w\s]+build\/(\w+)/i, // Nook + /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + + /(kf[A-z]+)\sbuild\/.+silk\//i // Kindle Fire HD + ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [ + /(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i // Fire Phone + ], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [ + + /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone + ], [MODEL, VENDOR, [TYPE, MOBILE]], [ + /\((ip[honed|\s\w*]+);/i // iPod/iPhone + ], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [ + + /(blackberry)[\s-]?(\w+)/i, // BlackBerry + /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i, + // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron + /(hp)\s([\w\s]+\w)/i, // HP iPAQ + /(asus)-?(\w+)/i // Asus + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + /\(bb10;\s(\w+)/i // BlackBerry 10 + ], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [ + // Asus Tablets + /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i + ], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [ + + /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony + /(sony)?(?:sgp.+)\sbuild\//i + ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [ + /android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i + ], [MODEL, [VENDOR, 'Sony'], [TYPE, MOBILE]], [ + + /\s(ouya)\s/i, // Ouya + /(nintendo)\s([wids3u]+)/i // Nintendo + ], [VENDOR, MODEL, [TYPE, CONSOLE]], [ + + /android.+;\s(shield)\sbuild/i // Nvidia + ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [ + + /(playstation\s[34portablevi]+)/i // Playstation + ], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [ + + /(sprint\s(\w+))/i // Sprint Phones + ], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [ + + /(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i // Lenovo tablets + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + + /(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC + /(zte)-(\w*)/i, // ZTE + /(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i + // Alcatel/GeeksPhone/Lenovo/Nexian/Panasonic/Sony + ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [ + + /(nexus\s9)/i // HTC Nexus 9 + ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [ + + /d\/huawei([\w\s-]+)[;\)]/i, + /(nexus\s6p)/i // Huawei + ], [MODEL, [VENDOR, 'Huawei'], [TYPE, MOBILE]], [ + + /(microsoft);\s(lumia[\s\w]+)/i // Microsoft Lumia + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + + /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox + ], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [ + /(kin\.[onetw]{3})/i // Microsoft Kin + ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [ + + // Motorola + /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i, + /mot[\s-]?(\w*)/i, + /(XT\d{3,4}) build\//i, + /(nexus\s6)/i + ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [ + /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i + ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [ + + /hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i // HbbTV devices + ], [[VENDOR, util.trim], [MODEL, util.trim], [TYPE, SMARTTV]], [ + + /hbbtv.+maple;(\d+)/i + ], [[MODEL, /^/, 'SmartTV'], [VENDOR, 'Samsung'], [TYPE, SMARTTV]], [ + + /\(dtv[\);].+(aquos)/i // Sharp + ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [ + + /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i, + /((SM-T\w+))/i + ], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung + /smart-tv.+(samsung)/i + ], [VENDOR, [TYPE, SMARTTV], MODEL], [ + /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i, + /(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i, + /sec-((sgh\w+))/i + ], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [ + + /sie-(\w*)/i // Siemens + ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [ + + /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia + /(nokia)[\s_-]?([\w-]*)/i + ], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [ + + /android\s3\.[\s\w;-]{10}(a\d{3})/i // Acer + ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [ + + /android.+([vl]k\-?\d{3})\s+build/i // LG Tablet + ], [MODEL, [VENDOR, 'LG'], [TYPE, TABLET]], [ + /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet + ], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [ + /(lg) netcast\.tv/i // LG SmartTV + ], [VENDOR, MODEL, [TYPE, SMARTTV]], [ + /(nexus\s[45])/i, // LG + /lg[e;\s\/-]+(\w*)/i, + /android.+lg(\-?[\d\w]+)\s+build/i + ], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [ + + /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo + ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [ + + /linux;.+((jolla));/i // Jolla + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + + /((pebble))app\/[\d\.]+\s/i // Pebble + ], [VENDOR, MODEL, [TYPE, WEARABLE]], [ + + /android.+;\s(oppo)\s?([\w\s]+)\sbuild/i // OPPO + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + + /crkey/i // Google Chromecast + ], [[MODEL, 'Chromecast'], [VENDOR, 'Google']], [ + + /android.+;\s(glass)\s\d/i // Google Glass + ], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [ + + /android.+;\s(pixel c)\s/i // Google Pixel C + ], [MODEL, [VENDOR, 'Google'], [TYPE, TABLET]], [ + + /android.+;\s(pixel xl|pixel)\s/i // Google Pixel + ], [MODEL, [VENDOR, 'Google'], [TYPE, MOBILE]], [ + + /android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models + /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi + /android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i, // Xiaomi Mi + /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i // Redmi Phones + ], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [ + /android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i // Mi Pad tablets + ],[[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [ + /android.+;\s(m[1-5]\snote)\sbuild/i // Meizu Tablet + ], [MODEL, [VENDOR, 'Meizu'], [TYPE, TABLET]], [ + + /android.+a000(1)\s+build/i, // OnePlus + /android.+oneplus\s(a\d{4})\s+build/i + ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [ + + /android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets + ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [ + + /android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets + ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet + ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [ + + /android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i // Barnes & Noble Tablet + ], [[VENDOR, 'Barnes & Noble'], MODEL, [TYPE, TABLET]], [ + + /android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i // Barnes & Noble Tablet + ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [ + + /android.+;\s(k88)\sbuild/i // ZTE K Series Tablet + ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*(gen\d{3})\s+build.*49h/i // Swiss GEN Mobile + ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [ + + /android.+[;\/]\s*(zur\d{3})\s+build/i // Swiss ZUR Tablet + ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i // Zeki Tablets + ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [ + + /(android).+[;\/]\s+([YR]\d{2})\s+build/i, + /android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i // Dragon Touch Tablet + ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [ + + /android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i // Insignia Tablets + ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i // NextBook Tablets + ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i + ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [ // Voice Xtreme Phones + + /android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i // LvTel Phones + ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [ + + /android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i // Envizen Tablets + ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i // Le Pan Tablets + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + + /android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i // MachSpeed Tablets + ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [ + + /android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i // Trinity Tablets + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + + /android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets + ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [ + + /android.+(KS(.+))\s+build/i // Amazon Kindle Tablets + ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [ + + /android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + + /\s(tablet|tab)[;\/]/i, // Unidentifiable Tablet + /\s(mobile)(?:[;\/]|\ssafari)/i // Unidentifiable Mobile + ], [[TYPE, util.lowerize], VENDOR, MODEL], [ + + /(android[\w\.\s\-]{0,9});.+build/i // Generic Android Device + ], [MODEL, [VENDOR, 'Generic']] + + + /*////////////////////////// + // TODO: move to string map + //////////////////////////// + + /(C6603)/i // Sony Xperia Z C6603 + ], [[MODEL, 'Xperia Z C6603'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [ + /(C6903)/i // Sony Xperia Z 1 + ], [[MODEL, 'Xperia Z 1'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [ + + /(SM-G900[F|H])/i // Samsung Galaxy S5 + ], [[MODEL, 'Galaxy S5'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ + /(SM-G7102)/i // Samsung Galaxy Grand 2 + ], [[MODEL, 'Galaxy Grand 2'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ + /(SM-G530H)/i // Samsung Galaxy Grand Prime + ], [[MODEL, 'Galaxy Grand Prime'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ + /(SM-G313HZ)/i // Samsung Galaxy V + ], [[MODEL, 'Galaxy V'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ + /(SM-T805)/i // Samsung Galaxy Tab S 10.5 + ], [[MODEL, 'Galaxy Tab S 10.5'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [ + /(SM-G800F)/i // Samsung Galaxy S5 Mini + ], [[MODEL, 'Galaxy S5 Mini'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ + /(SM-T311)/i // Samsung Galaxy Tab 3 8.0 + ], [[MODEL, 'Galaxy Tab 3 8.0'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [ + + /(T3C)/i // Advan Vandroid T3C + ], [MODEL, [VENDOR, 'Advan'], [TYPE, TABLET]], [ + /(ADVAN T1J\+)/i // Advan Vandroid T1J+ + ], [[MODEL, 'Vandroid T1J+'], [VENDOR, 'Advan'], [TYPE, TABLET]], [ + /(ADVAN S4A)/i // Advan Vandroid S4A + ], [[MODEL, 'Vandroid S4A'], [VENDOR, 'Advan'], [TYPE, MOBILE]], [ + + /(V972M)/i // ZTE V972M + ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [ + + /(i-mobile)\s(IQ\s[\d\.]+)/i // i-mobile IQ + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + /(IQ6.3)/i // i-mobile IQ IQ 6.3 + ], [[MODEL, 'IQ 6.3'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [ + /(i-mobile)\s(i-style\s[\d\.]+)/i // i-mobile i-STYLE + ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + /(i-STYLE2.1)/i // i-mobile i-STYLE 2.1 + ], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [ + + /(mobiistar touch LAI 512)/i // mobiistar touch LAI 512 + ], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [ + + ///////////// + // END TODO + ///////////*/ + + ], + + engine : [[ + + /windows.+\sedge\/([\w\.]+)/i // EdgeHTML + ], [VERSION, [NAME, 'EdgeHTML']], [ + + /(presto)\/([\w\.]+)/i, // Presto + /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m + /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links + /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab + ], [NAME, VERSION], [ + + /rv\:([\w\.]{1,9}).+(gecko)/i // Gecko + ], [VERSION, NAME] + ], + + os : [[ + + // Windows based + /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes) + ], [NAME, VERSION], [ + /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT + /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i, // Windows Phone + /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i + ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ + /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i + ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ + + // Mobile/Embedded OS + /\((bb)(10);/i // BlackBerry 10 + ], [[NAME, 'BlackBerry'], VERSION], [ + /(blackberry)\w*\/?([\w\.]*)/i, // Blackberry + /(tizen)[\/\s]([\w\.]+)/i, // Tizen + /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]*)/i, + // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki + /linux;.+(sailfish);/i // Sailfish OS + ], [NAME, VERSION], [ + /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i // Symbian + ], [[NAME, 'Symbian'], VERSION], [ + /\((series40);/i // Series 40 + ], [NAME], [ + /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS + ], [[NAME, 'Firefox OS'], VERSION], [ + + // Console + /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation + + // GNU/Linux based + /(mint)[\/\s\(]?(\w*)/i, // Mint + /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux + /(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i, + // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware + // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus + /(hurd|linux)\s?([\w\.]*)/i, // Hurd/Linux + /(gnu)\s?([\w\.]*)/i // GNU + ], [NAME, VERSION], [ + + /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS + ], [[NAME, 'Chromium OS'], VERSION],[ + + // Solaris + /(sunos)\s?([\w\.\d]*)/i // Solaris + ], [[NAME, 'Solaris'], VERSION], [ + + // BSD based + /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly + ], [NAME, VERSION],[ + + /(haiku)\s(\w+)/i // Haiku + ], [NAME, VERSION],[ + + /cfnetwork\/.+darwin/i, + /ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS + ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [ + + /(mac\sos\sx)\s?([\w\s\.]*)/i, + /(macintosh|mac(?=_powerpc)\s)/i // Mac OS + ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ + + // Other + /((?:open)?solaris)[\/\s-]?([\w\.]*)/i, // Solaris + /(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i, // AIX + /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, + // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS + /(unix)\s?([\w\.]*)/i // UNIX + ], [NAME, VERSION] + ] + }; + + + ///////////////// + // Constructor + //////////////// + /* + var Browser = function (name, version) { + this[NAME] = name; + this[VERSION] = version; + }; + var CPU = function (arch) { + this[ARCHITECTURE] = arch; + }; + var Device = function (vendor, model, type) { + this[VENDOR] = vendor; + this[MODEL] = model; + this[TYPE] = type; + }; + var Engine = Browser; + var OS = Browser; + */ + var UAParser = function (uastring, extensions) { + + if (typeof uastring === 'object') { + extensions = uastring; + uastring = undefined; + } + + if (!(this instanceof UAParser)) { + return new UAParser(uastring, extensions).getResult(); + } + + var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); + var rgxmap = extensions ? util.extend(regexes, extensions) : regexes; + //var browser = new Browser(); + //var cpu = new CPU(); + //var device = new Device(); + //var engine = new Engine(); + //var os = new OS(); + + this.getBrowser = function () { + var browser = { name: undefined, version: undefined }; + mapper.rgx.call(browser, ua, rgxmap.browser); + browser.major = util.major(browser.version); // deprecated + return browser; + }; + this.getCPU = function () { + var cpu = { architecture: undefined }; + mapper.rgx.call(cpu, ua, rgxmap.cpu); + return cpu; + }; + this.getDevice = function () { + var device = { vendor: undefined, model: undefined, type: undefined }; + mapper.rgx.call(device, ua, rgxmap.device); + return device; + }; + this.getEngine = function () { + var engine = { name: undefined, version: undefined }; + mapper.rgx.call(engine, ua, rgxmap.engine); + return engine; + }; + this.getOS = function () { + var os = { name: undefined, version: undefined }; + mapper.rgx.call(os, ua, rgxmap.os); + return os; + }; + this.getResult = function () { + return { + ua : this.getUA(), + browser : this.getBrowser(), + engine : this.getEngine(), + os : this.getOS(), + device : this.getDevice(), + cpu : this.getCPU() + }; + }; + this.getUA = function () { + return ua; + }; + this.setUA = function (uastring) { + ua = uastring; + //browser = new Browser(); + //cpu = new CPU(); + //device = new Device(); + //engine = new Engine(); + //os = new OS(); + return this; + }; + return this; + }; + + UAParser.VERSION = LIBVERSION; + UAParser.BROWSER = { + NAME : NAME, + MAJOR : MAJOR, // deprecated + VERSION : VERSION + }; + UAParser.CPU = { + ARCHITECTURE : ARCHITECTURE + }; + UAParser.DEVICE = { + MODEL : MODEL, + VENDOR : VENDOR, + TYPE : TYPE, + CONSOLE : CONSOLE, + MOBILE : MOBILE, + SMARTTV : SMARTTV, + TABLET : TABLET, + WEARABLE: WEARABLE, + EMBEDDED: EMBEDDED + }; + UAParser.ENGINE = { + NAME : NAME, + VERSION : VERSION + }; + UAParser.OS = { + NAME : NAME, + VERSION : VERSION + }; + //UAParser.Utils = util; + + /////////// + // Export + ////////// + + + // check js environment + { + // nodejs env + if (module.exports) { + exports = module.exports = UAParser; + } + // TODO: test!!!!!!!! + /* + if (require && require.main === module && process) { + // cli + var jsonize = function (arr) { + var res = []; + for (var i in arr) { + res.push(new UAParser(arr[i]).getResult()); + } + process.stdout.write(JSON.stringify(res, null, 2) + '\n'); + }; + if (process.stdin.isTTY) { + // via args + jsonize(process.argv.slice(2)); + } else { + // via pipe + var str = ''; + process.stdin.on('readable', function() { + var read = process.stdin.read(); + if (read !== null) { + str += read; + } + }); + process.stdin.on('end', function () { + jsonize(str.replace(/\n$/, '').split('\n')); + }); + } + } + */ + exports.UAParser = UAParser; + } + + // jQuery/Zepto specific (optional) + // Note: + // In AMD env the global scope should be kept clean, but jQuery is an exception. + // jQuery always exports to global scope, unless jQuery.noConflict(true) is used, + // and we should catch that. + var $ = window && (window.jQuery || window.Zepto); + if (typeof $ !== UNDEF_TYPE) { + var parser = new UAParser(); + $.ua = parser.getResult(); + $.ua.get = function () { + return parser.getUA(); + }; + $.ua.set = function (uastring) { + parser.setUA(uastring); + var result = parser.getResult(); + for (var prop in result) { + $.ua[prop] = result[prop]; + } + }; + } + +})(typeof window === 'object' ? window : commonjsGlobal); +}); +var uaParser_1 = uaParser.UAParser; + +var _createProperty = function (object, index, value) { + if (index in object) _objectDp.f(object, index, _propertyDesc(0, value)); + else object[index] = value; +}; + +_export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', { + // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) + from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { + var O = _toObject(arrayLike); + var C = typeof this == 'function' ? this : Array; + var aLen = arguments.length; + var mapfn = aLen > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + var index = 0; + var iterFn = core_getIteratorMethod(O); + var length, result, step, iterator; + if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); + // if object isn't iterable or it's array with default iterator - use simple case + if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) { + for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { + _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value); + } + } else { + length = _toLength(O.length); + for (result = new C(length); length > index; index++) { + _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); + } + } + result.length = index; + return result; + } +}); + +var from_1 = _core.Array.from; + +var from_1$1 = createCommonjsModule(function (module) { +module.exports = { "default": from_1, __esModule: true }; +}); + +var _Array$from = unwrapExports(from_1$1); + +var toConsumableArray = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _from2 = _interopRequireDefault(from_1$1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + + return arr2; + } else { + return (0, _from2.default)(arr); + } +}; +}); + +var _toConsumableArray = unwrapExports(toConsumableArray); + +/** + * the handler to generate an deep traversal handler + * @param {Function} fn the function you wanna run when you reach in the deep property + * @return {Function} the handler + */ +function genTraversalHandler(fn) { + var setter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (target, key, value) { + target[key] = value; + }; + + // use recursive to move what in source to the target + // if you do not provide a target, we will create a new target + function recursiveFn(source, target, key) { + if (isArray(source) || isObject(source)) { + target = isPrimitive(target) ? isObject(source) ? {} : [] : target; + for (var _key in source) { + // $FlowFixMe: support computed key here + setter(target, _key, recursiveFn(source[_key], target[_key], _key)); + // target[key] = recursiveFn(source[key], target[key], key); + } + return target; + } + return fn(source, target, key); + } + return recursiveFn; +} +var _deepAssign = genTraversalHandler(function (val) { + return val; +}); +/** + * deeply clone an object + * @param {Array|Object} source if you pass in other type, it will throw an error + * @return {clone-target} the new Object + */ +function deepClone(source) { + if (isPrimitive(source)) { + throw new TypeError('deepClone only accept non primitive type'); + } + return _deepAssign(source); +} +/** + * merge multiple objects + * @param {...Object} args [description] + * @return {merge-object} [description] + */ +function deepAssign() { + for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (args.length < 2) { + throw new Error('deepAssign accept two and more argument'); + } + for (var i = args.length - 1; i > -1; i--) { + if (isPrimitive(args[i])) { + throw new TypeError('deepAssign only accept non primitive type'); + } + } + var target = args.shift(); + args.forEach(function (source) { + return _deepAssign(source, target); + }); + return target; +} + +/** + * camelize any string, e.g hello world -> helloWorld + * @param {string} str only accept string! + * @return {string} camelize string + */ +function camelize(str, isBig) { + return str.replace(/(^|[^a-zA-Z]+)([a-zA-Z])/g, function (match, spilt, initials, index) { + return !isBig && index === 0 ? initials.toLowerCase() : initials.toUpperCase(); + }); +} +/** + * hypenate any string e.g hello world -> hello-world + * @param {string} str only accept string + * @return {string} + */ +function hypenate(str) { + return camelize(str).replace(/([A-Z])/g, function (match) { + return '-' + match.toLowerCase(); + }); +} + +/** + * bind the function with some context. we have some fallback strategy here + * @param {function} fn the function which we need to bind the context on + * @param {any} context the context object + */ +function bind(fn, context) { + if (fn.bind) { + return fn.bind(context); + } else if (fn.apply) { + return function __autobind__() { + for (var _len2 = arguments.length, args = Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { + args[_key3] = arguments[_key3]; + } + + return fn.apply(context, args); + }; + } else { + return function __autobind__() { + for (var _len3 = arguments.length, args = Array(_len3), _key4 = 0; _key4 < _len3; _key4++) { + args[_key4] = arguments[_key4]; + } + + return fn.call.apply(fn, [context].concat(_toConsumableArray(args))); + }; + } +} + +/** + * get an deep property + */ +function getDeepProperty(obj, keys) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref$throwError = _ref.throwError, + throwError = _ref$throwError === undefined ? false : _ref$throwError, + backup = _ref.backup; + + if (isString(keys)) { + keys = keys.split('.'); + } + if (!isArray(keys)) { + throw new TypeError('keys of getDeepProperty must be string or Array'); + } + var read = []; + var target = obj; + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i]; + if (isVoid(target)) { + if (throwError) { + throw new Error('obj' + (read.length > 0 ? '.' + read.join('.') : ' itself') + ' is ' + target); + } else { + return backup; + } + } + target = target[key]; + read.push(key); + } + return target; +} + +// ********************** judgement ************************ +/** + * check if the code running in browser environment (not include worker env) + * @returns {Boolean} + */ +var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]'; + +// ********************** 对象操作 ************************ +/** + * 转变一个类数组对象为数组 + */ +function makeArray(obj) { + return _Array$from(obj); +} + +/** + * sort Object attributes by function + * and transfer them into array + * @param {Object} obj Object form from numric + * @param {Function} fn sort function + * @return {Array} the sorted attirbutes array + */ +function transObjectAttrIntoArray(obj) { + var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (a, b) { + return +a - +b; + }; + + return _Object$keys(obj).sort(fn).reduce(function (order, key) { + return order.concat(obj[key]); + }, []); +} +/** + * run a queue one by one.If include function reject or return false it will stop + * @param {Array} queue the queue which we want to run one by one + * @return {Promise} tell us whether a queue run finished + */ +function runRejectableQueue(queue) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return new _Promise(function (resolve, reject) { + var step = function step(index) { + if (index >= queue.length) { + resolve(); + return; + } + var result = isFunction(queue[index]) ? queue[index].apply(queue, _toConsumableArray(args)) : queue[index]; + if (result === false) return reject('stop'); + return _Promise.resolve(result).then(function () { + return step(index + 1); + }).catch(function (err) { + return reject(err || 'stop'); + }); + }; + step(0); + }); +} +/** + * run a queue one by one.If include function return false it will stop + * @param {Array} queue the queue which we want to run one by one + * @return {boolean} tell the user if the queue run finished + */ +function runStoppableQueue(queue) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + var step = function step(index) { + if (index >= queue.length) { + return true; + } + var result = isFunction(queue[index]) ? queue[index].apply(queue, _toConsumableArray(args)) : queue[index]; + if (result === false) return false; + return step(++index); + }; + return step(0); +} + +// requestAnimationFrame +var raf = inBrowser && (window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame) || function (cb) { + return setTimeout(cb, 17); +}; + +// cancelAnimationFrame +var caf = inBrowser && (window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.oCancelAnimationFrame) || function (id) { + clearTimeout(id); +}; + +/** +* @module event +* @author huzunjie +* @description 自定义事件基础类 +*/ + +/* 缓存事件监听方法及包装,内部数据格式: + * targetIndex_: [ [ + * function(){ ... handler ... }, + * function(){ ... handlerWrap ... handler.apply(target, arguments) ... }, + * isOnce + * ]] + */ +var _evtListenerCache = _Object$create(null); +_evtListenerCache.count = 0; + +/** + * 得到某对象的某事件类型对应的监听队列数组 + * @param {Object} target 发生事件的对象 + * @param {String} type 事件类型(这里的时间类型不只是名称,还是缓存标识,可以通过添加后缀来区分) + * @return {Array} + */ +function getEvtTypeCache(target, type) { + + var evtId = target.__evt_id; + if (!evtId) { + + /* 设置__evt_id不可枚举 */ + Object.defineProperty(target, '__evt_id', { + writable: true, + enumerable: false, + configurable: true + }); + + /* 空对象初始化绑定索引 */ + evtId = target.__evt_id = ++_evtListenerCache.count; + } + + var typeCacheKey = evtId + '_' + type; + var evtTypeCache = _evtListenerCache[typeCacheKey]; + if (!evtTypeCache) { + evtTypeCache = _evtListenerCache[typeCacheKey] = []; + } + + return evtTypeCache; +} + +/** + * 触发事件监听方法 + * @param {Object} target 发生事件的对象 + * @param {String} type 事件类型 + * @param {Object} eventObj 触发事件时要传回的event对象 + * @return {undefined} + */ +function emitEventCache(target, type, eventObj) { + var evt = _Object$create(null); + evt.type = type; + evt.target = target; + if (eventObj) { + _Object$assign(evt, isObject(eventObj) ? eventObj : { data: eventObj }); + } + getEvtTypeCache(target, type).forEach(function (item) { + (item[1] || item[0]).apply(target, [evt]); + }); +} + +/** + * 添加事件监听到缓存 + * @param {Object} target 发生事件的对象 + * @param {String} type 事件类型 + * @param {Function} handler 监听函数 + * @param {Boolean} isOnce 是否单次执行 + * @param {Function} handlerWrap + * @return {undefined} + */ +function addEventCache(target, type, handler) { + var isOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + var handlerWrap = arguments[4]; + + if (isFunction(isOnce) && !handlerWrap) { + handlerWrap = isOnce; + isOnce = undefined; + } + var handlers = [handler, undefined, isOnce]; + if (isOnce && !handlerWrap) { + handlerWrap = function handlerWrap() { + removeEventCache(target, type, handler, isOnce); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + handler.apply(target, args); + }; + } + if (handlerWrap) { + handlers[1] = handlerWrap; + } + getEvtTypeCache(target, type).push(handlers); +} + +/** + * 移除事件监听 + * @param {Object} target 发生事件的对象 + * @param {String} type 事件类型 + * @param {Function} handler 监听函数 + * @return {undefined} + */ +function removeEventCache(target, type, handler) { + var isOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + var typeCache = getEvtTypeCache(target, type); + + if (handler || isOnce) { + /* 有指定 handler 则清除对应监听 */ + var handlerId = -1; + var handlerWrap = void 0; + typeCache.find(function (item, i) { + if ((!handler || item[0] === handler) && (!isOnce || item[2])) { + handlerId = i; + handlerWrap = item[1]; + return true; + } + }); + if (handlerId !== -1) { + typeCache.splice(handlerId, 1); + } + return handlerWrap; + } else { + /* 未指定 handler 则清除type对应的所有监听 */ + typeCache.length = 0; + } +} + +/** + * @class CustEvent + * @description + * Event 自定义事件类 + * 1. 可以使用不传参得到的实例作为eventBus使用 + * 2. 可以通过指定target,用多个实例操作同一target对象的事件管理 + * 3. 当设定target时,可以通过设置assign为true,来给target实现"on\once\off\emit"方法 + * @param {Object} target 发生事件的对象(空则默认为event实例) + * @param {Boolean} assign 是否将"on\once\off\emit"方法实现到target对象上 + * @return {event} + */ +var CustEvent = function () { + function CustEvent(target, assign) { + var _this = this; + + _classCallCheck(this, CustEvent); + + /* 设置__target不可枚举 */ + Object.defineProperty(this, '__target', { + writable: true, + enumerable: false, + configurable: true + }); + this.__target = this; + + if (target) { + + if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object') { + throw new Error('CusEvent target are not object'); + } + this.__target = target; + + /* 为target实现on\once\off\emit */ + if (assign) { + ['on', 'once', 'off', 'emit'].forEach(function (mth) { + target[mth] = _this[mth]; + }); + } + } + } + + /** + * 添加事件监听 + * @param {String} type 事件类型 + * @param {Function} handler 监听函数 + * @param {Boolean} isOnce 单次监听类型 + * @return {event} + */ + + + _createClass(CustEvent, [{ + key: 'on', + value: function on(type, handler) { + var isOnce = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + addEventCache(this.__target, type, handler, isOnce); + return this; + } + + /** + * 添加事件监听,并且只执行一次 + * @param {String} type 事件类型 + * @param {Function} handler 监听函数 + * @return {event} + */ + + }, { + key: 'once', + value: function once(type, handler) { + return this.on(type, handler, true); + } + + /** + * 移除事件监听 + * @param {String} type 事件类型 + * @param {Function} handler 监听函数(不指定handler则清除type对应的所有事件监听) + * @param {Boolean} isOnce 单次监听类型 + * @return {event} + */ + + }, { + key: 'off', + value: function off(type, handler) { + var isOnce = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + removeEventCache(this.__target, type, handler, isOnce); + return this; + } + + /** + * 触发事件监听函数 + * @param {String} type 事件类型 + * @return {event} + */ + + }, { + key: 'emit', + value: function emit(type, data) { + emitEventCache(this.__target, type, { data: data }); + return this; + } + }]); + + return CustEvent; +}(); + +/** + * @module dom + * @author huzunjie + * @description 一些常用的DOM判断及操作方法,可以使用dom.$('*')包装DOM,实现类jQuery的链式操作;当然这里的静态方法也可以直接使用。 + */ + +var _divEl = inBrowser ? document.createElement('div') : {}; +var _textAttrName = 'innerText'; +'textContent' in _divEl && (_textAttrName = 'textContent'); +var _arrPrototype = Array.prototype; + +/** + * 读取HTML元素属性值 + * @param {HTMLElement} el 目标元素 + * @param {String} attrName 目标属性名称 + * @return {String} + */ +function getAttr(el, attrName) { + return el.getAttribute(attrName); +} + +/** + * 设置HTML元素属性值 + * @param {HTMLElement} el 目标元素 + * @param {String} attrName 目标属性名称 + * @param {String} attrVal 目标属性值 + */ +function setAttr(el, attrName, attrVal) { + if (attrVal === undefined) { + el.removeAttribute(attrName); + } else { + el.setAttribute(attrName, attrVal); + } +} + +/** + * 为HTML元素添加className + * @param {HTMLElement} el 目标元素 + * @param {String} cls 要添加的className(多个以空格分割) + */ +function addClassName(el, cls) { + if (!cls || !(cls = cls.trim())) { + return; + } + var clsArr = cls.split(/\s+/); + if (el.classList) { + clsArr.forEach(function (c) { + return el.classList.add(c); + }); + } else { + var curCls = ' ' + (el.className || '') + ' '; + clsArr.forEach(function (c) { + curCls.indexOf(' ' + c + ' ') === -1 && (curCls += ' ' + c); + }); + el.className = curCls.trim(); + } +} + +/** + * 为HTML元素移除className + * @param {HTMLElement} el 目标元素 + * @param {String} cls 要移除的className(多个以空格分割) + */ +function removeClassName(el, cls) { + if (!cls || !(cls = cls.trim())) { + return; + } + + var clsArr = cls.split(/\s+/); + if (el.classList) { + clsArr.forEach(function (c) { + return el.classList.remove(c); + }); + } else { + var curCls = ' ' + el.className + ' '; + clsArr.forEach(function (c) { + var tar = ' ' + c + ' '; + while (curCls.indexOf(tar) !== -1) { + curCls = curCls.replace(tar, ' '); + } + }); + el.className = curCls.trim(); + } +} + +/** + * 检查HTML元素是否已设置className + * @param {HTMLElement} el 目标元素 + * @param {String} className 要检查的className + * @return {Boolean} + */ +function hasClassName(el, className) { + return new RegExp('(?:^|\\s)' + className + '(?=\\s|$)').test(el.className); +} + +/** + * addEventListener 是否已支持 passive + * @return {Boolean} + */ +var supportsPassive = false; +try { + var opts = Object.defineProperty({}, 'passive', { + get: function get() { + supportsPassive = true; + } + }); + if (inBrowser) window.addEventListener('test', null, opts); +} catch (e) { + console.error(e); +} + +/** + * 为HTML元素移除事件监听 + * @param {HTMLElement} el 目标元素 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} once 是否只监听一次 + * @param {Boolean} capture 是否在捕获阶段的监听 + */ +function removeEvent(el, type, handler) { + var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + if (capture !== undefined && !isBoolean(capture) && supportsPassive) { + capture = { passive: true }; + } + if (once) { + /* 尝试从缓存中读取包装后的方法 */ + var handlerWrap = removeEventCache(el, type + '_once', handler); + if (handlerWrap) { + handler = handlerWrap; + } + } + el.removeEventListener(type, handler, capture); +} + +/** + * 为HTML元素添加事件监听 + * @param {HTMLElement} el 目标元素 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} once 是否只监听一次 + * @param {Boolean|Object} capture 是否在捕获阶段监听,这里也可以传入 { passive: true } 表示被动模式 + */ +function addEvent(el, type, handler) { + var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + if (capture !== undefined && !isBoolean(capture) && supportsPassive) { + capture = { passive: true }; + } + if (once) { + var oldHandler = handler; + handler = function () { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + oldHandler.apply(this, args); + removeEvent(el, type, handler, once, capture); + }; + }(); + /* 将包装后的方法记录到缓存中 */ + addEventCache(el, type + '_once', oldHandler, handler); + } + + el.addEventListener(type, handler, capture); +} + +/** + * 为HTML元素添加事件代理 + * @param {HTMLElement} el 目标元素 + * @param {String} selector 要被代理的元素 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} capture 是否在捕获阶段监听 + */ +function addDelegate(el, selector, type, handler) { + var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + if (capture !== undefined && !isBoolean(capture) && supportsPassive) { + capture = { passive: true }; + } + var handlerWrap = function handlerWrap(e) { + var targetElsArr = findParents(e.target || e.srcElement, el, true); + var targetElArr = query(selector, el, true); + var retEl = void 0; + if (targetElArr.find) { + retEl = targetElArr.find(function (seEl) { + return targetElsArr.find(function (tgEl) { + return seEl === tgEl; + }); + }); + } else { + // Fixed IE11 Array.find not defined bug + targetElArr.forEach(function (seEl) { + return !retEl && targetElsArr.forEach(function (tgEl) { + if (!retEl && seEl === tgEl) { + retEl = tgEl; + } + }); + }); + } + retEl && handler.apply(retEl, arguments); + }; + /* 将包装后的方法记录到缓存中 */ + addEventCache(el, type + '_delegate_' + selector, handler, handlerWrap); + el.addEventListener(type, handlerWrap, capture); +} + +/** + * 为HTML元素移除事件代理 + * @param {HTMLElement} el 目标元素 + * @param {String} selector 要被代理的元素 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} capture 是否在捕获阶段监听 + */ +function removeDelegate(el, selector, type, handler) { + var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + if (capture !== undefined && !isBoolean(capture) && supportsPassive) { + capture = { passive: true }; + } + /* 尝试从缓存中读取包装后的方法 */ + var handlerWrap = removeEventCache(el, type + '_delegate_' + selector, handler); + handlerWrap && el.removeEventListener(type, handlerWrap, capture); +} + +/** + * 读取HTML元素样式值 + * @param {HTMLElement} el 目标元素 + * @param {String} key 样式key + * @return {String} + */ +function getStyle(el, key) { + return (el.currentStyle || document.defaultView.getComputedStyle(el, null))[key] || el.style[key]; +} + +/** + * 设置HTML元素样式值 + * @param {HTMLElement} el 目标元素 + * @param {String} key 样式key + * @param {String} val 样式值 + */ +function setStyle(el, key, val) { + if (isObject(key)) { + for (var k in key) { + setStyle(el, k, key[k]); + } + } else { + el.style[key] = val; + } +} + +/** + * 根据选择器查询目标元素 + * @param {String} selector 选择器,用于 querySelectorAll + * @param {HTMLElement} container 父容器 + * @param {Boolean} toArray 强制输出为数组 + * @return {NodeList|Array} + */ +function query(selector) { + var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document; + var toArray = arguments[2]; + + var retNodeList = container.querySelectorAll(selector); + return toArray ? _Array$from(retNodeList) : retNodeList; +} + +/** + * 从DOM树中移除el + * @param {HTMLElement} el 目标元素 + */ +function removeEl(el) { + el.parentNode.removeChild(el); +} + +/** + * 查找元素的父节点们 + * @param {HTMLElement} el 目标元素 + * @param {HTMLElement} endEl 最大父容器(不指定则找到html) + * @param {Boolean} haveEl 包含当前元素 + * @param {Boolean} haveEndEl 包含设定的最大父容器 + */ +function findParents(el) { + var endEl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var haveEl = arguments[2]; + var haveEndEl = arguments[3]; + + var retEls = []; + if (haveEl) { + retEls.push(el); + } + while (el && el.parentNode !== endEl) { + el = el.parentNode; + el && retEls.push(el); + } + if (haveEndEl) { + retEls.push(endEl); + } + return retEls; +} + +/** + * @class NodeWrap + * @description + * NodeWrap DOM包装器,用以实现基本的链式操作 + * new dom.NodeWrap('*') 相当于 dom.$('*') + * 这里面用于DOM操作的属性方法都是基于上面静态方法实现,有需要可以随时修改补充 + * @param {String} selector 选择器(兼容 String||HTMLString||NodeList||NodeArray||HTMLElement) + * @param {HTMLElement} container 父容器(默认为document) + */ + +var NodeWrap = function () { + function NodeWrap(selector) { + var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document; + + _classCallCheck(this, NodeWrap); + + var _this = this; + _this.selector = selector; + + /* String||NodeList||HTMLElement 识别处理 */ + var elsArr = void 0; + if (selector && selector.constructor === NodeList) { + /* 支持直接传入NodeList来构建包装器 */ + elsArr = makeArray(selector); + } else if (isArray(selector)) { + /* 支持直接传入Node数组来构建包装器 */ + elsArr = selector; + } else if (isString(selector)) { + if (selector.indexOf('<') === 0) { + /* 支持直接传入HTML字符串来新建DOM并构建包装器 */ + _divEl.innerHTML = selector; + elsArr = query('*', _divEl, true); + } else { + /* 支持直接传入字符串选择器来查找DOM并构建包装器 */ + elsArr = query(selector, container, true); + } + } else { + /* 其他任意对象直接构建包装器 */ + elsArr = [selector]; + } + _Object$assign(_this, elsArr); + + /* NodeWrap本意可以 extends Array省略构造方法中下面这部分代码,但目前编译不支持 */ + _this.length = elsArr.length; + } + + /** + * 循环遍历DOM集合 + * @param {Function} fn 遍历函数 fn(item, i) + * @return {Object} + */ + + + _createClass(NodeWrap, [{ + key: 'each', + value: function each() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + _arrPrototype.forEach.apply(this, args); + return this; + } + + /** + * 添加元素到DOM集合 + * @param {HTMLElement} el 要加入的元素 + * @return {this} + */ + + }, { + key: 'push', + value: function push() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + _arrPrototype.push.apply(this, args); + return this; + } + + /** + * 截取DOM集合片段,并得到新的包装器splice + * @param {Nubmer} start + * @param {Nubmer} count + * @return {NodeWrap} 新的DOM集合包装器 + */ + + }, { + key: 'splice', + value: function splice() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + return $(_arrPrototype.splice.apply(this, args)); + } + + /** + * 查找子元素 + * @param {String} selector 选择器 + * @return {NodeWrap} 新的DOM集合包装器 + */ + + }, { + key: 'find', + value: function find(selector) { + var childs = []; + this.each(function (el) { + childs = childs.concat(query(selector, el, true)); + }); + var childsWrap = $(childs); + childsWrap.parent = this; + childsWrap.selector = selector; + return childsWrap; + } + + /** + * 添加子元素 + * @param {HTMLElement} childEls 要添加的HTML元素 + * @return {this} + */ + + }, { + key: 'append', + value: function append(childEls) { + var childsWrap = $(childEls); + var firstEl = this[0]; + childsWrap.each(function (newEl) { + return firstEl.appendChild(newEl); + }); + return this; + } + + /** + * 将元素集合添加到指定容器 + * @param {HTMLElement} parentEl 要添加到父容器 + * @return {this} + */ + + }, { + key: 'appendTo', + value: function appendTo(parentEl) { + $(parentEl).append(this); + return this; + } + + /** + * DOM集合text内容读写操作 + * @param {String} val 文本内容(如果有设置该参数则执行写操作,否则执行读操作) + * @return {this} + */ + + }, { + key: 'text', + value: function text(val) { + if (arguments.length === 0) { + return this[0][_textAttrName]; + } + return this.each(function (el) { + el[_textAttrName] = val; + }); + } + + /** + * DOM集合HTML内容读写操作 + * @param {String} html html内容(如果有设置该参数则执行写操作,否则执行读操作) + * @return {this} + */ + + }, { + key: 'html', + value: function html(_html) { + if (arguments.length === 0) { + return this[0].innerHTML; + } + return this.each(function (el) { + el.innerHTML = _html; + }); + } + + /** + * DOM集合属性读写操作 + * @param {String} name 属性名称 + * @param {String} val 属性值(如果有设置该参数则执行写操作,否则执行读操作) + * @return {this} + */ + + }, { + key: 'attr', + value: function attr(name, val) { + if (arguments.length === 1) { + return getAttr(this[0], name); + } + return this.each(function (el) { + return setAttr(el, name, val); + }); + } + + /** + * DOM集合dataset读写操作 + * @param {String} key 键名 + * @param {Any} val 键值(如果有设置该参数则执行写操作,否则执行读操作) + * @return {this} + */ + + }, { + key: 'data', + value: function data(key, val) { + if (arguments.length === 0) { + return this[0].dataset || {}; + } + if (arguments.length === 1) { + return (this[0].dataset || {})[key]; + } + return this.each(function (el) { + (el.dataset || (el.dataset = {}))[key] = val; + }); + } + + /** + * DOM集合样式读写操作 + * @param {String} key 样式key + * @param {String} val 样式值(如果有设置该参数则执行写操作,否则执行读操作) + * @return {this} + */ + + }, { + key: 'css', + value: function css(key, val) { + if (arguments.length === 1 && !isObject(key)) { + return getStyle(this[0], key); + } + return this.each(function (el) { + return setStyle(el, key, val); + }); + } + + /** + * 为DOM集合增加className + * @param {String} cls 要增加的className + * @return {this} + */ + + }, { + key: 'addClass', + value: function addClass(cls) { + return this.each(function (el) { + return addClassName(el, cls); + }); + } + + /** + * 移除当前DOM集合的className + * @param {String} cls 要移除的className + * @return {this} + */ + + }, { + key: 'removeClass', + value: function removeClass(cls) { + return this.each(function (el) { + return removeClassName(el, cls); + }); + } + + /** + * 检查索引0的DOM是否有className + * @param {String} cls 要检查的className + * @return {this} + */ + + }, { + key: 'hasClass', + value: function hasClass(cls) { + return hasClassName(this[0], cls); + } + + /** + * 为DOM集合添加事件监听 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} once 是否只监听一次 + * @param {Boolean} capture 是否在捕获阶段监听 + * @return {this} + */ + + }, { + key: 'on', + value: function on(type, handler) { + var once = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + return this.each(function (el) { + return addEvent(el, type, handler, once, capture); + }); + } + + /** + * 为DOM集合解除事件监听 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} once 是否只监听一次 + * @param {Boolean} capture 是否在捕获阶段监听 + * @return {this} + */ + + }, { + key: 'off', + value: function off(type, handler) { + var once = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + return this.each(function (el) { + return removeEvent(el, type, handler, once, capture); + }); + } + + /** + * 为DOM集合绑定事件代理 + * @param {String} selector 目标子元素选择器 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} capture 是否在捕获阶段监听 + * @return {this} + */ + + }, { + key: 'delegate', + value: function delegate(selector, type, handler) { + var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + return this.each(function (el) { + return addDelegate(el, selector, type, handler, capture); + }); + } + + /** + * 为DOM集合解绑事件代理 + * @param {String} selector 目标子元素选择器 + * @param {String} type 事件名称 + * @param {Function} handler 处理函数 + * @param {Boolean} capture 是否在捕获阶段监听 + * @return {this} + */ + + }, { + key: 'undelegate', + value: function undelegate(selector, type, handler) { + var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + return this.each(function (el) { + return removeDelegate(el, selector, type, handler, capture); + }); + } + + /** + * 从DOM树中移除 + * @return {this} + */ + + }, { + key: 'remove', + value: function remove() { + return this.each(function (el) { + return removeEl(el); + }); + } + }]); + + return NodeWrap; +}(); + +function $(selector, container) { + return selector.constructor === NodeWrap ? selector : new NodeWrap(selector, container); +} + +var tempCurrentTime = 0; + +var NativeVideoKernel = function (_CustEvent) { + _inherits(NativeVideoKernel, _CustEvent); + + _createClass(NativeVideoKernel, null, [{ + key: 'isSupport', + + /* istanbul ignore next */ + value: function isSupport() { + return true; + } + }]); + + function NativeVideoKernel(videoElement, config, customConfig) { + _classCallCheck(this, NativeVideoKernel); + + var _this = _possibleConstructorReturn(this, (NativeVideoKernel.__proto__ || _Object$getPrototypeOf(NativeVideoKernel)).call(this)); + + if (!isElement(videoElement)) throw new Error('You must pass in an legal video element but not ' + (typeof videoElement === 'undefined' ? 'undefined' : _typeof(videoElement))); + _this.video = videoElement; + _this.config = config; + _this.customConfig = customConfig; + return _this; + } + + _createClass(NativeVideoKernel, [{ + key: 'load', + value: function load(src) { + this.video.setAttribute('src', src); + this.video.src = src; + } + }, { + key: 'startLoad', + value: function startLoad(src) { + /* istanbul ignore next */ + var currentTime = this.video.currentTime || tempCurrentTime; + this.load(src); + this.seek(currentTime); + } + + // https://developer.mozilla.org/de/docs/Web/HTML/Using_HTML5_audio_and_video#Stopping_the_download_of_media + + }, { + key: 'stopLoad', + value: function stopLoad() { + tempCurrentTime = this.video.currentTime; + this.video.src = ''; + this.video.removeAttribute('src'); + } + }, { + key: 'destroy', + value: function destroy() { + /* istanbul ignore next */ + if (isElement(this.video)) this.stopLoad(); + } + }, { + key: 'play', + value: function play() { + return this.video.play(); + } + }, { + key: 'pause', + value: function pause() { + return this.video.pause(); + } + }, { + key: 'refresh', + value: function refresh() { + this.video.src = this.config.src; + } + }, { + key: 'attachMedia', + value: function attachMedia() {} + }, { + key: 'seek', + value: function seek(seconds) { + this.video.currentTime = seconds; + } + }]); + + return NativeVideoKernel; +}(CustEvent); + +var LOG_TAG = 'chimee'; +var boxSuffixMap = { + flv: '.flv', + hls: '.m3u8', + native: '.mp4' +}; + +// return the config box +// or choose the right one according to the src +function getLegalBox(_ref) { + var src = _ref.src, + box = _ref.box; + + if (isString(box) && box) return box; + src = src.toLowerCase(); + for (var key in boxSuffixMap) { + var suffix = boxSuffixMap[key]; + if (src.indexOf(suffix) > -1) return key; + } + return 'native'; +} + +var ChimeeKernel = function () { + /** + * kernelWrapper + * @param {any} wrap videoElement + * @param {any} option + * @class kernel + */ + function ChimeeKernel(videoElement, config) { + _classCallCheck(this, ChimeeKernel); + + if (!isElement(videoElement)) throw new Error('You must pass in an video element to the chimee-kernel'); + this.config = config; + this.videoElement = videoElement; + this.initVideoKernel(); + } + + _createClass(ChimeeKernel, [{ + key: 'destroy', + value: function destroy() { + this.videoKernel.destroy(); + } + }, { + key: 'initVideoKernel', + value: function initVideoKernel() { + var config = this.config; + var box = getLegalBox(config); + this.box = box; + var VideoKernel = this.chooseVideoKernel(this.box, config.preset); + + if (!isFunction(VideoKernel)) throw new Error('We can\'t find video kernel for ' + box + '. Please check your config and make sure it\'s installed or provided'); + + var customConfig = config.presetConfig[this.box]; + + // TODO: nowaday, kernels all get config from one config + // it's not a good way, because custom config may override kernel config + // so we may remove this code when we check all the chimee-kernel-* setting + if (customConfig) deepAssign(config, customConfig); + + this.videoKernel = new VideoKernel(this.videoElement, config, customConfig); + } + + // choose the right video kernel according to the box setting + + }, { + key: 'chooseVideoKernel', + value: function chooseVideoKernel(box, preset) { + switch (box) { + case 'native': + // $FlowFixMe: it's the same as videoKernel + return NativeVideoKernel; + case 'mp4': + return this.getMp4Kernel(preset.mp4); + case 'flv': + case 'hls': + return preset[box]; + default: + throw new Error('We currently do not support box ' + box + ', please contact us through https://github.com/Chimeejs/chimee/issues.'); + } + } + + // fetch the legal mp4 kernel + // if it's not exist or not support + // we will fall back to the native video kernel + + }, { + key: 'getMp4Kernel', + value: function getMp4Kernel(Mp4Kernel) { + var hasLegalMp4Kernel = Mp4Kernel && isFunction(Mp4Kernel.isSupport); + // $FlowFixMe: we have make sure it's an kernel now + var supportMp4Kernel = hasLegalMp4Kernel && Mp4Kernel.isSupport(); + // $FlowFixMe: we have make sure it's an kernel now + if (supportMp4Kernel) return Mp4Kernel; + if (hasLegalMp4Kernel) Log.warn(LOG_TAG, 'mp4 decode is not support in this browser, we will switch to the native video kernel'); + this.box = 'native'; + // $FlowFixMe: it's the same as videoKernel + return NativeVideoKernel; + } + }, { + key: 'attachMedia', + value: function attachMedia() { + this.videoKernel.attachMedia(); + } + }, { + key: 'load', + value: function load() { + var src = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.config.src; + + this.config.src = src; + this.videoKernel.load(src); + } + }, { + key: 'startLoad', + value: function startLoad() { + /* istanbul ignore if */ + if (!isFunction(this.videoKernel.startLoad)) throw new Error('This video kernel do not support startLoad, please contact us on https://github.com/Chimeejs/chimee/issues'); + this.videoKernel.startLoad(this.config.src); + } + }, { + key: 'stopLoad', + value: function stopLoad() { + /* istanbul ignore else */ + if (isFunction(this.videoKernel.stopLoad)) this.videoKernel.stopLoad(); + } + }, { + key: 'play', + value: function play() { + this.videoKernel.play(); + } + }, { + key: 'pause', + value: function pause() { + this.videoKernel.pause(); + } + }, { + key: 'seek', + value: function seek(seconds) { + if (!isNumber(seconds)) { + Log.error(LOG_TAG, 'When you try to seek, you must offer us a number, but not ' + (typeof seconds === 'undefined' ? 'undefined' : _typeof(seconds))); + return; + } + this.videoKernel.seek(seconds); + } + }, { + key: 'refresh', + value: function refresh() { + this.videoKernel.refresh(); + } + }, { + key: 'on', + value: function on(key, fn) { + this.videoKernel.on(key, fn); + } + }, { + key: 'off', + value: function off(key, fn) { + this.videoKernel.off(key, fn); + } + }, { + key: 'currentTime', + get: function get() { + return this.videoElement.currentTime || 0; + } + }]); + + return ChimeeKernel; +}(); + +// all object keys, includes non-enumerable and symbols + + + +var Reflect = _global.Reflect; +var _ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) { + var keys = _objectGopn.f(_anObject(it)); + var getSymbols = _objectGops.f; + return getSymbols ? keys.concat(getSymbols(it)) : keys; +}; + +// https://github.com/tc39/proposal-object-getownpropertydescriptors + + + + + + +_export(_export.S, 'Object', { + getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { + var O = _toIobject(object); + var getDesc = _objectGopd.f; + var keys = _ownKeys(O); + var result = {}; + var i = 0; + var key, desc; + while (keys.length > i) { + desc = getDesc(O, key = keys[i++]); + if (desc !== undefined) _createProperty(result, key, desc); + } + return result; + } +}); + +var getOwnPropertyDescriptors = _core.Object.getOwnPropertyDescriptors; + +var getOwnPropertyDescriptors$1 = createCommonjsModule(function (module) { +module.exports = { "default": getOwnPropertyDescriptors, __esModule: true }; +}); + +var _Object$getOwnPropertyDescriptors = unwrapExports(getOwnPropertyDescriptors$1); + +var getOwnPropertySymbols = _core.Object.getOwnPropertySymbols; + +var getOwnPropertySymbols$1 = createCommonjsModule(function (module) { +module.exports = { "default": getOwnPropertySymbols, __esModule: true }; +}); + +var _Object$getOwnPropertySymbols = unwrapExports(getOwnPropertySymbols$1); + +// 19.1.2.7 Object.getOwnPropertyNames(O) +_objectSap('getOwnPropertyNames', function () { + return _objectGopnExt.f; +}); + +var $Object$3 = _core.Object; +var getOwnPropertyNames = function getOwnPropertyNames(it) { + return $Object$3.getOwnPropertyNames(it); +}; + +var getOwnPropertyNames$1 = createCommonjsModule(function (module) { +module.exports = { "default": getOwnPropertyNames, __esModule: true }; +}); + +var _Object$getOwnPropertyNames = unwrapExports(getOwnPropertyNames$1); + +/** + * bind the function with some context. we have some fallback strategy here + * @param {function} fn the function which we need to bind the context on + * @param {any} context the context object + */ +function bind$1(fn, context) { + if (fn.bind) { + return fn.bind(context); + } else if (fn.apply) { + return function __autobind__() { + for (var _len2 = arguments.length, args = Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { + args[_key3] = arguments[_key3]; + } + + return fn.apply(context, args); + }; + } else { + return function __autobind__() { + for (var _len3 = arguments.length, args = Array(_len3), _key4 = 0; _key4 < _len3; _key4++) { + args[_key4] = arguments[_key4]; + } + + return fn.call.apply(fn, [context].concat(_toConsumableArray(args))); + }; + } +} + +/** + * get an deep property + */ +function getDeepProperty$1(obj, keys) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref$throwError = _ref.throwError, + throwError = _ref$throwError === undefined ? false : _ref$throwError, + backup = _ref.backup; + + if (isString(keys)) { + keys = keys.split('.'); + } + if (!isArray(keys)) { + throw new TypeError('keys of getDeepProperty must be string or Array'); + } + var read = []; + var target = obj; + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i]; + if (isVoid(target)) { + if (throwError) { + throw new Error('obj' + (read.length > 0 ? '.' + read.join('.') : ' itself') + ' is ' + target); + } else { + return backup; + } + } + target = target[key]; + read.push(key); + } + return target; +} + +var SPECIES$2 = _wks('species'); + +var _arraySpeciesConstructor = function (original) { + var C; + if (_isArray(original)) { + C = original.constructor; + // cross-realm fallback + if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined; + if (_isObject(C)) { + C = C[SPECIES$2]; + if (C === null) C = undefined; + } + } return C === undefined ? Array : C; +}; + +// 9.4.2.3 ArraySpeciesCreate(originalArray, length) + + +var _arraySpeciesCreate = function (original, length) { + return new (_arraySpeciesConstructor(original))(length); +}; + +// 0 -> Array#forEach +// 1 -> Array#map +// 2 -> Array#filter +// 3 -> Array#some +// 4 -> Array#every +// 5 -> Array#find +// 6 -> Array#findIndex + + + + + +var _arrayMethods = function (TYPE, $create) { + var IS_MAP = TYPE == 1; + var IS_FILTER = TYPE == 2; + var IS_SOME = TYPE == 3; + var IS_EVERY = TYPE == 4; + var IS_FIND_INDEX = TYPE == 6; + var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; + var create = $create || _arraySpeciesCreate; + return function ($this, callbackfn, that) { + var O = _toObject($this); + var self = _iobject(O); + var f = _ctx(callbackfn, that, 3); + var length = _toLength(self.length); + var index = 0; + var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; + var val, res; + for (;length > index; index++) if (NO_HOLES || index in self) { + val = self[index]; + res = f(val, index, O); + if (TYPE) { + if (IS_MAP) result[index] = res; // map + else if (res) switch (TYPE) { + case 3: return true; // some + case 5: return val; // find + case 6: return index; // findIndex + case 2: result.push(val); // filter + } else if (IS_EVERY) return false; // every + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; + }; +}; + +var _validateCollection = function (it, TYPE) { + if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); + return it; +}; + +var getWeak = _meta.getWeak; + + + + + + + +var arrayFind = _arrayMethods(5); +var arrayFindIndex = _arrayMethods(6); +var id$1 = 0; + +// fallback for uncaught frozen keys +var uncaughtFrozenStore = function (that) { + return that._l || (that._l = new UncaughtFrozenStore()); +}; +var UncaughtFrozenStore = function () { + this.a = []; +}; +var findUncaughtFrozen = function (store, key) { + return arrayFind(store.a, function (it) { + return it[0] === key; + }); +}; +UncaughtFrozenStore.prototype = { + get: function (key) { + var entry = findUncaughtFrozen(this, key); + if (entry) return entry[1]; + }, + has: function (key) { + return !!findUncaughtFrozen(this, key); + }, + set: function (key, value) { + var entry = findUncaughtFrozen(this, key); + if (entry) entry[1] = value; + else this.a.push([key, value]); + }, + 'delete': function (key) { + var index = arrayFindIndex(this.a, function (it) { + return it[0] === key; + }); + if (~index) this.a.splice(index, 1); + return !!~index; + } +}; + +var _collectionWeak = { + getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { + var C = wrapper(function (that, iterable) { + _anInstance(that, C, NAME, '_i'); + that._t = NAME; // collection type + that._i = id$1++; // collection id + that._l = undefined; // leak store for uncaught frozen objects + if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); + }); + _redefineAll(C.prototype, { + // 23.3.3.2 WeakMap.prototype.delete(key) + // 23.4.3.3 WeakSet.prototype.delete(value) + 'delete': function (key) { + if (!_isObject(key)) return false; + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key); + return data && _has(data, this._i) && delete data[this._i]; + }, + // 23.3.3.4 WeakMap.prototype.has(key) + // 23.4.3.4 WeakSet.prototype.has(value) + has: function has(key) { + if (!_isObject(key)) return false; + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key); + return data && _has(data, this._i); + } + }); + return C; + }, + def: function (that, key, value) { + var data = getWeak(_anObject(key), true); + if (data === true) uncaughtFrozenStore(that).set(key, value); + else data[that._i] = value; + return that; + }, + ufstore: uncaughtFrozenStore +}; + +var dP$2 = _objectDp.f; +var each = _arrayMethods(0); + + +var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { + var Base = _global[NAME]; + var C = Base; + var ADDER = IS_MAP ? 'set' : 'add'; + var proto = C && C.prototype; + var O = {}; + if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () { + new C().entries().next(); + }))) { + // create collection constructor + C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); + _redefineAll(C.prototype, methods); + _meta.NEED = true; + } else { + C = wrapper(function (target, iterable) { + _anInstance(target, C, NAME, '_c'); + target._c = new Base(); + if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target); + }); + each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) { + var IS_ADDER = KEY == 'add' || KEY == 'set'; + if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) { + _anInstance(this, C, KEY); + if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false; + var result = this._c[KEY](a === 0 ? 0 : a, b); + return IS_ADDER ? this : result; + }); + }); + IS_WEAK || dP$2(C.prototype, 'size', { + get: function () { + return this._c.size; + } + }); + } + + _setToStringTag(C, NAME); + + O[NAME] = C; + _export(_export.G + _export.W + _export.F, O); + + if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); + + return C; +}; + +var es6_weakMap = createCommonjsModule(function (module) { +var each = _arrayMethods(0); + + + + + + + +var WEAK_MAP = 'WeakMap'; +var getWeak = _meta.getWeak; +var isExtensible = Object.isExtensible; +var uncaughtFrozenStore = _collectionWeak.ufstore; +var tmp = {}; +var InternalMap; + +var wrapper = function (get) { + return function WeakMap() { + return get(this, arguments.length > 0 ? arguments[0] : undefined); + }; +}; + +var methods = { + // 23.3.3.3 WeakMap.prototype.get(key) + get: function get(key) { + if (_isObject(key)) { + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key); + return data ? data[this._i] : undefined; + } + }, + // 23.3.3.5 WeakMap.prototype.set(key, value) + set: function set(key, value) { + return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value); + } +}; + +// 23.3 WeakMap Objects +var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true); + +// IE11 WeakMap frozen keys fix +if (_fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) { + InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP); + _objectAssign(InternalMap.prototype, methods); + _meta.NEED = true; + each(['delete', 'has', 'get', 'set'], function (key) { + var proto = $WeakMap.prototype; + var method = proto[key]; + _redefine(proto, key, function (a, b) { + // store frozen objects on internal weakmap shim + if (_isObject(a) && !isExtensible(a)) { + if (!this._f) this._f = new InternalMap(); + var result = this._f[key](a, b); + return key == 'set' ? this : result; + // store all the rest on native weakmap + } return method.call(this, a, b); + }); + }); +} +}); + +// https://tc39.github.io/proposal-setmap-offrom/ + + +var _setCollectionOf = function (COLLECTION) { + _export(_export.S, COLLECTION, { of: function of() { + var length = arguments.length; + var A = new Array(length); + while (length--) A[length] = arguments[length]; + return new this(A); + } }); +}; + +// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of +_setCollectionOf('WeakMap'); + +// https://tc39.github.io/proposal-setmap-offrom/ + + + + + +var _setCollectionFrom = function (COLLECTION) { + _export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) { + var mapFn = arguments[1]; + var mapping, A, n, cb; + _aFunction(this); + mapping = mapFn !== undefined; + if (mapping) _aFunction(mapFn); + if (source == undefined) return new this(); + A = []; + if (mapping) { + n = 0; + cb = _ctx(mapFn, arguments[2], 2); + _forOf(source, false, function (nextItem) { + A.push(cb(nextItem, n++)); + }); + } else { + _forOf(source, false, A.push, A); + } + return new this(A); + } }); +}; + +// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from +_setCollectionFrom('WeakMap'); + +var weakMap = _core.WeakMap; + +var weakMap$1 = createCommonjsModule(function (module) { +module.exports = { "default": weakMap, __esModule: true }; +}); + +var _WeakMap = unwrapExports(weakMap$1); + +var defineProperty$3 = createCommonjsModule(function (module, exports) { + +exports.__esModule = true; + + + +var _defineProperty2 = _interopRequireDefault(defineProperty$1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (obj, key, value) { + if (key in obj) { + (0, _defineProperty2.default)(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +}; +}); + +var _defineProperty = unwrapExports(defineProperty$3); + +// 19.1.2.15 Object.preventExtensions(O) + +var meta = _meta.onFreeze; + +_objectSap('preventExtensions', function ($preventExtensions) { + return function preventExtensions(it) { + return $preventExtensions && _isObject(it) ? $preventExtensions(meta(it)) : it; + }; +}); + +var preventExtensions = _core.Object.preventExtensions; + +var preventExtensions$1 = createCommonjsModule(function (module) { +module.exports = { "default": preventExtensions, __esModule: true }; +}); + +unwrapExports(preventExtensions$1); + +var getOwnPropertyDescriptor$2 = _Object$getOwnPropertyDescriptor; +// ********************** 对象操作 ************************ +/** + * sort Object attributes by function + * and transfer them into array + * @param {Object} obj Object form from numric + * @param {Function} fn sort function + * @return {Array} the sorted attirbutes array + */ + + +/** + * to check if an descriptor + * @param {anything} desc + */ +function isDescriptor(desc) { + if (!desc || !desc.hasOwnProperty) { + return false; + } + + var keys = ['value', 'initializer', 'get', 'set']; + + for (var i = 0, l = keys.length; i < l; i++) { + if (desc.hasOwnProperty(keys[i])) { + return true; + } + } + return false; +} +/** + * to check if the descirptor is an accessor descriptor + * @param {descriptor} desc it should be a descriptor better + */ +function isAccessorDescriptor(desc) { + return !!desc && (isFunction(desc.get) || isFunction(desc.set)) && isBoolean(desc.configurable) && isBoolean(desc.enumerable) && desc.writable === undefined; +} +/** + * to check if the descirptor is an data descriptor + * @param {descriptor} desc it should be a descriptor better + */ +function isDataDescriptor(desc) { + return !!desc && desc.hasOwnProperty('value') && isBoolean(desc.configurable) && isBoolean(desc.enumerable) && isBoolean(desc.writable); +} +/** + * to check if the descirptor is an initiallizer descriptor + * @param {descriptor} desc it should be a descriptor better + */ +function isInitializerDescriptor(desc) { + return !!desc && isFunction(desc.initializer) && isBoolean(desc.configurable) && isBoolean(desc.enumerable) && isBoolean(desc.writable); +} +/** + * set one value on the object + * @param {string} key + */ +function createDefaultSetter(key) { + return function set(newValue) { + _Object$defineProperty(this, key, { + configurable: true, + writable: true, + // IS enumerable when reassigned by the outside word + enumerable: true, + value: newValue + }); + return newValue; + }; +} + +/** + * Compress many function into one function, but this function only accept one arguments; + * @param {Array} fns the array of function we need to compress into one function + * @param {string} errmsg When we check that there is something is not function, we will throw an error, you can set your own error message + */ +function compressOneArgFnArray(fns) { + var errmsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'You must pass me an array of function'; + + if (!isArray(fns) || fns.length < 1) { + throw new TypeError(errmsg); + } + if (fns.length === 1) { + if (!isFunction(fns[0])) { + throw new TypeError(errmsg); + } + return fns[0]; + } + return fns.reduce(function (prev, curr) { + if (!isFunction(curr) || !isFunction(prev)) throw new TypeError(errmsg); + return function (value) { + return bind$1(curr, this)(bind$1(prev, this)(value)); + }; + }); +} +/** + * just a method to call console.warn, maybe i will add some handler on it someday + * @param {anything} args + */ +function warn(message) { + if (isFunction(console.warn)) return console.warn(message); + console.log(message); +} + +function getOwnKeysFn() { + var getOwnPropertyNames = _Object$getOwnPropertyNames, + getOwnPropertySymbols = _Object$getOwnPropertySymbols; + + return isFunction(getOwnPropertySymbols) ? function (obj) { + // $FlowFixMe: do not support symwbol yet + return _Array$from(getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj))); + } : getOwnPropertyNames; +} + +var getOwnKeys = getOwnKeysFn(); + +function getOwnPropertyDescriptorsFn() { + // $FlowFixMe: In some environment, Object.getOwnPropertyDescriptors has been implemented; + return isFunction(_Object$getOwnPropertyDescriptors) ? _Object$getOwnPropertyDescriptors : function (obj) { + return getOwnKeys(obj).reduce(function (descs, key) { + descs[key] = getOwnPropertyDescriptor$2(obj, key); + return descs; + }, {}); + }; +} + +var getOwnPropertyDescriptors$2 = getOwnPropertyDescriptorsFn(); + +function compressMultipleDecorators() { + for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { + fns[_key] = arguments[_key]; + } + + if (!fns.length) throw new TypeError('You must pass in decorators in compressMultipleDecorators'); + fns.forEach(function (fn) { + if (!isFunction(fn)) throw new TypeError('Decorators must be a function, but not "' + fn + '" in ' + (typeof fn === 'undefined' ? 'undefined' : _typeof(fn))); + }); + if (fns.length === 1) return fns[0]; + return function (obj, prop, descirptor) { + // $FlowFixMe: the reduce will return a descriptor + return fns.reduce(function (descirptor, fn) { + return fn(obj, prop, descirptor); + }, descirptor); + }; +} + +function accessor() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + get = _ref.get, + set = _ref.set; + + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$preGet = _ref2.preGet, + preGet = _ref2$preGet === undefined ? false : _ref2$preGet, + _ref2$preSet = _ref2.preSet, + preSet = _ref2$preSet === undefined ? true : _ref2$preSet; + + if (!isFunction(get) && !isFunction(set) && !(isArray(get) && get.length > 0) && !(isArray(set) && set.length > 0)) throw new TypeError("@accessor need a getter or setter. If you don't need to add setter/getter. You should remove @accessor"); + var errmsg = '@accessor only accept function or array of function as getter/setter'; + get = isArray(get) ? compressOneArgFnArray(get, errmsg) : get; + set = isArray(set) ? compressOneArgFnArray(set, errmsg) : set; + return function (obj, prop, descriptor) { + var _ref3 = descriptor || {}, + _ref3$configurable = _ref3.configurable, + configurable = _ref3$configurable === undefined ? true : _ref3$configurable, + _ref3$enumerable = _ref3.enumerable, + enumerable = _ref3$enumerable === undefined ? true : _ref3$enumerable; + + var hasGet = isFunction(get); + var hasSet = isFunction(set); + var handleGet = function handleGet(value) { + // $FlowFixMe: it's really function here + return hasGet ? bind$1(get, this)(value) : value; + }; + var handleSet = function handleSet(value) { + // $FlowFixMe: it's really function here + return hasSet ? bind$1(set, this)(value) : value; + }; + if (isAccessorDescriptor(descriptor)) { + var originGet = descriptor.get, + originSet = descriptor.set; + + var hasOriginGet = isFunction(originGet); + var hasOriginSet = isFunction(originSet); + if (!hasOriginGet && hasGet) { + warn('You are trying to set getter via @accessor on ' + prop + ' without getter. That\'s not a good idea.'); + } + if (!hasOriginSet && hasSet) { + warn('You are trying to set setter via @accessor on ' + prop + ' without setter. That\'s not a good idea.'); + } + var getter = hasOriginGet || hasGet ? function () { + var _this = this; + + var boundGetter = bind$1(handleGet, this); + var originBoundGetter = function originBoundGetter() { + return hasOriginGet + // $FlowFixMe: we have do a check here + ? bind$1(originGet, _this)() : undefined; + }; + var order = preGet ? [boundGetter, originBoundGetter] : [originBoundGetter, boundGetter]; + // $FlowFixMe: it's all function here + return order.reduce(function (value, fn) { + return fn(value); + }, undefined); + } : undefined; + var setter = hasOriginSet || hasSet ? function (val) { + var _this2 = this; + + var boundSetter = bind$1(handleSet, this); + var originBoundSetter = function originBoundSetter(value) { + return hasOriginSet + // $FlowFixMe: flow act like a retarded child on optional property + ? bind$1(originSet, _this2)(value) : value; + }; + var order = preSet ? [boundSetter, originBoundSetter] : [originBoundSetter, boundSetter]; + return order.reduce(function (value, fn) { + return fn(value); + }, val); + } : undefined; + return { + get: getter, + set: setter, + configurable: configurable, + enumerable: enumerable + }; + } else if (isInitializerDescriptor(descriptor)) { + // $FlowFixMe: disjoint union is horrible, descriptor is initializerDescriptor now + var initializer = descriptor.initializer; + + var value = void 0; + var inited = false; + return { + get: function get() { + var boundFn = bind$1(handleGet, this); + if (inited) return boundFn(value); + value = bind$1(initializer, this)(); + inited = true; + return boundFn(value); + }, + set: function set(val) { + var boundFn = bind$1(handleSet, this); + value = preSet ? boundFn(val) : val; + inited = true; + if (!preSet) { + boundFn(value); + } + return value; + }, + + configurable: configurable, + enumerable: enumerable + }; + } else { + // $FlowFixMe: disjoint union is horrible, descriptor is DataDescriptor now + var _ref4 = descriptor || {}, + _value = _ref4.value; + + return { + get: function get() { + return bind$1(handleGet, this)(_value); + }, + set: function set(val) { + var boundFn = bind$1(handleSet, this); + _value = preSet ? boundFn(val) : val; + if (!preSet) { + boundFn(_value); + } + return _value; + }, + + configurable: configurable, + enumerable: enumerable + }; + } + }; +} + +function before() { + for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { + fns[_key] = arguments[_key]; + } + + if (fns.length === 0) throw new Error("@before accept at least one parameter. If you don't need to preprocess before your function, do not add @before decorators"); + if (fns.length > 2 && isDescriptor(fns[2])) { + throw new Error('You may use @before straightly, @before return decorators, you should call it before you set it as decorator.'); + } + for (var i = fns.length - 1; i > -1; i--) { + if (!isFunction(fns[i])) throw new TypeError('@before only accept function parameter'); + } + return function (obj, prop, descriptor) { + var _ref = descriptor || {}, + fn = _ref.value, + configurable = _ref.configurable, + enumerable = _ref.enumerable, + writable = _ref.writable; + + if (!isFunction(fn)) throw new TypeError('@before can only be used on function, please check the property "' + prop + '" is a method or not.'); + var handler = function handler() { + var _this = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var paras = fns.reduce(function (paras, fn) { + var result = bind$1(fn, _this).apply(undefined, _toConsumableArray(paras)); + return result === undefined ? paras : isArray(result) ? result + // $FlowFixMe: what the hell, it can be anything + : [result]; + }, args); + return bind$1(fn, this).apply(undefined, _toConsumableArray(paras)); + }; + return { + value: handler, + configurable: configurable, + enumerable: enumerable, + writable: writable + }; + }; +} + +function initialize() { + for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { + fns[_key] = arguments[_key]; + } + + if (fns.length === 0) throw new Error("@initialize accept at least one parameter. If you don't need to initialize your value, do not add @initialize."); + if (fns.length > 2 && isDescriptor(fns[2])) { + throw new Error('You may use @initialize straightly, @initialize return decorators, you need to call it'); + } + var fn = compressOneArgFnArray(fns, '@initialize only accept function parameter'); + return function (obj, prop, descriptor) { + if (descriptor === undefined) { + return { + value: bind$1(fn, obj)(), + configurable: true, + writable: true, + enumerable: true + }; + } + if (isAccessorDescriptor(descriptor)) { + var hasBeenReset = false; + var originSet = descriptor.set; + + return accessor({ + get: function get(value) { + if (hasBeenReset) return value; + return bind$1(fn, this)(value); + }, + + set: originSet ? function (value) { + hasBeenReset = true; + return value; + } : undefined + })(obj, prop, descriptor); + } + /** + * when we set decorator on propery + * we will get a descriptor with initializer + * as they will be attach on the instance later + * so, we need to substitute the initializer function + */ + if (isInitializerDescriptor(descriptor)) { + // $FlowFixMe: useless disjoint union + var initializer = descriptor.initializer; + + var handler = function handler() { + return bind$1(fn, this)(bind$1(initializer, this)()); + }; + return { + initializer: handler, + configurable: descriptor.configurable, + // $FlowFixMe: useless disjoint union + writable: descriptor.writable, + enumerable: descriptor.enumerable + }; + } + // $FlowFixMe: useless disjoint union + var value = bind$1(fn, this)(descriptor.value); + return { + value: value, + // $FlowFixMe: useless disjoint union + writable: descriptor.writable, + configurable: descriptor.configurable, + enumerable: descriptor.enumerable + }; + }; +} + +var getOwnPropertyDescriptor$1$1 = _Object$getOwnPropertyDescriptor; +var defineProperty$4 = _Object$defineProperty; + +function setAlias(root, prop, _ref, obj, key, _ref2) { + var configurable = _ref.configurable, + enumerable = _ref.enumerable; + var force = _ref2.force, + omit = _ref2.omit; + + var originDesc = getOwnPropertyDescriptor$1$1(obj, key); + if (originDesc !== undefined) { + if (omit) return; + // TODO: we should add an github link here + if (!force) throw new Error('"' + prop + '" is an existing property, if you want to override it, please set "force" true in @alias option.'); + if (!originDesc.configurable) { + throw new Error('property "' + prop + '" is unconfigurable.'); + } + } + defineProperty$4(obj, key, { + get: function get() { + return root[prop]; + }, + set: function set(value) { + root[prop] = value; + return prop; + }, + + configurable: configurable, + enumerable: enumerable + }); +} +function alias(other, key, option) { + // set argument into right position + if (arguments.length === 2) { + if (isString(other)) { + // $FlowFixMe: i will check this later + option = key; + key = other; + other = undefined; + } + } else if (arguments.length === 1) { + // $FlowFixMe: i will check this later + key = other; + other = undefined; + } + // argument validate + if (!isString(key)) throw new TypeError('@alias need a string as a key to find the porperty to set alias on'); + var illegalObjErrorMsg = 'If you want to use @alias to set alias on other instance, you must pass in a legal instance'; + if (other !== undefined && isPrimitive(other)) throw new TypeError(illegalObjErrorMsg); + + var _ref3 = isObject(option) ? option : { force: false, omit: false }, + force = _ref3.force, + omit = _ref3.omit; + + return function (obj, prop, descriptor) { + descriptor = descriptor || { + value: undefined, + configurable: true, + writable: true, + enumerable: true + }; + function getTargetAndName(other, obj, key) { + var target = isPrimitive(other) ? obj : other; + var keys = key.split('.'); + + var _keys$slice = keys.slice(-1), + _keys$slice2 = _slicedToArray(_keys$slice, 1), + name = _keys$slice2[0]; + + target = getDeepProperty$1(target, keys.slice(0, -1), { throwError: true }); + if (isPrimitive(target)) { + throw new TypeError(illegalObjErrorMsg); + } + return { + target: target, + name: name + }; + } + if (isInitializerDescriptor(descriptor)) { + return initialize(function (value) { + var _getTargetAndName = getTargetAndName(other, this, key), + target = _getTargetAndName.target, + name = _getTargetAndName.name; + + setAlias(this, prop, descriptor, target, name, { force: force, omit: omit }); + return value; + })(obj, prop, descriptor); + } + if (isAccessorDescriptor(descriptor)) { + var inited = void 0; + var handler = function handler(value) { + if (inited) return value; + + var _getTargetAndName2 = getTargetAndName(other, this, key), + target = _getTargetAndName2.target, + name = _getTargetAndName2.name; + + setAlias(this, prop, descriptor, target, name, { force: force, omit: omit }); + inited = true; + return value; + }; + return accessor({ get: handler, set: handler })(obj, prop, descriptor); + } + + var _getTargetAndName3 = getTargetAndName(other, obj, key), + target = _getTargetAndName3.target, + name = _getTargetAndName3.name; + + setAlias(obj, prop, descriptor, target, name, { force: force, omit: omit }); + return descriptor; + }; +} + +var defineProperty$1$1 = _Object$defineProperty; + +function classify(decorator) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + requirement = _ref.requirement, + _ref$customArgs = _ref.customArgs, + customArgs = _ref$customArgs === undefined ? false : _ref$customArgs; + + return function () { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref2$exclude = _ref2.exclude, + exclude = _ref2$exclude === undefined ? [] : _ref2$exclude, + _ref2$include = _ref2.include, + include = _ref2$include === undefined ? [] : _ref2$include, + _ref2$construct = _ref2.construct, + construct = _ref2$construct === undefined ? false : _ref2$construct, + _ref2$self = _ref2.self, + self = _ref2$self === undefined ? false : _ref2$self; + + if (!isArray(exclude)) throw new TypeError('options.exclude must be an array'); + if (!isArray(include)) throw new TypeError('options.include must be an array'); + return function (Klass) { + var isClass = isFunction(Klass); + if (!self && !isClass) throw new TypeError('@' + decorator.name + 'Class can only be used on class'); + if (self && isPrimitive(Klass)) throw new TypeError('@' + decorator.name + 'Class must be used on non-primitive type value in \'self\' mode'); + var prototype = self ? Klass : Klass.prototype; + if (isVoid(prototype)) throw new Error('The prototype of the ' + Klass.name + ' is empty, please check it'); + var descs = getOwnPropertyDescriptors$2(prototype); + getOwnKeys(prototype).concat(include).forEach(function (key) { + var desc = descs[key]; + if (key === 'constructor' && !construct || self && isClass && ['name', 'length', 'prototype'].indexOf(key) > -1 || exclude.indexOf(key) > -1 || isFunction(requirement) && requirement(prototype, key, desc, { self: self }) === false) return; + defineProperty$1$1(prototype, key, (customArgs ? decorator.apply(undefined, _toConsumableArray(args)) : decorator)(prototype, key, desc)); + }); + }; + }; +} + +var autobindClass = classify(autobind, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + } +}); + +var mapStore = void 0; +// save bound function for super +function getBoundSuper(obj, fn) { + if (typeof _WeakMap === 'undefined') { + throw new Error('Using @autobind on ' + fn.name + '() requires WeakMap support due to its use of super.' + fn.name + '()'); + } + + if (!mapStore) { + mapStore = new _WeakMap(); + } + + if (mapStore.has(obj) === false) { + mapStore.set(obj, new _WeakMap()); + } + + var superStore = mapStore.get(obj); + // $FlowFixMe: already insure superStore is not undefined + if (superStore.has(fn) === false) { + // $FlowFixMe: already insure superStore is not undefined + superStore.set(fn, bind$1(fn, obj)); + } + // $FlowFixMe: already insure superStore is not undefined + return superStore.get(fn); +} +/** + * auto bind the function on the class, just support function + * @param {Object} obj Target Object + * @param {string} prop prop strong + * @param {Object} descriptor + */ +function autobind(obj, prop, descriptor) { + if (arguments.length === 1) return autobindClass()(obj); + + var _ref = descriptor || {}, + fn = _ref.value, + configurable = _ref.configurable; + + if (!isFunction(fn)) { + throw new TypeError('@autobind can only be used on functions, not "' + fn + '" in ' + (typeof fn === 'undefined' ? 'undefined' : _typeof(fn)) + ' on property "' + prop + '"'); + } + var constructor = obj.constructor; + + return { + configurable: configurable, + enumerable: false, + get: function get() { + var _this = this; + + var boundFn = function boundFn() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return fn.call.apply(fn, [_this].concat(_toConsumableArray(args))); + }; + // Someone accesses the property directly on the prototype on which it is + // actually defined on, i.e. Class.prototype.hasOwnProperty(key) + if (this === obj) { + return fn; + } + // Someone accesses the property directly on a prototype, + // but it was found up the chain, not defined directly on it + // i.e. Class.prototype.hasOwnProperty(key) == false && key in Class.prototype + if (this.constructor !== constructor && _Object$getPrototypeOf(this).constructor === constructor) { + return fn; + } + + // Autobound method calling super.sameMethod() which is also autobound and so on. + if (this.constructor !== constructor && prop in this.constructor.prototype) { + return getBoundSuper(this, fn); + } + _Object$defineProperty(this, prop, { + configurable: true, + writable: true, + // NOT enumerable when it's a bound method + enumerable: false, + value: boundFn + }); + + return boundFn; + }, + + set: createDefaultSetter(prop) + }; +} + +var defineProperty$2$1 = _Object$defineProperty; +/** + * make one attr only can be read, but could not be rewrited/ deleted + * @param {Object} obj + * @param {string} prop + * @param {Object} descriptor + * @return {descriptor} + */ + +function frozen(obj, prop, descriptor) { + if (descriptor === undefined) { + /* istanbul ignore else */ + warn('You are using @frozen on an undefined property. This property will become a frozen undefined forever, which is meaningless'); + return { + value: undefined, + writable: false, + enumerable: false, + configurable: false + }; + } + descriptor.enumerable = false; + descriptor.configurable = false; + if (isAccessorDescriptor(descriptor)) { + var _get = descriptor.get; + + descriptor.set = undefined; + if (!isFunction(_get)) { + /* istanbul ignore else */ + warn('You are using @frozen on one accessor descriptor without getter. This property will become a frozen undefined finally.Which maybe meaningless.'); + return; + } + return { + get: function get() { + var value = bind$1(_get, this)(); + defineProperty$2$1(this, prop, { + value: value, + writable: false, + configurable: false, + enumerable: false + }); + return value; + }, + + set: undefined, + configurable: false, + enumerable: false + }; + } + // $FlowFixMe: comeon, can disjoint union be reliable? + descriptor.writable = false; + return descriptor; +} + +var getOwnPropertyDescriptor$2$1 = _Object$getOwnPropertyDescriptor; +var defineProperty$3$1 = _Object$defineProperty; + +function waituntil(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other; + + if (!isFunction(key) && !isPromise(key) && !isString(key)) throw new TypeError('@waitUntil only accept Function, Promise or String'); + return function (obj, prop, descriptor) { + var _ref2 = descriptor || {}, + _value = _ref2.value, + configurable = _ref2.configurable; + + if (!isFunction(_value)) throw new TypeError('@waituntil can only be used on function, but not ' + _value + ' on property "' + prop + '"'); + var binded = false; + var waitingQueue = []; + var canIRun = isPromise(key) ? function () { + return key; + } : isFunction(key) ? key : function () { + // $FlowFixMe: We have use isPromise to exclude + var keys = key.split('.'); + var prop = keys.slice(-1); + var originTarget = isPrimitive(other) ? this : other; + if (!binded) { + var target = getDeepProperty$1(originTarget, keys.slice(0, -1)); + if (isVoid(target)) return target; + var _descriptor = getOwnPropertyDescriptor$2$1(target, prop); + /** + * create a setter hook here + * when it get ture, it will run all function in waiting queue immediately + */ + var set = function set(value) { + if (value === true) { + while (waitingQueue.length > 0) { + waitingQueue[0](); + waitingQueue.shift(); + } + } + return value; + }; + var desc = isDescriptor(_descriptor) ? accessor({ set: set })(target, prop, _descriptor) : accessor({ set: set })(target, prop, { + value: undefined, + configurable: true, + enumerable: true, + writable: true + }); + defineProperty$3$1(target, prop, desc); + binded = true; + } + return getDeepProperty$1(originTarget, keys); + }; + return { + value: function value() { + var _this = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var boundFn = bind$1(_value, this); + var runnable = bind$1(canIRun, this).apply(undefined, args); + if (isPromise(runnable)) { + return _Promise.resolve(runnable).then(function () { + return bind$1(_value, _this).apply(undefined, args); + }); + } else if (runnable === true) { + return bind$1(_value, this).apply(undefined, args); + } else { + return new _Promise(function (resolve) { + var cb = function cb() { + boundFn.apply(undefined, args); + resolve(); + }; + waitingQueue.push(cb); + }); + } + }, + + // function should not be enmuerable + enumerable: false, + configurable: configurable, + // as we have delay this function + // it's not a good idea to change it + writable: false + }; + }; +} + +function nonenumerable(obj, prop, descriptor) { + if (descriptor === undefined) { + return { + value: undefined, + enumerable: false, + configurable: true, + writable: true + }; + } + descriptor.enumerable = false; + return descriptor; +} + +var defineProperty$6 = _Object$defineProperty; +var getOwnPropertyDescriptor$3 = _Object$getOwnPropertyDescriptor; + + +function applyDecorators(Class, props) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref$self = _ref.self, + self = _ref$self === undefined ? false : _ref$self, + _ref$omit = _ref.omit, + omit = _ref$omit === undefined ? false : _ref$omit; + + var isPropsFunction = isFunction(props); + if (isPropsFunction || isArray(props)) { + // apply decorators on class + if (!isFunction(Class)) throw new TypeError('If you want to decorator class, you must pass it a legal class'); + // $FlowFixMe: Terrible union, it's function now + if (isPropsFunction) props(Class);else { + // $FlowFixMe: Terrible union, it's array now + for (var i = 0, len = props.length; i < len; i++) { + // $FlowFixMe: Terrible union, it's array now + var fn = props[i]; + if (!isFunction(fn)) throw new TypeError('If you want to decorate an class, you must pass it function or array of function'); + fn(Class); + } + } + return Class; + } + if (!self && !isFunction(Class)) throw new TypeError('applyDecorators only accept class as first arguments. If you want to modify instance, you should set options.self true.'); + if (self && isPrimitive(Class)) throw new TypeError("We can't apply docorators on a primitive value, even in self mode"); + if (!isObject(props)) throw new TypeError('applyDecorators only accept object as second arguments'); + var prototype = self ? Class : Class.prototype; + if (isVoid(prototype)) throw new Error('The class muse have a prototype, please take a check'); + for (var key in props) { + var value = props[key]; + var decorators = isArray(value) ? value : [value]; + var handler = void 0; + try { + handler = compressMultipleDecorators.apply(undefined, _toConsumableArray(decorators)); + } catch (err) { + /* istanbul ignore else */ + warn(err && err.message); + throw new Error('The decorators set on props must be Function or Array of Function'); + } + var descriptor = getOwnPropertyDescriptor$3(prototype, key); + if (descriptor && !descriptor.configurable) { + if (!omit) throw new Error(key + ' of ' + prototype + ' is unconfigurable'); + continue; + } + defineProperty$6(prototype, key, handler(prototype, key, descriptor)); + } + return Class; +} + +var arrayChangeMethod = ['push', 'pop', 'unshift', 'shift', 'splice', 'sort', 'reverse']; + +function deepProxy(value, hook, _ref) { + var _operateProps; + + var diff = _ref.diff, + operationPrefix = _ref.operationPrefix; + + var mapStore = {}; + var arrayChanging = false; + var proxyValue = new Proxy(value, { + get: function get(target, property, receiver) { + var value = target[property]; + if (isArray(target) && arrayChangeMethod.indexOf(property) > -1) { + return function () { + arrayChanging = true; + bind$1(value, receiver).apply(undefined, arguments); + arrayChanging = false; + hook(); + }; + } + if (mapStore[property] === true) return value; + if (isObject(value) || isArray(value)) { + var _proxyValue = mapStore[property] || deepProxy(value, hook, { diff: diff, operationPrefix: operationPrefix }); + mapStore[property] = _proxyValue; + return _proxyValue; + } + mapStore[property] = true; + return value; + }, + set: function set(target, property, value) { + var oldVal = target[property]; + var newVal = isObject(value) || isArray(value) ? deepProxy(value, hook, { diff: diff, operationPrefix: operationPrefix }) : value; + target[property] = newVal; + mapStore[property] = true; + if (arrayChanging || diff && oldVal === newVal) return true; + hook(); + return true; + }, + deleteProperty: function deleteProperty(target, property) { + delete target[property]; + delete mapStore[property]; + if (arrayChanging) return true; + hook(); + return true; + } + }); + var operateProps = (_operateProps = {}, _defineProperty(_operateProps, operationPrefix + 'set', [initialize(function (method) { + return function (property, val) { + // $FlowFixMe: we have check the computed value + proxyValue[property] = val; + }; + }), nonenumerable]), _defineProperty(_operateProps, operationPrefix + 'del', [initialize(function (method) { + return function (property) { + // $FlowFixMe: we have check the computed value + delete proxyValue[property]; + }; + }), nonenumerable]), _operateProps); + applyDecorators(proxyValue, operateProps, { self: true }); + return proxyValue; +} + +function deepObserve(value, hook, _ref2) { + var _this = this, + _operateProps2; + + var operationPrefix = _ref2.operationPrefix, + diff = _ref2.diff; + + var mapStore = {}; + var arrayChanging = false; + function getPropertyDecorators(keys) { + var oldVal = void 0; + return keys.reduce(function (props, key) { + props[key] = [accessor({ + set: function set(value) { + oldVal = this[key]; + return value; + } + }), accessor({ + get: function get(val) { + if (mapStore[key]) return val; + if (isObject(val) || isArray(val)) { + deepObserve(val, hook, { operationPrefix: operationPrefix, diff: diff }); + } + mapStore[key] = true; + return val; + }, + set: function set(val) { + if (isObject(val) || isArray(val)) deepObserve(val, hook, { operationPrefix: operationPrefix, diff: diff }); + mapStore[key] = true; + if (!arrayChanging && (!diff || oldVal !== val)) hook(); + return val; + } + }, { preSet: false })]; + return props; + }, {}); + } + var props = getPropertyDecorators(getOwnKeys(value)); + applyDecorators(value, props, { self: true, omit: true }); + if (isArray(value)) { + var methodProps = arrayChangeMethod.reduce(function (props, key) { + props[key] = [initialize(function (method) { + method = isFunction(method) ? method + // $FlowFixMe: we have check the key + : Array.prototype[key]; + return function () { + var originLength = value.length; + arrayChanging = true; + bind$1(method, value).apply(undefined, arguments); + arrayChanging = false; + if (originLength < value.length) { + var keys = new Array(value.length - originLength).fill(1).map(function (value, index) { + return (index + originLength).toString(); + }); + var _props = getPropertyDecorators(keys); + applyDecorators(value, _props, { self: true, omit: true }); + } + hook(); + }; + }), nonenumerable]; + return props; + }, {}); + applyDecorators(value, methodProps, { self: true }); + } + var operateProps = (_operateProps2 = {}, _defineProperty(_operateProps2, operationPrefix + 'set', [initialize(function (method) { + return function (property, val) { + var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + disable = _ref3.disable, + isNewVal = _ref3.isNewVal; + + isNewVal = isNewVal || getOwnKeys(value).indexOf(property) === -1; + if (isFunction(method)) { + bind$1(method, _this)(property, val, { disable: true, isNewVal: isNewVal }); + } + if (isNewVal) { + var _props2 = getPropertyDecorators([property]); + applyDecorators(value, _props2, { self: true, omit: true }); + } + if (!disable) { + value[property] = val; + } + }; + }), nonenumerable]), _defineProperty(_operateProps2, operationPrefix + 'del', [initialize(function (method) { + return function (property) { + if (isFunction(method)) { + bind$1(method, _this)(property); + } else { + delete value[property]; + } + hook(); + }; + }), nonenumerable]), _operateProps2); + applyDecorators(value, operateProps, { self: true }); + return value; +} + +function watch() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var option = isObject(args[args.length - 1]) ? args[args.length - 1] : {}; + // $FlowFixMe: we have check if it's an object + var deep = option.deep, + omit = option.omit, + other = option.other, + _option$operationPref = option.operationPrefix, + operationPrefix = _option$operationPref === undefined ? '__' : _option$operationPref, + _option$diff = option.diff, + diff = _option$diff === undefined ? true : _option$diff; + // $FlowFixMe: we have check if it's an object + + var proxy = option.proxy; + + if (typeof Proxy !== 'function') { + proxy = false; + /* istanbul ignore else */ + warn('You browser do not support Proxy, we will fall back into observe mode.'); + } + if (!args.length) throw new TypeError('You must pass a function or a string to find the hanlder function.'); + if (other !== undefined && isPrimitive(other)) throw new TypeError('If you want us to trigger function on the other instance, you must pass in a legal instance'); + if (!isString(operationPrefix)) throw new TypeError('operationPrefix must be an string'); + return function (obj, prop, descriptor) { + var fns = args.reduce(function (fns, keyOrFn, index) { + if (!isString(keyOrFn) && !isFunction(keyOrFn)) { + if (!index || index !== args.length - 1) throw new TypeError('You can only pass function or string as handler'); + return fns; + } + fns.push(isString(keyOrFn) ? function (newVal, oldVal) { + var target = other || obj; + // $FlowFixMe: we have ensure it must be a string + var fn = getDeepProperty$1(target, keyOrFn); + if (!isFunction(fn)) { + if (!omit) throw new Error('You pass in a function for us to trigger, please ensure the property to be a function or set omit flag true'); + return; + } + return bind$1(fn, this)(newVal, oldVal); + } : keyOrFn); + return fns; + }, []); + var handler = function handler(newVal, oldVal) { + var _this2 = this; + + fns.forEach(function (fn) { + return bind$1(fn, _this2)(newVal, oldVal); + }); + }; + var inited = false; + var oldVal = void 0; + var newVal = void 0; + var proxyValue = void 0; + return compressMultipleDecorators(accessor({ + set: function set(value) { + var _this3 = this; + + oldVal = this[prop]; + proxyValue = undefined; + var hook = function hook() { + return bind$1(handler, _this3)(newVal, oldVal); + }; + return deep && (isObject(value) || isArray(value)) ? proxy ? deepProxy(value, hook, { diff: diff, operationPrefix: operationPrefix }) : deepObserve(value, hook, { operationPrefix: operationPrefix, diff: diff }) : value; + }, + get: function get(value) { + var _this4 = this; + + if (proxyValue) return proxyValue; + if (!inited) { + inited = true; + var hook = function hook() { + return bind$1(handler, _this4)(newVal, oldVal); + }; + if (deep && (isObject(value) || isArray(value))) { + if (proxy) { + proxyValue = deepProxy(value, hook, { diff: diff, operationPrefix: operationPrefix }); + oldVal = proxyValue; + newVal = proxyValue; + return proxyValue; + } + deepObserve(value, hook, { operationPrefix: operationPrefix, diff: diff }); + } + oldVal = value; + newVal = value; + } + return value; + } + }, { preSet: true }), accessor({ + set: function set(value) { + newVal = value; + if (!diff || oldVal !== value) bind$1(handler, this)(newVal, oldVal); + oldVal = value; + return value; + } + }, { preSet: false }))(obj, prop, descriptor); + }; +} + +function runnable(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other, + backup = _ref.backup; + + if (!isFunction(key) && !isString(key)) throw new TypeError('@runnable only accept Function or String'); + return function (obj, prop, descriptor) { + var _ref2 = descriptor || {}, + _value = _ref2.value, + configurable = _ref2.configurable; + + if (!isFunction(_value)) throw new TypeError('@runnable can only be used on method, but not ' + _value + ' on property "' + prop + '".'); + var canIRun = isFunction(key) ? key : function () { + var keys = key.split('.'); + var originTarget = isPrimitive(other) ? this : other; + return getDeepProperty$1(originTarget, keys); + }; + backup = isFunction(backup) ? backup : function () {}; + return { + value: function value() { + if (bind$1(canIRun, this).apply(undefined, arguments) === true) { + return bind$1(_value, this).apply(undefined, arguments); + } else { + // $FlowFixMe: I have reassign it when it's not a function + return bind$1(backup, this).apply(undefined, arguments); + } + }, + + // function should not be enmuerable + enumerable: false, + configurable: configurable, + // as we have delay this function + // it's not a good idea to change it + writable: false + }; + }; +} + +function nonconfigurable(obj, prop, descriptor) { + if (descriptor === undefined) { + return { + value: undefined, + enumerable: true, + configurable: true, + writable: true + }; + } + descriptor.configurable = true; + return descriptor; +} + +function string() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var defaultValue = isString(args[0]) ? args.shift() : ''; + args.unshift(function (value) { + return isString(value) ? value : defaultValue; + }); + return initialize.apply(undefined, args); +} + +function boolean() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var defaultValue = isBoolean(args[0]) ? args.shift() : false; + args.unshift(function (value) { + return isBoolean(value) ? value : defaultValue; + }); + return initialize.apply(undefined, args); +} + +function string$1() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var defaultValue = isString(args[0]) ? args.shift() : ''; + args.unshift(function (value) { + return isString(value) ? value : defaultValue; + }); + return accessor({ set: args, get: args }); +} + +function boolean$1() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var defaultValue = isBoolean(args[0]) ? args.shift() : false; + args.unshift(function (value) { + return isBoolean(value) ? value : defaultValue; + }); + return accessor({ set: args, get: args }); +} + +function number$1() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var defaultValue = isNumber(args[0]) ? args.shift() : 0; + args.unshift(function (value) { + return isNumber(value) ? value : defaultValue; + }); + return accessor({ set: args, get: args }); +} + +var $JSON$1 = _core.JSON || (_core.JSON = { stringify: JSON.stringify }); +var stringify = function stringify(it) { // eslint-disable-line no-unused-vars + return $JSON$1.stringify.apply($JSON$1, arguments); +}; + +var stringify$1 = createCommonjsModule(function (module) { +module.exports = { "default": stringify, __esModule: true }; +}); + +var _JSON$stringify = unwrapExports(stringify$1); + +var videoEvents = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'interruptbegin', 'interruptend', 'loadeddata', 'loadedmetadata', 'loadstart', 'mozaudioavailable', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting']; +var videoReadOnlyProperties = ['buffered', 'currentSrc', 'duration', 'error', 'ended', 'networkState', 'paused', 'readyState', 'seekable', 'sinkId', 'controlsList', 'tabIndex', 'dataset', 'offsetHeight', 'offsetLeft', 'offsetParent', 'offsetTop', 'offsetWidth']; +var domEvents = ['beforeinput', 'blur', 'click', 'compositionend', 'compositionstart', 'compositionupdate', 'dblclick', 'focus', 'focusin', 'focusout', 'input', 'keydown', 'keypress', 'keyup', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'wheel', 'mousewheel', 'contextmenu', 'touchstart', 'touchmove', 'touchend', 'fullscreen']; +var esFullscreenEvents = ['fullscreenchange']; +var passiveEvents = ['wheel', 'mousewheel', 'touchstart', 'touchmove']; +var selfProcessorEvents = ['silentLoad', 'fullscreen']; +var mustListenVideoDomEvents = ['mouseenter', 'mouseleave']; +var kernelMethods = ['play', 'pause', 'seek', 'startLoad', 'stopLoad']; +var dispatcherMethods = ['load']; +var kernelEvents = ['mediaInfo', 'heartbeat', 'error']; +var domMethods = ['focus', 'fullscreen', 'requestFullscreen', 'exitFullscreen']; +var videoMethods = ['canPlayType', 'captureStream', 'setSinkId']; + +/** + * checker for on, off, once function + * @param {string} key + * @param {Function} fn + */ +function eventBinderCheck(key, fn) { + if (!isString(key)) throw new TypeError('key parameter must be String'); + if (!isFunction(fn)) throw new TypeError('fn parameter must be Function'); +} +/** + * checker for attr or css function + */ +function attrAndStyleCheck() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length > 2) { + return ['set'].concat(args); + } + if (args.length === 2) { + if (['video', 'container', 'wrapper', 'videoElement'].indexOf(args[0]) > -1) { + return ['get'].concat(args); + } + return ['set', 'container'].concat(args); + } + return ['get', 'container'].concat(args); +} + +// 20.1.2.4 Number.isNaN(number) + + +_export(_export.S, 'Number', { + isNaN: function isNaN(number) { + // eslint-disable-next-line no-self-compare + return number != number; + } +}); + +var isNan = _core.Number.isNaN; + +var isNan$1 = createCommonjsModule(function (module) { +module.exports = { "default": isNan, __esModule: true }; +}); + +var _Number$isNaN = unwrapExports(isNan$1); + +var _dec, _dec2, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; + +function _initDefineProp(target, property, descriptor, context) { + if (!descriptor) return; + + _Object$defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} + +function stringOrVoid(value) { + return isString(value) ? value : undefined; +} + +function accessorVideoProperty(property) { + return accessor({ + get: function get(value) { + return this.dispatcher.videoConfigReady && this.inited ? this.dom.videoElement[property] : value; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + this.dom.videoElement[property] = value; + return value; + } + }); +} + +function accessorVideoAttribute(attribute) { + var _ref = isObject(attribute) ? attribute : { + set: attribute, + get: attribute, + isBoolean: false + }, + _set = _ref.set, + _get = _ref.get, + isBoolean$$1 = _ref.isBoolean; + + return accessor({ + get: function get(value) { + return this.dispatcher.videoConfigReady && this.inited ? this.dom.videoElement[_get] : value; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + var val = isBoolean$$1 ? value ? '' : undefined + /* istanbul ignore next */ + : value === null ? undefined : value; + this.dom.setAttr('video', _set, val); + return value; + } + }, { + preSet: false + }); +} + +function accessorCustomAttribute(attribute, isBoolean$$1) { + return accessor({ + get: function get(value) { + var attrValue = this.dom.getAttr('video', attribute); + return this.dispatcher.videoConfigReady && this.inited ? isBoolean$$1 ? !!attrValue : attrValue : value; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + var val = isBoolean$$1 ? value || undefined : value === null ? undefined : value; + this.dom.setAttr('video', attribute, val); + return value; + } + }); +} + +function accessorWidthAndHeight(property) { + return accessor({ + get: function get(value) { + if (!this.dispatcher.videoConfigReady || !this.inited) return value; + var attr = this.dom.getAttr('video', property); + var prop = this.dom.videoElement[property]; + if (isNumeric(attr) && isNumber(prop)) return prop; + return attr || undefined; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + var val = void 0; + if (value === undefined || isNumber(value)) { + val = value; + } else if (isString(value) && !_Number$isNaN(parseFloat(value))) { + val = value; + } + this.dom.setAttr('video', property, val); + return val; + } + }); +} + +var accessorMap = { + src: [string$1(), accessor({ + set: function set(val) { + // must check val !== this.src here + // as we will set config.src in the video + // the may cause dead lock + if (this.dispatcher.readySync && this.autoload && val !== this.src) this.needToLoadSrc = true; + return val; + } + }), accessor({ + set: function set(val) { + if (this.needToLoadSrc) { + // unlock it at first, to avoid deadlock + this.needToLoadSrc = false; + this.dispatcher.binder.emit({ + name: 'load', + target: 'plugin', + id: 'dispatcher' + }, val); + } + return val; + } + }, { preSet: false })], + autoload: boolean$1(), + autoplay: [boolean$1(), accessorVideoProperty('autoplay')], + controls: [boolean$1(), accessorVideoProperty('controls')], + width: [accessorWidthAndHeight('width')], + height: [accessorWidthAndHeight('height')], + crossOrigin: [accessor({ set: stringOrVoid }), accessorVideoAttribute({ set: 'crossorigin', get: 'crossOrigin' })], + loop: [boolean$1(), accessorVideoProperty('loop')], + defaultMuted: [boolean$1(), accessorVideoAttribute({ get: 'defaultMuted', set: 'muted', isBoolean: true })], + muted: [boolean$1(), accessorVideoProperty('muted')], + preload: [accessor({ + set: function set(value) { + var options = ['none', 'auto', 'metadata', '']; + return options.indexOf(value) > -1 ? value : 'none'; + } + }, { + preSet: true + }), accessorVideoAttribute('preload')], + poster: [ + // 因为如果在 video 上随便加一个字符串,他会将其拼接到地址上,所以这里要避免 + // 单元测试无法检测 + string$1(), accessor({ + get: function get(value) { + return this.dispatcher.videoConfigReady && this.inited ? this.dom.videoElement.poster : value; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + if (value.length) this.dom.setAttr('video', 'poster', value); + return value; + } + })], + playsInline: [accessor({ + get: function get(value) { + var playsInline = this.dom.videoElement.playsInline; + return this.dispatcher.videoConfigReady && this.inited ? playsInline === undefined ? value : playsInline : value; + }, + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + this.dom.videoElement.playsInline = value; + var val = value ? '' : undefined; + this.dom.setAttr('video', 'playsinline', val); + this.dom.setAttr('video', 'webkit-playsinline', val); + this.dom.setAttr('video', 'x5-playsinline', val); + return value; + } + }), boolean$1()], + x5VideoPlayerFullscreen: [accessor({ + set: function set(value) { + return !!value; + }, + get: function get(value) { + return !!value; + } + }), accessorCustomAttribute('x5-video-player-fullscreen', true)], + x5VideoOrientation: [accessor({ set: stringOrVoid }), accessorCustomAttribute('x5-video-orientation')], + x5VideoPlayerType: [accessor({ + set: function set(value) { + if (!this.dispatcher.videoConfigReady) return value; + var val = value === 'h5' ? 'h5' : undefined; + this.dom.setAttr('video', 'x5-video-player-type', val); + return value; + }, + get: function get(value) { + return this.dispatcher.videoConfigReady && value || (this.dom.getAttr('video', 'x5-video-player-type') ? 'h5' : undefined); + } + })], + xWebkitAirplay: [accessor({ + set: function set(value) { + return !!value; + }, + get: function get(value) { + return !!value; + } + }), accessorCustomAttribute('x-webkit-airplay', true)], + playbackRate: [number$1(1), accessorVideoProperty('playbackRate')], + defaultPlaybackRate: [accessorVideoProperty('defaultPlaybackRate'), number$1(1)], + disableRemotePlayback: [boolean$1(), accessorVideoProperty('disableRemotePlayback')], + volume: [number$1(1), accessorVideoProperty('volume')] +}; + +var VideoConfig = (_dec = boolean(), _dec2 = string(function (str) { + return str.toLocaleLowerCase(); +}), (_class = function () { + + // 转为供 kernel 使用的内部参数 + function VideoConfig(dispatcher, config) { + _classCallCheck(this, VideoConfig); + + _initDefineProp(this, 'needToLoadSrc', _descriptor, this); + + _initDefineProp(this, 'changeWatchable', _descriptor2, this); + + _initDefineProp(this, 'inited', _descriptor3, this); + + this.src = ''; + + _initDefineProp(this, 'isLive', _descriptor4, this); + + _initDefineProp(this, 'box', _descriptor5, this); + + this.preset = {}; + this.presetConfig = {}; + this.autoload = true; + this.autoplay = false; + this.controls = false; + this.width = '100%'; + this.height = '100%'; + this.crossOrigin = undefined; + this.loop = false; + this.defaultMuted = false; + this.muted = false; + this.preload = 'auto'; + this.poster = undefined; + this.playsInline = false; + this.x5VideoPlayerFullscreen = false; + this.x5VideoOrientation = undefined; + this.x5VideoPlayerType = undefined; + this.xWebkitAirplay = false; + this.playbackRate = 1; + this.defaultPlaybackRate = 1; + this.disableRemotePlayback = false; + this.volume = 1; + + _initDefineProp(this, '_kernelProperty', _descriptor6, this); + + _initDefineProp(this, '_realDomAttr', _descriptor7, this); + + applyDecorators(this, accessorMap, { self: true }); + Object.defineProperty(this, 'dispatcher', { + value: dispatcher, + enumerable: false, + writable: false, + configurable: false + }); + Object.defineProperty(this, 'dom', { + value: dispatcher.dom, + enumerable: false, + writable: false, + configurable: false + }); + deepAssign(this, config); + } + + // 此处 box 只能置空,因为 kernel 会自动根据你的安装 kernel 和相关地址作智能判断。 + // 曾经 bug 详见 https://github.com/Chimeejs/chimee-kernel/issues/1 + + // kernels 不在 videoConfig 上设置默认值,防止判断出错 + + + _createClass(VideoConfig, [{ + key: 'init', + value: function init() { + var _this = this; + + this._realDomAttr.forEach(function (key) { + // $FlowFixMe: we have check the computed here + _this[key] = _this[key]; + }); + this.inited = true; + } + }]); + + return VideoConfig; +}(), (_descriptor = _applyDecoratedDescriptor(_class.prototype, 'needToLoadSrc', [nonenumerable], { + enumerable: true, + initializer: function initializer() { + return false; + } +}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, 'changeWatchable', [nonenumerable], { + enumerable: true, + initializer: function initializer() { + return true; + } +}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, 'inited', [nonenumerable], { + enumerable: true, + initializer: function initializer() { + return false; + } +}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, 'isLive', [_dec, nonconfigurable], { + enumerable: true, + initializer: function initializer() { + return false; + } +}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, 'box', [_dec2, nonconfigurable], { + enumerable: true, + initializer: function initializer() { + return ''; + } +}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, '_kernelProperty', [frozen], { + enumerable: true, + initializer: function initializer() { + return ['isLive', 'box', 'preset', 'kernels', 'presetConfig']; + } +}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, '_realDomAttr', [frozen], { + enumerable: true, + initializer: function initializer() { + return ['src', 'controls', 'width', 'height', 'crossOrigin', 'loop', 'muted', 'preload', 'poster', 'autoplay', 'playsInline', 'x5VideoPlayerFullscreen', 'x5VideoOrientation', 'xWebkitAirplay', 'playbackRate', 'defaultPlaybackRate', 'autoload', 'disableRemotePlayback', 'defaultMuted', 'volume', 'x5VideoPlayerType']; + } +})), _class)); + +var _dec$1, _dec2$1, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _class$1, _class2; + +function _applyDecoratedDescriptor$1(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +var VideoWrapper = (_dec$1 = autobindClass(), _dec2$1 = alias('silentLoad'), _dec3 = alias('fullScreen'), _dec4 = alias('$fullScreen'), _dec5 = alias('fullscreen'), _dec6 = alias('emit'), _dec7 = alias('emitSync'), _dec8 = alias('on'), _dec9 = alias('addEventListener'), _dec10 = before(eventBinderCheck), _dec11 = alias('off'), _dec12 = alias('removeEventListener'), _dec13 = before(eventBinderCheck), _dec14 = alias('once'), _dec15 = before(eventBinderCheck), _dec16 = alias('css'), _dec17 = before(attrAndStyleCheck), _dec18 = alias('attr'), _dec19 = before(attrAndStyleCheck), _dec$1(_class$1 = (_class2 = function () { + function VideoWrapper() { + _classCallCheck(this, VideoWrapper); + + this.__events = {}; + this.__unwatchHandlers = []; + } + + _createClass(VideoWrapper, [{ + key: '__wrapAsVideo', + value: function __wrapAsVideo(videoConfig) { + var _this = this; + + // bind video read only properties on instance, so that you can get info like buffered + videoReadOnlyProperties.forEach(function (key) { + _Object$defineProperty(_this, key, { + get: function get() { + return this.__dispatcher.dom.videoElement[key]; + }, + + set: undefined, + configurable: false, + enumerable: false + }); + }); + // bind videoMethods like canplaytype on instance + videoMethods.forEach(function (key) { + _Object$defineProperty(_this, key, { + get: function get() { + var video = this.__dispatcher.dom.videoElement; + return bind(video[key], video); + }, + + set: undefined, + configurable: false, + enumerable: false + }); + }); + // bind video config properties on instance, so that you can just set src by this + var props = videoConfig._realDomAttr.concat(videoConfig._kernelProperty).reduce(function (props, key) { + props[key] = [accessor({ + get: function get() { + // $FlowFixMe: support computed key here + return videoConfig[key]; + }, + set: function set(value) { + // $FlowFixMe: support computed key here + videoConfig[key] = value; + return value; + } + }), nonenumerable]; + return props; + }, {}); + applyDecorators(this, props, { self: true }); + kernelMethods.forEach(function (key) { + _Object$defineProperty(_this, key, { + value: function value() { + var _this2 = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return new _Promise(function (resolve) { + var _dispatcher$binder; + + var id = _this2.__id; + _this2.__dispatcher.binder.once({ + id: id, + name: '_' + key, + fn: resolve + }); + (_dispatcher$binder = _this2.__dispatcher.binder)[/^(seek)$/.test(key) ? 'emitSync' : 'emit'].apply(_dispatcher$binder, [{ + target: 'video', + name: key, + id: id + }].concat(_toConsumableArray(args))); + }); + }, + + configurable: true, + enumerable: false, + writable: true + }); + }); + domMethods.forEach(function (key) { + if (key === 'fullscreen') return; + _Object$defineProperty(_this, key, { + value: function value() { + var _dispatcher$dom; + + return (_dispatcher$dom = this.__dispatcher.dom)[key].apply(_dispatcher$dom, arguments); + }, + + configurable: true, + enumerable: false, + writable: true + }); + }); + } + }, { + key: '$watch', + value: function $watch(key, handler) { + var _this3 = this; + + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + deep = _ref.deep, + _ref$diff = _ref.diff, + diff = _ref$diff === undefined ? true : _ref$diff, + other = _ref.other, + _ref$proxy = _ref.proxy, + proxy = _ref$proxy === undefined ? false : _ref$proxy; + + if (!isString(key) && !isArray(key)) throw new TypeError('$watch only accept string and Array as key to find the target to spy on, but not ' + key + ', whose type is ' + (typeof key === 'undefined' ? 'undefined' : _typeof(key))); + var watching = true; + var watcher = function watcher() { + if (watching && (!(this instanceof VideoConfig) || this.dispatcher.changeWatchable)) bind(handler, this).apply(undefined, arguments); + }; + var unwatcher = function unwatcher() { + watching = false; + var index = _this3.__unwatchHandlers.indexOf(unwatcher); + if (index > -1) _this3.__unwatchHandlers.splice(index, 1); + }; + var keys = isString(key) ? key.split('.') : key; + var property = keys.pop(); + var videoConfig = this.__dispatcher.videoConfig; + var target = keys.length === 0 && !other && videoConfig._realDomAttr.indexOf(property) > -1 ? videoConfig : ['isFullscreen', 'fullscreenElement'].indexOf(property) > -1 ? this.__dispatcher.dom : getDeepProperty(other || this, keys, { throwError: true }); + applyDecorators(target, _defineProperty({}, property, watch(watcher, { deep: deep, diff: diff, proxy: proxy })), { self: true }); + this.__unwatchHandlers.push(unwatcher); + return unwatcher; + } + }, { + key: '$set', + value: function $set(obj, property, value) { + if (!isObject(obj) && !isArray(obj)) throw new TypeError('$set only support Array or Object, but not ' + obj + ', whose type is ' + (typeof obj === 'undefined' ? 'undefined' : _typeof(obj))); + // $FlowFixMe: we have custom this function + if (!isFunction(obj.__set)) { + /* istanbul ignore else */ + Log.warn('chimee', _JSON$stringify(obj) + ' has not been deep watch. There is no need to use $set.'); + // $FlowFixMe: we support computed string on array here + obj[property] = value; + return; + } + obj.__set(property, value); + } + }, { + key: '$del', + value: function $del(obj, property) { + if (!isObject(obj) && !isArray(obj)) throw new TypeError('$del only support Array or Object, but not ' + obj + ', whose type is ' + (typeof obj === 'undefined' ? 'undefined' : _typeof(obj))); + // $FlowFixMe: we have custom this function + if (!isFunction(obj.__del)) { + /* istanbul ignore else */ + Log.warn('chimee', _JSON$stringify(obj) + ' has not been deep watch. There is no need to use $del.'); + // $FlowFixMe: we support computed string on array here + delete obj[property]; + return; + } + obj.__del(property); + } + }, { + key: 'load', + value: function load() { + var _this4 = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return new _Promise(function (resolve) { + var _dispatcher$binder2; + + _this4.__dispatcher.binder.once({ + id: _this4.__id, + name: '_load', + target: 'plugin', + fn: resolve + }); + (_dispatcher$binder2 = _this4.__dispatcher.binder).emit.apply(_dispatcher$binder2, [{ + name: 'load', + target: 'plugin', + id: _this4.__id + }].concat(args)); + }); + } + }, { + key: '$silentLoad', + value: function $silentLoad() { + var _this5 = this; + + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + return this.__dispatcher.binder.emit({ + name: 'silentLoad', + target: 'video', + id: this.__id + }).then(function () { + var _dispatcher; + + return (_dispatcher = _this5.__dispatcher).silentLoad.apply(_dispatcher, args); + }).then(function (result) { + _this5.__dispatcher.binder.trigger({ + name: 'silentLoad', + target: 'video', + id: _this5.__id + }, result); + }); + } + + /** + * call fullscreen api on some specific element + * @param {boolean} flag true means fullscreen and means exit fullscreen + * @param {string} element the element you want to fullscreen, default it's container, you can choose from video | container | wrapper + */ + + }, { + key: '$fullscreen', + value: function $fullscreen() { + var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'container'; + + if (!this.__dispatcher.binder.emitSync({ + name: 'fullscreen', + id: this.__id, + target: 'video-dom' + }, flag, element)) return false; + var result = this.__dispatcher.dom.fullscreen(flag, element); + this.__dispatcher.binder.triggerSync({ + name: 'fullscreen', + id: this.__id, + target: 'video-dom' + }, flag, element); + return result; + } + + /** + * emit an event + * @param {string} key event's name + * @param {...args} args + */ + + }, { + key: '$emit', + value: function $emit(key) { + var _dispatcher$binder3; + + var target = void 0; + if (isObject(key) && isString(key.name) && isString(key.target)) { + target = key.target; + key = key.name; + } + if (!isString(key)) throw new TypeError('emit key parameter must be String'); + /* istanbul ignore else */ + if (domEvents.indexOf(key.replace(/^\w_/, '')) > -1) { + Log.warn('plugin', 'You are try to emit ' + key + ' event. As emit is wrapped in Promise. It make you can\'t use event.preventDefault and event.stopPropagation. So we advice you to use emitSync'); + } + + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + return (_dispatcher$binder3 = this.__dispatcher.binder).emit.apply(_dispatcher$binder3, [{ + name: key, + id: this.__id, + target: target + }].concat(_toConsumableArray(args))); + } + + /** + * emit a sync event + * @param {string} key event's name + * @param {...args} args + */ + + }, { + key: '$emitSync', + value: function $emitSync(key) { + var _dispatcher$binder4; + + var target = void 0; + if (isObject(key) && isString(key.name) && isString(key.target)) { + target = key.target; + key = key.name; + } + if (!isString(key)) throw new TypeError('emitSync key parameter must be String'); + + for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { + args[_key5 - 1] = arguments[_key5]; + } + + return (_dispatcher$binder4 = this.__dispatcher.binder).emitSync.apply(_dispatcher$binder4, [{ + name: key, + id: this.__id, + target: target + }].concat(_toConsumableArray(args))); + } + + /** + * bind event handler through this function + * @param {string} key event's name + * @param {Function} fn event's handler + */ + + }, { + key: '$on', + value: function $on(key, fn) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var eventInfo = _Object$assign({}, options, { + name: key, + id: this.__id, + fn: fn + }); + this.__dispatcher.binder.on(eventInfo); + // set on __events as mark so that i can destroy it when i destroy + this.__addEvents(key, fn); + } + /** + * remove event handler through this function + * @param {string} key event's name + * @param {Function} fn event's handler + */ + + }, { + key: '$off', + value: function $off(key, fn) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var eventInfo = _Object$assign({}, options, { + name: key, + id: this.__id, + fn: fn + }); + this.__dispatcher.binder.off(eventInfo); + this.__removeEvents(key, fn); + } + /** + * bind one time event handler + * @param {string} key event's name + * @param {Function} fn event's handler + */ + + }, { + key: '$once', + value: function $once(key, fn) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var self = this; + var boundFn = function boundFn() { + bind(fn, this).apply(undefined, arguments); + self.__removeEvents(key, boundFn); + }; + self.__addEvents(key, boundFn); + var eventInfo = _Object$assign({}, options, { + name: key, + id: this.__id, + fn: boundFn + }); + this.__dispatcher.binder.once(eventInfo); + } + + /** + * set style + * @param {string} element optional, default to be video, you can choose from video | container | wrapper + * @param {string} attribute the atrribue name + * @param {any} value optional, when it's no offer, we consider you want to get the attribute's value. When it's offered, we consider you to set the attribute's value, if the value you passed is undefined, that means you want to remove the value; + */ + + }, { + key: '$css', + value: function $css(method) { + var _dispatcher$dom2; + + for (var _len6 = arguments.length, args = Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { + args[_key6 - 1] = arguments[_key6]; + } + + return (_dispatcher$dom2 = this.__dispatcher.dom)[method + 'Style'].apply(_dispatcher$dom2, args); + } + + /** + * set attr + * @param {string} element optional, default to be video, you can choose from video | container | wrapper + * @param {string} attribute the atrribue nameß + * @param {any} value optional, when it's no offer, we consider you want to get the attribute's value. When it's offered, we consider you to set the attribute's value, if the value you passed is undefined, that means you want to remove the value; + */ + + }, { + key: '$attr', + value: function $attr(method) { + var _dispatcher$dom3; + + for (var _len7 = arguments.length, args = Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) { + args[_key7 - 1] = arguments[_key7]; + } + + if (method === 'set' && /video/.test(args[0])) { + if (!this.__dispatcher.videoConfigReady) { + /* istanbul ignore else */ + Log.warn('chimee', this.__id + ' is tring to set attribute on video before video inited. Please wait until the inited event has benn trigger'); + return args[2]; + } + if (this.__dispatcher.videoConfig._realDomAttr.indexOf(args[1]) > -1) { + var key = args[1], + val = args[2]; + + this.__dispatcher.videoConfig[key] = val; + return val; + } + } + return (_dispatcher$dom3 = this.__dispatcher.dom)[method + 'Attr'].apply(_dispatcher$dom3, args); + } + }, { + key: '__addEvents', + value: function __addEvents(key, fn) { + this.__events[key] = this.__events[key] || []; + this.__events[key].push(fn); + } + }, { + key: '__removeEvents', + value: function __removeEvents(key, fn) { + if (isEmpty(this.__events[key])) return; + var index = this.__events[key].indexOf(fn); + if (index < 0) return; + this.__events[key].splice(index, 1); + if (isEmpty(this.__events[key])) delete this.__events[key]; + } + }, { + key: '__destroy', + value: function __destroy() { + var _this6 = this; + + this.__unwatchHandlers.forEach(function (unwatcher) { + return unwatcher(); + }); + _Object$keys(this.__events).forEach(function (key) { + if (!isArray(_this6.__events[key])) return; + _this6.__events[key].forEach(function (fn) { + return _this6.$off(key, fn); + }); + }); + delete this.__events; + } + }, { + key: 'currentTime', + get: function get() { + return this.__dispatcher.kernel.currentTime; + }, + set: function set(second) { + this.__dispatcher.binder.emitSync({ + name: 'seek', + target: 'video', + id: this.__id + }, second); + } + }, { + key: '$plugins', + get: function get() { + return this.__dispatcher.plugins; + } + }, { + key: '$pluginOrder', + get: function get() { + return this.__dispatcher.order; + } + }, { + key: '$wrapper', + get: function get() { + return this.__dispatcher.dom.wrapper; + } + }, { + key: '$container', + get: function get() { + return this.__dispatcher.dom.container; + } + }, { + key: '$video', + get: function get() { + return this.__dispatcher.dom.videoElement; + } + }, { + key: 'isFullscreen', + get: function get() { + return this.__dispatcher.dom.isFullscreen; + } + }, { + key: 'fullscreenElement', + get: function get() { + return this.__dispatcher.dom.fullscreenElement; + } + }, { + key: 'container', + get: function get() { + return this.__dispatcher.containerConfig; + }, + set: function set(config) { + if (!isObject(config)) { + throw new Error('The config of container must be Object, but not ' + (typeof config === 'undefined' ? 'undefined' : _typeof(config)) + '.'); + } + deepAssign(this.__dispatcher.containerConfig, config); + return this.__dispatcher.container; + } + }, { + key: 'videoRequireGuardedAttributes', + get: function get() { + return this.__dispatcher.dom.videoRequireGuardedAttributes; + } + }]); + + return VideoWrapper; +}(), (_applyDecoratedDescriptor$1(_class2.prototype, '$silentLoad', [_dec2$1], _Object$getOwnPropertyDescriptor(_class2.prototype, '$silentLoad'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$fullscreen', [_dec3, _dec4, _dec5], _Object$getOwnPropertyDescriptor(_class2.prototype, '$fullscreen'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$emit', [_dec6], _Object$getOwnPropertyDescriptor(_class2.prototype, '$emit'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$emitSync', [_dec7], _Object$getOwnPropertyDescriptor(_class2.prototype, '$emitSync'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$on', [_dec8, _dec9, _dec10], _Object$getOwnPropertyDescriptor(_class2.prototype, '$on'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$off', [_dec11, _dec12, _dec13], _Object$getOwnPropertyDescriptor(_class2.prototype, '$off'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$once', [_dec14, _dec15], _Object$getOwnPropertyDescriptor(_class2.prototype, '$once'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$css', [_dec16, _dec17], _Object$getOwnPropertyDescriptor(_class2.prototype, '$css'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$attr', [_dec18, _dec19], _Object$getOwnPropertyDescriptor(_class2.prototype, '$attr'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$plugins', [nonenumerable], _Object$getOwnPropertyDescriptor(_class2.prototype, '$plugins'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$pluginOrder', [nonenumerable], _Object$getOwnPropertyDescriptor(_class2.prototype, '$pluginOrder'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$wrapper', [nonenumerable], _Object$getOwnPropertyDescriptor(_class2.prototype, '$wrapper'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$container', [nonenumerable], _Object$getOwnPropertyDescriptor(_class2.prototype, '$container'), _class2.prototype), _applyDecoratedDescriptor$1(_class2.prototype, '$video', [nonenumerable], _Object$getOwnPropertyDescriptor(_class2.prototype, '$video'), _class2.prototype)), _class2)) || _class$1); + +var _dec$2, _class$2; + +/** + *
+ * Plugin is the class for plugin developer.
+ * When we use a plugin, we will generate an instance of plugin.
+ * Developer can do most of things base on this plugin
+ * 
+ */ +var Plugin = (_dec$2 = autobindClass(), _dec$2(_class$2 = function (_VideoWrapper) { + _inherits(Plugin, _VideoWrapper); + + /** + *
+   * to create a plugin, we need three parameter
+   * 1. the config of a plugin
+   * 2. the dispatcher
+   * 3. this option for plugin to read
+   * this is the plugin base class, which you can get on Chimee
+   * You can just extends it and then install
+   * But in that way you must remember to pass the arguments to super()
+   * 
+ * @param {string} PluginConfig.id camelize from plugin's name or class name. + * @param {string} PluginConfig.name plugin's name or class name + * @param {Number} PluginConfig.level the level of z-index + * @param {Boolean} PluginConfig.operable to tell if the plugin can be operable, if not, we will add pointer-events: none on it. + * @param {Function} PluginConfig.create the create function which we will called when plugin is used. sth like constructor in object style. + * @param {Function} PluginConfig.destroy function to be called when we destroy a plugin + * @param {Object} PluginConfig.events You can set some events handler in this object, we will bind it once you use the plugin. + * @param {Object} PluginConfig.data dataset we will bind on data in object style + * @param {Object<{get: Function, set: Function}} PluginConfig.computed dataset we will handle by getter and setter + * @param {Object} PluginConfig.methods some function we will bind on plugin + * @param {string|HTMLElment} PluginConfig.el can be string or HTMLElement, we will use this to create the dom for plugin + * @param {boolean} PluginConfig.penetrate boolean to let us do we need to forward the dom events for this plugin. + * @param {Dispatcher} dispatcher referrence of dispatcher + * @param {Object} option PluginOption that will pass to the plugin + * @return {Plugin} plugin instance + */ + function Plugin() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + id = _ref.id, + name = _ref.name, + _ref$level = _ref.level, + level = _ref$level === undefined ? 0 : _ref$level, + _ref$operable = _ref.operable, + operable = _ref$operable === undefined ? true : _ref$operable, + beforeCreate = _ref.beforeCreate, + create = _ref.create, + init = _ref.init, + inited = _ref.inited, + destroy = _ref.destroy, + _ref$events = _ref.events, + events = _ref$events === undefined ? {} : _ref$events, + _ref$data = _ref.data, + data = _ref$data === undefined ? {} : _ref$data, + _ref$computed = _ref.computed, + computed = _ref$computed === undefined ? {} : _ref$computed, + _ref$methods = _ref.methods, + methods = _ref$methods === undefined ? {} : _ref$methods, + el = _ref.el, + _ref$penetrate = _ref.penetrate, + penetrate = _ref$penetrate === undefined ? false : _ref$penetrate, + _ref$inner = _ref.inner, + inner = _ref$inner === undefined ? true : _ref$inner, + autoFocus = _ref.autoFocus, + className = _ref.className; + + var dispatcher = arguments[1]; + var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { name: name }; + + _classCallCheck(this, Plugin); + + var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this)); + + _this.destroyed = false; + _this.VERSION = '0.10.6'; + _this.__operable = true; + _this.__level = 0; + + if (isEmpty(dispatcher)) { + /* istanbul ignore else */ + Log.error('Dispatcher.plugin', 'lack of dispatcher. Do you forget to pass arguments to super in plugin?'); + throw new TypeError('lack of dispatcher'); + } + if (!isString(id)) { + throw new TypeError('id of PluginConfig must be string'); + } + _this.__id = id; + _this.__dispatcher = dispatcher; + _this.$videoConfig = _this.__dispatcher.videoConfig; + _this.__wrapAsVideo(_this.$videoConfig); + _this.beforeCreate = _this.beforeCreate || beforeCreate; + try { + isFunction(_this.beforeCreate) && _this.beforeCreate({ + events: events, + data: data, + computed: computed, + methods: methods + }, option); + } catch (error) { + _this.$throwError(error); + } + // bind plugin methods into instance + if (!isEmpty(methods) && isObject(methods)) { + _Object$keys(methods).forEach(function (key) { + var fn = methods[key]; + if (!isFunction(fn)) throw new TypeError('plugins methods must be Function'); + _Object$defineProperty(_this, key, { + value: bind(fn, _this), + writable: true, + enumerable: false, + configurable: true + }); + }); + } + // hook plugin events on bus + if (!isEmpty(events) && isObject(events)) { + _Object$keys(events).forEach(function (key) { + if (!isFunction(events[key])) throw new TypeError('plugins events hook must bind with Function'); + _this.$on(key, events[key]); + }); + } + // bind data into plugin instance + if (!isEmpty(data) && isObject(data)) { + deepAssign(_this, data); + } + // set the computed member by getter and setter + if (!isEmpty(computed) && isObject(computed)) { + var props = _Object$keys(computed).reduce(function (props, key) { + var val = computed[key]; + if (isFunction(val)) { + props[key] = accessor({ get: val }); + return props; + } + if (isObject(val) && (isFunction(val.get) || isFunction(val.set))) { + props[key] = accessor(val); + return props; + } + /* istanbul ignore else */ + Log.warn('Dispatcher.plugin', 'Wrong computed member \'' + key + '\' defination in Plugin ' + name); + return props; + }, {}); + applyDecorators(_this, props, { self: true }); + } + /** + * the create Function of plugin + * @type {Function} + */ + _this.create = _this.create || create; + /** + * this init Function of plugin + * which will be called when we start to create the video player + * the plugin can handle some config here + * @type {Function} + */ + _this.init = _this.init || init; + /** + * this inited Function of plugin + * which will be called when we have created the video player + * @type {Function} + */ + _this.inited = _this.inited || inited; + /** + * the destroy Function of plugin + * @type {Function} + */ + _this.destroy = _this.destroy || destroy; + /** + * the dom node of whole plugin + * @type {HTMLElement} + */ + _this.$dom = _this.__dispatcher.dom.insertPlugin(_this.__id, el, { penetrate: penetrate, inner: inner, className: className }); + _this.$autoFocus = isBoolean(autoFocus) ? autoFocus : inner; + // now we can frozen inner, autoFocus and penetrate + _this.$inner = inner; + _this.$penetrate = penetrate; + applyDecorators(_this, { + $inner: frozen, + $penetrate: frozen + }, { self: true }); + /** + * to tell us if the plugin can be operable, can be dynamic change + * @type {boolean} + */ + _this.$operable = isBoolean(option.operable) ? option.operable : operable; + _this.__level = isInteger$2(option.level) ? option.level : level; + /** + * pluginOption, so it's easy for plugin developer to check the config + * @type {Object} + */ + _this.$config = option; + try { + isFunction(_this.create) && _this.create(); + } catch (error) { + _this.$throwError(error); + } + return _this; + } + /** + * call for init lifecycle hook, which mainly handle the original config of video and kernel. + * @param {VideoConfig} videoConfig the original config of the videoElement or Kernel + */ + + + _createClass(Plugin, [{ + key: '__init', + value: function __init(videoConfig) { + try { + isFunction(this.init) && this.init(videoConfig); + } catch (error) { + this.$throwError(error); + } + } + /** + * call for inited lifecycle hook, which just to tell the plugin we have inited. + */ + + }, { + key: '__inited', + value: function __inited() { + var _this2 = this; + + var result = void 0; + try { + result = isFunction(this.inited) && this.inited(); + } catch (error) { + this.$throwError(error); + } + this.readySync = !isPromise(result); + this.ready = this.readySync ? _Promise.resolve(this) + // $FlowFixMe: it's promise now + : result.then(function () { + _this2.readySync = true; + return _this2; + }).catch(function (error) { + if (isError(error)) return _this2.$throwError(error); + return _Promise.reject(error); + }); + return this.readySync ? this : this.ready; + } + + /** + * set the plugin to be the top of all plugins + */ + + }, { + key: '$bumpToTop', + value: function $bumpToTop() { + var topLevel = this.__dispatcher._getTopLevel(this.$inner); + this.$level = topLevel + 1; + } + }, { + key: '$throwError', + value: function $throwError(error) { + this.__dispatcher.throwError(error); + } + /** + * officail destroy function for plugin + * we will call user destory function in this method + */ + + }, { + key: '$destroy', + value: function $destroy() { + if (this.destroyed) return; + isFunction(this.destroy) && this.destroy(); + _get(Plugin.prototype.__proto__ || _Object$getPrototypeOf(Plugin.prototype), '__destroy', this).call(this); + this.__dispatcher.dom.removePlugin(this.__id); + delete this.__dispatcher; + delete this.$dom; + this.destroyed = true; + } + /** + * to tell us if the plugin can be operable, can be dynamic change + * @type {boolean} + */ + + }, { + key: '$operable', + set: function set(val) { + if (!isBoolean(val)) return; + this.$dom.style.pointerEvents = val ? 'auto' : 'none'; + this.__operable = val; + }, + get: function get$$1() { + return this.__operable; + } + /** + * the z-index level, higher when you set higher + * @type {boolean} + */ + + }, { + key: '$level', + set: function set(val) { + if (!isInteger$2(val)) return; + this.__level = val; + this.__dispatcher._sortZIndex(); + }, + get: function get$$1() { + return this.__level; + } + }, { + key: '$autoFocus', + get: function get$$1() { + return this.__autoFocus; + }, + set: function set(val) { + this.__autoFocus = val; + this.__dispatcher.dom._autoFocusToVideo(this.$dom, !val); + } + }]); + + return Plugin; +}(VideoWrapper)) || _class$2); + +var VENDOR_PREFIXES = ['', 'o', 'ms', 'moz', 'webkit', 'webkitCurrent']; + +var SYNONYMS = [['', ''], // empty +['exit', 'cancel'], // firefox & old webkits expect cancelFullScreen instead of exitFullscreen +['screen', 'Screen']]; + +var DESKTOP_FULLSCREEN_STYLE = { + position: 'fixed', + zIndex: '2147483647', + left: 0, + top: 0, + right: 0, + bottom: 0, + overflow: 'hidden', + width: '100%', + height: '100%' +}; + +var FULLSCREEN_CHANGE = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange']; + +var FULLSCREEN_ERROR = ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError']; + +var supportDocument = typeof document !== 'undefined'; + +function setStyle$1(el, key, val) { + if (isObject(key)) { + for (var k in key) { + setStyle$1(el, k, key[k]); + } + } else { + // $FlowFixMe: we found it + el.style[key] = val; + } +} + +function native(target, name) { + var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + if (isObject(name)) { + option = name; + } + if (isString(target)) { + name = target; + } + var _option = option, + _option$keyOnly = _option.keyOnly, + keyOnly = _option$keyOnly === undefined ? false : _option$keyOnly; + /* istanbul ignore if */ + + if (!supportDocument) { + return keyOnly ? '' : undefined; + } + if (!isElement(target)) { + target = document; + } + if (!isString(name)) throw new Error('You must pass in a string as name, but not ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name)) + '.'); + for (var i = 0; i < SYNONYMS.length; i++) { + name = name.replace(SYNONYMS[i][0], SYNONYMS[i][1]); + for (var j = 0; j < VENDOR_PREFIXES.length; j++) { + var prefixed = j === 0 ? name : VENDOR_PREFIXES[j] + name.charAt(0).toUpperCase() + name.substr(1); + // $FlowFixMe: we support document computed property here + if (target[prefixed] !== undefined) return keyOnly ? prefixed : target[prefixed]; + } + } + return keyOnly ? '' : undefined; +} + +function dispatchEvent(element, name) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref$bubbles = _ref.bubbles, + bubbles = _ref$bubbles === undefined ? true : _ref$bubbles, + _ref$cancelable = _ref.cancelable, + cancelable = _ref$cancelable === undefined ? true : _ref$cancelable; + + var event = void 0; + /* istanbul ignore else */ + if (isFunction(Event)) { + event = new Event(name, { + bubbles: bubbles, + cancelable: cancelable + }); + } else if (supportDocument && document.createEvent) { + event = document.createEvent('HTMLEvents'); + event.initEvent(name, true, true); + } else if (supportDocument && document.createEventObject) { + // $FlowFixMe: IE < 9 + event = document.createEventObject(); + event.eventType = name; + event.eventName = name; + } + /* istanbul ignore next */ + if (!isObject(event) && !isEvent(event)) throw new Error("We can't create an object on this browser, please report to author"); + /* istanbul ignore else */ + if (element.dispatchEvent) { + element.dispatchEvent(event); + // $FlowFixMe: IE < 9 + } else if (element.fireEvent) { + // $FlowFixMe: IE < 9 + element.fireEvent('on' + event.eventType, event); // can trigger only real event (e.g. 'click') + // $FlowFixMe: support computed key + } else if (element[name]) { + // $FlowFixMe: support computed key + element[name](); + // $FlowFixMe: support computed key + } else if (element['on' + name]) { + // $FlowFixMe: support computed key + element['on' + name](); + } +} + +var _dec$3, _dec2$2, _dec3$1, _dec4$1, _dec5$1, _class$3, _class2$1; + +function _applyDecoratedDescriptor$2(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +var fullscreenEnabled = native('fullscreenEnabled'); +var useStyleFirst = false; + +var ESFullScreen = (_dec$3 = autobindClass(), _dec2$2 = alias('requestFullscreen'), _dec3$1 = alias('exitFullscreen'), _dec4$1 = alias('addEventListener'), _dec5$1 = alias('removeEventListener'), _dec$3(_class$3 = (_class2$1 = function () { + function ESFullScreen() { + _classCallCheck(this, ESFullScreen); + + this._fullscreenElement = null; + this.isNativelySupport = defined(native('fullscreenElement')) && (!defined(fullscreenEnabled) || fullscreenEnabled === true); + this._openKey = supportDocument ? native(document.body || document.documentElement, 'requestFullscreen', { keyOnly: true }) : ''; + this._exitKey = native('exitFullscreen', { keyOnly: true }); + this._useStyleFirst = false; + this.hasUsedStyle = false; + } + + _createClass(ESFullScreen, [{ + key: 'open', + value: function open(element) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$force = _ref.force, + force = _ref$force === undefined ? false : _ref$force; + + /* istanbul ignore else */ + { + if (!isElement(element)) throw new Error('You should passed in a legal element to requestFullScreen, but not ' + (typeof element === 'undefined' ? 'undefined' : _typeof(element)) + '.'); + if (!isPosterityNode(document, element)) throw new Error('You must pass in a HTML element in document.'); + } + var originElement = this.fullscreenElement; + if (originElement && originElement !== element) { + if (!force) { + dispatchEvent(document, 'fullscreenerror'); + return false; + } + this.exit(); + } + + if (!this.useStyleFirst) { + if (this.isNativelySupport) { + // $FlowFixMe: support computed key on HTMLElment here + isFunction(element[this._openKey]) && element[this._openKey](); + return true; + } + + // add wekitEnterFullscreen support as required in https://github.com/toxic-johann/es-fullscreen/issues/4 + /* istanbul ignore if */ + if (element instanceof HTMLVideoElement && element.webkitSupportsFullscreen && + // $FlowFixMe: support webkitEnterFullscreen on some werid safari + isFunction(element.webkitEnterFullscreen)) { + element.webkitEnterFullscreen(); + this._fullscreenElement = element; + return true; + } + } + + this._savedStyles = _Object$keys(DESKTOP_FULLSCREEN_STYLE).reduce(function (styles, key) { + // $FlowFixMe: support string here + styles[key] = element.style[key]; + return styles; + }, {}); + setStyle$1(element, DESKTOP_FULLSCREEN_STYLE); + + /* istanbul ignore else */ + if (document.body) { + this._bodyOverflow = document.body.style.overflow; + document.body.style.overflow = 'hidden'; + } + /* istanbul ignore else */ + if (document.documentElement) { + this._htmlOverflow = document.documentElement.style.overflow; + document.documentElement.style.overflow = 'hidden'; + } + this._fullscreenElement = element; + this.hasUsedStyle = true; + dispatchEvent(element, 'fullscreenchange'); + return true; + } + }, { + key: 'exit', + value: function exit() { + if (!this.isFullscreen) return false; + if (this.isNativelySupport && !this.useStyleFirst && !this.hasUsedStyle) { + // $FlowFixMe: support document computed key here + document[this._exitKey](); + return true; + } + // $FlowFixMe: element is an Elment here + var element = this._fullscreenElement; + setStyle$1(element, this._savedStyles); + /* istanbul ignore else */ + if (document.body) document.body.style.overflow = this._bodyOverflow; + /* istanbul ignore else */ + if (document.documentElement) document.documentElement.style.overflow = this._htmlOverflow; + + this._fullscreenElement = null; + this._savedStyles = {}; + dispatchEvent(element, 'fullscreenchange'); + return true; + } + }, { + key: 'on', + value: function on(name, fn) { + var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document; + + this._handleEvent(element, 'addEventListener', name, fn); + } + }, { + key: 'off', + value: function off(name, fn) { + var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document; + + this._handleEvent(element, 'removeEventListener', name, fn); + } + }, { + key: '_handleEvent', + value: function _handleEvent(element, behavior, name, fn) { + /* istanbul ignore else */ + { + if (name !== 'fullscreenchange' && name !== 'fullscreenerror' && name !== 'esfullscreenmethodchange') throw new Error(this.constructor.name + ' only handle "fullscreenchange", "fullscreenerror" and "esfullscreenmethodchange" event, but not ' + name + '. Pleas pass in an right event name.'); + if (!isFunction(fn)) throw new Error('You must pass in an legal function, but not ' + (typeof fn === 'undefined' ? 'undefined' : _typeof(fn)) + '.'); + if (!isElement(element) && element !== document) throw new Error('You should passed in a legal element, but not ' + (typeof element === 'undefined' ? 'undefined' : _typeof(element)) + '.'); + } + var names = name === 'fullscreenchange' ? FULLSCREEN_CHANGE : name === 'fullscreenerror' ? FULLSCREEN_ERROR : [name]; + names.forEach(function (name) { + // $FlowFixMe: support computed attribute here + element[behavior](name, fn); + }); + } + }, { + key: 'useStyleFirst', + get: function get() { + return useStyleFirst; + }, + set: function set(value) { + value = !!value; + if (value === useStyleFirst) return value; + useStyleFirst = value; + dispatchEvent(document, 'esfullscreenmethodchange'); + return value; + } + }, { + key: 'fullscreenElement', + get: function get() { + var element = ['fullscreenElement', 'webkitFullscreenElement', 'mozFullScreenElement', 'msFullscreenElement'].reduce(function (element, key) { + // $FlowFixMe: support computed element on document + return element || document[key]; + }, null); + return element || this._fullscreenElement; + } + }, { + key: 'isFullscreen', + get: function get() { + return isElement(this.fullscreenElement); + } + }]); + + return ESFullScreen; +}(), _applyDecoratedDescriptor$2(_class2$1.prototype, 'open', [_dec2$2], _Object$getOwnPropertyDescriptor(_class2$1.prototype, 'open'), _class2$1.prototype), _applyDecoratedDescriptor$2(_class2$1.prototype, 'exit', [_dec3$1], _Object$getOwnPropertyDescriptor(_class2$1.prototype, 'exit'), _class2$1.prototype), _applyDecoratedDescriptor$2(_class2$1.prototype, 'on', [_dec4$1], _Object$getOwnPropertyDescriptor(_class2$1.prototype, 'on'), _class2$1.prototype), _applyDecoratedDescriptor$2(_class2$1.prototype, 'off', [_dec5$1], _Object$getOwnPropertyDescriptor(_class2$1.prototype, 'off'), _class2$1.prototype), _class2$1)) || _class$3); + +var index = new ESFullScreen(); + +var _dec$4, _dec2$3, _dec3$2, _dec4$2, _dec5$2, _dec6$1, _class$4; + +function _applyDecoratedDescriptor$3(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +function targetCheck(target) { + if (target === 'video') target = 'videoElement'; + if (!isElement(this[target])) throw new TypeError('Your target "' + target + '" is not a legal HTMLElement'); + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return [target].concat(args); +} +function attrOperationCheck(target, attr, val) { + if (!isString(attr)) throw new TypeError('to handle dom\'s attribute or style, your attr parameter must be string, but not ' + attr + ' in ' + (typeof attr === 'undefined' ? 'undefined' : _typeof(attr))); + if (!isString(target)) throw new TypeError('to handle dom\'s attribute or style, your target parameter must be string, , but not ' + target + ' in ' + (typeof target === 'undefined' ? 'undefined' : _typeof(target))); + return [target, attr, val]; +} +/** + *
+ * Dom work for Dispatcher.
+ * It take charge of dom management of Dispatcher.
+ * 
+ */ +var Dom = (_dec$4 = waituntil('__dispatcher.videoConfigReady'), _dec2$3 = before(attrOperationCheck, targetCheck), _dec3$2 = before(attrOperationCheck, targetCheck), _dec4$2 = before(attrOperationCheck, targetCheck), _dec5$2 = before(attrOperationCheck, targetCheck), _dec6$1 = before(targetCheck), (_class$4 = function () { + _createClass(Dom, [{ + key: 'mouseInVideo', + + /** + * to mark is the mouse in the video area + */ + + /** + * all plugin's dom element set + */ + get: function get() { + return this.__mouseInVideo; + } + /** + * the html to restore when we are destroyed + */ + , + set: function set(val) { + this.__mouseInVideo = !!val; + } + /** + * collection of video extension nodes + * some nodes can be regarded as part of video (such as penetrate element) + * so we store them here + */ + + }, { + key: 'videoExtendedNodes', + get: function get() { + return this.__videoExtendedNodes; + } + }]); + + function Dom(config, dispatcher) { + _classCallCheck(this, Dom); + + this.plugins = {}; + this.originHTML = ''; + this.__mouseInVideo = false; + this.destroyed = false; + this.__videoExtendedNodes = []; + this.isFullscreen = false; + this.fullscreenElement = undefined; + + var _ref = config || {}, + wrapper = _ref.wrapper; + + this.__dispatcher = dispatcher; + if (!isElement(wrapper) && !isString(wrapper)) throw new TypeError('Wrapper can only be string or HTMLElement, but not ' + (typeof wrapper === 'undefined' ? 'undefined' : _typeof(wrapper))); + var $wrapper = $(wrapper); + // TODO: we have to decalre length for wrapper + // $FlowFixMe: we have to decalre length here + if ($wrapper.length === 0) { + throw new TypeError('Can not get dom node accroding wrapper. Please check your wrapper'); + } + /** + * the referrence of the dom wrapper of whole Chimee + */ + // $FlowFixMe: support computed key on nodewrap + this.wrapper = $wrapper[0]; + this.originHTML = this.wrapper.innerHTML; + // if we find video element inside wrapper + // we use it + // or we create a video element by ourself. + // $FlowFixMe: support computed key on nodewrap + var videoElement = $wrapper.find('video')[0]; + if (!videoElement) { + videoElement = document.createElement('video'); + } + /** + * referrence of video's dom element + */ + this.installVideo(videoElement); + this._fullscreenMonitor(); + index.on('fullscreenchange', this._fullscreenMonitor); + // As some video attributes will missed when we switch kernel + // we set a guarder for it + // and we must make sure style be guarded + var videoRequiredGuardedAttributes = isArray(config.videoRequiredGuardedAttributes) ? config.videoRequiredGuardedAttributes : []; + if (videoRequiredGuardedAttributes.indexOf('style') < 0) { + videoRequiredGuardedAttributes.unshift('style'); + } + this.videoRequireGuardedAttributes = videoRequiredGuardedAttributes; + } + + _createClass(Dom, [{ + key: 'installVideo', + value: function installVideo(videoElement) { + this.__videoExtendedNodes.push(videoElement); + setAttr(videoElement, 'tabindex', -1); + this._autoFocusToVideo(videoElement); + if (!isElement(this.container)) { + // create container + if (videoElement.parentElement && isElement(videoElement.parentElement) && videoElement.parentElement !== this.wrapper) { + this.container = videoElement.parentElement; + } else { + this.container = document.createElement('container'); + $(this.container).append(videoElement); + } + } else { + var container = this.container; + if (container.childNodes.length === 0) { + container.appendChild(videoElement); + } else { + container.insertBefore(videoElement, container.childNodes[0]); + } + } + // check container.position + if (this.container.parentElement !== this.wrapper) { + $(this.wrapper).append(this.container); + } + this.videoElement = videoElement; + return videoElement; + } + }, { + key: 'removeVideo', + value: function removeVideo() { + var videoElement = this.videoElement; + this._autoFocusToVideo(this.videoElement, false); + // when we destroy the chimee + // binder is destroyed before dom + // so we need to make a check here + this.__dispatcher.binder && this.__dispatcher.binder.bindEventOnVideo(videoElement, true); + $(videoElement).remove(); + delete this.videoElement; + return videoElement; + } + + /** + * each plugin has its own dom node, this function will create one or them. + * we support multiple kind of el + * 1. Element, we will append this dom node on wrapper straight + * 2. HTMLString, we will create dom based on this HTMLString and append it on wrapper + * 3. string, we will transfer this string into hypen string, then we create a custom elment called by this and bind it on wrapper + * 4. nothing, we will create a div and bind it on the wrapper + */ + + }, { + key: 'insertPlugin', + value: function insertPlugin(id, el) { + var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + if (!isString(id)) throw new TypeError('insertPlugin id parameter must be string'); + if (isElement(this.plugins[id])) { + /* istanbul ignore else */ + Log.warn('Dispatcher.dom', 'Plugin ' + id + ' have already had a dom node. Now it will be replaced'); + this.removePlugin(id); + } + if (isString(el)) { + if (isHTMLString(el)) { + var outer = document.createElement('div'); + outer.innerHTML = el; + el = outer.children[0]; + } else { + el = document.createElement(hypenate(el)); + } + } else if (isObject(el)) { + // $FlowFixMe: we have check el's type here and make sure it's an object + option = el; + } + var _option = option, + inner = _option.inner, + penetrate = _option.penetrate; + var _option2 = option, + className = _option2.className; + + var node = el && isElement(el) ? el : document.createElement('div'); + if (isArray(className)) { + className = className.join(' '); + } + if (isString(className)) { + addClassName(node, className); + } + this.plugins[id] = node; + var outerElement = inner ? this.container : this.wrapper; + var originElement = inner ? this.videoElement : this.container; + // auto forward the event if this plugin can be penetrate + if (penetrate) { + this.__dispatcher.binder.bindEventOnPenetrateNode(node); + this.__videoExtendedNodes.push(node); + } + if (outerElement.lastChild === originElement) { + outerElement.appendChild(node); + return node; + } + outerElement.insertBefore(node, originElement.nextSibling); + return node; + } + + /** + * remove plugin's dom + */ + + }, { + key: 'removePlugin', + value: function removePlugin(id) { + if (!isString(id)) return; + var dom = this.plugins[id]; + if (isElement(dom)) { + dom.parentNode && dom.parentNode.removeChild(dom); + this._autoFocusToVideo(dom, true); + } + + var _ref2 = Dispatcher.getPluginConfig(id) || {}, + _ref2$penetrate = _ref2.penetrate, + penetrate = _ref2$penetrate === undefined ? false : _ref2$penetrate; + + if (penetrate) this.__dispatcher.binder.bindEventOnPenetrateNode(dom, true); + delete this.plugins[id]; + } + + /** + * Set zIndex for a plugins list + */ + + }, { + key: 'setPluginsZIndex', + value: function setPluginsZIndex(plugins) { + var _this = this; + + // $FlowFixMe: there are videoElment and container here + plugins.forEach(function (key, index$$1) { + return setStyle(key.match(/^(videoElement|container)$/) ? _this[key] : _this.plugins[key], 'z-index', ++index$$1); + }); + } + + /** + * set attribute on our dom + * @param {string} attr attribute's name + * @param {anything} val attribute's value + * @param {string} target the HTMLElemnt string name, only support video/wrapper/container now + */ + + }, { + key: 'setAttr', + value: function setAttr$$1(target, attr, val) { + // $FlowFixMe: flow do not support computed property/element on class, which is silly here. + setAttr(this[target], attr, val); + } + }, { + key: 'getAttr', + value: function getAttr$$1(target, attr) { + // $FlowFixMe: flow do not support computed property/element on class, which is silly here. + return getAttr(this[target], attr); + } + }, { + key: 'setStyle', + value: function setStyle$$1(target, attr, val) { + // $FlowFixMe: flow do not support computed property/element on class, which is silly here. + setStyle(this[target], attr, val); + } + }, { + key: 'getStyle', + value: function getStyle$$1(target, attr) { + // $FlowFixMe: flow do not support computed property/element on class, which is silly here. + return getStyle(this[target], attr); + } + }, { + key: 'requestFullscreen', + value: function requestFullscreen(target) { + // $FlowFixMe: flow do not support computed property/element on document, which is silly here. + return index.open(this[target]); + } + }, { + key: 'exitFullscreen', + value: function exitFullscreen() { + return index.exit(); + } + }, { + key: 'fullscreen', + value: function fullscreen() { + var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'container'; + + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + return request ? this.requestFullscreen.apply(this, [target].concat(_toConsumableArray(args))) : this.exitFullscreen.apply(this, _toConsumableArray(args)); + } + }, { + key: 'focus', + value: function focus() { + this.videoElement.focus(); + } + }, { + key: 'isNodeInsideVideo', + value: function isNodeInsideVideo(node) { + return this.__videoExtendedNodes.indexOf(node) > -1 || this.__videoExtendedNodes.reduce(function (flag, video) { + if (flag) return flag; + return isPosterityNode(video, node); + }, false); + } + }, { + key: 'migrateVideoRequiredGuardedAttributes', + value: function migrateVideoRequiredGuardedAttributes(video) { + var _this2 = this; + + var guardedAttributesAndValue = this.videoRequireGuardedAttributes.map(function (attr) { + return [attr, getAttr(_this2.videoElement, attr)]; + }); + guardedAttributesAndValue.forEach(function (_ref3) { + var _ref4 = _slicedToArray(_ref3, 2), + attr = _ref4[0], + value = _ref4[1]; + + return setAttr(video, attr, value); + }); + } + + /** + * function called when we distory + */ + + }, { + key: 'destroy', + value: function destroy() { + this.removeVideo(); + index.off('fullscreenchange', this._fullscreenMonitor); + this.wrapper.innerHTML = this.originHTML; + delete this.wrapper; + delete this.plugins; + this.destroyed = true; + } + }, { + key: '_autoFocusToVideo', + value: function _autoFocusToVideo(element) { + var remove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + /* istanbule ignore next */ + if (!isElement(element)) return; + (remove ? removeEvent : addEvent)(element, 'mouseup', this._focusToVideo, false, true); + (remove ? removeEvent : addEvent)(element, 'touchend', this._focusToVideo, false, true); + } + }, { + key: '_focusToVideo', + value: function _focusToVideo() { + var x = window.scrollX; + var y = window.scrollY; + isFunction(this.videoElement.focus) && this.videoElement.focus(); + window.scrollTo(x, y); + } + }, { + key: '_fullscreenMonitor', + value: function _fullscreenMonitor(evt) { + var element = index.fullscreenElement; + var original = this.isFullscreen; + if (!element || !isPosterityNode(this.wrapper, element) && element !== this.wrapper) { + this.isFullscreen = false; + this.fullscreenElement = undefined; + } else { + this.isFullscreen = true; + this.fullscreenElement = this.wrapper === element ? 'wrapper' : this.container === element ? 'container' : this.videoElement === element ? 'video' : element; + } + if (isEvent(evt) && original !== this.isFullscreen) { + this.__dispatcher.binder.triggerSync({ + name: 'fullscreenchange', + target: 'esFullscreen', + id: 'dispatcher' + }, evt); + } + } + }]); + + return Dom; +}(), (_applyDecoratedDescriptor$3(_class$4.prototype, 'setAttr', [_dec$4, _dec2$3], _Object$getOwnPropertyDescriptor(_class$4.prototype, 'setAttr'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, 'getAttr', [_dec3$2], _Object$getOwnPropertyDescriptor(_class$4.prototype, 'getAttr'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, 'setStyle', [_dec4$2], _Object$getOwnPropertyDescriptor(_class$4.prototype, 'setStyle'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, 'getStyle', [_dec5$2], _Object$getOwnPropertyDescriptor(_class$4.prototype, 'getStyle'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, 'requestFullscreen', [_dec6$1], _Object$getOwnPropertyDescriptor(_class$4.prototype, 'requestFullscreen'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, '_focusToVideo', [autobind], _Object$getOwnPropertyDescriptor(_class$4.prototype, '_focusToVideo'), _class$4.prototype), _applyDecoratedDescriptor$3(_class$4.prototype, '_fullscreenMonitor', [autobind], _Object$getOwnPropertyDescriptor(_class$4.prototype, '_fullscreenMonitor'), _class$4.prototype)), _class$4)); + +var defaultContainerConfig = { + width: '100%', + height: '100%', + position: 'relative', + display: 'block' +}; + +// base css controller for container and wrapper + +var Vessel = function Vessel(dispatcher, target, config) { + var _this = this; + + _classCallCheck(this, Vessel); + + this.__dispatcher = dispatcher; + this.__target = target; + ['width', 'height', 'position', 'display'].forEach(function (key) { + _Object$defineProperty(_this, key, { + get: function get() { + return this.__dispatcher.dom.getStyle(this.__target, key); + }, + set: function set(value) { + if (isNumber(value)) { + value = value + 'px'; + } + if (!isString(value)) { + throw new Error('The value of ' + key + ' in ' + this.__target + 'Config must be string, but not ' + (typeof value === 'undefined' ? 'undefined' : _typeof(value)) + '.'); + } + this.__dispatcher.dom.setStyle(this.__target, key, value); + // return value; + }, + + configurable: true, + enumerable: true + }); + }); + deepAssign(this, config); +}; + +var dP$3 = _objectDp.f; + + + + + + + + + +var fastKey = _meta.fastKey; + +var SIZE = _descriptors ? '_s' : 'size'; + +var getEntry = function (that, key) { + // fast case + var index = fastKey(key); + var entry; + if (index !== 'F') return that._i[index]; + // frozen object case + for (entry = that._f; entry; entry = entry.n) { + if (entry.k == key) return entry; + } +}; + +var _collectionStrong = { + getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { + var C = wrapper(function (that, iterable) { + _anInstance(that, C, NAME, '_i'); + that._t = NAME; // collection type + that._i = _objectCreate(null); // index + that._f = undefined; // first entry + that._l = undefined; // last entry + that[SIZE] = 0; // size + if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); + }); + _redefineAll(C.prototype, { + // 23.1.3.1 Map.prototype.clear() + // 23.2.3.2 Set.prototype.clear() + clear: function clear() { + for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { + entry.r = true; + if (entry.p) entry.p = entry.p.n = undefined; + delete data[entry.i]; + } + that._f = that._l = undefined; + that[SIZE] = 0; + }, + // 23.1.3.3 Map.prototype.delete(key) + // 23.2.3.4 Set.prototype.delete(value) + 'delete': function (key) { + var that = _validateCollection(this, NAME); + var entry = getEntry(that, key); + if (entry) { + var next = entry.n; + var prev = entry.p; + delete that._i[entry.i]; + entry.r = true; + if (prev) prev.n = next; + if (next) next.p = prev; + if (that._f == entry) that._f = next; + if (that._l == entry) that._l = prev; + that[SIZE]--; + } return !!entry; + }, + // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) + // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) + forEach: function forEach(callbackfn /* , that = undefined */) { + _validateCollection(this, NAME); + var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); + var entry; + while (entry = entry ? entry.n : this._f) { + f(entry.v, entry.k, this); + // revert to the last existing entry + while (entry && entry.r) entry = entry.p; + } + }, + // 23.1.3.7 Map.prototype.has(key) + // 23.2.3.7 Set.prototype.has(value) + has: function has(key) { + return !!getEntry(_validateCollection(this, NAME), key); + } + }); + if (_descriptors) dP$3(C.prototype, 'size', { + get: function () { + return _validateCollection(this, NAME)[SIZE]; + } + }); + return C; + }, + def: function (that, key, value) { + var entry = getEntry(that, key); + var prev, index; + // change existing entry + if (entry) { + entry.v = value; + // create new entry + } else { + that._l = entry = { + i: index = fastKey(key, true), // <- index + k: key, // <- key + v: value, // <- value + p: prev = that._l, // <- previous entry + n: undefined, // <- next entry + r: false // <- removed + }; + if (!that._f) that._f = entry; + if (prev) prev.n = entry; + that[SIZE]++; + // add to index + if (index !== 'F') that._i[index] = entry; + } return that; + }, + getEntry: getEntry, + setStrong: function (C, NAME, IS_MAP) { + // add .keys, .values, .entries, [@@iterator] + // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 + _iterDefine(C, NAME, function (iterated, kind) { + this._t = _validateCollection(iterated, NAME); // target + this._k = kind; // kind + this._l = undefined; // previous + }, function () { + var that = this; + var kind = that._k; + var entry = that._l; + // revert to the last existing entry + while (entry && entry.r) entry = entry.p; + // get next entry + if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { + // or finish the iteration + that._t = undefined; + return _iterStep(1); + } + // return step by kind + if (kind == 'keys') return _iterStep(0, entry.k); + if (kind == 'values') return _iterStep(0, entry.v); + return _iterStep(0, [entry.k, entry.v]); + }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); + + // add [@@species], 23.1.2.2, 23.2.2.2 + _setSpecies(NAME); + } +}; + +var MAP = 'Map'; + +// 23.1 Map Objects +var es6_map = _collection(MAP, function (get) { + return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; +}, { + // 23.1.3.6 Map.prototype.get(key) + get: function get(key) { + var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key); + return entry && entry.v; + }, + // 23.1.3.9 Map.prototype.set(key, value) + set: function set(key, value) { + return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value); + } +}, _collectionStrong, true); + +var _arrayFromIterable = function (iter, ITERATOR) { + var result = []; + _forOf(iter, false, result.push, result, ITERATOR); + return result; +}; + +// https://github.com/DavidBruant/Map-Set.prototype.toJSON + + +var _collectionToJson = function (NAME) { + return function toJSON() { + if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic"); + return _arrayFromIterable(this); + }; +}; + +// https://github.com/DavidBruant/Map-Set.prototype.toJSON + + +_export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') }); + +// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of +_setCollectionOf('Map'); + +// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from +_setCollectionFrom('Map'); + +var map = _core.Map; + +var map$1 = createCommonjsModule(function (module) { +module.exports = { "default": map, __esModule: true }; +}); + +var _Map = unwrapExports(map$1); + +var _dec$5, _dec2$4, _dec3$3, _dec4$3, _class$5; + +function _applyDecoratedDescriptor$4(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +var secondaryReg = /^(before|after|_)/; +function secondaryChecker(key) { + if (key.match(secondaryReg)) { + /* istanbul ignore else */ + Log.warn('bus', 'Secondary Event "' + key + '" could not be call straightly by API.'); + return false; + } + return true; +} +/** + *
+ * event Bus class. Bus take charge of commuication between plugins and user.
+ * Some of the event may trigger the kernel to do some task.
+ * An event will run in four lifecycle
+ * before -> processor -> main -> after -> side effect(_)
+ * -------------------- emit period ----------------
+ * before: once an event emit, it will run through plugins in bubble to know is it possible to run.
+ * processor: if sth need to be done on kernel. It will tell kernel. If kernel will trigger event later, it will break down here. Else will run into trigger period
+ * -------------------- trigger period -----------------
+ * main: this procedure will trigger the main event in bubble, which means it can be stop in one plugin.
+ * after: once event run through all events. It will trigger after event. This event will be trigger in broadcast way.
+ * side effect(_): This events will always trigger once we bump into trigger period. So that you can know if the events been blocked. But it's not advice to listen on this effect.
+ * 
+ */ +var Bus = (_dec$5 = runnable(secondaryChecker), _dec2$4 = runnable(secondaryChecker, { + backup: function backup() { + return false; + } +}), _dec3$3 = runnable(secondaryChecker), _dec4$3 = runnable(secondaryChecker, { + backup: function backup() { + return false; + } +}), (_class$5 = function () { + /** + * @param {Dispatcheer} dispatcher bus rely on dispatcher, so you mush pass dispatcher at first when you generate Bus. + * @return {Bus} + */ + + /** + * the handler set of all events + * @type {Object} + * @member events + */ + function Bus(dispatcher, kind) { + _classCallCheck(this, Bus); + + this.events = {}; + this.onceMap = {}; + + /** + * the referrence to dispatcher + * @type {Dispatcher} + */ + this.__dispatcher = dispatcher; + this.__kind = kind; + } + /** + * [Can only be called in dispatcher]bind event on bus. + */ + + + _createClass(Bus, [{ + key: 'on', + value: function on(id, eventName, fn, stage) { + this._addEvent([eventName, stage, id], fn); + } + /** + * [Can only be called in dispatcher]remove event off bus. Only suggest one by one. + */ + + }, { + key: 'off', + value: function off(id, eventName, fn, stage) { + var keys = [eventName, stage, id]; + var deleted = this._removeEvent(keys, fn); + if (deleted) return; + var handler = this._getHandlerFromOnceMap(keys, fn); + if (isFunction(handler)) { + this._removeEvent(keys, handler) && this._removeFromOnceMap(keys, fn, handler); + } + } + /** + * [Can only be called in dispatcher]bind event on bus and remove it once event is triggered. + */ + + }, { + key: 'once', + value: function once(id, eventName, fn, stage) { + var bus = this; + var keys = [eventName, stage, id]; + var handler = function handler() { + // keep the this so that it can run + bind(fn, this).apply(undefined, arguments); + bus._removeEvent(keys, handler); + bus._removeFromOnceMap(keys, fn, handler); + }; + this._addEvent(keys, handler); + this._addToOnceMap(keys, fn, handler); + } + /** + * [Can only be called in dispatcher]emit an event, which will run before -> processor period. + * It may stop in before period. + * @param {string} key event's name + * @param {anything} args other argument will be passed into handler + * @return {Promise} this promise maybe useful if the event would not trigger kernel event. In that will you can know if it runs successful. But you can know if the event been stopped by the promise. + */ + + }, { + key: 'emit', + value: function emit(key) { + var _this = this; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var event = this.events[key]; + if (isEmpty(event)) { + if (selfProcessorEvents.indexOf(key) > -1) return _Promise.resolve(); + // $FlowFixMe: conditional return here + return this._eventProcessor.apply(this, [key, { sync: false }].concat(_toConsumableArray(args))); + } + var beforeQueue = this._getEventQueue(event.before, this.__dispatcher.order); + return runRejectableQueue.apply(undefined, [beforeQueue].concat(_toConsumableArray(args))).then(function () { + if (selfProcessorEvents.indexOf(key) > -1) return; + return _this._eventProcessor.apply(_this, [key, { sync: false }].concat(_toConsumableArray(args))); + }).catch(function (error) { + if (isError(error)) _this.__dispatcher.throwError(error); + return _Promise.reject(error); + }); + } + /** + * [Can only be called in dispatcher]emit an event, which will run before -> processor period synchronize. + * It may stop in before period. + * @param {string} key event's name + * @param {anything} args other argument will be passed into handler + * @return {Promise} this promise maybe useful if the event would not trigger kernel event. In that will you can know if it runs successful. But you can know if the event been stopped by the promise. + */ + + }, { + key: 'emitSync', + value: function emitSync(key) { + var event = this.events[key]; + + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + if (isEmpty(event)) { + if (selfProcessorEvents.indexOf(key) > -1) return true; + // $FlowFixMe: conditional return here + return this._eventProcessor.apply(this, [key, { sync: true }].concat(_toConsumableArray(args))); + } + var beforeQueue = this._getEventQueue(event.before, this.__dispatcher.order); + return runStoppableQueue.apply(undefined, [beforeQueue].concat(_toConsumableArray(args))) && (selfProcessorEvents.indexOf(key) > -1 || + // $FlowFixMe: conditional return here + this._eventProcessor.apply(this, [key, { sync: true }].concat(_toConsumableArray(args)))); + } + /** + * [Can only be called in dispatcher]trigger an event, which will run main -> after -> side effect period + * @param {string} key event's name + * @param {anything} args + * @return {Promise|undefined} you can know if event trigger finished~ However, if it's unlegal + */ + + }, { + key: 'trigger', + value: function trigger(key) { + var _this2 = this; + + for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + var event = this.events[key]; + if (isEmpty(event)) { + return _Promise.resolve(true); + } + var mainQueue = this._getEventQueue(event.main, this.__dispatcher.order); + return runRejectableQueue.apply(undefined, [mainQueue].concat(_toConsumableArray(args))).then(function () { + var afterQueue = _this2._getEventQueue(event.after, _this2.__dispatcher.order); + return runRejectableQueue.apply(undefined, [afterQueue].concat(_toConsumableArray(args))); + }).then(function () { + return _this2._runSideEffectEvent.apply(_this2, [key, _this2.__dispatcher.order].concat(_toConsumableArray(args))); + }).catch(function (error) { + if (isError(error)) _this2.__dispatcher.throwError(error); + return _this2._runSideEffectEvent.apply(_this2, [key, _this2.__dispatcher.order].concat(_toConsumableArray(args))); + }); + } + /** + * [Can only be called in dispatcher]trigger an event, which will run main -> after -> side effect period in synchronize + * @param {string} key event's name + * @param {anything} args + * @return {boolean} you can know if event trigger finished~ However, if it's unlegal + */ + + }, { + key: 'triggerSync', + value: function triggerSync(key) { + var event = this.events[key]; + if (isEmpty(event)) { + return true; + } + var mainQueue = this._getEventQueue(event.main, this.__dispatcher.order); + var afterQueue = this._getEventQueue(event.after, this.__dispatcher.order); + + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + var result = runStoppableQueue.apply(undefined, [mainQueue].concat(_toConsumableArray(args))) && runStoppableQueue.apply(undefined, [afterQueue].concat(_toConsumableArray(args))); + this._runSideEffectEvent.apply(this, [key, this.__dispatcher.order].concat(_toConsumableArray(args))); + return result; + } + /** + * destroy hook which will be called when object destroy + */ + + }, { + key: 'destroy', + value: function destroy() { + delete this.events; + delete this.__dispatcher; + } + /** + * add event into bus + * @private + * @param {Array} keys keys map pointing to position to put event handler + * @param {function} fn handler to put + */ + + }, { + key: '_addEvent', + value: function _addEvent(keys, fn) { + keys = deepClone(keys); + var id = keys.pop(); + var target = keys.reduce(function (target, key) { + target[key] = target[key] || {}; + return target[key]; + }, this.events); + // events will store like {play: {main: {plugin: []}}} + target[id] = target[id] || []; + target[id].push(fn); + } + /** + * remove event from bus + * @private + * @param {Array} keys keys map pointing to position to get event handler + * @param {function} fn handler to put + */ + + }, { + key: '_removeEvent', + value: function _removeEvent(keys, fn) { + keys = deepClone(keys); + var id = keys.pop(); + var target = this.events; + var backtrackList = []; + for (var i = 0, len = keys.length; i < len; i++) { + var son = target[keys[i]]; + // if we can't find the event binder, just return + if (isEmpty(son)) return; + backtrackList.push([target, keys[i]]); + target = son; + } + var queue = target[id] || []; + var index = queue.indexOf(fn); + var hasFn = index > -1; + // if we found handler remove it + if (hasFn) { + queue.splice(index, 1); + } + // if this plugin has no event binding, we remove this event session, which make us perform faster in emit & trigger period. + if (queue.length < 1) { + delete target[id]; + // backtrack to remove the redudant object + for (var _i = backtrackList.length - 1; _i > -1; _i--) { + var _backtrackList$_i = _slicedToArray(backtrackList[_i], 2), + parent = _backtrackList$_i[0], + key = _backtrackList$_i[1]; + + if (!isEmpty(parent[key])) break; + delete parent[key]; + } + } + return hasFn; + } + }, { + key: '_addToOnceMap', + value: function _addToOnceMap(keys, fn, handler) { + var key = keys.join('-'); + var map = this.onceMap[key] = this.onceMap[key] || new _Map(); + if (!map.has(fn)) map.set(fn, []); + var handlers = map.get(fn); + // $FlowFixMe: flow do not understand map yet + handlers.push(handler); + } + }, { + key: '_removeFromOnceMap', + value: function _removeFromOnceMap(keys, fn, handler) { + var key = keys.join('-'); + var map = this.onceMap[key]; + // do not need to check now + // if(isVoid(map) || !map.has(fn)) return; + var handlers = map.get(fn); + var index = handlers.indexOf(handler); + handlers.splice(index, 1); + if (isEmpty(handlers)) map.delete(fn); + } + }, { + key: '_getHandlerFromOnceMap', + value: function _getHandlerFromOnceMap(keys, fn) { + var key = keys.join('-'); + var map = this.onceMap[key]; + if (isVoid(map) || !map.has(fn)) return; + var handlers = map.get(fn); + return handlers[0]; + } + /** + * get event stage by evnet key name + * @private + * @param {key} key event's name + * @return {stage} event stage + */ + + }, { + key: '_getEventStage', + value: function _getEventStage(key) { + var secondaryCheck = key.match(secondaryReg); + // $FlowFixMe: make sure it's event stage here + var stage = secondaryCheck && secondaryCheck[0] || 'main'; + if (secondaryCheck) { + key = camelize(key.replace(secondaryReg, '')); + } + return { stage: stage, key: key }; + } + /** + * get event handlers queue to run + * @private + * @param {Object} handlerSet the object include all handler + * @param {Array} Array form of plugin id + * @return {Array} event handler in queue to run + */ + + }, { + key: '_getEventQueue', + value: function _getEventQueue(handlerSet, order) { + var _this3 = this; + + order = isArray(order) ? order.concat(['_vm']) : ['_vm']; + return isEmpty(handlerSet) ? [] : order.reduce(function (queue, id) { + if (isEmpty(handlerSet[id]) || !isArray(handlerSet[id]) || + // in case plugins is missed + // _vm indicate the user. This is the function for user + !_this3.__dispatcher.plugins[id] && id !== '_vm') { + return queue; + } + return queue.concat(handlerSet[id].map(function (fn) { + // bind context for plugin instance + return bind(fn, _this3.__dispatcher.plugins[id] || _this3.__dispatcher.vm); + })); + }, []); + } + /** + * event processor period. If event needs call kernel function. + * I will called here. + * If kernel will reponse. I will stop here. + * Else I will trigger next period. + * @param {string} key event's name + * @param {boolean} options.sync we will take triggerSync if true, otherwise we will run trigger. default is false + * @param {anything} args + * @return {Promise|undefined} + */ + + }, { + key: '_eventProcessor', + value: function _eventProcessor(key, _ref) { + var sync = _ref.sync; + + var isKernelMethod = kernelMethods.indexOf(key) > -1; + var isDomMethod = domMethods.indexOf(key) > -1; + var isDispatcherMethod = dispatcherMethods.indexOf(key) > -1; + + for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) { + args[_key5 - 2] = arguments[_key5]; + } + + if (isKernelMethod || isDomMethod || isDispatcherMethod) { + if (isDispatcherMethod) { + var _dispatcher; + + (_dispatcher = this.__dispatcher)[key].apply(_dispatcher, _toConsumableArray(args)); + } else { + var _dispatcher2; + + (_dispatcher2 = this.__dispatcher[isKernelMethod ? 'kernel' : 'dom'])[key].apply(_dispatcher2, _toConsumableArray(args)); + } + if (videoEvents.indexOf(key) > -1 || domEvents.indexOf(key) > -1) return true; + } + // $FlowFixMe: flow do not support computed sytax on classs, but it's ok here + return this[sync ? 'triggerSync' : 'trigger'].apply(this, [key].concat(_toConsumableArray(args))); + } + /** + * run side effect period + * @param {string} key event's name + * @param {args} args + */ + + }, { + key: '_runSideEffectEvent', + value: function _runSideEffectEvent(key, order) { + for (var _len6 = arguments.length, args = Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) { + args[_key6 - 2] = arguments[_key6]; + } + + var event = this.events[key]; + if (isEmpty(event)) { + return false; + } + var queue = this._getEventQueue(event._, order); + queue.forEach(function (run) { + return run.apply(undefined, _toConsumableArray(args)); + }); + return true; + } + }]); + + return Bus; +}(), (_applyDecoratedDescriptor$4(_class$5.prototype, 'emit', [_dec$5], _Object$getOwnPropertyDescriptor(_class$5.prototype, 'emit'), _class$5.prototype), _applyDecoratedDescriptor$4(_class$5.prototype, 'emitSync', [_dec2$4], _Object$getOwnPropertyDescriptor(_class$5.prototype, 'emitSync'), _class$5.prototype), _applyDecoratedDescriptor$4(_class$5.prototype, 'trigger', [_dec3$3], _Object$getOwnPropertyDescriptor(_class$5.prototype, 'trigger'), _class$5.prototype), _applyDecoratedDescriptor$4(_class$5.prototype, 'triggerSync', [_dec4$3], _Object$getOwnPropertyDescriptor(_class$5.prototype, 'triggerSync'), _class$5.prototype)), _class$5)); + +var _dec$6, _dec2$5, _dec3$4, _dec4$4, _dec5$3, _dec6$2, _dec7$1, _dec8$1, _dec9$1, _dec10$1, _dec11$1, _class$6; + +function _applyDecoratedDescriptor$5(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} + +var secondaryReg$1 = /^(before|after|_)/; + +/** + * In logic before 0.10.0, we use 'c_' and 'w_' to mark event of container and wrapper + * we need to keep that logic work until next major version. + * @param {string} name 事件名字 + */ +function getEventTargetByOldLogic(oldName) { + var targetKeyReg = new RegExp('^(c|w)_'); + var matches = oldName.match(targetKeyReg); + if (matches) { + var _name = oldName.replace(targetKeyReg, ''); + var _target = oldName.indexOf('c') === 0 ? 'container' : 'wrapper'; + /* istanbul ignore else */ + { + Log.warn('We no longer support event names like ' + oldName + '. Please use ' + _name + ' and options like { target: \'' + _target + '\' } instead'); + } + return { name: _name, target: _target }; + } else if (oldName === 'error') { + return { name: 'error', target: 'kernel' }; + } + return false; +} + +function getEventStage(name) { + var matches = name.match(secondaryReg$1); + // $FlowFixMe: We make sure it's event stage here + var stage = matches && matches[0] || 'main'; + if (matches) { + name = camelize(name.replace(secondaryReg$1, '')); + } + return { name: name, stage: stage }; +} + +function getEventTargetByEventName(name) { + if (videoEvents.indexOf(name) > -1) return 'video'; + if (kernelEvents.indexOf(name) > -1) return 'kernel'; + if (domEvents.indexOf(name) > -1) return 'video-dom'; + if (esFullscreenEvents.indexOf(name) > -1) return 'esFullscreen'; + return 'plugin'; +} + +function getEventInfo(_ref) { + var name = _ref.name, + target = _ref.target, + stage = _ref.stage; + + var oldInfo = getEventTargetByOldLogic(name); + if (oldInfo) { + name = oldInfo.name; + target = oldInfo.target; + } + + var _getEventStage = getEventStage(name), + newStage = _getEventStage.stage, + newName = _getEventStage.name; + + name = newName; + + if (!target) { + target = getEventTargetByEventName(name); + } + + return { + name: name, + stage: stage || newStage, + target: target + }; +} + +function prettifyEventParameter(info) { + var id = info.id, + fn = info.fn; + + var _getEventInfo = getEventInfo(info), + name = _getEventInfo.name, + target = _getEventInfo.target, + stage = _getEventInfo.stage; + + if (!isFunction(fn)) { + throw new Error('You must provide a function to handle with event ' + name + ', but not ' + (typeof fn === 'undefined' ? 'undefined' : _typeof(fn))); + } + return { + id: id, + fn: fn, + name: name, + target: target, + stage: stage + }; +} + +function isEventEmitalbe(_ref2) { + var id = _ref2.id, + name = _ref2.name; + + if (!name || !isString(name) || secondaryReg$1.test(name)) { + Log.error('You must provide a legal event name, which is string and could not started with before/after/_'); + return false; + } + if (!id || !isString(id)) { + Log.error('You must provide the id of emitter'); + return false; + } + return true; +} + +function checkEventEmitParameter(info) { + // $FlowFixMe: the info match requirement here + info.target = getEventInfo(info).target; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return [info].concat(_toConsumableArray(args)); +} + +var Binder = (_dec$6 = before(prettifyEventParameter), _dec2$5 = before(prettifyEventParameter), _dec3$4 = before(prettifyEventParameter), _dec4$4 = runnable(isEventEmitalbe), _dec5$3 = before(checkEventEmitParameter), _dec6$2 = runnable(isEventEmitalbe, { + backup: function backup() { + return false; + } +}), _dec7$1 = before(checkEventEmitParameter), _dec8$1 = runnable(isEventEmitalbe), _dec9$1 = before(checkEventEmitParameter), _dec10$1 = runnable(isEventEmitalbe, { + backup: function backup() { + return false; + } +}), _dec11$1 = before(checkEventEmitParameter), (_class$6 = function () { + function Binder(dispatcher) { + _classCallCheck(this, Binder); + + this.__dispatcher = dispatcher; + this.kinds = ['kernel', 'container', 'wrapper', 'video', 'video-dom', 'plugin', 'esFullscreen']; + this.buses = {}; + this.bindedEventNames = {}; + this.bindedEventInfo = {}; + this.pendingEventsInfo = {}; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = _getIterator(this.kinds), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var kind = _step.value; + + this.bindedEventNames[kind] = []; + this.bindedEventInfo[kind] = []; + this.pendingEventsInfo[kind] = []; + this.buses[kind] = new Bus(dispatcher, kind); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + } + + _createClass(Binder, [{ + key: 'on', + value: function on(_ref3) { + var target = _ref3.target, + id = _ref3.id, + name = _ref3.name, + fn = _ref3.fn, + stage = _ref3.stage; + + this._addEventListenerOnTarget({ + name: name, + target: target, + id: id + }); + return this.buses[target].on(id, name, fn, stage); + } + }, { + key: 'off', + value: function off(_ref4) { + var target = _ref4.target, + id = _ref4.id, + name = _ref4.name, + fn = _ref4.fn, + stage = _ref4.stage; + + var ret = this.buses[target].off(id, name, fn, stage); + this._removeEventListenerOnTargetWhenIsUseless({ name: name, target: target }); + return ret; + } + }, { + key: 'once', + value: function once(_ref5) { + var target = _ref5.target, + id = _ref5.id, + name = _ref5.name, + fn = _ref5.fn, + stage = _ref5.stage; + + return this.buses[target].once(id, name, fn, stage); + } + }, { + key: 'emit', + value: function emit(_ref6) { + var _buses$target; + + var target = _ref6.target, + name = _ref6.name; + + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + return (_buses$target = this.buses[target]).emit.apply(_buses$target, [name].concat(_toConsumableArray(args))); + } + }, { + key: 'emitSync', + value: function emitSync(_ref7) { + var _buses$target2; + + var target = _ref7.target, + name = _ref7.name; + + for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + return (_buses$target2 = this.buses[target]).emitSync.apply(_buses$target2, [name].concat(_toConsumableArray(args))); + } + }, { + key: 'trigger', + value: function trigger(_ref8) { + var _buses$target3; + + var target = _ref8.target, + name = _ref8.name; + + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + return (_buses$target3 = this.buses[target]).trigger.apply(_buses$target3, [name].concat(_toConsumableArray(args))); + } + }, { + key: 'triggerSync', + value: function triggerSync(_ref9) { + var _buses$target4; + + var target = _ref9.target, + name = _ref9.name; + + for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { + args[_key5 - 1] = arguments[_key5]; + } + + return (_buses$target4 = this.buses[target]).triggerSync.apply(_buses$target4, [name].concat(_toConsumableArray(args))); + } + + // when we create a penetrate plugin, we need to rebind video events on it + + }, { + key: 'bindEventOnPenetrateNode', + value: function bindEventOnPenetrateNode(node) { + var _this = this; + + var remove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + this.bindedEventInfo['video-dom'].forEach(function (_ref10) { + var _ref11 = _slicedToArray(_ref10, 2), + name = _ref11[0], + fn = _ref11[1]; + + remove ? removeEvent(node, name, fn) : _this._addEventOnDom(node, name, fn); + }); + } + + // when we switch kernel, we will create a new video. + // we need to transfer the event from the oldvideo to it. + + }, { + key: 'bindEventOnVideo', + value: function bindEventOnVideo(node) { + var _this2 = this; + + var remove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + this.bindedEventInfo['video-dom'].concat(this.bindedEventInfo.video).forEach(function (_ref12) { + var _ref13 = _slicedToArray(_ref12, 2), + name = _ref13[0], + fn = _ref13[1]; + + remove ? removeEvent(node, name, fn) : _this2._addEventOnDom(node, name, fn); + }); + } + + // As penetrate plugin is considered to be part of video + // we need to transfer event for it + // so we need some specail event handler + + }, { + key: 'listenOnMouseMoveEvent', + value: function listenOnMouseMoveEvent(node) { + var _this3 = this; + + var dom = this.__dispatcher.dom; + var target = 'video-dom'; + var id = '_vm'; + mustListenVideoDomEvents.forEach(function (name) { + var fn = function fn() { + for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; + } + + var _args$ = args[0], + toElement = _args$.toElement, + currentTarget = _args$.currentTarget, + relatedTarget = _args$.relatedTarget, + type = _args$.type; + + var to = toElement || relatedTarget; + // As we support penetrate plugin, the video dom event may be differnet. + if (dom.mouseInVideo && type === 'mouseleave' && !dom.isNodeInsideVideo(to)) { + dom.mouseInVideo = false; + return _this3.triggerSync.apply(_this3, [{ + target: target, + name: name, + id: id + }].concat(args)); + } + if (!dom.mouseInVideo && type === 'mouseenter' && dom.isNodeInsideVideo(currentTarget)) { + dom.mouseInVideo = true; + return _this3.triggerSync.apply(_this3, [{ + target: target, + name: name, + id: id + }].concat(args)); + } + }; + _this3._addEventOnDom(node, name, fn); + // this function is only used once now + // so we do not cover this branch + // but we still keep this judegement + /* istanbul ignore else */ + if (_this3.bindedEventNames[target].indexOf(name) < 0) { + _this3.bindedEventNames[target].push(name); + // $FlowFixMe: fn must be function now + _this3.bindedEventInfo[target].push([name, fn]); + } + }); + } + + // When we switch kernel, we need to rebind the events + + }, { + key: 'migrateKernelEvent', + value: function migrateKernelEvent(oldKernel, newKernel) { + var bindedEventInfoList = this.bindedEventInfo.kernel; + bindedEventInfoList.forEach(function (_ref14) { + var _ref15 = _slicedToArray(_ref14, 2), + name = _ref15[0], + fn = _ref15[1]; + + oldKernel.off(name, fn); + newKernel.on(name, fn); + }); + } + + // when we destroy, we remove all binder + + }, { + key: 'destroy', + value: function destroy() { + var _this4 = this; + + this.kinds.forEach(function (target) { + if (target === 'kernel') { + _this4.bindedEventInfo.kernel.forEach(function (_ref16) { + var _ref17 = _slicedToArray(_ref16, 2), + name = _ref17[0], + fn = _ref17[1]; + + _this4.__dispatcher.kernel.off(name, fn); + }); + } else { + var targetDom = _this4._getTargetDom(target); + _this4.bindedEventInfo[target].forEach(function (_ref18) { + var _ref19 = _slicedToArray(_ref18, 2), + name = _ref19[0], + fn = _ref19[1]; + + removeEvent(targetDom, name, fn); + + if (target === 'video-dom') { + _this4.__dispatcher.dom.videoExtendedNodes.forEach(function (node) { + return removeEvent(node, name, fn); + }); + } + }); + } + _this4.bindedEventInfo.kernel = []; + _this4.bindedEventNames.kernel = []; + }); + } + }, { + key: '_addEventOnDom', + value: function _addEventOnDom(element, key, fn) { + if (passiveEvents.indexOf(key) > -1) { + return addEvent(element, key, fn, false, { passive: true }); + } + addEvent(element, key, fn); + } + + // Some event needs us to transfer it from the real target + // such as dom event + + }, { + key: '_addEventListenerOnTarget', + value: function _addEventListenerOnTarget(_ref20) { + var _this5 = this; + + var name = _ref20.name, + target = _ref20.target, + id = _ref20.id; + + if (!this._isEventNeedToBeHandled(target, name)) return; + var fn = void 0; + // if this event has been binded, return; + if (this.bindedEventNames[target].indexOf(name) > -1) return; + var targetDom = this._getTargetDom(target); + // choose the correspond method to bind + if (target === 'kernel') { + if (!this.__dispatcher.kernel) { + this.addPendingEvent(target, name, id); + return; + } + fn = function fn() { + for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { + args[_key7] = arguments[_key7]; + } + + return _this5.triggerSync.apply(_this5, [{ target: target, name: name, id: 'kernel' }].concat(args)); + }; + this.__dispatcher.kernel.on(name, fn); + } else if (target === 'container' || target === 'wrapper') { + fn = function fn() { + for (var _len8 = arguments.length, args = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { + args[_key8] = arguments[_key8]; + } + + return _this5.triggerSync.apply(_this5, [{ target: target, name: name, id: target }].concat(args)); + }; + this._addEventOnDom(targetDom, name, fn); + } else if (target === 'video') { + fn = function fn() { + for (var _len9 = arguments.length, args = Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + args[_key9] = arguments[_key9]; + } + + return _this5.trigger.apply(_this5, [{ target: target, name: name, id: target }].concat(args)); + }; + this._addEventOnDom(targetDom, name, fn); + } else if (target === 'video-dom') { + fn = function fn() { + for (var _len10 = arguments.length, args = Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { + args[_key10] = arguments[_key10]; + } + + return _this5.triggerSync.apply(_this5, [{ target: target, name: name, id: target }].concat(args)); + }; + this.__dispatcher.dom.videoExtendedNodes.forEach(function (node) { + return _this5._addEventOnDom(node, name, fn); + }); + this._addEventOnDom(targetDom, name, fn); + } + this.bindedEventNames[target].push(name); + // $FlowFixMe: fn must be function now + this.bindedEventInfo[target].push([name, fn]); + } + + // when we off one event, we can remove the useless binder + // actually we should remove on once event too + // but it seems ugliy + // TODO: add this function on once event too + + }, { + key: '_removeEventListenerOnTargetWhenIsUseless', + value: function _removeEventListenerOnTargetWhenIsUseless(_ref21) { + var name = _ref21.name, + target = _ref21.target; + + if (!this._isEventNeedToBeHandled(target, name)) return; + var eventNamesList = this.bindedEventNames[target]; + var nameIndex = eventNamesList.indexOf(name); + // if we have not bind this event before, we omit it + if (nameIndex < 0) return; + // if the buses still have another function on bind, we do not need to remove the binder + if (!isEmpty(this.buses[target].events[name])) return; + + // we fetch the binded function from bindedEventInfo + var bindedEventInfoList = this.bindedEventInfo[target]; + var fn = void 0; + var index = void 0; + for (index = 0; index < bindedEventInfoList.length; index++) { + if (bindedEventInfoList[index][0] === name) { + fn = bindedEventInfoList[index][1]; + break; + } + } + if (!isFunction(fn)) return; + + if (target === 'kernel') { + this.__dispatcher.kernel.off(name, fn); + } else { + var targetDom = this._getTargetDom(target); + + removeEvent(targetDom, name, fn); + + // When we remove something on video dom, we also need to remove event on penetrate plugin + if (target === 'video-dom') { + this.__dispatcher.dom.videoExtendedNodes.forEach(function (node) { + // $FlowFixMe: fn is function now + removeEvent(node, name, fn); + }); + } + } + + bindedEventInfoList.splice(index, 1); + eventNamesList.splice(nameIndex, 1); + } + }, { + key: '_getTargetDom', + value: function _getTargetDom(target) { + var targetDom = void 0; + switch (target) { + case 'container': + case 'wrapper': + // $FlowFixMe: fix dom index bug + targetDom = this.__dispatcher.dom[target]; + break; + default: + targetDom = this.__dispatcher.dom.videoElement; + break; + } + return targetDom; + } + }, { + key: '_isEventNeedToBeHandled', + value: function _isEventNeedToBeHandled(target, name) { + // the plugin target do not need us to transfer + // we have listened on esFullscreen in dom + // we have listened mustListenVideoDomEvents + // so the events above do not need to rebind + return target !== 'plugin' && target !== 'esFullscreen' && (mustListenVideoDomEvents.indexOf(name) < 0 || target !== 'video'); + } + }, { + key: 'addPendingEvent', + value: function addPendingEvent(target, name, id) { + this.pendingEventsInfo[target].push([name, id]); + } + }, { + key: 'applyPendingEvents', + value: function applyPendingEvents(target) { + var pendingEvents = this.pendingEventsInfo[target]; + var pendingEventsCopy = pendingEvents.splice(0, pendingEvents.length); + while (pendingEventsCopy.length) { + var _pendingEventsCopy$po = pendingEventsCopy.pop(), + _pendingEventsCopy$po2 = _slicedToArray(_pendingEventsCopy$po, 2), + _name2 = _pendingEventsCopy$po2[0], + id = _pendingEventsCopy$po2[1]; + + this._addEventListenerOnTarget({ name: _name2, target: target, id: id }); + } + } + }]); + + return Binder; +}(), (_applyDecoratedDescriptor$5(_class$6.prototype, 'on', [_dec$6], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'on'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'off', [_dec2$5], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'off'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'once', [_dec3$4], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'once'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'emit', [_dec4$4, _dec5$3], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'emit'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'emitSync', [_dec6$2, _dec7$1], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'emitSync'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'trigger', [_dec8$1, _dec9$1], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'trigger'), _class$6.prototype), _applyDecoratedDescriptor$5(_class$6.prototype, 'triggerSync', [_dec10$1, _dec11$1], _Object$getOwnPropertyDescriptor(_class$6.prototype, 'triggerSync'), _class$6.prototype)), _class$6)); + +var _dec$7, _dec2$6, _dec3$5, _dec4$5, _dec5$4, _class$7; + +function _applyDecoratedDescriptor$6(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +var pluginConfigSet = {}; +var kernelsSet = {}; +function convertNameIntoId(name) { + if (!isString(name)) throw new Error('Plugin\'s name must be a string, but not "' + name + '" in ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + return camelize(name); +} +function checkPluginConfig(config) { + if (isFunction(config)) { + if (!(config.prototype instanceof Plugin)) { + throw new TypeError('Your are trying to install plugin ' + config.name + ', but it\'s not extends from Chimee.plugin.'); + } + return; + } + if (!isObject(config) || isEmpty(config)) throw new TypeError('plugin\'s config must be an Object, but not "' + config + '" in ' + (typeof config === 'undefined' ? 'undefined' : _typeof(config))); + var name = config.name; + + if (!isString(name) || name.length < 1) throw new TypeError('plugin must have a legal namea, but not "' + name + '" in ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); +} +/** + *
+ * Dispatcher is the hub of plugins, user, and video kernel.
+ * It take charge of plugins install, use and remove
+ * It also offer a bridge to let user handle video kernel.
+ * 
+ */ +var Dispatcher = (_dec$7 = before(convertNameIntoId), _dec2$6 = before(checkPluginConfig), _dec3$5 = before(convertNameIntoId), _dec4$5 = before(convertNameIntoId), _dec5$4 = before(convertNameIntoId), (_class$7 = function () { + /** + * @param {UserConfig} config UserConfig for whole Chimee player + * @param {Chimee} vm referrence of outer class + * @return {Dispatcher} + */ + + /** + * the synchronous ready flag + * @type {boolean} + * @member readySync + */ + + /** + * all plugins instance set + * @type {Object} + * @member plugins + */ + function Dispatcher(config, vm) { + var _this = this; + + _classCallCheck(this, Dispatcher); + + this.plugins = {}; + this.order = []; + this.readySync = false; + this.zIndexMap = { + inner: [], + outer: [] + }; + this.changeWatchable = true; + this.kernelEventHandlerList = []; + + if (!isObject(config)) throw new TypeError('UserConfig must be an Object, but not "' + config + '" in ' + (typeof config === 'undefined' ? 'undefined' : _typeof(config))); + /** + * dom Manager + * @type {Dom} + */ + this.dom = new Dom(config, this); + /** + * Chimee's referrence + * @type {[type]} + */ + this.vm = vm; + /** + * tell user have Chimee installed finished + * @type {Promises} + */ + this.videoConfigReady = false; + // create the videoconfig + this.videoConfig = new VideoConfig(this, config); + // support both plugin and plugins here as people often cofuse both + // $FlowFixMe: we support plugins here, which should be illegal + if (isArray(config.plugins) && !isArray(config.plugin)) { + config.plugin = config.plugins; + delete config.plugins; + } + this.binder = new Binder(this); + this.binder.listenOnMouseMoveEvent(this.dom.videoElement); + // use the plugin user want to use + this._initUserPlugin(config.plugin); + // add default config for container + var containerConfig = deepAssign({}, defaultContainerConfig, config.container || {}); + // trigger the init life hook of plugin + this.order.forEach(function (key) { + return _this.plugins[key].__init(_this.videoConfig, containerConfig); + }); + this.videoConfigReady = true; + this.videoConfig.init(); + this.containerConfig = new Vessel(this, 'container', containerConfig); + /** + * video kernel + * @type {Kernel} + */ + this.kernel = this._createKernel(this.dom.videoElement, this.videoConfig); + this.binder.applyPendingEvents('kernel'); + if (config.noDefaultContextMenu) { + var noDefaultContextMenu = config.noDefaultContextMenu; + + var target = noDefaultContextMenu === 'container' || noDefaultContextMenu === 'wrapper' ? noDefaultContextMenu : 'video-dom'; + this.binder.on({ + target: target, + id: '_vm', + name: 'contextmenu', + fn: function fn(evt) { + return evt.preventDefault(); + }, + stage: 'main' + }); + } + // trigger auto load event + var asyncInitedTasks = []; + this.order.forEach(function (key) { + var ready = _this.plugins[key].__inited(); + if (isPromise(ready)) { + asyncInitedTasks.push(ready); + } + }); + this.readySync = asyncInitedTasks.length === 0; + // tell them we have inited the whold player + this.ready = this.readySync ? _Promise.resolve() : _Promise.all(asyncInitedTasks).then(function () { + _this.readySync = true; + _this.onReady(); + }); + if (this.readySync) this.onReady(); + } + // to save the kernel event handler, so that we can remove it when we destroy the kernel + + /** + * the z-index map of the dom, it contain some important infomation + * @type {Object} + * @member zIndexMap + */ + + /** + * plugin's order + * @type {Array} + * @member order + */ + + + _createClass(Dispatcher, [{ + key: 'onReady', + value: function onReady() { + this.binder.trigger({ + target: 'plugin', + name: 'ready', + id: 'dispatcher' + }); + this._autoloadVideoSrcAtFirst(); + } + + /** + * use a plugin, which means we will new a plugin instance and include int this Chimee instance + * @param {Object|string} option you can just set a plugin name or plugin config + * @return {Promise} + */ + + }, { + key: 'use', + value: function use(option) { + if (isString(option)) option = { name: option, alias: undefined }; + if (!isObject(option) || isObject(option) && !isString(option.name)) { + throw new TypeError('pluginConfig do not match requirement'); + } + if (!isString(option.alias)) option.alias = undefined; + var _option = option, + name = _option.name, + alias$$1 = _option.alias; + + option.name = alias$$1 || name; + delete option.alias; + var key = camelize(name); + var id = camelize(alias$$1 || name); + var pluginOption = option; + var pluginConfig = Dispatcher.getPluginConfig(key); + if (isEmpty(pluginConfig)) throw new TypeError('You have not installed plugin ' + key); + if (isObject(pluginConfig)) { + pluginConfig.id = id; + } + var plugin = isFunction(pluginConfig) ? new pluginConfig({ id: id }, this, pluginOption) // eslint-disable-line + : new Plugin(pluginConfig, this, pluginOption); + this.plugins[id] = plugin; + _Object$defineProperty(this.vm, id, { + value: plugin, + configurable: true, + enumerable: false, + writable: false + }); + this.order.push(id); + this._sortZIndex(); + if (this.videoConfigReady) plugin.__inited(); + return plugin.ready; + } + + /** + * unuse an plugin, we will destroy the plugin instance and exlude it + * @param {string} name plugin's name + */ + + }, { + key: 'unuse', + value: function unuse(id) { + var plugin = this.plugins[id]; + if (!isObject(plugin) || !isFunction(plugin.$destroy)) { + delete this.plugins[id]; + return; + } + plugin.$destroy(); + var orderIndex = this.order.indexOf(id); + if (orderIndex > -1) { + this.order.splice(orderIndex, 1); + } + delete this.plugins[id]; + delete this.vm[id]; + } + }, { + key: 'throwError', + value: function throwError(error) { + this.vm.__throwError(error); + } + }, { + key: 'silentLoad', + value: function silentLoad(src) { + var _this2 = this; + + var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var _option$duration = option.duration, + duration = _option$duration === undefined ? 3 : _option$duration, + _option$bias = option.bias, + bias = _option$bias === undefined ? 0 : _option$bias, + _option$repeatTimes = option.repeatTimes, + repeatTimes = _option$repeatTimes === undefined ? 0 : _option$repeatTimes, + _option$increment = option.increment, + increment = _option$increment === undefined ? 0 : _option$increment, + _option$isLive = option.isLive, + isLive = _option$isLive === undefined ? this.videoConfig.isLive : _option$isLive, + _option$box = option.box, + box = _option$box === undefined ? this.videoConfig.box : _option$box, + _option$kernels = option.kernels, + kernels = _option$kernels === undefined ? this.videoConfig.kernels : _option$kernels, + _option$preset = option.preset, + preset = _option$preset === undefined ? this.videoConfig.preset : _option$preset; + // all live stream seem as immediate mode + // it's impossible to seek on live stream + + var immediate = option.immediate || isLive; + // form the base config for kernel + // it should be the same as the config now + var config = { isLive: isLive, box: box, src: src, kernels: kernels, preset: preset }; + // build tasks accroding repeat times + var tasks = new Array(repeatTimes + 1).fill(1).map(function (value, index) { + return function () { + return new _Promise(function (resolve, reject) { + // if abort, give up and reject + if (option.abort) reject({ error: true, message: 'user abort the mission' }); + var video = document.createElement('video'); + var idealTime = _this2.kernel.currentTime + duration + increment * index; + video.muted = true; + var newVideoReady = false; + var kernel = void 0; + var _videoError = void 0; + var videoCanplay = void 0; + var videoLoadedmetadata = void 0; + // bind time update on old video + // when we bump into the switch point and ready + // we switch + var oldVideoTimeupdate = function oldVideoTimeupdate() { + var currentTime = _this2.kernel.currentTime; + if (bias <= 0 && currentTime >= idealTime || bias > 0 && (Math.abs(idealTime - currentTime) <= bias && newVideoReady || currentTime - idealTime > bias)) { + removeEvent(_this2.dom.videoElement, 'timeupdate', oldVideoTimeupdate); + removeEvent(video, 'error', _videoError, true); + if (!newVideoReady) { + removeEvent(video, 'canplay', videoCanplay, true); + removeEvent(video, 'loadedmetadata', videoLoadedmetadata, true); + kernel.destroy(); + return resolve(); + } + return reject({ + error: false, + video: video, + kernel: kernel + }); + } + }; + videoCanplay = function videoCanplay() { + newVideoReady = true; + // you can set it immediately run by yourself + if (immediate) { + removeEvent(_this2.dom.videoElement, 'timeupdate', oldVideoTimeupdate); + removeEvent(video, 'error', _videoError, true); + return reject({ + error: false, + video: video, + kernel: kernel + }); + } + }; + videoLoadedmetadata = function videoLoadedmetadata() { + if (!isLive) { + kernel.seek(immediate ? _this2.kernel.currentTime : idealTime); + } + }; + _videoError = function videoError(evt) { + removeEvent(video, 'canplay', videoCanplay, true); + removeEvent(video, 'loadedmetadata', videoLoadedmetadata, true); + removeEvent(_this2.dom.videoElement, 'timeupdate', oldVideoTimeupdate); + kernel.off('error', _videoError); + var error = void 0; + if (!isEmpty(evt.data) && evt.data.errmsg) { + var errmsg = evt.data.errmsg; + + Log.error("chimee's silentload bump into a kernel error", errmsg); + error = new Error(errmsg); + } else { + error = !isEmpty(video.error) ? new Error(video.error.message) : new Error('unknow video error'); + Log.error("chimee's silentload", error.message); + } + kernel.destroy(); + _this2._silentLoadTempKernel = undefined; + return index === repeatTimes ? reject(error) : resolve(error); + }; + addEvent(video, 'canplay', videoCanplay, true); + addEvent(video, 'loadedmetadata', videoLoadedmetadata, true); + addEvent(video, 'error', _videoError, true); + kernel = _this2._createKernel(video, config); + _this2._silentLoadTempKernel = kernel; + kernel.on('error', _videoError); + addEvent(_this2.dom.videoElement, 'timeupdate', oldVideoTimeupdate); + kernel.load(); + }); + }; + }); + return runRejectableQueue(tasks).then(function () { + var message = 'The silentLoad for ' + src + ' timed out. Please set a longer duration or check your network'; + /* istanbul ignore else */ + { + Log.warn("chimee's silentLoad", message); + } + return _Promise.reject(new Error(message)); + }).catch(function (data) { + if (isError(data)) { + return _Promise.reject(data); + } + if (data.error) { + /* istanbul ignore else */ + { + Log.warn("chimee's silentLoad", data.message); + } + return _Promise.reject(new Error(data.message)); + } + var video = data.video, + kernel = data.kernel; + + if (option.abort) { + kernel.destroy(); + return _Promise.reject(new Error('user abort the mission')); + } + var paused = _this2.dom.videoElement.paused; + if (paused) { + _this2.switchKernel({ video: video, kernel: kernel, config: config }); + return _Promise.resolve(); + } + return new _Promise(function (resolve) { + addEvent(video, 'play', function () { + _this2.switchKernel({ video: video, kernel: kernel, config: config }); + resolve(); + }, true); + video.play(); + }); + }); + } + }, { + key: 'load', + value: function load(srcOrOption) { + var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var src = isString(srcOrOption) ? srcOrOption : isObject(srcOrOption) && isString(srcOrOption.src) ? srcOrOption.src + // give a chance for user to clear the src + : ''; + if (isObject(srcOrOption)) { + delete srcOrOption.src; + option = srcOrOption; + } + var oldBox = this.kernel.box; + var videoConfig = this.videoConfig; + var _option2 = option, + _option2$isLive = _option2.isLive, + isLive = _option2$isLive === undefined ? videoConfig.isLive : _option2$isLive, + _option2$box = _option2.box, + box = _option2$box === undefined ? getLegalBox({ src: src, box: videoConfig.box }) : _option2$box, + _option2$preset = _option2.preset, + preset = _option2$preset === undefined ? videoConfig.preset : _option2$preset, + _option2$kernels = _option2.kernels, + kernels = _option2$kernels === undefined ? videoConfig.kernels : _option2$kernels; + + if (box !== 'native' || box !== oldBox || !isEmpty(option)) { + var video = document.createElement('video'); + var config = { isLive: isLive, box: box, preset: preset, src: src, kernels: kernels }; + var kernel = this._createKernel(video, config); + this.switchKernel({ video: video, kernel: kernel, config: config, notifyChange: true }); + } + var originAutoLoad = this.videoConfig.autoload; + this._changeUnwatchable(this.videoConfig, 'autoload', false); + this.videoConfig.src = src || this.videoConfig.src; + this.kernel.load(this.videoConfig.src); + this._changeUnwatchable(this.videoConfig, 'autoload', originAutoLoad); + } + }, { + key: 'switchKernel', + value: function switchKernel(_ref) { + var _this3 = this; + + var video = _ref.video, + kernel = _ref.kernel, + config = _ref.config, + notifyChange = _ref.notifyChange; + + var oldKernel = this.kernel; + var originVideoConfig = deepClone(this.videoConfig); + this.dom.migrateVideoRequiredGuardedAttributes(video); + this.dom.removeVideo(); + this.dom.installVideo(video); + // as we will reset the currentVideoConfig on the new video + // it will trigger the watch function as they maybe differnet + // because video config will return the real situation + // so we need to stop them + this.videoConfig.changeWatchable = false; + this.videoConfig.autoload = false; + this.videoConfig.src = config.src; + this.videoConfig._realDomAttr.forEach(function (key) { + // $FlowFixMe: support computed key here + if (key !== 'src') _this3.videoConfig[key] = originVideoConfig[key]; + }); + this.videoConfig.changeWatchable = true; + this.binder.migrateKernelEvent(oldKernel, kernel); + this.kernel = kernel; + this._silentLoadTempKernel = undefined; + var isLive = config.isLive, + box = config.box, + preset = config.preset, + kernels = config.kernels; + + _Object$assign(this.videoConfig, { isLive: isLive, box: box, preset: preset, kernels: kernels }); + oldKernel.destroy(); + // delay video event binding + // so that people can't feel the default value change + // unless it's caused by autoload + if (notifyChange) { + this.binder && this.binder.bindEventOnVideo && this.binder.bindEventOnVideo(video); + } else { + setTimeout(function () { + _this3.binder && _this3.binder.bindEventOnVideo && _this3.binder.bindEventOnVideo(video); + }); + } + } + + /** + * destroy function called when dispatcher destroyed + */ + + }, { + key: 'destroy', + value: function destroy() { + for (var _key in this.plugins) { + this.unuse(_key); + } + this.binder.destroy(); + delete this.binder; + this.dom.destroy(); + delete this.dom; + this.kernel.destroy(); + delete this.kernel; + delete this.vm; + delete this.plugins; + delete this.order; + } + + /** + * use a set of plugin + * @param {Array} configs a set of plugin config + * @return {Array} a set of Promise indicate the plugin install stage + */ + + }, { + key: '_initUserPlugin', + value: function _initUserPlugin() { + var _this4 = this; + + var configs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (!isArray(configs)) { + /* istanbul ignore else */ + Log.warn('Dispatcher', 'UserConfig.plugin can only by an Array, but not "' + configs + '" in ' + (typeof configs === 'undefined' ? 'undefined' : _typeof(configs))); + configs = []; + } + return configs.map(function (config) { + return _this4.use(config); + }); + } + + /** + * sort zIndex of plugins to make plugin display in order + */ + + }, { + key: '_sortZIndex', + value: function _sortZIndex() { + var _this5 = this; + + var _order$reduce = this.order.reduce(function (levelSet, key) { + var plugin = _this5.plugins[key]; + if (isEmpty(plugin)) return levelSet; + var set = levelSet[plugin.$inner ? 'inner' : 'outer']; + var level = plugin.$level; + set[level] = set[level] || []; + set[level].push(key); + return levelSet; + }, { inner: {}, outer: {} }), + inner = _order$reduce.inner, + outer = _order$reduce.outer; + + inner[0] = inner[0] || []; + inner[0].unshift('videoElement'); + outer[0] = outer[0] || []; + outer[0].unshift('container'); + var innerOrderArr = transObjectAttrIntoArray(inner); + var outerOrderArr = transObjectAttrIntoArray(outer); + this.dom.setPluginsZIndex(innerOrderArr); + this.dom.setPluginsZIndex(outerOrderArr); + this.zIndexMap.inner = innerOrderArr; + this.zIndexMap.outer = outerOrderArr; + } + + /** + * get the top element's level + * @param {boolean} inner get the inner array or the outer array + */ + + }, { + key: '_getTopLevel', + value: function _getTopLevel(inner) { + var arr = this.zIndexMap[inner ? 'inner' : 'outer']; + var plugin = this.plugins[arr[arr.length - 1]]; + return isEmpty(plugin) ? 0 : plugin.$level; + } + }, { + key: '_autoloadVideoSrcAtFirst', + value: function _autoloadVideoSrcAtFirst() { + if (this.videoConfig.autoload) { + if (!this.videoConfig.src) { + Log.warn('You have not set the src, so you better set autoload to be false. Accroding to https://github.com/Chimeejs/chimee/blob/master/doc/zh-cn/chimee-api.md#src.'); + return; + } + this.binder.emit({ + name: 'load', + target: 'plugin', + id: 'dispatcher' + }, { src: this.videoConfig.src }); + } + } + }, { + key: '_changeUnwatchable', + value: function _changeUnwatchable(object, property, value) { + this.changeWatchable = false; + object[property] = value; + this.changeWatchable = true; + } + }, { + key: '_createKernel', + value: function _createKernel(video, config) { + var kernels = config.kernels, + preset = config.preset; + /* istanbul ignore else */ + + if (isEmpty(kernels) && !isEmpty(preset)) Log.warn('preset will be deprecated in next major version, please use kernels instead.'); + var presetConfig = {}; + var newPreset = {}; + if (isArray(kernels)) { + // SKC means SingleKernelConfig + newPreset = kernels.reduce(function (kernels, keyOrSKC) { + // if it is a string key, it means the kernel has been pre installed. + if (isString(keyOrSKC)) { + var kernelFn = kernelsSet[keyOrSKC]; + if (!isFunction(kernelFn)) { + Log.warn('You have not installed kernel for ' + keyOrSKC + '.'); + return kernels; + } + kernels[keyOrSKC] = kernelFn; + return kernels; + } + // if it is a SingleKernelConfig, it means user may pass in some config here + // so we need to extract the handler + // get the name of the handler + // and collect the config for the handler + if (isObject(keyOrSKC)) { + var name = keyOrSKC.name, + handler = keyOrSKC.handler; + // if the handler is a pure string, it means the kernel has been pre installed + + if (isString(handler)) { + var _kernelFn = kernelsSet[handler]; + if (!isFunction(_kernelFn)) { + Log.warn('You have not installed kernel for ' + handler + '.'); + return kernels; + } + kernels[handler] = _kernelFn; + presetConfig[handler] = keyOrSKC; + return kernels; + } + // if the handler is a function, it means that the user pass in the kernel directly + // if the provide name, we use it as kernel name + // if they do not provide name, we just use the function's name + if (isFunction(handler)) { + var kernelName = name || handler.name; + kernels[kernelName] = handler; + presetConfig[kernelName] = keyOrSKC; + return kernels; + } + Log.warn('When you pass in an SingleKernelConfig in Array, you must clarify it\'s handler, we only support handler in string or function but not ' + (typeof handler === 'undefined' ? 'undefined' : _typeof(handler))); + return kernels; + } + Log.warn('If you pass in kernels as array, you must pass in kernels in string or function, but not ' + (typeof keyOrSKC === 'undefined' ? 'undefined' : _typeof(keyOrSKC))); + return kernels; + }, {}); + } + + if (isObject(kernels)) { + // SKC means SingleKernelConfig + _Object$keys(kernels).forEach(function (key) { + var fnOrSKC = kernels[key]; + // if it's a function, means we need to do nothing + if (isFunction(fnOrSKC)) { + newPreset[key] = fnOrSKC; + return; + } + if (isObject(fnOrSKC)) { + var handler = fnOrSKC.handler; + // if handler is an string, it means user has pre install it + + if (isString(handler)) { + var kernelFn = kernelsSet[handler]; + if (!isFunction(kernelFn)) { + Log.warn('You have not installed kernel for ' + handler + '.'); + return; + } + newPreset[key] = kernelFn; + presetConfig[key] = fnOrSKC; + return; + } + if (isFunction(handler)) { + newPreset[key] = handler; + presetConfig[key] = fnOrSKC; + return; + } + Log.warn('When you pass in an SingleKernelConfig in Object, you must clarify it\'s handler, we only support handler in string or function but not ' + (typeof handler === 'undefined' ? 'undefined' : _typeof(handler))); + return; + } + Log.warn('If you pass in kernels as object, you must pass in kernels in string or function, but not ' + (typeof fnOrSKC === 'undefined' ? 'undefined' : _typeof(fnOrSKC))); + return kernels; + }); + } + config.preset = _Object$assign(newPreset, preset); + config.presetConfig = presetConfig; + var kernel = new ChimeeKernel(video, config); + return kernel; + } + /** + * static method to install plugin + * we will store the plugin config + * @type {string} plugin's id + */ + + }], [{ + key: 'install', + value: function install(config) { + var name = config.name; + + var id = camelize(name); + if (!isEmpty(pluginConfigSet[id])) { + /* istanbul ignore else */ + Log.warn('Dispatcher', 'You have installed ' + name + ' again. And the older one will be replaced'); + } + var pluginConfig = isFunction(config) ? config : deepAssign({ id: id }, config); + pluginConfigSet[id] = pluginConfig; + return id; + } + }, { + key: 'hasInstalled', + value: function hasInstalled(id) { + return !isEmpty(pluginConfigSet[id]); + } + }, { + key: 'uninstall', + value: function uninstall(id) { + delete pluginConfigSet[id]; + } + /** + * get Plugin config based on plugin's id + * @type {[type]} + */ + + }, { + key: 'getPluginConfig', + value: function getPluginConfig(id) { + return pluginConfigSet[id]; + } + }, { + key: 'installKernel', + value: function installKernel(key, value) { + var tasks = isObject(key) ? _Object$entries(key) : [[key, value]]; + tasks.forEach(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + key = _ref3[0], + value = _ref3[1]; + + if (!isFunction(value)) throw new Error('The kernel you install on ' + key + ' must be a Function, but not ' + (typeof value === 'undefined' ? 'undefined' : _typeof(value))); + if (isFunction(kernelsSet[key])) Log.warn('You have alrady install a kernel on ' + key + ', and now we will replace it'); + kernelsSet[key] = value; + }); + } + + // only use for debug in internal + + }, { + key: 'uninstallKernel', + value: function uninstallKernel(key) { + delete kernelsSet[key]; + } + }, { + key: 'hasInstalledKernel', + value: function hasInstalledKernel(key) { + return isFunction(kernelsSet[key]); + } + }]); + + return Dispatcher; +}(), (_applyDecoratedDescriptor$6(_class$7.prototype, 'unuse', [_dec$7], _Object$getOwnPropertyDescriptor(_class$7.prototype, 'unuse'), _class$7.prototype), _applyDecoratedDescriptor$6(_class$7.prototype, 'throwError', [autobind], _Object$getOwnPropertyDescriptor(_class$7.prototype, 'throwError'), _class$7.prototype), _applyDecoratedDescriptor$6(_class$7, 'install', [_dec2$6], _Object$getOwnPropertyDescriptor(_class$7, 'install'), _class$7), _applyDecoratedDescriptor$6(_class$7, 'hasInstalled', [_dec3$5], _Object$getOwnPropertyDescriptor(_class$7, 'hasInstalled'), _class$7), _applyDecoratedDescriptor$6(_class$7, 'uninstall', [_dec4$5], _Object$getOwnPropertyDescriptor(_class$7, 'uninstall'), _class$7), _applyDecoratedDescriptor$6(_class$7, 'getPluginConfig', [_dec5$4], _Object$getOwnPropertyDescriptor(_class$7, 'getPluginConfig'), _class$7)), _class$7)); + +var _class$8, _descriptor$1; + +function _initDefineProp$1(target, property, descriptor, context) { + if (!descriptor) return; + + _Object$defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor$7(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} +var GlobalConfig = (_class$8 = function () { + _createClass(GlobalConfig, [{ + key: 'silent', + get: function get() { + return this._silent; + }, + set: function set(val) { + var _this = this; + + val = !!val; + this._silent = val; + _Object$keys(this.log).forEach(function (key) { + _this.log[key] = !val; + }); + } + }, { + key: 'useStyleFullscreen', + get: function get() { + return index.useStyleFirst; + }, + set: function set(val) { + index.useStyleFirst = !!val; + } + }]); + + function GlobalConfig() { + _classCallCheck(this, GlobalConfig); + + this.log = { + error: true, + info: true, + warn: true, + debug: true, + verbose: true + }; + + _initDefineProp$1(this, '_silent', _descriptor$1, this); + + this.errorHandler = undefined; + + var props = _Object$keys(this.log).reduce(function (props, key) { + props[key] = accessor({ + get: function get() { + // $FlowFixMe: we have check the keys + return Log['ENABLE_' + key.toUpperCase()]; + }, + set: function set(val) { + // $FlowFixMe: we have check the keys + Log['ENABLE_' + key.toUpperCase()] = val; + if (val === true) this.silent = false; + return val; + } + }); + return props; + }, {}); + applyDecorators(this.log, props, { self: true }); + } + + return GlobalConfig; +}(), (_descriptor$1 = _applyDecoratedDescriptor$7(_class$8.prototype, '_silent', [nonenumerable], { + enumerable: true, + initializer: function initializer() { + return false; + } +})), _class$8); + +var _global$1 = createCommonjsModule(function (module) { +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); +if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef +}); + +var _core$1 = createCommonjsModule(function (module) { +var core = module.exports = { version: '2.5.7' }; +if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef +}); +var _core_1$1 = _core$1.version; + +var _isObject$1 = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +var _anObject$1 = function (it) { + if (!_isObject$1(it)) throw TypeError(it + ' is not an object!'); + return it; +}; + +var _fails$1 = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } +}; + +// Thank's IE8 for his funny defineProperty +var _descriptors$1 = !_fails$1(function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; +}); + +var document$3 = _global$1.document; +// typeof document.createElement is 'object' in old IE +var is$1 = _isObject$1(document$3) && _isObject$1(document$3.createElement); +var _domCreate$1 = function (it) { + return is$1 ? document$3.createElement(it) : {}; +}; + +var _ie8DomDefine$1 = !_descriptors$1 && !_fails$1(function () { + return Object.defineProperty(_domCreate$1('div'), 'a', { get: function () { return 7; } }).a != 7; +}); + +// 7.1.1 ToPrimitive(input [, PreferredType]) + +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +var _toPrimitive$1 = function (it, S) { + if (!_isObject$1(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !_isObject$1(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !_isObject$1(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !_isObject$1(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); +}; + +var dP$4 = Object.defineProperty; + +var f$8 = _descriptors$1 ? Object.defineProperty : function defineProperty(O, P, Attributes) { + _anObject$1(O); + P = _toPrimitive$1(P, true); + _anObject$1(Attributes); + if (_ie8DomDefine$1) try { + return dP$4(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; + +var _objectDp$1 = { + f: f$8 +}; + +var _propertyDesc$1 = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; + +var _hide$1 = _descriptors$1 ? function (object, key, value) { + return _objectDp$1.f(object, key, _propertyDesc$1(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; + +var hasOwnProperty$1 = {}.hasOwnProperty; +var _has$1 = function (it, key) { + return hasOwnProperty$1.call(it, key); +}; + +var id$2 = 0; +var px$1 = Math.random(); +var _uid$1 = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id$2 + px$1).toString(36)); +}; + +var _redefine$1 = createCommonjsModule(function (module) { +var SRC = _uid$1('src'); +var TO_STRING = 'toString'; +var $toString = Function[TO_STRING]; +var TPL = ('' + $toString).split(TO_STRING); + +_core$1.inspectSource = function (it) { + return $toString.call(it); +}; + +(module.exports = function (O, key, val, safe) { + var isFunction = typeof val == 'function'; + if (isFunction) _has$1(val, 'name') || _hide$1(val, 'name', key); + if (O[key] === val) return; + if (isFunction) _has$1(val, SRC) || _hide$1(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); + if (O === _global$1) { + O[key] = val; + } else if (!safe) { + delete O[key]; + _hide$1(O, key, val); + } else if (O[key]) { + O[key] = val; + } else { + _hide$1(O, key, val); + } +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +})(Function.prototype, TO_STRING, function toString() { + return typeof this == 'function' && this[SRC] || $toString.call(this); +}); +}); + +var _aFunction$1 = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; +}; + +// optional / simple context binding + +var _ctx$1 = function (fn, that, length) { + _aFunction$1(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; +}; + +var PROTOTYPE$3 = 'prototype'; + +var $export$1 = function (type, name, source) { + var IS_FORCED = type & $export$1.F; + var IS_GLOBAL = type & $export$1.G; + var IS_STATIC = type & $export$1.S; + var IS_PROTO = type & $export$1.P; + var IS_BIND = type & $export$1.B; + var target = IS_GLOBAL ? _global$1 : IS_STATIC ? _global$1[name] || (_global$1[name] = {}) : (_global$1[name] || {})[PROTOTYPE$3]; + var exports = IS_GLOBAL ? _core$1 : _core$1[name] || (_core$1[name] = {}); + var expProto = exports[PROTOTYPE$3] || (exports[PROTOTYPE$3] = {}); + var key, own, out, exp; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + // export native or passed + out = (own ? target : source)[key]; + // bind timers to global for call from export context + exp = IS_BIND && own ? _ctx$1(out, _global$1) : IS_PROTO && typeof out == 'function' ? _ctx$1(Function.call, out) : out; + // extend global + if (target) _redefine$1(target, key, out, type & $export$1.U); + // export + if (exports[key] != out) _hide$1(exports, key, exp); + if (IS_PROTO && expProto[key] != out) expProto[key] = out; + } +}; +_global$1.core = _core$1; +// type bitmap +$export$1.F = 1; // forced +$export$1.G = 2; // global +$export$1.S = 4; // static +$export$1.P = 8; // proto +$export$1.B = 16; // bind +$export$1.W = 32; // wrap +$export$1.U = 64; // safe +$export$1.R = 128; // real proto method for `library` +var _export$1 = $export$1; + +// https://github.com/tc39/proposal-global + + +_export$1(_export$1.G, { global: _global$1 }); + +var global$1 = _core$1.global; + +var _dec$8, _class$9, _class2$2, _descriptor$2, _descriptor2$1, _descriptor3$1, _init, _init2, _init3, _init4, _init5, _init6, _init7, _init8, _init9, _class3, _temp; + +function _initDefineProp$2(target, property, descriptor, context) { + if (!descriptor) return; + + _Object$defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor$8(target, property, decorators, descriptor, context) { + var desc = {}; + Object['ke' + 'ys'](descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object['define' + 'Property'](target, property, desc); + desc = null; + } + + return desc; +} + +var Chimee = (_dec$8 = autobindClass(), _dec$8(_class$9 = (_class2$2 = (_temp = _class3 = function (_VideoWrapper) { + _inherits(Chimee, _VideoWrapper); + + _createClass(Chimee, null, [{ + key: 'registerEvents', + + + // In some situation, we may have custom events + // For example, we may have a custom kernel event + // We can register the event through this method + value: function registerEvents() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + name = _ref.name, + target = _ref.target; + + if (!name || !isString(name)) throw new Error('The event name must be a string, but not ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + if (!target || !isString(target)) throw new Error('The event target must be a string, but not ' + (typeof target === 'undefined' ? 'undefined' : _typeof(target))); + if (target === 'kernel') { + kernelEvents.push(name); + } + } + }]); + + function Chimee(config) { + _classCallCheck(this, Chimee); + + /* istanbul ignore if */ + var _this = _possibleConstructorReturn(this, (Chimee.__proto__ || _Object$getPrototypeOf(Chimee)).call(this)); + + _this.destroyed = false; + + _initDefineProp$2(_this, '__id', _descriptor$2, _this); + + _initDefineProp$2(_this, 'version', _descriptor2$1, _this); + + _initDefineProp$2(_this, 'config', _descriptor3$1, _this); + + if (!global$1.Object.defineProperty) { + /* istanbul ignore next */ + Log.error('Chimee', "We detect that this browser lack of Object.defineProperty. Chimee can't run on this browser"); + } + /* istanbul ignore if */ + if (!global$1.Promise) { + /* istanbul ignore next */ + Log.error('Chimee', 'We detect that this browser lack of Promise. If you are running Chimee in old browser. Please make sure you have import polyfill such as babel-polyfill.'); + } + if (isString(config) || isElement(config)) { + config = { + wrapper: config, + controls: true + }; + } else if (isObject(config)) { + if (!config.wrapper) throw new Error('You must pass in an legal object'); + } else { + throw new Error('You must pass in an Object containing wrapper or string or element to new a Chimee'); + } + // $FlowFixMe: we have check wrapper here + _this.__dispatcher = new Dispatcher(config, _this); + _this.ready = _this.__dispatcher.ready; + _this.readySync = _this.__dispatcher.readySync; + _this.__wrapAsVideo(_this.__dispatcher.videoConfig); + return _this; + } + + _createClass(Chimee, [{ + key: 'destroy', + value: function destroy() { + if (this.destroyed) return; + _get(Chimee.prototype.__proto__ || _Object$getPrototypeOf(Chimee.prototype), '__destroy', this).call(this); + this.__dispatcher.destroy(); + // $FlowFixMe: normal obejct define + Object.defineProperty(this, '__dispatcher', { + get: function get$$1() { + throw new Error('This instance has been destroyed.'); + }, + + enumerable: true, + configurable: true + }); + this.destroyed = true; + } + }, { + key: 'use', + value: function use(option) { + return this.__dispatcher.use(option); + } + }, { + key: 'unuse', + value: function unuse(name) { + return this.__dispatcher.unuse(name); + } + }, { + key: '__throwError', + value: function __throwError(error) { + if (isString(error)) error = new Error(error); + var errorHandler = this.config.errorHandler || Chimee.config.errorHandler; + if (isFunction(errorHandler)) return errorHandler(error); + if (Chimee.config.silent) return; + /* istanbul ignore else */ + if (isError(error)) throw error;else console.error(error); + } + }]); + + return Chimee; +}(VideoWrapper), _class3.plugin = Plugin, _class3.config = new GlobalConfig(), _class3.install = Dispatcher.install, _class3.uninstall = Dispatcher.uninstall, _class3.hasInstalled = Dispatcher.hasInstalled, _class3.installKernel = Dispatcher.installKernel, _class3.uninstallKernel = Dispatcher.uninstallKernel, _class3.hasInstalledKernel = Dispatcher.hasInstalledKernel, _class3.getPluginConfig = Dispatcher.getPluginConfig, _temp), (_descriptor$2 = _applyDecoratedDescriptor$8(_class2$2.prototype, '__id', [frozen], { + enumerable: true, + initializer: function initializer() { + return '_vm'; + } +}), _descriptor2$1 = _applyDecoratedDescriptor$8(_class2$2.prototype, 'version', [frozen], { + enumerable: true, + initializer: function initializer() { + return '0.10.6'; + } +}), _descriptor3$1 = _applyDecoratedDescriptor$8(_class2$2.prototype, 'config', [frozen], { + enumerable: true, + initializer: function initializer() { + return { + errorHandler: undefined + }; + } +}), _applyDecoratedDescriptor$8(_class2$2, 'plugin', [frozen], (_init = _Object$getOwnPropertyDescriptor(_class2$2, 'plugin'), _init = _init ? _init.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'config', [frozen], (_init2 = _Object$getOwnPropertyDescriptor(_class2$2, 'config'), _init2 = _init2 ? _init2.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init2; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'install', [frozen], (_init3 = _Object$getOwnPropertyDescriptor(_class2$2, 'install'), _init3 = _init3 ? _init3.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init3; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'uninstall', [frozen], (_init4 = _Object$getOwnPropertyDescriptor(_class2$2, 'uninstall'), _init4 = _init4 ? _init4.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init4; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'hasInstalled', [frozen], (_init5 = _Object$getOwnPropertyDescriptor(_class2$2, 'hasInstalled'), _init5 = _init5 ? _init5.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init5; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'installKernel', [frozen], (_init6 = _Object$getOwnPropertyDescriptor(_class2$2, 'installKernel'), _init6 = _init6 ? _init6.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init6; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'uninstallKernel', [frozen], (_init7 = _Object$getOwnPropertyDescriptor(_class2$2, 'uninstallKernel'), _init7 = _init7 ? _init7.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init7; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'hasInstalledKernel', [frozen], (_init8 = _Object$getOwnPropertyDescriptor(_class2$2, 'hasInstalledKernel'), _init8 = _init8 ? _init8.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init8; + } +}), _class2$2), _applyDecoratedDescriptor$8(_class2$2, 'getPluginConfig', [frozen], (_init9 = _Object$getOwnPropertyDescriptor(_class2$2, 'getPluginConfig'), _init9 = _init9 ? _init9.value : undefined, { + enumerable: true, + configurable: true, + writable: true, + initializer: function initializer() { + return _init9; + } +}), _class2$2)), _class2$2)) || _class$9); + +export default Chimee; diff --git a/lib/index.js b/lib/index.js index a9f9b1d7..6e6def11 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,6 @@ /** - * chimee v0.10.5 + * chimee v0.10.6 * (c) 2017-2018 toxic-johann * Released under MIT */ @@ -1293,7 +1293,7 @@ var Plugin = (_dec$2 = toxicDecorators.autobindClass(), _dec$2(_class$2 = functi var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this)); _this.destroyed = false; - _this.VERSION = '0.10.5'; + _this.VERSION = '0.10.6'; _this.__operable = true; _this.__level = 0; @@ -4099,7 +4099,7 @@ var Chimee = (_dec$7 = toxicDecorators.autobindClass(), _dec$7(_class$8 = (_clas }), _descriptor2$1 = _applyDecoratedDescriptor$7(_class2$1.prototype, 'version', [toxicDecorators.frozen], { enumerable: true, initializer: function initializer() { - return '0.10.5'; + return '0.10.6'; } }), _descriptor3$1 = _applyDecoratedDescriptor$7(_class2$1.prototype, 'config', [toxicDecorators.frozen], { enumerable: true, diff --git a/lib/index.min.js b/lib/index.min.js index 58defbd4..122df71a 100644 --- a/lib/index.min.js +++ b/lib/index.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Chimee=t()}(this,function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}var i=t(n(function(e,t){t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}})),E=n(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),v=n(function(e){var t=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=t)}),a=(v.version,function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}),b=function(r,i,e){if(a(r),void 0===i)return r;switch(e){case 1:return function(e){return r.call(i,e)};case 2:return function(e,t){return r.call(i,e,t)};case 3:return function(e,t,n){return r.call(i,e,t,n)}}return function(){return r.apply(i,arguments)}},k=function(e){return"object"==typeof e?null!==e:"function"==typeof e},p=function(e){if(!k(e))throw TypeError(e+" is not an object!");return e},O=function(e){try{return!!e()}catch(e){return!0}},x=!O(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),r=E.document,o=k(r)&&k(r.createElement),s=function(e){return o?r.createElement(e):{}},u=!x&&!O(function(){return 7!=Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a}),c=function(e,t){if(!k(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!k(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!k(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!k(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},l=Object.defineProperty,f={f:x?Object.defineProperty:function(e,t,n){if(p(e),t=c(t,!0),p(n),u)try{return l(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},S=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},P=x?function(e,t,n){return f.f(e,t,S(1,n))}:function(e,t,n){return e[t]=n,e},d={}.hasOwnProperty,y=function(e,t){return d.call(e,t)},g="prototype",m=function(e,t,n){var r,i,o,a=e&m.F,s=e&m.G,u=e&m.S,c=e&m.P,l=e&m.B,f=e&m.W,d=s?v:v[t]||(v[t]={}),h=d[g],p=s?E:u?E[t]:(E[t]||{})[g];for(r in s&&(n=t),n)(i=!a&&p&&void 0!==p[r])&&y(d,r)||(o=i?p[r]:n[r],d[r]=s&&"function"!=typeof p[r]?n[r]:l&&i?b(o,E):f&&p[r]==o?function(r){var e=function(e,t,n){if(this instanceof r){switch(arguments.length){case 0:return new r;case 1:return new r(e);case 2:return new r(e,t)}return new r(e,t,n)}return r.apply(this,arguments)};return e[g]=r[g],e}(o):c&&"function"==typeof o?b(Function.call,o):o,c&&((d.virtual||(d.virtual={}))[r]=o,e&m.R&&h&&!h[r]&&P(h,r,o)))};m.F=1,m.G=2,m.S=4,m.P=8,m.B=16,m.W=32,m.U=64,m.R=128;var j=m;j(j.S+j.F*!x,"Object",{defineProperty:f.f});var h,w=v.Object,_=function(e,t,n){return w.defineProperty(e,t,n)},T=n(function(e){e.exports={default:_,__esModule:!0}}),A=t(T),C=t(n(function(e,t){t.__esModule=!0;var n,i=(n=T)&&n.__esModule?n:{default:n};t.default=function(){function r(e,t){for(var n=0;ni;)y(r,n=t[i++])&&(~X(o,n)||o.push(n));return o},te="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ne=Object.keys||function(e){return ee(e,te)},re=x?Object.defineProperties:function(e,t){p(e);for(var n,r=ne(t),i=r.length,o=0;odocument.F=Object<\/script>"),e.close(),ce=e.F;n--;)delete ce[ue][te[n]];return ce()},le=Object.create||function(e,t){var n;return null!==e?(se[ue]=p(e),n=new se,se[ue]=null,n[ae]=e):n=ce(),void 0===t?n:re(n,t)},fe=n(function(e){var t=H("wks"),n=E.Symbol,r="function"==typeof n;(e.exports=function(e){return t[e]||(t[e]=r&&n[e]||(r?n:Y)("Symbol."+e))}).store=t}),de=f.f,he=fe("toStringTag"),pe=function(e,t,n){e&&!y(e=n?e:e.prototype,he)&&de(e,he,{configurable:!0,value:t})},ve={};P(ve,fe("iterator"),function(){return this});var ye,ge=function(e){return Object(N(e))},me=Z("IE_PROTO"),be=Object.prototype,we=Object.getPrototypeOf||function(e){return e=ge(e),y(e,me)?e[me]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?be:null},_e=fe("iterator"),Ee=!([].keys&&"next"in[].keys()),ke="values",Oe=function(){return this},xe=function(e,t,n,r,i,o,a){var s,u,c;u=t,c=r,(s=n).prototype=le(ve,{next:S(1,c)}),pe(s,u+" Iterator");var l,f,d,h=function(e){if(!Ee&&e in g)return g[e];switch(e){case"keys":case ke:return function(){return new n(this,e)}}return function(){return new n(this,e)}},p=t+" Iterator",v=i==ke,y=!1,g=e.prototype,m=g[_e]||g["@@iterator"]||i&&g[i],b=m||h(i),w=i?v?h("entries"):b:void 0,_="Array"==t&&g.entries||m;if(_&&(d=we(_.call(new e)))!==Object.prototype&&d.next&&pe(d,p,!0),v&&m&&m.name!==ke&&(y=!0,b=function(){return m.call(this)}),a&&(Ee||y||!g[_e])&&P(g,_e,b),D[t]=b,D[p]=Oe,i)if(l={values:v?b:h(ke),keys:o?b:h("keys"),entries:w},a)for(f in l)f in g||F(g,f,l[f]);else j(j.P+j.F*(Ee||y),t,l);return l},Se=(ye=!0,function(e,t){var n,r,i=String(N(e)),o=z(t),a=i.length;return o<0||a<=o?ye?"":void 0:(n=i.charCodeAt(o))<55296||56319=t.length?{value:void 0,done:!0}:(e=Se(t,n),this._i+=e.length,{value:e,done:!1})});var Pe=function(e,t){return{value:t,done:!!e}};xe(Array,"Array",function(e,t){this._t=V(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,Pe(1)):Pe(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values");D.Arguments=D.Array;for(var je=fe("toStringTag"),Te="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),Ae=0;Aea;)o.call(e,r=i[a++])&&t.push(r);return t}(t=V(t)),i=0,o=r.length;ii;)y(ct,t=n[i++])||t==ot||t==Ze||r.push(t);return r},kt=function(e){for(var t,n=e===ft,r=et(n?lt:V(e)),i=[],o=0;r.length>o;)!y(ct,t=r[o++])||n&&!y(ft,t)||i.push(ct[t]);return i};dt||(F((tt=function(){if(this instanceof tt)throw TypeError("Symbol is not a constructor!");var t=Y(0xt;)fe(Ot[xt++]);for(var St=ne(fe.store),Pt=0;St.length>Pt;)Re(St[Pt++]);j(j.S+j.F*!dt,"Symbol",{for:function(e){return y(ut,e+="")?ut[e]:ut[e]=tt(e)},keyFor:function(e){if(!gt(e))throw TypeError(e+" is not a symbol!");for(var t in ut)if(ut[t]===e)return t},useSetter:function(){pt=!0},useSimple:function(){pt=!1}}),j(j.S+j.F*!dt,"Object",{create:function(e,t){return void 0===t?le(e):bt(le(e),t)},defineProperty:mt,defineProperties:bt,getOwnPropertyDescriptor:_t,getOwnPropertyNames:Et,getOwnPropertySymbols:kt}),nt&&j(j.S+j.F*(!dt||O(function(){var e=tt();return"[null]"!=rt([e])||"{}"!=rt({a:e})||"{}"!=rt(Object(e))})),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(k(t)||void 0!==e)&&!gt(e))return Ke(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!gt(t))return t}),r[1]=t,rt.apply(nt,r)}}),tt[it][at]||P(tt[it],at,tt[it].valueOf),pe(tt,"Symbol"),pe(Math,"Math",!0),pe(E.JSON,"JSON",!0),Re("asyncIterator"),Re("observable");var jt=v.Symbol,Tt=n(function(e){e.exports={default:jt,__esModule:!0}});t(Tt);var At=t(n(function(e,t){t.__esModule=!0;var n=o(Fe),r=o(Tt),i="function"==typeof r.default&&"symbol"==typeof n.default?function(e){return typeof e}:function(e){return e&&"function"==typeof r.default&&e.constructor===r.default&&e!==r.default.prototype?"symbol":typeof e};function o(e){return e&&e.__esModule?e:{default:e}}t.default="function"==typeof r.default&&"symbol"===i(n.default)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof r.default&&e.constructor===r.default&&e!==r.default.prototype?"symbol":void 0===e?"undefined":i(e)}})),Ct=function(e,t){var n=(v.Object||{})[e]||Object[e],r={};r[e]=t(n),j(j.S+j.F*O(function(){n(1)}),"Object",r)};Ct("keys",function(){return function(e){return ne(ge(e))}});var Lt=v.Object.keys,Mt=t(n(function(e){e.exports={default:Lt,__esModule:!0}})),zt=Math.floor;j(j.S,"Number",{isInteger:function(e){return!k(e)&&isFinite(e)&&zt(e)===e}});var Nt=v.Number.isInteger,Ft=t(n(function(e){e.exports={default:Nt,__esModule:!0}})),Dt="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff",It="["+Dt+"]",Rt=RegExp("^"+It+It+"*"),$t=RegExp(It+It+"*$"),Vt=function(e,t,n){var r={},i=O(function(){return!!Dt[e]()||"​…"!="​…"[e]()}),o=r[e]=i?t(Kt):Dt[e];n&&(r[n]=o),j(j.P+j.F*i,"String",r)},Kt=Vt.trim=function(e,t){return e=String(N(e)),1&t&&(e=e.replace(Rt,"")),2&t&&(e=e.replace($t,"")),e},Bt=Vt,Gt=E.parseFloat,Wt=Bt.trim,Ht=1/Gt(Dt+"-0")!=-1/0?function(e){var t=Wt(String(e),3),n=Gt(t);return 0===n&&"-"==t.charAt(0)?-0:n}:Gt;j(j.S+j.F*(Number.parseFloat!=Ht),"Number",{parseFloat:Ht});var Ut=v.Number.parseFloat,qt=t(n(function(e){e.exports={default:Ut,__esModule:!0}}));function Yt(e){return void 0!==e}function Qt(e){return null==e}function Zt(e){return Array.isArray(e)}function Xt(e){return"function"==typeof e}function Jt(e){return Object(e)===e&&"[object Object]"===String(e)&&!Xt(e)&&!Zt(e)}function en(e){return"number"==typeof e}function tn(e){return Ft(e)}function nn(e){return Zt(e)?0===e.length:Jt(e)?0===Mt(e).length:!e}function rn(e){return e instanceof Event||(e&&e.originalEvent)instanceof Event}function on(e){return"string"==typeof e||e instanceof String}function an(e){return"boolean"==typeof e}function sn(e){return!!e&&("object"===(void 0===e?"undefined":At(e))||"function"==typeof e)&&"function"==typeof e.then}function un(e){return Qt(e)||an(e)||on(e)||en(e)}function cn(e){return!!("object"===("undefined"==typeof Node?"undefined":At(Node))?e instanceof Node:e&&"object"===(void 0===e?"undefined":At(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName)}function ln(e){return!!("object"===("undefined"==typeof HTMLElement?"undefined":At(HTMLElement))?e instanceof HTMLElement:e&&"object"===(void 0===e?"undefined":At(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)}function fn(e,t){if(!cn(e)||!cn(t))return!1;for(;t.parentNode;)if((t=t.parentNode)===e)return!0;return!1}function dn(e){return e instanceof Error}function hn(e,t){if(!on(e))throw new TypeError("Log's method only acccept string as argument, but not "+e+" in "+(void 0===e?"undefined":At(e)));return on(t)?"["+(e=pn.FORCE_GLOBAL_TAG?pn.GLOBAL_TAG:e||pn.GLOBAL_TAG)+"] > "+t:"["+pn.GLOBAL_TAG+"] > "+e}var pn=function(){function n(){i(this,n)}return C(n,null,[{key:"error",value:function(e,t){n.ENABLE_ERROR&&(console.error||console.warn||console.log).call(console,hn(e,t))}},{key:"info",value:function(e,t){n.ENABLE_INFO&&(console.info||console.log).call(console,hn(e,t))}},{key:"warn",value:function(e,t){n.ENABLE_WARN&&(console.warn||console.log).call(console,hn(e,t))}},{key:"debug",value:function(e,t){n.ENABLE_DEBUG&&(console.debug||console.log).call(console,hn(e,t))}},{key:"verbose",value:function(e,t){n.ENABLE_VERBOSE&&console.log(hn(e,t))}}]),n}();pn.GLOBAL_TAG="chimee",pn.FORCE_GLOBAL_TAG=!1,pn.ENABLE_ERROR=!0,pn.ENABLE_INFO=!0,pn.ENABLE_WARN=!0,pn.ENABLE_DEBUG=!0,pn.ENABLE_VERBOSE=!0;n(function(_,E){!function(i,f){var d="function",e="model",t="name",n="type",r="vendor",o="version",a="architecture",s="console",u="mobile",c="tablet",l="smarttv",h="wearable",p={extend:function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:f},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},v={rgx:function(e,t){for(var n,r,i,o,a,s,u=0;un;)t.push(arguments[n++]);return Qn[++Yn]=function(){!function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}e.apply(n,t)}("function"==typeof e?e:Function(e),t)},Dn(Yn),Yn},Hn=function(e){delete Qn[e]},"process"==R(Gn)?Dn=function(e){Gn.nextTick(b(Xn,e,1))}:qn&&qn.now?Dn=function(e){qn.now(b(Xn,e,1))}:Un?(Rn=(In=new Un).port2,In.port1.onmessage=Jn,Dn=b(Rn.postMessage,Rn,1)):E.addEventListener&&"function"==typeof postMessage&&!E.importScripts?(Dn=function(e){E.postMessage(e+"","*")},E.addEventListener("message",Jn,!1)):Dn=Zn in s("script")?function(e){oe.appendChild(s("script"))[Zn]=function(){oe.removeChild(this),Xn.call(e)}}:function(e){setTimeout(b(Xn,e,1),0)});var er={set:Wn,clear:Hn},tr=er.set,nr=E.MutationObserver||E.WebKitMutationObserver,rr=E.process,ir=E.Promise,or="process"==R(rr);function ar(e){var n,r;this.promise=new e(function(e,t){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=e,r=t}),this.resolve=a(n),this.reject=a(r)}var sr,ur,cr,lr,fr,dr,hr={f:function(e){return new ar(e)}},pr=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}},vr=E.navigator,yr=vr&&vr.userAgent||"",gr=function(e,t){if(p(e),k(t)&&t.constructor===e)return t;var n=hr.f(e);return(0,n.resolve)(t),n.promise},mr=function(e,t,n){for(var r in t)n&&e[r]?e[r]=t[r]:P(e,r,t[r]);return e},br=fe("species"),wr=er.set,_r=function(){var n,r,i,e=function(){var e,t;for(or&&(e=rr.domain)&&e.exit();n;){t=n.fn,n=n.next;try{t()}catch(e){throw n?i():r=void 0,e}}r=void 0,e&&e.enter()};if(or)i=function(){rr.nextTick(e)};else if(!nr||E.navigator&&E.navigator.standalone)if(ir&&ir.resolve){var t=ir.resolve(void 0);i=function(){t.then(e)}}else i=function(){tr.call(E,e)};else{var o=!0,a=document.createTextNode("");new nr(e).observe(a,{characterData:!0}),i=function(){a.data=o=!o}}return function(e){var t={fn:e,next:void 0};r&&(r.next=t),n||(n=t,i()),r=t}}(),Er="Promise",kr=E.TypeError,Or=E.process,xr=Or&&Or.versions,Sr=xr&&xr.v8||"",Pr=E[Er],jr="process"==En(Or),Tr=function(){},Ar=ur=hr.f,Cr=!!function(){try{var e=Pr.resolve(1),t=(e.constructor={})[fe("species")]=function(e){e(Tr,Tr)};return(jr||"function"==typeof PromiseRejectionEvent)&&e.then(Tr)instanceof t&&0!==Sr.indexOf("6.6")&&-1===yr.indexOf("Chrome/66")}catch(e){}}(),Lr=function(e){var t;return!(!k(e)||"function"!=typeof(t=e.then))&&t},Mr=function(l,n){if(!l._n){l._n=!0;var r=l._c;_r(function(){for(var u=l._v,c=1==l._s,e=0,t=function(e){var t,n,r,i=c?e.ok:e.fail,o=e.resolve,a=e.reject,s=e.domain;try{i?(c||(2==l._h&&Fr(l),l._h=1),!0===i?t=u:(s&&s.enter(),t=i(u),s&&(s.exit(),r=!0)),t===e.promise?a(kr("Promise-chain cycle")):(n=Lr(t))?n.call(t,o,a):o(t)):a(u)}catch(e){s&&!r&&s.exit(),a(e)}};r.length>e;)t(r[e++]);l._c=[],l._n=!1,n&&!l._h&&zr(l)})}},zr=function(o){wr.call(E,function(){var e,t,n,r=o._v,i=Nr(o);if(i&&(e=pr(function(){jr?Or.emit("unhandledRejection",r,o):(t=E.onunhandledrejection)?t({promise:o,reason:r}):(n=E.console)&&n.error&&n.error("Unhandled promise rejection",r)}),o._h=jr||Nr(o)?2:1),o._a=void 0,i&&e.e)throw e.v})},Nr=function(e){return 1!==e._h&&0===(e._a||e._c).length},Fr=function(t){wr.call(E,function(){var e;jr?Or.emit("rejectionHandled",t):(e=E.onrejectionhandled)&&e({promise:t,reason:t._v})})},Dr=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),Mr(t,!0))},Ir=function(e){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===e)throw kr("Promise can't be resolved itself");(n=Lr(e))?_r(function(){var t={_w:r,_d:!1};try{n.call(e,b(Ir,t,1),b(Dr,t,1))}catch(e){Dr.call(t,e)}}):(r._v=e,r._s=1,Mr(r,!1))}catch(e){Dr.call({_w:r,_d:!1},e)}}};Cr||(Pr=function(e){$n(this,Pr,Er,"_h"),a(e),sr.call(this);try{e(b(Ir,this,1),b(Dr,this,1))}catch(e){Dr.call(this,e)}},(sr=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=mr(Pr.prototype,{then:function(e,t){var n=Ar(Bn(this,Pr));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=jr?Or.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&Mr(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),cr=function(){var e=new sr;this.promise=e,this.resolve=b(Ir,e,1),this.reject=b(Dr,e,1)},hr.f=Ar=function(e){return e===Pr||e===lr?new cr(e):ur(e)}),j(j.G+j.W+j.F*!Cr,{Promise:Pr}),pe(Pr,Er),dr="function"==typeof v[fr=Er]?v[fr]:E[fr],x&&dr&&!dr[br]&&f.f(dr,br,{configurable:!0,get:function(){return this}}),lr=v[Er],j(j.S+j.F*!Cr,Er,{reject:function(e){var t=Ar(this);return(0,t.reject)(e),t.promise}}),j(j.S+!0*j.F,Er,{resolve:function(e){return gr(this===lr?Pr:this,e)}}),j(j.S+j.F*!(Cr&&Pn(function(e){Pr.all(e).catch(Tr)})),Er,{all:function(e){var a=this,t=Ar(a),s=t.resolve,u=t.reject,n=pr(function(){var r=[],i=0,o=1;Vn(e,!1,function(e){var t=i++,n=!1;r.push(void 0),o++,a.resolve(e).then(function(e){n||(n=!0,r[t]=e,--o||s(r))},u)}),--o||s(r)});return n.e&&u(n.v),t.promise},race:function(e){var t=this,n=Ar(t),r=n.reject,i=pr(function(){Vn(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}}),j(j.P+j.R,"Promise",{finally:function(t){var n=Bn(this,v.Promise||E.Promise),e="function"==typeof t;return this.then(e?function(e){return gr(n,t()).then(function(){return e})}:t,e?function(e){return gr(n,t()).then(function(){throw e})}:t)}}),j(j.S,"Promise",{try:function(e){var t=hr.f(this),n=pr(e);return(n.e?t.reject:t.resolve)(n.v),t.promise}});var Rr=v.Promise,$r=t(n(function(e){e.exports={default:Rr,__esModule:!0}})),Vr="undefined"!=typeof window&&"[object Object]"!==Object.prototype.toString.call(window);function Kr(n){var e=1=o.length)){var n=Xt(o[t])?o[t].apply(o,Cn(a)):o[t];return!1===n?i("stop"):$r.resolve(n).then(function(){return e(t+1)}).catch(function(e){return i(e||"stop")})}r()}(0)})}function Gr(n){for(var e=arguments.length,r=Array(1=n.length||!1!==(Xt(n[t])?n[t].apply(n,Cn(r)):n[t])&&e(++t)}(0)}Vr&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),Vr&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.oCancelAnimationFrame);var Wr=Object.assign,Hr=!Wr||O(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=Wr({},e)[n]||Object.keys(Wr({},t)).join("")!=r})?function(e,t){for(var n=ge(e),r=arguments.length,i=1,o=$e.f,a=Ve.f;is;)void 0!==(n=i(r,t=o[s++]))&&bn(a,t,n);return a}});var zi=v.Object.getOwnPropertyDescriptors,Ni=t(n(function(e){e.exports={default:zi,__esModule:!0}})),Fi=v.Object.getOwnPropertySymbols,Di=t(n(function(e){e.exports={default:Fi,__esModule:!0}}));Ct("getOwnPropertyNames",function(){return qe.f});var Ii=v.Object,Ri=function(e){return Ii.getOwnPropertyNames(e)},$i=t(n(function(e){e.exports={default:Ri,__esModule:!0}})),Vi=Qe.f;Ct("getOwnPropertyDescriptor",function(){return function(e,t){return Vi(V(e),t)}});var Ki=v.Object,Bi=function(e,t){return Ki.getOwnPropertyDescriptor(e,t)},Gi=t(n(function(e){e.exports={default:Bi,__esModule:!0}}));function Wi(r,i){return r.bind?r.bind(i):r.apply?function(){for(var e=arguments.length,t=Array(e),n=0;n");for(var a=[],s=e,u=0,c=t.length;u as key to find the target to spy on, but not "+e+", whose type is "+(void 0===e?"undefined":bi(e)));var l,f,d,h=!0,p=function e(){h=!1;var t=n.__unwatchHandlers.indexOf(e);-1");for(var a=[],s=e,u=0,c=t.length;u]+?>/.test(t)){var r=document.createElement("div");r.innerHTML=t,t=r.children[0]}else t=document.createElement(Nn(t).replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}));else Jt(t)&&(n=t);var i=n,o=i.inner,a=i.penetrate,s=n.className,u=t&&ln(t)?t:document.createElement("div");Zt(s)&&(s=s.join(" ")),on(s)&&ui(u,s),this.plugins[e]=u;var c=o?this.container:this.wrapper,l=o?this.videoElement:this.container;return a&&(this.__dispatcher.binder.bindEventOnPenetrateNode(u),this.__videoExtendedNodes.push(u)),c.lastChild===l?c.appendChild(u):c.insertBefore(u,l.nextSibling),u}},{key:"removePlugin",value:function(e){if(on(e)){var t=this.plugins[e];ln(t)&&(t.parentNode&&t.parentNode.removeChild(t),this._autoFocusToVideo(t,!0));var n=(Tu.getPluginConfig(e)||{}).penetrate;void 0!==n&&n&&this.__dispatcher.binder.bindEventOnPenetrateNode(t,!0),delete this.plugins[e]}}},{key:"setPluginsZIndex",value:function(e){var n=this;e.forEach(function(e,t){return vi(e.match(/^(videoElement|container)$/)?n[e]:n.plugins[e],"z-index",++t)})}},{key:"setAttr",value:function(e,t,n){si(this[e],t,n)}},{key:"getAttr",value:function(e,t){return ai(this[e],t)}},{key:"setStyle",value:function(e,t,n){vi(this[e],t,n)}},{key:"getStyle",value:function(e,t){return pi(this[e],t)}},{key:"requestFullscreen",value:function(e){return Fs.open(this[e])}},{key:"exitFullscreen",value:function(){return Fs.exit()}},{key:"fullscreen",value:function(){for(var e=!(0i;)y(r,n=t[i++])&&(~X(o,n)||o.push(n));return o},te="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ne=Object.keys||function(e){return ee(e,te)},re=x?Object.defineProperties:function(e,t){p(e);for(var n,r=ne(t),i=r.length,o=0;odocument.F=Object<\/script>"),e.close(),ce=e.F;n--;)delete ce[ue][te[n]];return ce()},le=Object.create||function(e,t){var n;return null!==e?(se[ue]=p(e),n=new se,se[ue]=null,n[ae]=e):n=ce(),void 0===t?n:re(n,t)},fe=n(function(e){var t=H("wks"),n=E.Symbol,r="function"==typeof n;(e.exports=function(e){return t[e]||(t[e]=r&&n[e]||(r?n:Y)("Symbol."+e))}).store=t}),de=f.f,he=fe("toStringTag"),pe=function(e,t,n){e&&!y(e=n?e:e.prototype,he)&&de(e,he,{configurable:!0,value:t})},ve={};P(ve,fe("iterator"),function(){return this});var ye,ge=function(e){return Object(N(e))},me=Z("IE_PROTO"),be=Object.prototype,we=Object.getPrototypeOf||function(e){return e=ge(e),y(e,me)?e[me]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?be:null},_e=fe("iterator"),Ee=!([].keys&&"next"in[].keys()),ke="values",Oe=function(){return this},xe=function(e,t,n,r,i,o,a){var s,u,c;u=t,c=r,(s=n).prototype=le(ve,{next:S(1,c)}),pe(s,u+" Iterator");var l,f,d,h=function(e){if(!Ee&&e in g)return g[e];switch(e){case"keys":case ke:return function(){return new n(this,e)}}return function(){return new n(this,e)}},p=t+" Iterator",v=i==ke,y=!1,g=e.prototype,m=g[_e]||g["@@iterator"]||i&&g[i],b=m||h(i),w=i?v?h("entries"):b:void 0,_="Array"==t&&g.entries||m;if(_&&(d=we(_.call(new e)))!==Object.prototype&&d.next&&pe(d,p,!0),v&&m&&m.name!==ke&&(y=!0,b=function(){return m.call(this)}),a&&(Ee||y||!g[_e])&&P(g,_e,b),D[t]=b,D[p]=Oe,i)if(l={values:v?b:h(ke),keys:o?b:h("keys"),entries:w},a)for(f in l)f in g||F(g,f,l[f]);else j(j.P+j.F*(Ee||y),t,l);return l},Se=(ye=!0,function(e,t){var n,r,i=String(N(e)),o=z(t),a=i.length;return o<0||a<=o?ye?"":void 0:(n=i.charCodeAt(o))<55296||56319=t.length?{value:void 0,done:!0}:(e=Se(t,n),this._i+=e.length,{value:e,done:!1})});var Pe=function(e,t){return{value:t,done:!!e}};xe(Array,"Array",function(e,t){this._t=V(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,Pe(1)):Pe(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values");D.Arguments=D.Array;for(var je=fe("toStringTag"),Te="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),Ae=0;Aea;)o.call(e,r=i[a++])&&t.push(r);return t}(t=V(t)),i=0,o=r.length;ii;)y(ct,t=n[i++])||t==ot||t==Ze||r.push(t);return r},kt=function(e){for(var t,n=e===ft,r=et(n?lt:V(e)),i=[],o=0;r.length>o;)!y(ct,t=r[o++])||n&&!y(ft,t)||i.push(ct[t]);return i};dt||(F((tt=function(){if(this instanceof tt)throw TypeError("Symbol is not a constructor!");var t=Y(0xt;)fe(Ot[xt++]);for(var St=ne(fe.store),Pt=0;St.length>Pt;)Re(St[Pt++]);j(j.S+j.F*!dt,"Symbol",{for:function(e){return y(ut,e+="")?ut[e]:ut[e]=tt(e)},keyFor:function(e){if(!gt(e))throw TypeError(e+" is not a symbol!");for(var t in ut)if(ut[t]===e)return t},useSetter:function(){pt=!0},useSimple:function(){pt=!1}}),j(j.S+j.F*!dt,"Object",{create:function(e,t){return void 0===t?le(e):bt(le(e),t)},defineProperty:mt,defineProperties:bt,getOwnPropertyDescriptor:_t,getOwnPropertyNames:Et,getOwnPropertySymbols:kt}),nt&&j(j.S+j.F*(!dt||O(function(){var e=tt();return"[null]"!=rt([e])||"{}"!=rt({a:e})||"{}"!=rt(Object(e))})),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(k(t)||void 0!==e)&&!gt(e))return Ke(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!gt(t))return t}),r[1]=t,rt.apply(nt,r)}}),tt[it][at]||P(tt[it],at,tt[it].valueOf),pe(tt,"Symbol"),pe(Math,"Math",!0),pe(E.JSON,"JSON",!0),Re("asyncIterator"),Re("observable");var jt=v.Symbol,Tt=n(function(e){e.exports={default:jt,__esModule:!0}});t(Tt);var At=t(n(function(e,t){t.__esModule=!0;var n=o(Fe),r=o(Tt),i="function"==typeof r.default&&"symbol"==typeof n.default?function(e){return typeof e}:function(e){return e&&"function"==typeof r.default&&e.constructor===r.default&&e!==r.default.prototype?"symbol":typeof e};function o(e){return e&&e.__esModule?e:{default:e}}t.default="function"==typeof r.default&&"symbol"===i(n.default)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof r.default&&e.constructor===r.default&&e!==r.default.prototype?"symbol":void 0===e?"undefined":i(e)}})),Ct=function(e,t){var n=(v.Object||{})[e]||Object[e],r={};r[e]=t(n),j(j.S+j.F*O(function(){n(1)}),"Object",r)};Ct("keys",function(){return function(e){return ne(ge(e))}});var Lt=v.Object.keys,Mt=t(n(function(e){e.exports={default:Lt,__esModule:!0}})),zt=Math.floor;j(j.S,"Number",{isInteger:function(e){return!k(e)&&isFinite(e)&&zt(e)===e}});var Nt=v.Number.isInteger,Ft=t(n(function(e){e.exports={default:Nt,__esModule:!0}})),Dt="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff",It="["+Dt+"]",Rt=RegExp("^"+It+It+"*"),$t=RegExp(It+It+"*$"),Vt=function(e,t,n){var r={},i=O(function(){return!!Dt[e]()||"​…"!="​…"[e]()}),o=r[e]=i?t(Kt):Dt[e];n&&(r[n]=o),j(j.P+j.F*i,"String",r)},Kt=Vt.trim=function(e,t){return e=String(N(e)),1&t&&(e=e.replace(Rt,"")),2&t&&(e=e.replace($t,"")),e},Bt=Vt,Gt=E.parseFloat,Wt=Bt.trim,Ht=1/Gt(Dt+"-0")!=-1/0?function(e){var t=Wt(String(e),3),n=Gt(t);return 0===n&&"-"==t.charAt(0)?-0:n}:Gt;j(j.S+j.F*(Number.parseFloat!=Ht),"Number",{parseFloat:Ht});var Ut=v.Number.parseFloat,qt=t(n(function(e){e.exports={default:Ut,__esModule:!0}}));function Yt(e){return void 0!==e}function Qt(e){return null==e}function Zt(e){return Array.isArray(e)}function Xt(e){return"function"==typeof e}function Jt(e){return Object(e)===e&&"[object Object]"===String(e)&&!Xt(e)&&!Zt(e)}function en(e){return"number"==typeof e}function tn(e){return Ft(e)}function nn(e){return Zt(e)?0===e.length:Jt(e)?0===Mt(e).length:!e}function rn(e){return e instanceof Event||(e&&e.originalEvent)instanceof Event}function on(e){return"string"==typeof e||e instanceof String}function an(e){return"boolean"==typeof e}function sn(e){return!!e&&("object"===(void 0===e?"undefined":At(e))||"function"==typeof e)&&"function"==typeof e.then}function un(e){return Qt(e)||an(e)||on(e)||en(e)}function cn(e){return!!("object"===("undefined"==typeof Node?"undefined":At(Node))?e instanceof Node:e&&"object"===(void 0===e?"undefined":At(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName)}function ln(e){return!!("object"===("undefined"==typeof HTMLElement?"undefined":At(HTMLElement))?e instanceof HTMLElement:e&&"object"===(void 0===e?"undefined":At(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)}function fn(e,t){if(!cn(e)||!cn(t))return!1;for(;t.parentNode;)if((t=t.parentNode)===e)return!0;return!1}function dn(e){return e instanceof Error}function hn(e,t){if(!on(e))throw new TypeError("Log's method only acccept string as argument, but not "+e+" in "+(void 0===e?"undefined":At(e)));return on(t)?"["+(e=pn.FORCE_GLOBAL_TAG?pn.GLOBAL_TAG:e||pn.GLOBAL_TAG)+"] > "+t:"["+pn.GLOBAL_TAG+"] > "+e}var pn=function(){function n(){i(this,n)}return C(n,null,[{key:"error",value:function(e,t){n.ENABLE_ERROR&&(console.error||console.warn||console.log).call(console,hn(e,t))}},{key:"info",value:function(e,t){n.ENABLE_INFO&&(console.info||console.log).call(console,hn(e,t))}},{key:"warn",value:function(e,t){n.ENABLE_WARN&&(console.warn||console.log).call(console,hn(e,t))}},{key:"debug",value:function(e,t){n.ENABLE_DEBUG&&(console.debug||console.log).call(console,hn(e,t))}},{key:"verbose",value:function(e,t){n.ENABLE_VERBOSE&&console.log(hn(e,t))}}]),n}();pn.GLOBAL_TAG="chimee",pn.FORCE_GLOBAL_TAG=!1,pn.ENABLE_ERROR=!0,pn.ENABLE_INFO=!0,pn.ENABLE_WARN=!0,pn.ENABLE_DEBUG=!0,pn.ENABLE_VERBOSE=!0;n(function(_,E){!function(i,f){var d="function",e="model",t="name",n="type",r="vendor",o="version",a="architecture",s="console",u="mobile",c="tablet",l="smarttv",h="wearable",p={extend:function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:f},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},v={rgx:function(e,t){for(var n,r,i,o,a,s,u=0;un;)t.push(arguments[n++]);return Qn[++Yn]=function(){!function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}e.apply(n,t)}("function"==typeof e?e:Function(e),t)},Dn(Yn),Yn},Hn=function(e){delete Qn[e]},"process"==R(Gn)?Dn=function(e){Gn.nextTick(b(Xn,e,1))}:qn&&qn.now?Dn=function(e){qn.now(b(Xn,e,1))}:Un?(Rn=(In=new Un).port2,In.port1.onmessage=Jn,Dn=b(Rn.postMessage,Rn,1)):E.addEventListener&&"function"==typeof postMessage&&!E.importScripts?(Dn=function(e){E.postMessage(e+"","*")},E.addEventListener("message",Jn,!1)):Dn=Zn in s("script")?function(e){oe.appendChild(s("script"))[Zn]=function(){oe.removeChild(this),Xn.call(e)}}:function(e){setTimeout(b(Xn,e,1),0)});var er={set:Wn,clear:Hn},tr=er.set,nr=E.MutationObserver||E.WebKitMutationObserver,rr=E.process,ir=E.Promise,or="process"==R(rr);function ar(e){var n,r;this.promise=new e(function(e,t){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=e,r=t}),this.resolve=a(n),this.reject=a(r)}var sr,ur,cr,lr,fr,dr,hr={f:function(e){return new ar(e)}},pr=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}},vr=E.navigator,yr=vr&&vr.userAgent||"",gr=function(e,t){if(p(e),k(t)&&t.constructor===e)return t;var n=hr.f(e);return(0,n.resolve)(t),n.promise},mr=function(e,t,n){for(var r in t)n&&e[r]?e[r]=t[r]:P(e,r,t[r]);return e},br=fe("species"),wr=er.set,_r=function(){var n,r,i,e=function(){var e,t;for(or&&(e=rr.domain)&&e.exit();n;){t=n.fn,n=n.next;try{t()}catch(e){throw n?i():r=void 0,e}}r=void 0,e&&e.enter()};if(or)i=function(){rr.nextTick(e)};else if(!nr||E.navigator&&E.navigator.standalone)if(ir&&ir.resolve){var t=ir.resolve(void 0);i=function(){t.then(e)}}else i=function(){tr.call(E,e)};else{var o=!0,a=document.createTextNode("");new nr(e).observe(a,{characterData:!0}),i=function(){a.data=o=!o}}return function(e){var t={fn:e,next:void 0};r&&(r.next=t),n||(n=t,i()),r=t}}(),Er="Promise",kr=E.TypeError,Or=E.process,xr=Or&&Or.versions,Sr=xr&&xr.v8||"",Pr=E[Er],jr="process"==En(Or),Tr=function(){},Ar=ur=hr.f,Cr=!!function(){try{var e=Pr.resolve(1),t=(e.constructor={})[fe("species")]=function(e){e(Tr,Tr)};return(jr||"function"==typeof PromiseRejectionEvent)&&e.then(Tr)instanceof t&&0!==Sr.indexOf("6.6")&&-1===yr.indexOf("Chrome/66")}catch(e){}}(),Lr=function(e){var t;return!(!k(e)||"function"!=typeof(t=e.then))&&t},Mr=function(l,n){if(!l._n){l._n=!0;var r=l._c;_r(function(){for(var u=l._v,c=1==l._s,e=0,t=function(e){var t,n,r,i=c?e.ok:e.fail,o=e.resolve,a=e.reject,s=e.domain;try{i?(c||(2==l._h&&Fr(l),l._h=1),!0===i?t=u:(s&&s.enter(),t=i(u),s&&(s.exit(),r=!0)),t===e.promise?a(kr("Promise-chain cycle")):(n=Lr(t))?n.call(t,o,a):o(t)):a(u)}catch(e){s&&!r&&s.exit(),a(e)}};r.length>e;)t(r[e++]);l._c=[],l._n=!1,n&&!l._h&&zr(l)})}},zr=function(o){wr.call(E,function(){var e,t,n,r=o._v,i=Nr(o);if(i&&(e=pr(function(){jr?Or.emit("unhandledRejection",r,o):(t=E.onunhandledrejection)?t({promise:o,reason:r}):(n=E.console)&&n.error&&n.error("Unhandled promise rejection",r)}),o._h=jr||Nr(o)?2:1),o._a=void 0,i&&e.e)throw e.v})},Nr=function(e){return 1!==e._h&&0===(e._a||e._c).length},Fr=function(t){wr.call(E,function(){var e;jr?Or.emit("rejectionHandled",t):(e=E.onrejectionhandled)&&e({promise:t,reason:t._v})})},Dr=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),Mr(t,!0))},Ir=function(e){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===e)throw kr("Promise can't be resolved itself");(n=Lr(e))?_r(function(){var t={_w:r,_d:!1};try{n.call(e,b(Ir,t,1),b(Dr,t,1))}catch(e){Dr.call(t,e)}}):(r._v=e,r._s=1,Mr(r,!1))}catch(e){Dr.call({_w:r,_d:!1},e)}}};Cr||(Pr=function(e){$n(this,Pr,Er,"_h"),a(e),sr.call(this);try{e(b(Ir,this,1),b(Dr,this,1))}catch(e){Dr.call(this,e)}},(sr=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=mr(Pr.prototype,{then:function(e,t){var n=Ar(Bn(this,Pr));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=jr?Or.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&Mr(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),cr=function(){var e=new sr;this.promise=e,this.resolve=b(Ir,e,1),this.reject=b(Dr,e,1)},hr.f=Ar=function(e){return e===Pr||e===lr?new cr(e):ur(e)}),j(j.G+j.W+j.F*!Cr,{Promise:Pr}),pe(Pr,Er),dr="function"==typeof v[fr=Er]?v[fr]:E[fr],x&&dr&&!dr[br]&&f.f(dr,br,{configurable:!0,get:function(){return this}}),lr=v[Er],j(j.S+j.F*!Cr,Er,{reject:function(e){var t=Ar(this);return(0,t.reject)(e),t.promise}}),j(j.S+!0*j.F,Er,{resolve:function(e){return gr(this===lr?Pr:this,e)}}),j(j.S+j.F*!(Cr&&Pn(function(e){Pr.all(e).catch(Tr)})),Er,{all:function(e){var a=this,t=Ar(a),s=t.resolve,u=t.reject,n=pr(function(){var r=[],i=0,o=1;Vn(e,!1,function(e){var t=i++,n=!1;r.push(void 0),o++,a.resolve(e).then(function(e){n||(n=!0,r[t]=e,--o||s(r))},u)}),--o||s(r)});return n.e&&u(n.v),t.promise},race:function(e){var t=this,n=Ar(t),r=n.reject,i=pr(function(){Vn(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}}),j(j.P+j.R,"Promise",{finally:function(t){var n=Bn(this,v.Promise||E.Promise),e="function"==typeof t;return this.then(e?function(e){return gr(n,t()).then(function(){return e})}:t,e?function(e){return gr(n,t()).then(function(){throw e})}:t)}}),j(j.S,"Promise",{try:function(e){var t=hr.f(this),n=pr(e);return(n.e?t.reject:t.resolve)(n.v),t.promise}});var Rr=v.Promise,$r=t(n(function(e){e.exports={default:Rr,__esModule:!0}})),Vr="undefined"!=typeof window&&"[object Object]"!==Object.prototype.toString.call(window);function Kr(n){var e=1=o.length)){var n=Xt(o[t])?o[t].apply(o,Cn(a)):o[t];return!1===n?i("stop"):$r.resolve(n).then(function(){return e(t+1)}).catch(function(e){return i(e||"stop")})}r()}(0)})}function Gr(n){for(var e=arguments.length,r=Array(1=n.length||!1!==(Xt(n[t])?n[t].apply(n,Cn(r)):n[t])&&e(++t)}(0)}Vr&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),Vr&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.oCancelAnimationFrame);var Wr=Object.assign,Hr=!Wr||O(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=Wr({},e)[n]||Object.keys(Wr({},t)).join("")!=r})?function(e,t){for(var n=ge(e),r=arguments.length,i=1,o=$e.f,a=Ve.f;is;)void 0!==(n=i(r,t=o[s++]))&&bn(a,t,n);return a}});var zi=v.Object.getOwnPropertyDescriptors,Ni=t(n(function(e){e.exports={default:zi,__esModule:!0}})),Fi=v.Object.getOwnPropertySymbols,Di=t(n(function(e){e.exports={default:Fi,__esModule:!0}}));Ct("getOwnPropertyNames",function(){return qe.f});var Ii=v.Object,Ri=function(e){return Ii.getOwnPropertyNames(e)},$i=t(n(function(e){e.exports={default:Ri,__esModule:!0}})),Vi=Qe.f;Ct("getOwnPropertyDescriptor",function(){return function(e,t){return Vi(V(e),t)}});var Ki=v.Object,Bi=function(e,t){return Ki.getOwnPropertyDescriptor(e,t)},Gi=t(n(function(e){e.exports={default:Bi,__esModule:!0}}));function Wi(r,i){return r.bind?r.bind(i):r.apply?function(){for(var e=arguments.length,t=Array(e),n=0;n");for(var a=[],s=e,u=0,c=t.length;u as key to find the target to spy on, but not "+e+", whose type is "+(void 0===e?"undefined":bi(e)));var l,f,d,h=!0,p=function e(){h=!1;var t=n.__unwatchHandlers.indexOf(e);-1");for(var a=[],s=e,u=0,c=t.length;u]+?>/.test(t)){var r=document.createElement("div");r.innerHTML=t,t=r.children[0]}else t=document.createElement(Nn(t).replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}));else Jt(t)&&(n=t);var i=n,o=i.inner,a=i.penetrate,s=n.className,u=t&&ln(t)?t:document.createElement("div");Zt(s)&&(s=s.join(" ")),on(s)&&ui(u,s),this.plugins[e]=u;var c=o?this.container:this.wrapper,l=o?this.videoElement:this.container;return a&&(this.__dispatcher.binder.bindEventOnPenetrateNode(u),this.__videoExtendedNodes.push(u)),c.lastChild===l?c.appendChild(u):c.insertBefore(u,l.nextSibling),u}},{key:"removePlugin",value:function(e){if(on(e)){var t=this.plugins[e];ln(t)&&(t.parentNode&&t.parentNode.removeChild(t),this._autoFocusToVideo(t,!0));var n=(Tu.getPluginConfig(e)||{}).penetrate;void 0!==n&&n&&this.__dispatcher.binder.bindEventOnPenetrateNode(t,!0),delete this.plugins[e]}}},{key:"setPluginsZIndex",value:function(e){var n=this;e.forEach(function(e,t){return vi(e.match(/^(videoElement|container)$/)?n[e]:n.plugins[e],"z-index",++t)})}},{key:"setAttr",value:function(e,t,n){si(this[e],t,n)}},{key:"getAttr",value:function(e,t){return ai(this[e],t)}},{key:"setStyle",value:function(e,t,n){vi(this[e],t,n)}},{key:"getStyle",value:function(e,t){return pi(this[e],t)}},{key:"requestFullscreen",value:function(e){return Fs.open(this[e])}},{key:"exitFullscreen",value:function(){return Fs.exit()}},{key:"fullscreen",value:function(){for(var e=!(0