(function () { 'use strict'; let p={API_CALL:"api_call",BACK_ICON:"back_icon",CLOSE_ICON:"close_icon",INSTANT_START:"instant_start",PIP_NATIVE_ICON:"pip_native_icon",SCROLL:"scroll",TOGGLE_ICON:"toggle_icon"},r=16/9,d=[],u=e=>(d=[...d,e],()=>{d=d.filter(t=>t!==e)}),P=()=>{d.forEach(e=>e()),d=[]},c=[],_=(e,t,i,o)=>{let n=e.on(t,i,o);c=[...c,n];let l=()=>{n(),c=c.filter(e=>e!==n)};return u(l),l},m=e=>e._do_not_use_03d404c11d1978869851.rootNode,g=e=>m(e)?.querySelector(".dailymotion-player-wrapper"),y=e=>m(e)?.querySelector(".dailymotion-player"),h={state:{},prevState:{},defaultState:{isRunning:!1,displayMode:null,isSmallViewportDisplay:!1,isExpanded:!1,isPipCustomPosition:!1,hasPipBanner:!1,hasRequestedPipNative:!1,uiActionOrigin:null,playerSelectedForPip:null,playerSelectedForPipNative:null,pipPositionX:null,pipPositionY:null,pipTransformSmallViewportCollapsed:null,videoAspectRatio:null},nonPersistentStateProps:["uiActionOrigin"],onStateChange(){},setState(e){this.nonPersistentStateProps.forEach(t=>{Object.prototype.hasOwnProperty.call(e,t)||(e={...e,[t]:this.defaultState[t]})}),this.prevState={...this.prevState,...this.state},this.state={...this.state,...e},this.onStateChange(this.prevState,this.state)}},E=e=>{h.setState(e)},S=()=>h.state,C=()=>h.defaultState,f=e=>{h.onStateChange=e},I=null,b=!1,A=!1,N=null,w=Object.values(window.dailymotion._do_not_use_03d404c11d1978869851.players);for(let e=0;ewindow.innerWidth<=_dmpespesIframe001.B.SMALL?"small":"large",x=()=>"small"===R(),L=e=>!!x()&&!!($()||A||e?.adIsPlaying),O=(i,o)=>{let n=e=>{e&&E({isExpanded:L(),displayMode:R(),isSmallViewportDisplay:x()}),v(i)};F(i,o),_(i,_dmpesplayer.E.PUBLIC.VIDEO_PLAY,()=>{E({hasPipBanner:i._do_not_use_03d404c11d1978869851.settings.enableGooglePolicyUi&&i._do_not_use_03d404c11d1978869851.settings.enablePlaybackControls})}),n();let l=_dmpesplayer.t(window,"resize",n);u(()=>{l(),B(i),document.body.offsetWidth,N&&(N(),N=null)})},T=(e,t,i)=>{S().isRunning&&!A&&(I=!!t,E({hasPipBanner:e._do_not_use_03d404c11d1978869851.settings.enableGooglePolicyUi&&e._do_not_use_03d404c11d1978869851.settings.enablePlaybackControls,isExpanded:I,uiActionOrigin:i}),v(e,{animate:!1}))},v=function(t){let{animate:i=!1,computePlayerIframeSizes:o=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};B(t,{animate:i,computePlayerIframeSizes:o});let n=m(t),l=g(t),s=y(t),a=$()||A,p=S().hasPipBanner,{dynamicWidth:d,dynamicHeight:u}=D(),P=document.documentElement.clientWidth,c=Math.round(P/r)+(p?32:0);l.id=`dailymotion-pip-${R()}-viewport`;let{defaultPositionX:_,defaultPositionY:h,defaultMargin:C}={large:{defaultPositionX:"right",defaultPositionY:"bottom",defaultMargin:"20px"},small:{defaultPositionX:"left",defaultPositionY:"top",defaultMargin:"0px"}}[R()],f=e=>getComputedStyle(document.querySelector(`#${l.id}`)).getPropertyValue(e),I=e=>""!==f(`--position-${e}`).trim();I("top")||I("bottom")||l.style.setProperty(`--position-${h}`,C),I("left")||I("right")||l.style.setProperty(`--position-${_}`,C),!I("bottom")&&N&&(N(),N=null),I("bottom")&&x()&&!N&&(N=_dmpesplayer.t(window,"scroll",()=>{v(t,{computePlayerIframeSizes:!1})}));let b=x()&&(I("bottom")||I("right")||f("--position-top")!==C||f("--position-left")!==C),w=I("left")||I("top")||f("--position-bottom")!==C||f("--position-right")!==C,L=I("left")?"left":"right",O=I("top")?"top":"bottom",T=getComputedStyle(l),F=()=>"0.00001"!==parseFloat(T.marginRight).toPrecision(1)?`${parseFloat(T.marginRight)}px`:"left"!==L||isNaN(f("--position-left").trim())?"right"!==L||isNaN(f("--position-right").trim())?`var(--position-${L})`:`${Number(f("--position-right"))}px`:`${Number(f("--position-left"))}px`,V=()=>{let e=parseFloat(T.marginBottom);return"0.00001"!==e.toPrecision(1)&&0!==e?`${e}px`:"top"!==O||isNaN(f("--position-top").trim())?"bottom"!==O||isNaN(f("--position-bottom").trim())?`var(--position-${O})`:`${Number(f("--position-bottom"))}px`:`${Number(f("--position-top"))}px`},M=()=>"large"===R()?p?u+32:u:a?c:p?136:104,G=()=>"large"===R()?d:P;Object.assign(l.style,{boxShadow:"0 0.25rem 0.5rem rgba(0, 0, 0, 0.2)",height:`${M()}px`,position:"fixed",transform:(()=>{let e,t;let i=[],o=l.parentNode;for(;o!==document&&o;)i.push(o),o=o.parentNode;let s=document.documentElement.scrollLeft?document.documentElement.scrollLeft:i.reduce((e,t)=>{let{scrollLeft:i}=t;return e+i},0),a=document.documentElement.scrollTop?document.documentElement.scrollTop:i.reduce((e,t)=>{let{scrollTop:i}=t;return e+i},0);return"rtl"===T.direction?("right"===L&&(e=document.documentElement.clientWidth),"left"===L&&(e=G()),e-=n.getBoundingClientRect().right):("right"===L&&(e=document.documentElement.clientWidth-G()),"left"===L&&(e=0),e-=n.getBoundingClientRect().left),e-=s,"bottom"===O&&(t=window.innerHeight-M()),"top"===O&&(t=0),t=t-n.getBoundingClientRect().top-a,`translate( calc(${e}px ${"right"===L?"-":"+"} ${F()}), calc(${t}px ${"bottom"===O?"-":"+"} ${V()}) )`})(),transition:"none",width:`${G()}px`,zIndex:0x7fffffff,bottom:"unset",left:"unset",right:"unset",top:"unset",borderRadius:`${"large"===R()?"0.5rem":"0rem"}`});let U=null;x()&&(Object.assign(s,{height:`${c}px`,width:`${P}px`}),U=Math.round((c-104)/2),Object.assign(s.style,{height:`${c}px`,transition:"none",transform:a?"translate(0px,0px)":`translate(0px, -${U}px)`,width:`${P}px`})),E({isPipCustomPosition:b||w,pipPositionX:l.getBoundingClientRect().x,pipPositionY:l.getBoundingClientRect().y,uiActionOrigin:S().uiActionOrigin,pipTransformSmallViewportCollapsed:U})},$=()=>!!I||null===I&&!!b,B=function(e){let{animate:t=!1,computePlayerIframeSizes:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=g(e),n=y(e);o.removeAttribute("id"),o.style.removeProperty("--position-top"),o.style.removeProperty("--position-left"),o.style.removeProperty("--position-bottom"),o.style.removeProperty("--position-right"),Object.assign(o.style,{boxShadow:"unset",...t?{}:{height:"100%"},position:"absolute",transform:"translate(0px,0px)",width:"100%",zIndex:"auto",margin:"0.00001px",borderRadius:"0px"}),i&&(Object.assign(n,{height:"100%",width:"100%"}),Object.assign(n.style,{height:"100%",transform:"translate(0px,0px)",transition:"none",width:"100%"}))},D=()=>{let e=window.innerWidth;if(e<=_dmpespesIframe001.B.MEDIUM)return{dynamicWidth:410,dynamicHeight:Math.round(410/r)};if(e>=_dmpespesIframe001.B.LARGE)return{dynamicWidth:560,dynamicHeight:Math.round(560/r)};let t=_dmpespesIframe001.B.LARGE-_dmpespesIframe001.B.MEDIUM,i=Math.round((e-_dmpespesIframe001.B.LARGE+t)/t*150)+410,o=Math.round(i/r);return{dynamicWidth:i,dynamicHeight:o}},F=(e,t)=>{(A=t.adIsPlaying)?M(e):V(e)},V=e=>{_(e,_dmpesplayer.E.PUBLIC.AD_START,()=>{A=!0,E({hasPipBanner:e._do_not_use_03d404c11d1978869851.settings.enableGooglePolicyUi&&e._do_not_use_03d404c11d1978869851.settings.enableAdsControls}),$()||E({isExpanded:x()}),v(e),M(e)},{once:!0})},M=e=>{_(e,_dmpesplayer.E.PUBLIC.AD_END,()=>{A=!1,E({hasPipBanner:e._do_not_use_03d404c11d1978869851.settings.enableGooglePolicyUi&&e._do_not_use_03d404c11d1978869851.settings.enablePlaybackControls}),$()||E({isExpanded:!1}),v(e),V(e)},{once:!0})},G=(e,o,n)=>{let{isRunning:l,isExpanded:s}=o,{displayMode:a,isRunning:r,isExpanded:d,uiActionOrigin:u,playerSelectedForPipNative:P}=n,c={playerPipDisplay:`${a}Viewport`,playerPipIsExpanded:d,playerPipStatus:u===p.CLOSE_ICON?"closed":"enabled",playerPresentationMode:P?"nativePip":r?"pip":"inline"},{id:_,stateFromPES:m}=e._do_not_use_03d404c11d1978869851;Object.assign(m,c),l!==r&&_dmpesplayer.s(_dmpesplayer.E.PUBLIC.PLAYER_PRESENTATIONMODECHANGE,{id:_,...c}),s!==d&&_dmpesplayer.s(_dmpesplayer.E.PUBLIC.PLAYER_PIPEXPANDEDCHANGE,{id:_,...c})},U=(e,t,i)=>{let{isRunning:s,isSmallViewportDisplay:a,isExpanded:p,isPipCustomPosition:r,hasPipBanner:d,hasRequestedPipNative:u,pipPositionX:P,pipPositionY:c,pipTransformSmallViewportCollapsed:_,videoAspectRatio:m}=t,{isRunning:g,isSmallViewportDisplay:y,isExpanded:h,isPipCustomPosition:E,hasPipBanner:S,hasRequestedPipNative:C,uiActionOrigin:f,pipPositionX:I,pipPositionY:b,pipTransformSmallViewportCollapsed:A,videoAspectRatio:N}=i;if(s!==g||a!==y||p!==h||d!==S||r!==E||u!==C||P!==I||c!==b||_!==A||m!==N){let t={isRunning:g,isSmallViewportDisplay:y,isExpanded:h,isPipCustomPosition:E,hasPipBanner:S,hasRequestedPipNative:C,uiActionOrigin:f,screenId:window.dailymotion._do_not_use_03d404c11d1978869851.screenId,pipPositionX:I,pipPositionY:b,pipTransformSmallViewportCollapsed:A,videoAspectRatio:N};_dmpesplayer.l.log("pip","Sending new PIP state to player :",t),_dmpesplayer.b(e,_dmpesplayer.C.NOTIFY_PIP_CHANGED,t)}},Y=()=>{},j=()=>{},X=e=>{T(S().playerSelectedForPip,!0,e)},k=e=>{T(S().playerSelectedForPip,!1,e)},q=()=>{v(S().playerSelectedForPip)},W=()=>{E({...C()}),Y=t=>{e(),i(),n(),l(),a(),r(),j(t)};let e=_dmpesplayer.k(_dmpesplayer.E.PUBLIC.PLAYER_VIEWABILITYCHANGE,e=>{let{viewable:t,wasViewableAtLeastOnce:i,id:n,uiActionOrigin:l}=e,s=window.dailymotion._do_not_use_03d404c11d1978869851.players[n];if(!s||"off"===s._do_not_use_03d404c11d1978869851.settings.pip||S().playerSelectedForPip&&s!==S().playerSelectedForPip||S().playerSelectedForPipNative)return;let{status:a,reason:r}=s.isEligibleForPipDisplay(i);_dmpesplayer.l.log("pip",`Viewability change received - is player viewable : ${t} - is player eligible for PIP display : ${a} (${r})`),t?j(l||p.SCROLL):!t&&s.isEligibleForPipDisplay(i).status&&s.getState().then(e=>{H(s,e,i||"instant"!==s._do_not_use_03d404c11d1978869851.settings.pip?p.SCROLL:p.INSTANT_START)})}),i=_dmpesplayer.k(_dmpesplayer.E.PUBLIC.PLAYER_PRESENTATIONMODECHANGE,e=>{let{playerPresentationMode:t,id:i}=e,o=window.dailymotion._do_not_use_03d404c11d1978869851.players[i];if(o){if("inline"===t&&S().playerSelectedForPipNative===o&&E({playerSelectedForPipNative:null}),"nativePip"===t){E({playerSelectedForPipNative:o}),S().hasRequestedPipNative&&E({hasRequestedPipNative:!1}),S().playerSelectedForPip&&j(p.PIP_NATIVE_ICON);return}o.getState().then(e=>{e.playerIsViewable||H(o,e,p.PIP_NATIVE_ICON)})}}),n=_dmpesplayer.k(_dmpesplayer.E.PRIVATE.CLOSE_PIP_REQUESTED,()=>{Y(p.CLOSE_ICON)}),l=_dmpesplayer.k(_dmpesplayer.E.PRIVATE.BACK_TO_INLINE_DISPLAY_REQUESTED,()=>{let e=S().playerSelectedForPip,{observer:t}=e._do_not_use_03d404c11d1978869851;t.setUIActionOrigin(p.BACK_ICON),m(e).scrollIntoView({block:"start"})}),a=_dmpesplayer.k(_dmpesplayer.E.PRIVATE.COLLAPSE_PIP_REQUESTED,()=>{T(S().playerSelectedForPip,!1,p.TOGGLE_ICON)}),r=_dmpesplayer.k(_dmpesplayer.E.PRIVATE.EXPAND_PIP_REQUESTED,()=>{T(S().playerSelectedForPip,!0,p.TOGGLE_ICON)})},H=(e,t,i)=>{if(S().isRunning||window.dailymotion._do_not_use_03d404c11d1978869851.playerSelectedForPip!==e||S().playerSelectedForPipNative)return;j=t=>{S().isRunning&&(P(),E({isPipCustomPosition:!1,isRunning:!1,hasPipBanner:!1,pipPositionX:null,pipPositionY:null,playerSelectedForPip:null,uiActionOrigin:t,videoAspectRatio:null}),f(()=>{}),(t===p.CLOSE_ICON||t===p.API_CALL)&&(e.cancelAutoskip(),e.pause()))},f((t,i)=>{G(e,t,i),U(e,t,i)});let o=e._do_not_use_03d404c11d1978869851.settings.enableGooglePolicyUi,n=!t.adIsPlaying&&e._do_not_use_03d404c11d1978869851.settings.enablePlaybackControls,l=t.adIsPlaying&&e._do_not_use_03d404c11d1978869851.settings.enableAdsControls;E({hasPipBanner:o&&(n||l),isRunning:!0,uiActionOrigin:i,displayMode:R(),isSmallViewportDisplay:x(),isExpanded:L(t),playerSelectedForPip:e}),O(e,t)};window.dailymotion.pipResume=()=>{_dmpesplayer.l.log("api","Called dailymotion.pipResume()"),W()},window.dailymotion.pipClose=()=>{_dmpesplayer.l.log("api","Called dailymotion.pipClose()"),Y(p.API_CALL)},window.dailymotion.pipExpand=()=>{_dmpesplayer.l.log("api","Called dailymotion.pipExpand()"),X(p.API_CALL)},window.dailymotion.pipCollapse=()=>{_dmpesplayer.l.log("api","Called dailymotion.pipCollapse()"),k(p.API_CALL)},window.dailymotion.pipRepaint=()=>{_dmpesplayer.l.log("api","Called dailymotion.pipRepaint()"),q()}; })();