1"use strict";(self.webpackChunkredbarrelsgames=self.webpackChunkredbarrelsgames||[]).push([["src_js_ui_mouse-wheel-youtube_index_js"],{
1"./src/js/ui/mouse-wheel-youtube/index.js":(t,e,i)=>{i.r(e),i.d(e,{SELECTOR:()=>h,default:()=>p});var s=i("./src/js/utils/dom.js"),n=i("./src/js/utils/math.js"),r=i("./src/js/utils/mobile.js"),a=i("./src/js/utils/youtube-api.js");function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}function u(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}var h='.wysiwyg iframe[src*="youtube.com"]',c=[.1,.25,.5,.75],_=1,d=function(){function t(e,i){l(this,t),this.el=e,this.emitter=i,this.items=null,this._elements=null,this._status=0,this._initChildren=this._initChildren.bind(this)}return u(t,[{key:"init",value:function(){var t=this;r.ai||(this._elements=Array.from((0,s.$$)(h,this.el)),this._elements&&0!==this._elements.length&&(this._status=1,a.Z.load().then((function(){t._status<1||(t._initChildren(),3===t._status&&t.start())}))))}},{key:"destroy",value:function(){this.items&&this.items.forEach((function(t){return t.destroy()})),this.el=null,this.emitter=null,this.items=null,this._elements=null,this._status=0}},{key:"start",value:function(){this._status=3,this.items&&this.items.forEach((function(t){return t.start()}))}},{key:"stop",value:function(){this.items&&this.items.forEach((function(t){return t.stop()})),this._status=2}},{key:"add",value:function(t){var e=this;r.ai||(this._status<1&&(this._status=1),a.Z.load().then((function(){if(!(e._status<1)){var i=new y(t);e.items||(e.items=[]),e.items.push(i),3===e._status&&i.start()}})))}},{key:"remove",value:function(t){if(this._elements&&(this._elements=this._elements.filter((function(e){return e!==t}))),this.items){var e=this.items.findIndex((function(e){return e.el===t}));if(e>-1){var i=this.items.splice(e,1)[0];i.stop(),i.destroy()}}}},{key:"_initChildren",value:function(){this.items=this._elements.map((function(t){return new y(t)})),this._elements=null}}]),t}(),y=function(){function t(e){l(this,t),this.el=e,this.parent=this.el.parentNode,this.udid=this.el.id?this.el.id:null,this.udid||(this.udid="youtube-smooth-scroll--".concat(_++),this.el.id=this.udid);var i=new URLSearchParams(this.el.src);this._autoplay="1"===i.get("autoplay"),this._currentProgress=0,this._playerReady=!1,this._playerStatus=null,this._startEventTriggered=!1,this._tick=null,this._onClick=this._onClick.bind(this),this._onReady=this._onReady.bind(this),this._onStateChange=this._onStateChange.bind(this),this._onProgress=this._onProgress.bind(this)}return u(t,[{key:"destroy",value:function(){this._tick&&clearInterval(this._tick),this.player&&this.player.destroy(),this.el=null,this.parent=null,this.player=null,this.udid=null,this._autoplay=null,this._currentProgress=null,this._playerReady=null,this._playerStatus=null,this._startEventTriggered=null,this._tick=null,this._onClick=null,this._onReady=null,this._onStateChange=null,this._onProgress=null}},{key:"start",value:function(){this._bindEvents(),this._autoplay&&(this._onClick(),this._onStateChange({data:YT.PlayerState.PLAYING}))}},{key:"stop",value:function(){this._unbindEvents(),this.player&&(this.player.removeEventListener("onReady",this._onReady),this.player.removeEventListener("onStateChange",this._onStateChange)),this._unbindProgress()}},{key:"_bindEvents",value:function(){this.parent&&(this.el.style.pointerEvents="none",this.parent.removeEventListener("click",this._onClick),this.parent.addEventListener("click",this._onClick))}},{key:"_unbindEvents",value:function(){this.parent&&(this.el.style.pointerEvents="",this.parent.removeEventListener("click",this._onClick))}},{key:"_bindProgress",value:function(){this._tick||(this._tick=setInterval(this._onProgress,1e3))}},{key:"_unbindProgress",value:function(){this._tick&&(clearInterval(this._tick),this._tick=null)}},{key:"_trackEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;window.dataLayer&&window.dataLayer.push&&this.player&&window.dataLayer.push({event:"video_".concat(t),video_current_time:this.player.getCurrentTime(),video_duration:this.player.getDuration(),video_percent:e,video_provider:"youtube",video_title:this.player.videoTitle,video_url:this.player.getVideoUrl(),visible:!0})}},{key:"_onClick",value:function(t){t&&(t.stopPropagation(),t.preventDefault()),this.player?!0===this._playerReady&&this.player.playVideo():(this.player=new YT.Player(this.udid),this.player.addEventListener("onReady",this._onReady),this.player.addEventListener("onStateChange",this._onStateChange))}},{key:"_onReady",value:function(){this._playerReady=!0,this.player.playVideo(),this._unbindEvents()}},{key:"_onStateChange",value:function(t){this._playerReady=!0,t.data===YT.PlayerState.PLAYING&!this._startEventTriggered&&(this._startEventTriggered=!0,this._trackEvent("start",0)),t.data===YT.PlayerState.PAUSED||t.data===YT.PlayerState.ENDED?(this._bindEvents(),this._unbindProgress()):t.data===YT.PlayerState.PLAYING&&(this._unbindEvents(),this._bindProgress()),t.data===YT.PlayerState.ENDED&&(this._trackEvent("complete",100),this._startEventTriggered=!1,this._currentProgress=0)}},{key:"_onProgress",value:function(){if(this.player&&!(null===this._currentProgress||this._currentProgress>=c.length)){var t=this.player.getCurrentTime(),e=this.player.getDuration();(0,n.b9)(0,1,e>0?t/e:0)<c[this._currentProgress]||(this._trackEvent("progress",100*c[this._currentProgress]),this._currentProgress++)}}}]),t}();const p=d},
1"./src/js/utils/youtube-api.js":(t,e,i)=>{i.d(e,{Z:()=>r});var s=i("./src/js/utils/dom.js");function n(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}const r=new(function(){function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._script=null,this._ready=!1,this._promises=[],window.onYouTubeIframeAPIReady=function(){e._ready=!0,e._promises.forEach((function(t){return t()})),e._promises=null,window.onYouTubeIframeAPIReady=null}}var e,i,r;return e=t,(i=[{key:"load",value:function(){var t=this;if(this._ready)return Promise.resolve();var e=new Promise((function(e){return t._promises.push(e)}));return this._script||(this._script=document.createElement("script"),this._script.onerror=function(t){console.error("Error loading Youtube iFrame API :",t)},this._script.src="https://www.youtube.com/iframe_api",s.YM.appendChild(this._script)),e}},{key:"ready",get:function(){return this._ready}}])&&n(e.prototype,i),r&&n(e,r),t}())}
1}]); 2//# sourceMappingURL=src_js_ui_mouse-wheel-youtube_index_js.1c4616c3c71088afcfa7.bundle.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.