"use strict";(self.webpackChunk_genially_view_client=self.webpackChunk_genially_view_client||[]).push([[1616],{91616:(e,t,a)=>{a.r(t),a.d(t,{geniallyRandomImageViewScript:()=>u});var o=a(54072),i=a(48237),n=a(68283),c=a(10285),s=a(66264),r=a(84054),l=function(e,t,a,o){return new(a||(a=Promise))((function(i,n){function c(e){try{r(o.next(e))}catch(t){n(t)}}function s(e){try{r(o.throw(e))}catch(t){n(t)}}function r(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(c,s)}r((o=o.apply(e,t||[])).next())}))};const u=(e,t)=>{const a=e.item,{config:u}=e,d=u.imageItemRef,g=[],m=e=>{if(!e||e.data.type!==i.L.PlayAudio||!e.data.source)return;const{source:a}=e.data;return t.preloadAudio(a),Object.assign(Object.assign({},e.data),{source:a})},p=m(u.onStepAudio),f=m(u.onClickAudio);(p||f)&&(e.slide.audioRequirement=r.w.ShowMute);const y=u.images.filter((e=>!!e.image.source)).map((e=>({source:e.image.source,altText:e.image.altText})));u.images.forEach((e=>{e.imageAction&&e.imageAction.preload()}));const h=e=>{if(d){const t=y[e];d.alternativeText=t.altText,d.source=t.source}};y.forEach((e=>{t.preloadImage(e.source)})),u.showCoverImage?(u.coverImage.source&&t.preloadImage(u.coverImage.source),d&&(d.alternativeText=u.coverImage.altText)):y.length>0&&h(0);let v=0;const A=(e,a)=>{const i=(e=>{let t;do{a=0,o=y.length-1,a=Math.ceil(a),o=Math.floor(o),t=Math.floor(Math.random()*(o-a+1))+a}while(t===v&&!e&&y.length>1);var a,o;return v=t,t})(a);h(i),e&&p&&t.playAudio(Object.assign(Object.assign({},p),{refId:(0,o.Ak)()}))};let b=Symbol("animationInstance");const I=e=>200+10*(6-e),w=(()=>{let e=0;for(let t=0;t<6;t+=1)e+=I(t);return e})();y.length>1&&(a.markAsInteractive=!0,a.on(s.q.Click,(()=>l(void 0,void 0,void 0,(function*(){let e;var o;g.forEach((e=>{t.playAudio(Object.assign(Object.assign({},e),{playMode:c.F.Stop}))})),g.length=0,a.playAnimation({type:n.x.Wobble,parameters:{delayMs:0,durationMs:w}}),f&&(e=t.playAudio(Object.assign(Object.assign({},f),{playMode:c.F.PlayRestart}))),b=Symbol("animationInstance"),yield(o=b,l(void 0,void 0,void 0,(function*(){const e=y.length<=2;A(!0,e);for(let i=0;i<6&&(yield new Promise((e=>t.setTimeout(e,I(i)))),a.parentSlide.isCurrent&&b===o);i+=1)A(!0,!1)})));const s=u.images[v];if(s.imageAction)if(s.imageAction.data.type===i.L.PlayAudio){const a=s.imageAction.data;if(a.source){f&&e&&t.playAudio(Object.assign(Object.assign({},f),{refId:e.refId,playMode:c.F.PlayStop}));const o={source:a.source,playMode:c.F.PlayStop},i=t.playAudio(o);g.push(Object.assign(Object.assign({},o),{refId:i.refId,completed:!1}))}}else s.imageAction.run()})))))}}}]);
//# sourceMappingURL=https://s3-static-genially.genially.com/view/static/js/1616.4716386b.chunk.js.map