!(function (n, t, i, r) {
  'use strict';
  function e(n) {
    var u,
      i,
      f,
      t,
      e,
      o,
      r,
      s = {};
    for (
      e = n
        .replace(/\s*:\s*/g, ':')
        .replace(/\s*,\s*/g, ',')
        .split(','),
        r = 0,
        o = e.length;
      o > r &&
      ((i = e[r]),
      -1 === i.search(/^(http|https|ftp):\/\//) && -1 !== i.search(':'));
      r++
    )
      (u = i.indexOf(':')),
        (f = i.substring(0, u)),
        (t = i.substring(u + 1)),
        t || (t = void 0),
        'string' == typeof t && (t = 'true' === t || ('false' === t ? !1 : t)),
        'string' == typeof t && (t = isNaN(t) ? t : +t),
        (s[f] = t);
    return null == f && null == t ? n : s;
  }
  function o(n) {
    n = '' + n;
    for (
      var t, e = n.split(/\s+/), r = '50%', u = '50%', i = 0, f = e.length;
      f > i;
      i++
    )
      (t = e[i]),
        'left' === t
          ? (r = '0%')
          : 'right' === t
          ? (r = '100%')
          : 'top' === t
          ? (u = '0%')
          : 'bottom' === t
          ? (u = '100%')
          : 'center' === t
          ? 0 === i
            ? (r = '50%')
            : (u = '50%')
          : 0 === i
          ? (r = t)
          : (u = t);
    return { x: r, y: u };
  }
  function s(t, i) {
    var r = function () {
      i(this.src);
    };
    n("<img src='" + t + ".gif'>").load(r);
    n("<img src='" + t + ".jpg'>").load(r);
    n("<img src='" + t + ".jpeg'>").load(r);
    n("<img src='" + t + ".png'>").load(r);
  }
  function f(t, i, r) {
    if (
      ((this.$element = n(t)),
      'string' == typeof i && (i = e(i)),
      r ? 'string' == typeof r && (r = e(r)) : (r = {}),
      'string' == typeof i)
    )
      i = i.replace(/\.\w*$/, '');
    else if ('object' == typeof i)
      for (var u in i)
        i.hasOwnProperty(u) && (i[u] = i[u].replace(/\.\w*$/, ''));
    this.settings = n.extend({}, h, r);
    this.path = i;
    this.init();
  }
  var u = 'vide',
    h = {
      volume: 1,
      playbackRate: 1,
      muted: !0,
      loop: !0,
      autoplay: !0,
      position: '50% 50%',
      posterType: 'detect',
      resizing: !0,
    },
    c = /iPad|iPhone|iPod/i.test(r.userAgent),
    l = /Android/i.test(r.userAgent);
  f.prototype.init = function () {
    var f,
      r,
      t = this,
      i = o(t.settings.position);
    t.$wrapper = n('<div>').css({
      position: 'absolute',
      'z-index': -1,
      top: 0,
      left: 0,
      bottom: 0,
      right: 0,
      overflow: 'hidden',
      '-webkit-background-size': 'cover',
      '-moz-background-size': 'cover',
      '-o-background-size': 'cover',
      'background-size': 'cover',
      'background-repeat': 'no-repeat',
      'background-position': i.x + ' ' + i.y,
    });
    r = t.path;
    'object' == typeof t.path &&
      (t.path.poster
        ? (r = t.path.poster)
        : t.path.mp4
        ? (r = t.path.mp4)
        : t.path.webm
        ? (r = t.path.webm)
        : t.path.ogv && (r = t.path.ogv));
    'detect' === t.settings.posterType
      ? s(r, function (n) {
          t.$wrapper.css('background-image', 'url(' + n + ')');
        })
      : 'none' !== t.settings.posterType &&
        t.$wrapper.css(
          'background-image',
          'url(' + r + '.' + t.settings.posterType + ')'
        );
    'static' === t.$element.css('position') &&
      t.$element.css('position', 'relative');
    t.$element.prepend(t.$wrapper);
    c ||
      l ||
      ((f = ''),
      'object' == typeof t.path
        ? (t.path.mp4 &&
            (f += "<source src='" + t.path.mp4 + ".mp4' type='video/mp4'>"),
          t.path.webm &&
            (f += "<source src='" + t.path.webm + ".webm' type='video/webm'>"),
          t.path.ogv &&
            (f += "<source src='" + t.path.ogv + ".ogv' type='video/ogv'>"),
          (t.$video = n('<video>' + f + '</video>')))
        : (t.$video = n(
            "<video><source src='" +
              t.path +
              ".mp4' type='video/mp4'><source src='" +
              t.path +
              ".webm' type='video/webm'><source src='" +
              t.path +
              ".ogv' type='video/ogg'></video>"
          )),
      t.$video.css('visibility', 'hidden'),
      t.$video.prop({
        autoplay: t.settings.autoplay,
        loop: t.settings.loop,
        volume: t.settings.volume,
        muted: t.settings.muted,
        playbackRate: t.settings.playbackRate,
      }),
      t.$wrapper.append(t.$video),
      t.$video.css({
        margin: 'auto',
        position: 'absolute',
        'z-index': -1,
        top: i.y,
        left: i.x,
        '-webkit-transform': 'translate(-' + i.x + ', -' + i.y + ')',
        '-ms-transform': 'translate(-' + i.x + ', -' + i.y + ')',
        transform: 'translate(-' + i.x + ', -' + i.y + ')',
      }),
      t.$video.bind('loadedmetadata.' + u, function () {
        t.$video.css('visibility', 'visible');
        t.resize();
        t.$wrapper.css('background-image', 'none');
      }),
      t.$element.bind('resize.' + u, function () {
        t.settings.resizing && t.resize();
      }));
  };
  f.prototype.getVideoObject = function () {
    return this.$video ? this.$video[0] : null;
  };
  f.prototype.resize = function () {
    if (this.$video) {
      var i = this.$video[0].videoHeight,
        r = this.$video[0].videoWidth,
        n = this.$wrapper.height(),
        t = this.$wrapper.width();
      this.$video.css(
        t / r > n / i
          ? { width: t + 2, height: 'auto' }
          : { width: 'auto', height: n + 2 }
      );
    }
  };
  f.prototype.destroy = function () {
    this.$element.unbind(u);
    this.$video && this.$video.unbind(u);
    delete n[u].lookup[this.index];
    this.$element.removeData(u);
    this.$wrapper.remove();
  };
  n[u] = { lookup: [] };
  n.fn[u] = function (t, i) {
    var r;
    return (
      this.each(function () {
        r = n.data(this, u);
        r && r.destroy();
        r = new f(this, t, i);
        r.index = n[u].lookup.push(r) - 1;
        n.data(this, u, r);
      }),
      this
    );
  };
  n(i).ready(function () {
    n(t).bind('resize.' + u, function () {
      for (var t, r = n[u].lookup.length, i = 0; r > i; i++)
        (t = n[u].lookup[i]), t && t.settings.resizing && t.resize();
    });
    n(i)
      .find('[data-' + u + '-bg]')
      .each(function (t, i) {
        var r = n(i),
          f = r.data(u + '-options'),
          e = r.data(u + '-bg');
        r[u](e, f);
      });
  });
})(window.jQuery, window, document, navigator);
