!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VmaxGoogleIMA=t()}(this,(function(){"use strict";function e(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s{!1===(!1===(null==e?void 0:e[i(this,f,"f")])||"visible"===(null==e?void 0:e.visibilityState))&&(n(this,p,!1,"f"),i(this,o,"m",T).call(this))}),1),"f")},T=function(){const e=i(this,u,"f")&&i(this,p,"f");if(i(this,v,"f")===e)return;const t=i(this,u,"f")&&i(this,p,"f"),s=i(this,t?l:d,"f"),o=i(this,t?c:h,"f");s.forEach((e=>e())),o.forEach((e=>e())),n(this,t?c:h,[],"f"),n(this,v,e,"f")},function(e){e.errorCode="{errorcode}",e.noFill="",e.noFillError="[nofill.error]",e.demandPartnerSDKVersion="[demand.partner.sdkversion]",e.eventName="[event.name]",e.vastErrorCode="[vast.error]",e.OmidSDKVersion="[omid.partner.sdkversion]",e.eventAttribute1="[event.attribute1]",e.eventAttribute2="[event.attribute2]",e.eventAttribute3="[event.attribute3]",e.randomCcb="[random.ccb]",e.deviceIFA="[device.ifa]"}(I||(I={}));const _=Object.freeze({XML_PARSING_ERROR:{code:100,message:"XML parsing error."},VAST_SCHEMA_VALIDATION_ERROR:{code:101,message:"VAST schema validation error."},VAST_VERSION_NOT_SUPPORTED:{code:102,message:"VAST version of response not supported."},TRAFFICKING_ERROR:{code:200,message:"Video player received an Ad type that it was not expecting and/or cannot display."},LINEARITY_ERROR:{code:201,message:"Video player expecting different linearity."},DURATION_ERROR:{code:202,message:"Video player expecting different duration."},SIZE_ERROR:{code:203,message:"Video player expecting different size."},GENERAL_WRAPPER_ERROR:{code:300,message:"General Wrapper error."},TIMEOUT_ERROR:{code:301,message:"Timeout of VAST URI provided in Wrapper element, or of VAST URI provided in a subsequent Wrapper element. (URI was either unavailable or reached a timeout as defined by the video player.)"},WRAPPER_LIMIT_ERROR:{code:302,message:"Wrapper limit reached, as defined by the video player. Too many Wrapper responses have been received with no InLine response."},NO_ADS_ERROR:{code:303,message:"No Ads VAST response after one or more Wrappers."},INLINE_TIMEOUT_ERROR:{code:304,message:"InLine response returned ad unit that failed to result in ad display within defined time limit."},GENERAL_LINEAR_ERROR:{code:400,message:"General Linear error. Video player is unable to display the Linear Ad."},FILE_NOT_FOUND_ERROR:{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."},MEDIAFILE_TIMEOUT_ERROR:{code:402,message:"Video Prepare failed because of Media Timeout"},MEDIAFILE_UNSUPPORTED_ERROR:{code:403,message:"Couldn't find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."},MEDIAFILE_DISPLAY_ERROR:{code:405,message:"Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn't display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."},GENERAL_NONLINEAR_ERROR:{code:500,message:"General NonLinearAds error."},NONLINEAR_SIZE_ERROR:{code:501,message:"Unable to display NonLinear Ad because creative dimensions do not align with creative display area (i.e. creative dimension too large)."},NONLINEAR_RESOURCE_ERROR:{code:502,message:"Unable to fetch NonLinearAds/NonLinear resource."},NONLINEAR_UNSUPPORTED_ERROR:{code:503,message:"Couldn't find NonLinear resource with supported type."},GENERAL_COMPANION_ERROR:{code:600,message:"General CompanionAds error."},COMPANION_SIZE_ERROR:{code:601,message:"Unable to display Companion because creative dimensions do not fit within Companion display area (i.e., no available space)."},REQUIRED_COMPANION_ERROR:{code:602,message:"Unable to display Required Companion."},COMPANION_RESOURCE_ERROR:{code:603,message:"Unable to fetch CompanionAds/Companion resource."},COMPANION_UNSUPPORTED_ERROR:{code:604,message:"Couldn't find Companion resource with supported type."},UNDEFINED_ERROR:{code:900,message:"Undefined Error."}});function y(e,t){const i=function(e,t){const i=navigator.userAgent.match(/Android/i),n=navigator.userAgent.match(/Chrome/i),s=e&&i&&n;if(!s)return!1;const o=function(e,t){try{const i=e.split("://"),n=i[0];return`intent://${i[1]}/#Intent;scheme=${n};S.browser_fallback_url=${t||""};end`}catch(e){return!1}}(e,t);return o||!1}(e,t);return i||t}function S(e){if("number"==typeof e)return e;try{const[t,i,n]=e.split(":"),s=60*parseInt(t)*60,o=60*parseInt(i);return s+o+parseInt(n)}catch(e){return function(...e){console.debug.apply(console,e)}("videoInstreamVmaxAd: Wrong time specified in vast parser",e),0}}function w(e){var t,i,n,s,o,r;const{bid:a,vast:l,hasVideoAdElement:d=!1,imaCompanions:c={companions:[],companionResourceUrls:[]}}=e,{ext:h={},w:f=null,h:u=null}=a||{},p=null!==(t=null==h?void 0:h["ad-meta"])&&void 0!==t?t:{},{id:v=null,name:E=null,"campaign-meta":m={}}=p,{id:g=null,name:A=null,marketer:R={},order:T={}}=m,{id:I=null,name:O=null,agency:_=null,brand:w=null}=R||{},{id:k=null,name:N=null}=T,D=e=>"number"==typeof e&&e>=0?e:-1,b=function(e){try{return JSON.parse(e)}catch(e){return{}}}((null==a?void 0:a.adm)||"{}"),C=(null==b?void 0:b.title)||"",L=(null==b?void 0:b.ctaText)||"",M=!!(null==b?void 0:b.linkUrl)||!!(null==b?void 0:b.linkFallback),P=y((null==b?void 0:b.linkUrl)||"",(null==b?void 0:b.linkFallback)||""),U=(null==l?void 0:l.adSystem)||"",V=(null==l?void 0:l.adTitle)||"",W=(null==l?void 0:l.description)||"",F=(null===(i=null==l?void 0:l.linear)||void 0===i?void 0:i.skipoffset)||(null==l?void 0:l.skipOffset)?D(S((null===(n=null==l?void 0:l.linear)||void 0===n?void 0:n.skipoffset)||(null==l?void 0:l.skipOffset)||"")):"",x=(null==l?void 0:l.duration)?D(S(null==l?void 0:l.duration)):"",H=!!(null==l?void 0:l.deepLinkUrl)||!!(null==l?void 0:l.clickThrough);let G=(null==l?void 0:l.companions)||[],K=(null==l?void 0:l.companionResourceUrls)||[];const j=y((null==l?void 0:l.deepLinkUrl)||"",(null==l?void 0:l.clickThrough)||""),{companions:Y=[],companionResourceUrls:Q=[]}=c;Y.length&&(G=[...Y],K=[...Q]);return{adId:v,adName:E,campaignId:g,campaignName:A,marketerId:I,marketerName:O,brand:w,agency:_,orderId:k,orderName:N,qualifiedSignature:(null===(r=null===(o=null===(s=null==a?void 0:a.ext)||void 0===s?void 0:s.modules)||void 0===o?void 0:o.render)||void 0===r?void 0:r.signature)||"",width:f,height:u,adSystem:U,adTitle:C||V,adDescription:W,ctaText:L,skipOffset:F,adDuration:x,isCTAAvailable:M||H,adClickUrl:P||j,companionResourceUrls:K,hasVideoAdElement:d,companions:G}}var k,N,D,b,C,L,M;!function(e){e.AD_READY="adReady",e.AD_IMPRESSION="adImpression",e.AD_RENDERED="adRendered",e.AD_REFRESHED="adRefreshed",e.AD_ERROR="adError",e.AD_CLOSED="adClosed",e.AD_CLICKED="adClicked",e.AD_SKIPPED="adSkipped",e.AD_SKIPPABLE_STATE_CHANGE="adSkippableStateChange",e.AD_PAUSED="adPaused",e.AD_RESUMED="adResumed",e.AD_VIDEO_START="adVideoStart",e.AD_VIDEO_FIRST_QUARTILE="adVideoFirstQuartile",e.AD_VIDEO_MIDPOINT="adVideoMidpoint",e.AD_VIDEO_THIRD_QUARTILE="adVideoThirdQuartile",e.AD_VIDEO_COMPLETE="adVideoComplete",e.AD_VOLUME_CHANGED="adVolumeChanged",e.AD_MUTED="adMuted",e.AD_UNMUTED="adUnmuted",e.AD_PROGRESS="adProgress",e.AD_USER_CLOSE="adUserClose",e.AD_INSERTION_START="adInsertionStart",e.AD_INSERTION_END="adInsertionEnd",e.AD_MEDIA_EXPAND="onFullScreen",e.AD_MEDIA_COLLAPSE="onExitFullScreen"}(k||(k={})),function(e){e.PERSONAL_COMPUTER="2",e.CONNECTED_TV="3",e.PHONE="4",e.TABLET="5",e.CONNECTED_DEVICE="6",e.SET_TOP_BOX="7"}(N||(N={})),function(e){e.GEO_PROFILE="geoProfile",e.USER_PROFILE="userProfile"}(D||(D={})),function(e){e.APP_ID="appId",e.ACCOUNT_KEY="accountKey",e.SECRET_KEY="secretKey",e.SDK_INITIALIZED="sdkInitialized",e.GEO_PROFILE="geoProfile",e.USER_PROFILE="userProfile",e.IS_APP="isApp",e.SOURCE_CONFIG_DATA="sourceConfig",e.ABORT="abort",e.PRIVATE_KEY="privateKey",e.KEY_ID="keyId",e.UPS_ENDPOINT="upsEndpoint",e.UPS_XAUTH="upsXAuth",e.DGS_ENDPOINT="dgsEndpoint",e.DGS_XAUTH="dgsXAuth",e.AS_ENDPOINT="adspotEndpoint",e.AS_XAUTH="adspotXAuth",e.UPS_FIRST_FETCH_DONE="upsFirstFetchDone",e.UPS_SERVICE_CALL="UPSServiceCall",e.DGS_SERVICE_CALL="DGSServiceCall"}(b||(b={})),function(e){e.UID="uid",e.GENDER="gender",e.AGE="age",e.COUNTRY="country",e.REGION="region",e.CITY="city",e.ZIPCODE="zip",e.KEYWORDS="keywords"}(C||(C={})),function(e){e.PLAY_ONCE="play_once",e.REPEAT="repeat"}(L||(L={}));class P{constructor(){M.set(this,new Map)}static getInstance(){return P.instance}set(e,t){"object"!=typeof e?i(this,M,"f").set(e,t):Object.entries(e).forEach((([e,t])=>{i(this,M,"f").set(e,t)}))}get(e){var t;return"string"!=typeof e||0==e.length?i(this,M,"f"):null!==(t=i(this,M,"f").get(e))&&void 0!==t?t:null}get isSDKInitialized(){return Boolean(i(this,M,"f").get(b.SDK_INITIALIZED))}}M=new WeakMap,P.instance=new P;const U=P.getInstance();var V,W,F,x;class H{static post(e){return t(this,void 0,void 0,(function*(){const{url:t,payload:i,headers:n={},credentials:o}=e||{};let r={method:"POST",body:JSON.stringify(i)};o&&(r.credentials=o),n&&(r.headers=n);const a=new AbortController;r.signal=a.signal;return[fetch(t,r).then((e=>e.ok?e.json().catch((()=>Promise.reject(s("Invalid JSON response")))):e.text().then((t=>Promise.reject({message:`Error: ${e.status}`,status:e.status,body:t}))))).catch((e=>(function(...e){console.log.apply(console,e)}("Error in Fetch.post",e),Promise.reject(e)))),a]}))}static get(e){return t(this,arguments,void 0,(function*(e,t={}){return fetch(e,t).then((e=>e.json()))}))}static getPlainResponse(e){return t(this,arguments,void 0,(function*(e,t={}){return fetch(e,t)}))}static DeviceGeoService(){const e=U.get(b.ACCOUNT_KEY),t=U.get(b.DGS_ENDPOINT);U.get(b.DGS_XAUTH);const i=(t||"").replace("ACCOUNT_KEY",e);return V.get(i)}static UserProfileService(e){return t(this,void 0,void 0,(function*(){const t=U.get(b.ACCOUNT_KEY),i=U.get(b.UPS_ENDPOINT),n=U.get(b.UPS_XAUTH),s=(i||"").replace("ACCOUNT_KEY",t),[o]=yield V.post({url:s,headers:{"X-AUTH":n},payload:e});return o}))}static AdQuery(e){const{ACCOUNT_KEY:t,AS_ENDPOINT:i}=b,n=U.get(t)||"",s=U.get(i);return V.post({url:s.replace("ACCOUNT_KEY",n),payload:e,credentials:"include"})}static replaceAllMacros(e,t){const i=Object.keys(I);if(0===i.length)return e;const{ifa:n=""}=window.VmaxAdManager.getDevice().getPayload();return i.forEach((i=>{var s;const o=I[i];let r;r=o===I.randomCcb?Date.now().toString():o===I.deviceIFA?n:t&&(null===(s=t[o])||void 0===s?void 0:s.toString())||"";const a=new RegExp(this.escapeRegExp(o),"g");e=e.replace(a,r)})),t||i.forEach((t=>{const i=I[t],n=new RegExp(this.escapeRegExp(i),"g");e=e.replace(n,"")})),e}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static FireTracker(e,n){return t(this,void 0,void 0,(function*(){if(!(t=e,"string"==typeof t&&t.length>0||(e=>Array.isArray(e))(e)))return Promise.reject("No url to fire tracker");var t;for(let t of e)t=this.replaceAllMacros(t,n),yield i(V,V,"m",W).call(V,t)}))}}V=H,W=function(e){return t(this,void 0,void 0,(function*(){try{const t=window.VmaxAdManager.getSite().getPayload(),{pageUrl:i,referrerUrl:n}=t,o=yield fetch(e,{method:"GET",headers:{Connection:"keep-alive","X-Requested-with":`${i}`},credentials:"include"});o.ok||s("Tracker request failed:",o.status,o.statusText)}catch(e){s("Error while firing the tracker:",e)}}))};class G{constructor(e=new Map){F.set(this,new Map),n(this,F,e,"f")}fireTracker(e,t){const n=i(this,F,"f").get(e);n&&H.FireTracker(n,t)}}F=new WeakMap,function(e){e.IMPRESSION="impression",e.NO_FILL="nofill",e.FILL="fill",e.CLICK="click",e.ERROR="error",e.START="start",e.FIRST_QUARTILE="firstQuartile",e.MIDPOINT="midpoint",e.THIRD_QUARTILE="thirdQuartile",e.COMPLETE="complete",e.PAUSE="pause",e.RESUME="resume",e.SKIP="skip",e.MUTE="mute",e.UNMUTE="unmute",e.SKIPPABLE_STATE_CHANGE="skippableStateChange"}(x||(x={}));var K,j,Y,Q,z,X,q,B,$,Z,J,ee,te,ie,ne,se,oe,re,ae,le,de,ce,he,fe,ue,pe,ve,Ee,me,ge,Ae,Re,Te,Ie,Oe,_e,ye,Se,we,ke,Ne,De,be,Ce,Le=x;return j=new WeakMap,Y=new WeakMap,Q=new WeakMap,z=new WeakMap,X=new WeakMap,q=new WeakMap,B=new WeakMap,$=new WeakMap,Z=new WeakMap,J=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ne=new WeakMap,se=new WeakMap,oe=new WeakMap,re=new WeakMap,ae=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakMap,he=new WeakMap,fe=new WeakMap,ue=new WeakMap,pe=new WeakMap,ve=new WeakMap,K=new WeakSet,Ee=function(e){const t=document.createElement("style");t.textContent="\n .vmax-gam-circular-loader {\n border: 4px solid rgba(0, 0, 0, 0.1); /* Light gray background */\n border-top: 4px solid grey; /* Blue spinner */\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: spin 1s linear infinite;\n\n /* Positioning to center within the container */\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n display: none;\n }\n\n /* Spin Animation */\n @keyframes spin {\n to { transform: translate(-50%, -50%) rotate(360deg); }\n }\n ";const s=document.createElement("div");s.classList.add("vmax-gam-circular-loader"),s.appendChild(t),i(this,Y,"f").style.position="relative",i(this,Y,"f").appendChild(s),n(this,ae,s,"f"),i(this,K,"m",ge).call(this)},me=function(){clearInterval(i(this,fe,"f"));!!i(this,ae,"f")&&"block"===i(this,ae,"f").style.display&&n(this,fe,setTimeout((()=>{i(this,ae,"f").style.display="block"}),200),"f")},ge=function(){clearInterval(i(this,fe,"f"));!!i(this,ae,"f")&&"block"===i(this,ae,"f").style.display&&(i(this,ae,"f").style.display="none")},Ae=function(){i(this,K,"m",Re).call(this,"7")},Re=function(e){var t,n;null===(n=null===(t=i(this,ie,"f"))||void 0===t?void 0:t.fireTracker)||void 0===n||n.call(t,null==Le?void 0:Le.NO_FILL,{[I.noFill]:e,[I.noFillError]:e}),this.cleanup()},Te=function(){n(this,ee,new O(i(this,Y,"f")),"f"),i(this,ee,"f").enter(i(this,K,"m",Oe).bind(this)),i(this,ee,"f").exit(i(this,K,"m",Ie).bind(this))},Ie=function(){var e;i(this,oe,"f")||(n(this,re,!0,"f"),null===(e=i(this,B,"f"))||void 0===e||e.pause())},Oe=function(){var e;i(this,oe,"f")||(n(this,re,!1,"f"),null===(e=i(this,B,"f"))||void 0===e||e.resume())},_e=function(){const{IMPRESSION:e,NO_FILL:t,FILL:s}=Le,{burl:o="",nurl:r="",lurl:a=""}=i(this,j,"f")||{};o&&i(this,$,"f").set(e,[o]),a&&i(this,$,"f").set(t,[a]),r&&i(this,$,"f").set(s,[r]),i(this,se,"f")&&i(this,$,"f").set(Le.CLICK,i(this,se,"f")),n(this,ie,new G(i(this,$,"f")),"f")},ye=function(){n(this,X,new google.ima.AdDisplayContainer(i(this,Y,"f")),"f"),i(this,X,"f").initialize()},Se=function(){n(this,q,new google.ima.AdsLoader(i(this,X,"f")),"f")},we=function(e){const t=new google.ima.AdsRequest,s=function(e,t){const i=Object.keys(I);return 0===i.length||i.forEach((i=>{var n;const s=I[i],o=s===I.randomCcb?Date.now().toString():t&&(null===(n=t[s])||void 0===n?void 0:n.toString())||"",r=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");e=e.replace(r,o)})),e}(i(this,z,"f"),{[I.demandPartnerSDKVersion]:i(this,ne,"f")});t.adTagUrl=s,t.linearAdSlotWidth=i(this,Y,"f").offsetWidth||640,t.linearAdSlotHeight=i(this,Y,"f").offsetHeight||400,i(this,q,"f").requestAds(t),i(this,pe,"f")&&n(this,ve,setTimeout((()=>{var t;null===(t=i(this,B,"f"))||void 0===t||t.destroy(),i(this,K,"m",Re).call(this,"2"),e(_.MEDIAFILE_TIMEOUT_ERROR)}),1e3*i(this,pe,"f")),"f")},ke=function(e,t,s){const o=new google.ima.AdsRenderingSettings;o.enablePreloading=!0,n(this,B,e.getAdsManager(null,o),"f");const r=i(this,Y,"f").offsetWidth||640,a=i(this,Y,"f").offsetHeight||400;n(this,de,!0,"f"),i(this,B,"f").init(r,a,google.ima.ViewMode.NORMAL),i(this,B,"f").setVolume(i(this,ue,"f")),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.LOADED,(e=>{s(),clearTimeout(i(this,ve,"f")),i(this,K,"m",De).bind(this)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.IMPRESSION,(e=>{var t,n,s,o,r;const a=i(this,K,"m",Ne).call(this,e);null===(n=(t=i(this,ie,"f")).fireTracker)||void 0===n||n.call(t,Le.FILL),null===(o=(s=i(this,ie,"f")).fireTracker)||void 0===o||o.call(s,Le.IMPRESSION),null===(r=i(this,te,"f"))||void 0===r||r.AdImpression(a)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.STARTED,(e=>{var t,s;i(this,K,"m",ge).call(this);i(this,Y,"f").querySelector("#adsLoader")&&i(this,Y,"f").removeChild(i(this,ae,"f")),n(this,le,!0,"f");const o=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.START),null===(s=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVideoStart)||void 0===s||s.call(t,o);var r=e.getAd();i(this,K,"m",Ce).call(this,r)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.COMPLETE,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.COMPLETE),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVideoComplete)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.VOLUME_CHANGED,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVolumeChanged)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.PAUSED,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.PAUSE),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdPaused)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.RESUMED,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.RESUME),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdResumed)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,(e=>{this.cleanupAndCloseAd(e)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.CLICK,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.CLICK),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdClicked)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.FIRST_QUARTILE,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.FIRST_QUARTILE),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVideoFirstQuartile)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.MIDPOINT,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.MIDPOINT),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVideoMidpoint)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.THIRD_QUARTILE,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.THIRD_QUARTILE),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdVideoThirdQuartile)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.SKIPPABLE_STATE_CHANGE),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdSkippableStateChange)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdEvent.Type.SKIPPED,(e=>{var t,n;const s=i(this,K,"m",Ne).call(this,e);i(this,ie,"f").fireTracker(Le.SKIP),null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdSkipped)||void 0===n||n.call(t,s)})),i(this,B,"f").addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,(e=>{i(this,K,"m",be).bind(this,e,t)}))},Ne=function(t){var i,s;const{currentTime:o=null,duration:r=null}=t&&t.getAdData()||{},a=(null===(i=null==t?void 0:t.getAd())||void 0===i?void 0:i.data)||{},{skipTimeOffset:l=null}=a,d=e(a,["skipTimeOffset"]),c=Object.assign(Object.assign({},t&&t.getAdData()||{}),(null===(s=null==t?void 0:t.getAd())||void 0===s?void 0:s.data)||{}),{clickThroughUrl:h="",title:f="",advertiserName:u="",skipTimeOffset:p="-1"}=c,v=e(c,["clickThroughUrl","title","advertiserName","skipTimeOffset"]);return n(this,he,Object.assign({clickThrough:h,adTitle:f,adName:u,skipOffset:p},v),"f"),Object.assign({currentTime:o,duration:r,skipTimeOffset:l},d)},De=function(e){i(this,K,"m",Ne).call(this,e)},be=function(e,t){i(this,ie,"f").fireTracker(Le.ERROR),i(this,K,"m",Re).call(this,"6"),null==t||t(e?e.getError():"Unknown error")},Ce=function(e){const t=new google.ima.CompanionAdSelectionSettings;t.sizeCriteria=google.ima.CompanionAdSelectionSettings.SizeCriteria.IGNORE;const n=e.getCompanionAds(-1,-1,t);for(let e=0;e{})),J.set(this,(()=>{})),ee.set(this,void 0),te.set(this,void 0),ie.set(this,void 0),this.shouldProcessRefresh=!1,ne.set(this,void 0),this.canRefresh=!1,se.set(this,void 0),oe.set(this,void 0),re.set(this,void 0),ae.set(this,void 0),le.set(this,!1),de.set(this,!1),ce.set(this,{companionResourceUrls:[],companions:[]}),he.set(this,void 0),fe.set(this,void 0),ue.set(this,1),pe.set(this,void 0),ve.set(this,void 0)}getAllSignatures(){return"nw.imavideo"}prepare(e){return new Promise(((t,s)=>{var o;try{const{bid:r,container:a,listeners:l}=e||{};n(this,Y,a,"f"),i(this,K,"m",Ee).call(this,i(this,Y,"f")),n(this,j,r,"f"),n(this,te,l,"f");const d=(null===(o=i(this,j,"f"))||void 0===o?void 0:o.adm)||"";if(!d)return s("No ad object found");const c=JSON.parse(d),{ad_tag_url:h}=null==c?void 0:c.adnetwork_params;if(n(this,se,(null==c?void 0:c.adnetwork_params["click-url"])||"","f"),i(this,K,"m",_e).call(this),!h)return i(this,K,"m",Re).call(this,"7"),s("No Ad Tag URL");n(this,z,h+"?"+Date.now(),"f");const{AdPaused:f,AdResumed:u}=l||{};"function"==typeof f&&n(this,J,f,"f"),"function"==typeof u&&n(this,Z,u,"f"),i(this,K,"m",ye).call(this),i(this,K,"m",Se).call(this),n(this,ne,i(this,q,"f").getVersion(),"f"),i(this,q,"f").addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(e=>{i(this,K,"m",ke).call(this,e,s,t)}),!1),i(this,q,"f").addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,(e=>{i(this,K,"m",Ae).call(this),s(e.getError())}),!1),i(this,K,"m",we).call(this,s)}catch(e){console.warn("VmaxGoogleIMA: Error in prepare",e),i(this,K,"m",Re).call(this,"2"),s(e)}}))}setMediaTimeOut(e){n(this,pe,e,"f")}setVolume(e){var t,s;"number"!=typeof e||e<0||e>1||(n(this,ue,e,"f"),null===(s=null===(t=i(this,B,"f"))||void 0===t?void 0:t.setVolume)||void 0===s||s.call(t,e))}render(e){if(!i(this,B,"f"))return Promise.reject("Ads Manager not initialized");try{i(this,B,"f").resize(i(this,Y,"f").offsetWidth,i(this,Y,"f").offsetHeight,google.ima.ViewMode.NORMAL),i(this,K,"m",me).call(this),i(this,B,"f").start(),i(this,K,"m",Te).call(this)}catch(e){return console.debug("Error during Ad Manager initialization:",e),i(this,ie,"f").fireTracker(Le.ERROR),i(this,K,"m",Re).call(this,"6"),Promise.reject("Failed to start ads")}return Promise.resolve()}cleanupAndCloseAd(e){var t,n;i(this,K,"m",ge).call(this);const s=i(this,K,"m",Ne).call(this,e);null===(n=null===(t=i(this,te,"f"))||void 0===t?void 0:t.AdClosed)||void 0===n||n.call(t,s),setTimeout((()=>{var e;this.destroy(),null===(e=i(this,X,"f"))||void 0===e||e.destroy()}),3e3)}cleanup(){setTimeout((()=>{var e;null===(e=i(this,X,"f"))||void 0===e||e.destroy(),this.destroy()}),300)}destroy(){var e,t,s,o;i(this,B,"f")&&i(this,B,"f").destroy(),i(this,q,"f")&&(null===(e=i(this,q,"f"))||void 0===e||e.destroy()),null===(t=i(this,X,"f"))||void 0===t||t.destroy(),null===(s=i(this,ee,"f"))||void 0===s||s.destroy(),n(this,ee,null,"f"),n(this,j,{},"f");const r=null===(o=i(this,Y,"f"))||void 0===o?void 0:o.querySelector(".vmax-gam-circular-loader");return i(this,Y,"f")&&r&&i(this,Y,"f").removeChild(r),Promise.resolve()}closeAd(){this.destroy(),this.canRefresh=!1}getVmaxAdInfo(){const e=w({bid:i(this,j,"f"),vast:i(this,he,"f"),hasVideoAdElement:i(this,de,"f"),imaCompanions:i(this,ce,"f")});return Object.assign({},e)}getAdMarkup(){var e;return(null===(e=i(this,j,"f"))||void 0===e?void 0:e.adm)||""}pauseAd(){var e;return i(this,B,"f")&&(i(this,B,"f").pause(),n(this,oe,!0,"f")),null===(e=i(this,ie,"f"))||void 0===e||e.fireTracker(Le.PAUSE),Promise.resolve()}resumeAd(){var e;if(i(this,le,"f")&&i(this,oe,"f"))return i(this,B,"f")&&(i(this,B,"f").resume(),n(this,oe,!1,"f")),null===(e=i(this,ie,"f"))||void 0===e||e.fireTracker(Le.RESUME),Promise.resolve()}}}));