!function(e,t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?t(require("jquery")):t(e.jQuery)}(this,function(e){"use strict";var t="vide",o={volume:1,playbackRate:1,muted:!0,loop:!0,autoplay:!0,position:"50% 50%",posterType:"detect",resizing:!0,bgColor:"transparent",className:""},i="Not implemented";function r(e){var t,o,i,r,s,n,a,p={};for(a=0,n=(s=e.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",").split(",")).length;a<n&&(-1===(o=s[a]).search(/^(http|https|ftp):\/\//)&&-1!==o.search(":"));a++)t=o.indexOf(":"),i=o.substring(0,t),(r=o.substring(t+1))||(r=void 0),"string"==typeof r&&(r="true"===r||"false"!==r&&r),"string"==typeof r&&(r=isNaN(r)?r:+r),p[i]=r;return null==i&&null==r?e:p}function s(t,s,n){if(this.$element=e(t),"string"==typeof s&&(s=r(s)),n?"string"==typeof n&&(n=r(n)):n={},"string"==typeof s)s=s.replace(/\.\w*$/,"");else if("object"==typeof s)for(var a in s)s.hasOwnProperty(a)&&(s[a]=s[a].replace(/\.\w*$/,""));this.settings=e.extend({},o,n),this.path=s;try{this.init()}catch(e){if(e.message!==i)throw e}}s.prototype.init=function(){var o,r,s,n,a,p=this,c=p.path,d=c,u="",l=p.$element,g=p.settings,f=function(e){var t,o,i,r=(e=""+e).split(/\s+/),s="50%",n="50%";for(i=0,t=r.length;i<t;i++)"left"===(o=r[i])?s="0%":"right"===o?s="100%":"top"===o?n="0%":"bottom"===o?n="100%":"center"===o?0===i?s="50%":n="50%":0===i?s=o:n=o;return{x:s,y:n}}(g.position),h=g.posterType;r=p.$wrapper=e("<div>").addClass(g.className).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-color":g.bgColor,"background-repeat":"no-repeat","background-position":f.x+" "+f.y}),"object"==typeof c&&(c.poster?d=c.poster:c.mp4?d=c.mp4:c.webm?d=c.webm:c.ogv&&(d=c.ogv)),"detect"===h?(n=function(e){r.css("background-image","url("+e+")")},a=function(){n(this.src)},e('<img src="'+(s=d)+'.gif">').on("load",a),e('<img src="'+s+'.jpg">').on("load",a),e('<img src="'+s+'.jpeg">').on("load",a),e('<img src="'+s+'.png">').on("load",a)):"none"!==h&&r.css("background-image","url("+d+"."+h+")"),"static"===l.css("position")&&l.css("position","relative"),l.prepend(r),"object"==typeof c?(c.mp4&&(u+='<source src="'+c.mp4+'.mp4" type="video/mp4">'),c.webm&&(u+='<source src="'+c.webm+'.webm" type="video/webm">'),c.ogv&&(u+='<source src="'+c.ogv+'.ogv" type="video/ogg">'),o=p.$video=e("<video>"+u+"</video>")):o=p.$video=e('<video><source src="'+c+'.mp4" type="video/mp4"><source src="'+c+'.webm" type="video/webm"><source src="'+c+'.ogv" type="video/ogg"></video>');try{o.prop({autoplay:g.autoplay,loop:g.loop,volume:g.volume,muted:g.muted,defaultMuted:g.muted,playbackRate:g.playbackRate,defaultPlaybackRate:g.playbackRate})}catch(e){throw new Error(i)}o.css({margin:"auto",position:"absolute","z-index":-1,top:f.y,left:f.x,"-webkit-transform":"translate(-"+f.x+", -"+f.y+")","-ms-transform":"translate(-"+f.x+", -"+f.y+")","-moz-transform":"translate(-"+f.x+", -"+f.y+")",transform:"translate(-"+f.x+", -"+f.y+")",visibility:"hidden",opacity:0}).one("canplaythrough."+t,function(){p.resize()}).one("playing."+t,function(){o.css({visibility:"visible",opacity:1}),r.css("background-image","none")}),l.on("resize."+t,function(){g.resizing&&p.resize()}),r.append(o)},s.prototype.getVideoObject=function(){return this.$video[0]},s.prototype.resize=function(){if(this.$video){var e=this.$wrapper,t=this.$video,o=t[0],i=o.videoHeight,r=o.videoWidth,s=e.height(),n=e.width();n/r>s/i?t.css({width:n+2,height:"auto"}):t.css({width:"auto",height:s+2})}},s.prototype.destroy=function(){delete e[t].lookup[this.index],this.$video&&this.$video.off(t),this.$element.off(t).removeData(t),this.$wrapper.remove()},e[t]={lookup:[]},e.fn[t]=function(o,i){var r;return this.each(function(){(r=e.data(this,t))&&r.destroy(),(r=new s(this,o,i)).index=e[t].lookup.push(r)-1,e.data(this,t,r)}),this},e(document).ready(function(){var o=e(window);o.on("resize."+t,function(){for(var o,i=e[t].lookup.length,r=0;r<i;r++)(o=e[t].lookup[r])&&o.settings.resizing&&o.resize()}),o.on("unload."+t,function(){return!1}),e(document).find("[data-vide-bg]").each(function(o,i){var r=e(i),s=r.data(t+"-options"),n=r.data(t+"-bg");r[t](n,s)})})});