"use strict";(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[915],{86915:(e,t,o)=>{o.r(t);var n=o(78673),a=o(34089);class i extends n.A{constructor(e){if(super(e),this.divid=e.orig.id,this.container=document.getElementById(this.divid),this.caption="YouTube",null==document.getElementById("youtubescript")){let e=document.createElement("script");e.id="youtubescript",e.src="https://www.youtube.com/player_api",document.body.appendChild(e)}this.containerDiv=this.container.parentElement,this.addCaption("runestone"),this.indicate_component_ready()}}function d(){let e=document.createElement("script");e.src="https://www.youtube.com/player_api",document.body.appendChild(e)}window.onPlayerStateChange=function(e){let t=new n.A,o=e.target.getCurrentTime(),a={event:"video",div_id:e.target.getIframe().id};e.data==YT.PlayerState.PLAYING?(console.log("playing "+e.target.getIframe().id),a.act="play:"+o):e.data==YT.PlayerState.ENDED?(console.log("ended "+e.target.getIframe().id),a.act="complete"):e.data==YT.PlayerState.PAUSED?(console.log("paused at "+o),a.act="pause:"+o):(console.log(`YT Player State: ${YT.PlayerState}`),a.act="ready"),t.logBookEvent(a)},window.onYouTubeIframeAPIReady=function(){for(let e of document.querySelectorAll(".youtube-video")){let t={};t.start=(0,a.Qt)(e,"video-start"),-1!=(0,a.Qt)(e,"video-end")&&(t.end=(0,a.Qt)(e,"video-end")),new YT.Player((0,a.Qt)(e,"video-divid"),{height:(0,a.Qt)(e,"video-height"),width:(0,a.Qt)(e,"video-width"),videoId:(0,a.Qt)(e,"video-videoid"),align:"center",playerVars:t,events:{onStateChange:window.onPlayerStateChange}})}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),document.addEventListener("runestone:login-complete",(function(){for(let t of document.querySelectorAll("[data-component=youtube]")){var e={orig:t,useRunestoneServices:eBookConfig.useRunestoneServices};window.componentMap[t.id]=new i(e)}})),void 0===window.component_factory&&(window.component_factory={}),window.component_factory.youtube=function(e){return new i(e)},window.component_factory.vimeo=function(e){return new i(e)}}}]);
//# sourceMappingURL=915.dd69731e7a3826eb.js.map