"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),n=a(48237),i=a(68283),c=a(10285),r=a(66264),s=a(84054),l=function(e,t,a,o){return new(a||(a=Promise))((function(n,i){function c(e){try{s(o.next(e))}catch(t){i(t)}}function r(e){try{s(o.throw(e))}catch(t){i(t)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(c,r)}s((o=o.apply(e,t||[])).next())}))};const u=(e,t)=>{const a=e.item,{config:u}=e,d=u.imageItemRef,m=e=>{if(!e||e.data.type!==n.L.PlayAudio||!e.data.source)return;const{source:a}=e.data;return t.preloadAudio(a),Object.assign(Object.assign({},e.data),{source:a})},g=m(u.onStepAudio),f=m(u.onClickAudio);(g||f)&&(e.slide.audioRequirement=s.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 p=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&&p(0);let h=0;const v=(e,a)=>{const n=(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===h&&!e&&y.length>1);var a,o;return h=t,t})(a);p(n),e&&g&&t.playAudio(Object.assign(Object.assign({},g),{refId:(0,o.Ak)()}))};let A=Symbol("animationInstance");const w=e=>200+10*(6-e),b=(()=>{let e=0;for(let t=0;t<6;t+=1)e+=w(t);return e})();y.length>1&&(a.markAsInteractive=!0,a.on(r.q.Click,(()=>l(void 0,void 0,void 0,(function*(){var e;a.playAnimation({type:i.x.Wobble,parameters:{delayMs:0,durationMs:b}}),f&&t.playAudio(Object.assign(Object.assign({},f),{playMode:c.F.PlayRestart})),A=Symbol("animationInstance"),yield(e=A,l(void 0,void 0,void 0,(function*(){const o=y.length<=2;v(!0,o);for(let n=0;n<6&&(yield new Promise((e=>t.setTimeout(e,w(n)))),a.parentSlide.isCurrent&&A===e);n+=1)v(!0,!1)})));const o=u.images[h];if(o.imageAction)if(o.imageAction.data.type===n.L.PlayAudio){const e=o.imageAction.data;e.source&&t.playAudio({source:e.source,playMode:c.F.PlayRestart})}else o.imageAction.run()})))))}}}]);
//# sourceMappingURL=https://s3-static-genially.genially.com/view/static/js/1616.e344399d.chunk.js.map