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4C,iBAAiB,gBAAgBlC,SAAQ,SAACmC,GACjD,IAAIpE,EAAMoE,EACX,I","sources":["webpack://octopus.public.web/webpack/universalModuleDefinition","webpack://octopus.public.web/./Assets/js/video.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","class Video {\n constructor(el) {\n this.el = el;\n this.details = this.el.querySelector(\"[data-details]\");\n this.summary = this.el.querySelector(\"[data-toggle]\");\n this.videoId = this.el.getAttribute(\"data-video-id\");\n this.videoSource = this.el.getAttribute(\"data-video-source\");\n this.player = this.videoSource === 'yt' ? null : this.el.querySelector(\"[data-video-element]\");\n this.iframe = this.videoSource === 'yt' ? this.el.querySelector(\"[data-video-iframe]\") : null;\n this.playButton = this.el.querySelector(\"[data-video-play-button]\");\n\t\tthis.isInitialized = false;\n\t\t// Flag to initial play video when ready\n this.shouldPlayOnReady = false;\n\n if (this.videoSource === 'yt') {\n this.addVideoControls();\n } else {\n this.videoElement = this.el.querySelector(\"video\");\n this.addVideoControls();\n }\n\n // this.addEventListeners();\n }\n\n static loadYouTubeScript(videoInstance) {\n // Register this instance for initialization\n Video.instances.push(videoInstance);\n\n if (typeof YT !== 'undefined' && typeof YT.Player === 'function') {\n // YouTube API is already loaded\n videoInstance.initializePlayer();\n } else if (!Video.scriptLoading) {\n // Load the YouTube API script\n const tag = document.createElement(\"script\");\n tag.src = \"https://www.youtube.com/iframe_api\";\n const firstScriptTag = document.getElementsByTagName(\"script\")[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n\n // Set up the global callback for when the API is ready\n window.onYouTubeIframeAPIReady = () => {\n Video.scriptLoaded = true;\n Video.scriptLoading = false;\n Video.instances.forEach((instance) => instance.initializePlayer());\n Video.instances = []; // Clear the instances array\n };\n Video.scriptLoading = true;\n } else {\n // Script is already loading, do nothing\n }\n }\n\n initializePlayer() {\n this.player = new YT.Player(this.iframe, {\n height: \"390\",\n width: \"640\",\n videoId: this.videoId,\n events: {\n onReady: this.onPlayerReady.bind(this),\n onStateChange: this.onPlayerStateChange,\n },\n });\n\n window.onPlayerStateChange = (event) => {\n if (event.data == YT.PlayerState.PLAYING && !this.done) {\n setTimeout(this.player.stopVideo(), 6000);\n this.done = true;\n }\n };\n\n\t\tthis.addVideoControls();\n }\n\n\taddVideoControls() {\n this.summary.addEventListener(\"click\", () => {\n if (this.details.open) {\n\t\t\t\tif (this.videoSource === 'yt') {\n\t\t\t\t\tthis.player.pauseVideo();\n\t\t\t\t} else {\n\t\t\t\t\tthis.player.pause();\n\t\t\t\t}\n this.unlockScroll();\n } else {\n this.scrollToVideo();\n\t\t\t\tif (this.videoSource === 'yt') {\n\t\t\t\t\tif (!this.isInitialized) {\n this.shouldPlayOnReady = true; \n Video.loadYouTubeScript(this);\n this.isInitialized = true;\n } else {\n\t\t\t\t\t\tthis.player.playVideo();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.player.play();\n\t\t\t\t}\n }\n });\n\t}\n\n onPlayerReady(event) {\n if (this.shouldPlayOnReady) {\n event.target.playVideo();\n\t\t\t// Reset the initial flag\n this.shouldPlayOnReady = false;\n }\n\n this.playButton.addEventListener(\"click\", () => {\n event.target.playVideo();\n });\n }\n\n // addEventListeners() {\n // this.playButton.addEventListener(\"click\", () => {\n // if (this.player && this.player.playVideo) {\n // this.player.playVideo();\n // }\n // });\n // }\n\n scrollToVideo() {\n this.el.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n this.lockScroll();\n }\n\n lockScroll() {\n document.body.style.overflow = \"hidden\";\n }\n\n unlockScroll() {\n document.body.style.overflow = \"auto\";\n }\n}\n\n// Static properties to keep track of all instances and script load status\nVideo.instances = [];\nVideo.scriptLoaded = false;\nVideo.scriptLoading = false;\n\ndocument.querySelectorAll(\"[data-video]\").forEach((element) => {\n new Video(element);\n});\n"],"names":["root","factory","exports","module","define","amd","a","i","this","Video","el","details","querySelector","summary","videoId","getAttribute","videoSource","player","iframe","playButton","isInitialized","shouldPlayOnReady","videoElement","addVideoControls","videoInstance","instances","push","YT","Player","initializePlayer","scriptLoading","tag","document","createElement","src","firstScriptTag","getElementsByTagName","parentNode","insertBefore","window","onYouTubeIframeAPIReady","scriptLoaded","forEach","instance","height","width","events","onReady","onPlayerReady","bind","onStateChange","onPlayerStateChange","event","data","PlayerState","PLAYING","done","setTimeout","stopVideo","addEventListener","open","pauseVideo","pause","unlockScroll","scrollToVideo","playVideo","loadYouTubeScript","play","target","scrollIntoView","behavior","block","lockScroll","body","style","overflow","querySelectorAll","element"],"sourceRoot":""}