"use strict";(self.webpackChunk_genially_view_client=self.webpackChunk_genially_view_client||[]).push([[914],{76091:(i,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GeniallyScript=void 0;t.GeniallyScript=class{constructor(i,t){this.events={},this.script=i,this.geniallyEngine=t}}},50914:(i,t,e)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=e(66424),l=e(76091);function a(i){return 1===i.length?"0".concat(i):i}function s(i){if(void 0===i)return"00:00:00";const t=Math.floor(i/3600).toString(),e=Math.floor(i%3600/60).toString(),n=(i%60).toString();return"".concat(a(t),":").concat(a(e),":").concat(a(n))}class o extends l.GeniallyScript{constructor(i,t){super(i,t),this.events={onEnteringSlide:this.initializeCountdown.bind(this),onEnteredSlide:this.countdown.bind(this),onExitingSlide:this.clear.bind(this),onLoad:this.load.bind(this)},this.time=this.getTime()}load(){console.log("Load script")}getTime(){return parseInt(this.script.configuration.time.value,10)}initializeCountdown(){const i=this.geniallyEngine.findElementsByTag("elementsToDisplay");this.geniallyEngine.findElementsByTagAndType("playPauseButton",n.ItemType.Svg).forEach((i=>{this.geniallyEngine.addEventListener(i.id,"click",(()=>{this.interval?(this.clear(),i.opacity="0.2",i.Colors="#fff44f"):(this.countdown(),i.Colors="green",i.opacity="1")}))})),i.forEach((i=>{i.opacity="0"}));this.geniallyEngine.findElementsByTagAndType("timerText",n.ItemType.Text).forEach((i=>{i.text=s()}))}countdown(){this.time<=0&&(this.time=this.getTime());const i=this.geniallyEngine.findElementsByTagAndType("timerText",n.ItemType.Text),t=this.geniallyEngine.getConfigurationValue("elementsToDisplay");0!==i.length&&(this.interval=this.geniallyEngine.setInterval((()=>{if(this.time<0)return clearInterval(this.interval),i.forEach((i=>{this.geniallyEngine.addAnimationToItem(i.id,{type:n.ContinuousAnimation.Notification,parameters:{delayMs:1e3,durationMs:2500}})})),void this.geniallyEngine.launchEvent("finish");Array.isArray(t)&&t.forEach((i=>{if(i.configuration.time.value===this.time){this.geniallyEngine.getItemById(i.itemId).opacity="1"}})),i.forEach((i=>{i.text=s(this.time)})),this.time-=1}),1e3))}clear(){this.interval&&(this.geniallyEngine.clearInterval(this.interval),this.interval=void 0)}}t.default=o}}]);
//# sourceMappingURL=https://statics-view.genially.com/view/static/js/914.d260d575.chunk.js.map