(this.dmpJsonp=this.dmpJsonp||[]).push([[124],{9669:(e,t,i)=>{e.exports=i(1609)},5448:(e,t,i)=>{"use strict";var n=i(4867),r=i(6026),s=i(5327),a=i(4109),o=i(7985),d=i(5061);e.exports=function(e){return new Promise((function(t,l){var c=e.data,u=e.headers;n.isFormData(c)&&delete u["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var p=e.auth.username||"",E=e.auth.password||"";u.Authorization="Basic "+btoa(p+":"+E)}if(h.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,h.onreadystatechange=function(){if(h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var i="getAllResponseHeaders"in h?a(h.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:i,config:e,request:h};r(t,l,n),h=null}},h.onerror=function(){l(d("Network Error",e,null,h)),h=null},h.ontimeout=function(){l(d("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",h)),h=null},n.isStandardBrowserEnv()){var _=i(4372),m=(e.withCredentials||o(e.url))&&e.xsrfCookieName?_.read(e.xsrfCookieName):void 0;m&&(u[e.xsrfHeaderName]=m)}if("setRequestHeader"in h&&n.forEach(u,(function(e,t){void 0===c&&"content-type"===t.toLowerCase()?delete u[t]:h.setRequestHeader(t,e)})),e.withCredentials&&(h.withCredentials=!0),e.responseType)try{h.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),l(e),h=null)})),void 0===c&&(c=null),h.send(c)}))}},1609:(e,t,i)=>{"use strict";var n=i(4867),r=i(1849),s=i(321),a=i(5655);function o(e){var t=new s(e),i=r(s.prototype.request,t);return n.extend(i,s.prototype,t),n.extend(i,t),i}var d=o(a);d.Axios=s,d.create=function(e){return o(n.merge(a,e))},d.Cancel=i(5263),d.CancelToken=i(4972),d.isCancel=i(6502),d.all=function(e){return Promise.all(e)},d.spread=i(8713),e.exports=d,e.exports.default=d},5263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},4972:(e,t,i)=>{"use strict";var n=i(5263);function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var i=this;e((function(e){i.reason||(i.reason=new n(e),t(i.reason))}))}r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e;return{token:new r((function(t){e=t})),cancel:e}},e.exports=r},6502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,i)=>{"use strict";var n=i(5655),r=i(4867),s=i(782),a=i(3572);function o(e){this.defaults=e,this.interceptors={request:new s,response:new s}}o.prototype.request=function(e){"string"==typeof e&&(e=r.merge({url:arguments[0]},arguments[1])),(e=r.merge(n,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[a,void 0],i=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)i=i.then(t.shift(),t.shift());return i},r.forEach(["delete","get","head","options"],(function(e){o.prototype[e]=function(t,i){return this.request(r.merge(i||{},{method:e,url:t}))}})),r.forEach(["post","put","patch"],(function(e){o.prototype[e]=function(t,i,n){return this.request(r.merge(n||{},{method:e,url:t,data:i}))}})),e.exports=o},782:(e,t,i)=>{"use strict";var n=i(4867);function r(){this.handlers=[]}r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=r},5061:(e,t,i)=>{"use strict";var n=i(481);e.exports=function(e,t,i,r,s){var a=new Error(e);return n(a,t,i,r,s)}},3572:(e,t,i)=>{"use strict";var n=i(4867),r=i(8527),s=i(6502),a=i(5655),o=i(8203),d=i(7303);function l(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return l(e),e.baseURL&&!o(e.url)&&(e.url=d(e.baseURL,e.url)),e.headers=e.headers||{},e.data=r(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return l(e),t.data=r(t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(l(e),t&&t.response&&(t.response.data=r(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,i,n,r){return e.config=t,i&&(e.code=i),e.request=n,e.response=r,e}},6026:(e,t,i)=>{"use strict";var n=i(5061);e.exports=function(e,t,i){var r=i.config.validateStatus;i.status&&r&&!r(i.status)?t(n("Request failed with status code "+i.status,i.config,null,i.request,i)):e(i)}},8527:(e,t,i)=>{"use strict";var n=i(4867);e.exports=function(e,t,i){return n.forEach(i,(function(i){e=i(e,t)})),e}},5655:(e,t,i)=>{"use strict";var n=i(4867),r=i(6016),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var o,d={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process)&&(o=i(5448)),o),transformRequest:[function(e,t){return r(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(a(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};d.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){d.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){d.headers[e]=n.merge(s)})),e.exports=d},1849:e=>{"use strict";e.exports=function(e,t){return function(){for(var i=new Array(arguments.length),n=0;n{"use strict";var n=i(4867);function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,i){if(!t)return e;var s;if(i)s=i(t);else if(n.isURLSearchParams(t))s=t.toString();else{var a=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),a.push(r(t)+"="+r(e))})))})),s=a.join("&")}return s&&(e+=(-1===e.indexOf("?")?"?":"&")+s),e}},7303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},4372:(e,t,i)=>{"use strict";var n=i(4867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,i,r,s,a){var o=[];o.push(e+"="+encodeURIComponent(t)),n.isNumber(i)&&o.push("expires="+new Date(i).toGMTString()),n.isString(r)&&o.push("path="+r),n.isString(s)&&o.push("domain="+s),!0===a&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},8203:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},7985:(e,t,i)=>{"use strict";var n=i(4867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");function r(e){var n=e;return t&&(i.setAttribute("href",n),n=i.href),i.setAttribute("href",n),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}return e=r(window.location.href),function(t){var i=n.isString(t)?r(t):t;return i.protocol===e.protocol&&i.host===e.host}}():function(){return!0}},6016:(e,t,i)=>{"use strict";var n=i(4867);e.exports=function(e,t){n.forEach(e,(function(i,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=i,delete e[n])}))}},4109:(e,t,i)=>{"use strict";var n=i(4867),r=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,i,s,a={};return e?(n.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=n.trim(e.substr(0,s)).toLowerCase(),i=n.trim(e.substr(s+1)),t){if(a[t]&&r.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([i]):a[t]?a[t]+", "+i:i}})),a):a}},8713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},4867:(e,t,i)=>{"use strict";var n=i(1849),r=i(8778),s=Object.prototype.toString;function a(e){return"[object Array]"===s.call(e)}function o(e){return null!==e&&"object"==typeof e}function d(e){return"[object Function]"===s.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var i=0,n=e.length;i{ /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},4285:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AdErrorMessages:()=>le,AdEvents:()=>oe,IMASdkHandler:()=>Nd,adEventEmitter:()=>ae,adSdk:()=>Xl,initAdStack:()=>Rh,initCookieSync:()=>wd,resetAdStack:()=>Sh});var n={};i.r(n),i.d(n,{AD_DIRECTOR_XHR_CALL_FAILED:()=>ce,AD_STACK_INIT_ERROR:()=>he,BLOCKED_DOMAIN:()=>Ce,IMA_REQUEST_ADS_TIMEOUT:()=>Ne,IMA_REQUEST_ERROR:()=>Ue,NO_ADS:()=>ue,PARSING_ERROR:()=>Oe,SIMID_ERROR:()=>be,UNKNOWN_ERROR:()=>pe,VPAID_ABORTED:()=>Ee,VPAID_BUFFER_ERROR:()=>Ie,VPAID_BUFFER_TIMEOUT:()=>fe,VPAID_FETCH_ERROR:()=>Ae,VPAID_FETCH_TIMEOUT:()=>ve,VPAID_INIT_ERROR:()=>ge,VPAID_INIT_TIMEOUT:()=>Te,VPAID_PLAY_ERROR:()=>De,VPAID_SDK_LOAD_ERROR:()=>_e,VPAID_SDK_LOAD_TIMEOUT:()=>me,VPAID_SKIP_ERROR:()=>Pe,VPAID_SKIP_TIMEOUT:()=>ye,VPAID_START_ERROR:()=>Re,VPAID_START_TIMEOUT:()=>Se,VPAID_STOP_ERROR:()=>Le,VPAID_STOP_TIMEOUT:()=>ke});var r={};i.r(r),i.d(r,{canUseNativeOmsdk:()=>xn,getExecutableVerificationScripts:()=>Kn,getLoadedParameters:()=>Bn,getOmPartner:()=>Fn,hasOmid:()=>Qn});var s={};i.r(s),i.d(s,{init:()=>_s});var a={};i.r(a),i.d(a,{init:()=>fs});var o={};i.r(o),i.d(o,{init:()=>Ls});var d={};i.r(d),i.d(d,{init:()=>Ps});var l={};i.r(l),i.d(l,{init:()=>Us});var c={};i.r(c),i.d(c,{init:()=>Vs});var u={};i.r(u),i.d(u,{init:()=>Bs});var h={};i.r(h),i.d(h,{init:()=>Qs});var p={};i.r(p),i.d(p,{init:()=>zs});var E={};i.r(E),i.d(E,{_unitTests:()=>fd,callFetchAd:()=>hd,callInitAd:()=>pd,callSkipAd:()=>_d,callStartAd:()=>Ed,callStopAd:()=>md,cleanPendingCalls:()=>vd,getVastHandler:()=>cd,loadMediaFile:()=>ld,subscribe:()=>Rd,unload:()=>Ad,unsubscribe:()=>Sd});let _=null,m=null,A=null,v=null;function g(e){_=e.config,A=e.playerSizeAPI,m=e.playerAPI,v=e.eventBus}function T(){for(var e=arguments.length,t=new Array(e),i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return m?.getMetadata()[e]??t}function x(){return m?.getFullscreenState()}function F(){return m?.getPlayerVolume()}function K(){return m?.isRealAutoplay()}function H(){return m?.getPlayerVideoTag()}function Y(e,t){const i=(m?.getStore().getState()).settings;if(!R())return i?i[e]:t;if(!i)return t;const n=i[e]||_.settings(e);return void 0===n?t:n}function G(){return m?.getVideoSettings()}function Q(){return m.getVideoState()}function j(){return m?.getPlaybackState()}function q(){return m?.getSequenceState()}function $(){return m?.getNativeSdkCapabilities()}function W(){return m?.getChromecastStatus()}function z(e,t){m.dispatchFromPlayer(e,t)}function X(){return m?.getCcpaToLeoParam()}function Z(){m?.onFallbackToVideoContent()}function J(){return m?.isGdprApplicable()}function ee(e,t){const i=m?.getPlayerBackendConfig();return i?.[e]??t}function te(){return m?.getEmbedder()}function ie(){return m?.getTopDomain()}function ne(){return m?.getContext()}function re(){return m?.getHls()}class se{constructor(){this.handlers=[],this.alreadyDispatchedEvent=null}subscribe(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;this.alreadyDispatchedEvent===t&&R()&&e(),this.handlers.push({event:t,handler:e,context:i})}unsubscribe(e,t){this.handlers.forEach(((i,n,r)=>{i.event===t&&i.handler===e&&r.splice(n,1)}))}publish(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n{t.event!==e&&"*"!==t.event||r.push({isAlwaysExecute:"*"===t.event,handler:t.handler.bind(t.context)})})),i[0]?.shouldSubscribeEvent&&R()&&(this.alreadyDispatchedEvent=e),r.forEach((t=>{let{isAlwaysExecute:n,handler:r}=t;n?r(e,...i):r(...i)}))}unsubscribeAll(){this.handlers=[]}}const ae=new class extends se{dispatchEvent(e,t){this.publish(e,t)}addEventListener(e,t){this.subscribe(t,e)}removeEventListener(e,t){this.unsubscribe(t,e)}removeAllEventListeners(){this.unsubscribeAll()}},oe={AD_BREAK_WILL_START:"AD_BREAK_WILL_START",AD_BUFFER_FINISH:"AD_BUFFER_FINISH",AD_BUFFER_START:"AD_BUFFER_START",AD_CLICK:"AD_CLICK",AD_COMPANIONS_RECEIVED:"AD_COMPANIONS_RECEIVED",AD_ERROR:"AD_ERROR",AD_DATA_UPDATED:"AD_DATA_UPDATED",AD_IMPRESSION:"AD_IMPRESSION",AD_LINEAR_BREAK_ENDED:"AD_LINEAR_BREAK_ENDED",AD_LINEAR_BREAK_STARTED:"AD_LINEAR_BREAK_STARTED",AD_LINEAR_STARTED:"AD_LINEAR_STARTED",AD_LINEAR_STOPPED:"AD_LINEAR_STOPPED",AD_LINEAR_WILL_START:"AD_LINEAR_WILL_START",AD_LOADED:"AD_LOADED",AD_LOG:"AD_LOG",AD_NON_LINEAR_DISPLAY_STARTED:"AD_NON_LINEAR_DISPLAY_STARTED",AD_PAUSED:"AD_PAUSED",AD_PLAYING:"AD_PLAYING",AD_POD_ERROR:"AD_POD_ERROR",AD_NON_LINEAR_WILL_START:"AD_NON_LINEAR_WILL_START",AD_NON_LINEAR_WILL_STOP:"AD_NON_LINEAR_WILL_STOP",AD_REGISTER_ADBREAKS:"AD_REGISTER_ADBREAKS",AD_SDK_READY:"AD_SDK_READY",AD_SKIPPED:"AD_SKIPPED",AD_SKIP_REQUESTED:"AD_SKIP_REQUESTED",AD_SLOT_INJECTED:"AD_SLOT_INJECTED",AD_STACK_ERROR:"AD_STACK_ERROR",AD_STARTED:"AD_STARTED",AD_STOPPED:"AD_STOPPED",AD_VIDEO_COMPLETE:"AD_VIDEO_COMPLETE",AD_VIDEO_FIRST_QUARTILE:"AD_VIDEO_FIRST_QUARTILE",AD_VIDEO_MIDPOINT:"AD_VIDEO_MIDPOINT",AD_VIDEO_SKIPPABLE_REMAINING_TIME:"AD_VIDEO_SKIPPABLE_REMAINING_TIME",AD_VIDEO_SKIPPABLE_STATE:"AD_VIDEO_SKIPPABLE_STATE",AD_VIDEO_START:"AD_VIDEO_START",AD_VIDEO_THIRD_QUARTILE:"AD_VIDEO_THIRD_QUARTILE",AD_VIDEO_VOLUME_CHANGED:"AD_VIDEO_VOLUME_CHANGED",AD_VMAP_RECEIVED:"AD_VMAP_RECEIVED",AD_VMAP_REQUESTED:"AD_VMAP_REQUESTED",AD_BREAK_STARTED:"AD_BREAK_STARTED",RESET_CURRENT_AD_BREAK:"RESET_CURRENT_AD_BREAK",SET_AD_FALLBACK:"SET_AD_FALLBACK",START_AD_FALLBACK:"START_AD_FALLBACK",PLAYER_API_CUST_CONFIG_CONSUMED:"PLAYER_API_CUST_CONFIG_CONSUMED",PLAYER_API_SET_CUST_CONFIG:"PLAYER_API_SET_CUST_CONFIG",PLAYER_CHROMECAST_SESSION_AVAILABLE:"PLAYER_CHROMECAST_SESSION_AVAILABLE",PLAYER_CHROMECAST_STATUS_CHANGED:"PLAYER_CHROMECAST_STATUS_CHANGED",PLAYER_CONTENT_SIZE_CHANGED:"PLAYER_CONTENT_SIZE_CHANGED",PLAYER_ERROR:"PLAYER_ERROR",PLAYER_FULLSCREEN_CHANGED:"PLAYER_FULLSCREEN_CHANGED",PLAYER_GDPR_CONSENT_COLLECTION_REQUESTED:"PLAYER_GDPR_CONSENT_COLLECTION_REQUESTED",PLAYER_GDPR_CONSENT_COLLECTION_RESOLVED:"PLAYER_GDPR_CONSENT_COLLECTION_RESOLVED",PLAYER_HEAVYADSINTERVENTION_CHANGED:"PLAYER_HEAVYADSINTERVENTION_CHANGED",PLAYER_IMA_NATIVE_EVENT:"PLAYER_IMA_NATIVE_EVENT",PLAYER_LOAD_VIDEO:"PLAYER_LOAD_VIDEO",PLAYER_PAUSE_REQUESTED:"PLAYER_PAUSE_REQUESTED",PLAYER_PLAY_REQUESTED:"PLAYER_PLAY_REQUESTED",PLAYER_SCHEDULER_END_SEQUENCE:"PLAYER_SCHEDULER_END_SEQUENCE",PLAYER_SEEK_REQUESTED:"PLAYER_SEEK_REQUESTED",PLAYER_SEQUENCE_ENDED:"PLAYER_SEQUENCE_ENDED",PLAYER_TOGGLE_PLAYBACK_REQUESTED:"PLAYER_TOGGLE_PLAYBACK_REQUESTED",PLAYER_VIDEO_DURATION_CHANGE:"PLAYER_VIDEO_DURATION_CHANGE",PLAYER_VIDEO_ENDED:"PLAYER_VIDEO_ENDED",PLAYER_VIDEO_PAUSE:"PLAYER_VIDEO_PAUSE",PLAYER_VIDEO_PLAY:"PLAYER_VIDEO_PLAY",PLAYER_VIDEO_PLAYING:"PLAYER_VIDEO_PLAYING",PLAYER_VIDEO_SELECTED:"PLAYER_VIDEO_SELECTED",PLAYER_VIDEO_TIME_UPDATE:"PLAYER_VIDEO_TIME_UPDATE",PLAYER_VIDEO_VOLUME_CHANGED:"PLAYER_VIDEO_VOLUME_CHANGED",IMA_NATIVE_AD_REQUESTED:"IMA_NATIVE_AD_REQUESTED",IMA_NATIVE_AD_STOPPED:"IMA_NATIVE_AD_STOPPED"},de={AD_DIRECTOR_REQUEST_TIMEOUT:"Ad Director request timeout",AD_DIRECTOR_REQUEST_FAILED:"Ad Director request failed",AD_UNIT_CANCEL:"Ad unit has been cancelled",BAD_PROTOCOL:"Cannot go from HTTPS to HTTP",EMPTY_VAST_DATA_OR_URI:"Unexpected outcome while trying to parse VAST XML",IMA_SDK_NOT_LOADED:"IMA SDK not loaded",IMA_SDK_INCORRECT_TAG:"Unexpected VMAP/playlist tag. Only VAST tags are supported.",NO_FILL:"No fill",NO_SUPPORTED_CREATIVE:"No supported creative",NON_LINEAR_DIMENSIONS:"Unable to display NonLinear ad because creative dimensions do not align with creative display area",SUPPORTED_CREATIVE_ERROR:"Error while getting a supported creative",STREAM_UNPLAYABLE_SRC:"No playable Mediafile",VAST_WRAPPER_REQUEST_TIMEOUT:"VAST wrapper request timeout",VAST_WRAPPER_REQUEST_FAILED:"VAST wrapper request failed",VPAID_SDK_REQUEST_FAILED:"Unreacheable VPAID url",AD_TIMEOUT_REACHED:"Timeout reached",UNSUPPORTED_ADSOURCE:"No supported VAST adSource provided",INVALID_ERROR:"invalid AdError raised",INVALID_FORMAT_VPAID_ERROR:"Invalid format for VPAID Error",IMA_ADSMANAGER_UNDEFINED:"IMA adsManager undefined",FAILED_TO_PARSE_AD_PARAMS:"Failed to parse JSON ad parameters",CREATIVE_ALREADY_PLAYED_IN_SLOT:"Creative was already played in this ad slot",FAILED_AD_SEQUENCE:"Failed to resolve ad sequence",BLOCKED_DOMAIN:"Blocked domain"};Object.entries(de).forEach((e=>{let[t,i]=e;de[t]=`DM_${i}`}));const le=de,ce="AD_DIRECTOR_XHR_CALL_FAILED",ue="NO_ADS",he="AD_STACK_INIT_ERROR",pe="UNKNOWN_ERROR",Ee="VPAID_ABORTED",_e="VPAID_SDK_LOAD_ERROR",me="VPAID_SDK_LOAD_TIMEOUT",Ae="VPAID_FETCH_ERROR",ve="VPAID_FETCH_TIMEOUT",ge="VPAID_INIT_ERROR",Te="VPAID_INIT_TIMEOUT",Re="VPAID_START_ERROR",Se="VPAID_START_TIMEOUT",Ie="VPAID_BUFFER_ERROR",fe="VPAID_BUFFER_TIMEOUT",De="VPAID_PLAY_ERROR",Le="VPAID_STOP_ERROR",ke="VPAID_STOP_TIMEOUT",Pe="VPAID_SKIP_ERROR",ye="VPAID_SKIP_TIMEOUT",Oe="PARSING_ERROR",be="SIMID_ERROR",Ce="BLOCKED_DOMAIN",Ne="IMA_REQUEST_ADS_TIMEOUT",Ue="IMA_REQUEST_ERROR",we=T("AdStackDM");let Ve=null;const Me={get value(){return Ve},set value(e){"number"==typeof e?Ve=e:we.log(`Can only set lastAdHttpStatus value from number : ${e} is ${typeof e}`)},reset:()=>{Ve=null}};class Be extends Error{constructor(e,t){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,Be),Object.defineProperty(this,"message",{value:e,enumerable:!0}),this.type=null,this.code=null,this.httpStatus=null,this.position=null,this.timeoutInfo=null,this.adSystem=null,this.adTitle=null,this.adURL=null,this.inventoryId=null,this.provider=null,this.buyerType=null,this.bid=null,this.sid=null,this.adom=null,this.cid=null,this.adid=null,this.crid=null,this.did=null,this.bidid=null,this.pid=null,this.dva=null,this.dva_provider=null,this.dva_vpaid=null,this.dva_vpaid_inner=null,this.dva_wr=null,this.integrator=null,this.fallbackUrl=null,this.lastVastUrl=null,this.internalCode=null,this.vastVersion=null,this.vpaidRuntimeError=null,this.hasRemainingAds=!1,this.updateProperties(t)}updateProperties(e){this.httpStatus=Me.value,"object"==typeof e&&("type"in e&&(this.type=n[e.type]?e.type:pe),"code"in e&&(this.code=e.code),"httpStatus"in e&&(this.httpStatus=e.httpStatus),"position"in e&&(this.position=e.position),"timeoutInfo"in e&&(this.timeoutInfo=e.timeoutInfo),"adSystem"in e&&(this.adSystem=e.adSystem),"adTitle"in e&&(this.adTitle=e.adTitle),"adURL"in e&&(this.adURL=e.adURL),"inventoryId"in e&&(this.inventoryId=e.inventoryId),"provider"in e&&(this.provider=e.provider),"buyerType"in e&&(this.buyerType=e.buyerType),"bid"in e&&(this.bid=e.bid),"bidid"in e&&(this.bidid=e.bidid),"sid"in e&&(this.sid=e.sid),"adom"in e&&(this.adom=e.adom),"cid"in e&&(this.cid=e.cid),"adid"in e&&(this.adid=e.adid),"crid"in e&&(this.crid=e.crid),"pid"in e&&(this.pid=e.pid),"did"in e&&(this.did=e.did),"dva"in e&&(this.dva=e.dva),"dva_provider"in e&&(this.dva_provider=e.dva_provider),"dva_vpaid"in e&&(this.dva_vpaid=e.dva_vpaid),"dva_vpaid_inner"in e&&(this.dva_vpaid_inner=e.dva_vpaid_inner),"dva_wr"in e&&(this.dva_wr=e.dva_wr),"integrator"in e&&(this.integrator=e.integrator),"fallbackUrl"in e&&(this.fallbackUrl=e.fallbackUrl),"lastVastUrl"in e&&(this.lastVastUrl=e.lastVastUrl),"internalCode"in e&&(this.internalCode=e.internalCode),"vastVersion"in e&&(this.vastVersion=e.vastVersion),"vpaidRuntimeError"in e&&(this.vpaidRuntimeError=e.vpaidRuntimeError),"hasRemainingAds"in e&&(this.hasRemainingAds=e.hasRemainingAds))}isMediationAllowed(){return[_e,me,Ae,ve,ge,Te,Re,Se,Ie,Ce].indexOf(this.type)>=0}}var xe=i(4993);let Fe,Ke,He,Ye=!1,Ge=null;const Qe=()=>{Fe="VMAP",Ke={},He=0,Ge=null};Qe();const je={get value(){return Ge||(Ge=R()?window.dmp_getViewIdForVideoIndex():B("viewId")),Ge?[Ge,Fe,Ke[Fe]||0,He].join("_"):"NO_VIEW_ID"},get podIndex(){return He},get isConsecutiveAdBreak(){return Ye},newAdBreak:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i={[xe.ev.PREROLL]:"PRE",[xe.ev.MIDROLL]:"MID",[xe.ev.POSTROLL]:"POST",[xe.ev.LIVEADBREAK]:"LIVEADBREAK"};if(!i[e])throw new Error("Invalid ad break type");Fe=i[e],He=1,Ye=t,Ke[Fe]?Ke[Fe]++:Ke[Fe]=1},newAd:e=>{e?He=e:He++},reset:Qe};let qe={adBreaks:{prerolls:[],midrolls:[],postrolls:[],liveAdBreaks:[]},isFirstAdBreakForAdSlot:!0,adSlotTotalAdBreaks:0,currentAdBreakIndex:0,adPodIndex:0,linearSlotStarted:!1,position:null,nextPosition:null,current:null,nextAdBreak:null,fetchedViewId:null,adPods:[],adBuffet:[],isCrossPodReranking:!1,vmapData:{}};ae.addEventListener(oe.AD_BREAK_WILL_START,(e=>{let{position:t,nextAdBreak:i}=e;qe.nextPosition=t,qe.nextAdBreak=i})),ae.addEventListener(oe.AD_STARTED,(()=>{qe.nextAdBreak=null})),[oe.AD_STOPPED,oe.AD_SKIPPED,oe.RESET_CURRENT_AD_BREAK].forEach((e=>ae.addEventListener(e,(()=>{qe.current&&qe.current.track("breakEnd"),qe.current=null,qe.nextAdBreak=null,qe.isFirstAdBreakForAdSlot=!1})))),ae.addEventListener(oe.PLAYER_SEQUENCE_ENDED,(()=>{qe.adBreaks={prerolls:[],midrolls:[],postrolls:[],liveAdBreaks:[]}})),ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,(()=>{R()&&(!R()||qe.fetchedViewId===window.dmp_getViewIdForVideoIndex()&&qe.fetchedViewId)||(qe={...qe,adBreaks:{prerolls:[],midrolls:[],postrolls:[],liveAdBreaks:[]},isFirstAdBreakForAdSlot:!0,adSlotTotalAdBreaks:0,currentAdBreakIndex:0,adPodIndex:0,linearSlotStarted:!1,position:null,nextPosition:null,current:null,nextAdBreak:null,fetchedViewId:null,adPods:[],adBuffet:[],isCrossPodReranking:!1,vmapData:{}}),je.reset()})),ae.addEventListener(oe.AD_LINEAR_BREAK_STARTED,(()=>{qe.linearSlotStarted=!0,qe.isFirstAdBreakForAdSlot=!0})),ae.addEventListener(oe.AD_LINEAR_BREAK_ENDED,(()=>{qe={...qe,adBreaks:{prerolls:[],midrolls:[],postrolls:[],liveAdBreaks:[]},isFirstAdBreakForAdSlot:!0,adSlotTotalAdBreaks:0,currentAdBreakIndex:0,adPodIndex:0,linearSlotStarted:!1,position:null,nextPosition:null,current:null,nextAdBreak:null,fetchedViewId:null,adPods:[],adBuffet:[],isCrossPodReranking:!1,vmapData:{},adBreaks:qe.adBreaks}}));var $e=i(4155),We=i(9669),ze=i.n(We);function Xe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,adId:e.adId||null,sequence:e.sequence||null,apiFramework:e.apiFramework||null,universalAdIds:[],creativeExtensions:[]}}const Ze=["ADCATEGORIES","ADCOUNT","ADPLAYHEAD","ADSERVINGID","ADTYPE","APIFRAMEWORKS","APPBUNDLE","ASSETURI","BLOCKEDADCATEGORIES","BREAKMAXADLENGTH","BREAKMAXADS","BREAKMAXDURATION","BREAKMINADLENGTH","BREAKMINDURATION","BREAKPOSITION","CLICKPOS","CLICKTYPE","CLIENTUA","CONTENTID","CONTENTPLAYHEAD","CONTENTURI","DEVICEIP","DEVICEUA","DOMAIN","EXTENSIONS","GDPRCONSENT","IFA","IFATYPE","INVENTORYSTATE","LATLONG","LIMITADTRACKING","MEDIAMIME","MEDIAPLAYHEAD","OMIDPARTNER","PAGEURL","PLACEMENTTYPE","PLAYERCAPABILITIES","PLAYERSIZE","PLAYERSTATE","PODSEQUENCE","REGULATIONS","SERVERSIDE","SERVERUA","TRANSACTIONID","UNIVERSALADID","VASTVERSIONS","VERIFICATIONVENDORS"];function Je(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=[],r=it(e);!t.ERRORCODE||i.isCustomCode||/^[0-9]{3}$/.test(t.ERRORCODE)||(t.ERRORCODE=900),t.CACHEBUSTING=ot(Math.round(1e8*Math.random())),t.TIMESTAMP=(new Date).toISOString(),t.RANDOM=t.random=t.CACHEBUSTING;for(const e in t)t[e]=at(t[e]);for(const e in r){const i=r[e];"string"==typeof i&&n.push(et(i,t))}return n}function et(e,t){const i=(e=tt(e,t)).match(/[^[\]]+(?=])/g);if(!i)return e;let n=i.filter((e=>Ze.indexOf(e)>-1));return 0===n.length?e:(n=n.reduce(((e,t)=>(e[t]=-1,e)),{}),tt(e,n))}function tt(e,t){let i=e;for(const e in t){const n=t[e];i=i.replace(new RegExp("(?:\\[|%%)(".concat(e,")(?:\\]|%%)"),"g"),n)}return i}function it(e){return Array.isArray(e)?e.map((e=>e&&e.hasOwnProperty("url")?e.url:e)):e}function nt(e){return/^(https?:\/\/|\/\/)/.test(e)}function rt(e,t){for(let i=0;i"%".concat(e.charCodeAt(0).toString(16))))}function ot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return e.toString().padStart(t,"0")}const dt={track:function(e,t,i){Je(e,t,i).forEach((e=>{"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:Je,extractURLsFromTemplates:it,filterUrlTemplates:function(e){return e.reduce(((e,t)=>{const i=t.url||t;return nt(i)?e.validUrls.push(i):e.invalidUrls.push(i),e}),{validUrls:[],invalidUrls:[]})},containsTemplateObject:rt,isTemplateObjectEqual:st,encodeURIComponentRFC3986:at,replaceUrlMacros:et,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce(((t,i)=>t.concat(Array.isArray(i)?e(i):i)),[])},joinArrayOfUniqueTemplateObjs:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const i=Array.isArray(e)?e:[],n=Array.isArray(t)?t:[];return i.concat(n).reduce(((e,t)=>(rt(t,e)||e.push(t),e)),[])},isValidTimeValue:function(e){return Number.isFinite(e)&&e>=-2},addLeadingZeros:ot,isValidUrl:nt,isBrowserEnvironment:function(){return"undefined"!=typeof window},formatMacrosValues:function(e){return"object"!=typeof e?e:JSON.stringify(e)}};function lt(e){return["true","TRUE","True","1"].includes(e)}const ct={childByName:function(e,t){return Array.from(e.childNodes).find((e=>e.nodeName===t))},childrenByName:function(e,t){return Array.from(e.childNodes).filter((e=>e.nodeName===t))},resolveVastAdTagURI:function(e,t){if(!t)return e;if(e.startsWith("//")){const{protocol:t}=location;return"".concat(t).concat(e)}if(!e.includes("://")){const i=t.slice(0,t.lastIndexOf("/"));return"".concat(i,"/").concat(e)}return e},parseBoolean:lt,parseNodeText:function(e){return e&&(e.textContent||e.text||"").trim()},copyNodeAttribute:function(e,t,i){const n=t.getAttribute(e);n&&i.setAttribute(e,n)},parseAttributes:function(e){return Array.from(e.attributes).reduce(((e,t)=>(e[t.nodeName]=t.nodeValue,e)),{})},parseDuration:function(e){if(null==e)return-1;if(dt.isNumeric(e))return parseInt(e);const t=e.split(":");if(3!==t.length)return-1;const i=t[2].split(".");let n=parseInt(i[0]);2===i.length&&(n+=parseFloat("0.".concat(i[1])));const r=parseInt(60*t[1]),s=parseInt(60*t[0]*60);return isNaN(s)||isNaN(r)||isNaN(n)||r>3600||n>60?-1:s+r+n},getStandAloneAds:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter((e=>!parseInt(e.sequence,10)))},getSortedAdPods:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter((e=>parseInt(e.sequence,10))).sort(((e,t)=>e.sequence-t.sequence))},assignAttributes:function(e,t){e&&Array.from(e).forEach((e=>{let{nodeName:i,nodeValue:n}=e;if(i&&n&&t.hasOwnProperty(i)){let e=n;"boolean"==typeof t[i]&&(e=lt(e)),t[i]=e}}))},mergeWrapperAdData:function(e,t){var i;e.errorURLTemplates=t.errorURLTemplates.concat(e.errorURLTemplates),e.impressionURLTemplates=t.impressionURLTemplates.concat(e.impressionURLTemplates),e.extensions=t.extensions.concat(e.extensions),t.viewableImpression.length>0&&(e.viewableImpression=[...e.viewableImpression,...t.viewableImpression]),e.followAdditionalWrappers=t.followAdditionalWrappers,e.allowMultipleAds=t.allowMultipleAds,e.fallbackOnNoAd=t.fallbackOnNoAd;const n=(t.creatives||[]).filter((e=>e&&"companion"===e.type)),r=n.reduce(((e,t)=>((t.variations||[]).forEach((t=>{(t.companionClickTrackingURLTemplates||[]).forEach((t=>{dt.containsTemplateObject(t,e)||e.push(t)}))})),e)),[]);e.creatives=n.concat(e.creatives);const s=t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length,a=t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length;if(e.creatives.forEach((e=>{if(t.trackingEvents&&t.trackingEvents[e.type])for(const i in t.trackingEvents[e.type]){const n=t.trackingEvents[e.type][i];Array.isArray(e.trackingEvents[i])||(e.trackingEvents[i]=[]),e.trackingEvents[i]=e.trackingEvents[i].concat(n)}"linear"===e.type&&(s&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates)),a&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates)),!t.videoClickThroughURLTemplate||null!==e.videoClickThroughURLTemplate&&void 0!==e.videoClickThroughURLTemplate||(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)),"companion"===e.type&&r.length&&(e.variations||[]).forEach((e=>{e.companionClickTrackingURLTemplates=dt.joinArrayOfUniqueTemplateObjs(e.companionClickTrackingURLTemplates,r)}))})),t.adVerifications&&(e.adVerifications=e.adVerifications.concat(t.adVerifications)),t.blockedAdCategories&&(e.blockedAdCategories=e.blockedAdCategories.concat(t.blockedAdCategories)),null!==(i=t.creatives)&&void 0!==i&&i.length){const i=t.creatives.filter((e=>{var t;return(null===(t=e.icons)||void 0===t?void 0:t.length)&&!e.mediaFiles.length}));i.length&&(e.creatives=e.creatives.concat(i))}}};function ut(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t,adId:i,sequence:n,apiFramework:r}=Xe(e);return{id:t,adId:i,sequence:n,apiFramework:r,type:"companion",required:null,variations:[]}}(t);return i.required=e.getAttribute("required")||null,i.variations=ct.childrenByName(e,"Companion").map((e=>{const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,adType:"companionAd",width:e.width||0,height:e.height||0,assetWidth:e.assetWidth||null,assetHeight:e.assetHeight||null,expandedWidth:e.expandedWidth||null,expandedHeight:e.expandedHeight||null,apiFramework:e.apiFramework||null,adSlotId:e.adSlotId||null,pxratio:e.pxratio||"1",renderingMode:e.renderingMode||"default",staticResources:[],htmlResources:[],iframeResources:[],adParameters:null,altText:null,companionClickThroughURLTemplate:null,companionClickTrackingURLTemplates:[],trackingEvents:{}}}(ct.parseAttributes(e));t.htmlResources=ct.childrenByName(e,"HTMLResource").reduce(((e,t)=>{const i=ct.parseNodeText(t);return i?e.concat(i):e}),[]),t.iframeResources=ct.childrenByName(e,"IFrameResource").reduce(((e,t)=>{const i=ct.parseNodeText(t);return i?e.concat(i):e}),[]),t.staticResources=ct.childrenByName(e,"StaticResource").reduce(((e,t)=>{const i=ct.parseNodeText(t);return i?e.concat({url:i,creativeType:t.getAttribute("creativeType")||null}):e}),[]),t.altText=ct.parseNodeText(ct.childByName(e,"AltText"))||null;const i=ct.childByName(e,"TrackingEvents");i&&ct.childrenByName(i,"Tracking").forEach((e=>{const i=e.getAttribute("event"),n=ct.parseNodeText(e);i&&n&&(Array.isArray(t.trackingEvents[i])||(t.trackingEvents[i]=[]),t.trackingEvents[i].push(n))})),t.companionClickTrackingURLTemplates=ct.childrenByName(e,"CompanionClickTracking").map((e=>({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)}))),t.companionClickThroughURLTemplate=ct.parseNodeText(ct.childByName(e,"CompanionClickThrough"))||null;const n=ct.childByName(e,"AdParameters");return n&&(t.adParameters={value:ct.parseNodeText(n),xmlEncoded:n.getAttribute("xmlEncoded")||null}),t})),i}function ht(e,t){let i;const n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t,adId:i,sequence:n,apiFramework:r}=Xe(e);return{id:t,adId:i,sequence:n,apiFramework:r,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}}(t);n.duration=ct.parseDuration(ct.parseNodeText(ct.childByName(e,"Duration")));const r=e.getAttribute("skipoffset");if(null==r)n.skipDelay=null;else if("%"===r.charAt(r.length-1)&&-1!==n.duration){const e=parseInt(r,10);n.skipDelay=n.duration*(e/100)}else n.skipDelay=ct.parseDuration(r);const s=ct.childByName(e,"VideoClicks");if(s){const e=ct.childByName(s,"ClickThrough");n.videoClickThroughURLTemplate=e?{id:e.getAttribute("id")||null,url:ct.parseNodeText(e)}:null,ct.childrenByName(s,"ClickTracking").forEach((e=>{n.videoClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)})})),ct.childrenByName(s,"CustomClick").forEach((e=>{n.videoCustomClickURLTemplates.push({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)})}))}const a=ct.childByName(e,"AdParameters");a&&(n.adParameters={value:ct.parseNodeText(a),xmlEncoded:a.getAttribute("xmlEncoded")||null}),ct.childrenByName(e,"TrackingEvents").forEach((e=>{ct.childrenByName(e,"Tracking").forEach((e=>{let t=e.getAttribute("event");const r=ct.parseNodeText(e);if(t&&r){if("progress"===t){if(i=e.getAttribute("offset"),!i)return;t="%"===i.charAt(i.length-1)?"progress-".concat(i):"progress-".concat(ct.parseDuration(i))}Array.isArray(n.trackingEvents[t])||(n.trackingEvents[t]=[]),n.trackingEvents[t].push(r)}}))})),ct.childrenByName(e,"MediaFiles").forEach((e=>{ct.childrenByName(e,"MediaFile").forEach((e=>{n.mediaFiles.push(function(e){const t={id:null,fileURL:null,fileSize:0,deliveryType:"progressive",mimeType:null,mediaType:null,codec:null,bitrate:0,minBitrate:0,maxBitrate:0,width:0,height:0,apiFramework:null,scalable:null,maintainAspectRatio:null};t.id=e.getAttribute("id"),t.fileURL=ct.parseNodeText(e),t.deliveryType=e.getAttribute("delivery"),t.codec=e.getAttribute("codec"),t.mimeType=e.getAttribute("type"),t.mediaType=e.getAttribute("mediaType")||"2D",t.apiFramework=e.getAttribute("apiFramework"),t.fileSize=parseInt(e.getAttribute("fileSize")||0),t.bitrate=parseInt(e.getAttribute("bitrate")||0),t.minBitrate=parseInt(e.getAttribute("minBitrate")||0),t.maxBitrate=parseInt(e.getAttribute("maxBitrate")||0),t.width=parseInt(e.getAttribute("width")||0),t.height=parseInt(e.getAttribute("height")||0);const i=e.getAttribute("scalable");i&&"string"==typeof i&&(t.scalable=ct.parseBoolean(i));const n=e.getAttribute("maintainAspectRatio");return n&&"string"==typeof n&&(t.maintainAspectRatio=ct.parseBoolean(n)),t}(e))}));const t=ct.childByName(e,"InteractiveCreativeFile");t&&(n.interactiveCreativeFile=function(e){const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,apiFramework:e.apiFramework||null,variableDuration:ct.parseBoolean(e.variableDuration),fileURL:null}}(ct.parseAttributes(e));return t.fileURL=ct.parseNodeText(e),t}(t));const i=ct.childByName(e,"ClosedCaptionFiles");i&&ct.childrenByName(i,"ClosedCaptionFile").forEach((e=>{const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,language:e.language||null,fileURL:null}}(ct.parseAttributes(e));t.fileURL=ct.parseNodeText(e),n.closedCaptionFiles.push(t)}));const r=ct.childByName(e,"Mezzanine"),s=function(e,t){const i={};let n=!1;return["delivery","type","width","height"].forEach((t=>{e&&e.getAttribute(t)?i[t]=e.getAttribute(t):n=!0})),n?null:i}(r);if(s){const e={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};e.id=r.getAttribute("id"),e.fileURL=ct.parseNodeText(r),e.delivery=s.delivery,e.codec=r.getAttribute("codec"),e.type=s.type,e.width=parseInt(s.width,10),e.height=parseInt(s.height,10),e.fileSize=parseInt(r.getAttribute("fileSize"),10),e.mediaType=r.getAttribute("mediaType")||"2D",n.mezzanine=e}}));const o=ct.childByName(e,"Icons");return o&&ct.childrenByName(o,"Icon").forEach((e=>{n.icons.push(function(e){const t={program:null,height:0,width:0,xPosition:0,yPosition:0,apiFramework:null,offset:null,duration:0,type:null,staticResource:null,htmlResource:null,iframeResource:null,pxratio:"1",iconClickThroughURLTemplate:null,iconClickTrackingURLTemplates:[],iconViewTrackingURLTemplate:null,iconClickFallbackImages:[],altText:null,hoverText:null};t.program=e.getAttribute("program"),t.height=parseInt(e.getAttribute("height")||0),t.width=parseInt(e.getAttribute("width")||0),t.xPosition=function(e){return-1!==["left","right"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("xPosition")),t.yPosition=function(e){return-1!==["top","bottom"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("yPosition")),t.apiFramework=e.getAttribute("apiFramework"),t.pxratio=e.getAttribute("pxratio")||"1",t.offset=ct.parseDuration(e.getAttribute("offset")),t.duration=ct.parseDuration(e.getAttribute("duration")),t.altText=e.getAttribute("altText"),t.hoverText=e.getAttribute("hoverText"),ct.childrenByName(e,"HTMLResource").forEach((e=>{t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=ct.parseNodeText(e)})),ct.childrenByName(e,"IFrameResource").forEach((e=>{t.type=e.getAttribute("creativeType")||0,t.iframeResource=ct.parseNodeText(e)})),ct.childrenByName(e,"StaticResource").forEach((e=>{t.type=e.getAttribute("creativeType")||0,t.staticResource=ct.parseNodeText(e)}));const i=ct.childByName(e,"IconClicks");if(i){t.iconClickThroughURLTemplate=ct.parseNodeText(ct.childByName(i,"IconClickThrough")),ct.childrenByName(i,"IconClickTracking").forEach((e=>{t.iconClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)})}));const e=ct.childByName(i,"IconClickFallbackImages");e&&ct.childrenByName(e,"IconClickFallbackImage").forEach((e=>{t.iconClickFallbackImages.push({url:ct.parseNodeText(e)||null,width:e.getAttribute("width")||null,height:e.getAttribute("height")||null})}))}return t.iconViewTrackingURLTemplate=ct.parseNodeText(ct.childByName(e,"IconViewTracking")),t}(e))})),n}function pt(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t,adId:i,sequence:n,apiFramework:r}=Xe(e);return{id:t,adId:i,sequence:n,apiFramework:r,type:"nonlinear",variations:[],trackingEvents:{}}}(t);return ct.childrenByName(e,"TrackingEvents").forEach((e=>{let t,n;ct.childrenByName(e,"Tracking").forEach((e=>{t=e.getAttribute("event"),n=ct.parseNodeText(e),t&&n&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(n))}))})),ct.childrenByName(e,"NonLinear").forEach((e=>{const t={id:null,width:0,height:0,expandedWidth:0,expandedHeight:0,scalable:!0,maintainAspectRatio:!0,minSuggestedDuration:0,apiFramework:"static",adType:"nonLinearAd",type:null,staticResource:null,htmlResource:null,iframeResource:null,nonlinearClickThroughURLTemplate:null,nonlinearClickTrackingURLTemplates:[],adParameters:null};t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.expandedWidth=e.getAttribute("expandedWidth"),t.expandedHeight=e.getAttribute("expandedHeight"),t.scalable=ct.parseBoolean(e.getAttribute("scalable")),t.maintainAspectRatio=ct.parseBoolean(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=ct.parseDuration(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),ct.childrenByName(e,"HTMLResource").forEach((e=>{t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=ct.parseNodeText(e)})),ct.childrenByName(e,"IFrameResource").forEach((e=>{t.type=e.getAttribute("creativeType")||0,t.iframeResource=ct.parseNodeText(e)})),ct.childrenByName(e,"StaticResource").forEach((e=>{t.type=e.getAttribute("creativeType")||0,t.staticResource=ct.parseNodeText(e)}));const n=ct.childByName(e,"AdParameters");n&&(t.adParameters={value:ct.parseNodeText(n),xmlEncoded:n.getAttribute("xmlEncoded")||null}),t.nonlinearClickThroughURLTemplate=ct.parseNodeText(ct.childByName(e,"NonLinearClickThrough")),ct.childrenByName(e,"NonLinearClickTracking").forEach((e=>{t.nonlinearClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)})})),i.variations.push(t)})),i}function Et(e){const t=[];return e.forEach((e=>{const i=_t(e);i&&t.push(i)})),t}function _t(e){if("#comment"===e.nodeName)return null;const t={name:null,value:null,attributes:{},children:[]},i=e.attributes,n=e.childNodes;if(t.name=e.nodeName,e.attributes)for(const e in i)if(i.hasOwnProperty(e)){const n=i[e];n.nodeName&&n.nodeValue&&(t.attributes[n.nodeName]=n.nodeValue)}for(const e in n)if(n.hasOwnProperty(e)){const i=_t(n[e]);i&&t.children.push(i)}if(0===t.children.length||1===t.children.length&&["#cdata-section","#text"].indexOf(t.children[0].name)>=0){const i=ct.parseNodeText(e);""!==i&&(t.value=i),t.children=[]}return null===(r=t).value&&0===Object.keys(r.attributes).length&&0===r.children.length?null:t;var r}function mt(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}const At={Wrapper:{subElements:["VASTAdTagURI","Impression"]},BlockedAdCategories:{attributes:["authority"]},InLine:{subElements:["AdSystem","AdTitle","Impression","AdServingId","Creatives"]},Category:{attributes:["authority"]},Pricing:{attributes:["model","currency"]},Verification:{oneOfinLineResources:["JavaScriptResource","ExecutableResource"],attributes:["vendor"]},UniversalAdId:{attributes:["idRegistry"]},JavaScriptResource:{attributes:["apiFramework","browserOptional"]},ExecutableResource:{attributes:["apiFramework","type"]},Tracking:{attributes:["event"]},Creatives:{subElements:["Creative"]},Creative:{subElements:["UniversalAdId"]},Linear:{subElements:["MediaFiles","Duration"]},MediaFiles:{subElements:["MediaFile"]},MediaFile:{attributes:["delivery","type","width","height"]},Mezzanine:{attributes:["delivery","type","width","height"]},NonLinear:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},Companion:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},StaticResource:{attributes:["creativeType"]},Icons:{subElements:["Icon"]},Icon:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"]}};function vt(e,t){if(!At[e.nodeName]||!At[e.nodeName].attributes)return;const i=At[e.nodeName].attributes.filter((t=>!e.getAttribute(t)));i.length>0&&Rt({name:e.nodeName,parentName:e.parentNode.nodeName,attributes:i},t)}function gt(e,t,i){const n=At[e.nodeName],r=!i&&"Wrapper"!==e.nodeName;if(n&&!r){if(n.subElements){const i=n.subElements.filter((t=>!ct.childByName(e,t)));i.length>0&&Rt({name:e.nodeName,parentName:e.parentNode.nodeName,subElements:i},t)}i&&n.oneOfinLineResources&&(n.oneOfinLineResources.some((t=>ct.childByName(e,t)))||Rt({name:e.nodeName,parentName:e.parentNode.nodeName,oneOfResources:n.oneOfinLineResources},t))}}function Tt(e){return e.children&&0!==e.children.length}function Rt(e,t){let{name:i,parentName:n,attributes:r,subElements:s,oneOfResources:a}=e,o="Element '".concat(i,"'");o+=r?" missing required attribute(s) '".concat(r.join(", "),"' "):s?" missing required sub element(s) '".concat(s.join(", "),"' "):a?" must provide one of the following '".concat(a.join(", "),"' "):" is empty",t("VAST-warning",{message:o,parentElement:n,specVersion:4.1})}const St={verifyRequiredValues:function e(t,i,n){if(t&&t.nodeName)if("InLine"===t.nodeName&&(n=!0),vt(t,i),Tt(t)){gt(t,i,n);for(let r=0;r2&&void 0!==arguments[2]?arguments[2]:{};const r=Array.from(e.childNodes).filter((e=>{const t=e.nodeName.toLowerCase();return"inline"===t||!1!==n&&"wrapper"===t}));for(const n of r){if(ct.copyNodeAttribute("id",e,n),ct.copyNodeAttribute("sequence",e,n),ct.copyNodeAttribute("adType",e,n),"Wrapper"===n.nodeName)return{ad:Lt(n,t),type:"WRAPPER"};if("InLine"===n.nodeName)return{ad:ft(n,t,{allowMultipleAds:i}),type:"INLINE"};const r=n.nodeName.toLowerCase();t("VAST-warning",{message:"<".concat(n.nodeName,"inline"===r?"> must be written ":"> must be written "),wrongNode:n})}}function ft(e,t){let{allowMultipleAds:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!1===i&&e.getAttribute("sequence")?null:Dt(e,t)}function Dt(e,t){let i=[];t&&St.verifyRequiredValues(e,t);const n=Array.from(e.childNodes),r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,sequence:e.sequence||null,adType:e.adType||null,adServingId:null,categories:[],expires:null,viewableImpression:[],system:null,title:null,description:null,advertiser:null,pricing:null,survey:null,errorURLTemplates:[],impressionURLTemplates:[],creatives:[],extensions:[],adVerifications:[],blockedAdCategories:[],followAdditionalWrappers:!0,allowMultipleAds:!1,fallbackOnNoAd:null}}(ct.parseAttributes(e));return n.forEach((e=>{switch(e.nodeName){case"Error":r.errorURLTemplates.push(ct.parseNodeText(e));break;case"Impression":r.impressionURLTemplates.push({id:e.getAttribute("id")||null,url:ct.parseNodeText(e)});break;case"Creatives":r.creatives=function(e){const t=[];return e.forEach((e=>{const i={id:e.getAttribute("id")||null,adId:mt(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null},n=[];let r;ct.childrenByName(e,"UniversalAdId").forEach((e=>{const t={idRegistry:e.getAttribute("idRegistry")||"unknown",value:ct.parseNodeText(e)};n.push(t)}));const s=ct.childByName(e,"CreativeExtensions");s&&(r=Et(ct.childrenByName(s,"CreativeExtension")));for(const s in e.childNodes){const a=e.childNodes[s];let o;switch(a.nodeName){case"Linear":o=ht(a,i);break;case"NonLinearAds":o=pt(a,i);break;case"CompanionAds":o=ut(a,i)}o&&(n&&(o.universalAdIds=n),r&&(o.creativeExtensions=r),t.push(o))}})),t}(ct.childrenByName(e,"Creative"));break;case"Extensions":{const t=ct.childrenByName(e,"Extension");r.extensions=Et(t),r.adVerifications.length||(i=function(e){let t=null,i=[];return e.some((e=>t=ct.childByName(e,"AdVerifications"))),t&&(i=kt(ct.childrenByName(t,"Verification"))),i}(t));break}case"AdVerifications":r.adVerifications=kt(ct.childrenByName(e,"Verification"));break;case"AdSystem":r.system={value:ct.parseNodeText(e),version:e.getAttribute("version")||null};break;case"AdTitle":r.title=ct.parseNodeText(e);break;case"AdServingId":r.adServingId=ct.parseNodeText(e);break;case"Category":r.categories.push({authority:e.getAttribute("authority")||null,value:ct.parseNodeText(e)});break;case"Expires":r.expires=parseInt(ct.parseNodeText(e),10);break;case"ViewableImpression":r.viewableImpression.push(function(e){const t=(e,t)=>{const i=ct.parseNodeText(t);return i&&e.push(i),e};return{id:e.getAttribute("id")||null,viewable:ct.childrenByName(e,"Viewable").reduce(t,[]),notViewable:ct.childrenByName(e,"NotViewable").reduce(t,[]),viewUndetermined:ct.childrenByName(e,"ViewUndetermined").reduce(t,[])}}(e));break;case"Description":r.description=ct.parseNodeText(e);break;case"Advertiser":r.advertiser={id:e.getAttribute("id")||null,value:ct.parseNodeText(e)};break;case"Pricing":r.pricing={value:ct.parseNodeText(e),model:e.getAttribute("model")||null,currency:e.getAttribute("currency")||null};break;case"Survey":r.survey={value:ct.parseNodeText(e),type:e.getAttribute("type")||null};break;case"BlockedAdCategories":r.blockedAdCategories.push({authority:e.getAttribute("authority")||null,value:ct.parseNodeText(e)})}})),i.length&&(r.adVerifications=r.adVerifications.concat(i)),r}function Lt(e,t){const i=Dt(e,t),n=e.getAttribute("followAdditionalWrappers"),r=e.getAttribute("allowMultipleAds"),s=e.getAttribute("fallbackOnNoAd");i.followAdditionalWrappers=!n||ct.parseBoolean(n),i.allowMultipleAds=!!r&&ct.parseBoolean(r),i.fallbackOnNoAd=s?ct.parseBoolean(s):null;let a=ct.childByName(e,"VASTAdTagURI");if(a?i.nextWrapperURL=ct.parseNodeText(a):(a=ct.childByName(e,"VASTAdTagURL"),a&&(i.nextWrapperURL=ct.parseNodeText(ct.childByName(a,"URL")))),i.creatives.forEach((e=>{if(["linear","nonlinear"].includes(e.type)){if(e.trackingEvents){i.trackingEvents||(i.trackingEvents={}),i.trackingEvents[e.type]||(i.trackingEvents[e.type]={});for(const t in e.trackingEvents){const n=e.trackingEvents[t];Array.isArray(i.trackingEvents[e.type][t])||(i.trackingEvents[e.type][t]=[]),n.forEach((n=>{i.trackingEvents[e.type][t].push(n)}))}}e.videoClickTrackingURLTemplates&&(Array.isArray(i.videoClickTrackingURLTemplates)||(i.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((e=>{i.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(i.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(Array.isArray(i.videoCustomClickURLTemplates)||(i.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((e=>{i.videoCustomClickURLTemplates.push(e)})))}})),i.nextWrapperURL)return i}function kt(e){const t=[];return e.forEach((e=>{const i={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},n=Array.from(e.childNodes);ct.assignAttributes(e.attributes,i),n.forEach((e=>{let{nodeName:t,textContent:n,attributes:r}=e;switch(t){case"JavaScriptResource":case"ExecutableResource":i.resource=n.trim(),ct.assignAttributes(r,i);break;case"VerificationParameters":i.parameters=n.trim()}}));const r=ct.childByName(e,"TrackingEvents");r&&ct.childrenByName(r,"Tracking").forEach((e=>{const t=e.getAttribute("event"),n=ct.parseNodeText(e);t&&n&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(n))})),t.push(i)})),t}class Pt{constructor(){this._handlers=[]}on(e,t){if("function"!=typeof t)throw new TypeError("The handler argument must be of type Function. Received type ".concat(typeof t));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(typeof e));return this._handlers.push({event:e,handler:t}),this}once(e,t){return this.on(e,function(e,t,i){const n={fired:!1,wrapFn:void 0};function r(){n.fired||(e.off(t,n.wrapFn),n.fired=!0,i.bind(e)(...arguments))}return n.wrapFn=r,r}(this,e,t))}off(e,t){return this._handlers=this._handlers.filter((i=>i.event!==e||i.handler!==t)),this}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n{"*"===t.event&&(r=!0,t.handler(e,...i)),t.event===e&&(r=!0,t.handler(...i))})),r}removeAllListeners(e){return e?(this._handlers=this._handlers.filter((t=>t.event!==e)),this):(this._handlers=[],this)}listenerCount(e){return this._handlers.filter((t=>t.event===e)).length}listeners(e){return this._handlers.reduce(((t,i)=>(i.event===e&&t.push(i.handler),t)),[])}eventNames(){return this._handlers.map((e=>e.event))}}let yt=0,Ot=0;const bt=(e,t)=>{!e||!t||e<=0||t<=0||(Ot=(Ot*yt+8*e/t)/++yt)},Ct={ERRORCODE:900,extensions:[]},Nt="VAST response version not supported";class Ut extends Pt{constructor(){let{fetcher:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.maxWrapperDepth=null,this.rootErrorURLTemplates=[],this.errorURLTemplates=[],this.remainingAds=[],this.parsingOptions={},this.fetcher=e||null,this.keepFailedAdPod=!1}trackVastError(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r0&&void 0!==arguments[0]?arguments[0]:{};this.maxWrapperDepth=e.wrapperLimit||10,this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.keepFailedAdPod=e.keepFailedAdPod||!1,this.rootURL="",this.resetParsingStatus(),bt(e.byteLength,e.requestDuration)}resetParsingStatus(){this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.vastVersion=null}getRemainingAds(e){if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));const t=e?this.remainingAds:[this.remainingAds.shift()];return this.errorURLTemplates=[],this.resolveAds(t,{wrapperDepth:0,url:this.rootURL}).then((e=>this.buildVASTResponse(e)))}parseVAST(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(t),t.isRootVAST=!0,this.parse(e,t).then((e=>this.buildVASTResponse(e)))}buildVASTResponse(e){const t=function(e){let{ads:t,errorURLTemplates:i,version:n}=e;return{ads:t||[],errorURLTemplates:i||[],version:n||null}}({ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion});return this.completeWrapperResolving(t),t}parseVastXml(e,t){let{isRootVAST:i=!1,url:n=null,wrapperDepth:r=0,allowMultipleAds:s,followAdditionalWrappers:a,wrapperChainId:o=0}=t;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName){var d;this.emit("VAST-ad-parsed",{type:"ERROR",url:n,wrapperDepth:r,wrapperChainId:o});const t="VideoAdServingTemplate"===(null==e||null===(d=e.documentElement)||void 0===d?void 0:d.nodeName);throw new Error(t?Nt:"Invalid VAST XMLDocument")}const l=[],c=e.documentElement.childNodes,u=e.documentElement.getAttribute("version");i&&u&&(this.vastVersion=u);for(const e in c){const t=c[e];if("Error"===t.nodeName){const e=ct.parseNodeText(t);i?this.rootErrorURLTemplates.push(e):this.errorURLTemplates.push(e)}else if("Ad"===t.nodeName){if(this.vastVersion&&parseFloat(this.vastVersion)<3)s=!0;else if(!1===s&&l.length>1)break;const e=It(t,this.emit.bind(this),{allowMultipleAds:s,followAdditionalWrappers:a});e.ad?(l.push(e.ad),this.emit("VAST-ad-parsed",{type:e.type,url:n,wrapperDepth:r,adIndex:l.length-1,vastVersion:u,wrapperChainId:o})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return l}parse(e){let{url:t=null,resolveAll:i=!0,wrapperSequence:n=null,previousUrl:r=null,wrapperDepth:s=0,isRootVAST:a=!1,followAdditionalWrappers:o,allowMultipleAds:d,wrapperChainId:l=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&a&&(d=!0);try{c=this.parseVastXml(e,{isRootVAST:a,url:t,wrapperDepth:s,allowMultipleAds:d,followAdditionalWrappers:o,wrapperChainId:l})}catch(e){return Promise.reject(e)}if(1===c.length&&s>0&&void 0!==n&&(c[0].sequence=n),!1===i){const e=ct.getSortedAdPods(c),t=ct.getStandAloneAds(c);e.length?c=e:t.length&&(c=[t.shift()]),this.remainingAds=t}return this.resolveAds(c,{wrapperDepth:s,previousUrl:r,url:t,wrapperChainId:l})}resolveAds(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{wrapperDepth:t,previousUrl:i,url:n,wrapperChainId:r=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[];return i=n,e.forEach((e=>{const n=this.resolveWrappers(e,t,i,r);s.push(n),0===t&&r++})),Promise.all(s).then((e=>dt.flatten(e)))}resolveWrappers(e,t,i,n){const r={...e};return new Promise((e=>{var s;if(t++,!r.nextWrapperURL)return delete r.nextWrapperURL,e(r);if(!this.fetcher)return r.VASTAdTagURI=r.nextWrapperURL,delete r.nextWrapperURL,e(r);if(t>=this.maxWrapperDepth)return r.errorCode=302,delete r.nextWrapperURL,e(r);r.nextWrapperURL=ct.resolveVastAdTagURI(r.nextWrapperURL,i);const a=null!==(s=this.parsingOptions.allowMultipleAds)&&void 0!==s?s:r.allowMultipleAds,o=r.sequence;this.fetcher.fetchVAST({url:r.nextWrapperURL,emitter:this.emit.bind(this),maxWrapperDepth:this.maxWrapperDepth,wrapperDepth:t,previousUrl:i,wrapperAd:r,wrapperChainId:n}).then((s=>this.parse(s,{url:r.nextWrapperURL,previousUrl:i,wrapperSequence:o,wrapperDepth:t,followAdditionalWrappers:r.followAdditionalWrappers,allowMultipleAds:a,wrapperChainId:n}).then((t=>{if(delete r.nextWrapperURL,0===t.length)return r.creatives=[],e(r);t.forEach((e=>{e&&ct.mergeWrapperAdData(e,r)})),e(t)})))).catch((t=>{r.errorCode=t.message===Nt?102:301,r.errorMessage=t.message,e(r)}))}))}completeWrapperResolving(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(let t=e.ads.length-1;t>=0;t--){const i=e.ads[t],n=!i.creatives.some((e=>{var t,i;return(null===(t=e.mediaFiles)||void 0===t?void 0:t.length)>0||(null===(i=e.variations)||void 0===i?void 0:i.length)>0}));!i.errorCode&&!n||i.VASTAdTagURI||(this.trackVastError(i.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:i.errorCode||303},{ERRORMESSAGE:i.errorMessage||""},{extensions:i.extensions},{system:i.system}),this.keepFailedAdPod&&i.sequence?i.hasFailed=!0:e.ads.splice(t,1))}}}let wt=null;const Vt={data:{},length:0,getItem(e){return this.data[e]},setItem(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem(e){delete this.data[e],this.length=Object.keys(this.data).length},clear(){this.data={},this.length=0}};class Mt{constructor(){this.storage=this.initStorage()}initStorage(){if(wt)return wt;try{wt="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){wt=null}return wt&&!this.isStorageDisabled(wt)||(wt=Vt,wt.clear()),wt}isStorageDisabled(e){const t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}getItem(e){return this.storage.getItem(e)}setItem(e,t){return this.storage.setItem(e,t)}removeItem(e){return this.storage.removeItem(e)}clear(){return this.storage.clear()}}const Bt=12e4,xt={get:async function(e,t){try{const n=new AbortController,r=setTimeout((()=>{throw n.abort(),new Error("URLHandler: Request timed out after ".concat(t.timeout||Bt," ms (408)"))}),t.timeout||Bt),s=await fetch(e,{...t,signal:n.signal,credentials:t.withCredentials?"include":"omit"}).finally((()=>{clearTimeout(r)})),a=function(e){return dt.isBrowserEnvironment()&&"https:"===window.location.protocol&&e.url.includes("http://")?"URLHandler: Cannot go from HTTPS to HTTP.":200===e.status&&e.ok?null:"URLHandler: ".concat(e.statusText," (").concat(e.status,")")}(s);return a?{error:new Error(a),statusCode:s.status}:async function(e){const t=await e.text();let n;return n=dt.isBrowserEnvironment()?new DOMParser:new((await i.e(969).then(i.t.bind(i,3969,19))).DOMParser),{xml:n.parseFromString(t,"text/xml"),details:{byteLength:t.length,statusCode:e.status,rawXml:t}}}(s)}catch(e){return{error:e,statusCode:"AbortError"===e.name?408:null}}}};class Ft{constructor(){this.URLTemplateFilters=[]}setOptions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.urlHandler=e.urlHandler||e.urlhandler||xt,this.fetchingOptions={...e.fetchOptions,timeout:e.timeout||Bt,withCredentials:Boolean(e.withCredentials)}}addURLTemplateFilter(e){"function"==typeof e&&this.URLTemplateFilters.push(e)}removeLastURLTemplateFilter(){this.URLTemplateFilters.pop()}countURLTemplateFilters(){return this.URLTemplateFilters.length}clearURLTemplateFilters(){this.URLTemplateFilters=[]}async fetchVAST(e){var t;let{url:i,maxWrapperDepth:n,emitter:r,wrapperDepth:s=0,previousUrl:a=null,wrapperAd:o=null,wrapperChainId:d=0}=e;const l=Date.now();this.URLTemplateFilters.forEach((e=>{i=e(i)})),r("VAST-resolving",{url:i,previousUrl:a,wrapperDepth:s,maxWrapperDepth:n,timeout:this.fetchingOptions.timeout,wrapperAd:o,wrapperChainId:d});const c=await this.urlHandler.get(i,this.fetchingOptions),u=Math.round(Date.now()-l);if(r("VAST-resolved",{url:i,previousUrl:a,wrapperDepth:s,error:(null==c?void 0:c.error)||null,duration:u,statusCode:(null==c?void 0:c.statusCode)||null,wrapperChainId:d,...null==c?void 0:c.details}),bt(null==c||null===(t=c.details)||void 0===t?void 0:t.byteLength,u),c.error)throw new Error(c.error);return c.xml}}class Kt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Mt;this.cappingFreeLunch=e,this.cappingMinimumTimeInterval=t,this.fetcher=new Ft,this.vastParser=new Ut({fetcher:this.fetcher}),this.storage=i,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}addURLTemplateFilter(e){this.fetcher.addURLTemplateFilter(e)}removeLastURLTemplateFilter(){this.fetcher.removeLastURLTemplateFilter()}countURLTemplateFilters(){return this.fetcher.countURLTemplateFilters()}clearURLTemplateFilters(){this.fetcher.clearURLTemplateFilters()}getParser(){return this.vastParser}get lastSuccessfulAd(){return this.storage.getItem("vast-client-last-successful-ad")}set lastSuccessfulAd(e){this.storage.setItem("vast-client-last-successful-ad",e)}get totalCalls(){return this.storage.getItem("vast-client-total-calls")}set totalCalls(e){this.storage.setItem("vast-client-total-calls",e)}get totalCallsTimeout(){return this.storage.getItem("vast-client-total-calls-timeout")}set totalCallsTimeout(e){this.storage.setItem("vast-client-total-calls-timeout",e)}hasRemainingAds(){return this.vastParser.remainingAds.length>0}getNextAds(e){return this.vastParser.getRemainingAds(e)}parseVAST(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.fetcher.setOptions(t),this.vastParser.parseVAST(e,t)}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=Date.now();return t.hasOwnProperty("resolveAll")||(t.resolveAll=!1),this.totalCallsTimeout{if(this.cappingFreeLunch>=this.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls,"/").concat(this.cappingFreeLunch)));const s=i-this.lastSuccessfulAd;if(s<0)this.lastSuccessfulAd=0;else if(s(t.previousUrl=e,t.isRootVAST=!0,t.url=e,this.vastParser.parse(i,t).then((e=>{const t=this.vastParser.buildVASTResponse(e);n(t)}))))).catch((e=>r(e)))}))}}class Ht extends Pt{constructor(e,t,i){var n;let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.ad=t,this.creative=i,this.variation=r,this.muted=s,this.impressed=!1,this.skippable=!1,this.trackingEvents={},this.trackedProgressEvents=[],this.lastPercentage=0,this._alreadyTriggeredQuartiles={},this.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"];for(const e in this.creative.trackingEvents){const t=this.creative.trackingEvents[e];this.trackingEvents[e]=t.slice(0)}this.viewableImpressionTrackers=(null===(n=this.ad.viewableImpression)||void 0===n?void 0:n.reduce(((e,t)=>(e.notViewable.push(...t.notViewable),e.viewUndetermined.push(...t.viewUndetermined),e.viewable.push(...t.viewable),e)),{notViewable:[],viewUndetermined:[],viewable:[]}))||{},Object.entries(this.viewableImpressionTrackers).forEach((e=>{let[t,i]=e;i.length&&(this.trackingEvents[t]=i)})),function(e){return"linear"===e.type}(this.creative)?this._initLinearTracking():this._initVariationTracking(),e&&this.on("start",(()=>{e.lastSuccessfulAd=Date.now()}))}_initLinearTracking(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}_initVariationTracking(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(const e in this.variation.trackingEvents){const t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}"nonLinearAd"===this.variation.adType?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):function(e){return"companionAd"===e.adType}(this.variation)&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}setDuration(e){dt.isValidTimeValue(e)?(this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}):this.emit("TRACKER-error",{message:"the duration provided is not valid. duration: ".concat(e)})}setProgress(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!dt.isValidTimeValue(e)||"object"!=typeof t)return void this.emit("TRACKER-error",{message:"One given setProgress parameter has the wrong type. progress: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))});const n=this.skipDelay||-1;if(-1===n||this.skippable||(n>e?this.emit("skip-countdown",n-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){const n=Math.round(e/this.assetDuration*100),r=[];if(e>0){r.push("start");for(let e=this.lastPercentage;e{this.track(e,{macros:t,once:i})})),e1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"==typeof t?(this.muted!==e&&this.track(e?"mute":"unmute",{macros:t}),this.muted=e):this.emit("TRACKER-error",{message:"One given setMuted parameter has the wrong type. muted: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))})}setPaused(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"==typeof t?(this.paused!==e&&this.track(e?"pause":"resume",{macros:t}),this.paused=e):this.emit("TRACKER-error",{message:"One given setPaused parameter has the wrong type. paused: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))})}setFullscreen(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"==typeof t?(this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen",{macros:t}),this.fullscreen=e):this.emit("TRACKER-error",{message:"One given setFullScreen parameter has the wrong type. fullscreen: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))})}setExpand(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"==typeof t?(this.expanded!==e&&(this.track(e?"expand":"collapse",{macros:t}),this.track(e?"playerExpand":"playerCollapse",{macros:t})),this.expanded=e):this.emit("TRACKER-error",{message:"One given setExpand parameter has the wrong type. expanded: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))})}setSkipDelay(e){dt.isValidTimeValue(e)?this.skipDelay=e:this.emit("TRACKER-error",{message:"setSkipDelay parameter does not have a valid value. duration: ".concat(e)})}trackImpression(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.impressed||(this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates,e),this.track("creativeView",{macros:e})):this.emit("TRACKER-error",{message:"trackImpression parameter has the wrong type. macros: ".concat(e)})}trackViewableImpression(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof e?this.track("viewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackNotViewableImpression(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof e?this.track("notViewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackNotViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackUndeterminedImpression(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof e?this.track("viewUndetermined",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e)})}error(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof e&&"boolean"==typeof t?this.trackURLs(this.ad.errorURLTemplates,e,{isCustomCode:t}):this.emit("TRACKER-error",{message:"One given error parameter has the wrong type. macros: ".concat(dt.formatMacrosValues(e),", isCustomCode: ").concat(t)})}errorWithCode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"string"==typeof e&&"boolean"==typeof t?(this.error({ERRORCODE:e},t),console.log("The method errorWithCode is deprecated, please use vast tracker error method instead")):this.emit("TRACKER-error",{message:"One given errorWithCode parameter has the wrong type. errorCode: ".concat(e,", isCustomCode: ").concat(t)})}complete(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("complete",{macros:e}):this.emit("TRACKER-error",{message:"complete given macros has the wrong type. macros: ".concat(e)})}notUsed(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?(this.track("notUsed",{macros:e}),this.trackingEvents=[]):this.emit("TRACKER-error",{message:"notUsed given macros has the wrong type. macros: ".concat(e)})}otherAdInteraction(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("otherAdInteraction",{macros:e}):this.emit("TRACKER-error",{message:"otherAdInteraction given macros has the wrong type. macros: ".concat(e)})}acceptInvitation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("acceptInvitation",{macros:e}):this.emit("TRACKER-error",{message:"acceptInvitation given macros has the wrong type. macros: ".concat(e)})}adExpand(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("adExpand",{macros:e}):this.emit("TRACKER-error",{message:"adExpand given macros has the wrong type. macros: ".concat(e)})}adCollapse(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("adCollapse",{macros:e}):this.emit("TRACKER-error",{message:"adCollapse given macros has the wrong type. macros: ".concat(e)})}minimize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("minimize",{macros:e}):this.emit("TRACKER-error",{message:"minimize given macros has the wrong type. macros: ".concat(e)})}verificationNotExecuted(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof e||"object"!=typeof t)return void this.emit("TRACKER-error",{message:"One given verificationNotExecuted parameter has to wrong type. vendor: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))});if(!this.ad||!this.ad.adVerifications||!this.ad.adVerifications.length)throw new Error("No adVerifications provided");if(!e)throw new Error("No vendor provided, unable to find associated verificationNotExecuted");const i=this.ad.adVerifications.find((t=>t.vendor===e));if(!i)throw new Error("No associated verification element found for vendor: ".concat(e));const n=i.trackingEvents;if(n&&n.verificationNotExecuted){const e=n.verificationNotExecuted;this.trackURLs(e,t),this.emit("verificationNotExecuted",{trackingURLTemplates:e})}}overlayViewDuration(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"==typeof e&&"object"==typeof t?(t.ADPLAYHEAD=e,this.track("overlayViewDuration",{macros:t})):this.emit("TRACKER-error",{message:"One given overlayViewDuration parameters has the wrong type. formattedDuration: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))})}close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track(this.linear?"closeLinear":"close",{macros:e}):this.emit("TRACKER-error",{message:"close given macros has the wrong type. macros: ".concat(e)})}skip(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("skip",{macros:e}):this.emit("TRACKER-error",{message:"skip given macros has the wrong type. macros: ".concat(e)})}load(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"==typeof e?this.track("loaded",{macros:e}):this.emit("TRACKER-error",{message:"load given macros has the wrong type. macros: ".concat(e)})}click(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!==e&&"string"!=typeof e||"object"!=typeof t)return void this.emit("TRACKER-error",{message:"One given click parameter has the wrong type. fallbackClickThroughURL: ".concat(e,", macros: ").concat(dt.formatMacrosValues(t))});this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates,t);const i=this.clickThroughURLTemplate||e,n={...t};if(i){this.progress&&(n.ADPLAYHEAD=this.progressFormatted());const e=dt.resolveURLTemplates([i],n)[0];this.emit("clickthrough",e)}}trackProgressEvents(e,t,i){const n=parseFloat(e.split("-")[1]);Object.entries(this.trackingEvents).filter((e=>{let[t]=e;return t.startsWith("progress-")})).map((e=>{let[t,i]=e;return{name:t,time:parseFloat(t.split("-")[1]),urls:i}})).filter((e=>{let{time:t}=e;return t<=n&&t>this.progress})).forEach((e=>{let{name:n,urls:r}=e;!i&&this.trackedProgressEvents.includes(n)||(this.emit(n,{trackingURLTemplates:r}),this.trackURLs(r,t),i?delete this.trackingEvents[n]:this.trackedProgressEvents.push(n))}))}track(e){let{macros:t={},once:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof t)return void this.emit("TRACKER-error",{message:"track given macros has the wrong type. macros: ".concat(t)});"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close"),e.startsWith("progress-")&&!e.endsWith("%")&&this.trackProgressEvents(e,t,i);const n=this.trackingEvents[e],r=this.emitAlwaysEvents.indexOf(e)>-1;n?(this.emit(e,{trackingURLTemplates:n}),this.trackURLs(n,t)):r&&this.emit(e,null),i&&(delete this.trackingEvents[e],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}trackURLs(e){var t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{validUrls:r,invalidUrls:s}=dt.filterUrlTemplates(e);s.length&&this.emit("TRACKER-error",{message:"Provided urls are malformed. url: ".concat(s)});const a={...i};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(a.ASSETURI=this.creative.mediaFiles[0].fileURL),this.progress&&(a.ADPLAYHEAD=this.progressFormatted())),null!==(t=this.creative)&&void 0!==t&&null!==(t=t.universalAdIds)&&void 0!==t&&t.length&&(a.UNIVERSALADID=this.creative.universalAdIds.map((e=>e.idRegistry.concat(" ",e.value))).join(",")),this.ad&&(this.ad.sequence&&(a.PODSEQUENCE=this.ad.sequence),this.ad.adType&&(a.ADTYPE=this.ad.adType),this.ad.adServingId&&(a.ADSERVINGID=this.ad.adServingId),this.ad.categories&&this.ad.categories.length&&(a.ADCATEGORIES=this.ad.categories.map((e=>e.value)).join(",")),this.ad.blockedAdCategories&&this.ad.blockedAdCategories.length&&(a.BLOCKEDADCATEGORIES=this.ad.blockedAdCategories.map((e=>e.value)).join(","))),dt.track(r,a,n)}convertToTimecode(e){if(!dt.isValidTimeValue(e))return"";const t=1e3*e,i=Math.floor(t/36e5),n=Math.floor(t/6e4%60),r=Math.floor(t/1e3%60),s=Math.floor(t%1e3);return"".concat(dt.addLeadingZeros(i,2),":").concat(dt.addLeadingZeros(n,2),":").concat(dt.addLeadingZeros(r,2),".").concat(dt.addLeadingZeros(s,3))}progressFormatted(){return this.convertToTimecode(this.progress)}}let Yt,Gt,Qt;const jt=()=>Yt,qt=()=>Qt,$t=()=>void 0===Yt?void 0:jt()-qt(),Wt=()=>{Gt=!0};let zt,Xt;const Zt=()=>void 0!==zt,Jt=()=>zt,ei=()=>{zt=void 0,Xt=void 0},ti=()=>Xt,ii=()=>Zt()?Jt()-ti():void 0,ni="loadAd",ri="fetchAd",si="initAd",ai="startAd",oi="bufferAd",di="stopAd",li="skipAd";const ci=()=>{const e=$t(),t=ii();let i="Server";return e>=jt()?i=`Ad Break after ${e} ms`:(t>=Jt()||e>=Jt())&&(i=`Ad Unit after ${t} ms`),`${le.AD_TIMEOUT_REACHED} for ${i}`},ui=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e instanceof Be)return e.updateProperties(t),e;const i=e.message?e.message:"string"==typeof e?e:"Unknown error";return new Be(`${le.INVALID_ERROR}: ${i}`,{type:pe,...t})};let hi=0;const pi={get value(){return hi},increment(){hi++},reset(){hi=0}};let Ei=0;const _i={get value(){return Ei},set value(e){e>=0&&(Ei=e)},reset(){Ei=0}};let mi=0;const Ai={get value(){return mi},increment(){mi++},reset(){mi=0}};let vi=0;const gi={get value(){return vi},set value(e){"number"==typeof e&&(qe.adPods.length||(mi=1),vi=e+mi)},reset(){vi=0}};let Ti=0;const Ri={get value(){return Ti},increment(){Ti++},reset(){Ti=0}};function Si(){pi.reset(),_i.reset(),gi.reset(),Ai.reset(),Ri.reset()}const Ii=408,fi=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const{cancelToken:n,timeout:r}=t,s=performance.now(),a={withCredentials:i,...n&&{cancelToken:n},...r&&{timeout:r}},o=sessionStorage.getItem("X-DM-Inspector");o&&(a.headers={"X-DM-Inspector":o});try{const t=await ze().get(e,a);return{data:t.data,httpStatus:t.status,byteLength:parseInt(t.headers["content-length"],10)||t.data.length||null,duration:Math.round(performance.now()-s)}}catch(n){if(I("PV5_VMAP_REQUEST_NO_RETRY")||!i)throw n.duration=Math.round(performance.now()-s),n.httpStatus=(e=>e.response?.status||("ECONNABORTED"===e.code?Ii:400))(n),function(e){let{errorUrl:t,timeoutErrorCode:i,failedErrorCode:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||!i||!n)return;const r=e===Ii?i:n;ze().get(t.replace("[ERRORCODE]",r))}(n.httpStatus,t),n;return fi(e,t,!1)}};const Di=T("Player","Scheduler","AdsScheduling");let Li=[],ki={},Pi=0;const yi=e=>{if(!e.length)return;const t=e.reduce(((e,t)=>{const{dataEndpointUrl:i,...n}=t;return i&&(e[i]=e[i]||[],e[i].push(n)),e}),{});Object.keys(t).forEach((e=>{(function(e){let{url:t,payload:i}=e,n="";try{n=JSON.stringify(i)}catch(e){throw new Error(`Could not encode payload (${e.message})`)}return ze().post(t,n,{timeout:3e4,headers:{"Content-Type":"text/plain; charset=UTF-8"}})})({url:e,payload:t[e]}).then((e=>{const{status:t,error_code:i,error_message:n}=e.data;"nok"===t&&Di.log(`Invalid save vast endpoint response: ${n} (${i})`)})).catch((e=>{Di.log("Unexpected save vast endpoint error:",e.message)}))}))},Oi={get values(){return Li},setChainEndpoint:(e,t)=>{ki[e]||(ki[e]={dataEndpointUrl:null,vastLogs:[]}),ki[e].dataEndpointUrl=t},addToChain:(e,t)=>{t.xmlData&&(ki[e]||(ki[e]={dataEndpointUrl:null,vastLogs:[]}),ki[e].vastLogs.push((e=>{let{xmlData:t}=e,i=t;return t&&t.documentElement&&(i=(new XMLSerializer).serializeToString(t.documentElement)),{ad_call_type:"save",ad_client_inventory_id:je.value,ad_vast:i,ad_fallback:pi.value}})(t)))},activateChain:e=>{const t=ki[e];t?.dataEndpointUrl&&(t.vastLogs.forEach((e=>{Li.push({...e,dataEndpointUrl:t.dataEndpointUrl})})),delete ki[e])},clean:()=>{window.clearInterval(Pi),Li.length&&yi(Li),Li=[],ki={},Pi=0},enableLogging:()=>{Pi||(Pi=window.setInterval((()=>{Li.length&&(yi(Li),Li=[])}),5e3))}},bi={},Ci=e=>Object.prototype.hasOwnProperty.call(bi,e),Ni=e=>{if(Ci(e))return clearTimeout(bi[e].id),delete bi[e]},Ui={hasName:Ci,start:(e,t,i)=>{if(t<=0)return;Ci(e)&&Ni(e);const n=()=>{Ni(e),i()};bi[e]={id:setTimeout(n,t),delay:t,handler:n}},stop:Ni};let wi={};const Vi=e=>wi[e]?.duration,Mi=e=>{if(wi[e])return wi[e].duration=Date.now()-(e=>wi[e]?.startTime)(e),Vi(e)},Bi=()=>{wi={}},xi=T("Ads","GlobalTimeout"),Fi="GLOBAL_TIMEOUT",Ki=e=>{(e=>{Yt=e,Qt=e,Gt=!1})(e),ei(),Bi(),xi.log(`setAdBreakTimeout: ${e}`)},Hi=e=>{(e=>{zt=e,Xt=e})(e),xi.log(`setAdUnitTimeout: ${e}`)},Yi=()=>{let e=qt();if(Zt()){const t=ti();eObject.assign({globalAdTimeout:jt(),cumulativeTime:$t(),localAdTimeout:Jt(),localCumulativeTime:ii()},e?{[e]:Vi(e)}:null),Qi=()=>qe.position===xe.ev.MIDROLL&&!Gt&&!je.isConsecutiveAdBreak,ji=e=>{let t,i;switch(e){case ni:case ri:case si:case ai:case oi:t=Fi,i=Yi();break;case di:case li:t="STOP_TIMEOUT",i=250}return{timeoutId:t,delay:i}},qi=e=>{const{timeoutId:t}=ji(e),i=Mi(e);t!==Fi||Qi()||(Qt-=i,(e=>{"number"==typeof Xt&&(Xt-=e)})(i)),xi.log(`Done with ${e}: [took ${i}ms]`,t===Fi?`- ${Yi()} ms remaining before reaching AdUnit Timeout`:""),Ui.stop(t)},$i=(e,t)=>{xi.log(`start step ${e}`),wi[e]={startTime:Date.now(),duration:0};const i=[t];if(!Qi()){const t=new Promise(((t,i)=>{!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const{timeoutId:i,delay:n}=ji(e),r=()=>{xi.warn(`Reached timeout for ${i}...`),t(n)};xi.log(`Starting timeout for ${e}: ${n}`),n<=0?r():Ui.start(i,n,r)}(e,(()=>{qi(e),i(function(e){const t=ci();switch(e){case ni:return new Be(t,{type:me,code:2001});case ri:return new Be(t,{type:ve,code:2002});case si:return new Be(t,{type:Te,code:2003});case ai:return new Be(t,{type:Se,code:2004});case oi:return new Be(t,{type:fe,code:2005});case di:return new Be(t,{type:ke,code:2006});case li:return new Be(t,{type:ye,code:2007})}}(e))}))}));i.push(t)}return Promise.race(i).then((t=>(qi(e),t)))},Wi=T("AdStackDM","VAST"),zi="VPAID",Xi="IMA";function Zi(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce(((e,t)=>{const i=t.attributes.source,n=t.attributes.type;if("dailymotion"===i||"dmx"===i||"dailymotion"===n&&"dva"===i)try{const n=JSON.parse(t.value);return{...e,...n,..."dva"===i&&{dva:!0}}}catch(e){Wi.error(`Failed to parse dailymotion extension: ${t.value}`)}return e}),{})}function Ji(e,t){return!(!e?.length||!t?.length)&&e.some((e=>function(e,t){if(!e||!t?.length)return!1;try{const i=new URL(e).hostname.toLowerCase();return t.some((e=>{const t=e.toLowerCase();return i===t||i.endsWith(`.${t}`)}))}catch(e){return!1}}(e,t)))}function en(e,t){let i={integratorType:null,mediaFiles:[],error:void 0};return e?.creatives?.forEach((n=>{let r={};switch(n.type){case"linear":r=function(e){const t={vpaid:[],stream:[],ima:[],others:[]};return e.reduce(((e,t)=>(t.apiFramework===zi&&xe.VS.xq.includes(t.mimeType)?e.vpaid.push(t):t.apiFramework===Xi&&xe.VS.xq.includes(t.mimeType)?e.ima.push(t):xe.VS.Kd.includes(t.mimeType)||xe.VS.Aq.includes(t.mimeType)||xe.VS.Od===t.mimeType?e.stream.push(t):e.others.push(t),e)),t)}(n.mediaFiles);break;case"nonlinear":r=function(e){const t={vpaid:[],stream:[],ima:[],others:[]};return e.variations.reduce(((e,t)=>(t.apiFramework===Xi&&xe.VS.xq.includes(t.type)?e.ima.push(t):xe.VS.Kd.includes(t.type)?(t.fileURL=t.staticResource,t.mimeType=t.type,e.stream.push(t)):e.others.push(t),e)),t)}(n);break;default:return}r.stream.length?i={integratorType:xe.Z4.iF,ad:e,creative:n,mediaFiles:r.stream}:r.ima.length?i={integratorType:tn()?xe.Z4.Vf:xe.Z4.Hs,ad:e,creative:n,mediaFiles:r.ima}:r.vpaid.length?i={integratorType:xe.Z4.cV,ad:e,creative:n,mediaFiles:r.vpaid}:r.others.length&&(t.trackVastError(e.errorURLTemplates,{ERRORCODE:403}),i={integratorType:null,ad:e,creative:n,mediaFiles:r.others})})),i}const tn=()=>!(!C()||!I("PV5_IMA_NATIVE_POC"))&&!!b();function nn(e){return"string"==typeof e?(new DOMParser).parseFromString(e,"text/xml"):{documentElement:e}}var rn=i(4575);const sn=e=>{Object.defineProperty(e,"duration",{get(){return this.mediaFileDuration||this.vastDuration}})},an=e=>{Object.defineProperty(e,"isLinear",{get(){return"linear"===this.creativeType}})},on=e=>{Object.defineProperty(e,"isNonLinear",{get(){return"nonlinear"===this.creativeType}})},dn=e=>{Object.defineProperty(e,"height",{get(){return this.isNonLinear&&this.integrator?this.integrator.getNonLinearHeight():this._height},set(e){this._height=e}})},ln=e=>{Object.defineProperty(e,"fileWeightInKB",{get(){return this.integrator?.getFileWeight()||0}})},cn=e=>{Object.defineProperty(e,"isAudio",{get(){return this.mimeType?.includes("audio")}})},un=e=>{Object.defineProperty(e,"audioAdCompanion",{get(){const e=this.displayedCompanion;return this.isAudio&&this.isAdSlotRunning&&e&&e.resource?.url&&e.variation&&e.vastTracker?{companionImgUrl:e.resource.url,companionClickThruUrl:e.variation.companionClickThroughURLTemplate,companionSlotWidth:e.variation.width,companionSlotHeight:e.variation.height,companionAssetWidth:e.variation.assetWidth,companionAssetHeight:e.variation.assetHeight,companionVastTracker:e.vastTracker}:null}})},hn=function(){const e={adData:{},adCreativeId:null,adEndedReason:null,adError:null,adPodIndex:0,adPodTotalAds:0,adSlot:null,adSlotImpressions:0,adType:null,adid:null,adom:null,width:0,adPaused:!1,bid:null,bidid:null,cid:null,creativeType:"linear",currentTime:0,contentShouldResumePaused:!1,companions:null,displayedCompanion:null,mediaFileDuration:0,vastDuration:0,did:null,sid:null,crid:null,pid:null,siteid:null,integrator:null,icons:[],integratorName:null,inventoryId:null,hasIconsCollision:null,hasStarted:!1,hasLoaded:!1,hasSimid:!1,hasOmid:!1,isAdPod:!1,isFallback:!1,isNonLinearDisplayRunning:!1,isAdSlotRunning:!1,isSkippable:!1,fallbackUrl:null,fallbackMethod:null,fileWeightInKB:0,adVerifications:null,vastTracker:null,provider:null,buyerType:null,adSystem:null,adTitle:null,mimeType:null,vastVersion:null,skipOffset:null,skipType:null,skippableRemainingTime:0,clientFallbackIndex:0,gppString:null,gppSectionId:null,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}};var t;return sn(e),an(e),on(e),dn(e),ln(e),cn(e),un(e),t=e,Object.defineProperty(t,"clientInventoryId",{get:()=>je.value}),(e=>{Object.defineProperty(e,"clientFallbackIndex",{get:()=>pi.value})})(e),e};ae.addEventListener(oe.AD_STARTED,(e=>{pn.hasStarted=!0,pn.vastDuration=e.vastDuration})),ae.addEventListener(oe.AD_LOADED,(e=>{const t=Qn(e.adVerifications);pn.integratorName=e.integrator,pn.inventoryId=e.inventoryId,pn.adCreativeId=e.adCreativeId,pn.vastTracker=e.vastTracker,pn.adVerifications=e.adVerifications,pn.adEndedReason=null,pn.adError=null,pn.bid=e.bid,pn.adid=e.adid,pn.adom=e.adom,pn.did=e.did,pn.cid=e.cid,pn.sid=e.sid,pn.crid=e.crid,pn.pid=e.pid,pn.siteid=e.siteid,pn.adType=e.adType,pn.bidid=e.bidid,pn.hasSimid=e.hasSimid,pn.hasOmid=t,pn.isAdPod=e.isAdPod,pn.adPodIndex=e.adPodIndex,pn.adPodTotalAds=e.adPodTotalAds,pn.mediaFileDuration=e.mediaFileDuration,pn.height=e.height,pn.width=e.width,pn.provider=e.provider,pn.buyerType=e.buyerType,pn.adSystem=e.adSystem,pn.adTitle=e.adTitle,pn.mimeType=e.mimeType,pn.vastVersion=e.vastVersion,pn.skipType=e.skipType,pn.skipOffset=e.skipOffset,pn.creativeType=e.creativeType,pn.hasLoaded=!0,pn.gppString=e.gppString,pn.gppSectionId=e.gppSectionId})),ae.addEventListener(oe.AD_IMPRESSION,(()=>{pn.adSlotImpressions=pn.adSlotImpressions++})),ae.addEventListener(oe.AD_NON_LINEAR_DISPLAY_STARTED,(()=>{pn.isNonLinearDisplayRunning=!0})),ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,(()=>{pn=hn()})),ae.addEventListener(oe.AD_LINEAR_WILL_START,(()=>{pn.isAdSlotRunning=!0,pn.creativeType="linear"})),ae.addEventListener(oe.AD_STARTED,(e=>{let{__type:t,type:i,timeoutInfo:n,integrator:r,...s}=e;pn.adData=s,pn.hasStarted=!0})),ae.addEventListener(oe.AD_SLOT_INJECTED,(e=>{let{element:t}=e;pn.adSlot=t})),ae.addEventListener(oe.AD_VIDEO_SKIPPABLE_STATE,(e=>{let{adSkippable:t}=e;pn.isSkippable=t})),ae.addEventListener(oe.AD_VIDEO_SKIPPABLE_REMAINING_TIME,(e=>{let{time:t}=e;pn.skippableRemainingTime=t})),[(oe.AD_SKIPPED,oe.AD_STOPPED)].forEach((e=>{ae.addEventListener(e,(()=>{pn=hn({isAdSlotRunning:pn.isAdSlotRunning})}))})),ae.addEventListener(oe.AD_ERROR,(e=>{let{adError:t}=e;pn=hn({adPaused:pn.adPaused,isAdSlotRunning:pn.isAdSlotRunning,inventoryId:pn.inventoryId,adError:t})})),ae.addEventListener(xe.k3.PAUSED,(()=>{pn.adPaused=!0})),ae.addEventListener(xe.k3.PLAYING,(()=>{pn.adPaused=!1})),ae.addEventListener(oe.AD_LINEAR_STOPPED,(e=>{let{reason:t,position:i}=e;"REASON_AD_ERROR"===t&&i===xe.ev.MIDROLL&&(pn.contentShouldResumePaused=pn.adPaused),pn.adEndedReason=t})),ae.addEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,(e=>{let{time:t}=e;pn.isAdSlotRunning&&(pn.currentTime=t)})),ae.addEventListener(oe.PLAYER_VIDEO_DURATION_CHANGE,(e=>{let{duration:t}=e;pn.isAdSlotRunning&&(pn.mediaFileDuration=t)})),ae.addEventListener(oe.AD_COMPANIONS_RECEIVED,(e=>{let{companionAds:t,displayedCompanion:i}=e;pn.companions=t,pn.displayedCompanion=i})),ae.addEventListener(oe.AD_DATA_UPDATED,(e=>{let{adData:t}=e;pn.inventoryId=t.inventoryId,pn.bidid=t.bidid,pn.bid=t.bid,pn.did=t.did,pn.adCreativeId=t.adCreativeId||pn.adCreativeId})),ae.addEventListener(oe.SET_AD_FALLBACK,(e=>{let{fallbackMethod:t,fallbackUrl:i}=e;pn=hn({isAdSlotRunning:pn.isAdSlotRunning,inventoryId:pn.inventoryId,isFallback:!0,fallbackMethod:t,fallbackUrl:i})})),ae.addEventListener(oe.AD_LINEAR_BREAK_ENDED,(()=>{pn.isAdSlotRunning=!1})),ae.addEventListener(oe.AD_BREAK_STARTED,(()=>{pn=hn({isAdSlotRunning:pn.isAdSlotRunning})})),ae.addEventListener(oe.RESET_CURRENT_AD_BREAK,(()=>{pn=hn({contentShouldResumePaused:pn.contentShouldResumePaused})}));let pn=hn(),En=null;const _n=["webapp","website","webtv"],mn=["androidapp","iosapp","windowsapp"],An=["DMv31","androidtv","appletv","firetv","lgtv","orangetv","orangetv31","playstation","roku","samsungtv","samsungv3","sonytv"],vn=()=>(null===En&&(En=F().muted),En),gn=()=>{En=null},Tn=function(){let{config:e=V()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{APPBUNDLE:C()?L():0,BREAKMAXADLENGTH:-1,BREAKMAXDURATION:-1,BREAKMAXADS:-1,BREAKMINADLENGTH:-1,BREAKPOSITION:Dn(),CLICKTYPE:In(),CLIENTUA:"Dailymotion/5 vast-client/6.4.5",CONTENTID:`dailymotion.com ${B("accessId")}`,CONTENTURI:B("streamUrl"),DEVICEUA:window.navigator.userAgent,DOMAIN:ie()||e.getEmbedderHostname(),GDPRCONSENT:window.btoa(er()),GPPSTRING:pn.gppString||-1,GPPSECTIONID:pn.gppSectionId||-1,INVENTORYSTATE:Pn(),LIMITADTRACKING:Rn(),OMIDPARTNER:Fn(),PAGEURL:te(),PLACEMENTTYPE:1,PLAYERCAPABILITIES:yn(),PLAYERSIZE:Sn(),REGULATIONS:Jn()?"gdpr":"",SERVERSIDE:0,TRANSACTIONID:je.value,CREATIVEDURATION:pn.duration||-1,PLAYBACKMETHODS:wn(),STOREURL:-1,STOREID:-1}},Rn=()=>_r()["reader.lmt"]?1:0,Sn=()=>{const{width:e,height:t}=A;return[e,t]},In=()=>{const e=k();return _n.includes(e)?1:mn.includes(e)?2:An.includes(e)?0:-1},fn=(e,t)=>{if(t)return{CLICKPOS:[t.x,t.y]};const i=e.target.getBoundingClientRect();return{CLICKPOS:[e.clientX-i.left,e.clientY-i.top]}},Dn=()=>{const e=qe.position,t=[];return t[xe.ev.PREROLL]=1,t[xe.ev.MIDROLL]=2,t[xe.ev.LIVEADBREAK]=2,t[xe.ev.POSTROLL]=3,t[e]||0},Ln=()=>{if(qe.position===xe.ev.MIDROLL){const e=j().currentTime;return new Date(1e3*e).toISOString().substr(11,12)}return-1},kn=()=>{const e=Ln();return{CONTENTPLAYHEAD:e,MEDIAPLAYHEAD:e}},Pn=()=>{const e=[];if(G().autoplay){const t=vn()?"m":"";e.push(`${t}autoplayed`)}return pn.isSkippable&&e.push("skippable"),e.join(",")},yn=()=>{const e=["skip","autoplay"];return Y("controls")&&(e.push("mute"),x().isSupported&&e.push("fullscreen")),e.join(",")},On=()=>{const e=[xe.nF.LN];return(I("PV5_OMSDK")||xn())&&e.push(xe.nF.IO),I("PV5_SIMID")&&e.push(xe.nF.jY,xe.nF.fn),e},bn=()=>{const e=[];return F().muted&&e.push("muted"),x().isOpened&&e.push("fullscreen"),e.join(",")},Cn=()=>({...Tn(),...kn(),ADCOUNT:-1,APIFRAMEWORKS:On(),CACHEBUSTING:Math.round(1e10*Math.random()).toString(),EXTENSIONS:"AdVerifications",MEDIAMIME:[...xe.VS.Kd,...xe.VS.Aq,...xe.VS.$U],TIMESTAMP:(new Date).toISOString(),VASTVERSIONS:[1,2,3,4,5,6,7,8,11,12,13,14],VERIFICATIONVENDORS:-1}),Nn=()=>({...Tn(),...kn(),ADCOUNT:je.podIndex,PLAYERSTATE:bn()}),Un={UNMUTED_AUTOPLAY:1,MUTED_AUTOPLAY:2,NO_AUTOPLAY:3},wn=()=>{const e=vn();return G().autoplay?e?Un.MUTED_AUTOPLAY:Un.UNMUTED_AUTOPLAY:e?"":Un.NO_AUTOPLAY},Vn=e=>{const t=Cn();return Object.entries(t).forEach((t=>{let[i,n]=t;e=e.replace(`[${i}]`,encodeURIComponent(n).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16)}`)))})),e},Mn=T("Stats","Omsdk"),Bn=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{skippable:!!e.skipOffset,skipOffset:e.skipOffset||0,autoplay:e.isRealAutoplay,position:[xe.ev.PREROLL,xe.ev.POSTROLL].includes(e.position)?e.position:xe.ev.MIDROLL}},xn=()=>C()&&I("PV5_OMSDK_NATIVE")&&(!!$()?.omsdk||null!==m?.getOmsdk()),Fn=()=>{const e=m?.getOmPartner(),t=m?.getOmVersion();if(xn()){if(null!==e&&null!==t)return`${e}/${t}`;const i=$();return`${i.ompartner}/${i.omversion}`}return I("PV5_OMSDK")&&(O().isDesktop()||O().isChromeMobile()||O().isSafariMobile())?`${rn.cv}/${rn.Y2}`:""},Kn=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;const[i,n]=Hn(e);return n.length&&n.forEach((e=>Yn(t,e))),Gn(i),i},Hn=e=>{const t=[];return[e.filter((e=>{try{return new URL(e.resource),!0}catch{return t.push(e),!1}})),t]},Yn=(e,t)=>{Mn.log(`Triggered verificationNotExecuted for vendor ${t.vendor} with reason ${rn.QF.LOADING_RESOURCE}`),e.verificationNotExecuted(t.vendor,{...Nn(),REASON:rn.QF.LOADING_RESOURCE}),ae.dispatchEvent(oe.AD_LOG,{...xe.r0.OMID_VERIFICATION_NOT_EXECUTED,name:t.vendor})},Gn=e=>{e.filter((e=>"integralads.com-omid"===e.vendor)).forEach((e=>{const t=pn.isAudio?"audio":"video",i=encodeURIComponent(pn.adCreativeId?.substring(0,50)||"");e.resource=e.resource.replace("[CUSTOM4]",t),e.resource=e.resource.replace("[PLACEMENTID]",i)}))},Qn=e=>0!==e.length&&e.some((e=>{const t="integralads.com-omid"===e.vendor&&e.resource.includes("custom=leo"),i=e.vendor.includes("moat.com-omsdkdailymotion");return!t&&!i}));var jn=i(1638);const qn=1,$n=2,Wn=3,zn=e=>e?{ct:e}:{},Xn=e=>e?{td:encodeURI(e)}:{},Zn=()=>{const e=te();return e?{eb:encodeURI(e)}:{}},Jn=()=>J()?"1":"0",er=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:f().getTcfConsentString())||""},tr=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:f().TCF2HasConsentForGoogle())?"opt-in":"opt-out"},ir=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:f().isEnabledForTcf())?"1":"0"},nr=()=>({reader_gdpr_flag:Jn(),reader_gdpr_consent:er(),gdpr_binary_consent:tr(),gdpr_comes_from_infopack:ir()}),rr=()=>{const e=window.infopack.getGppConsentStringFromPublisher(),t=window.infopack.getGppConsentStringFromPlayer(),i=window.infopack.getGppApplicableSectionsFromPublisher(),n=window.infopack.getGppApplicableSectionsFromPlayer(),r={};return e&&(r.gpp_pb=e),t&&(r.gpp_pl=t),i?.length&&i[0]>=1&&(r.gpp_pbs=i),n?.length&&n[0]>=1&&(r.gpp_pls=n),r},sr=()=>{const e=m?.getUID();return e?B("isCreatedForKids")||J()&&!f().TCF2HasConsentForDailymotion()?{}:{uid_dm:e}:{}},ar=(e,t)=>{if(ee("enableMute")||"MuteForced"===t.reason)return-1;if(e){if(e?.muted)return-1;if(0===e?.volume)return 0;if(e?.volume)return Math.round(10*e.volume)}return 10},or=(e,t)=>{const i=0===j().playedVideosCounter;if(R()&&!qe.position&&i){const i=ar(e,t);return null===i?{}:{vl:i}}if(!e)return{};return{vl:e.muted?-1:Math.round(10*e.volume)}},dr=()=>({ciid:je.value,cidx:pi.value,sidx:_i.value}),lr=async()=>{if(!document?.browsingTopics||!document.featurePolicy?.allowsFeature("browsing-topics"))return{};try{const e=(e=>e?.length?e.map((e=>{const{topic:t,taxonomyVersion:i,modelVersion:n}=e;if(t&&i&&n)return[t,parseInt(i),parseInt(n)]})).filter((e=>e)):[])(await document.browsingTopics());return e.length?{gt:e}:{}}catch(e){return{}}},cr=async e=>{if(qe.position||!R()||j().playedVideosCounter>=1)return{rap:e?1:0};if("off"===Y("autostart"))return{rap:0};let t=!1,i=null;try{i=await(n={from:"ad"},m?.getTryAutoplay(n)),t=!0}catch(e){t=!1}var n;return{rap:t?1:0,reason:t?i:null}},ur=()=>({vidIdx:j().playedVideosCounter}),hr=()=>{const e=Fn();return e?{omp:e}:{}},pr=async()=>{const e=await(async()=>{if("cookieDeprecationLabel"in navigator)try{return await navigator.cookieDeprecationLabel.getValue()}catch(e){return}})();return e?{cdep:e}:{}},Er=()=>({omn:xn()?1:0}),_r=()=>{const e=m?.getDeviceId(),t=m?.getAtts(),i=m?.isTrackingAllowed(),n=m?.getLimitAdTracking();return C()?{ads_device_id:e,"reader.advertising.id":e,"reader.atts":t,"sdk.tracking.allowed":i,"reader.lmt":n}:{}},mr=()=>{const e=$();return Nd.isLoaded()||e?.ima||b()?{imal:1}:{imal:-1}},Ar=()=>{const e=y(),t={},i=m?.getCustomConfigKeysForMetadata();return Object.keys(e).forEach((n=>{if(!S()&&i.includes(n))return;const r=n[0].toUpperCase()+n.slice(1);t[`cc${r}`]=e[n]})),ae.dispatchEvent(oe.PLAYER_API_CUST_CONFIG_CONSUMED),t},vr=()=>{const e=L();return e?{cap:e}:{}},gr=()=>{const e=m?.getPlayerTrafficSegment();return e?{rts:e}:{}},Tr=()=>{const e=ne().reader_id;return e?{rid:e}:{}},Rr=()=>{const e=m?.getPlayerV1st()?1:0;return e?{rhv:e}:{}},Sr=()=>{const e=ne().envFrontend;return e?{cen:e}:{}},Ir=()=>{if(!I("PV5_DYNAMIC_AD_PRESSURE_CC")||!U())return{};const e=M(),{action:t}=e.getEventBusPayload();return{...t?.gesture&&{ccUserGesture:t?.gesture}}},fr=()=>{const e=ne().publisher_xid;return e?{cpi:e}:{}},Dr=()=>{const e=ne().publisher_type;return e?{cpt:e}:{}},Lr=()=>{const e=m?.getEffectiveLocaleShort();return e?{rla:e}:{}},kr=()=>{const e=m?.getPlayerPlaylistId()||V().get()?.suggestedContent?.source?.xid;return e?{cpl:e}:{}},Pr=()=>{const e=ee("id")||Y("syndication");return e?{cpr:e}:{}},yr=()=>{const e=m?.getPlayerViewId();return e?{cse:e}:{}},Or=()=>{const e=(t="dmaid",m?.getPlayerCookie(t));var t;return e?{rdm:e}:{}},br=(e,t)=>{if(!S()&&!I("PV5_TEMP_PBM_UPDATED"))return{};let i=-1===ar(e,t);return t.rap?{pbm:i?$n:qn}:i?{}:{pbm:Wn}},Cr=(e,t)=>{if(!I("PV5_TEMP_PBM_UPDATED"))return{};const i=F()?.muted;return qe.position===jn.e.PREROLL&&0===qe.currentAdBreakIndex?br(e,t):{pbm:i?$n:qn}},Nr=()=>R()?{pos:1}:I("PV5_TMP_ORTB_POS")&&x().isOpened?{pos:7}:{pos:m?.isPesPipIsRunning()||m?.isPlayerInViewport()?1:3},Ur=()=>{const e=m?.getPlayerDisplayMode();return e?{pdm:e}:{}},wr=()=>{const e=m?.getEID();if(!e)return{};const t=Object.fromEntries(Object.entries(e).filter((e=>{let[t,i]=e;return null!=i})));return{eid:JSON.stringify(t)}},Vr=()=>U()&&I("PV5_ADPODS_ONSITE")||!U()&&I("PV5_ADPODS")?{aps:1}:{},Mr=()=>I("PV5_CROSS_POD_RERANKING")?{csr:1}:{};let Br=window.DMP_INITIAL_VIDEO_ID,xr=window.DMP_INITIAL_PLAYLIST_ID;const Fr=(e,t)=>{t&&(xr=t),e?Br=e:window.DMP_INITIAL_VIDEO_ID&&(Br=window.DMP_INITIAL_VIDEO_ID);const i=xr&&!Br?`playlist/${xr}`:`video/${Br}`;return{stage:`https://leo-portal-staging.dailymotion.com/cdn/manifest/${i}.m3u8`,prod:`https://dmxleo.dailymotion.com/cdn/manifest/${i}.m3u8`}},Kr=(e,t)=>{const i=Fr(e,t),n={stage:`${i.stage}?af=[APIFRAMEWORKS]&vv=[VASTVERSIONS]&mm=[MEDIAMIME]`,prod:`${i.prod}?af=[APIFRAMEWORKS]&vv=[VASTVERSIONS]&mm=[MEDIAMIME]`},r={stage:`${i.stage}?error=[ERRORCODE]`,prod:`${i.prod}?error=[ERRORCODE]`},s="prod",a=new URL(document.location.href).searchParams.get("dmDevVmapUrl");return{adUrl:a||n[s],errorUrl:r[s]}};function Hr(e,t){const i=new URL(e);return Object.entries(t).filter((e=>{let[,t]=e;return null!=t})).reduce(((e,t)=>{let[n,r]=t;return i.searchParams.append(n,r)}),i),i.toString()}function Yr(e){try{const t=new URL(e),i=S()?Kr().adUrl:B("adUrl");return new URL(i).host===t.host}catch{return!1}}function Gr(e,t){return{supported:()=>!0,async get(e){if(Me.reset(),"https:"===window.location.protocol&&0===e.indexOf("http://"))return{error:new Error(le.BAD_PROTOCOL)};let i=le.VAST_WRAPPER_REQUEST_FAILED,n=e;const r=t.cancelToken||null;if(Yr(e)){const r=await pr(),s=await lr(),a=await cr(t.isRealAutoplay);n=Hr(e,{...or(t.volume),...dr(),rap:a.rap,...ur(),...hr(),...Er(),..._r(),...Ar(),...r,...s,...Nr(),...Ur(),...Vr(),...Mr(),...Cr(t.volume,a)}),i=le.AD_DIRECTOR_REQUEST_FAILED}return fi(n,{cancelToken:r}).then((e=>{let{data:t,httpStatus:i,byteLength:n}=e;Me.value=i;const r=nn(t);return[null,r,{byteLength:n,statusCode:i,xmlData:r}]})).catch((e=>{Me.value=e.httpStatus;return[new Error(i),null,{statusCode:e.httpStatus}]})).then((e=>{let[t,i,n]=e;return{error:t,xml:i,details:n}}))}}}const Qr=T("AdStackDM","VAST","SkipHandler");class jr{constructor(e,t,i){this._publish=t.bind(i),this._vastTracker=e,this._skippableState=e.skippable,this._skippableRemainingTime=e.skipDelay,this._smartSkipUsed=!1,this._smartSkipStart=0,this._smartSkipEnd=0,this._hasSmartSkipStarted=!1}initSkipCountdown(e){this._skippableRemainingTime>e-1||this._vastTracker.on("skip-countdown",this._onSkipCountdown.bind(this))}unbindSkipCountdown(){this._vastTracker.off("skip-countdown",this._onSkipCountdown.bind(this))}getSkippableState(){return this._skippableState}getSkippableRemainingTime(){return this._skippableRemainingTime}setSkipToNow(e){if(this._isSmartSkipEnabled()&&this._hasSmartSkipStarted){this._smartSkipEnd=performance.now();const t=this._smartSkipEnd-this._smartSkipStart;Qr.log("Smart skip ended. Took:",t,"ms"),t>=5e3?(Qr.log("Smart skip enabled"),this._vastTracker.setSkipDelay(e),this._onSkipCountdown(0),this._smartSkipUsed=!0):(Qr.log("Smart skip disabled"),this._smartSkipStart=0,this._smartSkipEnd=0,this._hasSmartSkipStarted=!1)}}initSmartSkip(){this._isSmartSkipEnabled()&&(this._smartSkipStart=performance.now(),Qr.log("Smart skip started"),this._hasSmartSkipStarted=!0)}getSkipLogs(e){return{skipDisplayed:Math.round(1e3*this._vastTracker.skipDelay),skipClicked:e?Math.round(1e3*e):null,isSmartSkip:this._smartSkipUsed}}isSkipEnabled(){return this._vastTracker.skipDelay>0}_isSmartSkipEnabled(){return I("PV5_ENABLE_SMART_SKIP")&&this.isSkipEnabled()&&!this._skippableState}_onSkipCountdown(e){this._skippableRemainingTime!==e&&(this._skippableRemainingTime=e,this._publish(xe.k3.SKIPPABLE_REMAINING_TIME_CHANGE)),this._skippableState!==this._vastTracker.skippable&&(this._skippableState=this._vastTracker.skippable,this._publish(xe.k3.SKIPPABLE_STATE_CHANGE))}}let qr={};const $r=()=>{const{byteLength:e,duration:t,sent:i}=qr;return!i&&e&&t?(qr.sent=!0,{byteLength:e,requestDuration:t}):{}},Wr=T("Mediafile","IntegratorProxy");class zr extends se{constructor(){super(),pn.integrator=null,this._integratorType=null,this._defaultEventBindings={}}_bindDefaultListeners(){var e=this;let{include:t=[],exclude:i=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(const r in xe.k3){const s=xe.k3[r];if(this._shouldBindEvent(s,t,i,n)){Wr.log(`Binding default integrator handler for ${s}`);const t=function(){Wr.log(`Re-publishing ${s}`);for(var t=arguments.length,i=new Array(t),n=0;n{Zr=e},ts=e=>{Jr=e?{...Jr,...e}:{ad_type:qe.position,ad_provider:pn.provider,ad_buyer_type:pn.buyerType,ad_system:pn.adSystem,ad_title:pn.adTitle,ad_inventory_id:pn.inventoryId,ad_integrator:pn.integratorName,ad_mediafile_mimetype:pn.mimeType,ad_ima_loaded:Nd.isLoaded(),ad_adscheduleid:qe.current?.extension?.asid||null,ad_is_a_retake:qe.current?.isARetake||null,...pn.integratorName===xe.Z4.iF&&{ad_mediafile_height:pn.height,ad_mediafile_width:pn.width},...pn.vastVersion&&{ad_vast_version:pn.vastVersion},...null!==pn.bid&&{ad_bid:pn.bid},...null!==pn.sid&&{ad_sid:pn.sid},...null!==pn.adom&&{ad_adom:pn.adom},...null!==pn.cid&&{ad_cid:pn.cid},...null!==pn.adid&&{ad_adid:pn.adid},...null!==pn.crid&&{ad_crid:pn.crid},...null!==pn.did&&{ad_did:pn.did},...null!==pn.bidid&&{ad_bidid:pn.bidid},...null!==pn.pid&&{ad_pid:pn.pid},...pn.isLinear&&null!==pn.vastDuration&&{ad_duration:pn.vastDuration},...pn.isNonLinear&&{is_nonlinear:!0},...null!==pn.hasSimid&&{has_simid:pn.hasSimid},...null!==pn.hasOmid&&{has_omid:pn.hasOmid}}};let is=0,ns=0,rs=0,ss=0;const as=()=>is=Date.now(),os=()=>rs=Date.now(),ds=()=>ns=Date.now(),ls=()=>ss=Date.now(),cs=e=>{let{tableName:t,customData:i={}}=e;const n=M(),r=n.createEventBusEvent({name:`advertising.${t}`,data:{...n.getEventBusPayload(),...(Zr||ts(),Jr),ad_client_inventory_id:je.value,ad_client_idx:pi.value,ad_server_idx:_i.value,ad_pod_index:je.podIndex,ad_buffet_index:Ai.value,ad_buffet_total:gi.value,ad_vast_index:Ri.value,...i}});n.sendEventToEventBus(r,{priority:"low"})},us=e=>(t,i)=>{const n=()=>{e.forEach((e=>{ae.removeEventListener(e,t)})),i?.()};ae.addEventListener(oe.AD_LINEAR_BREAK_STARTED,(()=>{e.forEach((e=>{ae.addEventListener(e,t)}))})),ae.addEventListener(oe.AD_LINEAR_BREAK_ENDED,n),ae.addEventListener(oe.PLAYER_LOAD_VIDEO,n)};let hs=!1;const ps=e=>{const{endedReason:t,skipDisplayed:i,skipClicked:n}=e;cs({tableName:"adEnded",customData:{ad_paused:hs,ad_displayed_time:ss-ns,ad_ended_reason:t,ad_skip_offset:pn.skipOffset?1e3*pn.skipOffset:null,...(0===i||i)&&{ad_skip_displayed:i},...(0===n||n)&&{ad_skip_clicked:n},...pn.skipType&&{ad_skip_type:pn.skipType}}})},Es=e=>{e.reason&&"nonlinear"===e.creativeType&&cs({tableName:"adEnded",customData:{ad_ended_reason:e.reason}})},_s=()=>{const e=us([oe.AD_VIDEO_COMPLETE]),t=us([oe.AD_STOPPED]),i=us([oe.PLAYER_VIDEO_PAUSE]);e(ps),t(Es),i((()=>hs=!0),(()=>hs=!1))};let ms=null,As=null,vs=!1,gs=!0,Ts=null;const Rs={get value(){return gs?null:As||Math.floor(performance.now()-ms)},start(){gs||vs||(ms=performance.now(),vs=!0,As=null)},finish:()=>!(gs||!vs)&&(As=Math.floor(performance.now()-ms),vs=!1,!0),reset(){ms=null,As=null,vs=!1,gs=!0},disable(){gs=!0},enable(){gs=!1}},Ss={get value(){return Math.floor(performance.now()-Ts)},start(){Ts=performance.now()}},Is=function(){let{adError:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{message:t,type:i,code:n,httpStatus:r,timeoutInfo:s,adSystem:a,adTitle:o,adURL:d,inventoryId:l,provider:c,buyerType:u,integrator:h,bid:p,sid:E,adom:_,cid:m,adid:A,crid:v,did:g,bidid:T,pid:R,lastVastUrl:S,vastVersion:I,vpaidRuntimeError:f}=e,D=n??null,L="string"==typeof t?t:t?.message;if(qe.isCrossPodReranking&&L===le.FAILED_AD_SEQUENCE)return;const k={...a&&{ad_system:a},...o&&{ad_title:o},...l&&{ad_inventory_id:l},...h&&{ad_integrator:h},...c&&{ad_provider:c},...u&&{ad_buyer_type:u},...I&&{ad_vast_version:I},...null!=p&&{ad_bid:p},...null!=E&&{ad_sid:E},...null!=_&&{ad_adom:_},...null!=m&&{ad_cid:m},...null!=A&&{ad_adid:A},...null!=v&&{ad_crid:v},...null!=g&&{ad_did:g},...null!=T&&{ad_bidid:T},...null!=R&&{ad_pid:R}};es(!0),ts(k),cs({tableName:"adError",customData:{error_type:i,message:L,ad_cumulative_time:Ss.value,...d&&{ad_url:d},...n&&{code:n},...S&&{last_vast_url:S},...s?.globalAdTimeout&&{ad_global_timeout_time:s.globalAdTimeout},...null!==D&&{ad_vast_error_code:D},...null!==f&&{ad_vpaid_runtime_error:f},...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value},...null!==r&&{ad_status_code:1e3+r}}})},fs=()=>{ae.addEventListener(oe.AD_STACK_ERROR,Is);us([oe.AD_ERROR,oe.AD_POD_ERROR])(Is)},Ds=()=>{cs({tableName:"adImpression",customData:{ad_impression_time:rs-is,ad_cumulative_time:Ss.value,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value},...null!==pn.siteid&&{ad_siteid:pn.siteid},...null!==pn.hasIconsCollision&&{has_icons_collision:pn.hasIconsCollision},file_weight_in_kB:pn.fileWeightInKB}})},Ls=()=>{us([oe.AD_IMPRESSION])(Ds)},ks=e=>{cs({tableName:"adLoaded",customData:{ad_loaded_time:e.timeoutInfo.initAd,ad_cumulative_time:Ss.value,ad_global_timeout_time:e.timeoutInfo.globalAdTimeout,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value}}})},Ps=()=>{us([oe.AD_LOADED])(ks)},ys=[xe.r0.AD_RESOLVED_ERROR.id,xe.r0.AD_RESOLVED_OK.id,xe.r0.CONSECUTIVE_EXCLUSION.id,xe.r0.ELEMENT_SHIELD.id,xe.r0.IAS_LOADED.id,xe.r0.IMA_RECOVERABLE_AD_ERROR.id,xe.r0.OMID_NEEDED.id,xe.r0.OMID_SCRIPT_URL_LOADED.id,xe.r0.OMID_SESSION_OBSERVER_VENDOR.id,xe.r0.OMID_VERIFICATION_NOT_EXECUTED.id,xe.r0.PERMANENT_EXCLUSION.id,xe.r0.SIMID_REQUEST_CHANGE_AD_DURATION.id,xe.r0.SIMID_REQUEST_EXIT_FULLSCREEN.id,xe.r0.SIMID_REQUEST_FULLSCREEN.id,xe.r0.TEMPORARY_EXCLUSION.id,xe.r0.TOPICS_API.id,xe.r0.VAST_URI_MIXED_CONTENT.id,xe.r0.VPAID_EARLY_START_AD_EVENT.id,xe.r0.VPAID_SAFE_OBJECT_WRAP_ERROR.id,xe.r0.VPAID_VERSION_SUPPORT.id,xe.r0.AD_READY_TO_FETCH_TIMEOUT.id,xe.r0.VMAP_RECEIVED_DURATION.id];let Os=!1;const bs=e=>{ys.includes(e.id)&&cs({tableName:"adLog",customData:{ad_log_id:e.id,ad_log_action:e.action,ad_log_name:e.name,ad_log_value:null==e.value?e.value:String(e.value),ad_log_step:e.step,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value}}})},Cs=()=>{Os||(Rd(bs,xe.k3.LOG),Os=!0)},Ns=()=>{Os&&(Sd(bs,xe.k3.LOG),Os=!1)},Us=()=>{ae.addEventListener(oe.AD_LOG,bs);us([oe.AD_SDK_READY])(Cs,Ns)},ws=e=>{Ss.start(),cs({tableName:"adSdkReady",customData:{ad_sdk_ready_time:e.timeoutInfo.loadAd,ad_cumulative_time:Ss.value,ad_global_timeout_time:e.timeoutInfo.globalAdTimeout,ad_fallback_method:e.fallbackMethod,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value}}})},Vs=()=>{us([oe.AD_SDK_READY])(ws)},Ms=e=>{cs({tableName:"adStarted",customData:{ad_started_time:e.timeoutInfo.startAd,ad_cumulative_time:Ss.value,ad_global_timeout_time:e.timeoutInfo.globalAdTimeout,ad_skip_offset:pn.skipOffset?1e3*pn.skipOffset:null,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value}}})},Bs=()=>{us([oe.AD_LINEAR_STARTED])(Ms)},xs=1,Fs=2,Ks=3,Hs=4,Ys=()=>{const e=w()?128:180,t=w()?128:240;if(pn.skipOffset)return pn.duration&&pn.skipOffset>pn.duration?xs:A.height{const e=Ys();cs({tableName:"adVideoStarted",customData:{ad_cumulative_time:Ss.value,...null!==Rs.value&&{ad_time_from_first_fetch:Rs.value},...e&&{ad_skip_ignored:e}}})},Qs=()=>{us([oe.AD_VIDEO_START])(Gs)};let js=!1;const qs=()=>{cs({tableName:"userClose"})},$s=()=>{js||(Rd(qs,xe.k3.USER_CLOSE),js=!0)},Ws=()=>{js&&(Sd(qs,xe.k3.USER_CLOSE),js=!1)},zs=()=>{us([oe.AD_SDK_READY])($s,Ws)},Xs=[s,a,o,d,l,c,u,h,p],Zs=()=>{is=0,ns=0,rs=0,ss=0,Jr={},es(!1)},Js=()=>{ae.addEventListener(oe.AD_STARTED,as),ae.addEventListener(oe.AD_IMPRESSION,os),ae.addEventListener(oe.AD_VIDEO_START,ds),ae.addEventListener(oe.AD_VIDEO_COMPLETE,ls),Xs.forEach((e=>e.init())),ae.addEventListener(oe.PLAYER_LOAD_VIDEO,Zs),ae.addEventListener(oe.AD_LINEAR_BREAK_ENDED,Zs),ae.addEventListener(oe.AD_SDK_READY,Zs)},ea="IMA",ta="IMA NATIVE",ia="VAST",na="VMAP",ra="VPAID",sa="SEND",aa="INIT",oa="RECEIVE",da="ERROR",la="TIMEOUT",ca="VMAP",ua=e=>e.component===na?{}:{ad_bid_id:pn.bidid,ad_bidder_id:pn.bid,ad_buffet_index:Ai.value,ad_buffet_total:gi.value,ad_client_index:pi.value,ad_creative_id:pn.adCreativeId,ad_cumulative_time:Ss.value,ad_deal_id:pn.did,ad_inventory_id:pn.inventoryId,ad_time_before_timeout:Yi(),ad_time_from_first_fetch:Rs.value,ad_timeout_value_origin:Zt()&&qt()>=ti()?"ADUNIT":"ADBREAK",ad_vast_index:Ri.value,ad_wrapper_index:e.wrapperDepth},ha=e=>{const t=M();let i=null;if(e.url)try{i=new URL(e.url).hostname}catch{}const n=t.createEventBusEvent({name:"advertising.adAction",data:{ad_action:e.action,ad_call_latency:e.callLatency,ad_client_inventory_id:je.value,ad_component:e.component,ad_response_type:e.responseType,ad_status_code:e.statusCode,ad_url_domain:i,...ua(e)}});t.sendEventToEventBus(n,{priority:"low",update:!1})};let pa=null,Ea=null,_a="visible"===document.visibilityState;const ma=[0,.5,1];let Aa=null;function va(){_a="visible"===window.document.visibilityState,Aa=Ea&&_a}const ga=(e,t)=>{const i=e.ad,n={};if(t===xe.Z4.Hs)try{const e=i.getWrapperAdIds(),t=e.length>0?e[e.length-1]:i.getAdId(),r=i.getWrapperCreativeIds(),s=r.length>0?r[r.length-1]:i.getCreativeId();n.adId=t,n.creativeId=s,n.id=i.id,n.vastDuration=i.getDuration(),n.title=i.getTitle(),n.description=i.getDescription(),n.advertiserName=i.getAdvertiserName(),n.uiElements=i.getUiElements(),n.adSystem=i.getAdSystem(),n.adPods=i.getAdPodInfo()}catch(e){}else if(t===xe.Z4.Vf){const e=i?.wrapperAdIds?.length>0?i.wrapperAdIds[i.wrapperAdIds.length-1]:i?.adId,t=i?.wrapperCreativeIds?.length>0?i.wrapperCreativeIds[i.wrapperCreativeIds.length-1]:i?.creativeId;n.adId=e,n.creativeId=t,n.id=i?.id,n.vastDuration=i?.duration,n.title=i?.title,n.description=i?.description,n.advertiserName=i?.advertiserName}else{const t=e.creative,r=t?.universalAdId?`${t.universalAdId.idRegistry}-${t.universalAdId.value}`:i?.adId;n.vastDuration=t?.duration,n.advertiserName=i?.system?.value,n.description=i?.description,n.adId=r,n.title=i?.title,n.creativeId=t?.id,n.id=i?.id}return n},Ta=(e,t)=>{if(!e||!t)return 0;return parseFloat((e*t/8).toFixed(2))},Ra=e=>{let{previousViewMode:t,viewMode:i,vastTracker:n}=e;if(t!==i){const e="fullscreen"===i;if("fullscreen"===t||e){const t=Nn();n.setFullscreen(e,t),n.setExpand(e,t)}}},Sa=(e,t,i)=>{e>=2&&(Aa?t.trackViewableImpression(i,!0):t.trackNotViewableImpression(i,!0))},Ia=T("AdStackDM","VAST","IMAIntegrator"),fa="IMA Playlist timeout";class Da extends se{constructor(){let{mediaFiles:e,vastTracker:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{mediaFiles:null,vastTracker:null};super(),this.boundedListeners={},this.mediaFiles=e,this.vastTracker=t,this._lastAdEndedReason=null}_logAdMediaFileWeightDetails(){const e=this.adsManager.getCurrentAd();if(!e)return;const t=e.getWrapperCreativeIds(),i=t.length>0?t[t.length-1]:e.getCreativeId(),n=pn.inventoryId||null,r=pn.clientInventoryId||null,s=e.getDuration()||0,a=e.getVastMediaBitrate()||0,o={creativeId:i,inventoryId:n,clientInventoryId:r,duration:s,bitrate:a,fileWeightInKB:Ta(s,a)};Ia.log("Calculated File Weight in KB and Related Details:",o)}_bindListeners(){this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.LOADED,this._onLoaded),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.PAUSED,this._onPaused),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.RESUMED,this._onResumed),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.CLICK,this._onClick),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.USER_CLOSE,this._onUserClose),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.DURATION_CHANGE,this._onDurationChange),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.AD_PROGRESS,this._onAdProgress),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.VOLUME_CHANGED,this._onVolumeChange),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.VOLUME_MUTED,this._onVolumeChange),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.STARTED,this._onStarted),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.FIRST_QUARTILE,this._onFirstQuartile),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.MIDPOINT,this._onMidpoint),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.THIRD_QUARTILE,this._onThirdQuartile),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.COMPLETE,this._onVideoCompleted),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.SKIPPED,this._onSkipped),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.CONTENT_RESUME_REQUESTED,this._onContentResumeRequested),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.ALL_ADS_COMPLETED,this._onAllAdsCompleted),this._addBoundedEventListener(Nd.adUnit.AdEvent.Type.LOG,this._onAdLog)}_unbindListeners(){this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.LOADED),this._removeBoundedEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.PAUSED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.RESUMED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.CLICK),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.DURATION_CHANGE),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.VOLUME_CHANGED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.VOLUME_MUTED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.STARTED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.FIRST_QUARTILE),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.MIDPOINT),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.THIRD_QUARTILE),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.COMPLETE),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.USER_CLOSE),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.SKIPPED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.CONTENT_RESUME_REQUESTED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.ALL_ADS_COMPLETED),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.AD_PROGRESS),this._removeBoundedEventListener(Nd.adUnit.AdEvent.Type.LOG)}_addBoundedEventListener(e,t){this.boundedListeners[e]=t.bind(this),this.adsManager.addEventListener(e,this.boundedListeners[e])}_removeBoundedEventListener(e){const t=this.boundedListeners[e];t&&(this.adsManager.removeEventListener(e,t),delete this.boundedListeners[e])}_clean(){Ia.log("Cleaning Slot"),Nd.cleanAdUnit(),this.inventoryIdValue=null,Nd.notifyContentVideoEnd(),this.adsManager&&this.adsManager.destroy()}_startVideoAd(){this.publish(xe.k3.DURATION_CHANGE)}_endVideoAd(e){this._removeBoundedEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR);this._isLastAdFromPod(e)||(je.newAd(),this.startAdPromise=this.startAdsManagerHelper(),this._startNextAd())}initAdsManagerHelper(){return new Promise(((e,t)=>{this.adsManager||t(new Be(le.IMA_ADSMANAGER_UNDEFINED,{type:ge}));const i=()=>{this.adsManager.removeEventListener(Nd.adUnit.AdEvent.Type.CONTENT_PAUSE_REQUESTED,r),this.adsManager.removeEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,s),this.adsManager.removeEventListener(Nd.adUnit.AdErrorEvent.Type.LOADED,n)},n=i=>{this._onAdsManagerLoaded(i,e,t)},r=t=>{i(),e(t)},s=e=>{i();const n=e.getError(),r=new Be(n.getMessage(),{type:ge,code:n.getErrorCode()});this.adsManager.getCurrentAd()?.isLinear()?t(r):(this.vastTracker.error({...Nn(),ERRORCODE:n.getErrorCode()}),this.publish(xe.k3.ERROR,r))};this.adsManager.addEventListener(Nd.adUnit.AdEvent.Type.LOADED,n),this.adsManager.addEventListener(Nd.adUnit.AdEvent.Type.CONTENT_PAUSE_REQUESTED,r),this.adsManager.addEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,s)}))}startAdsManagerHelper(){return new Promise(((e,t)=>{const i=()=>{this.adsManager.removeEventListener(Nd.adUnit.AdEvent.Type.IMPRESSION,n),this.adsManager.removeEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,r)},n=t=>{const n=t.getAd();n.isLinear()||(this._setNonLinearDurationTimeout(n.getMinSuggestedDuration()),this.overlayViewDurationTimestamp=Date.now()),je.newAd(this._getAdPodIndexForAd(n)),this.inventoryIdValue=je.value,i(),e()},r=e=>{i();const n=e.getError();t(new Be(n.getMessage(),{type:Re,code:n.getErrorCode()}))};this.adsManager.addEventListener(Nd.adUnit.AdEvent.Type.IMPRESSION,n),this.adsManager.addEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,r)}))}initAd(e,t,i,n,r,s){if(!Nd.isIMALoaded())throw new Be(le.IMA_SDK_NOT_LOADED,{type:ge});Nd.prepareImaContainerSlot(),this.width=e,this.height=t;let a={};try{a=JSON.parse(r.AdParameters)}catch(e){throw Ia.error("AdParameters failed to parse:",r.AdParameters),new Be(le.FAILED_TO_PARSE_AD_PARAMS,{type:Oe})}const o=new Promise(((e,t)=>{const i=()=>{Nd.adsLoader.removeEventListener(Nd.adUnit.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,n),Nd.adsLoader.removeEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,r)},n=t=>{const n=new Nd.adUnit.AdsRenderingSettings;n.restoreCustomPlaybackStateOnAdBreakComplete=!1,n.loadVideoTimeout=Yi(),n.disableUi=!0,n.useStyledNonLinearAds=!0,this.adsManager=t.getAdsManager(Nd.videoSlot,n),this.initAdPromise=this.initAdsManagerHelper(),this.startAdPromise=this.startAdsManagerHelper(),i(),e()},r=e=>{const n=e.getError();i(),t(new Be(n.getMessage(),{type:ge,code:n.getErrorCode()}))};Nd.adsLoader.addEventListener(Nd.adUnit.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,n),Nd.adsLoader.addEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,r);const s=new Nd.adUnit.AdsRequest;s.vastLoadTimeout=Yi(),this._shouldSetPageUrl()&&(s.pageUrl=te()),s.adTagUrl=a.url,s.linearAdSlotWidth=this.width,s.linearAdSlotHeight=this.height,qe.position===xe.ev.MIDROLL&&(s.nonLinearAdSlotWidth=this.width,s.nonLinearAdSlotHeight=.2*this.height),Ia.log("Requesting ad to IMA with adsRequest",s),s.omidAccessModeRules={},s.omidAccessModeRules[Nd.adUnit.OmidVerificationVendor.OTHER]=Nd.adUnit.OmidAccessMode.FULL,Nd.adsLoader.requestAds(s),ha({action:aa,component:ea})})).then((()=>(Ia.log("adsManager loaded"),this.adsManager.init(this.width,this.height,Nd.adUnit.ViewMode.NORMAL,Nd.videoSlot),this.adsManager.start(),this.initAdPromise)));return $i(si,o).then((e=>{Wt(),this.publish(xe.k3.LOADED);const t=e?.getAd(),i=t?.getContentType();this.mediaFile={height:t?.getVastMediaHeight(),width:t?.getVastMediaWidth(),mimeType:i};return{adType:xe.VS.Aq.includes(i)?"audio":"video",adSlot:Nd.getImaContainerSlot()}})).catch((e=>{throw this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}startAd(){const e=this.adsManager.getCurrentAd();this._logAdMediaFileWeightDetails();const t=F();return t&&this.setAdVolume(t.volume,t.muted),this._bindListeners(),e.isLinear()&&this.publish(xe.k3.DURATION_CHANGE),this._startNextAd()}_startNextAd(){return $i(ai,this._startAd()).catch((e=>{throw this._unbindListeners(),this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}_startAd(){return this.startAdPromise.then((()=>{const e=this.adsManager.getCurrentAd();this._addBoundedEventListener(Nd.adUnit.AdErrorEvent.Type.AD_ERROR,(t=>{const i=t.getError(),n=new Be(i.getMessage(),{code:i.getErrorCode(),type:Re});this.publish(xe.k3.POD_ERROR,n),this._endVideoAd(e)}));const t=this.getAdPodInfo();t.isAdPod&&1===t.adPodIndex&&qe.adPods.length>1&&qe.adPods.splice(qe.adPodIndex,1,...new Array(t.adPodTotalAds)),qe.adPods.length&&1===t.adPodIndex&&qe.adPodIndex>0?qe.adPodIndex++:t.isAdPod&&qe.adPods.length>1?(qe.adPods[qe.adPodIndex]={mainAd:e,adBuffet:[]},t.adPodIndex1?qe.adPods.length:t.adPodTotalAds};this.publish(xe.k3.STARTED,i),this.vastTracker.trackURLs(this.vastTracker.ad.impressionURLTemplates,Nn()),this.publish(xe.k3.IMPRESSION),this._lastMutedState=this.getAdVolume().muted}))}_isLastAdFromPod(e){if(e)return this._getPodTotalAdsForAd(e)===this._getAdPodIndexForAd(e)}_getAdPodIndexForAd(e){if(e)return e.getAdPodInfo().getAdPosition()}_getPodTotalAdsForAd(e){if(e)return e.getAdPodInfo().getTotalAds()}getAdPodInfo(){const e=this.adsManager.getCurrentAd();if(!e)return;const t=this._getAdPodIndexForAd(e),i=this._getPodTotalAdsForAd(e);return{adPodIndex:t,adPodTotalAds:i,isAdPod:i>1}}stopAd(){const e=this.adsManager.getCurrentAd();if(e&&!e.isLinear()){let e=this.overlayViewDurationTimestamp?Date.now()-this.overlayViewDurationTimestamp:0;e=this.vastTracker.convertToTimecode(e/1e3),this.vastTracker.overlayViewDuration(e,Nn())}return this._unbindListeners(),this.adsManager&&this.adsManager.stop(),this._clean(),Promise.resolve()}skipAd(){return this.adsManager.skip(),new Promise((()=>{}))}pauseAd(){this.adsManager.pause()}resumeAd(){this.adsManager.resume()}resizeAd(e,t,i){if(!this.adsManager)return;const n=this.adsManager.getCurrentAd();if(n&&!n.isLinear()&&n.getHeight()>.2*A.height){const e=new Be(le.NON_LINEAR_DIMENSIONS,{type:Le,code:xe.Uk.Bp});this.publish(xe.k3.ERROR,e),this.stopAd()}this.adsManager.resize(e,t,i),Ra({previousViewMode:this._viewMode,viewMode:i,vastTracker:this.vastTracker}),this._viewMode=i}clicked(){this.adsManager.clicked()}getAdRemainingTime(){return this.adsManager.getRemainingTime()}getAdDuration(){const e=this.adsManager.getCurrentAd();return e?.getDuration()||0}getAdVolume(){const e=this.adsManager.getVolume();return{volume:e,muted:0===e}}setAdVolume(e,t){e>=0&&(this.adVolume=e),this.adMuted=t,(this.adMuted||this.adVolume>=0)&&this.adsManager.setVolume(this.adMuted?0:this.adVolume)}getAdSkippableState(){return this.adsManager.getAdSkippableState()}getAdSkippableRemainingTime(){const e=this.adsManager.getCurrentAd();return e.getSkipTimeOffset()-(e.getDuration()-this.adsManager.getRemainingTime())}isSkipEnabled(){return!1}getNonLinearHeight(){const e=this.adsManager?.getCurrentAd();return e?.getHeight()||0}getFileWeight(){const e=this.adsManager.getCurrentAd();if(!e)return;const t=e.getDuration()>0?e.getDuration():0,i=e.getVastMediaBitrate();return Ta(t,i)}_onLoaded(){this.setAdVolume(this.adVolume,this.adMuted)}_onPaused(){this.vastTracker.track("pause",{macros:Nn()}),this.publish(xe.k3.PAUSED),ae.dispatchEvent(oe.AD_PAUSED)}_onResumed(){this.vastTracker.track("resume",{macros:Nn()}),this.publish(xe.k3.PLAYING),ae.dispatchEvent(oe.AD_PLAYING)}_onClick(){const e=Nn();this.vastTracker.click(null,e),this.vastTracker.trackViewableImpression(e,!0),this.publish(xe.k3.CLICK_THRU)}_onDurationChange(){this.publish(xe.k3.DURATION_CHANGE)}_onAdProgress(e){this.publish(xe.k3.REMAINING_TIME_CHANGE);const t=Nn(),i=e?.getAdData?.()?.currentTime;Sa(i,this.vastTracker,t),this.vastTracker.setProgress(i,t)}_onVolumeChange(){const e=this.getAdVolume().muted;e&&!this._lastMutedState&&this.vastTracker.track("mute",{macros:Nn()}),!e&&this._lastMutedState&&this.vastTracker.track("unmute",{macros:Nn()}),this._lastMutedState=e,this.publish(xe.k3.VOLUME_CHANGE)}_onStarted(e){const t=e.getAd();this._lastAdEndedReason=null,I("PV5_IMA_COMPANION_AD")&&this._handleCompanionAds(t),this._isAdSenseDisplayPreroll(t)&&ae.dispatchEvent(oe.AD_NON_LINEAR_DISPLAY_STARTED),this.vastTracker.track("creativeView",{macros:Nn()}),t.isLinear()&&(this.vastTracker.track("start",{macros:Nn(),once:!0}),this._startVideoAd(),this.publish(xe.k3.VIDEO_START))}_onFirstQuartile(){this.vastTracker.track("firstQuartile",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_FIRST_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_FIRST_QUARTILE)}_onMidpoint(){this.vastTracker.track("midpoint",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_MIDPOINT),ae.dispatchEvent(oe.AD_VIDEO_MIDPOINT)}_onThirdQuartile(){this.vastTracker.track("thirdQuartile",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_THIRD_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_THIRD_QUARTILE)}_onSkipped(e){const t=e.getAd();this.vastTracker.track("skip",{macros:Nn()}),this._lastAdEndedReason=xe.Bj.SKIPPED,this.publish(xe.k3.VIDEO_COMPLETE,{endedReason:xe.Bj.SKIPPED}),this._endVideoAd(t)}_onUserClose(){Ia.log("User has closed the non linear");const e=Nn();this.vastTracker.close(e),this.vastTracker.skip(e),this.publish(xe.k3.USER_CLOSE),this.publish(xe.k3.STOPPED,{reason:xe.Bj.CLOSED}),this.stopAd()}_onVideoCompleted(e){const t=e.getAd();this.vastTracker.track("complete",{macros:Nn()}),this.publish(xe.k3.VIDEO_COMPLETE,{endedReason:xe.Bj.COMPLETED}),this._endVideoAd(t)}_onContentResumeRequested(e){const t=e.getAd();Ui.start(fa,500,(()=>{this._isAdSenseDisplayPreroll(t)?this._onAllAdsCompleted():(this._clean(),this.publish(xe.k3.ERROR,new Be(le.IMA_SDK_INCORRECT_TAG,{type:Le})))}))}_onAllAdsCompleted(){qe.adPodIndex>=qe.adPods.length&&qe.adPodIndex>0&&qe.adPodIndex--,Ui.stop(fa),this._clean(),this.publish(xe.k3.STOPPED,{...this._lastAdEndedReason&&{reason:this._lastAdEndedReason}})}_onAdLog(e){const t=e.getAdData();t?.adError&&this.publish(xe.k3.LOG,{...xe.r0.IMA_RECOVERABLE_AD_ERROR,value:t.adError.getMessage()})}_isAdSenseDisplay(e){const t=e.getAdSystem()===xe.z0,i=xe.VS.xU.includes(e.getContentType()),n=e.getDuration()>e.getMinSuggestedDuration();return t&&i&&n}_isAdSenseDisplayPreroll(e){return this._isAdSenseDisplay(e)&&"preroll"===qe.position}_shouldSetPageUrl(){return!C()&&(!(!I("PV5_TEMP_IMA_PAGEURL")||!U())||!(!I("PV5_TEMP_IMA_PAGEURL_OFFSITE")||U()))}_onAdsManagerLoaded(e,t,i){const n=e.getAd();this.vastTracker.load(Nn());const r=this._isAdSenseDisplay(n),s=qe.position===xe.ev.PREROLL,a=qe.position===xe.ev.MIDROLL,o=r&&!s;if(!n.isLinear()&&!a||o)return i(new Be(le.NO_SUPPORTED_CREATIVE,{type:ge}));t(e)}_setNonLinearDurationTimeout(e){const t=this._getNonLinearDuration(1e3*e);setTimeout((()=>{this.inventoryIdValue===je.value&&(this.publish(xe.k3.STOPPED,{reason:xe.Bj.COMPLETED}),this.stopAd())}),t)}_getNonLinearDuration(e){return e<1e4?1e4:e>3e4?3e4:e}_handleCompanionAds(e){const t=Nd.adUnit.CompanionAdSelectionSettings;let i=new t;i.resourceType=t.ResourceType.ALL,i.creativeType=t.CreativeType.ALL,i.sizeCriteria=t.SizeCriteria.IGNORE;let n=e.getCompanionAds(null,null,i);0!==n.length&&(n=[{apiFramework:"IMA",type:"companion",variations:n.map((e=>({adSlotId:e.getAdSlotId(),width:e.getWidth().toString(),height:e.getHeight().toString(),content:e.getContent()})))}],ae.dispatchEvent(oe.AD_COMPANIONS_RECEIVED,{companionAds:n}))}}const La=e=>new Da(e),ka=T("AdStackDM","VAST","ElementShield");class Pa{constructor(){let{element:e,logCallback:t,hasInitProtection:i,initProtectionSuccessCb:n,initProtectionFailCb:r,adPosition:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ka.log("Creating ElementShield for",e),this.element=e,this.adPosition=s,this.eventHandlers={},this.logCallback=t,this.hasInitProtection=i,this.initProtectionCallback=this._getProxyInitProtectionCallback(n,r),this.loggedActions=[],this.storedAttributes={},this.storedChildNodes=[],this.hasInitProtection||this._storeState()}_getProxyInitProtectionCallback(e,t){let i=!1;return n=>{let{action:r,name:s,value:a}=n;return!!i||("setProperty"===r&&("src"===s||"type"===s)||"setAttribute"===r&&("src"===s||"type"===s)||"removeAttribute"===r&&("src"===s||"type"===s)||"appendChild"===r||"insertBefore"===r?(ka.log("initProtectionCallback: WILL_START",r,s,a),e(),i=!0,!0):this.adPosition!==xe.ev.MIDROLL||"load"!==r||i?(ka.log("initProtectionCallback: rejecting",r,s,a),t(`proxy restriction: ${r}(${s}, ${a})`),!1):(ka.log("initProtectionCallback: ignoring",r,s,a),this.log({action:"silencedMethod",name:"load",value:null}),!1))}}start(){this.hasInitProtection&&this._storeState(),this.hasStarted=!0}checkInitProtection(){let{action:e,name:t="",value:i="",defaultHandler:n,isSilent:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.hasStarted)return n();{if(r)return;const s={[xe.ev.POSTROLL]:["load"]};if(!this.hasInitProtection||s[this.adPosition]&&~s[this.adPosition].indexOf(e))return n();if(this.initProtectionCallback({action:e,name:t,value:i}))return n()}}saveEventHandler(e,t){this.eventHandlers[e]=t}log(){let{action:e,name:t="",value:i=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ka.log("shielded",e,t,i);const n=[e,t].join("|");this.loggedActions.indexOf(n)>-1||(this.loggedActions.push(n),this.logCallback({...xe.r0.ELEMENT_SHIELD,action:e,name:t,value:i,step:this.hasStarted?"startAd":"initAd"}))}_storeState(){for(let e=0;e{this.element.appendChild(e)})),this.storedChildNodes=[]}destroy(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{};ka.log("destroy"),this._removeEventHandlers(),!this.hasStarted&&this.hasInitProtection||(e(),this._restore(),t()),this.element=null,this.loggedActions=[]}}const ya={create:e=>new Pa(e)},Oa=T("VAST","AryaProxy"),ba=["autoplay","class","controls","draggable","id","muted","poster","preload","playsinline","webkit-playsinline"],Ca=["id","scrollTop","scrollLeft","outerHTML","draggable","preload","defaultPlaybackRate","autoplay","loop","controls","defaultMuted","poster","className","width","height"],Na=[{name:"hidden"},{name:"innerHTML"},{name:"src"},{name:"type"},{name:"crossOrigin"},{name:"currentTime"},{name:"playbackRate"},{name:"volume",exception:(e,t)=>0===e&&t.muted},{name:"muted"},{name:"nodeValue"}],Ua=["insertBefore","appendChild","replaceChild","play","pause","addTextTrack","load"],wa=["height","width","style"],Va=["addEventListener","setAttribute","removeAttribute","requestFullscreen","webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen"],Ma=(e=>{const t=[e];let i=Object.getPrototypeOf(e);for(;i;)t.push(i),i=Object.getPrototypeOf(i);return t})(HTMLVideoElement.prototype);class Ba{constructor(){let{videoSlot:e,logCallback:t,hasInitProtection:i,initProtectionSuccessCb:n,initProtectionFailCb:r,adPosition:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._videoSlot=e,this._aryaSlot=document.createElement("div"),this._aryaSlot.id="dmp_Arya",this._aryaSlot.style.width=this._aryaSlot.style.height="100%",this._aryaSlot.style.position="absolute",this._aryaSlot.style.pointerEvents="none",this._videoSlot.parentElement.insertBefore(this._aryaSlot,this._videoSlot.nextSibling),this._mockedStyle=document.createElement("div").style,this._elementShield=ya.create({element:e,logCallback:t,hasInitProtection:i,initProtectionSuccessCb:n,initProtectionFailCb:r,adPosition:s}),Ma.forEach((e=>{this.createPropertiesAndMethods(e)}))}createPropertiesAndMethods(e){var t=this;Object.getOwnPropertyNames(e).forEach((i=>{const n=Object.getOwnPropertyDescriptor(e,i);if("constructor"!==i&&n.configurable){if("function"==typeof n.get)if(I("PV5_ENABLE_ARYA_PROXY_STRICT_STYLES")&&"style"===i)n.get=()=>this._customBehaviourForStyle();else{if("classList"===i)return this._customBehaviourForClasslist();n.get=()=>this.proxifyGetter(this._videoSlot,i)}if("function"==typeof n.set)if(Ca.indexOf(i)>-1)n.set=e=>{this._elementShield.log({action:"setProperty",name:i,value:e})};else{const e=Na.filter((e=>e.name===i))[0];n.set=e?t=>{this.initProtectionForSetter(i,t,e.exception)}:e=>{this.proxifySetter(this._videoSlot,i,e)}}"function"==typeof n.value&&(Ua.indexOf(i)>-1?n.value=function(){for(var e=arguments.length,n=new Array(e),r=0;r-1?n.value=function(){for(var e=arguments.length,n=new Array(e),r=0;r2?i-2:0),r=2;r1?n-1:0),s=1;se?e.nodeName.toLowerCase():"")):(t="",i=""),{name:t,value:i}}initProtectionForSetter(e,t,i){const n=this._videoSlot&&this._videoSlot[e]==t,r=this._videoSlot&&i&&i(t,this._videoSlot),s=n||r;this._elementShield.checkInitProtection({action:"setProperty",name:e,defaultHandler:()=>{this._elementShield.log({action:"setProperty",name:e,value:t}),this.proxifySetter(this._videoSlot,e,t)},isSilent:s})}initProtectionForMethod(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n(""!==r&&this._elementShield.log({action:e,name:r,value:s}),this.proxifyMethod(this._videoSlot,e,...i))})}_customBehaviourForStyle(){return this._elementShield.hasStarted?this.proxifyGetter(this._videoSlot,"style"):this._mockedStyle}_customBehaviourForClasslist(){var e=this;const t=["add","remove","toggle","replace"],i=DOMTokenList.prototype;Object.getOwnPropertyNames(i).forEach((n=>{const r=Object.getOwnPropertyDescriptor(i,n);"constructor"!==n&&r.configurable&&("function"==typeof r.get&&(r.get=()=>this._videoSlot?this.proxifyGetter(this._videoSlot.classList,n):null),"function"==typeof r.set&&(r.set=e=>{this._elementShield.log({action:"setProperty",name:"classList",value:e})}),"function"==typeof r.value&&(t.includes(n)?r.value=function(){for(var t=arguments.length,i=new Array(t),r=0;r1?t-1:0),n=1;n-1||wa.indexOf(i[0])>-1&&!this._elementShield.hasStarted?this._elementShield.log({action:e,name:i[0],value:i[1]?i[1]:""}):this.initProtectionForMethod(e,...i);case"addEventListener":if(this._videoSlot)return this._elementShield.saveEventHandler(...i),this._videoSlot.addEventListener(...i);break;case"requestFullscreen":case"webkitRequestFullScreen":case"mozRequestFullScreen":case"msRequestFullscreen":this._elementShield.log({action:"silencedMethod",name:"requestFullscreen",value:e})}}start(){this._elementShield.start()}destroy(){if(this._elementShield&&this._elementShield.destroy((()=>{this._videoSlot.pause()}),(()=>{this._videoSlot.load()})),this._videoSlot&&this._aryaSlot){try{this._videoSlot.parentElement.removeChild(this._aryaSlot)}catch(e){Oa.log("Error while removing Arya slot",e)}this._aryaSlot=null,this._videoSlot=null}}}const xa={create:e=>new Ba(e)},Fa=(e,t,i)=>function(){try{for(var n=arguments.length,r=new Array(n),s=0;st!==e)),this._handlerStack[t].length||(this._handlerStack[t]=null,this.vpaidAdUnit.unsubscribe(this._bindedVPAIDAdUnitHandlers[t],t)))}_onVPAIDAdUnitEvent(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n{e.bind(this)(...i)})))}_jsonStringifyReplacer=(e,t)=>t instanceof HTMLElement?t.id||"":t;_logMethodCallForExternalLogs(e){const t={isMethodCall:!0,isVpaid:!0};for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r{if("object"!=typeof t)e.push(t);else try{e.push(JSON.stringify(t,this._jsonStringifyReplacer))}catch(e){Ka.log(e)}})),t.args=e.join(", ")}Xr(e,t)}_bindListeners(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(this.vpaidAdUnit){Ka.log("Binding VPAID listeners");for(const t in this.eventMapping)-1===e.indexOf(t)&&this._subscribeVPAIDAdUnit(this.eventMapping[t],t,this)}}_unbindListeners(){if(this.vpaidAdUnit){Ka.log("Unbinding VPAID listeners");for(const e in this.eventMapping)this._unsubscribeVPAIDAdUnit(this.eventMapping[e],e);this._skipHandler.unbindSkipCountdown(),clearInterval(this._remainingTimeHandlerID),this._remainingTimeHandlerID=null}}handshakeVersion(e){return this._logMethodCallForExternalLogs("handshakeVersion",e),this._handshakeVersion=this.vpaidAdUnit.handshakeVersion(e),this.publish(xe.k3.LOG,{...xe.r0.VPAID_VERSION_SUPPORT,name:"handshakeVersion",value:this._handshakeVersion}),this._handshakeVersion}initAd(e,t,i,n,r,s){this._logMethodCallForExternalLogs("initAd",e,t,i,n,r,s),this.vpaidAdUnit.initAd(e,t,i,n,r,s)}resizeAd(e,t,i){this._logMethodCallForExternalLogs("resizeAd",e,t,i),this.vpaidAdUnit.resizeAd(e,t,i)}startAd(){this._logMethodCallForExternalLogs("startAd"),this.vpaidAdUnit.startAd()}stopAd(){this._logMethodCallForExternalLogs("stopAd"),this.vpaidAdUnit.stopAd()}pauseAd(){this._logMethodCallForExternalLogs("pauseAd"),this.vpaidAdUnit.pauseAd()}resumeAd(){this._logMethodCallForExternalLogs("resumeAd"),this.vpaidAdUnit.resumeAd()}expandAd(){this._logMethodCallForExternalLogs("expandAd"),this.vpaidAdUnit.expandAd()}collapseAd(){this._logMethodCallForExternalLogs("collapseAd"),this.vpaidAdUnit.collapseAd()}skipAd(){this._logMethodCallForExternalLogs("skipAd"),this.vpaidAdUnit.skipAd()}getAdDuration(){return this.vpaidAdUnit?this.vpaidAdUnit.getAdDuration():-2}getAdExpanded(){return this.vpaidAdUnit.getAdExpanded()}getAdHeight(){return this.vpaidAdUnit.getAdHeight()}getAdLinear(){return this.vpaidAdUnit.getAdLinear()}getAdRemainingTime(){let e=this.vpaidAdUnit.getAdRemainingTime();return-2===this._previousRemainingTime&&e<=0||-2!==this._previousRemainingTime&&this._previousRemainingTime0&&void 0!==arguments[0]?arguments[0]:{};super(),this._hasLoaded=!1,this._hasStarted=!1,this._hasImpressed=!1,this._remainingTimeHandlerID=null,this._adDurationHandlerID=null,this._remainingTimeValue=null,this.vpaidFrame=null,this.videoProxy=null,this.videoWrapper=null,this.slot=null,this.mediaFiles=e,this.vastTracker=t,this._skipHandler=new jr(t,this.publish,this),this._viewMode=null,this._internalVolume=null,this._lastVpaidVolume=null,this._vpaidError=null}_cleanSlot(){this.slot&&(this.slot.parentNode.removeChild(this.slot),this.slot=null)}_createBufferListener(){this.videoSlot&&(this.videoSlot.addEventListener("waiting",this._onVideoTagWaiting),this.videoSlot.addEventListener("playing",this._onVideoTagPlaying))}_removeBufferListener(){this.videoSlot&&(this.videoSlot.removeEventListener("waiting",this._onVideoTagWaiting),this.videoSlot.removeEventListener("playing",this._onVideoTagPlaying))}_cleanIframe(){this.vpaidFrame&&(this.vpaidFrame.parentNode.removeChild(this.vpaidFrame),this.vpaidFrame=null)}_cleanVideoShield(){null!==this.videoProxy&&(this.videoProxy.destroy(),this.videoProxy=null)}_clean(){Ga.log("Cleaning Iframe/VideoShield/Slot"),this._removeBufferListener(),this._cleanSlot(),this._cleanIframe(),this._cleanVideoShield(),clearInterval(this._adDurationHandlerID),clearInterval(this._remainingTimeHandlerID),this._remainingTimeHandlerID=null,this._adDurationHandlerID=null}_validateErrorFormat(e){return"string"!=typeof e?(Ga.warn("Invalid format for VPAID Error :",e),e=le.INVALID_FORMAT_VPAID_ERROR):e=`Error received from VPAID : ${e}`,e}_shouldStopAd(e){return~[ge,Te,Re,Se,Ie,fe].indexOf(e)}_resolveStepOnVPAIDEvents(e,t,i){const n=(e=>{switch(e){case ri:return Ae;case si:return ge;case ai:return Re;case di:return Le;case li:return Pe}})(e);return new Promise(((e,r)=>{const s=()=>{t.forEach((e=>{this._unsubscribeVPAIDAdUnit(a,e)})),this._unsubscribeVPAIDAdUnit(o,xe.k3.ERROR)},a=()=>{s(),e()},o=e=>{s(),r(new Be(this._validateErrorFormat(e),{type:n}))};t.forEach((e=>{this._subscribeVPAIDAdUnit(a,e)})),this._subscribeVPAIDAdUnit(o,xe.L0.pn);try{i(a,o)}catch(e){r(new Be(e.message,{type:n}))}}))}handleTimeout(e,t){return $i(e,t).catch((e=>{const t=ui(e,{vpaidRuntimeError:this._vpaidError});if(this._shouldStopAd(t.type))return this.stopAd({silent:!0}).finally((()=>{throw t}));throw t}))}getVpaidAdUnit(){return this.vpaidFrame.contentWindow.getVPAIDAd()}getMediaFileSrc(){return this.mediaFile.fileURL}async loadVpaidScript(e){this.videoSlot=e,Ga.log("Loading AdUnit"),this.mediaFile=this.mediaFiles[0];const t={id:"vpaid_frame",siblingNode:this.videoSlot,url:this.getMediaFileSrc()};try{this.vpaidFrame=await bd(t),this.vpaidFrame.className="vpaid_frame";const e=this.getVpaidAdUnit();this.vpaidAdUnit=this.silenceVpaidErrors(e),this.handshakeVersion("2.0"),this.slot=this.vpaidFrame.contentWindow.document.createElement("div"),this.slot.style.height="100%",this.vpaidFrame.contentWindow.document.body.appendChild(this.slot)}catch(e){throw Ga.error("Load vpaid ad unit failed: ",e),new Be(le.VPAID_SDK_REQUEST_FAILED,{type:ge})}}createAryaProxy(e,t){const{videoSlot:i,proxyInitProtection:n,position:r}=e;this.videoProxy=xa.create({logCallback:e=>{this.publish(xe.k3.LOG,e)},videoSlot:i,hasInitProtection:n,initProtectionSuccessCb:()=>this.publish(xe.k3.WILL_START),initProtectionFailCb:t,adPosition:r}),e.videoSlot=this.videoProxy._aryaSlot,delete e.proxyInitProtection}initAd(e,t,i,n,r,s){const a=(a,o)=>{s.slot=this.slot,this.createAryaProxy(s,o),this._bindListeners([xe.L0.of]),Ga.log("Initializing AdUnit"),super.initAd(e,t,i,n,r,s),ha({action:aa,component:ra}),this.setAdVolume(s.volume.volume,s.volume.muted)};return this.handleTimeout(si,this.loadVpaidScript(s.videoSlot).then((()=>this._resolveStepOnVPAIDEvents(si,[xe.L0.tE],a)))).then((()=>(this._hasLoaded=!0,this.publish(xe.k3.LOADED),this.vastTracker.load(Nn()),{adSlot:this.vpaidFrame}))).catch((e=>{throw this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}startAd(){return this.handleTimeout(ai,this._resolveStepOnVPAIDEvents(ai,[xe.L0.Hw,xe.L0.nt,xe.L0.Om],(()=>{this.videoProxy&&this.videoProxy.start(),this._createBufferListener(),Ga.log("Starting AdUnit"),super.startAd()}))).then((()=>{this.vastTracker.track("creativeView",{once:!0,macros:Nn()}),this._hasStarted=!0,this.publish(xe.k3.STARTED,ga(this.vastTracker,Ya)),this._handleDurationChange()})).catch((e=>{throw this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}stopAd(){let{silent:e=!1,logs:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._unbindListeners(),this.handleTimeout(di,this._resolveStepOnVPAIDEvents(di,[xe.L0.il],(()=>{Ga.log("Stopping AdUnit"),super.stopAd()}))).catch((()=>{})).then((()=>(this._clean(),e||this.publish(xe.k3.STOPPED),t)))}skipAd(){const e=this.getAdDuration()>0?this._getAdCurrentTime():null,t=this._skipHandler.getSkipLogs(e);if(!this.vpaidAdUnit.skipAd)return this.forceSkipAd(t);if(!this.vpaidAdUnit.getAdSkippableState())return this._skipHandler.isSkipEnabled()&&this.vastTracker.skippable?this.forceSkipAd(t):new Promise((()=>{}));this._unbindListeners();return this.handleTimeout(li,this._resolveStepOnVPAIDEvents(li,[xe.L0.kb],(()=>{Ga.log("Skipping AdUnit"),this.vastTracker.track("skip",{once:!0,macros:Nn()}),super.skipAd()}))).then((()=>{this._clean(),this.publish(xe.k3.SKIPPED)})).catch((e=>{throw this._clean(),this.publish(xe.k3.ERROR,e),e}))}isSkipEnabled(){return Boolean(this._skipHandler.isSkipEnabled()||this.vpaidAdUnit?.getAdSkippableState())}silenceVpaidErrors(e){return((e,t)=>{null==e._wrapped&&(e._wrapped=[]);const i=["constructor","startAd","initAd"];for(const n in e)try{const r=e[n];if(i.includes(n))continue;if(null==e._wrapped[n]&&(e._wrapped[n]=[]),"function"!=typeof r||e._wrapped[n].includes("safe"))continue;e[n]=Fa(r,n,t),e._wrapped[n].push("safe")}catch(e){"function"==typeof t&&t(e,"wrapping",n)}return e})(e,((e,t,i)=>{const n="wrapping"===t?`Vpaid object wrapper: Error while wrapping property ${i}: `:`Silenced vpaid error: Error catched with method ${i}: `;this._vpaidError=e.stack?JSON.stringify(e.stack).slice(0,1e3):e.message,Xr(n,{message:e.message,isVpaid:!0}),Ga.error(n,e),this.publish(xe.k3.LOG,{...xe.r0.VPAID_SAFE_OBJECT_WRAP_ERROR,name:t,value:n+this._vpaidError})}))}forceSkipAd(e){return this.vastTracker.track("skip",{once:!0,macros:Nn()}),this.stopAd({logs:e})}getAdVolume(){return{volume:this._internalVolume,muted:this.videoSlot.muted}}setAdVolume(e,t){this._internalVolume=e??this._internalVolume,this._setMuted(t),super.setAdVolume(t?0:this._internalVolume)}_setMuted(e){this.videoSlot&&this.videoSlot.muted!==e&&(this.videoSlot.muted=e)}resizeAd(e,t,i){this.vpaidFrame.style.height=`${t}px`,this.vpaidFrame.style.width=`${e}px`,super.resizeAd(e,t,i),Ra({previousViewMode:this._viewMode,viewMode:i,vastTracker:this.vastTracker}),this._viewMode=i}getAdSkippableState(){return this._skipHandler.isSkipEnabled()?this._skipHandler.getSkippableState():super.getAdSkippableState()}getAdSkippableRemainingTime(){return this._skipHandler.getSkippableRemainingTime()}_onStopped(){this._unbindListeners(),this._clean(),this._hasImpressed?super._onStopped():this._onError("No fill",!1)}_onSkipped(){super._onSkipped(),this._unbindListeners(),this._clean(),this.vastTracker.track("skip",{once:!0,macros:Nn()})}_onDurationChange(){super._onDurationChange(),this.vastTracker.setDuration(this.getAdDuration()),this._handleRemainingTime(),!this._skipHasBeenInitialized&&this.getAdDuration()>0&&(this._skipHandler.isSkipEnabled()?this._skipHandler.initSkipCountdown(this.getAdDuration()):this._subscribeVPAIDAdUnit(this._onSkippableStateChange,xe.L0.of,this),this._skipHasBeenInitialized=!0)}_getAdCurrentTime(){const e=this.getAdRemainingTime(),t=this.getAdDuration();return Number.isFinite(e)&&Number.isFinite(t)?e<0?0:Math.round(1e6*(t-e))/1e6:0}_onRemainingTimeChange(){let{emulated:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._remainingTimeValue=this.getAdRemainingTime();const t=this._getAdCurrentTime();this.vastTracker.setProgress(t,Nn()),Sa(t,this.vastTracker,Nn()),super._onRemainingTimeChange(),e||clearInterval(this._remainingTimeHandlerID)}_onVideoTagPlaying=()=>{this._isBuffering&&(this._isBuffering=!1,this.publish(xe.k3.BUFFER_FINISH))};_onVideoTagWaiting=()=>{this._isBuffering=!0,this.publish(xe.k3.BUFFER_START)};_onVolumeChange(){const e=super.getAdVolume();if(!Number.isFinite(e)||-1===e||e===this._lastVpaidVolume)return;const t=Math.max(0,Math.min(e,1)),i=0===t,n=0===t&&this._lastVpaidVolume>0,r=t>0&&0===this._lastVpaidVolume;this._lastVpaidVolume=t,0!==t&&(this._internalVolume=t),(n||r)&&(this._setMuted(i),this.vastTracker.setMuted(i,Nn())),super._onVolumeChange()}_onImpression(){super._onImpression(),this._hasImpressed||this.vastTracker.trackURLs(this.vastTracker.ad.impressionURLTemplates,Nn()),this._hasImpressed=!0}_onVideoStart(){super._onVideoStart(),this.vastTracker.track("start",{once:!0,macros:Nn()})}_onVideoFirstQuartile(){super._onVideoFirstQuartile(),this.vastTracker.track("firstQuartile",{once:!0,macros:Nn()})}_onVideoMidpoint(){super._onVideoMidpoint(),this.vastTracker.track("midpoint",{once:!0,macros:Nn()})}_onVideoThirdQuartile(){super._onVideoThirdQuartile(),this.vastTracker.track("thirdQuartile",{once:!0,macros:Nn()})}_onVideoComplete(){super._onVideoComplete(),this.vastTracker.track("complete",{once:!0,macros:Nn()})}_onClickThru(e,t,i){super._onClickThru(e||this.vastTracker.clickThroughURLTemplate?.url,t,i),this._skipHandler.initSmartSkip();let n=null;try{n=fn(event)}catch(e){Ga.warn("Unable to retrieve mouseEvent for _onClickThru:",e.message)}const r=n?{...Nn(),...n}:Nn();this.vastTracker.trackViewableImpression(r,!0),this.vastTracker.click(null,r)}_onUserAcceptInvitation(){super._onUserAcceptInvitation(),this.vastTracker.track("acceptInvitation",{macros:Nn()})}_onUserMinimize(){super._onUserMinimize(),this.vastTracker.track("collapse",{macros:Nn()})}_onUserClose(){super._onUserClose(),this.vastTracker.track("close",{once:!0,macros:Nn()})}_onPaused(){super._onPaused(),this.vastTracker.track("pause",{macros:Nn()})}_onPlaying(){super._onPlaying(),this.vastTracker.track("resume",{macros:Nn()});const e=this._getAdCurrentTime();e>0&&this._skipHandler.setSkipToNow(e)}_onError(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this._hasStarted){this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),e=t?this._validateErrorFormat(e):e;const i=new Be(e,{type:this._hasImpressed?De:Ie});super._onError(i)}}_handleRemainingTime(){null===this._remainingTimeHandlerID&&(this._remainingTimeHandlerID=setInterval((()=>{const e=this.getAdRemainingTime();!e&&0!==e||this._remainingTimeValue===e||this._onRemainingTimeChange({emulated:!0})}),300))}_handleDurationChange(){if(!this._adDurationHandlerID){let e=-2;this._adDurationHandlerID=setInterval((()=>{const t=this.getAdDuration();t>0&&e!==t&&(e=t,this._onDurationChange())}),1e3)}}getFileWeight(){return 0}}const ja=e=>new Qa(e);var qa=i(8775);const $a=T("StreamIntegrator"),Wa=(e,t)=>{e.mediaFile=t;const{fileURL:i,mimeType:n,bitrate:r}=t||{};e.loadVideo=e=>{$a.log("Setting video src to",i),e.setAttribute("type",n),e.src=i,e.load()},e.endVideo=()=>{},e.getMediaType=()=>n?xe.VS.Aq.includes(n)?"audio":"video":"",e.getBitrate=()=>r||0},za=T("StreamIntegrator"),Xa=e=>e/2,Za=e=>e.sort(((e,t)=>e.bitrate-t.bitrate)),Ja=(e,t)=>e.filter((e=>e.bitrate<=t)),eo=e=>e.length?e.length-1:0,to=(e,t,i,n,r)=>{let s=null,a=null;e||Wa(t,n),t.mediaFile=i;const{fileURL:o}=i||{};t.loadVideo=i=>(a=i,(0,qa.az)(window.dmp_isGKEnabled).then((i=>(za.log("create hls.js ad",(0,qa.gH)(i.workerPath,window.dmp_isGKEnabled)),s=new e({autoStartLoad:!1,testBandwidth:!1,maxMaxBufferLength:15,maxStarvationDelay:1,capLevelToPlayerSize:!0,...i}),(0,qa.BM)(s,e,window.dmp_isGKEnabled),new Promise(((i,d)=>{za.log("Setting video src to",o),s.on(e.Events.MANIFEST_PARSED,((e,t)=>{const n=((e,t)=>{if(!e?.length||!t)return 0;const i=Xa(t),n=Za([...e]),r=Ja(n,i);return eo(r)})(t?.levels,r);s.startLevel=n,s.startLoad(-1),za.log("Setting best level to index ",n),i()})),s.on(e.Events.ERROR,((e,r)=>{if(za.log("Received error from HLS :",e,r),r.fatal)if(t.endVideo(),t._currentTime)t._onMediaError({message:r.error.message});else{if(!n)return d(new Error(`Cannot start HLS stream: ${r.error.message}`));Wa(t,n),t.loadVideo(a),i()}})),s.loadSource(o),s.attachMedia(a)})))))),t.endVideo=()=>{s?.destroy()},t.getMediaType=()=>"video",t.getBitrate=()=>{const{realBitrate:e,bitrate:t}=s?.levelController?.currentLevel||{};return e||t||0}},io=T("StreamIntegrator"),no=document.documentElement.hasOwnProperty("ontouchend")?"touchend":"click";class ro extends se{constructor(){let{mediaFiles:e,vastTracker:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.boundedListeners={media:{},tracker:{}},this._paused=!1,this._isSeeking=!1,this._currentTime=0,this._skipHandler=new jr(t,this.publish,this),this._hasImpressed=!1,this._hasViewabilityTracked=!1,this._viewMode=null,this._playAd=null,this.mediaFiles=e,this.vastTracker=t,this.adRemainingTime=-2}_logAdMediaFileWeightDetails(){const e=this.vastTracker?.ad;if(!e)return;const t=e?.creatives?.length>0?e.creatives[0]:{},i=t?.id||null,n=pn.inventoryId||null,r=pn.clientInventoryId||null,s=pn.duration||0,a=this.getBitrate(),o={creativeId:i,inventoryId:n,clientInventoryId:r,duration:s,bitrate:a,fileWeightInKB:Ta(s,a)};io.log("Calculated File Weight in KB and Related Details:",o)}destroy(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xe.k3.STOPPED,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===this.vastTracker)return;this._unbindListeners(),this.videoTag&&(this.videoTag.pause(),this.videoTag.removeAttribute("src"),this.videoTag.removeAttribute("type"),this.endVideo(),this.videoTag.load(),this.clickTarget?.removeAttribute("data-cursor-pointer")),this.videoTag=null,this.mediaFiles=null,this.mediaFile=null,this.vastTracker=null,this.companionVastTracker=null,this.clickTarget=null;const i=t?[e,t]:[e];this.publish(...i)}_bindListeners(){this._bindTrackerListeners(),this._bindMediaListeners()}_unbindListeners(){this.videoTag&&this._unbindMediaListeners(),this.vastTracker&&this._unbindTrackerListeners(),this.companionVastTracker&&this.companionVastTracker.off("clickthrough",this._onTrackerClickThrough)}_bindMediaListeners(){this._addBoundedMediaEventListener("durationchange",this._onMediaDurationChange),this._addBoundedMediaEventListener("loadeddata",this._onMediaLoadedData),this._addBoundedMediaEventListener("timeupdate",this._onMediaTimeUpdate),this._addBoundedMediaEventListener("seeking",this._onMediaSeeking),this._addBoundedMediaEventListener("ended",this._onMediaEnded),this._addBoundedMediaEventListener("pause",this._onMediaPause),this._addBoundedMediaEventListener("playing",this._onMediaPlaying),this._addBoundedMediaEventListener("volumechange",this._onMediaVolumeChange),this._addBoundedMediaEventListener("error",this._onMediaError),this._addBoundedMediaEventListener("waiting",this._onMediaWaiting)}_unbindMediaListeners(){this._removeBoundedMediaEventListener("durationchange"),this._removeBoundedMediaEventListener("loadeddata"),this._removeBoundedMediaEventListener("timeupdate"),this._removeBoundedMediaEventListener("seeking"),this._removeBoundedMediaEventListener("ended"),this._removeBoundedMediaEventListener("pause"),this._removeBoundedMediaEventListener("playing"),this._removeBoundedMediaEventListener("volumechange"),this._removeBoundedMediaEventListener("error"),this._removeBoundedMediaEventListener("waiting"),this._removeBoundedMediaEventListener(no,this.clickTarget)}_initClickThrough(){this._addBoundedMediaEventListener(no,this._onMediaClick,this.videoTag),(this.vastTracker.clickThroughURLTemplate?.url||this._getAudioCompanionAd()?.companionClickThruUrl)&&this.videoTag.setAttribute("data-cursor-pointer","")}_bindTrackerListeners(){this._addBoundedTrackerEventListener("creativeView",this._onTrackerCreativeView),this._addBoundedTrackerEventListener("start",this._onTrackerStart),this._addBoundedTrackerEventListener("firstQuartile",this._onTrackerFirstQuartile),this._addBoundedTrackerEventListener("midpoint",this._onTrackerMidpoint),this._addBoundedTrackerEventListener("thirdQuartile",this._onTrackerThirdQuartile),this._addBoundedTrackerEventListener("complete",this._onTrackerComplete),this._addBoundedTrackerEventListener("pause",this._onTrackerPause),this._addBoundedTrackerEventListener("resume",this._onTrackerResume),this._addBoundedTrackerEventListener("skip",this._onTrackerSkip),this._addBoundedTrackerEventListener("close",this._onTrackerClose),this._addBoundedTrackerEventListener("closeLinear",this._onTrackerCloseLinear),this._addBoundedTrackerEventListener("clickthrough",this._onTrackerClickThrough),this._addBoundedTrackerEventListener("fullscreen",this._onTrackerFullscreenEntered),this._addBoundedTrackerEventListener("exitFullscreen",this._onTrackerFullscreenExited),this._addBoundedTrackerEventListener("mute",this._onTrackerMuted),this._addBoundedTrackerEventListener("unmute",this._onTrackerUnmuted)}_unbindTrackerListeners(){this._removeBoundedTrackerEventListener("creativeView"),this._removeBoundedTrackerEventListener("start"),this._removeBoundedTrackerEventListener("firstQuartile"),this._removeBoundedTrackerEventListener("midpoint"),this._removeBoundedTrackerEventListener("thirdQuartile"),this._removeBoundedTrackerEventListener("complete"),this._removeBoundedTrackerEventListener("pause"),this._removeBoundedTrackerEventListener("resume"),this._removeBoundedTrackerEventListener("skip"),this._removeBoundedTrackerEventListener("close"),this._removeBoundedTrackerEventListener("closeLinear"),this._removeBoundedTrackerEventListener("clickthrough"),this._skipHandler.unbindSkipCountdown()}_addBoundedMediaEventListener(e,t,i){this._addBoundedEventListener("media",e,t,i)}_removeBoundedMediaEventListener(e,t){this._removeBoundedEventListener("media",e,t)}_addBoundedTrackerEventListener(e,t){this._addBoundedEventListener("tracker",e,t)}_removeBoundedTrackerEventListener(e){this._removeBoundedEventListener("tracker",e)}_addBoundedEventListener(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.videoTag;if(!this.boundedListeners[e])throw new Error("Unexpected type");this.boundedListeners[e][t]=i.bind(this),"media"===e?n.addEventListener(t,this.boundedListeners[e][t]):"tracker"===e&&this.vastTracker.on(t,this.boundedListeners[e][t])}_removeBoundedEventListener(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.videoTag;if(!this.boundedListeners[e])throw new Error("Unexpected type");const n=this.boundedListeners[e][t];n&&("media"===e?i.removeEventListener(t,n):"tracker"===e&&this.vastTracker.off(t,n),delete this.boundedListeners[e][t])}_clean(){}_onMediaDurationChange(){this.adDuration=this.videoTag.duration,this.vastTracker.setDuration(this.adDuration),this.publish(xe.k3.DURATION_CHANGE)}_onMediaLoadedData(){this._initClickThrough(),this._logAdMediaFileWeightDetails(),this.vastTracker.trackImpression(Nn()),this._skipHandler.initSkipCountdown(this.adDuration)}_onMediaTimeUpdate(){if(this._isSeeking)return void(this._isSeeking=!1);const e=Nn();this._currentTime=this.videoTag.currentTime,this.vastTracker.setProgress(this._currentTime,e),this.adRemainingTime=this.adDuration-this._currentTime,"audio"!==this.getMediaType()&&Sa(this._currentTime,this.vastTracker,e),this.publish(xe.k3.REMAINING_TIME_CHANGE)}_onMediaSeeking(){this._isSeeking=!0;const e=this.videoTag.currentTime-this._currentTime;Math.abs(e)&&(this.videoTag.currentTime=this._currentTime)}_onMediaEnded(){this.vastTracker.complete(Nn())}_onMediaError(e){let{message:t=null}=e,i=De;this._hasImpressed||(this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.pc}),i=Ie);const n=new Be(t||this.videoTag.error?.message,{type:i,code:this.videoTag.error?.code||null});this.destroy(xe.k3.ERROR,n)}_onMediaWaiting(){this._isBuffering=!0,this.publish(xe.k3.BUFFER_START)}_onMediaPlaying(){this._isBuffering&&(this._isBuffering=!1,this.publish(xe.k3.BUFFER_FINISH)),this._paused&&(this._paused=!1,this.vastTracker.setPaused(this._paused,Nn()),this._skipHandler.setSkipToNow(this._currentTime))}_onMediaPause(){this.videoTag.ended||this._paused||(this._paused=!0,this.vastTracker.setPaused(this._paused,Nn()))}_onMediaVolumeChange(){this.vastTracker.setMuted(this.videoTag.muted,Nn()),this.adVolume===this.videoTag.volume&&this.adMuted===this.videoTag.muted||(this.adVolume=this.videoTag.volume,this.adMuted=this.videoTag.muted||!1,this.publish(xe.k3.VOLUME_CHANGE))}_onMediaClick(e){e.preventDefault();const t={...Nn(),...fn(e)},i=this._getAudioCompanionAd();i&&!this.vastTracker.clickThroughURLTemplate?.url&&(this.companionVastTracker=i.companionVastTracker,this.companionVastTracker.on("clickthrough",this._onTrackerClickThrough.bind(this)),this.companionVastTracker.click(null,t)),"audio"!==this.getMediaType()&&this.vastTracker.trackViewableImpression(t,!0),this.vastTracker.click(null,t)}_onTrackerCreativeView(){this._hasImpressed=!0,this.publish(xe.k3.IMPRESSION)}_onTrackerStart(){this.publish(xe.k3.VIDEO_START)}_onTrackerFirstQuartile(){this.publish(xe.k3.VIDEO_FIRST_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_FIRST_QUARTILE)}_onTrackerMidpoint(){this.publish(xe.k3.VIDEO_MIDPOINT),ae.dispatchEvent(oe.AD_VIDEO_MIDPOINT)}_onTrackerThirdQuartile(){this.publish(xe.k3.VIDEO_THIRD_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_THIRD_QUARTILE)}_onTrackerComplete(){this.publish(xe.k3.VIDEO_COMPLETE),this.stopAd()}_onTrackerPause(){this.publish(xe.k3.PAUSED),ae.dispatchEvent(oe.AD_PAUSED)}_onTrackerResume(){this.publish(xe.k3.PLAYING),ae.dispatchEvent(oe.AD_PLAYING)}_onTrackerSkip(){this.destroy(xe.k3.SKIPPED)}_onTrackerClose(){this.destroy()}_onTrackerCloseLinear(){this.destroy()}_onTrackerClickThrough(e){this.publish(xe.k3.CLICK_THRU,e,null,!0),this._skipHandler.initSmartSkip()}_onTrackerFullscreenEntered(){this.publish(xe.k3.FULLSCREEN_ENTERED)}_onTrackerFullscreenExited(){this.publish(xe.k3.FULLSCREEN_EXITED)}_onTrackerMuted(){this.publish(xe.k3.MUTED)}_onTrackerUnmuted(){this.publish(xe.k3.UNMUTED)}initAd(e,t,i,n,r){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const a=new Promise(((i,n)=>{const r=[];if(this.mediaFiles.forEach((e=>{this._canPlayType(e.mimeType)&&r.push(e)})),!r.length){this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.R4});const e=new Be(le.STREAM_UNPLAYABLE_SRC,{type:ge});return this.publish(xe.k3.ERROR,e),n(e)}const a=cd().getEstimatedBitrate(),o=1e3*a,d=r.reduce(((e,t)=>(t.mimeType===xe.VS.Od?e.hls.push(t):xe.VS.Aq.includes(t.mimeType)?e.audio.push(t):xe.VS.Kd.includes(t.mimeType)&&e.video.push(t),e)),{video:[],audio:[],hls:[]});if(d.video.length||d.hls.length){d.video.sort(((e,t)=>e.height-t.height));let i=null;d.video.forEach((n=>{i?n.height>i.height&&t>n.height&&e>n.width&&(i=n):i=n})),d.hls.length?to(re(),this,d.hls[0],i,o):Wa(this,i)}else{d.audio.sort(((e,t)=>e.bitrate-t.bitrate));let e=null;d.audio.forEach((t=>{e?this.hasBetterBitrate(e,t,a)&&(e=t):e=t})),Wa(this,e)}this.videoTag=s.videoSlot,this.adVolume=this.videoTag.volume,this.adMuted=this.videoTag.muted||!1,this.publish(xe.k3.LOADED),this.vastTracker.load(Nn()),i({adType:this.getMediaType()})}));return $i(si,a)}async startAd(){this._bindListeners();try{io.log("Starting to load stream mediafile"),await this.loadVideo(this.videoTag),io.log("Playing the mediafile"),this.videoTag.play(),this.publish(xe.k3.STARTED,ga(this.vastTracker,xe.Z4.iF))}catch(e){this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.pc});const t=new Be(e.message,{type:Re});throw this.destroy(xe.k3.ERROR,t),t}}stopAd(){return this.destroy(),Promise.resolve()}pauseAd(){this.videoTag.pause()}resumeAd(){this.videoTag.play()}skipAd(){const e=this._skipHandler.getSkipLogs(this._currentTime);return this.vastTracker.skip(Nn()),Promise.resolve(e)}resizeAd(e,t,i){Ra({previousViewMode:this._viewMode,viewMode:i,vastTracker:this.vastTracker}),this._viewMode=i}getAdRemainingTime(){return this.adRemainingTime}getAdDuration(){return this.adDuration}getAdVolume(){return{volume:this.adVolume,muted:this.adMuted}}setAdVolume(e,t){t&&!this.videoTag.muted?this.videoTag.muted=!0:!t&&this.videoTag.muted&&(this.videoTag.muted=!1),void 0!==e&&(this.videoTag.volume=e)}getAdSkippableState(){return this._skipHandler.getSkippableState()}getAdSkippableRemainingTime(){return this._skipHandler.getSkippableRemainingTime()}getFileWeight(){const e=pn.duration||0,t=this.getBitrate();return Ta(e,t)}isSkipEnabled(){return this._skipHandler.isSkipEnabled()}hasBetterBitrate(e,t,i){const n=this.convertToKiloBitrate(t.bitrate);return n>this.convertToKiloBitrate(e.bitrate)&&n1e4?e/1e3:e}loadVideo(){console.warn("Missing implementation for loadVideo")}endVideo(){console.warn("Missing implementation for endVideo")}getMediaType(){return console.warn("Missing implementation for getMediaType"),""}getBitrate(){return console.warn("Missing implementation for getBitrate"),0}_getAudioCompanionAd(){return"audio"===this.getMediaType()?pn.audioAdCompanion:null}_canPlayType(e){return e===xe.VS.Od?I("PV5_HLS_ADS")&&Boolean(re()):Boolean(document.createElement("video").canPlayType(e).replace(/^no$/,""))}}const so=e=>new ro(e),ao=T("AdStackDM","VAST","IMANativeIntegrator"),oo="IMA Playlist timeout";class lo extends se{constructor(){let{mediaFiles:e,vastTracker:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this._eventListeners={},this.ad=null,this.currentTime=0,this.mediaFiles=e,this.vastTracker=t,this._lastAdEndedReason=null,ao.log("Listening to IMA events from the app"),ae.addEventListener(oe.PLAYER_IMA_NATIVE_EVENT,(e=>{const t=this._eventListeners[e.event];t&&t.forEach((t=>{t(e)}))}))}_bindListeners(){this._addBoundedEventListener(xe.YK.COMPLETE,this._onVideoCompleted),this._addBoundedEventListener(xe.YK.SKIPPED,this._onSkipped),this._addBoundedEventListener(xe.YK.ALL_ADS_COMPLETED,this._onAllAdsCompleted),this._addBoundedEventListener(xe.YK.CONTENT_RESUME_REQUESTED,this._onContentResumeRequested),this._addBoundedEventListener(xe.YK.PAUSED,this._onPaused),this._addBoundedEventListener(xe.YK.RESUMED,this._onResumed),this._addBoundedEventListener(xe.YK.CLICK,this._onClick),this._addBoundedEventListener(xe.YK.VOLUME_CHANGED,this._onVolumeChange),this._addBoundedEventListener(xe.YK.FIRST_QUARTILE,this._onFirstQuartile),this._addBoundedEventListener(xe.YK.MIDPOINT,this._onMidpoint),this._addBoundedEventListener(xe.YK.THIRD_QUARTILE,this._onThirdQuartile),this._addBoundedEventListener(xe.YK.FULLSCREEN,this._onFullscreen),this._addBoundedEventListener(xe.YK.INLINE,this._onInline),this._addBoundedEventListener(xe.YK.DURATION_CHANGED,this._onDurationChange),this._addBoundedEventListener(xe.YK.AD_PROGRESS,this._onAdProgress)}_unbindListeners(){this._removeBoundedEventListener(xe.YK.LOADED),this._removeBoundedEventListener(xe.YK.STARTED),this._removeBoundedEventListener(xe.YK.IMPRESSION),this._removeBoundedEventListener(xe.YK.COMPLETE),this._removeBoundedEventListener(xe.YK.SKIPPED),this._removeBoundedEventListener(xe.YK.ALL_ADS_COMPLETED),this._removeBoundedEventListener(xe.YK.CONTENT_RESUME_REQUESTED),this._removeBoundedEventListener(xe.YK.CONTENT_PAUSE_REQUESTED),this._removeBoundedEventListener(xe.YK.AD_ERROR),this._removeBoundedEventListener(xe.YK.PAUSED),this._removeBoundedEventListener(xe.YK.RESUMED),this._removeBoundedEventListener(xe.YK.CLICK),this._removeBoundedEventListener(xe.YK.VOLUME_CHANGED),this._removeBoundedEventListener(xe.YK.FIRST_QUARTILE),this._removeBoundedEventListener(xe.YK.MIDPOINT),this._removeBoundedEventListener(xe.YK.THIRD_QUARTILE),this._removeBoundedEventListener(xe.YK.FULLSCREEN),this._removeBoundedEventListener(xe.YK.INLINE),this._removeBoundedEventListener(xe.YK.DURATION_CHANGED),this._removeBoundedEventListener(xe.YK.AD_PROGRESS)}_addBoundedEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t.bind(this))}_removeBoundedEventListener(e){this._eventListeners[e]&&delete this._eventListeners[e]}_clean(){this._unbindListeners(),ao.log("Cleaning Slot")}initAdsManagerHelper(e){return new Promise(((t,i)=>{const n=()=>{this._removeBoundedEventListener(xe.YK.LOADED),this._removeBoundedEventListener(xe.YK.CONTENT_PAUSE_REQUESTED)},r=e=>{ao.log("LOADED received from the app"),n(),t(e)};this._addBoundedEventListener(xe.YK.AD_ERROR,(e=>{ao.log("AD_ERROR received from the app",e),n();const t=new Be(e.errorMessage,{type:ge,code:e.errorCode});i(t)})),this._addBoundedEventListener(xe.YK.LOADED,r),this._addBoundedEventListener(xe.YK.CONTENT_PAUSE_REQUESTED,r),ao.log("Listening to IMA LOADED from the app"),ao.log("Sending IMA_AD_REQUESTED with url ",e),ae.dispatchEvent(oe.IMA_NATIVE_AD_REQUESTED,{adTagUrl:e,vastLoadTimeout:Yi()}),ha({action:aa,component:ta})}))}startAdsManagerHelper(){return new Promise(((e,t)=>{const i=()=>{this._removeBoundedEventListener(xe.YK.IMPRESSION),this._removeBoundedEventListener(xe.YK.AD_ERROR)};this._addBoundedEventListener(xe.YK.IMPRESSION,(t=>{ao.log("IMPRESSION received from the app with ad",t.ad),this.ad=ga(t,xe.Z4.Vf),ao.log("AdStart data",this.ad),this.adPosition=t.ad.adPosition,this.totalAds=t.ad.totalAds,je.newAd(this.adPosition),this.inventoryIdValue=je.value,i(),e()})),this._addBoundedEventListener(xe.YK.AD_ERROR,(e=>{ao.log("AD_ERROR received from the app",e),i(),t(new Be(e.errorMessage,{type:Re,code:e.errorCode}))})),ao.log("Listening to IMA IMPRESSION from the app")}))}initAd(e,t,i,n,r,s){let a={};try{a=JSON.parse(r.AdParameters)}catch(e){throw ao.error("AdParameters failed to parse:",r.AdParameters),new Be(le.FAILED_TO_PARSE_AD_PARAMS,{type:Oe})}return ao.log("adsManager loaded"),this.initAdPromise=this.initAdsManagerHelper(a.url),this.startAdPromise=this.startAdsManagerHelper(),$i(si,this.initAdPromise).then((()=>{this.publish(xe.k3.LOADED)})).catch((e=>{throw this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}startAd(){return this._bindListeners(),this._startNextAd()}_startNextAd(){return $i(ai,this._startAd()).catch((e=>{throw this._unbindListeners(),this._clean(),this.vastTracker.error({...Nn(),ERRORCODE:xe.Uk.wr}),this.publish(xe.k3.ERROR,e),e}))}_startAd(){return this.startAdPromise.then((()=>{this._addBoundedEventListener(xe.YK.AD_ERROR,(e=>{ao.log("AD_ERROR received from the app",e);const t=new Be(e.errorMessage,{code:e.errorCode,type:Re});this.publish(xe.k3.POD_ERROR,t),this._endVideoAd()})),this.publish(xe.k3.STARTED,this.ad),this.vastTracker.trackURLs(this.vastTracker.ad.impressionURLTemplates,Nn()),this.publish(xe.k3.IMPRESSION)}))}stopAd(){return this._clean(),ae.dispatchEvent(oe.IMA_NATIVE_AD_STOPPED),Promise.resolve()}skipAd(){return new Promise((()=>{}))}pauseAd(){}resumeAd(){}resizeAd(){}clicked(){}getAdRemainingTime(){return this.currentTime&&this.getAdDuration()-this.currentTime||-1}getAdDuration(){return this.ad?.vastDuration||0}getAdVolume(){return{volume:this._lastVolume,muted:0===this._lastVolume}}setAdVolume(){}getAdSkippableState(){return!1}getAdSkippableRemainingTime(){}isSkipEnabled(){return!1}_onPaused(){ao.log("Received PAUSED event from IMA native"),this.vastTracker.track("pause",{macros:Nn()}),this.publish(xe.k3.PAUSED),ae.dispatchEvent(oe.AD_PAUSED)}_onResumed(){ao.log("Received RESUMED event from IMA native"),this.vastTracker.track("resume",{macros:Nn()}),this.publish(xe.k3.PLAYING),ae.dispatchEvent(oe.AD_PLAYING)}_onClick(){ao.log("Received CLICK event from IMA native"),this.vastTracker.click(null,Nn()),this.publish(xe.k3.CLICK_THRU)}_onVolumeChange(e){ao.log("Received VOLUME_CHANGE event from IMA native with data",e);const t=e.muted?0:e.volume;void 0===this._lastVolume&&(this._lastVolume=t),0===t&&this._lastVolume>0&&this.vastTracker.track("mute",{macros:Nn()}),t>0&&0===this._lastVolume&&this.vastTracker.track("unmute",{macros:Nn()}),this._lastVolume=t,this.publish(xe.k3.VOLUME_CHANGE)}_onFirstQuartile(){ao.log("Received FIRST_QUARTILE event from IMA native"),this.vastTracker.track("firstQuartile",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_FIRST_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_FIRST_QUARTILE)}_onMidpoint(){ao.log("Received MIDPOINT event from IMA native"),this.vastTracker.track("midpoint",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_MIDPOINT),ae.dispatchEvent(oe.AD_VIDEO_MIDPOINT)}_onThirdQuartile(){ao.log("Received THIRD_QUARTILE event from IMA native"),this.vastTracker.track("thirdQuartile",{macros:Nn(),once:!0}),this.publish(xe.k3.VIDEO_THIRD_QUARTILE),ae.dispatchEvent(oe.AD_VIDEO_THIRD_QUARTILE)}_onFullscreen(){ao.log("Received FULLSCREEN event from IMA native");const e=Nn();this.vastTracker.setFullscreen(!0,e),this.vastTracker.setExpand(!0,e),this.publish(xe.k3.FULLSCREEN_ENTERED)}_onInline(){ao.log("Received INLINE event from IMA native");const e=Nn();this.vastTracker.setFullscreen(!1,e),this.vastTracker.setExpand(!1,e),this.publish(xe.k3.FULLSCREEN_EXITED)}_onStarted(){ao.log("Received STARTED event from IMA native"),this.vastTracker.track("creativeView",{macros:Nn()}),this.vastTracker.track("start",{macros:Nn()}),this.publish(xe.k3.VIDEO_START)}_onVideoCompleted(){ao.log("Received VIDEO_COMPLETE event from IMA native"),this.vastTracker.track("complete",{macros:Nn()}),this.publish(xe.k3.VIDEO_COMPLETE,{endedReason:xe.Bj.COMPLETED}),this._endVideoAd()}_onSkipped(){ao.log("Received SKIPPED event from IMA native"),this.vastTracker.track("skip",{macros:Nn()}),this._lastAdEndedReason=xe.Bj.SKIPPED,this.publish(xe.k3.VIDEO_COMPLETE,{endedReason:xe.Bj.SKIPPED}),this._endVideoAd()}_endVideoAd(){this._removeBoundedEventListener(xe.YK.AD_ERROR);const e=this._isLastAdFromPod();this.ad=null,e||(je.newAd(),this.startAdPromise=this.startAdsManagerHelper(),this._startNextAd())}_onDurationChange(e){let{duration:t}=e;this.ad&&(this.ad.vastDuration=t),this.vastTracker.setDuration(t),this.publish(xe.k3.DURATION_CHANGE)}_onAdProgress(e){let{currentTime:t}=e;this.currentTime=t,this.publish(xe.k3.REMAINING_TIME_CHANGE),this.vastTracker.setProgress(t,Nn())}_onContentResumeRequested(){ao.log("Received CONTENT_RESUME_REQUESTED event from IMA native");Ui.start(oo,500,(()=>{this.publish(xe.k3.ERROR,new Be(le.IMA_SDK_INCORRECT_TAG,{type:Le}))}))}_onAllAdsCompleted(){ao.log("Received ALL_ADS_COMPLETED event from IMA native"),Ui.stop(oo),this.publish(xe.k3.STOPPED,{...this._lastAdEndedReason&&{reason:this._lastAdEndedReason}}),this._clean()}_isLastAdFromPod(){return!!this.totalAds&&this.totalAds===this.adPosition}publish(e,t){super.publish(e,t),e===xe.k3.ERROR&&(ao.log("Sending IMA_NATIVE_AD_STOPPED"),ae.dispatchEvent(oe.IMA_NATIVE_AD_STOPPED))}getFileWeight(){return 0}}const co=e=>new lo(e),uo={CREATE_SESSION:"createSession",RESOLVE:"resolve",REJECT:"reject"},ho="Media:durationchange",po="Media:error",Eo="Media:pause",_o="Media:play",mo="Media:playing",Ao="Media:seeked",vo="Media:seeking",go="Media:stalled",To="Media:timeupdate",Ro="Media:volumechange",So="Player:resize",Io="Player:init",fo="Player:startCreative",Do="Player:adSkipped",Lo="Player:adStopped",ko="Player:fatalError",Po={CLICK_THRU:"Creative:clickThru",EXPAND_NONLINEAR:"Creative:expandNonlinear",COLLAPSE_NONLINEAR:"Creative:collapseNonlinear",FATAL_ERROR:"Creative:fatalError",GET_MEDIA_STATE:"Creative:getMediaState",LOG:"Creative:log",REQUEST_FULL_SCREEN:"Creative:requestFullScreen",REQUEST_EXIT_FULL_SCREEN:"Creative:requestExitFullScreen",REQUEST_SKIP:"Creative:requestSkip",REQUEST_NAVIGATION:"Creative:requestNavigation",REQUEST_STOP:"Creative:requestStop",REQUEST_PAUSE:"Creative:requestPause",REQUEST_PLAY:"Creative:requestPlay",REQUEST_RESIZE:"Creative:requestResize",REQUEST_VOLUME:"Creative:requestChangeVolume",REQUEST_TRACKING:"Creative:reportTracking",REQUEST_CHANGE_AD_DURATION:"Creative:requestChangeAdDuration"},yo=[Po.GET_MEDIA_STATE,Po.REQUEST_VIDEO_LOCATION,Po.READY,Po.CLICK_THRU,Po.REQUEST_SKIP,Po.REQUEST_STOP,Po.REQUEST_PAUSE,Po.REQUEST_PLAY,Po.REQUEST_FULL_SCREEN,Po.REQUEST_VOLUME,Po.REQUEST_RESIZE,Po.REQUEST_NAVIGATION,Po.REQUEST_CHANGE_AD_DURATION,Po.REPORT_TRACKING,Io,fo,Do,Lo,ko,uo.CREATE_SESSION],Oo={UNSPECIFIED:1100,CANNOT_LOAD_RESOURCE:1101,PLAYBACK_AREA_UNUSABLE:1102,INCORRECT_VERSION:1103,TECHNICAL_ERROR:1104,EXPAND_NOT_POSSIBLE:1105,PAUSE_NOT_HONORED:1106,PLAYMODE_NOT_ADEQUATE:1107,CREATIVE_INTERNAL_ERROR:1108,DEVICE_NOT_SUPPORTED:1109,MESSAGES_NOT_FOLLOWING_SPEC:1110,PLAYER_RESPONSE_TIMEOUT:1111},bo=1200,Co=1203,No=1208,Uo=1209,wo=1211,Vo=1212,Mo=1213,Bo=1214,xo=2,Fo=3,Ko=4;class Ho{constructor(){this.listeners_={},this.sessionId_="",this.nextMessageId_=1,this.target_=window.parent,this.resolutionListeners_={},window.addEventListener("message",this.receiveMessage.bind(this),!1)}reset(){this.listeners_={},this.sessionId_="",this.nextMessageId_=1,this.resolutionListeners_={}}sendMessage(e,t){const i=this.nextMessageId_++,n=e==uo.CREATE_SESSION?e:`SIMID:${e}`,r={sessionId:this.sessionId_,messageId:i,type:n,timestamp:Date.now(),args:t};return yo.includes(e)?new Promise(((e,t)=>{this.addResolveRejectListener_(i,e,t),this.target_.postMessage(JSON.stringify(r),"*")})):new Promise((e=>{this.target_.postMessage(JSON.stringify(r),"*"),e()}))}addListener(e,t){this.listeners_[e]?this.listeners_[e].push(t):this.listeners_[e]=[t]}addResolveRejectListener_(e,t,i){this.resolutionListeners_[e]=(e=>{const n=e.type,r=e.args.value;"resolve"==n?t(r):"reject"==n&&i(r)}).bind(this)}receiveMessage(e){if(!e||!e.data)return;let t;try{t=JSON.parse(e.data)}catch(e){}if(!t)return;const i=t.sessionId,n=t.type,r=""==this.sessionId_&&n==uo.CREATE_SESSION,s=this.sessionId_==i;if((r||s)&&null!=n)if(Object.values(uo).includes(n))this.handleProtocolMessage_(t);else if(n.startsWith("SIMID:")){const e=n.substr(6),i=this.listeners_[e];i&&i.forEach((e=>e(t)))}}handleProtocolMessage_(e){const t=e.type;switch(t){case uo.CREATE_SESSION:{this.sessionId_=e.sessionId,this.resolve(e);const i=this.listeners_[t];i&&i.forEach((t=>t(e)));break}case uo.RESOLVE:case uo.REJECT:{const t=e.args.messageId,i=this.resolutionListeners_[t];i&&(i(e),delete this.resolutionListeners_[t]);break}}}resolve(e,t){const i=this.nextMessageId_++,n={messageId:e.messageId,value:t},r={sessionId:this.sessionId_,messageId:i,type:uo.RESOLVE,timestamp:Date.now(),args:n};this.target_.postMessage(JSON.stringify(r),"*")}reject(e,t){const i=this.nextMessageId_++,n={messageId:e.messageId,value:t},r={sessionId:this.sessionId_,messageId:i,type:uo.REJECT,timestamp:Date.now(),args:n};this.target_.postMessage(JSON.stringify(r),"*")}createSession(){this.generateSessionId_(),this.sendMessage(uo.CREATE_SESSION).then((()=>{}),(()=>{}))}generateSessionId_(){const e=new Uint8Array(16);window.crypto.getRandomValues(e);const t=Array.from(Array(32).keys()).map((t=>{const i=t%2==0,n=e[Math.floor(t/2)];return i?n>>4:15&n}));t[12]=4,t[16]=8|3&t[16];const i=t.map((e=>e.toString(16))),n=[i.slice(0,8).join(""),i.slice(8,12).join(""),i.slice(12,16).join(""),i.slice(16,20).join(""),i.slice(20).join("")].join("-");this.sessionId_=n}setMessageTarget(e){this.target_=e}}const Yo=T("StreamSimidIntegrator");class Go extends ro{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this._viewMode=null,this.simidProtocol=null,this.simidResolveSessionCreatedPromise_=null,this.sessionCreatedPromise_=new Promise((e=>{this.simidResolveSessionCreatedPromise_=e})),this.simidResolveInitializationPromise_=null,this.simidInitializationPromise_=new Promise(((e,t)=>{this.simidResolveInitializationPromise_=e,this.simidRejectInitializationPromise_=e=>{const i=`Creative rejected ${Io} ${e?.reason||"CREATIVE_NOT_REPLIED_TO_INIT"}`;return this.triggerError(i,e?.errorCode||Vo),t}})),this.resolvedStartCreative=!1,this.playerSize=null}loadSimidScript(e,t){this.simidProtocol=new Ho,this.addSimidListeners(),this.simidIframe=document.createElement("iframe"),this.simidIframe.style.display="none",this.simidIframe.className="simid_frame",t.parentNode.insertBefore(this.simidIframe,t.nextSibling),this.simidIframe.src=e,this.simidIframe.setAttribute("data-cy","simid-iframe"),this.simidIframe.setAttribute("allowFullScreen",""),I("PV5_SIMID_IFRAME_ALLOW_ATTRIBUTES")&&(this.simidIframe.allow="accelerometer; ambient-light-sensor; battery; camera; gyroscope; magnetometer; microphone;"),this.simidProtocol.setMessageTarget(this.simidIframe.contentWindow)}initSimidScript(){this.timedPromise(this.sessionCreatedPromise_,(()=>this.sendInitMessage()),(()=>{this.triggerError("Failed to init simid script",No)}))}cleanSimid(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Yo.log("Clean SIMID iframe and protocol"),this.simidIframe&&(this.simidIframe.remove(),this.simidIframe=null),this.simidProtocol?.reset(),e||this._unbindListeners()}onSessionCreated_(){Yo.log("Session created"),this.simidResolveSessionCreatedPromise_()}addSimidListeners(){this.simidProtocol.addListener(uo.CREATE_SESSION,this.onSessionCreated_.bind(this)),this.simidProtocol.addListener(Po.REQUEST_FULL_SCREEN,this.onSimidRequestFullScreen.bind(this)),this.simidProtocol.addListener(Po.REQUEST_EXIT_FULL_SCREEN,this.onSimidRequestExitFullScreen.bind(this)),this.simidProtocol.addListener(Po.REQUEST_PLAY,this.onSimidRequestPlay.bind(this)),this.simidProtocol.addListener(Po.REQUEST_PAUSE,this.onSimidRequestPause.bind(this)),this.simidProtocol.addListener(Po.FATAL_ERROR,this.onSimidCreativeFatalError.bind(this)),this.simidProtocol.addListener(Po.REQUEST_SKIP,this.onSimidRequestSkip.bind(this)),this.simidProtocol.addListener(Po.REQUEST_STOP,this.onSimidRequestStop.bind(this)),this.simidProtocol.addListener(Po.REQUEST_CHANGE_AD_DURATION,this.onSimidRequestChangeAdDuration.bind(this)),this.simidProtocol.addListener(Po.GET_MEDIA_STATE,this.onSimidGetMediaState.bind(this)),this.simidProtocol.addListener(Po.LOG,this.onSimidReceiveCreativeLog.bind(this)),this.simidProtocol.addListener(Po.REQUEST_TRACKING,this.onSimidRequestTracking.bind(this)),this.simidProtocol.addListener(Po.REQUEST_RESIZE,this.onSimidRequestResize.bind(this)),this.simidProtocol.addListener(Po.CLICK_THRU,this.onSimidRequestClickthru.bind(this)),this.simidProtocol.addListener(Po.REQUEST_NAVIGATION,this.onSimidRequestNavigation.bind(this)),this.simidProtocol.addListener(Po.REQUEST_VOLUME,this.onSimidRequestVolumeChange.bind(this))}onSimidGetMediaState(e){const t={currentSrc:this.videoTag.currentSrc,currentTime:this.videoTag.currentTime,duration:this.videoTag.duration,ended:this.videoTag.ended,muted:this.videoTag.muted,paused:this.videoTag.paused,volume:this.videoTag.volume,fullscreen:"fullscreen"===this._viewMode};Yo.log(`${Po.GET_MEDIA_STATE} received, replying..`,t),this.simidProtocol.resolve(e,t)}onSimidRequestExitFullScreen(e){const t={errorCode:bo,message:"Player fullscreenAllowed is not allowed"};return Yo.log(`${Po.REQUEST_EXIT_FULL_SCREEN} received, rejecting..`,t),this.publish(xe.k3.LOG,xe.r0.SIMID_REQUEST_EXIT_FULLSCREEN),this.simidProtocol.reject(e,t)}onSimidRequestFullScreen(e){const t={errorCode:bo,message:"Player fullscreenAllowed is not allowed"};Yo.log(`${Po.REQUEST_FULL_SCREEN} received, rejecting..`,t),this.publish(xe.k3.LOG,xe.r0.SIMID_REQUEST_FULLSCREEN),this.simidProtocol.reject(e,t)}sendInitMessage(){const e={environmentData:{videoDimensions:this.playerSize,creativeDimensions:this.playerSize,fullscreen:"fullscreen"===this._viewMode,fullscreenAllowed:!1,variableDurationAllowed:!1,skippableState:"playerHandles",siteUrl:document.location.host,useragent:window.navigator.userAgent,muted:this.adMuted,volume:this.adVolume,version:"1.1.1"},creativeData:{adParameters:this.creativeData?.AdParameters,clickThroughUrl:this.vastTracker?.clickThroughURLTemplate?.url}};Yo.log("Sending init message",e);const t=this.simidProtocol.sendMessage(Io,e);this.timedPromise(t,(()=>{this.startCreative()}),this.simidRejectInitializationPromise_)}async timedPromise(e,t,i){const n=new Promise(((e,t)=>{const i=setTimeout((()=>{clearTimeout(i),t("Promise timed out")}),3e3)}));Promise.race([n,e]).then(t,i)}onSimidRequestPause(e){if(this._paused){const t={errorCode:Oo.PAUSE_NOT_HONORED,message:"Player is already in pause state"};return Yo.log(`${Po.REQUEST_PAUSE} received, rejecting..`,t),this.simidProtocol.reject(e,t)}Yo.log(`${Po.REQUEST_PAUSE} received`),this.pauseAd(),this.simidProtocol.resolve(e)}onSimidRequestPlay(e){if(!this._paused){const t={errorCode:bo,message:"Player is already in play state"};return Yo.log(`${Po.REQUEST_PLAY} received, rejecting..`,t),this.simidProtocol.reject(e,t)}Yo.log(`${Po.REQUEST_PLAY} received`),this.resumeAd(),this.simidProtocol.resolve(e)}onSimidCreativeFatalError(e){const{errorCode:t,errorMessage:i}=e.args||{errorCode:Oo.MESSAGES_NOT_FOLLOWING_SPEC,errorMessage:"Creative provided no error message or error code"};Yo.log(`${Po.FATAL_ERROR} received`,e),this.vastTracker.error({...Nn(),...t&&{ERRORCODE:t}},!0),this.simidProtocol.resolve(e);const n=new Be(i,{type:be,code:t});this.publish(xe.k3.ERROR,n),this.stopAd(Ko)}onSimidRequestSkip(e){Yo.log(`${Po.REQUEST_SKIP} received`),this.simidProtocol.resolve(e),this.skipAd(),this.publish(xe.k3.VIDEO_COMPLETE,{endedReason:xe.Bj.SKIPPED}),this.publish(xe.k3.STOPPED,{reason:xe.Bj.SKIPPED})}onSimidRequestStop(e){Yo.log(`${Po.REQUEST_STOP} received`),this.simidProtocol.resolve(e),this.stopAd(Ko)}onSimidRequestChangeAdDuration(e){const t={errorCode:Co,message:"variableDurationAllowed is false, player does not allow changeAdDuration"};Yo.log(`${Po.REQUEST_CHANGE_AD_DURATION} received, rejecting..`,t),this.publish(xe.k3.LOG,xe.r0.SIMID_REQUEST_CHANGE_AD_DURATION),this.simidProtocol.reject(e,t)}onSimidReceiveCreativeLog(e){Yo.log(`${Po.LOG} received`,e)}onSimidRequestNavigation(e){const t={errorCode:Bo,message:"Environment does not support navigation"};Yo.log(`${Po.REQUEST_NAVIGATION} received, rejecting..`,t),this.simidProtocol.reject(e,t)}onSimidRequestVolumeChange(e){if(!this.validateMessageFormat(Po.REQUEST_VOLUME,e))return;const{volume:t,muted:i}=e.args;if("number"!=typeof t||t<0||t>1||"boolean"!=typeof i){const t={errorCode:wo,message:"Wrong values given for volume or muted properties"};return Yo.log(`${Po.REQUEST_VOLUME} received, rejecting..`,t),this.simidProtocol.reject(e,t)}this.setAdVolume(t,i),Yo.log(`${Po.REQUEST_VOLUME} received`),this.simidProtocol.resolve(e)}onSimidRequestTracking(e){if(!this.validateMessageFormat(Po.REQUEST_TRACKING,e))return;const{trackingUrls:t}=e.args;Yo.log(`${Po.REQUEST_TRACKING} received`,e.args),this.vastTracker.trackURLs(t,Nn()),this.simidProtocol.resolve(e)}onSimidRequestClickthru(e){if(!this.validateMessageFormat(Po.CLICK_THRU,e))return;const{playerHandles:t,x:i,y:n,url:r}=e.args;if(!r){const t={errorCode:Oo.UNSUPPORTED_NAVIGATION_ON_WEB,reason:"Invalid URI"};return Yo.log(`${Po.CLICK_THRU} received, rejecting`,e.args,t),this.simidProtocol.reject(e,t)}Yo.log(`${Po.CLICK_THRU} received`,e.args),this.simidProtocol.resolve(e),t&&this.vastTracker.click(r,{...Nn(),...fn(null,{x:i,y:n})})}onSimidRequestResize(e){const t={errorCode:Oo.EXPAND_NOT_POSSIBLE,message:"Linear resize not yet supported."};Yo.log(`${Po.REQUEST_RESIZE} received, rejecting..`,t),this.simidProtocol.reject(e,t)}setDuration(e){this.adDuration=e,this.vastTracker.setDuration(e),this.publish(xe.k3.DURATION_CHANGE)}_bindMediaListeners(){this._addBoundedMediaEventListener("play",this._onMediaPlay),this._addBoundedMediaEventListener("seeked",this._onMediaSeeked),this._addBoundedMediaEventListener("stalled",this._onMediaStalled),super._bindMediaListeners()}_unbindMediaListeners(){this._removeBoundedMediaEventListener("play"),this._removeBoundedMediaEventListener("seeked"),this._removeBoundedMediaEventListener("stalled"),this._removeBoundedMediaEventListener("timeupdate"),super._unbindMediaListeners()}_onMediaDurationChange(){this.adDuration=this.videoTag.duration,this.setDuration(this.adDuration);const e={duration:this.videoTag.duration};Yo.log(`Sending ${ho}`,e),this.simidProtocol.sendMessage(ho,e),super._onMediaDurationChange()}_onMediaSeeking(){super._onMediaSeeking(),Yo.log(`Sending ${vo}`),this.simidProtocol.sendMessage(vo)}triggerSimidError(e,t){const i={errorMessage:e,errorCode:t};Yo.log(`Sending ${ko}`,i),this.simidProtocol.sendMessage(ko,i).then((()=>{const i=new Be(e,{type:be,code:t});this.publish(xe.k3.ERROR,i),this.cleanSimid()}))}stopSimidCreative(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Fo;if(this.simidIframe){this.simidIframe.style.display="none";const t={code:e};Yo.log(`Sending ${Lo}`,t),this.simidProtocol.sendMessage(Lo,t).then((()=>this.cleanSimid(!0)))}}_onMediaPlay(){Yo.log(`Sending ${_o}`),this.simidProtocol.sendMessage(_o)}_onMediaSeeked(){Yo.log(`Sending ${Ao}`),this.simidProtocol.sendMessage(Ao)}_onMediaStalled(){Yo.log(`Sending ${go}`),this.simidProtocol.sendMessage(go)}_onMediaError(){super._onMediaError(),this.simidProtocol.sendMessage(po,{error:this.videoTag.error.code,message:this.videoTag.error.message})}_onMediaPlaying(){Yo.log(`Sending ${mo}`),super._onMediaPlaying(),this.simidProtocol.sendMessage(mo)}_onMediaPause(){Yo.log(`Sending ${Eo}`),super._onMediaPause(),this.simidProtocol.sendMessage(Eo)}_onMediaVolumeChange(){const e={volume:this.videoTag.volume,muted:this.videoTag.muted||!1};Yo.log(`Sending ${Ro}`,e),super._onMediaVolumeChange(),this.simidProtocol.sendMessage(Ro,e)}_onMediaTimeUpdate(){const e={currentTime:this.videoTag.currentTime};this.simidProtocol.sendMessage(To,e),super._onMediaTimeUpdate()}initAd(e,t,i,n,r){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.creativeData=r,this.playerSize={x:0,y:0,width:e,height:t},this.videoTag=s.videoSlot,this.adVolume=this.videoTag.volume,this.adMuted=this.videoTag.muted||!1,this._viewMode=i,this.loadSimidScript(r?.interactiveCreativeFile?.fileURL,s.videoSlot),this.initSimidScript();const a=this.mediaFiles?.filter((e=>this._canPlayType(e.mimeType)));if(!a.length){const e="No playable file found";Yo.log(e),this.triggerSimidError(e,Uo)}return super.initAd(e,t,i,n,r,s)}startAd(){this.simidInitializationPromise_.catch((e=>{const t=e?.reason||"Cleaning SIMID due to CREATIVE_NOT_REPLIED_TO_INIT",i=e?.errorCode||Vo;this.vastTracker.error({...Nn(),ERRORCODE:i},!0);const n=new Be(t,{type:be,code:i});this.publish(xe.k3.ERROR,n),Yo.log(t),this.cleanSimid(!0)}));try{return super.startAd()}catch(e){Yo.log("Cleaning SIMID due to MEDIA_ERR_SRC_NOT_SUPPORTED",e),this.triggerSimidError(e.message,e.code||4)}}stopAd(e){return!e&&this.videoTag.duration-this.videoTag.currentTime<=0&&(e=xo),this.stopSimidCreative(e),this.resolvedStartCreative||e!==xo||(Yo.log("Creative ended without replying to startCreative"),this.vastTracker.error({...Nn(),ERRORCODE:Mo},!0)),super.stopAd()}skipAd(){return this.simidProtocol.sendMessage(Do).then((()=>(Yo.log("Skipping the ad"),this.cleanSimid(),super.skipAd())))}resizeAd(e,t,i){const n={width:e,height:t,x:0,y:0};this.simidProtocol.sendMessage(So,{videoDimensions:n,creativeDimensions:n,fullscreen:"fullscreen"===i}),super.resizeAd(e,t,i),this._viewMode=i}triggerError(e,t){Yo.log(e),this.vastTracker.error({...Nn(),ERRORCODE:t},!0),this.publish(xe.k3.ERROR,new Be(e,{type:be,code:t})),this.cleanSimid()}startCreative(){try{this.simidResolveInitializationPromise_(),Yo.log(`Sending ${fo}`),this.simidProtocol.sendMessage(fo).then((()=>{this.simidIframe.style.display="block",this.resolvedStartCreative=!0,Yo.log(`${fo} successfull`)})).catch((e=>{const t=e?.errorCode||Oo.UNSPECIFIED,i=`Cleaning SIMID due to CREATIVE_NOT_REPLIED_TO_START, ${e.reason}`;this.triggerError(i,t)}))}catch(e){Yo.log(e)}}validateMessageFormat(e,t){if(t?.args)return!0;const i={errorCode:Oo.MESSAGES_NOT_FOLLOWING_SPEC,reason:'Missing required "args" property in the message data structure'};return Yo.log(`${e} received, rejecting`,i),this.simidProtocol.reject(t,i),!1}}const Qo=e=>new Go(e),jo=e=>!isNaN(e.xPosition)&&!isNaN(e.yPosition),qo=e=>{let t=A.width/2,i=A.height/2,{xPosition:n,yPosition:r,height:s}=e;return{xPosition:n>=t?"right":"left",yPosition:r+s<=i?"top":"bottom"}},$o=e=>U()&&e.length?e.some(((t,i)=>e.slice(i+1).some((e=>((e,t)=>{if(isNaN(e.xPosition)||isNaN(e.yPosition)||isNaN(t.xPosition)||isNaN(t.yPosition))return!1;let i=e.xPosition<=t.xPosition+t.width&&e.xPosition+e.width>=t.xPosition,n=e.yPosition<=t.yPosition+t.height&&e.yPosition+e.height>=t.yPosition;return i&&n})(t,e)||((e,t)=>{if(jo(e)&&jo(t))return!1;const i=jo(e)?qo(e):e,n=jo(t)?qo(t):t;return i.xPosition===n.xPosition&&i.yPosition===n.yPosition})(t,e))))):null;let Wo=[],zo=[];const Xo="unknown",Zo=T("AdStackDM","VAST");class Jo extends zr{constructor(){super(),this._hasStarted=!1,this._pendingEvents={},this._vastErrorCode=null,this._dmExtension={},this._mixedContentErrors=[],this._companionAds=null,this._adVerifications=null,this._skipAdLogs=null,this._pendingVastClientData=[],this._resetAdData(),this._pendingRequest=null,this._vastTracker=null;this.vastClient=new Kt(0,0,{getItem:()=>{},setItem:()=>{}}),this.vastParser=this.vastClient.getParser();const e=this.vastParser.parseVastXml.bind(this.vastParser);this.vastParser.parseVastXml=(t,i)=>{const n=e(t,i),r=i?.wrapperChainId??0;return Array.isArray(n)&&n.forEach((e=>{e&&(e.wrapperChainId=r)})),n},this.vastClient.addURLTemplateFilter(Vn)}fetchAd(e,t){const{fallbackUrl:i,fallbackMethod:n}=t;this._dmExtension=e&&e.extension||{},this._resetAdData();const r=e&&e.getAdSource(),s=this._onErrorVastClientEvent.bind(this),a=this._onResolvingVastClientEvent.bind(this),o=this._onResolvedVastClientEvent.bind(this),d=this._onAdParsedVastClientEvent.bind(this),l=()=>{this.vastParser.on("VAST-error",s),this.vastParser.on("VAST-resolving",a),this.vastParser.on("VAST-resolved",o),this.vastParser.on("VAST-ad-parsed",d)},c=()=>{this.vastParser.off("VAST-error",s),this.vastParser.off("VAST-resolving",a),this.vastParser.off("VAST-resolved",o),this.vastParser.off("VAST-ad-parsed",d)};this._pendingRequest=null;const u=new Promise(((s,a)=>{if(!e||!e.hasSupportedAdSource()){const t=`${le.UNSUPPORTED_ADSOURCE} (${e?e.errorMessage:"no adBreak"})`;return a(new Be(t,{type:Ae}))}let o=r?.adTagURI?.uri||"xml";this._rootVastUrl="xml"!==o?o:null,n===xe.w3.URL&&i&&(e.setAdSource({adTagURI:{uri:i,templateType:"vast3"}}),o=i,this._rootVastUrl=i);const d=r?.vastAdData||null;if(null===o&&null===d)return a(new Be(le.EMPTY_VAST_DATA_OR_URI,{type:Ae}));l();const u=n===xe.w3.ADBUFFET?()=>new Promise((e=>{e({ads:qe.adBuffet})})):()=>(this._pendingRequest=ze().CancelToken.source(),"xml"===o?this.vastClient.parseVAST(nn(d),{urlhandler:Gr(0,{...t,cancelToken:this._pendingRequest.token}),resolveAll:!0,allowMultipleAds:!0,keepFailedAdPod:!0,...$r()}):this.vastClient.get(o,{urlhandler:Gr(0,{...t,cancelToken:this._pendingRequest.token}),resolveAll:!0,allowMultipleAds:!0,keepFailedAdPod:!0,...$r()}));u().then((e=>{c(),this.initAdPods(e?.ads,n);const t=qe.adPods.length?qe.adPods[0].mainAd:e?.ads[0];this.initAdBuffet(e?.ads),this.processDMExtensionData(t,t?.wrapperChainId??0),Oi.activateChain(t?.wrapperChainId??0),this._setVastVersion(e),s({currentAd:t})})).catch((e=>{c();const t=new Be(e&&e.message,{type:Ae});a(t)}))}));return this.getFetchTimePromise(u)}getFetchTimePromise(e){return $i(ri,e).catch((e=>{const t=ui(e);throw this._pendingRequest&&this._pendingRequest.cancel(),t.type===ve&&(t.message=Yr(this._lastVastURL)?le.AD_DIRECTOR_REQUEST_TIMEOUT:le.VAST_WRAPPER_REQUEST_TIMEOUT),this._publishMixedContentErrors(),this._onError(t),t}))}hasSimid(e){let{creative:t}=e;return"SIMID"===t.interactiveCreativeFile?.apiFramework&&I("PV5_SIMID")}isSkipEnabled(){return!(!pn||!pn.integrator)&&pn.integrator.isSkipEnabled()}initAd(e,t,i,n){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=arguments.length>5?arguments[5]:void 0;const a=[xe.k3.LOG,xe.k3.WILL_START,xe.k3.IMPRESSION,xe.k3.VIDEO_START],{ad:o,creative:d}=s;this._vastTracker=this._getTracker(o,d);let l=this._dmExtension.skipOffset>=0?this._dmExtension.skipOffset/1e3:0;var c,u;c=l,u=this._vastTracker.skipDelay,c&&(c!("companion"!==e.type||e.sequence!=t.sequence&&t.sequence&&e.sequence)))||[];return i.length&&Wi.log("Got companion creatives",i),i}(o,d),pn.integrator.initAd(e,t,i,n,p,r).then((i=>{this._publishMixedContentErrors(),this._bindDefaultListeners({exclude:a}),this._overrideDefaultListener(xe.k3.STOPPED,this._onStopped,this),this._overrideDefaultListener(xe.k3.SKIPPED,this._onSkipped,this),this._overrideDefaultListener(xe.k3.ERROR,this._onError,this);const n=pn.integrator?.mediaFile||null;return this.publish(xe.k3.LOADED,{adCreativeId:this._adCreativeId,adSystem:this._adSystem,adTitle:this._adTitle,inventoryId:this._inventoryId,provider:this._provider,buyerType:this._buyerType,integrator:this._integratorType,hasClickThru:pn.integrator.vastTracker&&pn.integrator.vastTracker.clickThroughURLTemplate&&pn.integrator.vastTracker.clickThroughURLTemplate.url,mimeType:n?.mimeType||null,height:n?.height||null,width:n?.width||null,companionAds:this._companionAds,displayedCompanion:this._handleDisplayedCompanion(o,i?.adType),skipOffset:this._skipOffset,adVerifications:this._adVerifications,vastTracker:this._vastTracker,injectedAdSlot:i?.adSlot??null,vastVersion:this._vastVersion,adType:i?.adType||"video",mediaFileDuration:this.getAdDuration(),hasSimid:this.hasSimid(s),...this.getAdPodInfo(),...this._getDmxInfos(),...this._getDvaExtensionInfos()}),this._checkAdRatio(e,t,n),pn.integrator})).catch((e=>{this._publishMixedContentErrors(),this._onError(e)}))}_checkAdRatio(e,t,i){const n=this._getAdSize(i);if(!n)return;e/t!==n.width/n.height&&this.publish(xe.k3.RATIO_CHANGE,{contentType:"ad",contentWidth:n.width,contentHeight:n.height,details:{adType:this._adType}})}_handleDisplayedCompanion(e,t){if(!this._companionAds||"audio"!==t)return null;const i=function(e){if(!e||!e.length)return null;let t=null,i=null,n=null;return e.some((e=>!(!e.variations||!e.variations.length)&&e.variations.some((r=>!!(r.staticResources&&r.height&&r.width)&&(n=r.staticResources.find((e=>e.url&&xe.VS.$U.includes(e.creativeType))),!!n&&(t=e,i=r,!0)))))),t?{creative:t,variation:i,resource:n}:null}(this._companionAds);if(!i)return null;const n=new Ht(null,e,i.creative,i.variation);return{...i,vastTracker:n}}_logVpaidEarlyEvents(){const e=Object.keys(this._pendingEvents).filter((e=>[xe.L0.Hw,xe.L0.nt,xe.L0.Om].includes(e)));e.length&&this.publish(xe.k3.LOG,{...xe.r0.VPAID_EARLY_START_AD_EVENT,value:e.join(",")})}startAd(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._logVpaidEarlyEvents(),pn.integrator.startAd(e).catch((e=>{this._onError(e),pn.integrator=null}))}stopAd(e){return this._clean(),null===pn.integrator?(this.publish(xe.k3.STOPPED),Promise.resolve()):pn.integrator.stopAd().then((()=>{this.publish(xe.k3.STOPPED,{reason:e})})).catch((e=>{this.publish(xe.k3.ERROR,e)})).finally((()=>{pn.integrator=null,gn()}))}skipAd(){return this._clean(),null===pn.integrator?Promise.resolve():pn.integrator.skipAd().then((e=>{this._skipAdLogs=e,this.publish(xe.k3.SKIPPED)})).catch((e=>{this.publish(xe.k3.ERROR,e)})).finally((()=>{pn.integrator=null,gn()}))}getSkipAdLogs(){return this._skipAdLogs||{}}resizeAd(e,t,i){pn.integrator.resizeAd(e,t,i),this.publish(xe.k3.RESIZE_AD_REQUESTED,{width:e,height:t,viewMode:i})}pauseAd(){pn.integrator.pauseAd()}resumeAd(){pn.integrator.resumeAd()}getAdPodInfo(){return qe.adPods.length>1?{adPodIndex:qe.adPodIndex,adPodTotalAds:qe.adPods.length,isAdPod:!0}:pn.integrator.getAdPodInfo?.()}publish(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:null;return new Promise(((t,i)=>{try{if(e.hasFailed)return i(new Be(le.FAILED_AD_SEQUENCE,{type:Oe}));const s=en(e,this.vastParser);if(s.ad){if(s.ad.extensions){if(this._dmExtension={...this._dmExtension,...Zi(s.ad.extensions)},this._isAdBlockedByDomain(e))throw new Be(le.BLOCKED_DOMAIN,{type:Ce,hasRemainingAds:Boolean(qe.adBuffet.length)});this._dmExtension.adSaveDataUrl&&Oi.enableLogging()}this._dmExtension.timeout&&Hi(this._dmExtension.timeout)}this._adCreativeId=s?.creative?.id||null,this._adSystem=s?.ad?.system?.value||null,this._adTitle=s?.ad?.title||null,this._inventoryId=this._dmExtension.inventoryId||null,this._provider=this._dmExtension.provider||Xo,this._buyerType=this._dmExtension.buyertype||Xo,this._bid=this._dmExtension.bid||null,this._sid=this._dmExtension.sid||null,this._cid=this._dmExtension.cid||null,this._adid=this._dmExtension.adid||null,this._crid=this._dmExtension.crid||null,this._did=this._dmExtension.did||null,this._bidid=this._dmExtension.bidid||null,this._pid=this._dmExtension.pid||null,this._siteid=this._dmExtension.siteid||null,this._fallbackUrl=this._dmExtension.fallbackUrl||null,this._adType=this._dmExtension.adType||"",this._isDvaEnabled=this._dmExtension.dva||null,this._dvaWr=this._dmExtension.wr||null,this._dvaAccVpaid=this._dmExtension.acc_vpaid||null,this._dvaAccVpaidInner=this._dmExtension.acc_vpaid_inner||null,this._dvaProvider=this._dmExtension.acc_provider||null,this._skipType=this._dmExtension.skipType||null,this._gppString=this._dmExtension.macros?.GPPSTRING||null,this._gppSectionId=this._dmExtension.macros?.GPPSECTIONID||null,_i.value=this._dmExtension.server_idx,this._dmExtension.adom&&(this._adom=this._dmExtension.adom.length?this._dmExtension.adom.join():null);const a=s.creative?.icons||[],o=(s.ad?.creatives||[]).filter((e=>"linear"===e.type&&!e.mediaFiles.length)).flatMap((e=>e.icons||[]));if(pn.icons=[...a,...o],pn.hasIconsCollision=$o(pn.icons),ae.dispatchEvent(oe.AD_DATA_UPDATED,{adData:{inventoryId:this._inventoryId,adCreativeId:this._adCreativeId,bidid:this._bidid,bid:this._bid,did:this._did}}),!s.integratorType||s.error){const e=(n=s,(r=this._dmExtension).noAd?new Be(r.noAd.reason,{type:ue,code:r.noAd.reasonId}):n.error&&n.error.type&&n.error.message?new Be(n.error.message,{type:n.error.type,adSystem:n?.ad?.system?.value??null,adTitle:n?.ad?.title??null,inventoryId:r.inventoryId||null,provider:r.provider||"unknown",buyerType:r.buyertype||"unknown",bid:r.bid||"unknown",sid:r.sid||"unknown",adom:r.adom||"unknown",cid:r.cid||"unknown",adid:r.adid||"unknown",crid:r.crid||"unknown",did:r.did||"unknown",bidid:r.bidid||"unknown",pid:r.pid||"unknown",dva:r.dva||"unknown",dva_provider:r.acc_provider||"unknown",dva_vpaid:r.acc_vpaid||"unknown",dva_vpaid_inner:r.acc_vpaid_inner||"unknown",dva_wr:r.wr||0,integrator:n.integratorType,fallbackUrl:r.fallbackUrl||null}):new Be(n.mediaFiles.length?le.NO_SUPPORTED_CREATIVE:le.NO_FILL,{type:ge}));throw e.updateProperties({hasRemainingAds:Boolean(qe.adBuffet.length)}),e}if(this._isNoRepeatedCreativeFeatureEnabled(s.integratorType)&&(e=>{let{vastCreativeId:t,dmxCreativeId:i}=e;return zo.some((e=>i===e))||Wo.some((e=>t===e))})({vastCreativeId:this._adCreativeId,dmxCreativeId:this._crid}))throw this._getTracker(e,s.creative).error({ERRORCODE:2008},!0),new Be(le.CREATIVE_ALREADY_PLAYED_IN_SLOT,{type:ge,code:2008,hasRemainingAds:Boolean(qe.adBuffet.length)});t(s)}catch(e){let t=e;e instanceof Be||(t=new Be(le.SUPPORTED_CREATIVE_ERROR,{type:ge})),this._onError(t),i(t)}var n,r}))}_isAdBlockedByDomain(e){const t=this._dmExtension?.blockDomains;if(!t?.length)return!1;const i=e?.wrapperChainId??0;return Ji([...this._resolvedURLsByChain[i]||[],...this._rootVastUrl?[this._rootVastUrl]:[],...e?.creatives?.flatMap((e=>function(e){if(!e)return[];const t=[];return e.mediaFiles?.forEach((e=>{e?.fileURL&&t.push(e.fileURL)})),e.interactiveCreativeFile?.fileURL&&t.push(e.interactiveCreativeFile.fileURL),e.variations?.forEach((e=>{e?.staticResource&&t.push(e.staticResource),e?.fileURL&&t.push(e.fileURL)})),t}(e)))||[]],t)}_isNoRepeatedCreativeFeatureEnabled(e){if(e===xe.Z4.Hs)return!1;const t=U()&&I("PV5_AD_SLOT_PREVENT_SAME_CREATIVE_ID_ONSITE"),i=!U()&&I("PV5_AD_SLOT_PREVENT_SAME_CREATIVE_ID_OFFSITE");return t||i}getEstimatedBitrate(){return this.vastParser.getEstimatedBitrate()}_publishPendingEvents(e){(0,$e.nextTick)((()=>{this._hasStarted=!0,Object.entries(this._pendingEvents).forEach((t=>{let[i,n]=t;this._logEvent(i,{type:"delayed"},e),super.publish(i,...n)})),this._pendingEvents={}}))}_onStopped(e){this._clean(),this.publish(xe.k3.STOPPED,e)}_onSkipped(){this._clean(),this.publish(xe.k3.SKIPPED)}_onError(e){const t=ui(e,{code:this._vastErrorCode||e.code,adSystem:this._adSystem,adTitle:this._adTitle,inventoryId:this._inventoryId,provider:this._provider,buyerType:this._buyerType,integrator:this._integratorType,fallbackUrl:this._fallbackUrl,lastVastUrl:this._lastVastURL||null,internalCode:e.code,vastVersion:this._vastVersion,hasRemainingAds:Boolean(qe.adBuffet.length),timeoutInfo:Gi(),...this._getDmxInfos(),...this._getDvaExtensionInfos()});this.publish(xe.k3.ERROR,t),this._vastErrorCode=null,pn.integrator?._clean()}_createIntegrator(e,t){const{integratorType:i,mediaFiles:n}=e;switch(i){case xe.Z4.cV:return ja({mediaFiles:n,vastTracker:t});case xe.Z4.iF:return this.hasSimid(e)?Qo({mediaFiles:n,vastTracker:t}):so({mediaFiles:n,vastTracker:t});case xe.Z4.Hs:return La({mediaFiles:n,vastTracker:t});case xe.Z4.Vf:return co({mediaFiles:n,vastTracker:t})}}_getCreativeVariation(e){return e.variations&&e.variations.length>0?e.variations[0]:null}_getTracker(e,t){return new Ht(this.vastClient,e,t,this._getCreativeVariation(t))}_publishMixedContentErrors(){this._mixedContentErrors.forEach((e=>{this.publish(xe.k3.LOG,{...xe.r0.VAST_URI_MIXED_CONTENT,adSystem:e.system.value,inventoryId:this._dmExtension.inventoryId||null,provider:this._dmExtension.provider||Xo,buyerType:this._dmExtension.buyertype||Xo,...this._getDmxInfos(),...this._getDvaExtensionInfos()})})),this._mixedContentErrors=[]}_getDmxInfos(){const e={bid:this._bid,sid:this._sid,adom:this._adom,cid:this._cid,adid:this._adid,crid:this._crid,did:this._did,bidid:this._bidid,pid:this._pid,siteid:this._siteid,skipType:this._skipType,gppString:this._gppString,gppSectionId:this._gppSectionId};if(this._integratorType===xe.Z4.Hs)try{const t=pn.integrator?.adsManager?.getCurrentAd();t&&(e.adom=t.getAdvertiserName(),e.cid=t.getCreativeId(),e.adid=t.getAdId(),e.crid=t.getCreativeAdId?.())}catch(e){Zo.log("Error retreiving Dmx infos:",e)}return e}_getDvaExtensionInfos(){return{dva:this._isDvaEnabled||!1,dva_provider:this._dvaProvider,dva_vpaid:this._dvaAccVpaid,dva_vpaid_inner:this._dvaAccVpaidInner,dva_wr:this._dvaWr||0}}_onErrorVastClientEvent(e){Zo.warn("Parsing error received",e);const t=this._pendingVastClientData.length;t&&(ha({...this._pendingVastClientData[t-1],action:oa,responseType:da,component:ia}),this._pendingVastClientData.splice(-1,1)),e.extensions&&(this._dmExtension={...this._dmExtension,...Zi(e.extensions)}),e.ERRORMESSAGE===le.BAD_PROTOCOL&&this._mixedContentErrors.push(e),this._vastErrorCode=e.ERRORCODE||null}_onResolvingVastClientEvent(e){1===e.wrapperDepth&&this.processDMExtensionData(e.wrapperAd,e.wrapperChainId??0);const t=e.wrapperChainId??0;this._resolvedURLsByChain[t]||(this._resolvedURLsByChain[t]=[]),e.url&&this._resolvedURLsByChain[t].push(e.url),this._lastVastURL=e.url,ha({...e,action:sa,component:ia})}_onResolvedVastClientEvent(e){const t=e.statusCode===Ii;t||e.error?ha({...e,action:oa,responseType:t?la:da,component:ia}):(this._pendingVastClientData.push(e),Oi.addToChain(e.wrapperChainId??0,e))}_onAdParsedVastClientEvent(e){const t=this._pendingVastClientData.findIndex((t=>t.url===e.url&&t.wrapperDepth===e.wrapperDepth));-1!==t?(ha({...this._pendingVastClientData[t],action:oa,responseType:e.type,vastVersion:e.vastVersion,component:ia}),this._pendingVastClientData.splice(t,1)):Zo.log("Ad call logs: Missing resolved data for",e)}processDMExtensionData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!e)return;const i={...this._dmExtension,...Zi(e.extensions)};i.adSaveDataUrl&&Oi.setChainEndpoint(t,i.adSaveDataUrl),ae.dispatchEvent(oe.AD_DATA_UPDATED,{adData:{inventoryId:i.inventoryId||null,bidid:i.bidid||null,bid:i.bid||null,did:i.did||null}})}_clean(){Zo.log("Removing listeners"),this._unbindDefaultListeners(),this.destroyFocusDetection&&this.destroyFocusDetection()}_logEvent(e){let{type:t=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(e!==xe.k3.SKIPPABLE_REMAINING_TIME_CHANGE&&e!==xe.k3.REMAINING_TIME_CHANGE){try{const t="queryString"===Y("apimode");"postMessage"===Y("api")&&t||Xr(e,i)}catch(e){Zo.log("Error with external output: ",e)}switch(t){case"delaying":Zo.log(`Received ${e}. Delaying until start ad phase.`);break;case"delayed":Zo.log("Publishing delayed",e);break;default:Zo.log("Received",e)}}}_eventCanBeDelayed(e){return-1===[xe.k3.ERROR,xe.k3.LOADED,xe.k3.LOG,xe.k3.STARTED,xe.k3.STOPPED,xe.k3.WILL_START].indexOf(e)}_getAdSize(e){return e&&parseInt(e.height)&&parseInt(e.width)?{width:e.width,height:e.height}:null}_setVastVersion(e){this._vastVersion=e&&e.version?e.version:null}_resetAdData(){this._resolvedURLsByChain={},this._rootVastUrl=null,this._adCreativeId=null,this._adSystem=null,this._adTitle=null,this._fallbackUrl=null,this._integratorType=null,this._inventoryId=null,this._provider=null,this._buyerType=null,this._bid=null,this._sid=null,this._adom=null,this._cid=null,this._adid=null,this._crid=null,this._did=null,this._bidid=null,this._pid=null,this._siteid=null,this._vastVersion=null,this._isDvaEnabled=null,this._dvaWr=null,this._dvaAccVpaid=null,this._dvaAccVpaidInner=null,this._dvaProvider=null,this._skipType=null}_logIfOmidNeeded(e){if(!e)return;const t=[];e.forEach((e=>{"OMID"===e.apiFramework?.toUpperCase()&&t.push(e.vendor)})),t.length>0&&this.publish(xe.k3.LOG,{...xe.r0.OMID_NEEDED,value:t.toString()})}async _logTopicsApi(){if(!(N()&&I("PV5_TOPICS_API")&&document?.browsingTopics&&document.featurePolicy.allowsFeature("browsing-topics")))return!1;const e=await document.browsingTopics();return Zo.log("Topics API has been observed"),!!e?.length&&(this.publish(xe.k3.LOG,{...xe.r0.TOPICS_API,value:JSON.stringify(e)}),!0)}initAdPods(e,t){if(t===xe.w3.ADBUFFET)return;if(this.isCrossPodReranking(e))return qe.isCrossPodReranking=!0,qe.adPods=e.filter((e=>e.sequence)).sort(((e,t)=>e.sequence-t.sequence)).map((e=>({mainAd:e,adBuffet:[]}))),void(qe.adSlotTotalAdBreaks=qe.adPods.length);(U()&&I("PV5_ADPODS_ONSITE")||!U()&&I("PV5_ADPODS"))&&(e.forEach((e=>{e.sequence?qe.adPods.push({mainAd:e,adBuffet:[]}):qe.adPods.length&&qe.adPods[qe.adPods.length-1].adBuffet.push(e)})),qe.adPods=qe.adPods.sort(((e,t)=>e.mainAd.sequence-t.mainAd.sequence))||[],qe.adPods.length&&(qe.adSlotTotalAdBreaks=qe.adPods.length))}isCrossPodReranking(e){return!!I("PV5_CROSS_POD_RERANKING")&&(e?.some((e=>e.sequence))&&e?.some((e=>!e.sequence)))}initAdBuffet(e){if(qe.isCrossPodReranking)return qe.adBuffet=e?.filter((e=>!e.sequence))||[],void(gi.value=qe.adBuffet.length);if(qe.adPods.length>1)qe.adBuffet=qe.adPods[0].adBuffet;else{const t=e?.filter((e=>!e.sequence))||[];t.shift(),qe.adBuffet=t}gi.value=qe.adBuffet.length}}const ed=T("Ads");let td=null,id=null,nd=null,rd=null,sd=null,ad=null,od=[],dd=[];const ld=e=>{gd(),null===id&&e&&(ad=new Jo)},cd=()=>ad,ud=e=>{let{fallbackMethod:t,fallbackUrl:i,isRealAutoplay:n=!1,adPause:r=!1,proxyInitProtection:s=!1,volume:a=!1,videoSlotCanAutoPlay:o=!0}=e;return{adPause:r,position:qe.position,isRealAutoplay:n,proxyInitProtection:s,videoSlotCanAutoPlay:o,videoSlot:H(),fallbackMethod:t,fallbackUrl:i,...a&&{volume:a}}},hd=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(td)return td;const t=ad.fetchAd(e.adBreak,ud(e)).then((e=>{let{currentAd:t}=e;return t})).catch((e=>{throw e}));return td=Td(t),td},pd=function(){let{creative:e,onAdWillStartEarly:t,initAdOptions:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(ed.log("initAd"),id&&qe.adPods.length<1)return id;const n=new Promise(((n,r)=>{const s=()=>{Sd(a,xe.k3.LOADED),Sd(d,xe.k3.ERROR),Sd(o,xe.k3.WILL_START)},a=e=>{s(),n(e)},o=()=>{"function"==typeof t&&t()},d=e=>{s(),r(e)};Rd(a,xe.k3.LOADED),Rd(o,xe.k3.WILL_START),Rd(d,xe.k3.ERROR);const{width:l,height:c}=A;try{ad.initAd(l,c,"normal",600,ud(i),e)}catch(e){d(new Be(e.message,{type:ge}))}}));return id=Td(n),id},Ed=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(nd&&qe.adPods.length<1)return nd;const t=new Promise(((t,i)=>{const n=()=>{Sd(r,xe.k3.STARTED),Sd(s,xe.k3.ERROR)},r=e=>{n(),ad.hasBufferStep=!0,ad.adData=e,t(ad)},s=e=>{n(),i(e)};Rd(r,xe.k3.STARTED),Rd(s,xe.k3.ERROR);try{ad.startAd(e)}catch(e){s(new Be(e.message,{type:Re}))}}));return nd=Td(t),nd},_d=()=>sd||(sd=new Promise((e=>{const t=i=>{Sd(t,xe.k3.SKIPPED),Sd(t,xe.k3.ERROR),e(i)};Rd(t,xe.k3.SKIPPED),Rd(t,xe.k3.ERROR);try{ad.skipAd()}catch(e){t(new Be(e.message,{type:Pe}))}})),sd),md=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return null===ad?(ed.log("callStopAd: nothing to stop"),Promise.resolve()):rd||(ed.log("callStopAd: creating new promise"),rd=new Promise((t=>{const i=e=>{Sd(i,xe.k3.STOPPED),Sd(i,xe.k3.ERROR),t(e)};Rd(i,xe.k3.STOPPED),Rd(i,xe.k3.ERROR),setTimeout((()=>{try{ad.stopAd(e)}catch(e){i(new Be(e.message,{type:Le}))}}),0)})).catch((()=>ed.error("callStopAd: error!"))).finally((()=>ed.log("callStopAd: finished"))),rd)},Ad=()=>md(),vd=()=>{const e=new Be(le.AD_UNIT_CANCEL,{type:Ee});od.forEach((t=>{t.forceReject(e)})),od=[],Id(),gd()},gd=()=>{td=null,id=null,nd=null,rd=null,sd=null},Td=e=>{const t=(e=>{let t,i;const n=new Promise(((e,n)=>{t=e,i=n})),r=Promise.race([e,n]);return r.forceResolve=t,r.forceReject=i,r})(e);return od.push(t),t.catch((e=>{throw e&&e.type===Ee&&ad&&(ed.log("VPAID aborted, calling stopAd"),ad.stopAd()),e}))},Rd=(e,t)=>{dd.push({event:t,handler:e}),ad&&ad.subscribe(e,t)},Sd=(e,t)=>{dd.forEach(((i,n,r)=>{i.event===t&&i.handler===e&&(ad&&ad.unsubscribe(i.handler,i.event),r.splice(n,1))}))},Id=()=>{ad&&dd.forEach((e=>{ad.unsubscribe(e.handler,e.event)})),dd=[]},fd={unsubscribeAll:Id},Dd=T("Ads","HeavyAds"),Ld="HeavyAdIntervention",kd=e=>{if(!e)return;const t=M(),i=[];e.forEach((e=>{if(e.body?.id===Ld){const n=Od(e.body.message);N()?i.push(n):(t.sendEventToEventBus(n),t.eventBusEmitter._emitEvents(!0),Dd.log("Sent Event Bus event",n))}})),N()&&(Dd.log("Sending reports to PES",e),ae.dispatchEvent(oe.PLAYER_HEAVYADSINTERVENTION_CHANGED,{playerHeavyAdsInterventionReports:[...e],playerHeavyAdsEvents:i}))},Pd=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!("ReportingObserver"in window))return void Dd.log("ReportingObserver not supported",e);Dd.log("Observing",e);const n=new window.ReportingObserver((e=>{Dd.log("Got reports (ReportingObserver)",e),t(e)}),{types:["intervention"],buffered:!0});null!==i&&i>=0&&ne().is_dm_network&&(Dd.log(`Emulating Heavy Ads in ${i}ms`),setTimeout((()=>{const e=[{body:{id:Ld,message:"Ad was removed (emulation)"}}];Dd.log("Got reports (emulation)",e),t(e)}),i)),n.observe(),e.addEventListener("pagehide",(()=>{const e=n.takeRecords();Dd.log("Got reports (pagehide)",e),t(e)}))},yd=e=>{if(!e)return;const t=e.find((e=>e.body?.id===Ld));t&&ae.dispatchEvent(oe.AD_ERROR,new Be(t.body.message,{type:Ee}))},Od=e=>{const t=M(),i=cd()||{},n={ad_remaining_ms:Object.keys(i).length?Math.round(i.getAdRemainingTime()):null,ad_running:pn.isAdSlotRunning,autoplay:G().autoplay,embedder:te(),intervention_message:e,playback_is_paused:j().isPaused,playback_is_playing:j().isPlaying,top_domain:ie(),inventory_id:pn.inventoryId,bid_id:pn.bidid,bidder_id:pn.bid,deal_id:pn.did,view_id:B("viewId")};return t.createEventBusEvent({name:"advertising.heavyAdsIntervention",data:n})};function bd(e){let{id:t,siblingNode:i,url:n}=e;return new Promise(((e,r)=>{const s=document.createElement("iframe");I("PV5_IFRAME_ALLOW_ATTRIBUTES")&&(s.allow="accelerometer; ambient-light-sensor; battery; camera; gyroscope; magnetometer; microphone;"),s.id=t,s.classList.add("no-border"),s.scrolling="no",i.parentNode.insertBefore(s,i.nextSibling);s.contentWindow.document.open().write(''),s.contentWindow.onBodyLoaded=t=>{const i=t.createElement("script");i.src=n,i.addEventListener("load",(()=>{e(s)})),i.addEventListener("error",(()=>{r(s)})),t.body.appendChild(i)},s.contentWindow.document.close(),Pd(s.contentWindow,yd)}))}const Cd=T("Ads","IMASdkHandler");const Nd=new class{constructor(){this.videoSlot=null,this.containerSlot=null,this.iFrame=null,this.adUnit=null,this.adsLoader=null,this.adDisplayContainer=null}async load(e){let{locale:t,videoElement:i}=e;this.videoSlot=i;const n={id:"ima_frame_sdk",siblingNode:this.videoSlot,url:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"};try{const e=await bd(n);D().metric("imaIframeCallback").start(),this.iFrame=e,this.iFrame.classList.add("ima_frame_sdk"),this.setImaContainerSlot(),this.setAdUnit(),this.initAdUnitSettings({locale:t}),this.adDisplayContainer=new this.adUnit.AdDisplayContainer(this.containerSlot,this.videoSlot),this.adsLoader=new this.adUnit.AdsLoader(this.adDisplayContainer),Cd.log("IMA sdk loaded"),D().metric("imaIframeCallback").end(),ae.dispatchEvent(oe.AD_SLOT_INJECTED,{element:this.containerSlot})}catch(e){D().metric("imaIframeCallback").end(),Cd.log("IMA sdk cannot be loaded"),this.unload(),ae.dispatchEvent(oe.AD_STACK_ERROR,{adError:new Be("IMA SDK load failed",{type:he})})}}setAdUnit(){this.adUnit=this.iFrame.contentWindow.google.ima}setImaContainerSlot(){this.containerSlot=document.createElement("div"),this.containerSlot.classList.add("ima_slot","ima_slot_hidden"),this.videoSlot.parentNode.insertBefore(this.containerSlot,this.iFrame.nextSibling)}initAdUnitSettings(e){let{locale:t}=e;this.adUnit.settings.setLocale(t),this.adUnit.settings.setPlayerType("dailymotion/player-html5"),this.adUnit.settings.setPlayerVersion("5.0.0"),this.adUnit.settings.setFeatureFlags({enableOmidBeta:!0}),this.adUnit.settings.setVpaidMode(this.adUnit.ImaSdkSettings.VpaidMode.INSECURE),this.adUnit.settings.setNumRedirects(9)}catchUserAction(){this.adDisplayContainer&&(Cd.log("adDisplayContainer initialized (user action)"),this.adDisplayContainer.initialize(),O().isIphone()&&this.videoSlot.load())}isIMALoaded(){return!!this.adUnit}prepareImaContainerSlot(){if(!this.containerSlot)return;this.containerSlot.classList.remove("ima_slot_hidden"),this.containerSlot.classList.add("ima_slot_visible");const e=this.containerSlot.querySelector("video");e&&e.classList.add("ima_slot_video")}getImaContainerSlot(){return this.containerSlot}cleanAdUnit(){this.containerSlot&&(this.containerSlot.classList.remove("ima_slot_visible"),this.containerSlot.classList.add("ima_slot_hidden"))}notifyContentVideoEnd(){this.adsLoader&&(Cd.log("notifying IMA that the content video is completed"),this.adsLoader.contentComplete())}unload(){this.containerSlot&&(this.containerSlot.parentNode.removeChild(this.containerSlot),this.containerSlot=null),this.iFrame&&(this.iFrame.parentNode.removeChild(this.iFrame),this.iFrame=null),this.videoSlot=null,Cd.log("IMA sdk unloaded")}isLoaded(){return!!this.iFrame}},Ud=T("Ads","CookieSync"),wd=()=>{let e=0;const t=()=>{if(5===e)return ae.removeEventListener(oe.PLAYER_VIDEO_SELECTED,t),void Ud.log("CookieSync aborted, 5 cap reached");Ud.log("Calling CookieSync after video selected"),i()};Ud.log("Trying CookieSync on every new video"),ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,t);const i=()=>{const{getTcfConsentString:e,isEnabledForTcf:t}=f();if(t()){Ud.log("Infopack available for CookieSync");const t=()=>{Ud.log("Calling CookieSync after consent resolved"),ae.removeEventListener(oe.PLAYER_GDPR_CONSENT_COLLECTION_RESOLVED,t),n()};if(m?.getConsentGdprCollectionRequested())return Ud.log("Consent already requested, waiting for resolution"),void ae.addEventListener(oe.PLAYER_GDPR_CONSENT_COLLECTION_RESOLVED,t);if(""===e())return Ud.log("Requesting consent"),ae.addEventListener(oe.PLAYER_GDPR_CONSENT_COLLECTION_RESOLVED,t),void ae.dispatchEvent(oe.PLAYER_GDPR_CONSENT_COLLECTION_REQUESTED)}Ud.log("Calling CookieSync without waiting for Infopack"),n()},n=()=>{const t=S()?(()=>{const e=Fr(),t=ne().reader_id||0;return e.stage,`${e.prod}?bs=1&rid=${t}`})():B("adSyncScriptUrl");if(!P())return!1;if(!t)return Ud.log("CookieSync URL not available for this video"),!1;e++;const i=Hr(t,{cookie_sync_ab_gk:I("PV5_COOKIE_SYNC_AB_TEST")?"1":"0",...nr(),...X(),...rr(),...Zn()}),n=document.createElement("script");return n.src=i,n.async=!0,document.body.appendChild(n),Ud.log("Doing ad cookie sync, url:",i),!0}},Vd=()=>{const e=U(),t=W();if(t.isConnecting||t.isActive)return xe.dx.CHROMECAST_SESSION;const i=e&&!I("PV5_ADS_ON_REPLAY_ONSITE"),n=!e&&!I("PV5_ADS_ON_REPLAY_OFFSITE");return q().isReplay&&(i||n)?xe.dx.VIDEO_REPLAY:void 0},Md=()=>{if(Vd())return Vd();switch(qe.position){case xe.ev.PREROLL:return(()=>{if(q().isReloadingLiveAfterPause)return xe.dx.NON_DVR_LIVE_PLAYBACK_TOGGLING})();case xe.ev.MIDROLL:return q().isSchedulerEnabled?Q().isLive?xe.dx.LIVE_MIDROLL_DISABLED:Q().mimeType!==xe.VS.Od?xe.dx.STREAM_NOT_HLS:void 0:xe.dx.SCHEDULER_DISABLED;case xe.ev.LIVEADBREAK:return(()=>{if(!q().isSchedulerEnabled)return xe.dx.SCHEDULER_DISABLED;if(j().isPaused)return xe.dx.LIVE_ADBREAKS_PAUSED_PLAYBACK;const{isVideoSeekable:e,isCurrentTimeDVR:t}=j();return e&&!t?xe.dx.LIVE_ADBREAKS_DVR_NOT_LIVE:void 0})()}},Bd=T("Player","Scheduler","AdsScheduling");let xd=0,Fd=null,Kd=null;const Hd=()=>{Fd=null},Yd=()=>{jd()||(Fd=j().currentTime)},Gd=()=>{if(qe.linearSlotStarted)return;const e=Math.trunc(j().currentTime);xd>0&&Kd!==e&&(xd--,Kd=e)},Qd=()=>{xd=0,Fd=null,Kd=null,ae.removeEventListener(oe.AD_LINEAR_BREAK_STARTED,Hd),ae.removeEventListener(oe.PLAYER_SEEK_REQUESTED,Yd),ae.removeEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,Gd),ae.removeEventListener(oe.AD_VIDEO_START,Zd)},jd=()=>zd()&&Boolean(xd),qd=()=>{ae.addEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,Gd.bind(null,Kd)),ae.addEventListener(oe.AD_VIDEO_START,Zd)},$d=(e,t)=>i=>{let{requested:n,cuepoint:r}=i;return e<=r&&r<=t&&!n},Wd=e=>t=>{let{requested:i,cuepoint:n}=t;return e===n&&!i},zd=()=>(U()?I("PV5_MIDROLL_RETAKE_ONSITE"):I("PV5_MIDROLL_RETAKE_OFFSITE"))&&Xd(),Xd=()=>B("duration")>=1200,Zd=()=>{!xd&&qe?.current?.isARetake&&(xd=120)},Jd=()=>ee("waitForCustomConfigDelay",6),el=()=>Y("waitForCustomConfig"),tl=()=>{const e=sl();if(e)return void ol(e,xe.ev.MIDROLL);const t=al();t&&ol(t,xe.ev.POSTROLL)},il=()=>{if(dl())return;const e=rl();e&&ol(e,qe.position)},nl=e=>{if(!e.some((e=>{let{requested:t,isDelayed:i}=e;return!t&&i})))return e.find((e=>{let{requested:t,isDelayed:i}=e;return!t&&!i}))},rl=()=>{if(qe.current&&qe.position&&!pn.isNonLinear&&pn.hasStarted)return nl(Ql())},sl=()=>{if(!qe.adBreaks.midrolls.length||qe.current||jd())return;const e=j().currentTime,t=qe.adBreaks.midrolls.filter((t=>{let{requested:i,cuepoint:n}=t;return n-Jd()-wl<=e&&e<=n+wl&&!i}));return nl(t)},al=()=>{const{currentTime:e,videoDuration:t}=j();if(!(t-e>Jd()||qe.current||jd()))return nl(qe.adBreaks.postrolls)},ol=(e,t)=>{e.delay(oe.PLAYER_API_SET_CUST_CONFIG,Bd),qe.nextPosition=t,ae.dispatchEvent(oe.AD_BREAK_WILL_START,{position:t,nextAdBreak:e}),Bd.log(`${t} ad will be played soon :`,e)},dl=()=>qe.position===xe.ev.PREROLL&&U()&&!I("PV5_TEMP_WAIT_CUST_CONF_VMAP");const ll=class{constructor(e){this.id=e.getAttribute("id"),this.allowMultipleAds=e.getAttribute("allowMultipleAds"),this.followRedirects=e.getAttribute("followRedirects"),this.vastAdData=null,this.adTagURI=null,this.customData=null;for(const t in e.childNodes){const i=e.childNodes[t];switch(i.localName){case"AdTagURI":this.adTagURI={templateType:i.getAttribute("templateType"),uri:(i.textContent||i.text||"").trim()};break;case"VASTAdData":for(this.vastAdData=i.firstChild;this.vastAdData&&1!==this.vastAdData.nodeType;)this.vastAdData=this.vastAdData.nextSibling;break;case"CustomAdData":this.customData=i}}}};function cl(e,t){const i=[];for(const n in e.childNodes){const r=e.childNodes[n];r.nodeName!==t&&t!==`vmap:${r.nodeName}`&&r.nodeName!==`vmap:${t}`||i.push(r)}return i}function ul(e){const t={attributes:{},children:{},value:{}};t.value=function(e){if(!e||!e.childNodes)return{};const t=e.childNodes,i=[];for(const e in t){const n=t[e];"#cdata-section"===n.nodeName&&i.push(n)}if(i&&i.length>0)try{return JSON.parse(i[0].data)}catch(e){}let n="";for(const e in t){const i=t[e];switch(i.nodeName){case"#text":n+=i.textContent.trim();break;case"#cdata-section":n+=i.data}}return n}(e);const i=e.attributes;if(i)for(const e in i){const n=i[e];n.nodeName&&void 0!==n.nodeValue&&null!==n.nodeValue&&(t.attributes[n.nodeName]=n.nodeValue)}const n=e.childNodes;if(n)for(const e in n){const i=n[e];i.nodeName&&"#"!==i.nodeName.substring(0,1)&&(t.children[i.nodeName]=ul(i))}return t}const hl=class{constructor(e){this.timeOffset=e.getAttribute("timeOffset"),this.breakType=e.getAttribute("breakType"),this.breakId=e.getAttribute("breakId"),this.repeatAfter=e.getAttribute("repeatAfter"),this.adSource=null,this.trackingEvents=[],this.extensions=[];for(const t in e.childNodes){const i=e.childNodes[t];switch(i.localName){case"AdSource":this.adSource=new ll(i);break;case"TrackingEvents":for(const e in i.childNodes){const t=i.childNodes[e];"Tracking"===t.localName&&this.trackingEvents.push({event:t.getAttribute("event"),uri:(t.textContent||t.text||"").trim()})}break;case"Extensions":this.extensions=cl(i,"Extension").map((e=>ul(e)))}}}track(e,t){for(const i in this.trackingEvents){const n=this.trackingEvents[i];if(n.event===e){let{uri:e}=n;"error"===n.event&&(e=e.replace("[ERRORCODE]",t)),this.tracker(e)}}}tracker(e){if("undefined"!=typeof window&&null!==window){(new Image).src=e}}};const pl=class{constructor(e){if(!e||!e.documentElement||"VMAP"!==e.documentElement.localName)throw new Error("Not a VMAP document");this.version=e.documentElement.getAttribute("version"),this.adBreaks=[],this.extensions=[];for(const t in e.documentElement.childNodes){const i=e.documentElement.childNodes[t];switch(i.localName){case"AdBreak":this.adBreaks.push(new hl(i));break;case"Extensions":this.extensions=cl(i,"Extension").map((e=>ul(e)))}}}},El=(e,t)=>_l(e,t)||ml(e),_l=(e,t)=>{let[,i]=e.match(/^([0-9]{1,3})%$/)||[null,null];return null==i?null:(i=Number(i),i<0||i>100?null:Math.floor(i*t/100))},ml=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const[t,i,n,r]=e.match(/^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]{3})?$/)||[null,null,null,null];if(null==t)return null;return 60*i*60+60*n+Number(r)};function Al(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce(((e,t)=>{const i=t.attributes.source;return"dailymotion"!==i&&"dmx"!==i||"object"!=typeof t.value?e:{...e,...t.value}}),{})}class vl{constructor(e){let{endEvent:t,logger:i}=e;this.resolvePromise=null,this.promise=null,this.delayRequestTimeoutId=null,this.initPromise(t,i),ae.addEventListener(t,this.onEndEvent)}onEndEvent=()=>{this.resolvePromise("holder callback")};waitForCustomConfig(){return this.promise}async initPromise(e,t){this.promise=new Promise((e=>{this.resolvePromise=e,this.delayRequestTimeoutId=setTimeout((()=>{ae.dispatchEvent(oe.AD_LOG,xe.r0.AD_READY_TO_FETCH_TIMEOUT),e("holder timeout")}),1e3*ee("waitForCustomConfigDelay",6))}));const i=await this.promise;t.log(`Resolving the delayed ad request promise from ${i}`),clearTimeout(this.delayRequestTimeoutId),ae.removeEventListener(e,this.onEndEvent)}}class gl{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;this._vmapAdBreak=e,this._adSource=this._vmapAdBreak.adSource,this.cuepoint=i,this.requested=!1,this.id=n,this.isDelayed=!1,this.requestDelayer=null,this.hasDoneFallback=!1,this.isARetake=!1,this.extension={timeout:4e3,...t,...Al(this._vmapAdBreak.extensions)},this.errorMessage=""}track(e,t){this._vmapAdBreak.track(e,t)}hasSupportedAdSource(){if(!this._adSource.vastAdData){const e=/^vast[1-4]?$/;this._adSource.adTagURI?this._adSource.adTagURI.uri?this._adSource.adTagURI.templateType.match(e)||(this.errorMessage=`adTagURI templateType - ${this._adSource.adTagURI.templateType} - invalid`):this.errorMessage="adTagURI.uri undefined":this.errorMessage="No vastAdData nor adTagURI defined"}return!this.errorMessage}setAdSource(e){let{vastAdData:t,adTagURI:i}=e;this._adSource={vastAdData:t,adTagURI:i}}getAdSource(){return this._adSource}setToRequested(){this.requested=!0}delay(e,t){this.requestDelayer=new vl({endEvent:e,logger:t}),this.isDelayed=!0}markFallbackDone(){this.hasDoneFallback=!0}markAsRetake(){this.isARetake=!0}}const Tl=T("AdStackDM"),Rl=async function(e){let{clientType:t,duration:i,errorUrl:n,volume:r,topDomain:s,isRealAutoplay:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return Promise.reject();e=Vn(e);const o=await pr(),d=await lr(),l=await cr(a),c=await(async()=>{await A.waitForPlayerSize;const e=A.width,t=A.height;return e&&t?{ps:`${e}x${t}`}:{}})(),u=Hr(e,{...S()?{...yr(),...vr(),...gr(),...Rr(),...Sr(),...C()?{cin:1}:{},...U()?{cos:1}:{},...fr(),...Dr(),...Lr(),...kr(),...Pr(),...Or(),...Tr(),...Zn()}:{},...c,...zn(t),...Xn(s),...nr(),...rr(),...X(),...or(r,l),...dr(),...ur(),...hr(),...Er(),..._r(),...mr(),...sr(),...Ar(),"3pcb":P()?"0":"1",rap:l.rap,...o,...d,...Ir(),apo:ee("adPressureOptimization")??"monetization",...Nr(),...I("PV5_LEO_AD_PLACEMENT_QS")?{plcmt:U()?1:2}:{},...Ur(),...Vr(),...Mr(),...wr(),...br(r,l)});return Tl.log("Fetching ad_url:",u),ha({action:sa,component:na,url:u}),D().metric("vmapLoad").start(),fi(u,{errorUrl:Vn(n),timeoutErrorCode:1107,failedErrorCode:1108,timeout:8e3}).then((e=>{let{data:t,httpStatus:n,byteLength:r,duration:s}=e;return D().metric("vmapLoad").end(),((e,t)=>{qr={byteLength:e,duration:t,sent:!1}})(r,s),ha({action:oa,callLatency:s,component:na,responseType:ca,statusCode:n,url:u}),Me.value=n,Sl(t,{duration:i})})).catch((e=>{D().metric("vmapLoad").end(),ha({action:oa,callLatency:e.duration,component:na,responseType:e.httpStatus===Ii?la:da,statusCode:e.httpStatus,url:u}),Me.value=e.httpStatus;throw new Be(`Unreacheable Ad Director url (${e})`,{type:ce})}))},Sl=(e,t)=>{let{duration:i}=t;return Promise.resolve().then((()=>{const t=new pl((new DOMParser).parseFromString(e,"text/xml"));Tl.log("Creating CuePoints from VMAP",t);const n=Al(t.extensions),r={prerolls:[],midrolls:[],postrolls:[],liveAdBreaks:[]};return t.adBreaks.forEach((e=>{if(!e.breakType.split(",").includes("display"))switch(e.timeOffset){case"start":r.prerolls.push(new gl(e,n,null,e.breakId));break;case"end":r.postrolls.push(new gl(e,n,null,e.breakId));break;default:{if(e.timeOffset.indexOf("#")>-1)return void r.liveAdBreaks.push(new gl(e,n,null,e.breakId));if(R()){qe.vmapData=t;break}const s=El(e.timeOffset,i);if(s&&(r.midrolls.push(new gl(e,n,s,`${e.id}_${s}`)),e.repeatAfter)){const t=El(e.repeatAfter,i),a=i-30;let o=s+t;for(;o<=a;)r.midrolls.push(new gl(e,n,o,`${e.id}_${o}`)),o+=t}}}})),r.midrolls.sort(((e,t)=>e.cuepoint-t.cuepoint)),r.liveAdBreaks.sort(((e,t)=>parseInt(e._vmapAdBreak.timeOffset.replace("#",""),10)-parseInt(t._vmapAdBreak.timeOffset.replace("#",""),10))),r.liveAdBreaks.length>0&&Tl.log("Parsed live ad breaks",r.liveAdBreaks),r}))},Il=async e=>{const t=new gl({},{},null,"preroll1");ae.dispatchEvent(oe.AD_BREAK_WILL_START,{position:jn.e.PREROLL,nextAdBreak:t}),e&&Object.keys(y()).length||await(async()=>{const e=new vl({endEvent:oe.PLAYER_API_SET_CUST_CONFIG,logger:Bd});Bd.log("Delaying VMAP fetching"),await e.waitForCustomConfig()})()},fl=T("Player","Scheduler","AdsScheduling");let Dl=!0;const Ll=async(e,t)=>{fl.log("Requesting Ads"),ae.dispatchEvent(oe.AD_VMAP_REQUESTED);const{adUrl:i,errorUrl:n}=((e,t)=>{if(!S())return{adUrl:B("adUrl"),errorUrl:B("adErrorUrl")};const i=Kr(e,t);return{adUrl:i.adUrl,errorUrl:i.errorUrl}})(e,t),r={clientType:k(),duration:B("duration"),volume:F(),errorUrl:n,topDomain:ie(),isRealAutoplay:K()};return(()=>{const e=!U(),t=I("PV5_TEMP_WAIT_CUST_CONF_VMAP");return el()&&(e||t)})()&&await Il(Dl),Dl=!1,Rl(i,r).catch((e=>{const t=(i={code:e.type,message:e.message},m?.createError(i));var i;throw ae.dispatchEvent(oe.PLAYER_ERROR,t),e}))},kl=e=>e.map((e=>`${Math.floor(e.cuepoint/3600)}:${Math.floor(e.cuepoint%3600/60)}:${e.cuepoint%60}`));let Pl=[],yl=-1,Ol=!1;const bl=()=>{const e=qe.adPods.length&&qe.adPodIndex+1===qe.adPods.length&&!qe.adBuffet.length;if(qe.adPods.length&&qe.adPodIndex+1{var t;qe.linearSlotStarted||ae.dispatchEvent(oe.AD_LINEAR_BREAK_STARTED,{position:qe.position}),el()&&(t=e,qe.position===xe.ev.PREROLL&&qe.isFirstAdBreakForAdSlot||t.isDelayed||dl()||ol(t,qe.position)),e.setToRequested(),qe.current=e,qe.adSlotTotalAdBreaks=Pl.length,qe.currentAdBreakIndex=yl,ae.dispatchEvent(oe.AD_BREAK_STARTED)},Nl=()=>{ae.addEventListener(oe.AD_STOPPED,bl),ae.addEventListener(oe.AD_SKIPPED,bl),ae.addEventListener(oe.AD_LINEAR_STOPPED,bl),ae.addEventListener(oe.RESET_CURRENT_AD_BREAK,bl),ae.addEventListener(oe.PLAYER_LOAD_VIDEO,Ul)},Ul=()=>{Pl=[],yl=-1,Ol=!0,ae.removeEventListener(oe.AD_STOPPED,bl),ae.removeEventListener(oe.AD_SKIPPED,bl),ae.removeEventListener(oe.AD_LINEAR_STOPPED,bl),ae.removeEventListener(oe.RESET_CURRENT_AD_BREAK,bl),ae.removeEventListener(oe.PLAYER_LOAD_VIDEO,Ul),Wo=[],zo=[]},wl=2;let Vl=null,Ml=0;const Bl=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;R()&&je.reset();try{const n=await Ll(t,i),r=window.performance.measure("vmap_received","vital_player_enter")?.duration;ae.dispatchEvent(oe.AD_LOG,{...xe.r0.VMAP_RECEIVED_DURATION,value:r}),ae.dispatchEvent(oe.AD_VMAP_RECEIVED,{shouldSubscribeEvent:!0}),qe.adBreaks=n,Bd.log("AdBreaks cue points",n),R()?qe.fetchedViewId=e:Bd.log("Registering midroll adBreaks",kl(n.midrolls))}catch(e){return Promise.reject(e)}},xl=()=>{el()&&(ae.addEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,(()=>{tl()})),ae.addEventListener(oe.AD_STARTED,(()=>{il()}))),ae.addEventListener(oe.PLAYER_VIDEO_ENDED,(()=>{Kl(xe.ev.POSTROLL)})),ae.addEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,(()=>{if(!Hl())return;const e=jl();e.length&&Fl(xe.ev.MIDROLL,e)})),ae.addEventListener(oe.PLAYER_LOAD_VIDEO,(()=>{Vl=null}))},Fl=(e,t)=>{if(qe.position=e,!$l())return Gl(),void Wl();(e=>{e?.length&&(Ol=!1,Nl(),Pl=e,bl())})(t)},Kl=e=>{qe.position=e;const t=Ql();t.length?Fl(e,t):(Bd.log("Ad slot request failed - no adbreak for",qe.position),Wl())},Hl=()=>qe.adBreaks.midrolls.length>0&&(!qe.position||pn.isNonLinear),Yl=()=>{const e=qe.adBreaks.liveAdBreaks;if(!e.length||!qe.isFirstAdBreakForAdSlot)return null;const t=qe.adBreaks.liveAdBreaks[Ml];return Ml=Ml{Ql().forEach((e=>e.setToRequested()))},Ql=()=>{switch(qe.position){case xe.ev.PREROLL:return qe.adBreaks.prerolls;case xe.ev.POSTROLL:return ql();case xe.ev.LIVEADBREAK:return qe.adBreaks.liveAdBreaks;case xe.ev.MIDROLL:return jl();default:return[]}},jl=()=>{if(jd())return[];const e=j().currentTime;let t=qe.adBreaks.midrolls.filter((i=e,e=>{let{requested:t,cuepoint:n}=e;return Math.abs(i-n)<=wl&&!t}));var i;return t.length||!zd()||xd||(t=(e=>{if(!Fd)return[];let t=[];const i=qe.adBreaks.midrolls.find($d(Fd,e));return i&&(t=qe.adBreaks.midrolls.filter(Wd(i.cuepoint)),t.forEach((e=>{e.markAsRetake()}))),Fd=null,t})(e)),t},ql=()=>jd()?[]:qe.adBreaks.postrolls,$l=()=>{if(Boolean(Md())){const e=Md();return ae.dispatchEvent(oe.AD_LOG,{...xe.r0.PERMANENT_EXCLUSION,name:e}),Bd.log(`Ad slot request denied - ${e}`),!1}return!0},Wl=()=>{qe.linearSlotStarted?setTimeout((()=>{ae.dispatchEvent(oe.AD_LINEAR_BREAK_ENDED,{position:qe.position})}),0):(qe.position===xe.ev.POSTROLL?ae.dispatchEvent(oe.PLAYER_SCHEDULER_END_SEQUENCE):qe.position===xe.ev.PREROLL&&Z(),qe.position=null)},zl=()=>{if(!qe.vmapData?.adBreaks)return;const e=B("duration"),t=Al(qe.vmapData?.extensions);qe.vmapData.adBreaks.filter((e=>!["start","end"].includes(e.timeOffset)||e.timeOffset.indexOf("#"))).map((i=>{const n=El(i.timeOffset,e);if(n&&(qe.adBreaks.midrolls.push(new gl(i,t,n,`midroll_${n}_${qe.adBreaks.midrolls.length}`)),i.repeatAfter)){const r=El(i.repeatAfter,e),s=e-30;let a=n+r;for(;a<=s;)qe.adBreaks.midrolls.push(new gl(i,t,a,`midroll_${n}_${qe.adBreaks.midrolls.length}`)),a+=r}})),Bd.log("Registering, after parallel ads call, midroll adBreaks",kl(qe.adBreaks.midrolls))},Xl={getAd:()=>pn,getAdBreak:()=>qe,start:async()=>{try{Vl?await Vl:await Bl(),Kl(xe.ev.PREROLL),R()&&zl(),Qd(),zd()&&(qd(),ae.addEventListener(oe.AD_LINEAR_BREAK_STARTED,Hd),ae.addEventListener(oe.PLAYER_SEEK_REQUESTED,Yd))}catch(e){Bd.log("Error while getting ads",e),Z()}},fetchAds:function(){return Vl=Bl(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null),Vl},updatePlayerDependencies:e=>{g(e)},startLiveAdBreak:()=>{Fl(xe.ev.LIVEADBREAK,[Yl()])},stopAd:Ad,adEventEmitter:ae,positions:xe.ev,AdEvents:oe,isSkipIgnored:()=>Boolean(Ys()),adsDisabledReason:Vd,catchUserAction:()=>{Nd.catchUserAction()},AdSdkHandler:E,IMASdkHandler:Nd,OmSdkUtils:r,getClickTrackingMacro:fn,getTrackingMacros:Nn,subscribe:Rd,unsubscribe:Sd};var Zl=i(6774),Jl=i.n(Zl);let ec=[],tc=[],ic=null;const nc=T("Player","PlayerDataLayer"),rc=oe.AD_LOADED,sc=[oe.AD_SKIPPED,oe.AD_STOPPED,oe.AD_ERROR],ac={[oe.AD_BUFFER_FINISH]:null,[oe.AD_BUFFER_START]:null,[oe.AD_CLICK]:null,[oe.AD_IMPRESSION]:null,[oe.AD_PAUSED]:null,[oe.AD_PLAYING]:null,[oe.AD_VIDEO_COMPLETE]:null,[oe.AD_VIDEO_FIRST_QUARTILE]:null,[oe.AD_VIDEO_MIDPOINT]:null,[oe.AD_VIDEO_START]:null,[oe.AD_VIDEO_THIRD_QUARTILE]:null,[oe.AD_VIDEO_VOLUME_CHANGED]:null,[oe.PLAYER_FULLSCREEN_CHANGED]:null},oc=e=>{!function(e,t){const{events:i,callback:n}=e;nc.log("dispatching",t,"to",{events:i,callback:n}),t.filter((t=>uc(e,t))).forEach((e=>{n(e)}))}(e,ec),tc.push(e)},dc=e=>{tc=tc.filter((t=>t.id!==e))},lc=()=>{Object.keys(ac).forEach((e=>{ac[e]=t=>Ec(e,t),ae.addEventListener(e,ac[e])})),ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,pc)},cc=()=>{Object.keys(ac).forEach((e=>{ae.removeEventListener(e,ac[e]),ac[e]=null}))},uc=(e,t)=>{let{events:i,inventoryIdValue:n=null,clientFallbackIndex:r=null}=e;const s=i.includes(t.name),a=!(n&&n!==t.data.inventoryIdValue||r&&r!==t.data.clientFallbackIndex);return s&&a};function hc(e){const{volume:t,muted:i}=F();return{...e,adLinearIsRunning:pn.isAdSlotRunning,duration:pn.duration,volume:t,muted:i,inventoryIdValue:pn.clientInventoryId,clientFallbackIndex:pn.clientFallbackIndex}}const pc=()=>{nc.log("Reset DataLayer"),ec=[],ic=null},Ec=(e,t)=>{const i={name:e,data:t};if(Jl()(ic,i))return;ic=i;const n={name:e,data:hc(t)};!function(e,t){nc.log("dispatching",e,"to",t),t.filter((t=>uc(t,e))).forEach((t=>{let{callback:i}=t;i(e)}))}(n,tc),ec.push(n)};var _c=i(9265);const mc="OMSDK_WEB",Ac={name:rn.IA.START,triggeringEvent:[oe.AD_LOADED]},vc=[{name:rn.IA.ERROR,triggeringEvent:[oe.AD_ERROR]},{name:rn.IA.FINISH,triggeringEvent:[oe.AD_SKIPPED,oe.AD_STOPPED]}],gc={impression:[oe.AD_IMPRESSION],loaded:[oe.AD_LOADED],start:[oe.AD_VIDEO_START],firstQuartile:[oe.AD_VIDEO_FIRST_QUARTILE],midpoint:[oe.AD_VIDEO_MIDPOINT],thirdQuartile:[oe.AD_VIDEO_THIRD_QUARTILE],complete:[oe.AD_VIDEO_COMPLETE],pause:[oe.AD_PAUSED],resume:[oe.AD_PLAYING],bufferStart:[oe.AD_BUFFER_START],bufferFinish:[oe.AD_BUFFER_FINISH],skipped:[oe.AD_SKIPPED],volumeChange:[oe.AD_VIDEO_VOLUME_CHANGED],playerStateChange:[oe.PLAYER_FULLSCREEN_CHANGED],adUserInteraction:[oe.AD_CLICK]},Tc=T("Stats","Omsdk"),Rc=[],Sc=()=>{if(!I("PV5_OMSDK"))return!1;return"full"===new URL(window.location.href).searchParams.get("access_mode")||!(O().isTv()||C())},Ic=e=>(t,i)=>{const n=kc(i.inventoryIdValue,i.clientFallbackIndex);switch(t.name){case rn.IA.START:{Tc.log("AdSession started for",{inventoryIdValue:i.inventoryIdValue,clientFallbackIndex:i.clientFallbackIndex},"with following session",e);const{sessionIframes:t}=e.start();Tc.log("OMID iframes",t);break}case rn.IA.ERROR:if(!n)return;Tc.log("AdSession error",i?.adError?.message),e.error("generic",i?.adError?.message),Oc(e,i);break;case rn.IA.FINISH:Oc(e,i)}},fc=e=>{try{const t=te(),i=H();return(0,_c.Xu)(e,t,i)}catch(e){return Tc.log("Unable to initialize AdSession",e),null}},Dc=e=>{const t=Lc();return e.map((e=>{const{resource:i,vendor:n,parameters:r}=e;return new _c.G3.VerificationScriptResource(i,n,r,t)}))},Lc=()=>{try{const e=new URL(window.location.href).searchParams.get("access_mode");return e&&rn.g8.includes(e)?e:rn.VP}catch{return rn.VP}},kc=(e,t)=>Rc.find((i=>i.inventoryIdValue===e&&i.clientFallbackIndex===t)),Pc=(e,t)=>{if("impression"===e)return Tc.log("OMSDK","Impression event reported"),_c.UV.impressionOccurred();const i=yc(e,t),n=Object.values(i);return Tc.log(`Reporting event ${e}${n.length?` with params ${JSON.stringify(i)}`:""}`),"loaded"===e?_c.UV.loaded(i):"error"===e?_c.UV.adSession?.error(i):_c.G$[e](...n)},yc=(e,t)=>{switch(e){case"loaded":return new _c.G3.VastProperties(...Object.values(Bn(t)));case"start":return{duration:t.duration,volume:t.muted?0:t.volume};case"playerStateChange":return{playerState:x().viewMode};case"volumeChange":return{volume:t.muted?0:t.volume};case"adUserInteraction":return{interactionType:"click"};default:return{}}},Oc=(e,t)=>{let{inventoryIdValue:i,clientFallbackIndex:n}=t;kc(i,n)&&(Tc.log("AdSession finished for",{inventoryIdValue:i,clientFallbackIndex:n}),e.finish().then((e=>{let{removedIframes:t}=e;t.forEach((e=>{Tc.log("Removed iframe",e,"for AdSession",{inventoryIdValue:i,clientFallbackIndex:n})}))})),bc(i,n))},bc=(e,t)=>{[Ac,...vc].forEach((i=>{dc(`${mc}_${e}_${t}_${i.name}`)})),rn.I8.forEach((i=>{dc(`${mc}_${e}_${t}_${i}`)}))},Cc=(e,t,i,n)=>{oc({id:`${mc}_${i}_${n}_${Ac.name}`,events:Ac.triggeringEvent,callback:function(){let{data:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{data:null};return e(Ac,t)},inventoryIdValue:i,clientFallbackIndex:n}),rn.I8.forEach((e=>{oc({id:`${mc}_${i}_${n}_${e}`,events:gc[e],callback:i=>{let{data:n}=i;return t(e,n)},inventoryIdValue:i,clientFallbackIndex:n})})),vc.forEach((t=>{oc({id:`${mc}_${i}_${n}_${t.name}`,events:t.triggeringEvent,callback:i=>{let{data:n}=i;return e(t,n)},inventoryIdValue:i})}))},Nc=()=>({adBreak:qe.current,adPause:!1,position:qe.position,proxyInitProtection:qe.position!==xe.ev.PREROLL,volume:F(),isRealAutoplay:K(),fallbackUrl:pn.fallbackUrl,fallbackMethod:pn.fallbackMethod}),Uc=e=>({position:qe.position,timeoutInfo:Gi(ai),integrator:pn.integratorName,...e}),wc=()=>({position:qe.position,settingsControls:Y("controls")}),Vc=T("Video","Ads"),Mc="linear";let Bc=null,xc=null,Fc=null;const Kc=(e,t)=>{ae.dispatchEvent(j().isPaused?oe.PLAYER_PLAY_REQUESTED:oe.PLAYER_PAUSE_REQUESTED,t)},Hc=()=>{xc=null,Fc=null,Yc(),Vc.log("startAd"),Ed().then((e=>{var t;xc=e,Jc(),gu(xc.adData),t=m?.getPlayerMainNode(),window.addEventListener("visibilitychange",va),pa=new IntersectionObserver((e=>{e.forEach((e=>{let{intersectionRatio:t}=e;Ea=t>=.5,Aa=Ea&&_a}))}),{threshold:ma}),pa.observe(t),xc.hasBufferStep&&Xc()})).catch((e=>{Vc.warn("callStartAd failed:",e);const t=ui(e,{position:qe.position,timeoutInfo:Gi()});ae.dispatchEvent(oe.AD_ERROR,{adError:t}),Zc()}))},Yc=()=>{ae.addEventListener(oe.PLAYER_CHROMECAST_SESSION_AVAILABLE,Gc),ae.addEventListener(oe.PLAYER_LOAD_VIDEO,Qc),ae.addEventListener(oe.PLAYER_PAUSE_REQUESTED,zc),ae.addEventListener(oe.PLAYER_PLAY_REQUESTED,Wc),A.on(qc),ae.addEventListener(oe.AD_SKIP_REQUESTED,$c),ae.addEventListener(oe.PLAYER_TOGGLE_PLAYBACK_REQUESTED,Kc),ae.addEventListener(oe.PLAYER_VIDEO_VOLUME_CHANGED,jc)},Gc=()=>{ku()},Qc=()=>{Zc()},jc=e=>{let{volume:t,muted:i,interactionType:n}=e;const r="number"==typeof t?Math.max(0,Math.min(t,1)):null;Fc=n,Du(r,i)},qc=()=>{Iu()},$c=()=>{fu()},Wc=()=>{Su()},zc=()=>{Ru()},Xc=()=>{$i(oi,new Promise((e=>{Bc=e}))).catch((e=>{ku(e)}))},Zc=()=>{xc=null,eu(),ae.removeEventListener(oe.PLAYER_CHROMECAST_SESSION_AVAILABLE,Gc),ae.removeEventListener(oe.PLAYER_LOAD_VIDEO,Qc),ae.removeEventListener(oe.PLAYER_PAUSE_REQUESTED,zc),ae.removeEventListener(oe.PLAYER_PLAY_REQUESTED,Wc),A.off(qc),ae.removeEventListener(oe.AD_SKIP_REQUESTED,$c),ae.removeEventListener(oe.PLAYER_TOGGLE_PLAYBACK_REQUESTED,Kc),ae.removeEventListener(oe.PLAYER_VIDEO_VOLUME_CHANGED,jc),pa.disconnect(),window.removeEventListener("visibilitychange",va)},Jc=()=>{xc&&(xc.subscribe(nu,xe.k3.BUFFER_FINISH),xc.subscribe(ru,xe.k3.BUFFER_START),xc.subscribe(mu,xe.k3.CLICK_THRU),xc.subscribe(_u,xe.k3.DURATION_CHANGE),xc.subscribe(Eu,xe.k3.ERROR),xc.subscribe(iu,xe.k3.IMPRESSION),xc.subscribe(ou,xe.k3.PAUSED),xc.subscribe(au,xe.k3.PLAYING),xc.subscribe(Tu,xe.k3.POD_ERROR),xc.subscribe(lu,xe.k3.RATIO_CHANGE),xc.subscribe(su,xe.k3.REMAINING_TIME_CHANGE),xc.subscribe(vu,xe.k3.SKIPPABLE_REMAINING_TIME_CHANGE),xc.subscribe(Au,xe.k3.SKIPPABLE_STATE_CHANGE),xc.subscribe(hu,xe.k3.SKIPPED),xc.subscribe(pu,xe.k3.STOPPED),xc.subscribe(gu,xe.k3.STARTED),xc.subscribe(cu,xe.k3.VIDEO_COMPLETE),xc.subscribe(tu,xe.k3.VIDEO_START),xc.subscribe(du,xe.k3.VOLUME_CHANGE))},eu=()=>{xc&&(xc.unsubscribe(nu,xe.k3.BUFFER_FINISH),xc.unsubscribe(ru,xe.k3.BUFFER_START),xc.unsubscribe(mu,xe.k3.CLICK_THRU),xc.unsubscribe(_u,xe.k3.DURATION_CHANGE),xc.unsubscribe(Eu,xe.k3.ERROR),xc.unsubscribe(iu,xe.k3.IMPRESSION),xc.unsubscribe(ou,xe.k3.PAUSED),xc.unsubscribe(au,xe.k3.PLAYING),xc.unsubscribe(Tu,xe.k3.POD_ERROR),xc.unsubscribe(lu,xe.k3.RATIO_CHANGE),xc.unsubscribe(su,xe.k3.REMAINING_TIME_CHANGE),xc.unsubscribe(vu,xe.k3.SKIPPABLE_REMAINING_TIME_CHANGE),xc.unsubscribe(Au,xe.k3.SKIPPABLE_STATE_CHANGE),xc.unsubscribe(uu,xe.k3.SKIPPED),xc.unsubscribe(hu,xe.k3.SKIPPED),xc.unsubscribe(pu,xe.k3.STOPPED),xc.unsubscribe(gu,xe.k3.STARTED),xc.unsubscribe(cu,xe.k3.VIDEO_COMPLETE),xc.unsubscribe(tu,xe.k3.VIDEO_START),xc.unsubscribe(du,xe.k3.VOLUME_CHANGE))},tu=()=>{Bc&&Bc(),Rs.finish()&&ae.dispatchEvent(oe.AD_LOG,xe.r0.AD_RESOLVED_OK),ae.dispatchEvent(oe.AD_VIDEO_START,{type:Mc,position:qe.position,timeoutInfo:Gi(oi),breakpointVerticalS:!1,settingsControls:Y("controls"),breakpointHorizontalXS:!1}),au(),Iu()},iu=()=>{Bc&&Bc(),ae.dispatchEvent(oe.AD_IMPRESSION,{type:Mc,...wc()})},nu=()=>{ae.dispatchEvent(oe.AD_BUFFER_FINISH)},ru=()=>{ae.dispatchEvent(oe.AD_BUFFER_START)},su=()=>{if(xc&&xc.getAdDuration()>0&&xc.getAdRemainingTime()>0){const e=xc.getAdDuration()-xc.getAdRemainingTime();ae.dispatchEvent(oe.PLAYER_VIDEO_TIME_UPDATE,{time:e})}},au=()=>{ae.dispatchEvent(oe.PLAYER_VIDEO_PLAY),ae.dispatchEvent(oe.PLAYER_VIDEO_PLAYING)},ou=()=>{ae.dispatchEvent(oe.PLAYER_VIDEO_PAUSE)},du=()=>{if(!xc)return;const{volume:e,muted:t}=xc.getAdVolume();"number"==typeof e&&"boolean"==typeof t&&(ae.dispatchEvent(oe.AD_VIDEO_VOLUME_CHANGED,{volume:e,muted:t,interactionType:Fc||"programmatic"}),Fc=null)},lu=e=>{ae.dispatchEvent(oe.PLAYER_CONTENT_SIZE_CHANGED,e)},cu=function(){let{endedReason:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Lu({endedReason:e||xe.Bj.COMPLETED})},uu=()=>{const e=xc?.getSkipAdLogs()||{};setTimeout((()=>{Lu({endedReason:e.isSmartSkip?xe.Bj.SMART_SKIPPED:xe.Bj.SKIPPED,skipDisplayed:e.skipDisplayed,skipClicked:e.skipClicked})}),0)},hu=()=>{uu(),pu({reason:xe.Bj.SKIPPED})},pu=function(){let{reason:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{reason:null};Vc.log(`Ad stopped ${e?`with reason: ${e}`:""}. Starting teardown`),eu(),ae.dispatchEvent(oe.AD_STOPPED,{type:Mc,position:qe.position,reason:e}),Zc()},Eu=e=>{Bc&&Bc();const t=ui(e,{position:qe.position});Vc.log("AD_ERROR (delaying after stopAd()):",t),ku(t)},_u=()=>{xc&&ae.dispatchEvent(oe.PLAYER_VIDEO_DURATION_CHANGE,{duration:xc.getAdDuration()})},mu=(e,t,i)=>{Ru(),Vc.log(`clickThru event received (handle: ${i})`,e),i&&/^([\w]+:)?\/\//.test(e)&&window.open(e),ae.dispatchEvent(oe.AD_CLICK,{type:Mc,position:qe.position})},Au=()=>{xc&&ae.dispatchEvent(oe.AD_VIDEO_SKIPPABLE_STATE,{adSkippable:xc.getAdSkippableState()})},vu=()=>{xc&&ae.dispatchEvent(oe.AD_VIDEO_SKIPPABLE_REMAINING_TIME,{time:xc.getAdSkippableRemainingTime()})},gu=e=>{ae.dispatchEvent(oe.AD_STARTED,{type:Mc,...Uc(e)})},Tu=e=>{const t=ui(e,{position:qe.position});ae.dispatchEvent(oe.AD_POD_ERROR,{adError:t})},Ru=()=>{xc&&(Vc.log("pause ad"),xc.pauseAd())},Su=()=>{xc&&(Vc.log("resume ad"),xc.resumeAd())},Iu=()=>{if(!xc)return;const{width:e,height:t}=A,i=x().viewMode;Vc.log("resize ad (",e,t,i,")"),xc.resizeAd(e,t,i)},fu=()=>{xc&&(xc.getAdSkippableState()?(eu(),_d().then((()=>{uu(),Zc(),ae.dispatchEvent(oe.AD_SKIPPED,{type:Mc,position:qe.position})}))):Vc.warn("Ad is not skippable. Ignoring skipAd()"))},Du=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];xc&&xc.setAdVolume(e,t)},Lu=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ae.dispatchEvent(oe.AD_VIDEO_COMPLETE,e)},ku=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;eu(),md().then((()=>{e?ae.dispatchEvent(oe.AD_ERROR,{adError:e}):ae.dispatchEvent(oe.AD_STOPPED,{type:Mc,position:qe.position}),Zc()}))},Pu=function(){let e=null;if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&qe.adBuffet.length)e=qe.adBuffet.shift(),Ai.increment(),qe.isCrossPodReranking||(gi.value=qe.adBuffet.length);else{qe.adPodIndex++,je.newAd(),Ai.reset();const t=qe.adPods[qe.adPodIndex];t&&(e=t.mainAd),t&&!qe.isCrossPodReranking&&(qe.adBuffet=t.adBuffet,gi.value=qe.adBuffet.length)}return e},yu=T("Player","Scheduler","AdLinearBreak"),Ou="REASON_AD_ERROR",bu="REASON_AD_SKIPPED";let Cu=!1,Nu=!1;const Uu=e=>{let{initAdOptions:t,creative:i}=e;Cu=!1,wu(),yu.log(`Initialized ${qe.position} ad break sequence`),Vu(t,i)},wu=()=>{ae.addEventListener(oe.PLAYER_LOAD_VIDEO,Yu),ae.addEventListener(oe.AD_ERROR,Fu),ae.addEventListener(oe.AD_STARTED,xu),ae.addEventListener(oe.AD_STOPPED,Ku),ae.addEventListener(oe.AD_SKIPPED,Hu)},Vu=(e,t)=>{pd({initAdOptions:e,onAdWillStartEarly:Bu.bind(void 0),creative:t}).then((e=>{const t=xn(),i=t?Kn(e.adVerifications,e.vastTracker):e.adVerifications,n={...e,position:qe.position,isRealAutoplay:K(),timeoutInfo:Gi(si),adVerifications:i,canNativeAppUseOmSdk:t};qe.adPods.length>1?(n.adPodTotal=qe.adPods.length,n.adPodIndex=qe.adPodIndex+1):I("PV5_DISPLAY_CONSECUTIVE_AD_BREAK_INDEX")&&(n.adPodTotal=qe.adSlotTotalAdBreaks,n.adPodIndex=qe.currentAdBreakIndex+1),ae.dispatchEvent(oe.AD_LOADED,{omSdkParams:Bn(n),...n,creativeType:"linear"}),t||(async e=>{const t=kc(pn.clientInventoryId,pn.clientFallbackIndex);if(!e?.length||t)return;if(!await(0,_c.mB)())return;const i=Kn(e,pn.integrator.vastTracker),n=Dc(i),r=fc(n);r&&(Rc.push({inventoryIdValue:pn.clientInventoryId,clientFallbackIndex:pn.clientFallbackIndex}),Cc(Ic(r),Pc,pn.clientInventoryId,pn.clientFallbackIndex))})(i),e.companionAds&&e.companionAds.length&&ae.dispatchEvent(oe.AD_COMPANIONS_RECEIVED,{companionAds:e.companionAds,displayedCompanion:e.displayedCompanion}),yu.log("Success - Responded with mediaFile"),e.injectedAdSlot&&ae.dispatchEvent(oe.AD_SLOT_INJECTED,{element:e.injectedAdSlot}),pn.isAdSlotRunning||ae.dispatchEvent(oe.AD_LINEAR_WILL_START,{position:qe.position}),Hc()})).catch((e=>{yu.error("Failed -",e);const t=ui(e,{position:qe.position,timeoutInfo:Gi()});ae.dispatchEvent(oe.AD_ERROR,{adError:t})}))},Mu=()=>{ae.removeEventListener(oe.PLAYER_LOAD_VIDEO,Yu),ae.removeEventListener(oe.AD_ERROR,Fu),ae.removeEventListener(oe.AD_STARTED,xu),ae.removeEventListener(oe.AD_STOPPED,Ku),ae.removeEventListener(oe.AD_SKIPPED,Hu),yu.log("Torn down")},Bu=()=>{yu.log("triggering early AD_LINEAR_WILL_START",qe.position),ae.dispatchEvent(oe.AD_LINEAR_WILL_START,{position:qe.position})},xu=e=>{ae.dispatchEvent(oe.AD_LINEAR_STARTED,e),Cu=!0},Fu=()=>{Gu(Ou)},Ku=function(){let{reason:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{reason:null};e!==xe.Bj.SKIPPED?Gu("REASON_AD_STOPPED"):Gu(bu)},Hu=()=>{Gu(bu)},Yu=()=>{Gu("REASON_AD_INTERRUPTED")},Gu=async e=>{const t=Boolean(e===Ou)&&Boolean(qe.adBuffet.length)&&(qe.adPods.length>0||qe.adPodIndex>0);(Cu&&0===qe.adPods.length||qe.adPods.length===qe.adPodIndex+1&&!t)&&ae.dispatchEvent(oe.AD_LINEAR_STOPPED,{type:"linear",position:qe.position,reason:e});const i=qe.adPods[qe.adPodIndex+1]&&!Nu;t||i?setTimeout((()=>{Mu(),Qu(t)}),0):Mu()},Qu=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(e||Nu)&&es(!1);try{ld(!1);const t=Nc(),i=cd(),n=Pu(e),r=await i.getSupportedCreative(n);Uu({initAdOptions:t,creative:r})}catch(t){ae.dispatchEvent(oe.AD_ERROR,{adError:t}),qe.adBuffet.length?(yu.log("Starting next ad buffet"),await Qu(!0),Nu=e):qe.adPods[qe.adPodIndex+1]?(yu.log("Starting next ad pod"),await Qu()):Gu(Ou)}},ju=T("AdNonLinearBreak"),qu=()=>{ae.addEventListener(oe.AD_LOADED,Wu),ae.addEventListener(oe.AD_NON_LINEAR_WILL_STOP,zu),ae.addEventListener(oe.AD_ERROR,Xu),ae.addEventListener(oe.AD_STOPPED,Xu),ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,Xu)},$u=async e=>{if(e.integratorType!==xe.Z4.Hs)return;const t=Nc();try{const i=await pd({initAdOptions:t,creative:e});ae.dispatchEvent(oe.AD_LOADED,{...i,position:t.position,isRealAutoplay:t.isRealAutoplay,timeoutInfo:Gi(si),creativeType:"nonlinear"})}catch(e){ju.log("callInitAd failed:",e),zu({error:e})}},Wu=async()=>{if(pn.integratorName===xe.Z4.Hs){ju.log("startAd");try{const e=await Ed();ae.addEventListener(oe.PLAYER_VIDEO_ENDED,Ju),ae.addEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,ih),ae.addEventListener(oe.PLAYER_VIDEO_VOLUME_CHANGED,nh),ae.addEventListener(oe.PLAYER_VIDEO_PAUSE,rh),ae.addEventListener(oe.PLAYER_VIDEO_PLAY,sh),ae.addEventListener(oe.PLAYER_FULLSCREEN_CHANGED,oh),A.on(eh),ae.dispatchEvent(oe.AD_STARTED,{...Uc(e.adData),creativeType:"nonlinear"}),Zu(e),eh()}catch(e){ju.log("callStartAd failed:",e),zu({error:e})}}},zu=async function(){let{error:e=null,reason:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ju.log("stopAd called"),await md(t),e&&ae.dispatchEvent(oe.AD_ERROR,{adError:{...e,creativeType:"nonlinear"}}),Xu()},Xu=()=>{ae.removeEventListener(oe.AD_LOADED,Wu),ae.removeEventListener(oe.AD_NON_LINEAR_WILL_STOP,zu),ae.removeEventListener(oe.AD_ERROR,Xu),ae.removeEventListener(oe.AD_STOPPED,Xu),ae.removeEventListener(oe.PLAYER_VIDEO_SELECTED,Xu),ae.removeEventListener(oe.PLAYER_VIDEO_ENDED,Ju),ae.removeEventListener(oe.PLAYER_VIDEO_TIME_UPDATE,ih),ae.removeEventListener(oe.PLAYER_VIDEO_VOLUME_CHANGED,nh),ae.removeEventListener(oe.PLAYER_VIDEO_PAUSE,rh),ae.removeEventListener(oe.PLAYER_VIDEO_PLAY,sh),ae.removeEventListener(oe.PLAYER_FULLSCREEN_CHANGED,oh),A.off(eh),dh()},Zu=e=>{const t=()=>{e.unsubscribe(r,xe.k3.IMPRESSION),e.unsubscribe(n,xe.k3.ERROR),e.unsubscribe(i,xe.k3.STOPPED)},i=e=>{ju.log(`Received ${xe.k3.STOPPED}, stopping the non linear`),t(),ae.dispatchEvent(oe.AD_STOPPED,{...e,creativeType:"nonlinear"})},n=e=>{const i=ui(e);ju.log(`Received ${xe.k3.ERROR}, stopping the non linear`),t(),ae.dispatchEvent(oe.AD_ERROR,{adError:{...i,creativeType:"nonlinear"}}),ae.dispatchEvent(oe.AD_STOPPED,{creativeType:"nonlinear"})},r=()=>{ae.dispatchEvent(oe.AD_IMPRESSION,wc())};e.subscribe(r,xe.k3.IMPRESSION),e.subscribe(n,xe.k3.ERROR),e.subscribe(i,xe.k3.STOPPED)},Ju=()=>{zu({reason:xe.Bj.INTERRUPTED})},eh=()=>{const e=document.querySelector(".ima_slot");ju.log("Resizing",e.clientHeight,e.clientWidth),cd().resizeAd(e.clientWidth,e.clientHeight-14,Nd.adUnit.ViewMode.NORMAL)};let th=null;const ih=()=>{const e=j().currentTime;th>e&&pn.integrator.vastTracker.track("rewind",Nn()),th=e},nh=e=>{let{muted:t}=e;pn.integrator.vastTracker.setMuted(t,Nn())},rh=()=>{pn.integrator.vastTracker.setPaused(!0,Nn())},sh=()=>{pn.integrator.vastTracker.setPaused(!1,Nn())};let ah=null;const oh=()=>{const e=x().isOpened;ah!==e&&(pn.integrator.vastTracker.setFullscreen(e,Nn()),pn.integrator.vastTracker.setExpand(e,Nn()),ah=e)},dh=()=>{th=null,ah=null},lh=T("Player","Scheduler","AdsFetching"),ch=e=>hd(e).catch((t=>{lh.error("Failed -",t);throw ui(t,{position:e.position,timeoutInfo:Gi()})})),uh=T("Player","Scheduler","AdLinearBreak"),hh=e=>{Eh(e)?setTimeout((()=>{ph(e.fallbackUrl)}),0):(Rs.finish()&&ae.dispatchEvent(oe.AD_LOG,xe.r0.AD_RESOLVED_ERROR),e.message===le.AD_DIRECTOR_REQUEST_TIMEOUT&&qe.current.track("error",1117),setTimeout((()=>{ae.dispatchEvent(oe.RESET_CURRENT_AD_BREAK)}),0))},ph=e=>{const t=e?xe.w3.URL:xe.w3.ADBUFFET;qe.current.markFallbackDone(),ei(),Bi(),xi.log(`adUnit timeout reset to: ${qt()}`),pi.increment(),t===xe.w3.URL?(Ri.increment(),gi.reset(),Ai.reset()):Ai.increment(),uh.log(`Cannot start ad, using fallback, clientFallbackIndex: ${pi.value}`),ae.dispatchEvent(oe.SET_AD_FALLBACK,{fallbackMethod:t,fallbackUrl:e}),ae.dispatchEvent(oe.START_AD_FALLBACK)},Eh=e=>{if(!(e instanceof Be))return!1;if(pn.isAdPod&&pn.adSlotImpressions>0)return!1;if(!(e.isMediationAllowed()&&qt()>200))return!1;const t=!!e.fallbackUrl,i=!e.fallbackUrl&&e.hasRemainingAds;return t||i},_h=()=>{ae.addEventListener(oe.PLAYER_VIDEO_SELECTED,vd),ae.addEventListener(oe.AD_BREAK_STARTED,vh),ae.addEventListener(oe.PLAYER_CHROMECAST_STATUS_CHANGED,mh),ae.addEventListener(oe.START_AD_FALLBACK,vh),ae.addEventListener(oe.AD_IMPRESSION,(()=>{var e;pn.adCreativeId&&pn.integratorName!==xe.Z4.Hs&&((e=pn.adCreativeId)&&Wo.push(e),(e=>{e&&zo.push(e)})(pn.crid))})),ae.addEventListener(oe.AD_ERROR,(e=>{let{adError:t}=e;qe.adPods.length||hh(t)}))},mh=()=>{Ah()&&pn.isAdSlotRunning&&ae.dispatchEvent(oe.AD_LINEAR_STOPPED,{reason:"REASON_CHROMECAST_REMOTE",position:qe.position})},Ah=()=>{const{isActive:e,isConnecting:t}=W();return t||e},vh=async()=>{(()=>{if(qe.position===xe.ev.PREROLL&&qe.isFirstAdBreakForAdSlot&&!pn.fallbackMethod||Me.reset(),!pn.fallbackMethod){try{je.newAdBreak(qe.position,!qe.isFirstAdBreakForAdSlot)}catch(e){Bd.error("Inventory ID update failed",e)}Si(),Oi.clean(),qe.isFirstAdBreakForAdSlot&&(Rs.reset(),qe.current.track("breakStart"))}Rs.enable(),Rs.start()})();const e=Nc();pn.isFallback||Ki(qe.current?.extension?.timeout);const t=pn.fallbackMethod!==xe.w3.ADBUFFET;let i;ld(t),ae.dispatchEvent(oe.AD_SDK_READY,{position:qe.position,adScheduleId:qe.current?.extension?.asid||null,timeoutInfo:Gi(ni),fallbackMethod:pn.fallbackMethod});try{Boolean(qe.current?.isDelayed&&!pn.fallbackMethod)&&(Bd.log("Delaying ad fetching"),await $i(ni,qe.current.requestDelayer.waitForCustomConfig())),i=await(e=>{if(!e.adBreak.hasSupportedAdSource()){const t=`${le.UNSUPPORTED_ADSOURCE}: ${e.adBreak.errorMessage}`;throw new Be(t,{type:Ee})}return new Promise(((t,i)=>{lh.log("Scheduling _fetchAdSync for next tick"),(0,$e.nextTick)((()=>(lh.log("Tick done, calling _fetchAdSync"),ch(e).then((e=>t(e))).catch((e=>i(e))))))}))})(e)}catch(e){return ae.dispatchEvent(oe.AD_ERROR,{adError:e}),void Bd.log("AdFetching failed",e)}Ah()?ae.dispatchEvent(oe.AD_ERROR,{adError:new Be(le.AD_UNIT_CANCEL,{type:Ee})}):await gh(i,e)},gh=async(e,t)=>{const i=cd();try{const r=await i.getSupportedCreative(e);if(Bd.log("Got supported creative",r),j().isPaused&&!je.isConsecutiveAdBreak&&await new Promise((e=>{const t=()=>{e(),ae.removeEventListener(oe.PLAYER_VIDEO_PLAY,t)};ae.addEventListener(oe.PLAYER_VIDEO_PLAY,t)})),r.integratorType!==xe.Z4.Hs&&Wt(),"linear"===r.creative.type)Bd.log("Attaching AdLinearBreak for",qe.position),Uu({initAdOptions:t,creative:r});else if("nonlinear"===r.creative.type){if(qe.position!==xe.ev.MIDROLL)throw Bd.log("Cannot play non linear if not midroll"),new Be(le.NO_SUPPORTED_CREATIVE,{type:Ee});n=r,qu(),$u(n),dh()}}catch(e){if(qe.adPods.length){const e=Pu(qe.adBuffet.length>0);e&&await gh(e,t)}else Bd.error("Failed -",e),ae.dispatchEvent(oe.AD_ERROR,{adError:e})}var n},Th=async e=>{let{injectStyles:t}=e;return _h(),xl(),ae.addEventListener(rc,(e=>{lc(),Ec(rc,e)})),sc.forEach((e=>{ae.addEventListener(e,(t=>{cc(),Ec(e,t)}))})),(async()=>{if(!Sc())return Tc.log("OMSDK for web disabled, sdk not loaded");try{await(0,_c.Bv)(),Tc.log("OMSDK loaded")}catch(e){Tc.log("Unable to load OMSDK lib",e)}})(),Pd(window,kd,Y("emulateHeavyAdsAfterMs")),Js(),wd(),t(".ima_frame_sdk{pointer-events:none;width:0;height:0;display:none}.ima_slot{position:absolute;bottom:0;left:0;right:0;top:0}.ima_slot iframe[id^=goog]{padding-bottom:4%!important;height:100vh;width:100vw}@media screen and (min-width:360px){.ima_slot iframe[id^=goog]{padding-bottom:0!important}}@media screen and (min-width:640px){.ima_slot iframe[id^=goog]{padding-bottom:2%!important}}.ima_slot_hidden{pointer-events:none;display:none}.ima_slot_visible{display:block;pointer-events:auto}.ima_slot_video{background-color:inherit}.vpaid_frame,.simid_frame{border:0;width:100%;overflow:hidden;height:100%;position:absolute;bottom:0;left:0;right:0;top:0}.no-border{border:0}.video_view[data-with-overlay-ad] iframe[id^=goog_]{padding-bottom:calc(4.5rem - 1.125rem)!important}#video[data-cursor-pointer]{cursor:pointer}.controls_ad{pointer-events:none}.controls_ad .ad_button,.controls_ad .playback_button,.controls_ad .mute_toggle_button,.controls_ad .fullscreen_toggle_button{pointer-events:auto}","advertising"),await Nd.load({locale:m?.getEffectiveLocale(),videoElement:H()}),Xl},Rh=async e=>{let{injectStyles:t,...i}=e;return g({injectStyles:t,...i}),Th({injectStyles:t,...i})},Sh=()=>{vd(),Me.reset(),Si()}},4575:(e,t,i)=>{"use strict";i.d(t,{Ez:()=>a,I8:()=>l,IA:()=>u,K7:()=>s,QF:()=>c,VP:()=>o,Y2:()=>r,cv:()=>n,g8:()=>d});const n="Dailymotion",r="1.0",s=window.top,a=3e3,o="full",d=["full","limited"],l=["loaded","start","impression","firstQuartile","midpoint","thirdQuartile","complete","pause","resume","bufferStart","bufferFinish","skipped","volumeChange","playerStateChange","adUserInteraction"],c={LOADING_RESOURCE:3},u={START:"sessionStart",FINISH:"sessionFinish",ERROR:"sessionError"}},9265:(e,t,i)=>{"use strict";i.d(t,{Xu:()=>_,mB:()=>p,Bv:()=>h,G3:()=>o,UV:()=>l,G$:()=>d});var n=i(4575);const r=i.p+"dmp.omweb-v1.83107b47376e0c05d33b.js",s=i.p+"dmp.omid-session-client-v1.7f675153e29102bef4a2.js";let a=null,o=null,d=null,l=null;const c=new Map,u=new Map,h=async()=>{const e=E(r),t=E(s);if(a=Promise.all([e,t]),await a,o=OmidSessionClient.default,!o)throw"sessionClient is missing"},p=async()=>{if(!a)return!1;try{return await a,!0}catch(e){return!1}},E=e=>new Promise(((t,i)=>{try{const i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=t,document.body.appendChild(i)}catch(e){i(e)}})),_=(e,t,i)=>{const r=o.Context,s=o.Partner,a=o.AdSession,c=new r(new s(n.cv,n.Y2),e,t);c.setServiceWindow(n.K7),c.underEvaluation=!1,c.setVideoElement(i);const u=new a(c);if(u.setCreativeType("video"),u.setImpressionType("onePixel"),!u.isSupported())throw new Error("AdSession not supported");d=new o.MediaEvents(u),l=new o.AdEvents(u);return m(u)},m=e=>new Proxy(e,{get:(e,t)=>"start"===t?function(){e[t]();return{sessionIframes:A(this)}}:"finish"===t?async function(){e[t]();return{removedIframes:await v(this)}}:e[t]}),A=e=>{const t=e.getAdSessionId(),i=document.querySelectorAll('[id^="omid-verification-script-frame"]'),n=[];return i.forEach((e=>{c.get(e.id)||(c.set(e.id,t),n.push(e))})),u.set(t,n),n},v=e=>new Promise((t=>{const i=e.getAdSessionId(),r=u.get(i)||[];setTimeout((()=>{r.forEach((e=>{e.remove(),c.delete(e.id)})),u.delete(i),t(r)}),n.Ez)}))}}]);