Skip to content

Instantly share code, notes, and snippets.

@simevidas
Created September 29, 2022 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simevidas/36dab6b4ea724a80ee630041a2357e36 to your computer and use it in GitHub Desktop.
Save simevidas/36dab6b4ea724a80ee630041a2357e36 to your computer and use it in GitHub Desktop.
!(function (e, t) {
if ('object' == typeof exports && 'object' == typeof module)
module.exports = t();
else if ('function' == typeof define && define.amd) define([], t);
else {
var n = t();
for (var o in n) ('object' == typeof exports ? exports : e)[o] = n[o];
}
})(self, function () {
return (() => {
'use strict';
var e,
t,
n = {
r: (e) => {
'undefined' != typeof Symbol &&
Symbol.toStringTag &&
Object.defineProperty(e, Symbol.toStringTag, { value: 'Module' }),
Object.defineProperty(e, '__esModule', { value: !0 });
},
},
o = {};
n.r(o),
(function (e) {
(e.HORIZONTAL = 'HORIZONTAL'),
(e.RECTANGLE = 'RECTANGLE'),
(e.VERTICAL = 'VERTICAL'),
(e.MOBILE = 'MOBILE'),
(e.MOBILE_BIG = 'MOBILE_BIG'),
(e.MOBILE_HORIZONTAL = 'MOBILE_HORIZONTAL'),
(e.PORTRAIT = 'PORTRAIT'),
(e.BILLBOARD = 'BILLBOARD');
})(e || (e = {}));
var i =
(((t = {})[e.HORIZONTAL] = [
[970, 90],
[728, 90],
[468, 60],
[234, 60],
]),
(t[e.RECTANGLE] = [
[336, 280],
[300, 250],
[250, 250],
[200, 200],
[180, 150],
[125, 125],
]),
(t[e.VERTICAL] = [
[300, 600],
[160, 600],
[120, 600],
[120, 240],
]),
(t[e.MOBILE] = [[320, 50]]),
(t[e.MOBILE_BIG] = [
[320, 100],
[320, 50],
]),
(t[e.MOBILE_HORIZONTAL] = [
[970, 90],
[728, 90],
[468, 60],
[320, 100],
[320, 50],
[234, 60],
]),
(t[e.PORTRAIT] = [[300, 1050]]),
(t[e.BILLBOARD] = [[970, 250]]),
(t['300x600'] = [
[300, 600],
[160, 600],
]),
(t['336x280'] = [
[336, 280],
[300, 250],
]),
(t['728x90'] = [
[728, 90],
[468, 60],
]),
(t['970x90'] = [
[970, 90],
[728, 90],
[468, 60],
]),
t),
r = 'https://ads.assemblyexchange.com',
a = 'web_'.concat('2.1.3'),
s = 'ana_client_uid',
d = 'ana_client_session_id',
c = 'ana_vast',
l = 'ana_staging',
u = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
p = '//c.amazon-adsystem.com/aax2/apstag.js',
h = [
new RegExp('^https://js.media-lab.ai$'),
new RegExp('^https://apps.media-lab.ai$'),
new RegExp('^https://ads.assemblyexchange.com$'),
new RegExp('^https://staging.apps.media-lab.ai$'),
new RegExp('^https://tpc.googlesyndication.com$'),
new RegExp(
'^https?://ana-sdk-creative.s3-website-us-west-2.amazonaws.com$'
),
new RegExp('^https://\\w+.safeframe.googlesyndication.com$'),
new RegExp('^https?://localhost:9000$'),
new RegExp('^https?://127.0.0.1:9000$'),
],
g = [
new RegExp('^https://js.media-lab.ai$'),
new RegExp('^https://apps.media-lab.ai$'),
new RegExp('^https://ads.assemblyexchange.com$'),
new RegExp('^https://staging.apps.media-lab.ai$'),
new RegExp('^https?://localhost:2279$'),
new RegExp('^https?://127.0.0.1:2279$'),
],
f = 417,
y = 'frequency_cap',
m = 'cs_',
v = 'cs_is_valid',
b = 2500,
E = function () {
var e = null;
if (
(window.XMLHttpRequest
? (e = new XMLHttpRequest())
: window.ActiveXObject &&
(e = new ActiveXObject('Microsoft.XMLHTTP')),
!e)
)
throw Error('Cannot create an XMLHttpRequest instance');
return e;
},
A = function (e) {
(e.withCredentials = !0),
e.setRequestHeader('Content-Type', 'application/json'),
e.setRequestHeader(
'ana-api-key',
'056363cfdcfcf7de5cea11820138b4d2daf3ca'
),
e.setRequestHeader('lib_version', a),
e.setRequestHeader('publisher_version', 'web_0.0.1');
},
w = function (e, t) {
void 0 === t && (t = {});
var n,
o,
i = new URL(e);
return t && t !== {}
? (void 0 !== i.searchParams
? Object.keys(t).forEach(function (e) {
return i.searchParams.append(e, String(t[e]));
})
: (i.href +=
'?' +
((n = t),
(o = []),
Object.keys(n).forEach(function (e) {
o.push(
encodeURIComponent(e) + '=' + encodeURIComponent(n[e])
);
}),
o.join('&'))),
i)
: i;
};
function S(e) {
return function () {
this.readyState === XMLHttpRequest.DONE && e && e(this);
};
}
function T(e) {
return function () {
console.error(
'Error occurred while HTTP request to ' + this.responseURL
),
e && e(this);
};
}
var I = function (e, t, n, o, i) {
void 0 === t && (t = {}), void 0 === n && (n = null);
var r = E();
(r.onreadystatechange = S(o)), (r.onerror = T(i));
var a = w(e, t);
r.open('POST', a.toString()),
A(r),
r.send(n ? JSON.stringify(n) : null);
},
O = function (e, t, n, o) {
void 0 === t && (t = {});
var i = E();
(i.onreadystatechange = S(n)), (i.onerror = T(o));
var r = w(e, t);
i.open('GET', r.toString()), A(i), i.send();
},
D = function (e, t, n) {
if (n || 2 === arguments.length)
for (var o, i = 0, r = t.length; i < r; i++)
(!o && i in t) ||
(o || (o = Array.prototype.slice.call(t, 0, i)), (o[i] = t[i]));
return e.concat(o || Array.prototype.slice.call(t));
};
function R() {
return window.ANAWebSDKInstance;
}
function _() {
var e = R();
if (e) return e.propertyId;
var t = window.ANAWebPropertyId;
return t || window.location.hostname;
}
function P(e) {
try {
var t = e(),
n = '__random_key__',
o = '__random_val__';
return t.setItem(n, o), t.getItem(n) !== o ? !1 : (t.removeItem(n), !0);
} catch (e) {
return !1;
}
}
function C() {
return (
!!window.ana_debug || -1 !== window.location.href.indexOf('ana_debug=1')
);
}
function M() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
C() &&
console.log.apply(
console,
D(['%c🚨ANA: ', 'background: #222; color: #33c65a'], e, !1)
);
}
function B(e) {
return -1 !== document.cookie.indexOf(e + '=');
}
function L(e) {
return new URLSearchParams(window.location.search).get(e);
}
function k(e) {
var t = !1;
return (
Array.from(document.getElementsByTagName('script')).forEach(function (
n
) {
n.getAttribute('src') === e && (t = !0);
}),
t
);
}
var N = 0,
U = L('aversion');
if (
U &&
((function e(t) {
if (!document.body)
return (
console.error(
'ana-web is triying to load another version before there is a body to append to. Retry ['
.concat(t, '][')
.concat(N, ']')
),
(N += 1) < 10
? void setTimeout(function () {
e(t);
}, 50)
: void console.error(
'Ana Web exhausted retries while waiting for document.body . Retry ['
.concat(t, '][')
.concat(N, ']')
)
);
var n = 'https://js.media-lab.ai/wana.' + t + '.js';
k(n) ||
(function (e, t) {
if (!k(e)) {
var n = document.createElement('script');
(n.async = t), (n.src = e), document.body.appendChild(n);
}
})(n, !0);
})(U),
!k('https://js.media-lab.ai/wana.' + U + '.js'))
)
throw Error(
'Ana Version parameter found, stoping current script to load requested version ['.concat(
U,
']'
)
);
var V,
q,
j = (function () {
function e() {}
return (
(e.prototype.setItem = function (e, t) {
this[e] = t;
}),
(e.prototype.getItem = function (e) {
var t = this[e];
return t || (t = null), t;
}),
(e.prototype.removeItem = function (e) {
delete this[e];
}),
(e.prototype.clear = function () {
var e = this;
Object.keys(this).forEach(function (t) {
delete e[t];
});
}),
(e.prototype.key = function (e) {
throw Error('not implemented (index = '.concat(e));
}),
Object.defineProperty(e.prototype, 'length', {
get: function () {
return Object.keys(this).length;
},
enumerable: !1,
configurable: !0,
}),
e
);
})();
(window.anaStorage = P(function () {
return window.localStorage;
})
? window.localStorage
: new j()),
(window.anaSessionStorage = P(function () {
return window.sessionStorage;
})
? window.sessionStorage
: new j()),
(function (e) {
(e[(e.GOOGLE = 0)] = 'GOOGLE'), (e[(e.ANA = 1)] = 'ANA');
})(V || (V = {})),
(function (e) {
(e[(e.VIDEO_JS = 0)] = 'VIDEO_JS'), (e[(e.HTML5 = 1)] = 'HTML5');
})(q || (q = {}));
var x = (function () {
function e(e) {
var t = this;
Object.keys(e).forEach(function (n) {
var o = (function (e, t) {
void 0 === t && (t = !1);
var n = e.replace(/([-_]id$)|([-_][a-z])/gi, function (e) {
return e.toUpperCase().replace('-', '').replace('_', '');
});
return (
'id' === n && (n = 'ID'),
n && t && (n = n[0].toUpperCase() + n.slice(1)),
n
);
})(n, !0);
t[o] = e[n];
});
}
return (
(e.prototype.toCustomJSON = function () {
var e = this,
t = {};
return (
Object.keys(this).forEach(function (n) {
var o = n
.replace(/\.?([A-Z]+)/g, function (e, t) {
return '_' + t.toLowerCase();
})
.replace(/^_/, '');
t[o] = e[n];
}),
t
);
}),
(e.prototype.renderImpressionPixels = function () {
var e = this.BidID;
this.ImpressionPixels.forEach(function (t) {
var n = document.createElement('img');
n.setAttribute('data-bid-id', e),
n.setAttribute('src', t),
n.setAttribute('width', '1'),
n.setAttribute('height', '1'),
document.body.appendChild(n);
});
}),
(e.prototype.removeImpressionPixels = function () {
for (
var e = [], t = document.getElementsByTagName('img'), n = 0;
n < t.length;
n++
) {
var o = t[n];
o.getAttribute('data-bid-id') === String(this.BidID) && e.push(o);
}
e.forEach(function (e) {
return document.body.removeChild(e);
});
}),
e
);
})(),
G = function () {
for (var e = [], t = '0123456789abcdef', n = 0; n < 36; n++)
e[n] = t.substr(Math.floor(16 * Math.random()), 1);
return (
(e[14] = '4'),
(e[19] = t.substr((3 & +e[19]) | 8, 1)),
(e[8] = e[13] = e[18] = e[23] = '-'),
e.join('')
);
},
H = function () {
return (
'y' === new URLSearchParams(window.location.search).get('tracing')
);
},
W = function () {
var e = anaStorage.getItem(s);
return e || ((e = G()), anaStorage.setItem(s, e)), H() ? 'tr' + e : e;
},
F = function (e, t) {
anaStorage.setItem(m + e, t);
},
J = function (e, t, n) {
if (!e) throw Error('propertyId is required');
var o;
(o = e),
(window.ANAWebPropertyId = o),
(function (e) {
anaStorage.setItem(s, e);
})(t),
M('sending a syncing cookie request to doh'),
de.UserSync.getUrls(Object.keys(n), function (e) {
if (200 === e.status) {
if ('' !== e.responseType && 'text' !== e.responseType)
throw Error(
'incorrect response type "'
.concat(e.responseType, '" from ')
.concat(e.responseURL)
);
if (!B(v)) {
var t = new Date(),
n = t.getTime() + 864e5;
t.setTime(n);
var o = ''
.concat(v, '=1;expires=')
.concat(t.toUTCString(), ';path=/');
M('setting cookie:', o), (document.cookie = o);
}
var i = JSON.parse(e.responseText),
r = i.sync_urls,
a = i.cookie_ids,
s = a ? Object.keys(a) : null;
M('got response from /doh/sync:', r, a),
Object.keys(r).forEach(function (e) {
(s && -1 !== s.indexOf(e)) || oe(e, r[e]);
}),
a &&
Object.keys(a).forEach(function (e) {
var t = a[e];
t && F(e, t);
});
}
});
};
function z(e) {
this.callCounter++,
M('appending iframe to body', e),
document.body
? document.body.appendChild(e)
: this.callCounter < 200 && setTimeout(z.bind(this, e), 50);
}
var K,
$,
Q,
Z,
X,
Y,
ee,
te,
ne,
oe = function (e, t) {
var n = _(),
o = document.createElement('iframe');
o.setAttribute('src', t),
o.setAttribute('frameborder', '0'),
o.setAttribute('scrolling', 'no'),
o.setAttribute('marginheight', '0'),
o.setAttribute('marginwidth', '0'),
o.setAttribute('TOPMARGIN', '0'),
o.setAttribute('LEFTMARGIN', '0'),
o.setAttribute('allowtransparency', 'true'),
o.setAttribute('width', '0'),
o.setAttribute('height', '0'),
o.setAttribute('data-property-id', n),
M('creating cookie syncing iframe for ' + e, t),
setTimeout(z.bind({ callCounter: 0 }, o), 0);
},
ie = function () {
var e = {};
return (
Object.keys(anaStorage).forEach(function (t) {
0 === t.indexOf(m) &&
B(v) &&
(e[t.slice(m.length)] = anaStorage.getItem(t));
}),
e
);
};
!(function (e) {
(e[(e.PageLoadSoundOn = 1)] = 'PageLoadSoundOn'),
(e[(e.PageLoadSoundOff = 2)] = 'PageLoadSoundOff'),
(e[(e.ClickSoundOn = 3)] = 'ClickSoundOn'),
(e[(e.MouseOverSoundOn = 4)] = 'MouseOverSoundOn'),
(e[(e.EnterViewpointSoundOn = 5)] = 'EnterViewpointSoundOn'),
(e[(e.EnterViewpointSoundOff = 6)] = 'EnterViewpointSoundOff');
})(K || (K = {})),
(function (e) {
(e[(e.GenericPostRoll = -2)] = 'GenericPostRoll'),
(e[(e.GenericMidRoll = -1)] = 'GenericMidRoll'),
(e[(e.PreRoll = 0)] = 'PreRoll'),
(e[(e.MidRoll3Sec = 3)] = 'MidRoll3Sec'),
(e[(e.MidRoll5Sec = 5)] = 'MidRoll5Sec'),
(e[(e.MidRoll10Sec = 10)] = 'MidRoll10Sec'),
(e[(e.MidRoll15Sec = 15)] = 'MidRoll15Sec'),
(e[(e.MidRoll30Sec = 30)] = 'MidRoll30Sec'),
(e[(e.MidRoll60Sec = 60)] = 'MidRoll60Sec');
})($ || ($ = {})),
(function (e) {
(e[(e.InStream = 1)] = 'InStream'),
(e[(e.InBanner = 2)] = 'InBanner'),
(e[(e.InArticle = 3)] = 'InArticle'),
(e[(e.InFeed = 4)] = 'InFeed'),
(e[(e.Interstitial = 5)] = 'Interstitial');
})(Q || (Q = {})),
(function (e) {
(e[(e.InStream = 1)] = 'InStream'), (e[(e.Overlay = 2)] = 'Overlay');
})(Z || (Z = {})),
(function (e) {
(e[(e.OnVideoCompletion = 1)] = 'OnVideoCompletion'),
(e[(e.OnLeavingViewport = 2)] = 'OnLeavingViewport'),
(e[(e.OnLeavingViewportContinues = 3)] =
'OnLeavingViewportContinues');
})(X || (X = {})),
(function (e) {
(e[(e.Unknown = 0)] = 'Unknown'),
(e[(e.AboveTheFold = 1)] = 'AboveTheFold'),
(e[(e.Deprecated = 2)] = 'Deprecated'),
(e[(e.BelowTheFold = 3)] = 'BelowTheFold'),
(e[(e.Header = 4)] = 'Header'),
(e[(e.Footer = 5)] = 'Footer'),
(e[(e.Sidebar = 6)] = 'Sidebar'),
(e[(e.FullScreen = 7)] = 'FullScreen');
})(Y || (Y = {})),
(function (e) {
(e[(e.Vast10 = 1)] = 'Vast10'),
(e[(e.Vast20 = 2)] = 'Vast20'),
(e[(e.Vast30 = 3)] = 'Vast30'),
(e[(e.Vast10Wrapper = 4)] = 'Vast10Wrapper'),
(e[(e.Vast20Wrapper = 5)] = 'Vast20Wrapper'),
(e[(e.Vast30Wrapper = 6)] = 'Vast30Wrapper'),
(e[(e.Vast40 = 7)] = 'Vast40'),
(e[(e.Vast40Wrapper = 8)] = 'Vast40Wrapper'),
(e[(e.Daast10 = 9)] = 'Daast10'),
(e[(e.Daast10Wrapper = 10)] = 'Daast10Wrapper');
})(ee || (ee = {})),
(function (e) {
(e[(e.Vpaid10 = 1)] = 'Vpaid10'),
(e[(e.Vpaid20 = 2)] = 'Vpaid20'),
(e[(e.Mraid1 = 3)] = 'Mraid1'),
(e[(e.Ormma = 4)] = 'Ormma'),
(e[(e.Mraid2 = 5)] = 'Mraid2'),
(e[(e.Mraid3 = 6)] = 'Mraid3');
})(te || (te = {})),
(function (e) {
(e[(e.Streaming = 1)] = 'Streaming'),
(e[(e.Progressive = 2)] = 'Progressive'),
(e[(e.Download = 3)] = 'Download');
})(ne || (ne = {}));
var re = function () {
var e = anaSessionStorage.getItem(d);
return (
e || ((e = G()), anaSessionStorage.setItem(d, e)), H() ? 'tr' + e : e
);
},
ae = function (e, t, n) {
var o = R().consentManager;
return {
ad_unit: e,
auction_timeout: n,
inventory_type: 'web',
additional_targeting: t,
property_id: _(),
opportunity_data: { platform: 'web' },
site: { page: document.location.href, referer: document.referrer },
matched_ids: { ids: ie() },
consent: { tcfV2: o.tcfV2String, usPrivacyString: o.usPrivacyString },
session_id: re(),
};
},
se = function (e, t, n, o, i, r, a, s, d) {
var c = ae(e, t, d);
return (
(c.video_delivery = ne.Progressive),
(c.video_placement = n),
(c.video_playback_method = o),
(c.video_position = i),
(c.video_start_delay = r),
(c.video_width = a),
(c.video_height = s),
c
);
},
de = {
BannerBids: {
get: function (e, t, n, o, i) {
I(
''.concat(le(), '/wana/bids/request'),
{ uid: W() },
ae(e, t, n),
function (e) {
switch (e.status) {
case 200:
var t = JSON.parse(e.responseText).bids || [];
o({
code: 200,
bids: t.map(function (e) {
return new x(e);
}),
});
break;
case f:
var n = void 0;
(n =
JSON.parse(e.responseText).message === y
? y
: e.status.toString()),
o({ code: f, bids: [], err_msg: n });
break;
default:
console.error('HTTP error ' + e.status),
o({
code: e.status,
bids: [],
err_msg: e.status.toString(),
});
}
},
i
);
},
invalidate: function (e, t, n, o) {
M('invalidating bids for adUnitID '.concat(e, ':'), t);
var i = t.map(function (e) {
var t = e.toCustomJSON();
return (
(t.creative = ''),
(t.impression_pixels = []),
(t.view_pixels = []),
(t.click_pixels = []),
t
);
});
I(
''.concat(le(), '/wana/bids/invalidate'),
{ uid: W(), ad_unit: e },
{ bids: i },
n,
o
);
},
},
VideoBids: {
get: function (e, t, n, o, i, r, a, s, d, c, l) {
var u = se(e, t, n, i, o, r, a, s, d);
I(
''.concat(le(), '/wana/bids/request'),
{ uid: W() },
u,
function (t) {
switch (t.status) {
case 200:
var n = JSON.parse(t.responseText);
M(''.concat(e, ' got video bid response from ANA'), n);
var o = n.bids || [];
c({
code: 200,
fallback_vast_url: n.fallback_vast_url,
bids: o.map(function (e) {
return new x(e);
}),
});
break;
case f:
var i = void 0;
(i =
(n = JSON.parse(t.responseText)).message === y
? y
: t.status.toString()),
c({
code: f,
bids: [],
fallback_vast_url: null,
err_msg: i,
});
break;
default:
console.error('HTTP error ' + t.status),
c({
code: t.status,
bids: [],
fallback_vast_url: null,
err_msg: t.status.toString(),
});
}
},
l
);
},
vicEvent: function (e, t, n) {
var o = (function (e) {
return e
.split('')
.map(function (e) {
return e.charCodeAt(0).toString(16).padStart(2, '0');
})
.join('');
})(W() + ':' + t);
O(
''.concat(le(), '/ana/vics/video'),
{ event: e, bk: o, bid_id: n },
null,
console.error
);
},
},
VMAP: {
get: function (e, t, n, o, i, r, a, s, d, c, l) {
var u = se(e, t, n, i, o, r, a, s, d);
I(
''.concat(le(), '/vmap/request'),
{ uid: W() },
u,
function (t) {
switch (t.status) {
case 200:
var n = JSON.parse(t.responseText);
M(''.concat(e, ' got video bid response from ANA'), n),
c({ code: 200, tag_url: n.tag_url });
break;
case f:
var o = void 0;
(o =
(n = JSON.parse(t.responseText)).message === y
? y
: t.status.toString()),
c({ code: f, tag_url: null, err_msg: o });
break;
default:
console.error('HTTP error ' + t.status),
c({
code: t.status,
tag_url: null,
err_msg: t.status.toString(),
});
}
},
l
);
},
},
UserSync: {
getUrls: function (e, t) {
var n = _();
I(
''.concat('https://ads.assemblyexchange.com', '/doh/sync'),
{ uid: W(), property_id: n },
{ synced_ids: e },
t
);
},
doSync: function (e, t, n) {
O(t, null, n);
},
},
Hertz: {
impression: function (e, t) {
void 0 === t && (t = 'adserver'),
M(
'reporting on bid '
.concat(t, ' impression to hertz for ')
.concat(e)
);
var n = _(),
o = W(),
i = re();
O(
''.concat(le(), '/hertz/impression'),
{
uid: o,
ad_unit_id: e,
session_id: i,
bid_id: t,
property_id: n,
},
null
);
},
},
},
ce = function (e, t) {
t &&
(de.BannerBids.invalidate(e, [t], null, console.error),
t.renderImpressionPixels());
},
le = function () {
return window.ana_staging || -1 !== window.location.href.indexOf(l)
? r.replace('https://', 'https://staging.')
: r;
},
ue = function () {
return (
(ue =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
ue.apply(this, arguments)
);
},
pe = {
adUnitID: '',
format: e.HORIZONTAL,
elementID: '',
collapseBeforeFill: !1,
collapseIfNoFill: !1,
dimensions: null,
baseTargeting: {},
passThroughANA: !1,
apsEnabled: !0,
adServerRender: !0,
},
he = (function () {
function e(e, t) {
(this.options = ue(ue({}, pe), t)),
(this.anaWeb = e),
(this.adUnitID = this.options.adUnitID),
(this.elementID = this.options.elementID),
(this.dimensions = this.options.dimensions),
(this.baseTargeting = this.options.baseTargeting),
(this.passThroughANA = this.options.passThroughANA),
(this.apsEnabled = e.apsEnabled && this.options.apsEnabled),
(this.adServerRender = this.options.adServerRender),
(this.refreshCount = 0);
}
return (
(e.prototype.updateBaseTargeting = function (e) {
this.baseTargeting = ue(ue({}, this.baseTargeting), e);
}),
(e.prototype.fetchANABids = function (e, t) {
var n = this;
if (!document.hasFocus() && this.refreshCount > 0)
return (
M('prevent ad slot refresh - document not in focus'), t && t()
);
if ((this.refreshCount++, this.passThroughANA)) e && e([]);
else {
var o = ue(
ue({}, this.anaWeb.globalTargeting),
this.baseTargeting
);
de.BannerBids.get(
this.adUnitID,
o,
this.anaWeb.auctionTimeout,
function (o) {
var i = [];
switch (o.code) {
case 200:
(i = o.bids).length > 0 &&
n.anaWeb.bidManager.addBids(i, n.adUnitID);
break;
case f:
return (
o.err_msg === y &&
console.warn(
'#'
.concat(n.elementID, ' ')
.concat(n.adUnitID, ' ANA user reached fcap')
),
void (t && t(o.err_msg))
);
}
e && e(i);
},
function (t) {
console.error(t), e && e([]);
}
);
}
}),
(e.prototype.fetchAPSBids = function (e, t) {
throw Error('method `fetchAPSBids` is not implemented');
}),
(e.prototype.updateTargeting = function () {}),
(e.prototype.getTopBid = function () {
var e = this.anaWeb,
t = this.adUnitID;
return e.bidManager.getBid(t);
}),
(e.prototype.renderInElement = function (e, t) {
var n = this.adUnitID,
o = this.anaWeb;
!(function (e, t) {
var n = document.getElementById(e);
if (!n) throw Error('tried to render ad on missing element ' + e);
for (; n.firstChild; ) n.removeChild(n.firstChild);
'none' === n.style.display && (n.style.display = 'inline-block');
var o = document.createElement('iframe');
o.setAttribute('srcdoc', t.Creative),
o.setAttribute('frameborder', '0'),
o.setAttribute('scrolling', 'no'),
o.setAttribute('marginheight', '0'),
o.setAttribute('marginwidth', '0'),
o.setAttribute('TOPMARGIN', '0'),
o.setAttribute('LEFTMARGIN', '0'),
o.setAttribute('allowtransparency', 'true');
var i = t.Width,
r = t.Height;
o.setAttribute('width', ''.concat(i)),
o.setAttribute('height', ''.concat(r)),
n.append(o);
})(e, t),
ce(n, t),
o.bidManager.useBid(n, t.BidID);
}),
(e.prototype.alreadyRendered = function () {
throw Error('unimplemented method: alreadyRendered');
}),
e
);
})();
he.prototype.toString = function () {
return "ANASlot('"
.concat(this.adUnitID, "', '")
.concat(this.elementID, "')");
};
var ge,
fe =
((ge = function (e, t) {
return (
(ge =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t)
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
ge(e, t)
);
}),
function (e, t) {
if ('function' != typeof t && null !== t)
throw new TypeError(
'Class extends value ' +
String(t) +
' is not a constructor or null'
);
function n() {
this.constructor = e;
}
ge(e, t),
(e.prototype =
null === t
? Object.create(t)
: ((n.prototype = t.prototype), new n()));
}),
ye = function () {
return (
(ye =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
ye.apply(this, arguments)
);
},
me = (function (e) {
function t(t, n) {
var o = e.call(this, t, n) || this;
return (
(o.format = o.options.format),
(o.collapseBeforeFill = o.options.collapseBeforeFill),
(o.collapseIfNoFill = o.options.collapseIfNoFill),
(o.slot = null),
(o.slotType = V.GOOGLE),
o.resetRequestMgr(),
o.registerSlot(),
o
);
}
return (
fe(t, e),
(t.prototype.resetRequestMgr = function () {
this.requestMgr = {
didDirectRender: !1,
anaRequestComplete: !1,
apsRequestComplete: !1,
gptRefreshComplete: !1,
};
}),
(t.prototype.fetchAPSBids = function (e) {
var t = this;
this.anaWeb.apsEnabled &&
window.apstag.fetchBids(
{
slots: [
{
slotID: this.elementID,
slotName: this.adUnitID,
sizes: this.dimensions,
},
],
},
function (n) {
googletag.cmd.push(function () {
t.apsRequestCompleted();
}),
e && e(n);
}
);
}),
(t.prototype.anaRequestCompleted = function () {
this.requestMgr.anaRequestComplete = !0;
}),
(t.prototype.apsRequestCompleted = function () {
window.apstag.setDisplayBids(),
(this.requestMgr.apsRequestComplete = !0);
}),
(t.prototype.alreadyRendered = function () {
return (
!!this.requestMgr.didDirectRender &&
((this.requestMgr.didDirectRender = !1), !0)
);
}),
(t.prototype.maybeRenderBid = function (e) {
return (
!(!e || (this.adServerRender && !e.DirectRender)) &&
((this.requestMgr.didDirectRender = !0),
this.renderInElement(this.elementID, e),
!0)
);
}),
(t.prototype.removeSlot = function () {
var e = this;
googletag.cmd.push(function () {
var t = e.slot;
googletag.destroySlots([t]),
(e.slot = null),
(document.getElementById(e.elementID).innerHTML = null);
});
var t = this.anaWeb,
n = t.createdSlots.indexOf(this);
-1 !== n && t.createdSlots.splice(n, 1);
}),
(t.prototype.setAdServerRender = function (e) {
this.adServerRender = e;
}),
(t.prototype.updateTargeting = function () {
var e = this.getTopBid();
if (e) {
if (this.maybeRenderBid(e)) return;
var t = this.slot,
n = this.baseTargeting;
Object.keys(ye(ye({}, n), e.Targeting)).forEach(function (n) {
t.setTargeting(n, e.Targeting[n]);
});
}
}),
(t.prototype.bidRequestReturned = function (e) {
if ((void 0 === e && (e = !0), this.requestMgr.anaRequestComplete))
return this.anaWeb.apsEnabled
? !!this.requestMgr.apsRequestComplete &&
(e && this.refreshGPTSlot(), !0)
: (e && this.refreshGPTSlot(), !0);
}),
(t.prototype.refreshGPTSlot = function () {
var e = this;
this.requestMgr.didDirectRender ||
this.requestMgr.gptRefreshComplete ||
((this.requestMgr.gptRefreshComplete = !0),
this.adServerRender &&
googletag.cmd.push(function () {
M('sending to ad server for ', e),
googletag.pubads().refresh([e.slot]);
}));
}),
(t.prototype.refresh = function (e) {
var t = this;
this.slot &&
googletag.cmd.push(function () {
t.slot.clearTargeting();
}),
this.resetRequestMgr();
this.fetchANABids(function (n) {
M('ANA responded with bids for '.concat(t), n),
e && e(n),
googletag.cmd.push(function () {
t.updateTargeting(),
t.anaRequestCompleted(),
t.bidRequestReturned();
});
}),
this.fetchAPSBids(function (e) {
M('APS responded with bids for '.concat(t), e),
googletag.cmd.push(function () {
t.apsRequestCompleted(), t.bidRequestReturned();
});
}),
setTimeout(
this.refreshGPTSlot.bind(this),
this.anaWeb.auctionTimeout + 500
);
}),
(t.prototype.registerSlot = function () {
var e = this,
t = this,
n = t.dimensions,
o = t.format,
i = t.collapseBeforeFill,
r = t.collapseIfNoFill,
a = t.adUnitID,
s = t.elementID,
d = this.prepareDimensions(n, o);
d && d.length
? (googletag.cmd.push(function () {
e.slot = googletag.defineSlot(a, d, s);
}),
googletag.cmd.push(function () {
var t = e.slot;
t.setCollapseEmptyDiv(i, r),
t.addService(googletag.pubads()),
googletag.display(s);
}))
: console.error('No dimensions found');
}),
(t.prototype.addSlotEventListener = function (e, t) {
var n = this.elementID;
googletag.cmd.push(function () {
googletag.pubads().addEventListener(e, function (e) {
e.slot.getSlotElementId() === n && t(e);
});
});
}),
(t.prototype.prepareDimensions = function (e, t) {
return e && e.length ? e : i[t] || [];
}),
t
);
})(he);
me.prototype.toString = function () {
return "BannerSlot('"
.concat(this.adUnitID, "', '")
.concat(this.elementID, "')");
};
var ve = (function () {
function e(e, t, n, o, i) {
(this.playerType = e),
(this.adUnitID = o),
(this.targeting = i),
(this.adsManagerLoadedCustomCbk = t),
(this.videoPlayerID = n),
(this.html5Player = document.getElementById(n)),
this.initAds();
}
return (
(e.prototype.initAds = function () {
throw new Error('must be implemented by child class');
}),
(e.prototype.anaBidRequest = function (e, t) {
var n = this;
e(
function (e) {
if (e.includes('bids=&') && !t)
throw Error(
'did not receive ANA bid and ad server render disabled'
);
n.imaInit(e);
},
function (e) {
throw Error(
''
.concat(n.videoPlayerID, ' error getting ANA bids: ')
.concat(e)
);
}
);
}),
(e.prototype.imaInit = function (e) {
throw new Error('must be implemented by child class');
}),
(e.prototype.vastUrlAndVideoSrc = function (e) {
M(''.concat(this.videoPlayerID, ' imaInit'));
var t,
n =
(t = window.ana_vast) ||
(-1 !== window.location.href.indexOf('ana_vast=') &&
(t = w(window.location.href).searchParams.get(c))
? t
: '');
if ((n || (n = e), n)) {
var o = this.html5Player.currentSrc;
if (!o && '' !== o)
throw Error(
''.concat(this.videoPlayerID, ' does not have a valid src')
);
return (
M(
''
.concat(this.videoPlayerID, ' vast used: ')
.concat(n, ', src: ')
.concat(o)
),
{ videoVastUrl: n, videoSrc: o }
);
}
M(''.concat(this.videoPlayerID, " we don't have an ad to show"));
}),
(e.prototype.adsManagerLoadedCallback = function (e) {
throw new Error('must be implemented by child class');
}),
(e.prototype.addDefaultListeners = function () {
var e = this,
t = window.google;
this.adsManagerLoadedCustomCbk &&
this.adsManagerLoadedCustomCbk(
this.html5Player,
this.playerType,
this.adsManager
);
var n = [
t.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
t.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
t.ima.AdEvent.Type.CLICK,
t.ima.AdEvent.Type.VIDEO_CLICKED,
t.ima.AdEvent.Type.VIDEO_ICON_CLICKED,
t.ima.AdEvent.Type.STARTED,
t.ima.AdEvent.Type.AD_PROGRESS,
t.ima.AdEvent.Type.AD_BUFFERING,
t.ima.AdEvent.Type.IMPRESSION,
t.ima.AdEvent.Type.PAUSED,
t.ima.AdEvent.Type.RESUMED,
t.ima.AdEvent.Type.FIRST_QUARTILE,
t.ima.AdEvent.Type.MIDPOINT,
t.ima.AdEvent.Type.THIRD_QUARTILE,
t.ima.AdEvent.Type.COMPLETE,
t.ima.AdEvent.Type.DURATION_CHANGE,
t.ima.AdEvent.Type.USER_CLOSE,
t.ima.AdEvent.Type.LOADED,
t.ima.AdEvent.Type.ALL_ADS_COMPLETED,
t.ima.AdEvent.Type.SKIPPED,
t.ima.AdEvent.Type.LINEAR_CHANGED,
t.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED,
t.ima.AdEvent.Type.AD_METADATA,
t.ima.AdEvent.Type.AD_BREAK_READY,
t.ima.AdEvent.Type.LOG,
t.ima.AdEvent.Type.VOLUME_CHANGED,
t.ima.AdEvent.Type.VOLUME_MUTED,
t.ima.AdEvent.Type.INTERACTION,
],
o = function () {
var t;
(t = e.adUnitID), de.Hertz.impression(t);
};
this.adsManager.addEventListener(t.ima.AdEvent.Type.IMPRESSION, o),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.IMPRESSION,
function () {
return e.adsManager.removeEventListener(
t.ima.AdEvent.Type.IMPRESSION,
o
);
}
);
for (var i = 0; i < n.length; i++)
this.adsManager.addEventListener(n[i], this.onAdEvent.bind(this)),
M(
''
.concat(this.videoPlayerID, ' bind ')
.concat(n[i], ' ad event')
);
}),
(e.prototype.onAdEvent = function (e) {
var t = window.google,
n = e.type;
n !== t.ima.AdEvent.Type.AD_PROGRESS &&
M(''.concat(this.videoPlayerID, ' ad event: ').concat(n));
}),
e
);
})(),
be = (function () {
var e = function (t, n) {
return (
(e =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t)
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
e(t, n)
);
};
return function (t, n) {
if ('function' != typeof n && null !== n)
throw new TypeError(
'Class extends value ' +
String(n) +
' is not a constructor or null'
);
function o() {
this.constructor = t;
}
e(t, n),
(t.prototype =
null === n
? Object.create(n)
: ((o.prototype = n.prototype), new o()));
};
})(),
Ee = (function (e) {
function t(t, n, o, i) {
var r = e.call(this, q.VIDEO_JS, t, n, o, i) || this;
return (
M('initializing IMAManagerHTML5 for', n), (r.adPlaying = !1), r
);
}
return (
be(t, e),
(t.prototype.initAds = function () {
var e = this,
t = window.google;
if (!this.html5Player)
throw Error(
'video element was not found on the page using id='.concat(
this.videoPlayerID
)
);
(this.overlayedBtnContainer = document.createElement('div')),
this.overlayedBtnContainer.classList.add('ana-ad-overlay'),
(this.overlayedBtnContainer.id =
this.videoPlayerID + '_ana_ad_overlay');
var n = document.createElement('div');
n.classList.add('ana-ad-container'),
(n.id = this.videoPlayerID + '_ana_ad_container'),
this.html5Player.after(this.overlayedBtnContainer, n),
(this.adDisplayContainer = new t.ima.AdDisplayContainer(
n,
this.html5Player
)),
(this.adsLoader = new t.ima.AdsLoader(this.adDisplayContainer)),
this.adsLoader.addEventListener(
t.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
this.adsManagerLoadedCallback.bind(this),
!1
),
this.adsLoader.addEventListener(
t.ima.AdErrorEvent.Type.AD_ERROR,
console.error,
!1
),
(this.html5Player.onended = this.adsLoader.contentComplete),
window.addEventListener('resize', function () {
if (e.adsManager) {
var n = e.html5Player.clientWidth,
o = e.html5Player.clientHeight;
e.adsManager.resize(n, o, t.ima.ViewMode.NORMAL);
}
});
}),
(t.prototype.imaInit = function (e) {
if (e && '' !== e) {
var t = window.google,
n = this.vastUrlAndVideoSrc(e).videoVastUrl;
this.adsManager && this.adsManager.destroy(),
this.adsLoader.contentComplete();
var o = new t.ima.AdsRequest();
(o.adTagUrl = n),
(o.linearAdSlotWidth = 640),
(o.linearAdSlotHeight = 480),
(o.nonLinearAdSlotWidth = 640),
(o.nonLinearAdSlotHeight = 150),
(o.forceNonLinearFullSlot = !0),
this.adsLoader.requestAds(o),
this.overlayedBtnContainer.addEventListener(
'click',
this.onOverlayedBtnContainerClick.bind(this)
),
this.overlayedBtnContainer.addEventListener(
'touchend',
this.onOverlayedBtnContainerClick.bind(this)
);
}
}),
(t.prototype.onOverlayedBtnContainerClick = function (e) {
e.preventDefault(),
this.adPlaying ? this.adsManager.resume() : this.playAds(),
this.toggleOverlayedBtnContainer();
}),
(t.prototype.toggleOverlayedBtnContainer = function () {
this.overlayedBtnContainer &&
(this.overlayedBtnContainer.hidden =
!this.overlayedBtnContainer.hidden);
}),
(t.prototype.playAds = function () {
var e = this,
t = window.google;
this.adDisplayContainer && this.adDisplayContainer.initialize(),
this.html5Player.load();
try {
var n = this.html5Player.getBoundingClientRect(),
o = n.width,
i = n.height;
this.adsManager.init(o, i, t.ima.ViewMode.NORMAL),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
this.onContentPauseRequested.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
this.onContentResumeRequested.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.LOADED,
this.onAdLoaded.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.STARTED,
this.onStarted.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.SKIPPED,
this.onSkipped.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.COMPLETE,
this.onComplete.bind(this)
),
this.adsManager.addEventListener(
t.ima.AdEvent.Type.PAUSED,
function () {
e.toggleOverlayedBtnContainer();
}
),
this.adsManager.start();
} catch (e) {
this.html5Player.play();
}
}),
(t.prototype.onComplete = function () {
this.adPlaying = !1;
}),
(t.prototype.onStarted = function () {
this.adPlaying = !0;
}),
(t.prototype.onSkipped = function () {
(this.adPlaying = !1),
this.adDisplayContainer.destroy(),
this.html5Player.play();
}),
(t.prototype.onContentPauseRequested = function () {
(this.adPlaying = !0), this.html5Player.pause();
}),
(t.prototype.onContentResumeRequested = function () {
(this.adPlaying = !1), this.html5Player.play();
}),
(t.prototype.onAdLoaded = function (e) {
e.getAd().isLinear() || this.html5Player.play();
}),
(t.prototype.adsManagerLoadedCallback = function (e) {
M(''.concat(this.videoPlayerID, ' AdsManager loaded'));
var t = window.google,
n = new t.ima.AdsRenderingSettings();
(n.restoreCustomPlaybackStateOnAdBreakComplete = !0),
(n.uiElements = [
t.ima.UiElements.AD_ATTRIBUTION,
t.ima.UiElements.COUNTDOWN,
]),
(this.adsManager = e.getAdsManager(this.html5Player, n)),
this.addDefaultListeners();
}),
t
);
})(ve),
Ae = (function () {
var e = function (t, n) {
return (
(e =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t)
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
e(t, n)
);
};
return function (t, n) {
if ('function' != typeof n && null !== n)
throw new TypeError(
'Class extends value ' +
String(n) +
' is not a constructor or null'
);
function o() {
this.constructor = t;
}
e(t, n),
(t.prototype =
null === n
? Object.create(n)
: ((o.prototype = n.prototype), new o()));
};
})(),
we = (function (e) {
function t(t, n, o, i) {
var r = e.call(this, q.VIDEO_JS, t, n, o, i) || this;
return (
M('initializing IMAManagerVideoJS for', n),
navigator.userAgent.match(/iPad|Android/i) &&
r.html5Player.hasAttribute('controls') &&
r.html5Player.removeAttribute('controls'),
(r.overlayedBtnContainer = document.getElementById(n)),
r
);
}
return (
Ae(t, e),
(t.prototype.initAds = function () {
var e = window.videojs;
if (
((this.html5Player = document.getElementById(
this.videoPlayerID + '_html5_api'
)),
!this.html5Player)
)
throw Error(
'video element was not found on the page using id='.concat(
this.videoPlayerID
)
);
this.videoJSPlayer = e(this.videoPlayerID);
var t = {
id: this.videoPlayerID,
adLabel: 'Advertisement',
disableAdControls: !1,
showControlsForJSAds: !0,
adsManagerLoadedCallback:
this.adsManagerLoadedCallback.bind(this),
};
this.videoJSPlayer.ima(t);
}),
(t.prototype.imaInit = function (e) {
if (e && '' !== e) {
var t = this.vastUrlAndVideoSrc(e),
n = t.videoVastUrl,
o = t.videoSrc;
this.videoJSPlayer.ima.setContentWithAdTag(o, n, !1),
this.videoJSPlayer.ima.requestAds(),
(this.boundBidRequestClick =
this.onOverlayedBtnContainerClick.bind(this)),
(this.boundBidRequestTouch =
this.onOverlayedBtnContainerClick.bind(this)),
this.overlayedBtnContainer.addEventListener(
'click',
this.boundBidRequestClick
),
this.overlayedBtnContainer.addEventListener(
'touchend',
this.boundBidRequestTouch
);
}
}),
(t.prototype.onOverlayedBtnContainerClick = function (e) {
e.preventDefault(),
this.videoJSPlayer.ima.initializeAdDisplayContainer(),
this.overlayedBtnContainer.removeEventListener(
'click',
this.boundBidRequestClick
),
this.overlayedBtnContainer.removeEventListener(
'touchend',
this.boundBidRequestTouch
);
}),
(t.prototype.adsManagerLoadedCallback = function () {
M(''.concat(this.videoPlayerID, ' AdsManager loaded')),
(this.adsManager = this.videoJSPlayer.ima.getAdsManager()),
this.addDefaultListeners();
}),
t
);
})(ve),
Se = (function () {
var e = function (t, n) {
return (
(e =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t)
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
e(t, n)
);
};
return function (t, n) {
if ('function' != typeof n && null !== n)
throw new TypeError(
'Class extends value ' +
String(n) +
' is not a constructor or null'
);
function o() {
this.constructor = t;
}
e(t, n),
(t.prototype =
null === n
? Object.create(n)
: ((o.prototype = n.prototype), new o()));
};
})(),
Te = function () {
return (
(Te =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
Te.apply(this, arguments)
);
},
Ie = (function (e) {
function t(t, n, o) {
var i,
r = e.call(this, t, o) || this;
if (((r.playerType = n), void 0 === o.startDelay))
throw Error('startDelay must be specified for video ad slots');
if (o.startDelay < -2) throw Error('startDelay must be valid');
if (void 0 === o.adPlacement)
throw Error('adPlacement must be specified for video ad slots');
if (void 0 === o.adPosition)
throw Error('adPosition must be specified for video ad slots');
if (o.adPosition < 1 || o.adPosition > 7)
throw Error('adPosition must be valid not Unknown');
if (!o.playbackMethod || o.playbackMethod < 1 || o.playbackMethod > 6)
throw Error('playbackMethod must be specified for video ad slots');
if (
((r.startDelay = o.startDelay),
(r.adPlacement = o.adPlacement),
(r.adPosition = o.adPosition),
(r.playbackMethod = o.playbackMethod),
(r.wrapperDiv = document.getElementById(r.elementID)),
r.dimensions && 0 === r.dimensions.length)
)
throw new Error(
''.concat(
r.elementID,
' dimensions must be either omitted or have at least one element in the array'
)
);
switch (r.playerType) {
case q.VIDEO_JS:
i = we;
break;
case q.HTML5:
i = Ee;
break;
default:
throw Error('unsupported video player type: '.concat(n));
}
return (
(r.videoManager = new i(
o.adsManagerLoadedCbk,
r.elementID,
r.adUnitID,
r.baseTargeting
)),
r.videoManager.anaBidRequest(
r.fetchANAVMAP.bind(r),
r.adServerRender
),
r
);
}
return (
Se(t, e),
(t.prototype.fetchANAVMAP = function (e, t) {
var n = this,
o = this.currentDimensions(),
i = Te(Te({}, this.anaWeb.globalTargeting), this.baseTargeting);
de.VMAP.get(
this.adUnitID,
i,
this.adPlacement,
this.adPosition,
this.playbackMethod,
this.startDelay,
o[0][0],
o[0][1],
this.anaWeb.auctionTimeout,
function (o) {
var i = '';
switch (o.code) {
case 200:
i = o.tag_url;
break;
case f:
return void (o.err_msg === y
? console.warn(
'#'
.concat(n.elementID, ' ')
.concat(n.adUnitID, ' ANA user reached fcap')
)
: t && t(o.err_msg));
}
n.adServerRender || (i += '&ad_server_render=0'), e && e(i);
},
function (e) {
console.error(e), t(e.status.toString());
}
);
}),
(t.prototype.fetchAPSBids = function (e, t) {}),
(t.prototype.currentDimensions = function () {
var e;
if (this.dimensions) e = this.dimensions;
else {
var t = this.playerDimensions();
e = [[t.w, t.h]];
}
if (0 === e.length || 2 !== e[0].length)
throw new Error(
''
.concat(this.elementID, ' final dimensions are not valid: ')
.concat(e)
);
return e;
}),
(t.prototype.playerDimensions = function () {
var e = this.wrapperDiv.getBoundingClientRect(),
t = e.width,
n = e.height;
if (0 === t || 0 === n)
throw Error(
''
.concat(this.elementID, ' wrong video ad slot dimensions: ')
.concat(t, 'x')
.concat(n)
);
return { w: t, h: n };
}),
t
);
})(he);
Ie.prototype.toString = function () {
return "VideoSlot('"
.concat(this.adUnitID, "', ")
.concat(this.playerType, ", '")
.concat(this.elementID, "')");
};
var Oe,
De = (function () {
function e(e) {
if (((this.anaWeb = e), window.addEventListener))
window.addEventListener(
'message',
this.handleMessage.bind(this),
!1
);
else {
if (!window.attachEvent) throw Error('No event listener found!');
window.attachEvent('onmessage', this.handleMessage.bind(this));
}
}
return (
(e.prototype.handleMessage = function (e) {
if (
((r = e.origin),
h.some(function (e) {
return e.test(r);
}) &&
e.data &&
e.data.bidID)
) {
var t = e.data,
n = t.adUnitID,
o = t.bidID,
i = this.anaWeb.bidManager.getBidToRender(n, o);
i &&
(e.source
? e.source.postMessage(JSON.stringify(i), e.origin)
: console.error('e.source is not available in this context'),
ce(n, i));
}
var r;
(function (e) {
return g.some(function (t) {
return t.test(e);
});
})(e.origin) &&
e.data &&
e.data.msgType &&
'cookieSyncingSuccess' === e.data.msgType &&
(M(
'synced cookie message event for '
.concat(e.data.bidderId, ', id=')
.concat(e.data.partnerUid)
),
F(e.data.bidderId, e.data.partnerUid));
}),
e
);
})(),
Re = function () {
return (
(Re =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
Re.apply(this, arguments)
);
},
_e = {
enableSingleRequest: !1,
globalTargeting: {},
sandboxIframe: !1,
collapseEmptyDivs: !1,
},
Pe = function (e) {
if (window.googletag)
throw new Error(
'attempting to initialize ANA sdk with pre-initialized gpt integration. aborting'
);
var t;
!(function () {
document.body ||
console.error(
'loadGPTTagJS called before there is a body to append to'
);
var e = document.createElement('script');
(e.async = !0),
(e.defer = !0),
(e.src = u),
document.body.appendChild(e),
M('added GPT script on the page '.concat(u));
})();
var n = (t = e ? Re(Re({}, _e), e) : _e).enableSingleRequest,
o = t.globalTargeting,
i = t.sandboxIframe,
r = t.collapseEmptyDivs;
(window.googletag = window.googletag || {}),
(googletag.cmd = googletag.cmd || []),
googletag.cmd.push(function () {
n && googletag.pubads().enableSingleRequest(),
i && googletag.pubads().setSafeFrameConfig({ sandbox: !0 }),
r && googletag.pubads().collapseEmptyDivs(),
o &&
Object.keys(o).length &&
Object.keys(o).forEach(function (e) {
googletag.pubads().setTargeting(e, o[e]);
}),
googletag.pubads().disableInitialLoad(),
googletag.enableServices();
});
};
!(function (e) {
e.GOOGLE = 'googletag';
})(Oe || (Oe = {}));
var Ce,
Me = function () {
return (
(Me =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
Me.apply(this, arguments)
);
},
Be = { pubID: null, adServer: Oe.GOOGLE },
Le = function (e) {
if (window.apstag)
throw new Error(
'attempting to initialize ANA sdk with pre-initialized apt integration'
);
!(function () {
function e(e, t) {
window.apstag._Q.push([e, t]);
}
document.body ||
console.error(
'loadAPSTagJS called before there is a body to append to'
),
(window.apstag = {
init: function () {
for (var t = [], n = 0; n < arguments.length; n++)
t[n] = arguments[n];
e('i', t);
},
fetchBids: function () {
for (var t = [], n = 0; n < arguments.length; n++)
t[n] = arguments[n];
e('f', t);
},
setDisplayBids: function () {},
targetingKeys: function () {
return [];
},
_Q: [],
});
var t = document.createElement('script');
(t.async = !0), (t.src = p);
var n = document.getElementsByTagName('script')[0];
n.parentNode.insertBefore(t, n),
M('added APS script on the page '.concat(p));
})();
var t = Me(Me({}, Be), e),
n = t.pubID,
o = t.adServer;
if (!n)
throw new Error(
'to fully enable amazon publisher tag integration you need to pass at least `pubID`'
);
window.apstag.init({ pubID: n, adServer: o });
},
ke = new ((function () {
function e() {
(this._usPrivacyData = null), (this._tcData = null);
}
return (
Object.defineProperty(e.prototype, 'tcData', {
get: function () {
return this._tcData;
},
set: function (e) {
this._tcData = e;
},
enumerable: !1,
configurable: !0,
}),
Object.defineProperty(e.prototype, 'tcfV2String', {
get: function () {
return this._tcData ? this._tcData.tcString : null;
},
enumerable: !1,
configurable: !0,
}),
Object.defineProperty(e.prototype, 'usPrivacyData', {
get: function () {
return this._usPrivacyData;
},
set: function (e) {
this._usPrivacyData = e;
},
enumerable: !1,
configurable: !0,
}),
Object.defineProperty(e.prototype, 'usPrivacyString', {
get: function () {
return this._usPrivacyData ? this._usPrivacyData.uspString : null;
},
enumerable: !1,
configurable: !0,
}),
e
);
})())(),
Ne = (function () {
function e(e, t) {
void 0 === e && (e = 0), (this.count = e), (this.doneCallback = t);
}
return (
(e.prototype.add = function (e) {
void 0 === e && (e = 1), (this.count += e);
}),
(e.prototype.decrement = function (e) {
void 0 === e && (e = 1),
(this.count = this.count - e),
0 === this.count && this.doneCallback();
}),
e
);
})(),
Ue = (function () {
function e() {
(this.bidsByID = {}),
(this.bidsByAdUnit = {}),
(this.usedBidIDs = {});
}
return (
(e.prototype.addBids = function (e, t) {
var n = this,
o = this,
i = o.usedBidIDs,
r = o.bidsByID,
a = o.bidsByAdUnit,
s = (0, o.adUnitKey)(t);
e.forEach(function (e) {
var t = e.BidID;
n.getBidByID(t) ||
i[t] ||
((r[t] = e), a[s] ? a[s].push(e) : (a[s] = [e]));
}),
a[s].sort(function (e, t) {
return e.Value - t.Value;
});
}),
(e.prototype.getBid = function (e) {
var t = this.bidsByAdUnit,
n = (0, this.adUnitKey)(e);
if (t[n] && t[n].length) {
var o = t[n];
return o[o.length - 1];
}
return null;
}),
(e.prototype.getBidByID = function (e) {
return this.bidsByID[e] || null;
}),
(e.prototype.getBidToRender = function (e, t) {
return this.usedBidIDs[t]
? null
: (this.useBid(e, t), this.getBidByID(t));
}),
(e.prototype.useBid = function (e, t) {
var n = this,
o = n.usedBidIDs,
i = n.bidsByAdUnit,
r = (0, n.adUnitKey)(e);
if (!o[t] && void 0 !== i && void 0 !== i[r]) {
var a = i[r]
.map(function (e) {
return e.BidID;
})
.indexOf(t);
-1 !== a && i[r].splice(a, 1), (o[t] = !0);
}
}),
(e.prototype.reset = function () {
(this.bidsByID = {}),
(this.bidsByAdUnit = {}),
(this.usedBidIDs = {});
}),
(e.prototype.adUnitKey = function (e) {
var t = window.location.href;
return ''.concat(e, ':').concat(t);
}),
e
);
})(),
Ve = function () {
return (
(Ve =
Object.assign ||
function (e) {
for (var t, n = 1, o = arguments.length; n < o; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
Ve.apply(this, arguments)
);
},
qe = {
slotEventsHandlers: {},
gptOptions: { globalTargeting: {} },
apsOptions: null,
syncCookies: !0,
resyncCookiesAfterTimeout: 5e3,
propertyId: window.location.hostname,
videoOptions: null,
lightMode: !1,
auctionTimeout: b,
},
je = (function () {
function e(e) {
void 0 === e && (e = {}),
(this.createdSlots = []),
(this.createdGoogleSlots = []),
(this.createdVideoContainers = []);
var t,
n = Ve(Ve({}, qe), e),
o = n.slotEventsHandlers,
i = n.gptOptions,
r = n.apsOptions,
a = n.syncCookies,
s = n.resyncCookiesAfterTimeout,
d = n.propertyId,
c = n.lightMode,
l = n.auctionTimeout;
L('auctionTimeout') &&
parseInt(L('auctionTimeout')) > 0 &&
(t = parseInt(L('auctionTimeout'))),
(this.bidManager = new Ue()),
(this.consentManager = ke),
(this.slotEventsHandlers = o),
(this.msgHandler = new De(this)),
(this.syncCookies = a),
(this.resyncCookiesAfterTimeout = s),
(this.propertyId = d),
(this.apsEnabled = !!r),
(this.refreshedAllSlots = !1),
(this.globalTargeting = i.globalTargeting ? i.globalTargeting : {}),
(this.lightMode = !!c),
(this.auctionTimeout = t || l),
(window.ANAWebSDKInstance = this);
l || t
? (l || t) &&
M('Setting auctionTimeout to '.concat(this.auctionTimeout))
: M(
"auctionTimeout wasn't provided, using default value: ".concat(
b
)
),
(this.auctionTimeout < 500 || this.auctionTimeout > 4e3) &&
((this.auctionTimeout = b),
console.error(
'auctionTimeout is out of range ('
.concat(500, ' - ')
.concat(4e3, '), using default value: ')
.concat(b)
)),
'__tcfapi' in window &&
(M('GDPR - consent management framework was found on the page'),
window.__tcfapi('getTCData', 2, function (e, t) {
t
? (M('getTCData cbk success', e), (ke.tcData = e))
: M('getTCData cbk fail', e);
})),
'__uspapi' in window &&
(M('CCPA - consent management framework was found on the page'),
window.__uspapi('getUSPData', 1, function (e, t) {
t
? (M('getUSPData cbk success', e), (ke.usPrivacyData = e))
: M('getUSPData cbk fail', e);
})),
(this.uid = W()),
(this.sessionId = re()),
this.syncCookies &&
(this.syncUserCookies(),
this.resyncCookiesAfterTimeout &&
setTimeout(
this.syncUserCookies.bind(this),
this.resyncCookiesAfterTimeout
)),
this.lightMode || (r && Le(r), Pe(i));
}
return (
(e.prototype.createSlot = function (e, t) {
var n = null;
switch (e) {
case V.GOOGLE:
this.lightMode &&
M('making google banner slots in light mode seems sketchy'),
(n = new me(this, t)),
this.createdGoogleSlots.push(n);
break;
case V.ANA:
this.lightMode ||
M(
'making a lightmode slot without the SDK in lightmode seems sketchy'
),
(n = new he(this, t));
break;
default:
throw Error('Specified slot type is not supported: '.concat(e));
}
return this.createdSlots.push(n), n;
}),
(e.prototype.createVideoSlot = function (e, t) {
var n = new Ie(this, e, t);
return this.createdVideoContainers.push(n), n;
}),
(e.prototype.refreshAllGoogleSlots = function () {
var e = this,
t = this.waitGroup;
this.refreshedAllSlots = !1;
var n = this.createdGoogleSlots;
if (null == t) {
var o = n.filter(function (e) {
return e.apsEnabled;
}).length,
i = n.length + o;
(t = new Ne(i, this.onBidsFetchSuccess.bind(this))),
(this.waitGroup = t),
n.forEach(function (e) {
e.slot &&
googletag.cmd.push(function () {
e.slot.clearTargeting();
}),
e.resetRequestMgr();
}),
n.forEach(function (n) {
if (n) {
if (n.slotType !== V.GOOGLE)
throw new Error(
'ANA Web SDK does not support refreshAll for '
.concat(n.slotType, ' slot type. Fix it for slot ')
.concat(n)
);
n.fetchANABids(
function (o) {
M(
'refreshAllSlots - ANA responded with bids for '.concat(
n
),
o
),
googletag.cmd.push(function () {
n.updateTargeting(),
n.anaRequestCompleted(),
t.decrement(),
e.bidRequestReturned(n, o);
});
},
function () {
e.waitGroup = null;
}
),
n.apsEnabled &&
n.fetchAPSBids(function (o) {
M(
'refreshAllSlots - APS responded with bids for '.concat(
n
),
o
),
googletag.cmd.push(function () {
n.apsRequestCompleted(),
t.decrement(),
e.bidRequestReturned(n, o);
});
});
}
}),
setTimeout(
this.onBidsFetchSuccess.bind(this),
this.auctionTimeout + 500
);
} else console.warn('calling refreshAllSlots too fast');
}),
(e.prototype.bidRequestReturned = function (e, t) {
if (
(M(
'ANAWeb bidRequestReturned called for '.concat(
e,
' with bids:'
),
t
),
e.bidRequestReturned(!1))
) {
for (var n = 0, o = this.createdSlots; n < o.length; n++) {
if (!o[n].bidRequestReturned(!1)) return;
}
this.onBidsFetchSuccess();
}
}),
(e.prototype.refreshSubscribedBannerSlots = function (e, t) {
if ((void 0 === t && (t = 3e4), !document.hasFocus()))
return (
M(
'skipping auto refresh, document not in focus, trying later with slots:',
e
),
void setTimeout(
this.refreshSubscribedBannerSlots.bind(this, e, t),
300
)
);
M('auto refreshing slots:', e),
e.forEach(function (e) {
return e.refresh();
}),
setTimeout(this.refreshSubscribedBannerSlots.bind(this, e, t), t);
}),
(e.prototype.autoRefreshSlots = function (e, t, n) {
void 0 === t && (t = 3e4),
void 0 === n && (n = !1),
M(
'subscribed slots for auto refresh:',
e,
'in',
t,
'ms, firstInstantRefresh=',
n
),
n
? this.refreshSubscribedBannerSlots(e, t)
: setTimeout(
this.refreshSubscribedBannerSlots.bind(this, e, t),
t
);
}),
Object.defineProperty(e, 'version', {
get: function () {
return '2.1.3';
},
enumerable: !1,
configurable: !0,
}),
(e.prototype.onBidsFetchSuccess = function () {
var e = this;
if (
(M(
'onBidsFetchSuccess, this.refreshedAllSlots=',
this.refreshedAllSlots
),
this.refreshedAllSlots)
)
M(
'onBidsFetchSuccess, skipping since all slots were already refreshed'
);
else {
this.refreshedAllSlots = !0;
var t = [];
this.createdGoogleSlots.forEach(function (e) {
e.adServerRender && !e.alreadyRendered() && t.push(e.slot);
}),
0 !== t.length
? googletag.cmd.push(function () {
(e.waitGroup = null),
M('sending to ad server all the slots'),
googletag.pubads().refresh(t);
})
: (this.waitGroup = null);
}
}),
(e.prototype.updateGlobalTargeting = function (e) {
var t;
(this.globalTargeting = Ve(Ve({}, this.globalTargeting), e)),
(t = this.globalTargeting) &&
Object.keys(t).length &&
googletag.cmd.push(function () {
Object.keys(t).forEach(function (e) {
googletag.pubads().setTargeting(e, t[e]);
});
});
}),
(e.prototype.syncUserCookies = function () {
if (!this.propertyId)
throw Error('propertyId is needed to initialize SDK');
var e = _();
J(e, this.uid, ie());
}),
e
);
})();
function xe() {
M('πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚ ANA Web SDK '.concat('2.1.3', ' πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚')),
M('dispatching anaReadyEvent'),
document.dispatchEvent(new CustomEvent('ANAReady'));
}
return (
(function (e) {
(e.VideoMp4 = 'video/mp4'), (e.VideoOgg = 'video/ogg');
})(Ce || (Ce = {})),
'loading' !== document.readyState
? setTimeout(xe, 0)
: document.addEventListener('DOMContentLoaded', xe),
(window.ANAWeb = je),
(window.SlotTypeEnum = V),
(je.SlotTypeEnum = V),
Object.defineProperty(je, 'uid', {
get: function () {
return W();
},
}),
Object.defineProperty(je, 'sessionId', {
get: function () {
return re();
},
}),
(je.AdPosition = Y),
(je.ContentDeliveryMethod = ne),
(je.PlaybackCessationMode = X),
(je.PlaybackMethod = K),
(je.StartDelay = $),
(je.VideoApiFramework = te),
(je.VideoLinearity = Z),
(je.VideoPlacementType = Q),
(je.VideoPlayerType = q),
(je.VideoProtocol = ee),
(je.Mime = Ce),
o
);
})();
});
// MediaLab Inc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment