(function(){"use strict";const he=':root{--player-controls-background-color: rgba(0, 0, 0, .2);--player-progress-value: 0;--player-volume-value: 0}div#mn-video-player-container.mn-adv-started>button#mn-play-button,div#mn-video-player-container.mn-adv-started>div#mn-controls-container{display:none!important}div#mn-controls-container.visible{height:20%;min-height:45px}div#mn-controls-container.visible>div#mn-info-and-buttons-container{display:flex}div#mn-controls-container.visible div#mn-subtitle-list-container.visible{display:flex}button#mn-play-button.visible{opacity:1}button#mn-play-button{background-color:var(--player-controls-background-color);left:50%;max-width:80px;min-width:40px;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);transition:opacity .5s;width:15%;z-index:2}button#mn-play-button>svg{width:75%}div#mn-controls-container{align-items:center;background-color:var(--player-controls-background-color);bottom:0;display:flex;flex-direction:column;max-height:60px;position:absolute;width:100%;z-index:2}div#mn-subtitle-list-container{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);background-color:var(--player-controls-background-color);border-radius:10px;border:1px solid white;bottom:100%;color:#fff;display:none;flex-direction:column;font-family:Verdana,sans-serif;font-size:small;gap:5px;padding:10px;position:absolute;right:5%}div.mn-subtitle-option{border-radius:5px;cursor:pointer;padding:5px}div.mn-subtitle-option.enabled{color:var(--player-color)}div.mn-subtitle-option:not(.enabled):hover{background:#ffffff14}video#mn-outstream-video-player::cue{line-height:55px}video#mn-outstream-video-player.controls-visible::cue{line-height:100px}input#mn-progress-bar,input#mn-controls-volume{-webkit-appearance:none;background:linear-gradient(to right,var(--player-color) 100%,transparent 100%) no-repeat;border-radius:4px;height:8px;margin:0}input#mn-progress-bar::-webkit-slider-runnable-track,input#mn-controls-volume::-webkit-slider-runnable-track{border-radius:4px;border:1px solid white;cursor:pointer;height:100%}input#mn-progress-bar::-webkit-slider-thumb,input#mn-controls-volume::-webkit-slider-thumb{-webkit-appearance:none;background-color:var(--player-color);border-radius:50%;cursor:pointer;height:14px;margin-top:-4.5px;width:14px}input#mn-progress-bar::-moz-range-track,input#mn-controls-volume::-moz-range-track{border-radius:4px;border:1px solid white;cursor:pointer;height:100%}input#mn-progress-bar::-moz-range-thumb,input#mn-controls-volume::-moz-range-thumb{background-color:var(--player-color);border-radius:50%;cursor:pointer;height:14px;margin-top:-4.5px;width:14px}div#mn-progress-bar-container{width:95%}input#mn-progress-bar{background-size:var(--player-progress-value) 100%;width:100%}div#mn-info-and-buttons-container{align-items:center;display:none;height:100%;width:95%}div#mn-video-info-container{align-items:center;display:flex;height:100%;margin-right:20px}span.mn-video-timer{color:#fff;font-family:Verdana,sans-serif;font-size:smaller}span#mn-video-duration:before{content:"/";margin:0 5px}div#mn-buttons-container{align-items:center;display:flex;width:100%}div#mn-volume-container{align-items:center;display:flex;width:50%}input#mn-controls-volume.visible{opacity:1}input#mn-controls-volume{background-size:var(--player-volume-value) 100%;margin-left:5px;opacity:0;transition:opacity .5s;width:50%}div#mn-options-container{align-items:center;display:flex;justify-content:flex-end;width:50%}button#mn-subtitle-button{margin-right:20px}button.mn-controls-button{align-items:center;background:none;border-radius:5px;border:0;color:#fff;cursor:pointer;display:flex;justify-content:center;padding:0;width:20px}button.mn-controls-button>svg{width:100%}div#mn-video-player-container.fullscreen-mode input#mn-controls-volume{width:25%!important}div#mn-outstream-container.mn-incontent.mn-small-incontent-type div#mn-volume-container{width:65%!important}div#mn-outstream-container.mn-incontent.mn-small-incontent-type div#mn-options-container{width:35%!important}:root{--player-color: rgb(96, 45, 53);--player-inslide-height: calc((var(--player-inslide-width) / 16) * 9);--player-inslide-mobile-height: calc((var(--player-inslide-mobile-width) / 16) * 9);--player-inslide-mobile-width: 250px;--player-inslide-offset-bottom: 10px;--player-inslide-offset-top: 10px;--player-inslide-width: 445px}div#mn-outstream-container *{box-sizing:border-box}div#mn-outstream-container{background-color:#000!important}div#mn-outstream-container.mn-incontent{width:100%}div#mn-outstream-container.mn-incontent div#mn-close-button{display:none}div#mn-outstream-container.mn-inslide{bottom:var(--player-inslide-offset-bottom);position:fixed;width:var(--player-inslide-width);z-index:9999}div#mn-outstream-container.mn-inslide.mn-position-right{right:15px;transition:right .3s linear}div#mn-outstream-container.mn-inslide.mn-offscreen-right{right:-1000px;transition:right .3s linear}div#mn-outstream-container.mn-inslide.mn-position-left{left:15px;transition:left .3s linear}div#mn-outstream-container.mn-inslide.mn-offscreen-left{left:-1000px;transition:left .3s linear}div#mn-outstream-container.mn-inslide.mn-position-center{bottom:var(--player-inslide-offset-bottom);left:50%;transform:translate(-50%);transition:bottom .3s linear}div#mn-outstream-container.mn-inslide.mn-offscreen-center{bottom:-1000px;transition:bottom .3s linear}div#mn-outstream-container.mn-inslide.mn-position-top{bottom:unset;left:50%;top:var(--player-inslide-offset-top);transform:translate(-50%);transition:top .3s linear}div#mn-outstream-container.mn-inslide.mn-offscreen-top{bottom:unset;top:-1000px;transition:top .3s linear}div#mn-video-player-container{display:flex;height:100%;position:relative;width:100%}video#mn-outstream-video-player{width:100%}div#mn-outstream-container.mn-inslide video#mn-outstream-video-player{height:var(--player-inslide-height)}div#mn-outstream-container div#mn-close-button{background-color:var(--player-color);border-radius:50%;color:#fff;cursor:pointer;font-family:sans-serif;position:absolute;text-align:center;vertical-align:middle;width:25px;z-index:1000}div#mn-outstream-container.mn-inslide div#mn-close-button{font-size:15px;line-height:25px;width:25px}div#mn-close-button.bottom-right{bottom:0;right:0;transform:translate(50%,50%)}div#mn-close-button.bottom-left{bottom:0;left:0;transform:translate(-50%,50%)}div#mn-close-button.top-right{right:0;top:0;transform:translate(50%,-50%)}div#mn-close-button.top-left{left:0;top:0;transform:translate(-50%,-50%)}div#mn-title-container,div#mn-injected-title-container{background-color:#000;color:#fff;font-family:sans-serif;font-weight:600;padding:5px;position:relative;text-align:left;width:100%}div#mn-title-container p,div#mn-injected-title-container p{margin:0}div#mn-title-container p#mn-title-text{overflow-wrap:break-word}div#mn-title-container.mn-adv-countdown-running{overflow:hidden}div#mn-title-container.mn-adv-countdown-running p#mn-title-text{filter:blur(3px);opacity:.5;-webkit-user-select:none;user-select:none}div#mn-title-container.mn-adv-countdown-running p#mn-adv-countdown{left:5px;overflow:hidden;position:absolute;right:5px;text-align:center;text-overflow:ellipsis;text-shadow:0 0 4px black;top:50%;transform:translateY(-50%);white-space:nowrap}div#mn-adv-container{height:100%;left:0;position:absolute;top:0;width:100%;z-index:3}div#mn-adv-container.adv-paused>button#mn-adv-play-button{opacity:1}button#mn-adv-play-button{background-color:#0003;left:50%;max-width:80px;min-width:40px;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:15%}button#mn-adv-close-button{position:absolute;top:10px}button#mn-adv-close-button.mn-adv-close-position-left{left:10px}button#mn-adv-close-button.mn-adv-close-position-right{right:10px}div#mn-adv-controls-container{bottom:5px;display:flex;justify-content:space-between;padding:5px 20px;position:absolute;width:100%;z-index:3}button#mn-adv-close-button,div#mn-adv-controls-container>button.mn-controls-button{max-width:25px;min-width:15px;width:25%}button#mn-adv-close-button svg,div#mn-adv-controls-container>button.mn-controls-button svg{filter:drop-shadow(0px 0px 1px black);width:100%}video#mn-test-video{display:none}div#mn-video-player-container.mn-adv-started div#mn-injected-container{display:none!important}div#mn-injected-container{align-items:center;display:flex;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}div#mn-injected-container.slot-render-ended{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);z-index:3}div#mn-video-player-container.fullscreen-mode video#mn-outstream-video-player{height:100%!important}.mn-status-hidden{display:none!important}.mn-max-width{width:100%!important}@media only screen and (max-width:768px){div#mn-outstream-container.mn-inslide{width:var(--player-inslide-mobile-width)}div#mn-outstream-container.mn-inslide video#mn-outstream-video-player{height:var(--player-inslide-mobile-height)!important}div#mn-title-container,div#mn-injected-title-container{font-size:11px;font-weight:400}}',me=` `,_=` `,F=` `,pe=` `,ge=` `,be=` `,ve=` `,U=` `,fe=` `,ye=` `;function M(i){const e=Math.floor(i/60),t=Math.floor(i%60);return t<10?`${e}:0${t}`:`${e}:${t}`}function W({formattedVideoCurrentTime:i,formattedVideoTotalTime:e}){const t=i||"0:00",n=e||"0:00",s=t.split(":"),o=n.split(":");return`${s[0]} Minuti ${s[1]} Secondi di ${o[0]} Minuti ${o[1]} Secondi`}function N({adsManagerResize:i,debugService:e,videoContainer:t,videoElement:n}){if(document.fullscreenElement){document.exitFullscreen().then(()=>{t.classList.remove("fullscreen-mode"),i({height:t.clientHeight,width:t.clientWidth})}).catch(r=>e.debug("Error exiting Full screen mode",r));return}try{const r=window.screen.orientation.type.startsWith("portrait")?"portrait":"any";window.screen.orientation.lock(r)}catch(r){e.debug("Screen orientation error:",r)}let s=!1;const o=z?t:n;typeof o.requestFullscreen=="function"?(o.requestFullscreen(),s=!0):typeof o.mozRequestFullScreen=="function"?(o.mozRequestFullScreen(),s=!0):typeof o.webkitRequestFullscreen=="function"?(o.webkitRequestFullscreen(),s=!0):typeof o.msRequestFullscreen=="function"?(o.msRequestFullscreen(),s=!0):o.webkitSupportsFullscreen&&typeof o.webkitEnterFullScreen=="function"&&(o.webkitEnterFullScreen(),s=!0),s&&(t.classList.add("fullscreen-mode"),i({height:window.screen.height,width:window.screen.width,viewMode:"FULLSCREEN"}))}function we({progressBar:i,videoElement:e}){window.requestAnimationFrame(()=>{const t=Math.floor(e.currentTime/e.duration*100);i.value=String(t),i.style.setProperty("--player-progress-value",`${t}%`)})}function Q(i){window.requestAnimationFrame(()=>{const e=Math.floor(Number(i.value)*100);i.setAttribute("aria-valuetext",`${e}% volume`),i.style.setProperty("--player-volume-value",`${e}%`)})}let R,K=!1;function Ce({debugService:i,fullScreenButton:e,progressBar:t,videoContainerElement:n,videoCurrentTime:s,videoElement:o,videoTotalTime:r}){t.oninput=()=>{K=!0,o.paused||o.pause();const a=Number(t.value)/100*o.duration,g=M(a);s.innerHTML=g,t.setAttribute("aria-valuenow",`${W({formattedVideoCurrentTime:g,formattedVideoTotalTime:R})}`),t.style.setProperty("--player-progress-value",`${t.value}%`)},t.onchange=()=>{K=!1;const a=Number(t.value)/100*o.duration,g=M(a);o.currentTime=a,t.setAttribute("aria-valuenow",`${W({formattedVideoCurrentTime:g,formattedVideoTotalTime:R})}`),o.paused&&k(o).then(()=>i.debug("Starting video content")).catch(m=>i.warn("Error while starting video content",m))},o.preload="metadata",o.onloadedmetadata=()=>{try{const l=Number.isFinite(o.currentTime)?M(o.currentTime):"";R=Number.isFinite(o.duration)?M(o.duration):"",s.innerHTML=l,r.innerHTML=R,t.setAttribute("aria-valuenow",`${W({formattedVideoCurrentTime:l,formattedVideoTotalTime:R})}`)}catch(l){i.debug("On load metadata error, no value is set for videoTotalTime and videoCurrentTime",l)}},o.addEventListener("play",()=>{n.classList.add("mn-video-started"),n.classList.contains("mn-content-resume")&&e.classList.remove("mn-status-hidden")},{once:!0,passive:!0}),o.ontimeupdate=()=>{if(K)return;const l=M(o.currentTime);s.innerHTML=l,t.setAttribute("aria-valuenow",`${W({formattedVideoCurrentTime:l,formattedVideoTotalTime:R})}`),we({progressBar:t,videoElement:o})}}let ne;function G({controlsContainer:i,playButton:e,videoElement:t}){i.classList.contains("visible")||(e.classList.add("visible"),i.classList.add("visible"),t.classList.add("controls-visible")),clearTimeout(ne),ne=setTimeout(()=>{t.paused||(e.classList.remove("visible"),i.classList.remove("visible"),t.classList.remove("controls-visible"))},5e3)}function se({debugService:i,toggleVideoAutoPlay:e,videoElement:t}){t.paused?k(t).then(()=>i.debug("Starting video content")).catch(n=>i.warn("Error while starting video content",n)):V(t,i),e()}function Y({debugService:i,label:e,subtitleListContainer:t,videoElement:n}){try{e==="Off"?i.debug("Disabling subtitles"):i.debug(`Enabling subtitles for: ${e}`);const s=t.querySelectorAll("div.mn-subtitle-option");for(const r of s)r.getAttribute("data-label")===e?(r.classList.add("enabled"),r.setAttribute("aria-selected","true")):(r.classList.remove("enabled"),r.setAttribute("aria-selected","false"));const o=n.textTracks;for(const r of o){if(r.label!==e){r.mode="disabled";continue}r.mode="showing"}}catch(s){i?.debug?.("Toggle subtitles error",s)}t.classList.remove("visible")}function oe(i,e){if(i.paused){e.innerHTML=U,e.setAttribute("aria-label","Riproduci video");return}e.innerHTML=ve,e.setAttribute("aria-label","Metti in pausa il video")}let D=0;function X({debugService:i,iconClicked:e,onKeyBoardEvent:t,videoElement:n,volumeButton:s,volumeInput:o}){const r=o!=null;if(e||t)i.debug("Updating volume with click on icon or with keyboard"),n.muted?(D===0&&(D=.4),n.muted=!1,n.volume=D,r&&(o.value=String(D))):(D=n.volume,n.muted=!0,n.volume=0,r&&(o.value="0")),r&&Q(o);else{i.debug("Updating volume with the input bar");const l=Number(o.value);D=l,n.volume=l,n.muted=n.volume===0}i.debug(`Volume updated to ${n.volume}`),s.innerHTML=$({volume:n.volume,volumeButton:s})}function $({volume:i,volumeButton:e}){if(i===0)return e.setAttribute("aria-pressed","false"),be;if(e.setAttribute("aria-pressed","true"),i>0&&i<=.5)return ge;if(i>.5)return pe}class x{device;static DeviceType={DESKTOP:"desktop",TABLET:"tablet",MOBILE:"mobile"};constructor(e){this.isDesktopWidth(e)?this.device=x.DeviceType.DESKTOP:this.isTabletWidth(e)?this.device=x.DeviceType.TABLET:this.device=x.DeviceType.MOBILE}get deviceType(){return this.device}isDesktopWidth(e){return e>=1025}isTabletWidth(e){return e<1025&&e>=768}}const re=new x(window.innerWidth).deviceType,z=re===x.DeviceType.DESKTOP,Ae=re===x.DeviceType.MOBILE;function O(i){return!!new URLSearchParams(window.location.search).get(i)}function Te(i){try{return window.localStorage.getItem(i)}catch(e){return console.error(`Error while getting ${i} from local storage`,e),null}}function Ee(){typeof window.mnPlayerQueue=="object"&&Array.isArray(window.mnPlayerQueue.queue)||(window.mnPlayerQueue={queue:[]})}function Le(){typeof window.mnPlayerQueue=="object"&&Array.isArray(window.mnPlayerQueue.queue)?window.mnPlayerQueue.queue.forEach(function(e){e()}):Ee(),Pe()}function Pe(){window.mnPlayerQueue.queue={},window.mnPlayerQueue.queue.push=function(e){e()},Object.freeze(window.mnPlayerQueue)}function d({elementType:i="div",elementId:e,className:t}={}){const n=document.createElement(i);return e!=null&&(n.id=e),t!=null&&n.classList.add(t),n}let J=!1;function Se({playerControls:i,videoContentTitle:e,videoElement:t}){t.onplay=()=>{i?.playButton!=null&&oe(t,i.playButton);const n=J?"video-resumed":"video-started";J||(J=!0),Z({type:n,videoContentTitle:e,videoElement:t})},t.onpause=()=>{i?.playButton!=null&&oe(t,i.playButton),Z({type:"video-paused",videoContentTitle:e,videoElement:t})},t.addEventListener("ended",()=>{i!=null&&(i.playButton.innerHTML=fe,i.playButton.classList.add("visible"),i.controlsContainer.classList.add("visible")),Z({type:"video-ended",videoContentTitle:e,videoElement:t})},{passive:!0})}function Z({type:i,videoContentTitle:e,videoElement:t}){window.dispatchEvent(new CustomEvent(i,{detail:{event:i,title:e,video_duration:M(t.duration),event_raised_at:performance.now()}}))}function v(){return new Promise(i=>{if("scheduler"in window&&typeof window.scheduler=="object"&&window.scheduler!=null){if("yield"in window.scheduler&&typeof window.scheduler.yield=="function")return window.scheduler.yield().then(()=>i(!0));if("postTask"in window.scheduler&&typeof window.scheduler.postTask=="function")return window.scheduler.postTask(()=>i(!0),{priority:"user-visible"})}setTimeout(()=>i(!0),0)})}const ae=new WeakMap;function V(i,e){const t=ae.get(i);return t?t.then(()=>{i.pause()}).catch(n=>{e.warn("The video was not paused, its play() failed:",n)}):(e.warn("Attempting to pause the video can not be accomplished, this may indicate that play was never called."),Promise.resolve())}function k(i){const e=new Promise((t,n)=>{try{const s=i.play();s!==void 0&&typeof s.then=="function"?s.then(()=>t()).catch(o=>n(o)):t()}catch(s){n(s)}});return ae.set(i,e),e}function ke({adsManagerResize:i,debugService:e,isAdTagUrlDefined:t,isDesktop:n,isMobile:s,subtitles:o,toggleVideoAutoPlay:r,videoContainerElement:l,videoElement:a}){const g=d({elementId:"mn-buttons-container"}),m=d({elementId:"mn-controls-container"}),u=d({elementId:"mn-info-and-buttons-container"}),c=d({elementId:"mn-options-container"}),p=d({elementId:"mn-progress-bar-container"}),w=d({elementId:"mn-video-info-container"}),P=d({elementId:"mn-volume-container"}),y=d({elementType:"button",elementId:"mn-play-button",className:"mn-controls-button"});y.setAttribute("data-title","Play (k)"),y.setAttribute("aria-keyshortcuts","k"),y.setAttribute("aria-label","Riproduci video"),y.innerHTML=U,a.paused&&(y.classList.add("visible"),m.classList.add("visible"),a.classList.add("controls-visible"));const E=d({elementType:"input",elementId:"mn-progress-bar"});E.type="range",E.name="video-progress",E.min="0",E.max="100",E.step="0.01",E.value="0";const S=d({elementType:"span",elementId:"mn-video-current-time",className:"mn-video-timer"}),T=d({elementType:"span",elementId:"mn-video-duration",className:"mn-video-timer"}),h=d({elementType:"button",elementId:"mn-volume-button",className:"mn-controls-button"});h.setAttribute("data-title","Volume (m)"),h.setAttribute("aria-keyshortcuts","m"),h.setAttribute("aria-label","Attiva audio video"),h.innerHTML=$({volume:a.volume,volumeButton:h}),h.onclick=async()=>{await v(),X({debugService:e,iconClicked:!0,onKeyBoardEvent:!1,videoElement:a,volumeButton:h,volumeInput:b})};let b;s||(b=d({elementType:"input",elementId:"mn-controls-volume"}),b.type="range",b.name="volume",b.min="0",b.max="1",b.step="0.05",b.value=String(a.volume),Q(b),b.oninput=()=>Q(b),b.onchange=()=>{X({debugService:e,iconClicked:!1,onKeyBoardEvent:!1,videoElement:a,volumeButton:h,volumeInput:b})},P.onmouseover=()=>b.classList.add("visible"),P.onmouseleave=()=>b.classList.remove("visible"));let L,A;if(o.enableSubtitles&&Array.isArray(o.subtitleTrackList)){L=d({elementType:"button",elementId:"mn-subtitle-button",className:"mn-controls-button"}),L.setAttribute("data-title","Sottotitoli (c)"),L.setAttribute("aria-keyshortcuts","c"),L.setAttribute("aria-label","Attiva sottotitoli"),L.innerHTML=ye,A=d({elementId:"mn-subtitle-list-container"}),A.onmouseleave=()=>A.classList.remove("visible");const I=d({className:"mn-subtitle-option"});I.innerText="Off",I.setAttribute("data-label","Off"),I.onclick=async()=>{await v(),Y({debugService:e,label:"Off",subtitleListContainer:A,videoElement:a})},A.appendChild(I);for(const q of o.subtitleTrackList){const j=d({className:"mn-subtitle-option"});j.innerText=q.label,j.setAttribute("data-label",q.label),j.onclick=async()=>{await v(),Y({debugService:e,label:q.label,subtitleListContainer:A,videoElement:a})},A.appendChild(j)}setTimeout(()=>{Y({debugService:e,label:o.defaultSubtitle,subtitleListContainer:A,videoElement:a})},0),L.onclick=async()=>{if(await v(),A.classList.contains("visible")){e.debug("Hiding subtitle list"),A.classList.remove("visible");return}e.debug("Showing subtitle list"),A.classList.add("visible")}}const C=d({elementType:"button",elementId:"mn-fullscreen-button",className:"mn-controls-button"});return C.setAttribute("data-title","Fullscreen (f)"),C.setAttribute("aria-keyshortcuts","f"),C.setAttribute("aria-label","Attiva modalità schermo intero"),C.setAttribute("aria-pressed","false"),C.innerHTML=_,!n&&t&&C.classList.add("mn-status-hidden"),l.onfullscreenchange=()=>{if(!document.fullscreenElement){e.debug("Exited from Full screen mode"),l.classList.remove("fullscreen-mode"),C.setAttribute("aria-pressed","false"),C.innerHTML=_,i({height:l.clientHeight,width:l.clientWidth});return}e.debug("Enter in Full screen mode"),C.setAttribute("aria-pressed","true"),C.innerHTML=F,G({controlsContainer:m,playButton:y,videoElement:a}),l.onmousemove=()=>G({controlsContainer:m,playButton:y,videoElement:a})},l.onfullscreenerror=I=>e.error("fullscreenerror",I),n?(y.onclick=async()=>{await v(),se({debugService:e,toggleVideoAutoPlay:r,videoElement:a})},C.onclick=async()=>{await v(),N({adsManagerResize:i,debugService:e,videoContainer:l})},l.onmouseover=()=>{document.fullscreenElement||(y.classList.add("visible"),m.classList.add("visible"),a.classList.add("controls-visible"))},l.onmouseleave=()=>{!a.paused&&!document.fullscreenElement&&(y.classList.remove("visible"),m.classList.remove("visible"),a.classList.remove("controls-visible")),A?.classList.remove("visible")}):(y.onpointerup=async()=>{await v(),se({debugService:e,toggleVideoAutoPlay:r,videoElement:a}),!a.paused&&(y.classList.remove("visible"),m.classList.remove("visible"),a.classList.remove("controls-visible"))},C.onpointerup=async()=>{await v(),N({adsManagerResize:i,debugService:e,videoElement:a})},l.onpointerdown=async()=>{await v(),G({controlsContainer:m,playButton:y,videoElement:a})}),Ce({debugService:e,fullScreenButton:C,progressBar:E,videoContainerElement:l,videoCurrentTime:S,videoElement:a,videoTotalTime:T}),p.appendChild(E),w.appendChild(S),w.appendChild(T),P.appendChild(h),b!=null&&P.appendChild(b),L!=null&&c.appendChild(L),c.appendChild(C),g.appendChild(P),g.appendChild(c),u.appendChild(w),u.appendChild(g),A!=null&&m.appendChild(A),m.appendChild(p),m.appendChild(u),l.appendChild(y),l.appendChild(m),{controlsContainer:m,fullScreenButton:C,playButton:y,subtitleButton:L,volumeButton:h,volumeInput:b}}function Ie(i,e){if(window.Hls)return Promise.resolve(window.Hls);let t;try{t=new Function("specifier","return import(specifier);")}catch{t=null}return t&&e?t(e).then(n=>n.default||n).catch(()=>le(i)):le(i)}function le(i){return new Promise((e,t)=>{const n=document.createElement("script");n.src=i,n.onload=()=>e(window.Hls),n.onerror=()=>t(new Error(`Failed to load HLS library from: ${i}`)),document.head.appendChild(n)})}async function xe({debugService:i,hlsEsmLibraryUrl:e,hlsLibraryUrl:t,source:n,subtitles:s,videoElement:o,vipSource:r}){return new Promise(l=>{if(n==null){i.debug("Video source NOT found, using the default vipSource"),ee({source:r,type:"video/mp4",videoElement:o}),l();return}i.debug("Video source found");const a="mp4",g="m3u8";switch(n.split(".").pop()){case a:{i.debug(`Video extension is ${a}`),ee({source:n,type:"video/mp4",videoElement:o}),l();break}case g:{i.debug(`Video extension is ${g}, loading HLS library dynamically`),Ie(t,e).then(u=>{if(!u.isSupported())return de({debugService:i,source:n,videoElement:o});i.debug("Hls.js is supported");const c=new u;c.loadSource(n),c.attachMedia(o),c.on(u.Events.MEDIA_ATTACHED,()=>i.debug("HLS media attached")),c.on(u.Events.MANIFEST_PARSED,(p,w)=>{i.debug(`HLS manifest loaded, found ${w.levels.length} quality level`)}),c.on(u.Events.ERROR,(p,w)=>{if(i.debug("HLS error encountered",w),w.fatal)switch(i.debug("HLS fatal error encountered, trying to recover"),w.type){case u.ErrorTypes.NETWORK_ERROR:{i.error("HLS fatal network error encountered",p),c.startLoad();break}case u.ErrorTypes.MEDIA_ERROR:{i.error("HLS fatal media error encountered",p),c.recoverMediaError();break}default:i.error("HLS fatal error cannot be recovered, destroying Hls instance",p),c.destroy()}}),l()}).catch(u=>{i.error("Failed to load HLS library",u),de({debugService:i,source:n,videoElement:o}),l()});break}default:{i.error(`Video extension is not supported. Supported extensions are: ${a}, ${g}`),l();return}}s.enableSubtitles&&Me({debugService:i,subtitleTrackList:s.subtitleTrackList,videoElement:o})})}function ee({source:i,type:e,videoElement:t}){const n=d({elementType:"source"});n.src=i,n.type=e,t.appendChild(n)}function de({debugService:i,source:e,videoElement:t}){if(i.debug("Hls.js is NOT supported, trying with native HLS support"),t.canPlayType("application/vnd.apple.mpegurl")){i.debug("This browser have native HLS support"),ee({source:e,type:"application/vnd.apple.mpegurl",videoElement:t});return}i.error("Neither Hls.js nor native HLS are supported, exit!")}function Me({debugService:i,subtitleTrackList:e,videoElement:t}){if(!Array.isArray(e)){i.debug("Subtitles track list is not an array, provide correct format");return}for(const n of e){const s=d({elementType:"track"});s.kind="subtitles",s.label=n.label,s.srclang=n.srclang,s.src=n.src,t.appendChild(s)}}function Re({closeButtonConfig:i,closePlayer:e,debugService:t,outstreamContainer:n}){t.debug("The close button is enabled");const s=d({elementType:"div",elementId:"mn-close-button",className:i.position});return s.setAttribute("data-title","Close (CTRL+Escape)"),s.setAttribute("aria-keyshortcuts","CTRL+Escape"),s.setAttribute("aria-label","Chiudi video"),s.innerHTML=i.text,s.onclick=async()=>{await v(),t.debug("The close button has been clicked"),e()},n.appendChild(s),s}function De({adContainer:i,closeButton:e,event:t,fullScreenButton:n,playButton:s,volumeButton:o}){if(document.activeElement===i){if(t.code==="Space"||t.key==="k"){s?.click();return}if(t.key==="m"){o?.click();return}if(t.key==="f"){n?.click();return}if(!t.ctrlKey&&t.key==="Escape"){if(e==null)return;e.classList.contains("mn-status-hidden")||e.click()}}}async function Ve({adsManagerResize:i,closeButton:e,debugService:t,event:n,outstreamContainer:s,playerContainer:o,playerControls:r,videoContainer:l,videoElement:a}){if(document.activeElement!==o&&document.activeElement!==a)return;if(n.preventDefault(),await v(),n.code==="Space"||n.key==="k"){if(a.paused)return k(a).then(()=>t.debug("Starting video content")).catch(u=>t.warn("Error while starting video content",u));const m=V(a,t);return r?.playButton.classList.add("visible"),r?.controlsContainer.classList.add("visible"),m}const g=Promise.resolve();if(n.key==="m")return X({debugService:t,iconClicked:!1,onKeyBoardEvent:!0,videoElement:a,volumeButton:r?.volumeButton,volumeInput:r?.volumeInput}),g;if(n.key==="c")return r?.subtitleButton==null||(t.debug("Toggling subtitle list with keyboard"),r.subtitleButton.click()),g;if(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter"){const m=document.getElementById("mn-subtitle-list-container");if(m==null||!m.classList.contains("visible"))return g;const u=Array.from(m.querySelectorAll(".mn-subtitle-option"));if(u.length===0)return g;if(n.key==="Enter")return u.find(P=>P.classList.contains("enabled")).click(),g;let c=u.findIndex(w=>w.classList.contains("enabled"));c===-1&&(c=0,u.forEach(w=>w.setAttribute("aria-selected","false")),u[c].classList.add("enabled"),u[c].setAttribute("aria-selected","true")),u[c].classList.remove("enabled"),u[c].setAttribute("aria-selected","false");let p;return n.key==="ArrowDown"?p=c===u.length-1?0:c+1:p=c===0?u.length-1:c-1,u[p].classList.add("enabled"),u[p].setAttribute("aria-selected","true"),g}if(n.key==="f")return N({adsManagerResize:i,debugService:t,videoContainer:l,videoElement:a}),g;if(n.ctrlKey&&n.key==="Escape"&&e!=null&&!e.classList.contains("mn-status-hidden")&&s?.classList.contains("mn-inslide"))return e.click(),g}const je=.75,Oe=.01,Be=[{opacity:1,scale:"1"},{opacity:0,scale:"0.5"}],He={duration:100,easing:"ease-in",fill:"forwards"},qe=[{opacity:0,scale:"0.5"},{opacity:1,scale:"1"}],_e={duration:100,easing:"ease-out"},We=Array.from({length:101},(i,e)=>e/100);function Ne({rootHeight:i,rootWidth:e,wrapperHeight:t,wrapperWidth:n}){return i==null||e==null||t<=0||n<=0?1:Math.min(1,i/t)*Math.min(1,e/n)}function $e(i,e){return i=e-Oe}function Fe({adContainer:i,adDefaultVolume:e,adsManager:t,adsManagerResize:n,closeAd:s,closeButtonConfig:o,debugService:r,emitEvent:l,isDesktop:a,onContentResumeRequested:g,videoContainerElement:m}){const u=d({elementType:"div",elementId:"mn-adv-controls-container"}),c=d({elementType:"button",elementId:"mn-adv-play-button",className:"mn-controls-button"});c.setAttribute("data-title","Play (k)"),c.setAttribute("aria-keyshortcuts","k"),c.setAttribute("aria-label","Riproduci video ad"),c.innerHTML=U,c.onclick=async()=>{await v(),i.classList.contains("adv-paused")&&t.resume()},i.appendChild(c);let p;const{advButtonEnabled:w,advButtonPosition:P,advButtonShowAfter:y,advButtonText:E}=o??{};w&&(p=d({elementType:"button",elementId:"mn-adv-close-button",className:"mn-controls-button"}),p.classList.add("mn-status-hidden",`mn-adv-close-position-${P}`),p.setAttribute("data-title","Close (Escape)"),p.setAttribute("aria-keyshortcuts","Escape"),p.setAttribute("aria-label","Chiudi video ad"),E==null?p.innerHTML=me:(p.innerHTML=E,p.style.color="black",p.style.maxWidth="unset",p.style.width="fit-content"),p.onclick=async()=>{await v(),s?.(),m.classList.remove("mn-adv-started"),l("AD_CLOSED"),g()},setTimeout(()=>{p?.classList.remove("mn-status-hidden")},y*1e3),i.appendChild(p));let S=t.getVolume();const T=d({elementType:"button",elementId:"mn-adv-volume-button",className:"mn-controls-button"});T.setAttribute("data-title","Volume (m)"),T.setAttribute("aria-keyshortcuts","m"),T.setAttribute("aria-label","Attiva audio video ad"),T.innerHTML=$({volume:S,volumeButton:T}),T.onclick=async()=>{await v(),r.debug("Clicked adv volume button"),S===0?(S=e,t.setVolume(e)):(S=0,t.setVolume(0)),T.innerHTML=$({volume:S,volumeButton:T})??""},u.appendChild(T);let h;a&&(h=d({elementType:"button",elementId:"mn-adv-fullscreen-button",className:"mn-controls-button"}),h.setAttribute("data-title","Fullscreen (f)"),h.setAttribute("aria-keyshortcuts","f"),h.setAttribute("aria-label","Attiva modalità schermo intero"),document.fullscreenElement?(h.setAttribute("aria-pressed","true"),h.innerHTML=F):(h.setAttribute("aria-pressed","false"),h.innerHTML=_),h.onclick=async()=>{await v(),N({adsManagerResize:n,debugService:r,videoContainer:m})},m.onfullscreenchange=()=>{if(!document.fullscreenElement){h?.setAttribute("aria-pressed","false"),h&&(h.innerHTML=_);return}h?.setAttribute("aria-pressed","true"),h&&(h.innerHTML=F)},u.appendChild(h)),i.addEventListener("keydown",b=>{try{De({adContainer:i,closeButton:p,event:b,fullScreenButton:h,playButton:c,volumeButton:T})}catch(L){r.debug("Error inside the advAccessibilityHandler",L)}},{passive:!0}),i.appendChild(u)}const Ue=8,ue=new WeakSet,te="unknown";function f(i,e,t){try{const n=i?.[e]?.();return n==null||n===""?t:n}catch{return t}}function B(i){return typeof i=="number"&&i>0?i:null}function Qe(i){return f(i,"getUniversalAdIds",[]).flatMap(e=>{const t=f(e,"getAdIdRegistry",te),n=f(e,"getAdIdValue",te);return n===te?[]:[`${t}:${n}`]})}function Ke(i){const e=f(i,"getAdPodInfo",null);return{adId:f(i,"getAdId",null),adPosition:B(f(e,"getAdPosition",null)),adSystem:f(i,"getAdSystem",null),advertiserName:f(i,"getAdvertiserName",null),creativeAdId:f(i,"getCreativeAdId",null),creativeId:f(i,"getCreativeId",null),dealId:f(i,"getDealId",null),duration:B(f(i,"getDuration",null)),totalAds:B(f(e,"getTotalAds",null)),universalAdIds:Qe(i),wrapperAdIds:f(i,"getWrapperAdIds",[]),wrapperAdSystems:f(i,"getWrapperAdSystems",[]),wrapperCreativeIds:f(i,"getWrapperCreativeIds",[])}}function Ge(){const{settings:i}=window.google.ima;ue.has(i)||(ue.add(i),i.setDisableCustomPlaybackForIOS10Plus(!0),i.setVpaidMode(window.google.ima.ImaSdkSettings.VpaidMode.ENABLED),i.setLocale("it"),i.setNumRedirects(Ue))}function Ye(i){const e=f(i,"getError",null);return{errorCode:B(f(e,"getErrorCode",null)),message:f(e,"getMessage",null),vastErrorCode:B(f(e,"getVastErrorCode",null))}}class ce{adCountDownText;adCountDownTimer;adDisplayContainer;adsLoader;adsManager;adStarted;adTagUrl;adWillAutoPlay;adWillPlayMuted;allAdCompleted;closeButton;debugService;imaSetupId;isAdRequestPending;emitEvent;endExternalInjection;injectedTitleContainer;injectedTitleText;isExternalInjectionRunning;isPlayerInslide;isPlayerVisible;mnAdvCountDown;onContentPauseRequested;onContentResumeRequested;onImaReadyQueue;outstreamAdvContainer;outstreamContainer;playerConfig;remainingTime;showOutstreamPlayer;sourceForAutoPlayCheck;testVideoElement;titleContainer;titleText;videoContainerElement;videoElement;static injectImaScript(){const e=typeof window.google<"u"&&typeof window.google.ima<"u",t="https://imasdk.googleapis.com/js/sdkloader/ima3.js",n=document.querySelector(`script[src="${t}"]`)==null;if(e&&n)return;const s=document.createElement("script");s.src=t,document.head.appendChild(s)}constructor({adCountDownText:e,debugService:t,emitEvent:n,endExternalInjection:s,isPlayerInslide:o,onContentPauseRequested:r,onContentResumeRequested:l,playerConfig:a,showOutstreamPlayer:g,sourceForAutoPlayCheck:m}){this.adCountDownText=e||"Video Ansa tra",this.adStarted=!1,this.allAdCompleted=!1,this.debugService=t,this.emitEvent=n,this.endExternalInjection=s,this.imaSetupId=0,this.isAdRequestPending=!1,this.isExternalInjectionRunning=!1,this.isPlayerInslide=o,this.isPlayerVisible=!1,this.onContentPauseRequested=r,this.onContentResumeRequested=l,this.onImaReadyQueue=[],this.playerConfig=a,this.showOutstreamPlayer=g,this.sourceForAutoPlayCheck=m}get areAllAdCompleted(){return this.allAdCompleted}get isAdStarted(){return this.adStarted}adsManagerPause(){this.adsManager?.pause()}adsManagerResize({height:e,width:t,viewMode:n="NORMAL"}={}){const s=e??this.videoElement?.clientHeight??0,o=t??this.videoElement?.clientWidth??0;this.adsManager?.resize(o,s,window.google.ima.ViewMode[n])}adsManagerResume(){this.adsManager?.resume()}closeAd(){this.debugService.debug("Closing the running ad"),this.allAdCompleted=!0;try{this.adsManager?.destroy()}catch(e){this.debugService.debug("Error while destroying the ads manager",e)}if(this.adsManager=void 0,clearInterval(this.adCountDownTimer),this.hideAdCountDown(),this.outstreamAdvContainer!=null)for(this.outstreamAdvContainer.classList.add("mn-status-hidden"),this.outstreamAdvContainer.classList.remove("adv-paused");this.outstreamAdvContainer.firstChild;)this.outstreamAdvContainer.firstChild.remove()}autoPlayCheckSupport(e){this.debugService.debug("Start testing for auto-play support with sound: "+(this.playerConfig.startAdWithVolume?"on":"off")),e.muted=!this.playerConfig.startAdWithVolume,e.volume=this.playerConfig.adDefaultVolume,e.play().then(()=>{this.debugService.debug("Auto-play succeeded"+(this.playerConfig.startAdWithVolume?" with sound":"")),e.pause(),this.adWillAutoPlay=!0,this.adWillPlayMuted=!this.playerConfig.startAdWithVolume,this.requestAds()}).catch(()=>{this.debugService.debug("Auto-play fails, check if video can auto-play while muted"),e.pause(),e.muted=!0,e.volume=0,e.play().then(()=>{this.debugService.debug("Auto-play succeeded while muted"),e.pause(),this.adWillAutoPlay=!0,this.adWillPlayMuted=!0,this.requestAds()}).catch(()=>{this.debugService.debug("Both muted and unmuted auto-play failed. Fallback to click to play"),e.pause(),this.adWillAutoPlay=!1,this.adWillPlayMuted=!0})})}destroyImaObjects(){for(const e of[this.adsManager,this.adsLoader,this.adDisplayContainer])try{e?.destroy?.()}catch(t){this.debugService.debug("Error while destroying an IMA object",t)}this.adsManager=void 0,this.adsLoader=void 0,this.adDisplayContainer=void 0}destroyAdContainer(){this.outstreamAdvContainer!=null&&(this.debugService.debug("Destroying Adv Container"),this.outstreamAdvContainer.remove())}destroyTestVideoElement(){this.testVideoElement!=null&&(this.debugService.debug("Destroying test video element"),this.testVideoElement.remove())}detectUserInteraction(){if(this.debugService.debug("The adv is click to play, setup event listener"),z){this.outstreamContainer.addEventListener("click",async()=>{await v(),this.debugService.debug("User clicked on the video, start ad request"),this.handleAdvRequest()},{once:!0,passive:!0});return}this.outstreamContainer.addEventListener("touchstart",()=>{this.debugService.debug("User touched on the screen above the video, start ad request"),this.handleAdvRequest()},{once:!0,passive:!0})}getMnPlayerElements({closeButton:e,outstreamContainer:t,titleContainer:n,titleText:s,videoContainerElement:o,videoElement:r}){this.closeButton=e,this.outstreamContainer=t,this.titleContainer=n,this.titleText=s,this.videoContainerElement=o,this.videoElement=r}getMnPlayerInjectedElements({injectedTitleContainer:e,injectedTitleText:t}){this.injectedTitleContainer=e,this.injectedTitleText=t}getPlayerVisibility(e){this.isPlayerVisible=e}handleAdvRequest(){if(this.adWillAutoPlay===!0&&(!this.adWillPlayMuted||!this.playerConfig.startAdWithVolume)){this.debugService.debug("Reuse the auto-play check of the previous adv request"),v().then(()=>this.requestAds());return}this.testVideoElement==null&&this.initTestVideoElement(),this.autoPlayCheckSupport(this.testVideoElement)}hideAdContainer(){this.outstreamAdvContainer!=null&&(this.debugService.debug("Adv container found, hide it"),this.outstreamAdvContainer.classList.add("mn-status-hidden"))}initTestVideoElement(){this.debugService.debug("Test video element not found, creating one"),this.testVideoElement=d({elementType:"video",elementId:"mn-test-video"}),this.testVideoElement.src=this.sourceForAutoPlayCheck,this.testVideoElement.playsInline=!0,this.testVideoElement.loop=!0,document.body.appendChild(this.testVideoElement)}showAdCountDown(e){this.mnAdvCountDown!=null&&(this.mnAdvCountDown.innerHTML=`${this.adCountDownText} ${e}`,this.titleText?.textContent?.trim()&&this.titleContainer?.classList.add("mn-adv-countdown-running"))}hideAdCountDown(){this.mnAdvCountDown!=null&&(this.mnAdvCountDown.innerHTML=""),this.titleContainer?.classList.remove("mn-adv-countdown-running")}isExternalInjectionActive(e){this.isExternalInjectionRunning=e}onAdError(e){this.debugService.debug("AD_ERROR",e.getError()),this.emitEvent("AD_ERROR",Ye(e))}async onAdEvent(e){switch(e.type){case window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:{if(this.emitEvent("ALL_ADS_COMPLETED"),this.adStarted){this.debugService.debug("The ads are started and now ALL ads are COMPLETED"),this.allAdCompleted=!0;const{showAfterAdComplete:t,showAfterAdCompleteDelay:n}=this.playerConfig.closeButton;if(!this.isExternalInjectionRunning){if(t){const s=typeof n=="number"?n*1e3:0;this.debugService.debug(`Setting a timeout of ${n} seconds, before show the close button`),setTimeout(()=>{this.debugService.debug("The close button can be shown after all ads are completed"),this.closeButton?.classList.remove("mn-status-hidden")},s)}this.playerConfig.source==null&&(this.debugService.debug("Removing outstream container from the viewport because source is null"),this.outstreamContainer?.classList.add(`mn-offscreen-${this.playerConfig.playerPosition}`),this.outstreamContainer?.classList.remove(`mn-position-${this.playerConfig.playerPosition}`))}}else this.debugService.debug("Inside ALL_ADS_COMPLETED but no ad is started");if(this.outstreamAdvContainer!=null)for(this.debugService.debug("Ad container found, hide it and remove the adDisplayContainer"),this.outstreamAdvContainer.classList.add("mn-status-hidden");this.outstreamAdvContainer.firstChild;)this.outstreamAdvContainer.firstChild.remove();break}case window.google.ima.AdEvent.Type.COMPLETE:{this.debugService.debug("The current ad is COMPLETE"),this.emitEvent("AD_COMPLETE"),this.hideAdCountDown();break}case window.google.ima.AdEvent.Type.IMPRESSION:{this.debugService.debug("The ad IMPRESSION has been pinged"),this.emitEvent("AD_IMPRESSION",Ke(e.getAd()));break}case window.google.ima.AdEvent.Type.LOADED:{if(this.debugService.debug("The ad is LOADED"),this.emitEvent("AD_LOADED"),this.debugService.debug(`The ad is starting, is linear? ${e.getAd().isLinear()}`),this.titleContainer!=null&&this.titleText!=null)if(this.mnAdvCountDown==null&&(this.mnAdvCountDown=d({elementType:"p",elementId:"mn-adv-countdown"}),this.titleContainer.insertBefore(this.mnAdvCountDown,this.titleText)),this.remainingTime=parseInt(this.adsManager.getRemainingTime()),this.debugService.debug(`Loaded a ${this.remainingTime} seconds ad`),this.remainingTime!=null&&this.remainingTime>0){if(typeof this.injectedTitleText=="string"){const n=this.injectedTitleText.split(" ").find(s=>!Number.isNaN(s));this.remainingTime=Math.max(Number(n),this.remainingTime)}this.showAdCountDown(this.remainingTime)}else this.debugService.debug(`AdsManager returns ${this.remainingTime} as the remaining time, skip count down!`);break}case window.google.ima.AdEvent.Type.PAUSED:{this.debugService.debug("The ad has been PAUSED"),this.outstreamAdvContainer?.classList.add("adv-paused");break}case window.google.ima.AdEvent.Type.RESUMED:{this.debugService.debug("The ad has been RESUMED"),this.outstreamAdvContainer?.classList.remove("adv-paused");break}case window.google.ima.AdEvent.Type.SKIPPED:{this.debugService.debug("The current ad has been SKIPPED"),this.hideAdCountDown();break}case window.google.ima.AdEvent.Type.STARTED:{if(this.debugService.debug("The ad is STARDED"),this.emitEvent("AD_STARTED"),this.adStarted=!0,this.allAdCompleted=!1,this.videoContainerElement?.classList.add("mn-adv-started"),this.videoElement.paused||await V(this.videoElement,this.debugService),this.isExternalInjectionRunning&&this.endExternalInjection(),this.closeButton!=null){this.closeButton.classList.add("mn-status-hidden");const{showAfter:t}=this.playerConfig.closeButton;typeof t=="number"&&(this.debugService.debug(`Setting a timeout of ${t} seconds on ad_starded, before show the close button`),setTimeout(()=>{this.debugService.debug("The close button can be shown"),this.closeButton?.classList.remove("mn-status-hidden")},t*1e3))}!this.isPlayerInslide&&!this.playerConfig.canIncontentGoInslide&&!this.isPlayerVisible?(this.debugService.debug("The player is incontent, not visible and can NOT go inslide, pause the current ad"),this.adsManager.pause()):this.showOutstreamPlayer(),this.debugService.debug("Show ad container"),this.outstreamAdvContainer?.classList.remove("mn-status-hidden"),this.playerConfig.adControlsEnabled&&Fe({adContainer:this.outstreamAdvContainer,adDefaultVolume:this.playerConfig.adDefaultVolume,adsManager:this.adsManager,adsManagerResize:this.adsManagerResize.bind(this),closeAd:this.closeAd.bind(this),closeButtonConfig:this.playerConfig.closeAdvButton,debugService:this.debugService,emitEvent:this.emitEvent.bind(this),isDesktop:z,onContentResumeRequested:this.onContentResumeRequested.bind(this),videoContainerElement:this.videoContainerElement}),this.mnAdvCountDown!=null&&(this.injectedTitleText?.remove(),this.injectedTitleContainer?.remove(),clearInterval(this.adCountDownTimer),this.adCountDownTimer=setInterval(()=>{this.remainingTime=parseInt(this.adsManager.getRemainingTime()),this.remainingTime>0?this.showAdCountDown(this.remainingTime):(clearInterval(this.adCountDownTimer),this.hideAdCountDown())},1e3));break}}}onAdsManagerLoaded(e){this.debugService.debug("onAdsManagerLoaded");const t=new window.google.ima.AdsRenderingSettings;t.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.adsManager=e.getAdsManager(this.videoElement,t),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.IMPRESSION,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.PAUSED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.RESUMED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.SKIPPED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent.bind(this)),this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.playAds()}onImaScriptReady({callback:e}){if(typeof window.google<"u"&&typeof window.google.ima<"u"){this.debugService.debug("IMA sdk is already defined, immediately execute callback"),e();return}this.debugService.debug("IMA sdk is NOT defined, push callback in the queue"),this.onImaReadyQueue.push(e);let t=!1;const n=(function(){if(t){this.debugService.debug("The IMA queue has already been executed");return}this.onImaReadyQueue.length>0&&(this.debugService.debug("Execute the IMA queue"),t=!0,this.onImaReadyQueue.shift()())}).bind(this),o=document.querySelector('script[src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"]');if(o!=null){this.debugService.debug("IMA script found"),o.onload=()=>{this.debugService.debug("Call executeImaQueue inside the script onload"),n()};const r=setInterval(()=>{typeof window.google<"u"&&typeof window.google.ima<"u"&&(this.debugService.debug("Call executeImaQueue inside the polling check"),clearInterval(r),n())},1e3)}}playAds(){this.debugService.debug("Initialize the adDisplayContainer"),this.adDisplayContainer.initialize(),this.adWillPlayMuted?(this.debugService.debug("The adv will play muted, set the adsManager volume to 0"),this.adsManager.setVolume(0)):(this.debugService.debug("The adv will not play muted and can start with sound, set the adsManager volume"),this.adsManager.setVolume(this.playerConfig.adDefaultVolume));try{this.debugService.debug("Outstream container sizes",this.videoContainerElement?.clientWidth,this.videoContainerElement?.clientHeight),this.adsManager.init(this.videoContainerElement?.clientWidth,this.videoContainerElement?.clientHeight,window.google.ima.ViewMode.NORMAL),this.adsManager.start()}catch(e){this.debugService.debug("Ads manager error",e)}}requestAds(){if(this.adsLoader==null){this.debugService.debug("The ads loader is not ready, request the ads once it is"),this.isAdRequestPending=!0;return}const e=new window.google.ima.AdsRequest;e.adTagUrl=this.adTagUrl,this.debugService.debug(`Adv will auto play: ${this.adWillAutoPlay}`),e.setAdWillAutoPlay(this.adWillAutoPlay),this.debugService.debug(`Adv will play muted: ${this.adWillPlayMuted}`),e.setAdWillPlayMuted(this.adWillPlayMuted),e.linearAdSlotWidth=640,e.linearAdSlotHeight=480,e.vastLoadTimeout=8e3,e.nonLinearAdSlotWidth=640,e.nonLinearAdSlotHeight=150,this.debugService.debug("Requesting ads",e),this.adsLoader.requestAds(e)}async setUpIMA({adTagUrl:e,refreshed:t=!1}){this.debugService.debug("Setup Ima sdk with the new service");const n=++this.imaSetupId;if(this.adTagUrl=e,this.outstreamAdvContainer==null&&(this.debugService.debug("Adv container not found, creating one"),this.outstreamAdvContainer=d({elementType:"div",elementId:"mn-adv-container",className:"mn-status-hidden"}),this.outstreamAdvContainer.setAttribute("tabindex","0"),this.videoContainerElement?.appendChild(this.outstreamAdvContainer)),Ge(),this.destroyImaObjects(),await v(),n===this.imaSetupId&&(this.adDisplayContainer=new window.google.ima.AdDisplayContainer(this.outstreamAdvContainer,this.videoElement),await v(),n===this.imaSetupId)){if(this.adsLoader=new window.google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.getSettings().setAutoPlayAdBreaks(!0),this.adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded.bind(this),!1),this.adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.videoElement.onended=()=>{try{this.adsLoader?.contentComplete()}catch(s){this.debugService.debug(s)}},t||this.isPlayerInslide){this.debugService.debug(t?"The adv request has been refreshed":"The player behavior is inslide, start handleAdvRequest"),this.isAdRequestPending=!1,this.handleAdvRequest();return}if(this.isAdRequestPending){this.debugService.debug("Send the adv request that came before the ads loader was ready"),this.isAdRequestPending=!1,this.requestAds();return}this.playerConfig.startAdClickToPlay&&(this.debugService.debug("The adv should start only after a user interaction with the player"),this.detectUserInteraction())}}}class H{console=window.console;isDebugEnabled=!1;static debugStyle="display:inline-block; color:white; background:black; border-radius:3px;";static warnStyle="display:inline-block; color:white; background:goldenrod; border-radius:3px;";static errorStyle="display:inline-block; color:white; background:red; border-radius:3px;";constructor({isDebug:e}){e&&(this.isDebugEnabled=!0)}debug(e,...t){this.isDebugEnabled&&this.console.debug("%c MN-Player ",H.debugStyle,e,...t)}warn(e,...t){this.isDebugEnabled&&this.console.warn("%c MN-Player ",H.warnStyle,e,...t)}error(e,...t){this.console.trace("%c MN-Player ",H.errorStyle,e,...t)}}ce.injectImaScript();class Xe{closeButton;debugService;events;injectedBannerContainer;injectedCloseButtonTimer;injectedCountDownTimer;injectedTitleContainer;injectedTitleText;isAdCycleEnded;isAdvRequestWithObserverStart;isDebugEnabled;isExternalInjectionRunning;isPlayerInslide;isPlayerVisible;isVideoAutoPlayEnabled;mnAdLibrary;mnPlayerWrapper;outstreamContainer;pendingPositionChange;playerConfig;playerControls;playerEventManager;positionAnimation;sourceForAutoPlayCheckOrVip;titleContainer;titleText;videoContainerElement;videoElement;wrapperReachableVisibleRatio;wrapperVisibleRatio;constructor({adControlsEnabled:e=!0,adDefaultVolume:t=.01,adTagUrl:n,appendTo:s="#mn-container",autoPlay:o=!1,behavior:r="incontent",canIncontentGoInslide:l=!0,closeAdvButton:{advButtonEnabled:a=!1,advButtonPosition:g="left",advButtonShowAfter:m=15,advButtonText:u}={},closeButton:{enabled:c=!0,enableOnBannerInjection:p=!1,position:w="top-right",showAfter:P=15,showAfterAdComplete:y=!1,showAfterAdCompleteDelay:E,text:S="X"}={},controls:T=!0,enableContinuousVideoPlayback:h=!1,hlsEsmLibraryUrl:b,hlsLibraryUrl:L,onPlayerReady:A,playerPosition:C="right",poster:I,source:q,startAdClickToPlay:j=!1,startAdInView:Je=!1,startAdWithVolume:Ze=!1,startVideoContentWithVolume:et=!1,style:tt,subtitles:{defaultSubtitle:it="Off",enableSubtitles:nt=!1,subtitleTrackList:st}={},videoAutoPlay:ot=!1,videoContentTitle:rt,videoDescription:{enableVideoDescription:at=!1,videoAdCountDownText:lt,videoDescriptionText:dt}={},videoVolume:ut=.1}={}){window.mnPlayerWebsiteApi={version:"[master]-[13-11-2026_16:01:33]"},this.events={},this.isAdCycleEnded=!1,this.isAdvRequestWithObserverStart=!1,this.isDebugEnabled=!1,this.isExternalInjectionRunning=!1,this.isPlayerVisible=!1,this.wrapperReachableVisibleRatio=1,this.wrapperVisibleRatio=0,this.sourceForAutoPlayCheckOrVip="https://pull-zone-pubtech.b-cdn.net/sample_video_ads.mp4",(Te("debug_player")||O("debug_player"))&&(this.isDebugEnabled=!0),this.debugService=new H({isDebug:this.isDebugEnabled});const ct="https://ads.talkscreativity.com/assets/product/mn-player-deps/hls.min.1.6.15.js",ht="https://ads.talkscreativity.com/assets/product/mn-player-deps/hls.1.6.15.mjs";if(this.playerConfig={adControlsEnabled:e,adDefaultVolume:t,adTagUrl:n,appendTo:s,autoPlay:o,behavior:r,canIncontentGoInslide:l,closeAdvButton:{advButtonEnabled:a,advButtonPosition:g,advButtonShowAfter:m,advButtonText:u},closeButton:{enabled:c,enableOnBannerInjection:p,position:w,showAfter:P,showAfterAdComplete:y,showAfterAdCompleteDelay:E,text:S},controls:T,enableContinuousVideoPlayback:h,hlsEsmLibraryUrl:b||ht,hlsLibraryUrl:L||ct,onPlayerReady:A,playerPosition:C,poster:I,source:q,startAdClickToPlay:j,startAdInView:Je,startAdWithVolume:Ze,startVideoContentWithVolume:et,style:tt,subtitles:{defaultSubtitle:it,enableSubtitles:nt,subtitleTrackList:st},videoAutoPlay:ot,videoContentTitle:rt,videoDescription:{enableVideoDescription:at,videoAdCountDownText:lt,videoDescriptionText:dt},videoVolume:ut},Array.isArray(window._mnPlayerConfig)&&window._mnPlayerConfig.length>0&&Object.assign(this.playerConfig,...window._mnPlayerConfig),this.debugService.debug("MnPlayer config:",this.playerConfig),this.isPlayerInslide=this.playerConfig.behavior==="inslide",this.isVideoAutoPlayEnabled=this.playerConfig.videoAutoPlay,this.mnPlayerWrapper=document.querySelector(this.playerConfig.appendTo),!this.isPlayerInslide&&this.mnPlayerWrapper==null){this.debugService.error("The container where the player should be appended is not on the page");return}this.isDebugEnabled&&(O("debug_single_adv")?this.playerConfig.adTagUrl="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=":O("debug_adv")&&(this.playerConfig.adTagUrl="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostpodbumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator="),O("debug_mp4")?this.playerConfig.source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4":O("debug_m3u8")&&(this.playerConfig.source="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8")),this.mnAdLibrary=new ce({adCountDownText:this.playerConfig.videoDescription.videoAdCountDownText,debugService:this.debugService,emitEvent:this.emit.bind(this),endExternalInjection:this.endExternalInjectionForAd.bind(this),isPlayerInslide:this.isPlayerInslide,onContentPauseRequested:this.onContentPauseRequested.bind(this),onContentResumeRequested:this.onContentResumeRequested.bind(this),playerConfig:this.playerConfig,showOutstreamPlayer:this.showOutstreamPlayer.bind(this),sourceForAutoPlayCheck:this.sourceForAutoPlayCheckOrVip}),this.initOutstreamPlayer().then(()=>{typeof this.playerConfig.onPlayerReady=="function"&&(this.playerEventManager={on:(ie,mt)=>{this.events[ie]==null&&(this.events[ie]=[]),this.events[ie].push(mt)}},this.playerConfig.onPlayerReady(this.playerEventManager)),this.mnAdLibrary.onImaScriptReady({callback:(function(){this.debugService.debug("Call startAdvLibrary from onImaScriptReady callback"),this.startAdvLibrary()}).bind(this)})})}async initOutstreamPlayer(){if(this.outstreamContainer=d({elementId:"mn-outstream-container"}),this.outstreamContainer.setAttribute("tabindex","0"),this.videoContainerElement=d({elementId:"mn-video-player-container"}),this.videoContainerElement.setAttribute("tabindex","0"),this.videoElement=d({elementType:"video",elementId:"mn-outstream-video-player"}),this.videoElement.setAttribute("tabindex","0"),this.videoElement.setAttribute("webkit-playsinline","true"),this.videoElement.playsInline=!0,this.videoElement.disableRemotePlayback=!0,this.videoElement.preload="none",this.videoElement.disablePictureInPicture=!0,this.videoElement.muted=!this.playerConfig.startVideoContentWithVolume,this.videoElement.volume=this.playerConfig.startVideoContentWithVolume?this.playerConfig.videoVolume:0,this.playerConfig.poster!=null&&(this.videoElement.poster=this.playerConfig.poster),this.playerConfig.style!=null)for(const t in this.playerConfig.style)this.outstreamContainer.style.setProperty(`--player-${t}`,this.playerConfig.style[t]);this.videoElement.addEventListener("contextmenu",t=>t.preventDefault());const e=xe({debugService:this.debugService,hlsLibraryUrl:this.playerConfig.hlsLibraryUrl,hlsEsmLibraryUrl:this.playerConfig.hlsEsmLibraryUrl,source:this.playerConfig.source,subtitles:this.playerConfig.subtitles,vipSource:this.sourceForAutoPlayCheckOrVip,videoElement:this.videoElement});this.playerConfig.controls&&(this.playerControls=ke({adsManagerResize:()=>this.mnAdLibrary.adsManagerResize(),debugService:this.debugService,isAdTagUrlDefined:this.playerConfig.adTagUrl!=null,isDesktop:z,isMobile:Ae,subtitles:this.playerConfig.subtitles,toggleVideoAutoPlay:this.toggleVideoAutoPlay.bind(this),videoContainerElement:this.videoContainerElement,videoElement:this.videoElement})),Se({playerControls:this.playerControls,videoContentTitle:this.playerConfig.videoContentTitle,videoElement:this.videoElement}),this.videoContainerElement.appendChild(this.videoElement),this.outstreamContainer.appendChild(this.videoContainerElement),this.playerConfig.videoDescription.enableVideoDescription&&(this.titleContainer=d({elementId:"mn-title-container"}),this.titleText=d({elementType:"p",elementId:"mn-title-text"}),this.titleText.innerHTML=this.playerConfig.videoDescription.videoDescriptionText,this.titleContainer.appendChild(this.titleText),this.outstreamContainer.appendChild(this.titleContainer)),this.playerConfig.closeButton.enabled&&(this.closeButton=Re({closeButtonConfig:this.playerConfig.closeButton,closePlayer:this.closePlayer.bind(this),debugService:this.debugService,outstreamContainer:this.outstreamContainer})),this.injectCSSStyle(),this.isPlayerInslide?(this.outstreamContainer.classList.add("mn-inslide"),this.playerConfig.source!=null&&this.playerConfig.videoAutoPlay?this.outstreamContainer.classList.add(`mn-position-${this.playerConfig.playerPosition}`):this.outstreamContainer.classList.add(`mn-offscreen-${this.playerConfig.playerPosition}`),document.body.appendChild(this.outstreamContainer)):(this.outstreamContainer.classList.add("mn-incontent"),this.mnPlayerWrapper.clientWidth<=300&&this.outstreamContainer.classList.add("mn-small-incontent-type"),this.setVideoElementHeight(),this.setUpObserver(),this.mnPlayerWrapper.appendChild(this.outstreamContainer)),this.mnAdLibrary.getMnPlayerElements({closeButton:this.closeButton,outstreamContainer:this.outstreamContainer,titleContainer:this.titleContainer,titleText:this.titleText,videoContainerElement:this.videoContainerElement,videoElement:this.videoElement}),this.isVideoAutoPlayEnabled&&this.videoElement.paused&&e.then(()=>{k(this.videoElement).then(()=>this.debugService.debug("Starting video content")).catch(t=>this.debugService.warn("Error while starting video content",t))}),this.outstreamContainer.addEventListener("keydown",t=>{Ve({adsManagerResize:()=>this.mnAdLibrary.adsManagerResize(),closeButton:this.closeButton,debugService:this.debugService,event:t,outstreamContainer:this.outstreamContainer,playerContainer:this.outstreamContainer,playerControls:this.playerControls,videoContainer:this.videoContainerElement,videoElement:this.videoElement})}),await v(),this.emit("PLAYER_READY")}emit(e,...t){this.events[e]&&this.events[e].forEach(n=>{n(...t)})}removeVideoElementInlineStyle(){this.videoElement.removeAttribute("style")}setVideoElementHeight(){const e=this.mnPlayerWrapper?.clientWidth??0;this.videoElement.style.height=`calc((${e}px / 16) * 9)`}keepPlayerWrapperHeight(){this.mnPlayerWrapper==null||!this.outstreamContainer.classList.contains("mn-incontent")||(this.mnPlayerWrapper.style.minHeight=getComputedStyle(this.outstreamContainer).height)}releasePlayerWrapperHeight(){this.mnPlayerWrapper?.style.removeProperty("min-height")}restoreIncontentPosition(){this.changePlayerPosition("incontent",()=>{this.outstreamContainer.classList.add("mn-incontent"),this.outstreamContainer.classList.remove("mn-inslide"),this.setVideoElementHeight(),this.releasePlayerWrapperHeight(),this.mnAdLibrary.adsManagerResize({height:this.videoContainerElement.clientHeight,width:this.videoContainerElement.clientWidth})})}get playerPosition(){return this.pendingPositionChange!=null?this.pendingPositionChange.target:this.outstreamContainer.classList.contains("mn-inslide")?"inslide":"incontent"}changePlayerPosition(e,t){const n=this.pendingPositionChange;if(n!=null){if(n.target===e)return;this.debugService.debug(`The move to ${n.target} is cancelled, the player stays ${e}`),this.pendingPositionChange=void 0,this.positionAnimation?.cancel();return}if(this.positionAnimation?.cancel(),this.playerPosition===e){t();return}const s=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(typeof this.outstreamContainer.animate!="function"||s){t();return}const o={change:t,target:e};this.pendingPositionChange=o;const r=this.outstreamContainer.animate(Be,He);this.positionAnimation=r,r.finished.then(()=>{this.pendingPositionChange===o&&(this.pendingPositionChange=void 0,t(),this.positionAnimation=this.outstreamContainer.animate(qe,_e),r.cancel())}).catch(()=>this.debugService.debug("The player position animation has been cancelled"))}removePlayer(){this.outstreamContainer.remove(),this.releasePlayerWrapperHeight()}closePlayer(){this.debugService.debug("The player has been closed by the user"),this.mnAdLibrary.closeAd(),this.videoContainerElement.classList.remove("mn-adv-started"),this.videoElement.paused||V(this.videoElement,this.debugService),this.isPlayerInslide?this.isAdCycleEnded?(this.debugService.debug("The ad cycle has already ended, remove the player"),this.removePlayer()):(this.outstreamContainer.classList.add(`mn-offscreen-${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.remove(`mn-position-${this.playerConfig.playerPosition}`)):this.restoreIncontentPosition(),this.emit("PLAYER_CLOSED",{})}toggleVideoAutoPlay(){this.isVideoAutoPlayEnabled=!this.isVideoAutoPlayEnabled,this.debugService.debug(`Set isVideoAutoPlayEnabled to ${this.isVideoAutoPlayEnabled}`)}startAdvLibrary(e=null,t=!1){this.debugService.debug("Starting adv library");const n=e??this.playerConfig.adTagUrl;this.mnAdLibrary.setUpIMA({adTagUrl:n,refreshed:t})}setUpObserver(){let e=!0;const t=new IntersectionObserver(n=>{n.forEach(s=>{this.wrapperVisibleRatio=s.intersectionRatio,this.wrapperReachableVisibleRatio=Ne({rootHeight:s.rootBounds?.height??null,rootWidth:s.rootBounds?.width??null,wrapperHeight:s.boundingClientRect.height,wrapperWidth:s.boundingClientRect.width}),this.updateStickyPosition(),!(!e&&s.isIntersecting===this.isPlayerVisible)&&(e=!1,this.handleVisibilityChange(s.isIntersecting))})},{threshold:We});this.mnPlayerWrapper&&t.observe(this.mnPlayerWrapper)}updateStickyPosition(){if(!this.isPlayerInslide){if(this.playerPosition==="inslide"){if(this.isInjectedBannerShown||!ze(this.wrapperVisibleRatio,this.wrapperReachableVisibleRatio))return;this.debugService.debug("The player position is fully visible, restore it"),this.restoreIncontentPosition();return}this.mnAdLibrary.isAdStarted&&!this.mnAdLibrary.areAllAdCompleted&&this.showOutstreamPlayer()}}handleVisibilityChange(e){this.isPlayerVisible=e,this.mnAdLibrary.getPlayerVisibility(this.isPlayerVisible),this.isPlayerVisible?(this.debugService.debug("The player become visible"),this.mnAdLibrary.isAdStarted&&!this.mnAdLibrary.areAllAdCompleted?this.playerConfig.canIncontentGoInslide||(this.debugService.debug("The player did NOT go inslide, resume the adv"),this.mnAdLibrary.adsManagerResume()):this.isVideoAutoPlayEnabled&&this.videoElement.paused&&k(this.videoElement).then(()=>this.debugService.debug("Starting video content")).catch(t=>this.debugService.warn("Error while starting video content",t)),!this.isAdvRequestWithObserverStart&&!this.playerConfig.startAdClickToPlay&&(this.isAdvRequestWithObserverStart=!0,this.mnAdLibrary.handleAdvRequest())):(this.debugService.debug("The player is not visible"),this.playerConfig.enableContinuousVideoPlayback||this.videoElement.pause(),this.playerControls?.controlsContainer.classList.add("visible"),this.playerControls?.playButton.classList.add("visible"),!this.isAdvRequestWithObserverStart&&!this.playerConfig.startAdInView&&!this.playerConfig.startAdClickToPlay&&(this.debugService.debug("The adv request can start even if the player is not visible"),this.isAdvRequestWithObserverStart=!0,this.mnAdLibrary.handleAdvRequest()),this.mnAdLibrary.isAdStarted&&!this.mnAdLibrary.areAllAdCompleted&&!this.playerConfig.canIncontentGoInslide&&(this.debugService.debug("The player can NOT go inslide, the adv is paused"),this.mnAdLibrary.adsManagerPause()))}showOutstreamPlayer(){if(this.isPlayerInslide){this.debugService.debug(`Show the player inslide with position ${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.add(`mn-position-${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.remove(`mn-offscreen-${this.playerConfig.playerPosition}`);return}this.playerPosition!=="inslide"&&this.playerConfig.canIncontentGoInslide&&$e(this.wrapperVisibleRatio,this.wrapperReachableVisibleRatio)&&(this.debugService.debug(`The player is incontent and mostly out of view, show the player in inslide mode at ${this.playerConfig.playerPosition} position`),this.changePlayerPosition("inslide",()=>{this.keepPlayerWrapperHeight(),this.outstreamContainer.classList.add("mn-inslide",`mn-position-${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.remove("mn-incontent",`mn-offscreen-${this.playerConfig.playerPosition}`),this.removeVideoElementInlineStyle(),this.mnAdLibrary.adsManagerResize({height:this.videoContainerElement.clientHeight,width:this.videoContainerElement.clientWidth})}))}handleVideoContentResume(){this.debugService.debug("Resuming video content"),this.isAdCycleEnded=!0,this.mnAdLibrary.destroyTestVideoElement();const e=this.outstreamContainer.classList.contains(`mn-offscreen-${this.playerConfig.playerPosition}`);if(this.isPlayerInslide&&(this.playerConfig.source==null||e)){this.debugService.debug("Destroying outstream player"),this.outstreamContainer.remove();return}this.mnAdLibrary.destroyAdContainer(),this.isVideoAutoPlayEnabled&&this.videoElement.paused&&(this.isPlayerInslide||this.isPlayerVisible)&&k(this.videoElement).then(()=>this.debugService.debug("Starting video content")).catch(t=>this.debugService.warn("Error while starting video content",t))}onContentPauseRequested(){this.debugService.debug("onContentPauseRequested: pause player"),V(this.videoElement,this.debugService)}onContentResumeRequested(){this.debugService.debug("onContentResumeRequested: request to resume content"),this.mnAdLibrary.hideAdContainer(),this.videoContainerElement.classList.remove("mn-adv-started"),this.videoContainerElement.classList.add("mn-content-resume"),this.videoContainerElement.classList.contains("mn-video-started")&&this.playerControls?.fullScreenButton.classList.remove("mn-status-hidden"),!this.isExternalInjectionRunning&&this.isVideoAutoPlayEnabled&&this.videoElement.paused&&k(this.videoElement).then(()=>this.debugService.debug("Starting video content")).catch(e=>this.debugService.warn("Error while starting video content",e))}createContainerForExternalInjection({elementToInject:e}){if(e==null){this.debugService.debug("The element to inject is null, skip container injection!");return}this.debugService.debug("Element injection starting.."),this.isExternalInjectionRunning=!0,this.mnAdLibrary.isExternalInjectionActive(this.isExternalInjectionRunning),this.injectedBannerContainer=d({elementId:"mn-injected-container"}),this.injectedBannerContainer.appendChild(e),this.videoContainerElement.appendChild(this.injectedBannerContainer)}setupPlayerUIForExternalInjection({enableVideoTitle:e,injectedElementViewTime:t,websiteDomain:n}){if(this.videoElement.paused||V(this.videoElement,this.debugService),this.isVideoAutoPlayEnabled=!1,this.isPlayerInslide||(this.pendingPositionChange=void 0,this.positionAnimation?.cancel(),this.keepPlayerWrapperHeight(),this.removeVideoElementInlineStyle()),this.outstreamContainer.classList.add("mn-inslide",`mn-position-${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.remove("mn-incontent",`mn-offscreen-${this.playerConfig.playerPosition}`),this.injectedBannerContainer?.classList.add("slot-render-ended"),this.playerControls?.controlsContainer.classList.add("mn-status-hidden"),this.playerControls?.playButton.classList.add("mn-status-hidden"),this.closeButton!=null){this.closeButton.classList.add("mn-status-hidden");const{enableOnBannerInjection:s,showAfter:o}=this.playerConfig.closeButton;s&&(this.debugService.debug("The close button is enabled during banner injection"),this.injectedCloseButtonTimer=setTimeout(()=>{this.debugService.debug("The close button can be shown"),this.closeButton?.classList.remove("mn-status-hidden")},o*1e3))}if(e){this.injectedTitleText=d({elementType:"p",elementId:"mn-injected-title-text"});let s=t;const o=n!=null?n.split(".").shift():"";this.injectedTitleText.innerHTML=`Video ${o} tra ${s}`,this.titleContainer!=null&&this.titleText!=null?this.titleContainer.insertBefore(this.injectedTitleText,this.titleText):(this.injectedTitleContainer=d({elementId:"mn-injected-title-container"}),this.injectedTitleContainer.appendChild(this.injectedTitleText),this.outstreamContainer.appendChild(this.injectedTitleContainer)),this.mnAdLibrary.getMnPlayerInjectedElements({injectedTitleContainer:this.injectedTitleContainer,injectedTitleText:this.injectedTitleText}),this.injectedCountDownTimer=setInterval(()=>{s=s-1,this.injectedTitleText.innerHTML=`Video ${o} tra ${s}`,s<=0&&clearInterval(this.injectedCountDownTimer)},1e3)}}get isInjectedBannerShown(){return this.isExternalInjectionRunning&&this.injectedBannerContainer?.classList.contains("slot-render-ended")===!0}endExternalInjectionForAd(){this.isExternalInjectionRunning&&(this.debugService.debug("A video ad started, remove the injected banner"),this.isVideoAutoPlayEnabled=this.playerConfig.videoAutoPlay,this.removeInjectedElements(),this.updateStickyPosition())}removeExternalInjectionUI(){if(!this.isExternalInjectionRunning){this.debugService.debug("The external injection has already ended");return}this.debugService.debug("Removing external injection UI"),this.isPlayerInslide?this.playerConfig.source==null&&(this.debugService.debug("The source is null, hide outstream container"),this.outstreamContainer.classList.add(`mn-offscreen-${this.playerConfig.playerPosition}`),this.outstreamContainer.classList.remove(`mn-position-${this.playerConfig.playerPosition}`)):this.playerConfig.videoAutoPlay&&k(this.videoElement).then(()=>{this.debugService.debug("Starting video content"),this.isVideoAutoPlayEnabled=!0}).catch(e=>this.debugService.warn("Error while starting video content",e)),this.removeInjectedElements(),this.closeButton?.classList.remove("mn-status-hidden"),this.updateStickyPosition()}removeInjectedElements(){clearTimeout(this.injectedCloseButtonTimer),clearInterval(this.injectedCountDownTimer),this.injectedTitleText?.remove(),this.injectedTitleContainer?.remove(),this.injectedBannerContainer?.remove(),this.playerControls?.controlsContainer.classList.remove("mn-status-hidden"),this.playerControls?.playButton.classList.remove("mn-status-hidden"),this.isExternalInjectionRunning=!1,this.mnAdLibrary.isExternalInjectionActive(this.isExternalInjectionRunning)}injectCSSStyle(){const e=document.createElement("style");e.appendChild(document.createTextNode(he)),document.head.appendChild(e)}}window.loadMnPlayer=i=>new Xe(i),Le()})();