diff --git a/.npmrc b/.npmrc index b185203..a4af349 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ -registry = https://registry.npmjs.org +registry=https://registry.npmjs.org/ +legacy-peer-deps=true diff --git a/dist/ads-manager.es.js b/dist/ads-manager.es.js index c332e0c..5833f68 100644 --- a/dist/ads-manager.es.js +++ b/dist/ads-manager.es.js @@ -1 +1 @@ -var e={686:function(e,t){!function(e){function t(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function i(e){for(var i=1;ie.length)&&(t=e.length);for(var i=0,r=new Array(t);i0&&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:[]}}var A=["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 g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[],n=y(e);for(var a in!t.ERRORCODE||i.isCustomCode||/^[0-9]{3}$/.test(t.ERRORCODE)||(t.ERRORCODE=900),t.CACHEBUSTING=b(Math.round(1e8*Math.random())),t.TIMESTAMP=(new Date).toISOString(),t.RANDOM=t.random=t.CACHEBUSTING,t)t[a]=S(t[a]);for(var o in n){var s=n[o];"string"==typeof s&&r.push(T(s,t))}return r}function T(e,t){var i=(e=E(e,t)).match(/[^[\]]+(?=])/g);if(!i)return e;var r=i.filter((function(e){return A.indexOf(e)>-1}));return 0===r.length?e:E(e,r=r.reduce((function(e,t){return e[t]=-1,e}),{}))}function E(e,t){var i=e;for(var r in t){var n=t[r];i=i.replace(new RegExp("(?:\\[|%%)(".concat(r,")(?:\\]|%%)"),"g"),n)}return i}function y(e){return Array.isArray(e)?e.map((function(e){return e&&e.hasOwnProperty("url")?e.url:e})):e}function _(e){return/^(https?:\/\/|\/\/)/.test(e)}function k(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:8;return e.toString().padStart(t,"0")}var C={track:function(e,t,i){g(e,t,i).forEach((function(e){"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:g,extractURLsFromTemplates:y,filterValidUrlTemplates:function(e){return Array.isArray(e)?e.filter((function(e){return _(e.hasOwnProperty("url")?e.url:e)})):_(e)},containsTemplateObject:k,isTemplateObjectEqual:R,encodeURIComponentRFC3986:S,replaceUrlMacros:T,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce((function(t,i){return t.concat(Array.isArray(i)?e(i):i)}),[])},joinArrayOfUniqueTemplateObjs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=Array.isArray(e)?e:[],r=Array.isArray(t)?t:[];return i.concat(r).reduce((function(e,t){return k(t,e)||e.push(t),e}),[])},isValidTimeValue:function(e){return Number.isFinite(e)&&e>=-2},addLeadingZeros:b};function V(e){return-1!==["true","TRUE","True","1"].indexOf(e)}function I(e){if(null==e)return-1;if(C.isNumeric(e))return parseInt(e);var t=e.split(":");if(3!==t.length)return-1;var i=t[2].split("."),r=parseInt(i[0]);2===i.length&&(r+=parseFloat("0.".concat(i[1])));var n=parseInt(60*t[1]),a=parseInt(60*t[0]*60);return isNaN(a)||isNaN(n)||isNaN(r)||n>3600||r>60?-1:a+n+r}var L={childByName:function(e,t){var i=e.childNodes;for(var r in i){var n=i[r];if(n.nodeName===t)return n}},childrenByName:function(e,t){var i=[],r=e.childNodes;for(var n in r){var a=r[n];a.nodeName===t&&i.push(a)}return i},resolveVastAdTagURI:function(e,t){if(!t)return e;if(0===e.indexOf("//")){var i=location.protocol;return"".concat(i).concat(e)}if(-1===e.indexOf("://")){var r=t.slice(0,t.lastIndexOf("/"));return"".concat(r,"/").concat(e)}return e},parseBoolean:V,parseNodeText:function(e){return e&&(e.textContent||e.text||"").trim()},copyNodeAttribute:function(e,t,i){var r=t.getAttribute(e);r&&i.setAttribute(e,r)},parseAttributes:function(e){for(var t=e.attributes,i={},r=0;r1){var a=e[n-1];if(a&&a.sequence===r.sequence-1)return void(i&&i.push(r));delete r.sequence}i=[r],t.push(i)})),t},assignAttributes:function(e,t){if(e)for(var i in e){var r=e[i];if(r.nodeName&&r.nodeValue&&t.hasOwnProperty(r.nodeName)){var n=r.nodeValue;"boolean"==typeof t[r.nodeName]&&(n=V(n)),t[r.nodeName]=n}}},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=[].concat(p(e.viewableImpression),p(t.viewableImpression))),e.followAdditionalWrappers=t.followAdditionalWrappers,e.allowMultipleAds=t.allowMultipleAds,e.fallbackOnNoAd=t.fallbackOnNoAd;var r=(t.creatives||[]).filter((function(e){return e&&"companion"===e.type})),n=r.reduce((function(e,t){return(t.variations||[]).forEach((function(t){(t.companionClickTrackingURLTemplates||[]).forEach((function(t){C.containsTemplateObject(t,e)||e.push(t)}))})),e}),[]);e.creatives=r.concat(e.creatives);var a=t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length,o=t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length;if(e.creatives.forEach((function(e){if(t.trackingEvents&&t.trackingEvents[e.type])for(var i in t.trackingEvents[e.type]){var r=t.trackingEvents[e.type][i];Array.isArray(e.trackingEvents[i])||(e.trackingEvents[i]=[]),e.trackingEvents[i]=e.trackingEvents[i].concat(r)}"linear"===e.type&&(a&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates)),o&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates)),!t.videoClickThroughURLTemplate||null!==e.videoClickThroughURLTemplate&&void 0!==e.videoClickThroughURLTemplate||(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)),"companion"===e.type&&n.length&&(e.variations||[]).forEach((function(e){e.companionClickTrackingURLTemplates=C.joinArrayOfUniqueTemplateObjs(e.companionClickTrackingURLTemplates,n)}))})),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){var s=t.creatives.filter((function(e){var t;return(null===(t=e.icons)||void 0===t?void 0:t.length)&&!e.mediaFiles.length}));s.length&&(e.creatives=e.creatives.concat(s))}}};function N(e,t){var i=function(){var e=f(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"companion",required:null,variations:[]}}(t);return i.required=e.getAttribute("required")||null,i.variations=L.childrenByName(e,"Companion").map((function(e){var t=function(){var 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:{}}}(L.parseAttributes(e));t.htmlResources=L.childrenByName(e,"HTMLResource").reduce((function(e,t){var i=L.parseNodeText(t);return i?e.concat(i):e}),[]),t.iframeResources=L.childrenByName(e,"IFrameResource").reduce((function(e,t){var i=L.parseNodeText(t);return i?e.concat(i):e}),[]),t.staticResources=L.childrenByName(e,"StaticResource").reduce((function(e,t){var i=L.parseNodeText(t);return i?e.concat({url:i,creativeType:t.getAttribute("creativeType")||null}):e}),[]),t.altText=L.parseNodeText(L.childByName(e,"AltText"))||null;var i=L.childByName(e,"TrackingEvents");i&&L.childrenByName(i,"Tracking").forEach((function(e){var i=e.getAttribute("event"),r=L.parseNodeText(e);i&&r&&(Array.isArray(t.trackingEvents[i])||(t.trackingEvents[i]=[]),t.trackingEvents[i].push(r))})),t.companionClickTrackingURLTemplates=L.childrenByName(e,"CompanionClickTracking").map((function(e){return{id:e.getAttribute("id")||null,url:L.parseNodeText(e)}})),t.companionClickThroughURLTemplate=L.parseNodeText(L.childByName(e,"CompanionClickThrough"))||null;var r=L.childByName(e,"AdParameters");return r&&(t.adParameters={value:L.parseNodeText(r),xmlEncoded:r.getAttribute("xmlEncoded")||null}),t})),i}function w(e,t){var i,r=function(){var e=f(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}}(t);r.duration=L.parseDuration(L.parseNodeText(L.childByName(e,"Duration")));var n=e.getAttribute("skipoffset");if(null==n)r.skipDelay=null;else if("%"===n.charAt(n.length-1)&&-1!==r.duration){var a=parseInt(n,10);r.skipDelay=r.duration*(a/100)}else r.skipDelay=L.parseDuration(n);var o=L.childByName(e,"VideoClicks");if(o){var s=L.childByName(o,"ClickThrough");r.videoClickThroughURLTemplate=s?{id:s.getAttribute("id")||null,url:L.parseNodeText(s)}:null,L.childrenByName(o,"ClickTracking").forEach((function(e){r.videoClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:L.parseNodeText(e)})})),L.childrenByName(o,"CustomClick").forEach((function(e){r.videoCustomClickURLTemplates.push({id:e.getAttribute("id")||null,url:L.parseNodeText(e)})}))}var l=L.childByName(e,"AdParameters");l&&(r.adParameters={value:L.parseNodeText(l),xmlEncoded:l.getAttribute("xmlEncoded")||null}),L.childrenByName(e,"TrackingEvents").forEach((function(e){L.childrenByName(e,"Tracking").forEach((function(e){var t=e.getAttribute("event"),n=L.parseNodeText(e);if(t&&n){if("progress"===t){if(!(i=e.getAttribute("offset")))return;t="%"===i.charAt(i.length-1)?"progress-".concat(i):"progress-".concat(Math.round(L.parseDuration(i)))}Array.isArray(r.trackingEvents[t])||(r.trackingEvents[t]=[]),r.trackingEvents[t].push(n)}}))})),L.childrenByName(e,"MediaFiles").forEach((function(e){L.childrenByName(e,"MediaFile").forEach((function(e){r.mediaFiles.push(function(e){var 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=L.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);var i=e.getAttribute("scalable");i&&"string"==typeof i&&(t.scalable=L.parseBoolean(i));var r=e.getAttribute("maintainAspectRatio");return r&&"string"==typeof r&&(t.maintainAspectRatio=L.parseBoolean(r)),t}(e))}));var t=L.childByName(e,"InteractiveCreativeFile");t&&(r.interactiveCreativeFile=function(e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,apiFramework:e.apiFramework||null,variableDuration:L.parseBoolean(e.variableDuration),fileURL:null}}(L.parseAttributes(e));return t.fileURL=L.parseNodeText(e),t}(t));var i=L.childByName(e,"ClosedCaptionFiles");i&&L.childrenByName(i,"ClosedCaptionFile").forEach((function(e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,language:e.language||null,fileURL:null}}(L.parseAttributes(e));t.fileURL=L.parseNodeText(e),r.closedCaptionFiles.push(t)}));var n,a,o,s=L.childByName(e,"Mezzanine"),l=(n=s,a={},o=!1,["delivery","type","width","height"].forEach((function(e){n&&n.getAttribute(e)?a[e]=n.getAttribute(e):o=!0})),o?null:a);if(l){var d={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};d.id=s.getAttribute("id"),d.fileURL=L.parseNodeText(s),d.delivery=l.delivery,d.codec=s.getAttribute("codec"),d.type=l.type,d.width=parseInt(l.width,10),d.height=parseInt(l.height,10),d.fileSize=parseInt(s.getAttribute("fileSize"),10),d.mediaType=s.getAttribute("mediaType")||"2D",r.mezzanine=d}}));var d=L.childByName(e,"Icons");return d&&L.childrenByName(d,"Icon").forEach((function(e){r.icons.push(function(e){var 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:[]};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=L.parseDuration(e.getAttribute("offset")),t.duration=L.parseDuration(e.getAttribute("duration")),L.childrenByName(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=L.parseNodeText(e)})),L.childrenByName(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=L.parseNodeText(e)})),L.childrenByName(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=L.parseNodeText(e)}));var i=L.childByName(e,"IconClicks");if(i){t.iconClickThroughURLTemplate=L.parseNodeText(L.childByName(i,"IconClickThrough")),L.childrenByName(i,"IconClickTracking").forEach((function(e){t.iconClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:L.parseNodeText(e)})}));var r=L.childByName(i,"IconClickFallbackImages");r&&L.childrenByName(r,"IconClickFallbackImage").forEach((function(e){t.iconClickFallbackImages.push({url:L.parseNodeText(e)||null,width:e.getAttribute("width")||null,height:e.getAttribute("height")||null})}))}return t.iconViewTrackingURLTemplate=L.parseNodeText(L.childByName(e,"IconViewTracking")),t}(e))})),r}function O(e,t){var i=function(){var e=f(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"nonlinear",variations:[],trackingEvents:{}}}(t);return L.childrenByName(e,"TrackingEvents").forEach((function(e){var t,r;L.childrenByName(e,"Tracking").forEach((function(e){t=e.getAttribute("event"),r=L.parseNodeText(e),t&&r&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(r))}))})),L.childrenByName(e,"NonLinear").forEach((function(e){var 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=L.parseBoolean(e.getAttribute("scalable")),t.maintainAspectRatio=L.parseBoolean(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=L.parseDuration(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),L.childrenByName(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=L.parseNodeText(e)})),L.childrenByName(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=L.parseNodeText(e)})),L.childrenByName(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=L.parseNodeText(e)}));var r=L.childByName(e,"AdParameters");r&&(t.adParameters={value:L.parseNodeText(r),xmlEncoded:r.getAttribute("xmlEncoded")||null}),t.nonlinearClickThroughURLTemplate=L.parseNodeText(L.childByName(e,"NonLinearClickThrough")),L.childrenByName(e,"NonLinearClickTracking").forEach((function(e){t.nonlinearClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:L.parseNodeText(e)})})),i.variations.push(t)})),i}function D(e){var t=[];return e.forEach((function(e){var i=P(e);i&&t.push(i)})),t}function P(e){if("#comment"===e.nodeName)return null;var t,i={name:null,value:null,attributes:{},children:[]},r=e.attributes,n=e.childNodes;if(i.name=e.nodeName,e.attributes)for(var a in r)if(r.hasOwnProperty(a)){var o=r[a];o.nodeName&&o.nodeValue&&(i.attributes[o.nodeName]=o.nodeValue)}for(var s in n)if(n.hasOwnProperty(s)){var l=P(n[s]);l&&i.children.push(l)}if(0===i.children.length||1===i.children.length&&["#cdata-section","#text"].indexOf(i.children[0].name)>=0){var d=L.parseNodeText(e);""!==d&&(i.value=d),i.children=[]}return null===(t=i).value&&0===Object.keys(t.attributes).length&&0===t.children.length?null:i}function U(e){var t=[];return e.forEach((function(e){var i,r={id:e.getAttribute("id")||null,adId:x(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null},n=[];L.childrenByName(e,"UniversalAdId").forEach((function(e){var t={idRegistry:e.getAttribute("idRegistry")||"unknown",value:L.parseNodeText(e)};n.push(t)}));var a=L.childByName(e,"CreativeExtensions");for(var o in a&&(i=D(L.childrenByName(a,"CreativeExtension"))),e.childNodes){var s=e.childNodes[o],l=void 0;switch(s.nodeName){case"Linear":l=w(s,r);break;case"NonLinearAds":l=O(s,r);break;case"CompanionAds":l=N(s,r)}l&&(n&&(l.universalAdIds=n),i&&(l.creativeExtensions=i),t.push(l))}})),t}function x(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}var M={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 F(e,t){if(M[e.nodeName]&&M[e.nodeName].attributes){var i=M[e.nodeName].attributes.filter((function(t){return!e.getAttribute(t)}));i.length>0&&W({name:e.nodeName,parentName:e.parentNode.nodeName,attributes:i},t)}}function B(e,t,i){var r=M[e.nodeName],n=!i&&"Wrapper"!==e.nodeName;if(r&&!n){if(r.subElements){var a=r.subElements.filter((function(t){return!L.childByName(e,t)}));a.length>0&&W({name:e.nodeName,parentName:e.parentNode.nodeName,subElements:a},t)}i&&r.oneOfinLineResources&&(r.oneOfinLineResources.some((function(t){return L.childByName(e,t)}))||W({name:e.nodeName,parentName:e.parentNode.nodeName,oneOfResources:r.oneOfinLineResources},t))}}function j(e){return e.children&&0!==e.children.length}function W(e,t){var i=e.name,r=e.parentName,n=e.attributes,a=e.subElements,o=e.oneOfResources,s="Element '".concat(i,"'");t("VAST-warning",{message:s+=n?" missing required attribute(s) '".concat(n.join(", "),"' "):a?" missing required sub element(s) '".concat(a.join(", "),"' "):o?" must provide one of the following '".concat(o.join(", "),"' "):" is empty",parentElement:r,specVersion:4.1})}var q={verifyRequiredValues:function e(t,i,r){if(t&&t.nodeName)if("InLine"===t.nodeName&&(r=!0),F(t,i),j(t)){B(t,i,r);for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{},r=i.allowMultipleAds,n=i.followAdditionalWrappers,a=e.childNodes;for(var o in a){var s=a[o];if(-1!==["Wrapper","InLine"].indexOf(s.nodeName)&&("Wrapper"!==s.nodeName||!1!==n)){if(L.copyNodeAttribute("id",e,s),L.copyNodeAttribute("sequence",e,s),L.copyNodeAttribute("adType",e,s),"Wrapper"===s.nodeName)return{ad:G(s,t),type:"WRAPPER"};if("InLine"===s.nodeName)return{ad:Q(s,t,{allowMultipleAds:r}),type:"INLINE"}}}}function Q(e,t){return!1===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).allowMultipleAds&&e.getAttribute("sequence")?null:z(e,t)}function z(e,t){var i=[];t&&q.verifyRequiredValues(e,t);var r,n,a=e.childNodes,o=function(){var 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}}(L.parseAttributes(e));for(var s in a){var l=a[s];switch(l.nodeName){case"Error":o.errorURLTemplates.push(L.parseNodeText(l));break;case"Impression":o.impressionURLTemplates.push({id:l.getAttribute("id")||null,url:L.parseNodeText(l)});break;case"Creatives":o.creatives=U(L.childrenByName(l,"Creative"));break;case"Extensions":var d=L.childrenByName(l,"Extension");o.extensions=D(d),o.adVerifications.length||(i=K(d));break;case"AdVerifications":o.adVerifications=Y(L.childrenByName(l,"Verification"));break;case"AdSystem":o.system={value:L.parseNodeText(l),version:l.getAttribute("version")||null};break;case"AdTitle":o.title=L.parseNodeText(l);break;case"AdServingId":o.adServingId=L.parseNodeText(l);break;case"Category":o.categories.push({authority:l.getAttribute("authority")||null,value:L.parseNodeText(l)});break;case"Expires":o.expires=parseInt(L.parseNodeText(l),10);break;case"ViewableImpression":o.viewableImpression.push((n=void 0,n=function(e,t){var i=L.parseNodeText(t);return i&&e.push(i),e},{id:(r=l).getAttribute("id")||null,viewable:L.childrenByName(r,"Viewable").reduce(n,[]),notViewable:L.childrenByName(r,"NotViewable").reduce(n,[]),viewUndetermined:L.childrenByName(r,"ViewUndetermined").reduce(n,[])}));break;case"Description":o.description=L.parseNodeText(l);break;case"Advertiser":o.advertiser={id:l.getAttribute("id")||null,value:L.parseNodeText(l)};break;case"Pricing":o.pricing={value:L.parseNodeText(l),model:l.getAttribute("model")||null,currency:l.getAttribute("currency")||null};break;case"Survey":o.survey={value:L.parseNodeText(l),type:l.getAttribute("type")||null};break;case"BlockedAdCategories":o.blockedAdCategories.push({authority:l.getAttribute("authority")||null,value:L.parseNodeText(l)})}}return i.length&&(o.adVerifications=o.adVerifications.concat(i)),o}function G(e,t){var i=z(e,t),r=e.getAttribute("followAdditionalWrappers"),n=e.getAttribute("allowMultipleAds"),a=e.getAttribute("fallbackOnNoAd");i.followAdditionalWrappers=!r||L.parseBoolean(r),i.allowMultipleAds=!!n&&L.parseBoolean(n),i.fallbackOnNoAd=a?L.parseBoolean(a):null;var o=L.childByName(e,"VASTAdTagURI");if(o?i.nextWrapperURL=L.parseNodeText(o):(o=L.childByName(e,"VASTAdTagURL"))&&(i.nextWrapperURL=L.parseNodeText(L.childByName(o,"URL"))),i.creatives.forEach((function(e){if(-1!==["linear","nonlinear"].indexOf(e.type)){if(e.trackingEvents){i.trackingEvents||(i.trackingEvents={}),i.trackingEvents[e.type]||(i.trackingEvents[e.type]={});var t=function(t){var r=e.trackingEvents[t];Array.isArray(i.trackingEvents[e.type][t])||(i.trackingEvents[e.type][t]=[]),r.forEach((function(r){i.trackingEvents[e.type][t].push(r)}))};for(var r in e.trackingEvents)t(r)}e.videoClickTrackingURLTemplates&&(Array.isArray(i.videoClickTrackingURLTemplates)||(i.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((function(e){i.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(i.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(Array.isArray(i.videoCustomClickURLTemplates)||(i.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((function(e){i.videoCustomClickURLTemplates.push(e)})))}})),i.nextWrapperURL)return i}function Y(e){var t=[];return e.forEach((function(e){var i={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},r=e.childNodes;for(var n in L.assignAttributes(e.attributes,i),r){var a=r[n];switch(a.nodeName){case"JavaScriptResource":case"ExecutableResource":i.resource=L.parseNodeText(a),L.assignAttributes(a.attributes,i);break;case"VerificationParameters":i.parameters=L.parseNodeText(a)}}var o=L.childByName(e,"TrackingEvents");o&&L.childrenByName(o,"Tracking").forEach((function(e){var t=e.getAttribute("event"),r=L.parseNodeText(e);t&&r&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(r))})),t.push(i)})),t}function K(e){var t=null,i=[];return e.some((function(e){return t=L.childByName(e,"AdVerifications")})),t&&(i=Y(L.childrenByName(t,"Verification"))),i}var X=function(){function e(){n(this,e),this._handlers=[]}return o(e,[{key:"on",value:function(e,t){if("function"!=typeof t)throw new TypeError("The handler argument must be of type Function. Received type ".concat(r(t)));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(r(e)));return this._handlers.push({event:e,handler:t}),this}},{key:"once",value:function(e,t){return this.on(e,function(e,t,i){var r={fired:!1,wrapFn:void 0};function n(){r.fired||(e.off(t,r.wrapFn),r.fired=!0,i.bind(e).apply(void 0,arguments))}return r.wrapFn=n,n}(this,e,t))}},{key:"off",value:function(e,t){return this._handlers=this._handlers.filter((function(i){return i.event!==e||i.handler!==t})),this}},{key:"emit",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r2?i-2:0),n=2;n1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return new Promise((function(a,o){t.URLTemplateFilters.forEach((function(t){e=t(e)}));var s=Date.now();t.emit("VAST-resolving",{url:e,previousUrl:r,wrapperDepth:i,maxWrapperDepth:t.maxWrapperDepth,timeout:t.fetchingOptions.timeout,wrapperAd:n}),t.urlHandler.get(e,t.fetchingOptions,(function(n,l){var d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=Math.round(Date.now()-s),c=Object.assign({url:e,previousUrl:r,wrapperDepth:i,error:n,duration:u},d);t.emit("VAST-resolved",c),ae(d.byteLength,u),n?o(n):a(l)}))}))}},{key:"initParsingStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.errorURLTemplates=[],this.fetchingOptions={timeout:e.timeout||J,withCredentials:e.withCredentials},this.maxWrapperDepth=e.wrapperLimit||10,this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.remainingAds=[],this.rootErrorURLTemplates=[],this.rootURL="",this.urlHandler=e.urlHandler||e.urlhandler||ie,this.vastVersion=null,ae(e.byteLength,e.requestDuration)}},{key:"getRemainingAds",value:function(e){var t=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var i=e?C.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.resolveAds(i,{wrapperDepth:0,url:this.rootURL}).then((function(e){return t.buildVASTResponse(e)}))}},{key:"getAndParseVAST",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(i),this.URLTemplateFilters.forEach((function(t){e=t(e)})),this.rootURL=e,this.fetchVAST(e).then((function(r){return i.previousUrl=e,i.isRootVAST=!0,i.url=e,t.parse(r,i).then((function(e){return t.buildVASTResponse(e)}))}))}},{key:"parseVAST",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(i),i.isRootVAST=!0,this.parse(e,i).then((function(e){return t.buildVASTResponse(e)}))}},{key:"buildVASTResponse",value:function(e){var t,i={ads:(t={ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion}).ads||[],errorURLTemplates:t.errorURLTemplates||[],version:t.version||null};return this.completeWrapperResolving(i),i}},{key:"parseVastXml",value:function(e,t){var i=t.isRootVAST,r=void 0!==i&&i,n=t.url,a=void 0===n?null:n,o=t.wrapperDepth,s=void 0===o?0:o,l=t.allowMultipleAds,d=t.followAdditionalWrappers;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName)throw this.emit("VAST-ad-parsed",{type:"ERROR",url:a,wrapperDepth:s}),new Error("Invalid VAST XMLDocument");var u=[],c=e.documentElement.childNodes,h=e.documentElement.getAttribute("version");for(var p in r&&h&&(this.vastVersion=h),c){var v=c[p];if("Error"===v.nodeName){var m=L.parseNodeText(v);r?this.rootErrorURLTemplates.push(m):this.errorURLTemplates.push(m)}else if("Ad"===v.nodeName){if(this.vastVersion&&parseFloat(this.vastVersion)<3)l=!0;else if(!1===l&&u.length>1)break;var f=H(v,this.emit.bind(this),{allowMultipleAds:l,followAdditionalWrappers:d});f.ad?(u.push(f.ad),this.emit("VAST-ad-parsed",{type:f.type,url:a,wrapperDepth:s,adIndex:u.length-1,vastVersion:h})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return u}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.url,r=void 0===i?null:i,n=t.resolveAll,a=void 0===n||n,o=t.wrapperSequence,s=void 0===o?null:o,l=t.previousUrl,d=void 0===l?null:l,u=t.wrapperDepth,c=void 0===u?0:u,h=t.isRootVAST,p=void 0!==h&&h,v=t.followAdditionalWrappers,m=t.allowMultipleAds,f=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&p&&(m=!0);try{f=this.parseVastXml(e,{isRootVAST:p,url:r,wrapperDepth:c,allowMultipleAds:m,followAdditionalWrappers:v})}catch(e){return Promise.reject(e)}return 1===f.length&&null!=s&&(f[0].sequence=s),!1===a&&(this.remainingAds=L.splitVAST(f),f=this.remainingAds.shift()),this.resolveAds(f,{wrapperDepth:c,previousUrl:d,url:r})}},{key:"resolveAds",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1?arguments[1]:void 0,r=i.wrapperDepth,n=i.previousUrl,a=i.url,o=[];return n=a,t.forEach((function(t){var i=e.resolveWrappers(t,r,n);o.push(i)})),Promise.all(o).then((function(t){var i=C.flatten(t);if(!i&&e.remainingAds.length>0){var o=e.remainingAds.shift();return e.resolveAds(o,{wrapperDepth:r,previousUrl:n,url:a})}return i}))}},{key:"resolveWrappers",value:function(e,t,i){var r=this;return new Promise((function(n){var a;if(t++,!e.nextWrapperURL)return delete e.nextWrapperURL,n(e);if(t>=r.maxWrapperDepth)return e.errorCode=302,delete e.nextWrapperURL,n(e);e.nextWrapperURL=L.resolveVastAdTagURI(e.nextWrapperURL,i),r.URLTemplateFilters.forEach((function(t){e.nextWrapperURL=t(e.nextWrapperURL)}));var o=null!==(a=r.parsingOptions.allowMultipleAds)&&void 0!==a?a:e.allowMultipleAds,s=e.sequence;r.fetchVAST(e.nextWrapperURL,t,i,e).then((function(a){return r.parse(a,{url:e.nextWrapperURL,previousUrl:i,wrapperSequence:s,wrapperDepth:t,followAdditionalWrappers:e.followAdditionalWrappers,allowMultipleAds:o}).then((function(t){if(delete e.nextWrapperURL,0===t.length)return e.creatives=[],n(e);t.forEach((function(t){t&&L.mergeWrapperAdData(t,e)})),n(t)}))})).catch((function(t){e.errorCode=301,e.errorMessage=t.message,n(e)}))}))}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;t>=0;t--){var i=e.ads[t];(i.errorCode||0===i.creatives.length)&&(this.trackVastError(i.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:i.errorCode||303},{ERRORMESSAGE:i.errorMessage||""},{extensions:i.extensions},{system:i.system}),e.ads.splice(t,1))}}}]),i}(X),le=null,de={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},ue=function(){function e(){n(this,e),this.storage=this.initStorage()}return o(e,[{key:"initStorage",value:function(){if(le)return le;try{le="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){le=null}return le&&!this.isStorageDisabled(le)||(le=de).clear(),le}},{key:"isStorageDisabled",value:function(e){var 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}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),ce=function(){function e(t,i,r){n(this,e),this.cappingFreeLunch=t||0,this.cappingMinimumTimeInterval=i||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new se,this.storage=r||new ue,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return o(e,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(e){this.storage.setItem("vast-client-last-successful-ad",e)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(e){this.storage.setItem("vast-client-total-calls",e)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(e){this.storage.setItem("vast-client-total-calls-timeout",e)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(e){return this.vastParser.getRemainingAds(e)}},{key:"get",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(i=Object.assign({},this.defaultOptions,i)).hasOwnProperty("resolveAll")||(i.resolveAll=!1),this.totalCallsTimeout=t.totalCalls)return a(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(t.totalCalls,"/").concat(t.cappingFreeLunch)));var o=r-t.lastSuccessfulAd;if(o<0)t.lastSuccessfulAd=0;else if(o3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4];for(var d in n(this,a),(o=t.call(this)).ad=i,o.creative=r,o.variation=s,o.muted=l,o.impressed=!1,o.skippable=!1,o.trackingEvents={},o.lastPercentage=0,o._alreadyTriggeredQuartiles={},o.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],o.creative.trackingEvents){var u=o.creative.trackingEvents[d];o.trackingEvents[d]=u.slice(0)}return function(e){return"linear"===e.type}(o.creative)?o._initLinearTracking():o._initVariationTracking(),e&&o.on("start",(function(){e.lastSuccessfulAd=Date.now()})),o}return o(a,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var e in this.variation.trackingEvents){var 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)}}},{key:"setDuration",value:function(e){C.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})}},{key:"setProgress",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(C.isValidTimeValue(e)&&"object"===r(i)){var 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){var a=Math.round(e/this.assetDuration*100),o=[];if(e>0){o.push("start");for(var s=this.lastPercentage;s1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.muted!==e&&this.track(e?"mute":"unmute",{macros:t}),this.muted=e)}},{key:"setPaused",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.paused!==e&&this.track(e?"pause":"resume",{macros:t}),this.paused=e)}},{key:"setFullscreen",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen",{macros:t}),this.fullscreen=e)}},{key:"setExpand",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.expanded!==e&&(this.track(e?"expand":"collapse",{macros:t}),this.track(e?"playerExpand":"playerCollapse",{macros:t})),this.expanded=e)}},{key:"setSkipDelay",value:function(e){C.isValidTimeValue(e)&&(this.skipDelay=e)}},{key:"trackImpression",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&(this.impressed||(this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates,e),this.track("creativeView",{macros:e})))}},{key:"trackViewableImpression",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(t)&&this.ad.viewableImpression.forEach((function(i){e.trackURLs(i.viewable,t)}))}},{key:"trackNotViewableImpression",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(t)&&this.ad.viewableImpression.forEach((function(i){e.trackURLs(i.notViewable,t)}))}},{key:"trackUndeterminedImpression",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(t)&&this.ad.viewableImpression.forEach((function(i){e.trackURLs(i.viewUndetermined,t)}))}},{key:"error",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"===r(e)&&"boolean"==typeof t&&this.trackURLs(this.ad.errorURLTemplates,e,{isCustomCode:t})}},{key:"errorWithCode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"string"==typeof e&&"boolean"==typeof t&&this.error({ERRORCODE:e},t)}},{key:"complete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("complete",{macros:e})}},{key:"notUsed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&(this.track("notUsed",{macros:e}),this.trackingEvents=[])}},{key:"otherAdInteraction",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("otherAdInteraction",{macros:e})}},{key:"acceptInvitation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("acceptInvitation",{macros:e})}},{key:"adExpand",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("adExpand",{macros:e})}},{key:"adCollapse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("adCollapse",{macros:e})}},{key:"minimize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("minimize",{macros:e})}},{key:"verificationNotExecuted",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e&&"object"===r(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");var i=this.ad.adVerifications.find((function(t){return t.vendor===e}));if(!i)throw new Error("No associated verification element found for vendor: ".concat(e));var n=i.trackingEvents;if(n&&n.verificationNotExecuted){var a=n.verificationNotExecuted;this.trackURLs(a,t),this.emit("verificationNotExecuted",{trackingURLTemplates:a})}}}},{key:"overlayViewDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"==typeof e&&"object"===r(t)&&(t.ADPLAYHEAD=e,this.track("overlayViewDuration",{macros:t}))}},{key:"close",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track(this.linear?"closeLinear":"close",{macros:e})}},{key:"skip",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("skip",{macros:e})}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("loaded",{macros:e})}},{key:"click",value:function(){var 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"===r(t)){this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates,t);var n=this.clickThroughURLTemplate||e,a=i({},t);if(n){this.progress&&(a.ADPLAYHEAD=this.progressFormatted());var o=C.resolveURLTemplates([n],a)[0];this.emit("clickthrough",o)}}}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.macros,n=void 0===i?{}:i,a=t.once,o=void 0!==a&&a;if("object"===r(n)){"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close");var s=this.trackingEvents[e],l=this.emitAlwaysEvents.indexOf(e)>-1;s?(this.emit(e,{trackingURLTemplates:s}),this.trackURLs(s,n)):l&&this.emit(e,null),o&&(delete this.trackingEvents[e],l&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}}},{key:"trackURLs",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=C.filterValidUrlTemplates(e),o=i({},r);this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(o.ASSETURI=this.creative.mediaFiles[0].fileURL),this.progress&&(o.ADPLAYHEAD=this.progressFormatted())),null!==(t=this.creative)&&void 0!==t&&null!==(t=t.universalAdIds)&&void 0!==t&&t.length&&(o.UNIVERSALADID=this.creative.universalAdIds.map((function(e){return e.idRegistry.concat(" ",e.value)})).join(",")),this.ad&&(this.ad.sequence&&(o.PODSEQUENCE=this.ad.sequence),this.ad.adType&&(o.ADTYPE=this.ad.adType),this.ad.adServingId&&(o.ADSERVINGID=this.ad.adServingId),this.ad.categories&&this.ad.categories.length&&(o.ADCATEGORIES=this.ad.categories.map((function(e){return e.value})).join(",")),this.ad.blockedAdCategories&&this.ad.blockedAdCategories.length&&(o.BLOCKEDADCATEGORIES=this.ad.blockedAdCategories)),C.track(a,o,n)}},{key:"convertToTimecode",value:function(e){if(!C.isValidTimeValue(e))return"";var t=1e3*e,i=Math.floor(t/36e5),r=Math.floor(t/6e4%60),n=Math.floor(t/1e3%60),a=Math.floor(t%1e3);return"".concat(C.addLeadingZeros(i,2),":").concat(C.addLeadingZeros(r,2),":").concat(C.addLeadingZeros(n,2),".").concat(C.addLeadingZeros(a,3))}},{key:"progressFormatted",value:function(){return this.convertToTimecode(this.progress)}}]),a}(X);e.VASTClient=ce,e.VASTParser=se,e.VASTTracker=he,e.parseDuration=I,Object.defineProperty(e,"__esModule",{value:!0})}(t)}},t={};function i(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,i),a.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};(()=>{i.d(r,{Z:()=>l});var e=i(686);const t=function(e,t,i){this.message=e,this.errorCode=t,this.innerError=i};t.prototype.getMessage=function(){return this.message},t.prototype.getErrorCode=function(){return this.errorCode},t.prototype.getInnerError=function(){return this.innerError instanceof Object?this.innerError:null},t.prototype.setInnerError=function(e){this.innerError=e},t.prototype.formatMessage=function(...e){return this.message=function(e,...t){try{t.forEach(((t,i)=>{e=e.replace(new RegExp("\\{"+i+"}","g"),t)}))}catch(e){}return e}(this.message,e),this},t.prototype.toString=function(){return"AdError "+this.getErrorCode()+": "+this.getMessage()+(null!=this.getInnerError()?" Caused by: "+this.getInnerError():"")};const n=t,a=function(e){this.adId=e.adId,this.duration=e.duration,this.linear="linear"===e.type};a.prototype.getAdId=function(){return this.adId},a.prototype.getDuration=function(){return this.duration},a.prototype.getMediaUrl=function(){return null},a.prototype.isLinear=function(){return this.linear};const o=a,s=function(e){if(!e||!(e instanceof HTMLElement||e.getRootNode))throw new Error("ad container is not defined");this._adContainer=e,this._slot=null,this._videoSlot=null,this.createSlot(),this.EVENTS={AdsManagerLoaded:"AdsManagerLoaded",AdStarted:"AdStarted",AdStopped:"AdStopped",AdSkipped:"AdSkipped",AdLoaded:"AdLoaded",AdLinearChange:"AdLinearChange",AdSizeChange:"AdSizeChange",AdExpandedChange:"AdExpandedChange",AdSkippableStateChange:"AdSkippableStateChange",AdDurationChange:"AdDurationChange",AdRemainingTimeChange:"AdRemainingTimeChange",AdVolumeChange:"AdVolumeChange",AdImpression:"AdImpression",AdClickThru:"AdClickThru",AdInteraction:"AdInteraction",AdVideoStart:"AdVideoStart",AdVideoFirstQuartile:"AdVideoFirstQuartile",AdVideoMidpoint:"AdVideoMidpoint",AdVideoThirdQuartile:"AdVideoThirdQuartile",AdVideoComplete:"AdVideoComplete",AdUserAcceptInvitation:"AdUserAcceptInvitation",AdUserMinimize:"AdUserMinimize",AdUserClose:"AdUserClose",AdPaused:"AdPaused",AdPlaying:"AdPlaying",AdError:"AdError",AdLog:"AdLog",AllAdsCompleted:"AllAdsCompleted"},this._eventCallbacks={},this._creativeEventCallbacks={},this._attributes={width:300,height:154,viewMode:"normal",desiredBitrate:-1,duration:10,remainingTime:10,currentTime:0,volume:0,version:"1.2.12"},this._quartileEvents=[{event:"AdImpression",value:0},{event:"AdVideoStart",value:0},{event:"AdVideoFirstQuartile",value:25},{event:"AdVideoMidpoint",value:50},{event:"AdVideoThirdQuartile",value:75},{event:"AdVideoComplete",value:100}],this._nextQuartileIndex=0,this._defaultEventCallbacks={AdImpression:this.onAdImpression.bind(this),AdVideoStart:this.onAdVideoStart.bind(this),AdVideoFirstQuartile:this.onAdVideoFirstQuartile.bind(this),AdVideoMidpoint:this.onAdVideoMidpoint.bind(this),AdVideoThirdQuartile:this.onAdVideoThirdQuartile.bind(this),AdVideoComplete:this.onAdVideoComplete.bind(this)},this._options={autoplay:!0,muted:!0,vastLoadTimeout:23e3,loadVideoTimeout:8e3,withCredentials:!1,wrapperLimit:10,resolveAll:!0},this.ERROR_CODES={VAST_MALFORMED_RESPONSE:100,ADS_REQUEST_NETWORK_ERROR:1012,FAILED_TO_REQUEST_ADS:1005,UNKNOWN_AD_RESPONSE:1010,VAST_ASSET_NOT_FOUND:1007,VAST_EMPTY_RESPONSE:1009,VAST_LINEAR_ASSET_MISMATCH:403,VAST_LOAD_TIMEOUT:301,VAST_MEDIA_LOAD_TIMEOUT:402,VIDEO_PLAY_ERROR:400,VPAID_ERROR:901},this.ERROR_MESSAGES={VAST_MALFORMED_RESPONSE:"VAST response was malformed and could not be parsed.",ADS_REQUEST_ERROR:"Unable to request ads from server. Cause: {0}.",ADS_REQUEST_NETWORK_ERROR:"Unable to request ads from server due to network error.",FAILED_TO_REQUEST_ADS:"The was a problem requesting ads from the server.",NO_ADS_FOUND:"The response does not contain any valid ads.",UNKNOWN_AD_RESPONSE:"The ad response was not understood and cannot be parsed.",VAST_ASSET_NOT_FOUND:"No assets were found in the VAST ad response.",VAST_EMPTY_RESPONSE:"The VAST response document is empty.",VAST_LINEAR_ASSET_MISMATCH:"Linear assets were found in the VAST ad response, but none of them matched the player's capabilities.",VAST_LOAD_TIMEOUT:"Ad request reached a timeout.",VAST_MEDIA_LOAD_TIMEOUT:"VAST media file loading reached a timeout of {0} seconds.",VIDEO_PLAY_ERROR:"There was an error playing the video ad.",VPAID_CREATIVE_ERROR:"An unexpected error occurred within the VPAID creative. Refer to the inner error for more info."},this.ERRORS={VAST_MALFORMED_RESPONSE:new n(this.ERROR_MESSAGES.VAST_MALFORMED_RESPONSE,this.ERROR_CODES.VAST_MALFORMED_RESPONSE),VAST_EMPTY_RESPONSE:new n(this.ERROR_MESSAGES.VAST_EMPTY_RESPONSE,this.ERROR_CODES.VAST_EMPTY_RESPONSE),VAST_ASSET_NOT_FOUND:new n(this.ERROR_MESSAGES.VAST_ASSET_NOT_FOUND,this.ERROR_CODES.VAST_ASSET_NOT_FOUND),VAST_LINEAR_ASSET_MISMATCH:new n(this.ERROR_MESSAGES.VAST_LINEAR_ASSET_MISMATCH,this.ERROR_CODES.VAST_LINEAR_ASSET_MISMATCH),VAST_LOAD_TIMEOUT:new n(this.ERROR_MESSAGES.VAST_LOAD_TIMEOUT,this.ERROR_CODES.VAST_LOAD_TIMEOUT),VAST_MEDIA_LOAD_TIMEOUT:new n(this.ERROR_MESSAGES.VAST_MEDIA_LOAD_TIMEOUT,this.ERROR_CODES.VAST_MEDIA_LOAD_TIMEOUT),VIDEO_PLAY_ERROR:new n(this.ERROR_MESSAGES.VIDEO_PLAY_ERROR,this.ERROR_CODES.VIDEO_PLAY_ERROR),VPAID_CREATIVE_ERROR:new n(this.ERROR_MESSAGES.VPAID_CREATIVE_ERROR,this.ERROR_CODES.VPAID_ERROR)},this._vastClient=null,this._vastParser=null,this._vastTracker=null,this._ad=null,this._adPod=null,this._isAdPod=!1,this._creative=null,this._mediaFiles=null,this._mediaFileIndex=0,this._mediaFile=null,this._isVPAID=!1,this._vpaidIframe=null,this._vpaidCreative=null,this._vastMediaLoadTimer=null,this._vpaidProgressTimer=null,this._requestId=null,this._handleLoadCreativeMessage=this.handleLoadCreativeMessage.bind(this),this._handleSlotClick=this.handleSlotClick.bind(this),this._handleVideoSlotError=this.handleVideoSlotError.bind(this),this._handleVideoSlotCanPlay=this.handleVideoSlotCanPlay.bind(this),this._handleVideoSlotVolumeChange=this.handleVideoSlotVolumeChange.bind(this),this._handleVideoSlotTimeUpdate=this.handleVideoSlotTimeUpdate.bind(this),this._handleVideoSlotLoadedMetaData=this.handleVideoSlotLoadedMetaData.bind(this),this._handleVideoSlotEnded=this.handleVideoSlotEnded.bind(this),this.MIN_VPAID_VERSION=2,this._hasLoaded=!1,this._hasError=!1,this._hasImpression=!1,this._hasStarted=!1,this._isDestroyed=!1};s.prototype.createSlot=function(){this._slot=document.createElement("div"),this._slot.style.position="absolute",this._adContainer.appendChild(this._slot),this.createVideoSlot()},s.prototype.removeSlot=function(){this._slot.parentNode&&this._slot.parentNode.removeChild(this._slot)},s.prototype.showSlot=function(){""===this._videoSlot.src&&this.hideVideoSlot(),this._slot.style.display="block"},s.prototype.hideSlot=function(){this._slot.style.display="none"},s.prototype.resizeSlot=function(e,t){this._slot.style.width=e+"px",this._slot.style.height=t+"px"},s.prototype.createVideoSlot=function(){this._videoSlot=document.createElement("video"),this._videoSlot.setAttribute("webkit-playsinline",!0),this._videoSlot.setAttribute("playsinline",!0),this._videoSlot.style.width="100%",this._videoSlot.style.height="100%",this._videoSlot.style.backgroundColor="rgb(0, 0, 0)",this._videoSlot.style.display="none";const e=this,t=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"src");Object.defineProperty(this._videoSlot,"src",{set:function(i){t.set.call(this,i),e.showHideVideoSlot()},get:t.get});const i=this._videoSlot.setAttribute;this._videoSlot.setAttribute=function(){const t=i.apply(this,[].slice.call(arguments));return"src"===arguments[0]&&e.showHideVideoSlot(),t},this._slot.appendChild(this._videoSlot)},s.prototype.hideVideoSlot=function(){this._videoSlot.style.display="none"},s.prototype.showVideoSlot=function(){this._videoSlot.style.display="block"},s.prototype.showHideVideoSlot=function(){""===this._videoSlot.getAttribute("src")?this.hideVideoSlot():this.showVideoSlot()},s.prototype.stopVASTMediaLoadTimeout=function(){this._vastMediaLoadTimer&&(clearTimeout(this._vastMediaLoadTimer),this._vastMediaLoadTimer=null)},s.prototype.startVASTMediaLoadTimeout=function(){this.stopVASTMediaLoadTimeout(),this._vastMediaLoadTimer=setTimeout((()=>{this.onAdError(this.ERRORS.VAST_MEDIA_LOAD_TIMEOUT.formatMessage(Math.floor(this._options.loadVideoTimeout/1e3%60)))}),this._options.loadVideoTimeout)},s.prototype.updateVPAIDProgress=function(){this._attributes.remainingTime=this._isCreativeFunctionInvokable("getAdRemainingTime")?this._vpaidCreative.getAdRemainingTime():-1,isNaN(this._attributes.remainingTime)||1===this._attributes.remainingTime||(this._attributes.currentTime=this._attributes.duration-this._attributes.remainingTime,this._vastTracker.setProgress(this._attributes.currentTime))},s.prototype.startVPAIDProgress=function(){this.stopVPAIDProgress(),this._vpaidProgressTimer=setInterval((()=>{this._isVPAID&&this._vpaidCreative&&this._vastTracker?this.updateVPAIDProgress():this.stopVPAIDProgress()}),1e3)},s.prototype.stopVPAIDProgress=function(){this._vpaidProgressTimer&&(clearInterval(this._vpaidProgressTimer),this._vpaidProgressTimer=null)},s.prototype._callEvent=function(e){e in this._eventCallbacks&&this._eventCallbacks[e]()},s.prototype.addEventListener=function(e,t,i){const r=t.bind(i);this._eventCallbacks[e]=r},s.prototype.removeEventListener=function(e){this._eventCallbacks[e]=null},s.prototype.removeEventListeners=function(e){for(const t in e)e.hasOwnProperty(t)&&this.removeEventListener(t)},s.prototype.onAdsManagerLoaded=function(){this._callEvent(this.EVENTS.AdsManagerLoaded)},s.prototype.onAdLoaded=function(){this._hasLoaded=!0,this.stopVASTMediaLoadTimeout(),this.EVENTS.AdLoaded in this._eventCallbacks&&this._eventCallbacks[this.EVENTS.AdLoaded](new o(this._creative))},s.prototype.onAdDurationChange=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&(this._attributes.duration=this._isCreativeFunctionInvokable("getAdDuration")?this._vpaidCreative.getAdDuration():-1,-1!==this._attributes.duration&&this._vastTracker.setDuration(this._attributes.duration)),this._callEvent(this.EVENTS.AdDurationChange)},s.prototype.onAdSizeChange=function(){this._callEvent(this.EVENTS.AdSizeChange)},s.prototype.onAdStarted=function(){this._hasStarted=!0,this._callEvent(this.EVENTS.AdStarted)},s.prototype.onAdVideoStart=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this.updateVPAIDProgress(),this._callEvent(this.EVENTS.AdVideoStart)},s.prototype.onAdStopped=function(){this._hasStarted?this._isAdPod&&0!=this._adPod.length?(this._nextQuartileIndex=0,this._hasImpression=!1,window.removeEventListener("message",this._handleLoadCreativeMessage),this._isVPAID&&(this.removeCallbacksForCreative(this._creativeEventCallbacks),this.removeCreativeAsset(),this._isVPAID=!1),this._removeHandlers(),this._videoSlot.pause(),this._videoSlot.removeAttribute("src"),this._videoSlot.load(),setTimeout((()=>{this._nextAd()}),75)):(this._callEvent(this.EVENTS.AdStopped),this._abort()):this.onAdError(this.ERRORS.VPAID_CREATIVE_ERROR)},s.prototype.onAdSkipped=function(){this._callEvent(this.EVENTS.AdSkipped),this._abort()},s.prototype.onAdVolumeChange=function(){this._callEvent(this.EVENTS.AdVolumeChange)},s.prototype.onAdImpression=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&(this._hasImpression||(this._attributes.duration=this._isCreativeFunctionInvokable("getAdDuration")?this._vpaidCreative.getAdDuration():-1,-1!==this._attributes.duration&&this._vastTracker.setDuration(this._attributes.duration),this._vastTracker.trackImpression(),this.startVPAIDProgress(),this._hasImpression=!0)),this._callEvent(this.EVENTS.AdImpression)},s.prototype.onAdClickThru=function(e,t,i){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this._vastTracker.click(),this.EVENTS.AdClickThru in this._eventCallbacks&&this._eventCallbacks[this.EVENTS.AdClickThru](e,t,i)},s.prototype.onAdVideoFirstQuartile=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this.updateVPAIDProgress(),this._callEvent(this.EVENTS.AdVideoFirstQuartile)},s.prototype.onAdVideoMidpoint=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this.updateVPAIDProgress(),this._callEvent(this.EVENTS.AdVideoMidpoint)},s.prototype.onAdVideoThirdQuartile=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this.updateVPAIDProgress(),this._callEvent(this.EVENTS.AdVideoThirdQuartile)},s.prototype.onAdPaused=function(){this._vastTracker&&this._vastTracker.setPaused(!0),this._callEvent(this.EVENTS.AdPaused)},s.prototype.onAdPlaying=function(){this._vastTracker&&this._vastTracker.setPaused(!1),this._callEvent(this.EVENTS.AdPlaying)},s.prototype.onAdVideoComplete=function(){this._isVPAID&&this._vpaidCreative&&this._vastTracker&&this._vastTracker.complete(),this._callEvent(this.EVENTS.AdVideoComplete)},s.prototype.onAllAdsCompleted=function(){this._callEvent(this.EVENTS.AllAdsCompleted)},s.prototype.onAdError=function(e){this._hasError=!0,this.abort(),this.EVENTS.AdError in this._eventCallbacks&&this._eventCallbacks[this.EVENTS.AdError]("object"!=typeof e?new n(e):e)},s.prototype.onAdLog=function(e){this.EVENTS.AdLog in this._eventCallbacks&&this._eventCallbacks[this.EVENTS.AdLog](e)},s.prototype.processVASTResponse=function(e){const t=e.ads;0!=t.length?(t.length>1?(this._isAdPod=!0,this._adPod=t.sort((function(e,t){const i=e.sequence,r=t.sequence;return i===r?0:null===i?1:null===r||ir?1:0})),this._ad=this._adPod.shift()):this._ad=t[0],this._processAd()):this.onAdError(this.ERRORS.VAST_EMPTY_RESPONSE)},s.prototype.requestAds=function(t,i={}){if(this._isDestroyed)return;this._requestId=(new Date).getTime(),Object.assign(this._options,i);const r={timeout:this._options.vastLoadTimeout,withCredentials:this._options.withCredentials,wrapperLimit:this._options.wrapperLimit,resolveAll:this._options.resolveAll};if(this.abort(),t&&"string"==typeof t){let i=!1;try{new URL(t),i=!0}catch(e){}if(i)this._vastClient=new e.VASTClient,this._vastClient.get(t,r).then((e=>{this.processVASTResponse(e)})).catch((e=>{this.onAdError(e.message)}));else{const i=(new window.DOMParser).parseFromString(t,"text/xml");this._vastParser=new e.VASTParser,this._vastParser.parseVAST(i,r).then((e=>{this.processVASTResponse(e)})).catch((e=>{this.onAdError(e.message)}))}}else this.onAdError("VAST URL/XML is empty")},s.prototype.canPlayVideoType=function(e){return!("video/3gpp"!==e||!this.supportsThreeGPVideo())||(!("video/webm"!==e||!this.supportsWebmVideo())||(!("video/ogg"!==e||!this.supportsOggTheoraVideo())||!("video/mp4"!==e||!this.supportsH264BaselineVideo())))},s.prototype.supportsVideo=function(){return!!document.createElement("video").canPlayType},s.prototype.supportsH264BaselineVideo=function(){return!!this.supportsVideo()&&document.createElement("video").canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')},s.prototype.supportsOggTheoraVideo=function(){return!!this.supportsVideo()&&document.createElement("video").canPlayType('video/ogg; codecs="theora, vorbis"')},s.prototype.supportsWebmVideo=function(){return!!this.supportsVideo()&&document.createElement("video").canPlayType('video/webm; codecs="vp8, vorbis"')},s.prototype.supportsThreeGPVideo=function(){return!!this.supportsVideo()&&document.createElement("video").canPlayType('video/3gpp; codecs="mp4v.20.8, samr"')},s.prototype.handshakeVersion=function(e){return this._vpaidCreative.handshakeVersion(e)},s.prototype._isCreativeFunctionInvokable=function(e){return!!this._vpaidCreative&&((e=this._vpaidCreative[e])&&"function"==typeof e)},s.prototype.checkVPAIDInterface=function(e){const t={passed:!0,missingInterfaces:""};for(let i=e.length-1;0<=i;i--)this._isCreativeFunctionInvokable(e[i])||(t.passed=!1,t.missingInterfaces+=e[i]+" ");return t},s.prototype.setCallbacksForCreative=function(e,t){for(const i in e)e.hasOwnProperty(i)&&this._vpaidCreative.subscribe(e[i],i,t)},s.prototype.removeCallbacksForCreative=function(e){if(null!==this._vpaidCreative)for(const t in e)e.hasOwnProperty(t)&&this._vpaidCreative.unsubscribe(t)},s.prototype.creativeAssetLoaded=function(){if(function(e){const t=e.checkVPAIDInterface("handshakeVersion initAd startAd stopAd subscribe unsubscribe getAdLinear".split(" "));return t.passed||e.onAdError("Missing interfaces in the VPAID creative: "+t.missingInterfaces),t.passed}(this)&&(()=>{const e=this.handshakeVersion(this.MIN_VPAID_VERSION.toFixed(1));return e?!(parseFloat(e)= "+this.MIN_VPAID_VERSION.toFixed(1)),!1):(this.onAdError("Cannot get VPAID version from the creative"),!1)})()){this._creativeEventCallbacks={AdStarted:this.onAdStarted,AdStopped:this.onAdStopped,AdSkipped:this.onAdSkipped,AdLoaded:this.onAdLoaded,AdSizeChange:this.onAdSizeChange,AdDurationChange:this.onAdDurationChange,AdVolumeChange:this.onAdVolumeChange,AdImpression:this.onAdImpression,AdClickThru:this.onAdClickThru,AdVideoStart:this.onAdVideoStart,AdVideoFirstQuartile:this.onAdVideoFirstQuartile,AdVideoMidpoint:this.onAdVideoMidpoint,AdVideoThirdQuartile:this.onAdVideoThirdQuartile,AdVideoComplete:this.onAdVideoComplete,AdPaused:this.onAdPaused,AdPlaying:this.onAdPlaying,AdError:this.onAdError,AdLog:this.onAdLog},this.setCallbacksForCreative(this._creativeEventCallbacks,this);const e=this._attributes.width,t=this._attributes.height,i={AdParameters:this._creative.adParameters},r={slot:this._slot,videoSlot:this._videoSlot,videoSlotCanAutoPlay:!0};this.startVASTMediaLoadTimeout();try{this._vpaidCreative.initAd(e,t,this._attributes.viewMode,this._attributes.desiredBitrate,i,r)}catch(e){this.onAdError(e)}}},s.prototype.handleLoadCreativeMessage=function(e){if(e&&e.data){const t=String(e.data).match(new RegExp("adm:"+this._requestId+"://(.*)"));if(t){const e=JSON.parse(t[1]);if("load"==e)try{let e=this._vpaidIframe.contentWindow.getVPAIDAd;e&&"function"==typeof e?(e=e(),void 0===e?this.onAdError("getVPAIDAd() returns undefined value"):null==e?this.onAdError("getVPAIDAd() returns null"):(this._vpaidCreative=e,this.creativeAssetLoaded())):this.onAdError("getVPAIDAd() is undefined")}catch(e){this.onAdError(e)}else"error"==e&&this.onAdError("Error load VPAID")}}},s.prototype.loadCreativeAsset=function(e){window.addEventListener("message",this._handleLoadCreativeMessage),this._vpaidIframe=document.createElement("iframe"),this._vpaidIframe.style.display="none",this._vpaidIframe.style.width="0px",this._vpaidIframe.style.height="0px",this._adContainer.appendChild(this._vpaidIframe),this._vpaidIframe.contentWindow.document.open(),this._vpaidIframe.contentWindow.document.write(`\n