Component=window.Component||{};Component.Video=function(){function e(n,t){this.pauseEvent=n;this.playEvent=t}function o(t,i,r,u){var f=this;this.type=t;this.iframe=i;this.id=r;this.setupPlayer=function(){if(!f.player)if(f.type===n.YouTube)f.player=new YT.Player(f.iframe,{videoId:f.id,playerVars:{enablejsapi:1,origin:window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.host},events:{onStateChange:function(n){n.data!==YT.PlayerState.PLAYING||!u.playEvent?n.data!==YT.PlayerState.PAUSED||!u.pauseEvent||u.pauseEvent.apply(this):u.playEvent.apply(this)}}});else{if(f.player=new Vimeo.Player(f.iframe,{id:f.id}),!!u.playEvent)f.player.on("play",u.playEvent);if(!!u.pauseEvent)f.player.on("pause",u.pauseEvent)}};this.getPlayer=function(){return f.player};this.iframe.pauseVideo=function(){!f.player||(f.type!==n.YouTube||!f.player.pauseVideo?f.type!==n.Vimeo||!f.player.pause||f.player.pause():f.player.pauseVideo())};this.iframe.playVideo=function(){!f.player||(f.type!==n.YouTube||!f.player.playVideo?f.type!==n.Vimeo||!f.player.play||f.player.play():f.player.playVideo())}}var n={YouTube:0,Vimeo:1},t=[],r={video:"[data-js-video]",wrapper:"[data-js-video-wrapper]",iframe:"[data-js-video-iframe]",thumbnail:"[data-js-video-thumb]"},i={YouTube:/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/,Vimeo:/(http|https)?:\/\/((?:www|player)\.)?vimeo.com\/(?:video\/)?(\d+)(\?.+)?/},u=function(){t.filter(function(t){return t.type===n.Vimeo}).forEach(function(n){n.setupPlayer();n.iframe.getPlayer=n.getPlayer})},f=function(){t.filter(function(t){return t.type===n.YouTube}).forEach(function(n){n.setupPlayer();n.iframe.getPlayer=n.getPlayer})},s=function(t){var r=t.src,u=r.match(i.YouTube),f=r.match(i.Vimeo);return u?n.YouTube:n.Vimeo},h=function(n){var t=n.src,r=t.match(i.YouTube),u=t.match(i.Vimeo);return r?r[5]||null:u[3]||null},c=function(n,i){var r=s(n),u=h(n);t.push(new o(r,n,u,i))},l=function(){var r=t.filter(function(t){return t.type===n.YouTube}).length,e=t.filter(function(t){return t.type===n.Vimeo}).length,i;typeof YT=="undefined"&&r>0?(i=window.onYouTubeIframeAPIReady,window.onYouTubeIframeAPIReady=function(){!i||i.apply(this);f()},$.getScript("https://www.youtube.com/iframe_api")):typeof YT!="undefined"&&r>0&&f();typeof Vimeo=="undefined"&&e?$.getScript("https://player.vimeo.com/api/player.js").done(function(){u()}):typeof Vimeo!="undefined"&&e>0&&u()};return{Init:function(){var n=this;$(r.video).each(function(){n.Bind($(this))});l()},Bind:function(n){var u=n.find(r.wrapper).first(),t=n.find("noscript").first(),i=$(t.get(0).innerText),f=n.find(r.thumbnail).first();if(t.length){c(i.get(0),new e(function(){n.removeClass("is-playing")},function(){n.addClass("is-playing")}));f.on("click",function(){var n=i.get(0);n.playVideo()});u.prepend(i);t.remove()}},GetVideos:function(){return t}}}()