@streamlayer/react-ui 1.28.2 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/app/Layout/styles.d.ts +1 -0
- package/lib/app/app/Layout/styles.js +33 -24
- package/lib/app/webos/Advertisement/AdvertisementUI.d.ts +0 -1
- package/lib/app/webos/Advertisement/AdvertisementUI.js +13 -15
- package/lib/app/webos/Advertisement/index.js +10 -11
- package/lib/app/webos/ExposedPauseAd/PauseAd.d.ts +2 -0
- package/lib/app/webos/ExposedPauseAd/PauseAd.js +92 -70
- package/lib/app/webos/ExposedPauseAd/styles.d.ts +1 -1
- package/lib/app/webos/ExposedPauseAd/styles.js +5 -5
- package/lib/app/webos/index.d.ts +4 -0
- package/lib/app/webos/index.js +38 -36
- package/lib/app/webos/story.js +47 -36
- package/lib/app/webos/ui/Sidebar/PromoAction.js +38 -34
- package/lib/app/webos/ui/Sidebar/index.d.ts +0 -1
- package/lib/app/webos/ui/Sidebar/index.js +70 -71
- package/lib/app/webos/ui/Sidebar/styles.d.ts +1 -0
- package/lib/app/webos/ui/Sidebar/styles.js +120 -115
- package/lib/app/webos/ui/insight/index.js +43 -77
- package/lib/assets/style.css +1 -1
- package/lib/{index-DXvAPWiE.js → index-l-eyvmpL.js} +296 -281
- package/lib/ui/advertisement/notification/index.js +24 -24
- package/lib/ui/advertisement/notification/lower-third/index.js +48 -40
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMPlayer.js +8 -7
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.d.ts +9 -0
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js +44 -0
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useVastAds.js +240 -6
- package/lib/ui/gamification/question/inapp/notification/AdNotification/index.js +62 -52
- package/lib/ui/video-player/index.d.ts +1 -0
- package/lib/ui/video-player/index.js +138 -125
- package/lib/ui/video-player/styles.d.ts +1 -0
- package/lib/ui/video-player/styles.js +32 -27
- package/lib/{useVastAds-CakWRNKN.js → vast-client.min-B0NUra1B.js} +358 -594
- package/package.json +17 -17
- package/lib/app/webos/ui/Layout/index.d.ts +0 -21
- package/lib/app/webos/ui/Layout/index.js +0 -78
- package/lib/app/webos/ui/Layout/styles.d.ts +0 -11
- package/lib/app/webos/ui/Layout/styles.js +0 -59
- package/lib/hooks/useKeyboardNavigation.d.ts +0 -15
- package/lib/hooks/useKeyboardNavigation.js +0 -74
|
@@ -1,203 +1,200 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function L() {
|
|
5
|
-
let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
6
|
-
return { id: a.id || null, adId: a.adId || null, sequence: a.sequence || null, apiFramework: a.apiFramework || null, universalAdIds: [], creativeExtensions: [] };
|
|
1
|
+
function N() {
|
|
2
|
+
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3
|
+
return { id: i.id || null, adId: i.adId || null, sequence: i.sequence || null, apiFramework: i.apiFramework || null, universalAdIds: [], creativeExtensions: [] };
|
|
7
4
|
}
|
|
8
|
-
const
|
|
9
|
-
function
|
|
5
|
+
const G = ["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"];
|
|
6
|
+
function w(i) {
|
|
10
7
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
11
|
-
const r = [],
|
|
12
|
-
!e.ERRORCODE || t.isCustomCode || /^[0-9]{3}$/.test(e.ERRORCODE) || (e.ERRORCODE = 900), e.CACHEBUSTING =
|
|
13
|
-
for (const s in e) e[s] =
|
|
14
|
-
for (const s in
|
|
15
|
-
const o =
|
|
16
|
-
typeof o == "string" && r.push(
|
|
8
|
+
const r = [], a = M(i);
|
|
9
|
+
!e.ERRORCODE || t.isCustomCode || /^[0-9]{3}$/.test(e.ERRORCODE) || (e.ERRORCODE = 900), e.CACHEBUSTING = q(Math.round(1e8 * Math.random())), e.TIMESTAMP = (/* @__PURE__ */ new Date()).toISOString(), e.RANDOM = e.random = e.CACHEBUSTING;
|
|
10
|
+
for (const s in e) e[s] = j(e[s]);
|
|
11
|
+
for (const s in a) {
|
|
12
|
+
const o = a[s];
|
|
13
|
+
typeof o == "string" && r.push(B(o, e));
|
|
17
14
|
}
|
|
18
15
|
return r;
|
|
19
16
|
}
|
|
20
|
-
function
|
|
21
|
-
const t = (
|
|
22
|
-
if (!t) return
|
|
23
|
-
let r = t.filter((
|
|
24
|
-
return r.length === 0 ?
|
|
17
|
+
function B(i, e) {
|
|
18
|
+
const t = (i = L(i, e)).match(/[^[\]]+(?=])/g);
|
|
19
|
+
if (!t) return i;
|
|
20
|
+
let r = t.filter((a) => G.indexOf(a) > -1);
|
|
21
|
+
return r.length === 0 ? i : (r = r.reduce((a, s) => (a[s] = -1, a), {}), L(i, r));
|
|
25
22
|
}
|
|
26
|
-
function
|
|
27
|
-
let t =
|
|
23
|
+
function L(i, e) {
|
|
24
|
+
let t = i;
|
|
28
25
|
for (const r in e) {
|
|
29
|
-
const
|
|
30
|
-
t = t.replace(new RegExp("(?:\\[|%%)(".concat(r, ")(?:\\]|%%)"), "g"),
|
|
26
|
+
const a = e[r];
|
|
27
|
+
t = t.replace(new RegExp("(?:\\[|%%)(".concat(r, ")(?:\\]|%%)"), "g"), a);
|
|
31
28
|
}
|
|
32
29
|
return t;
|
|
33
30
|
}
|
|
34
|
-
function
|
|
35
|
-
return Array.isArray(
|
|
31
|
+
function M(i) {
|
|
32
|
+
return Array.isArray(i) ? i.map((e) => e && e.hasOwnProperty("url") ? e.url : e) : i;
|
|
36
33
|
}
|
|
37
|
-
function
|
|
38
|
-
return /^(https?:\/\/|\/\/)/.test(
|
|
34
|
+
function C(i) {
|
|
35
|
+
return /^(https?:\/\/|\/\/)/.test(i);
|
|
39
36
|
}
|
|
40
|
-
function
|
|
41
|
-
for (let t = 0; t < e.length; t++) if (
|
|
37
|
+
function U(i, e) {
|
|
38
|
+
for (let t = 0; t < e.length; t++) if (W(e[t], i)) return !0;
|
|
42
39
|
return !1;
|
|
43
40
|
}
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
46
|
-
const t = Object.getOwnPropertyNames(
|
|
47
|
-
return t.length === r.length &&
|
|
41
|
+
function W(i, e) {
|
|
42
|
+
if (i && e) {
|
|
43
|
+
const t = Object.getOwnPropertyNames(i), r = Object.getOwnPropertyNames(e);
|
|
44
|
+
return t.length === r.length && i.id === e.id && i.url === e.url;
|
|
48
45
|
}
|
|
49
46
|
return !1;
|
|
50
47
|
}
|
|
51
|
-
function
|
|
52
|
-
return encodeURIComponent(
|
|
48
|
+
function j(i) {
|
|
49
|
+
return encodeURIComponent(i).replace(/[!'()*]/g, (e) => "%".concat(e.charCodeAt(0).toString(16)));
|
|
53
50
|
}
|
|
54
|
-
function
|
|
51
|
+
function q(i) {
|
|
55
52
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
56
|
-
return
|
|
53
|
+
return i.toString().padStart(e, "0");
|
|
57
54
|
}
|
|
58
|
-
const f = { track: function(
|
|
59
|
-
|
|
55
|
+
const f = { track: function(i, e, t) {
|
|
56
|
+
w(i, e, t).forEach((r) => {
|
|
60
57
|
typeof window < "u" && window !== null && (new Image().src = r);
|
|
61
58
|
});
|
|
62
|
-
}, resolveURLTemplates:
|
|
63
|
-
return
|
|
59
|
+
}, resolveURLTemplates: w, extractURLsFromTemplates: M, filterUrlTemplates: function(i) {
|
|
60
|
+
return i.reduce((e, t) => {
|
|
64
61
|
const r = t.url || t;
|
|
65
|
-
return
|
|
62
|
+
return C(r) ? e.validUrls.push(r) : e.invalidUrls.push(r), e;
|
|
66
63
|
}, { validUrls: [], invalidUrls: [] });
|
|
67
|
-
}, containsTemplateObject:
|
|
68
|
-
return !isNaN(parseFloat(
|
|
69
|
-
}, flatten: function
|
|
70
|
-
return e.reduce((t, r) => t.concat(Array.isArray(r) ?
|
|
64
|
+
}, containsTemplateObject: U, isTemplateObjectEqual: W, encodeURIComponentRFC3986: j, replaceUrlMacros: B, isNumeric: function(i) {
|
|
65
|
+
return !isNaN(parseFloat(i)) && isFinite(i);
|
|
66
|
+
}, flatten: function i(e) {
|
|
67
|
+
return e.reduce((t, r) => t.concat(Array.isArray(r) ? i(r) : r), []);
|
|
71
68
|
}, joinArrayOfUniqueTemplateObjs: function() {
|
|
72
|
-
let
|
|
73
|
-
const t = Array.isArray(
|
|
74
|
-
return t.concat(r).reduce((
|
|
75
|
-
}, isValidTimeValue: function(
|
|
76
|
-
return Number.isFinite(
|
|
77
|
-
}, addLeadingZeros:
|
|
69
|
+
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
70
|
+
const t = Array.isArray(i) ? i : [], r = Array.isArray(e) ? e : [];
|
|
71
|
+
return t.concat(r).reduce((a, s) => (U(s, a) || a.push(s), a), []);
|
|
72
|
+
}, isValidTimeValue: function(i) {
|
|
73
|
+
return Number.isFinite(i) && i >= -2;
|
|
74
|
+
}, addLeadingZeros: q, isValidUrl: C, isBrowserEnvironment: function() {
|
|
78
75
|
return typeof window < "u";
|
|
79
|
-
}, formatMacrosValues: function(
|
|
80
|
-
return typeof
|
|
76
|
+
}, formatMacrosValues: function(i) {
|
|
77
|
+
return typeof i != "object" ? i : JSON.stringify(i);
|
|
81
78
|
} };
|
|
82
|
-
function
|
|
83
|
-
return ["true", "TRUE", "True", "1"].includes(
|
|
79
|
+
function I(i) {
|
|
80
|
+
return ["true", "TRUE", "True", "1"].includes(i);
|
|
84
81
|
}
|
|
85
|
-
function
|
|
86
|
-
if (
|
|
87
|
-
if (f.isNumeric(
|
|
88
|
-
const e =
|
|
82
|
+
function Y(i) {
|
|
83
|
+
if (i == null) return -1;
|
|
84
|
+
if (f.isNumeric(i)) return parseInt(i);
|
|
85
|
+
const e = i.split(":");
|
|
89
86
|
if (e.length !== 3) return -1;
|
|
90
87
|
const t = e[2].split(".");
|
|
91
88
|
let r = parseInt(t[0]);
|
|
92
89
|
t.length === 2 && (r += parseFloat("0.".concat(t[1])));
|
|
93
|
-
const
|
|
94
|
-
return isNaN(s) || isNaN(
|
|
90
|
+
const a = parseInt(60 * e[1]), s = parseInt(60 * e[0] * 60);
|
|
91
|
+
return isNaN(s) || isNaN(a) || isNaN(r) || a > 3600 || r > 60 ? -1 : s + a + r;
|
|
95
92
|
}
|
|
96
|
-
const l = { childByName: function(
|
|
97
|
-
return Array.from(
|
|
98
|
-
}, childrenByName: function(
|
|
99
|
-
return Array.from(
|
|
100
|
-
}, resolveVastAdTagURI: function(
|
|
101
|
-
if (!e) return
|
|
102
|
-
if (
|
|
93
|
+
const l = { childByName: function(i, e) {
|
|
94
|
+
return Array.from(i.childNodes).find((t) => t.nodeName === e);
|
|
95
|
+
}, childrenByName: function(i, e) {
|
|
96
|
+
return Array.from(i.childNodes).filter((t) => t.nodeName === e);
|
|
97
|
+
}, resolveVastAdTagURI: function(i, e) {
|
|
98
|
+
if (!e) return i;
|
|
99
|
+
if (i.startsWith("//")) {
|
|
103
100
|
const { protocol: t } = location;
|
|
104
|
-
return "".concat(t).concat(
|
|
101
|
+
return "".concat(t).concat(i);
|
|
105
102
|
}
|
|
106
|
-
if (!
|
|
103
|
+
if (!i.includes("://")) {
|
|
107
104
|
const t = e.slice(0, e.lastIndexOf("/"));
|
|
108
|
-
return "".concat(t, "/").concat(
|
|
109
|
-
}
|
|
110
|
-
return
|
|
111
|
-
}, parseBoolean:
|
|
112
|
-
return
|
|
113
|
-
}, copyNodeAttribute: function(
|
|
114
|
-
const r = e.getAttribute(
|
|
115
|
-
r && t.setAttribute(
|
|
116
|
-
}, parseAttributes: function(
|
|
117
|
-
return Array.from(
|
|
118
|
-
}, parseDuration:
|
|
119
|
-
return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((
|
|
105
|
+
return "".concat(t, "/").concat(i);
|
|
106
|
+
}
|
|
107
|
+
return i;
|
|
108
|
+
}, parseBoolean: I, parseNodeText: function(i) {
|
|
109
|
+
return i && (i.textContent || i.text || "").trim();
|
|
110
|
+
}, copyNodeAttribute: function(i, e, t) {
|
|
111
|
+
const r = e.getAttribute(i);
|
|
112
|
+
r && t.setAttribute(i, r);
|
|
113
|
+
}, parseAttributes: function(i) {
|
|
114
|
+
return Array.from(i.attributes).reduce((e, t) => (e[t.nodeName] = t.nodeValue, e), {});
|
|
115
|
+
}, parseDuration: Y, getStandAloneAds: function() {
|
|
116
|
+
return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((i) => !parseInt(i.sequence, 10));
|
|
120
117
|
}, getSortedAdPods: function() {
|
|
121
|
-
return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((
|
|
122
|
-
}, assignAttributes: function(
|
|
123
|
-
|
|
124
|
-
let { nodeName: r, nodeValue:
|
|
125
|
-
if (r &&
|
|
126
|
-
let s =
|
|
127
|
-
typeof e[r] == "boolean" && (s =
|
|
118
|
+
return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((i) => parseInt(i.sequence, 10)).sort((i, e) => i.sequence - e.sequence);
|
|
119
|
+
}, assignAttributes: function(i, e) {
|
|
120
|
+
i && Array.from(i).forEach((t) => {
|
|
121
|
+
let { nodeName: r, nodeValue: a } = t;
|
|
122
|
+
if (r && a && e.hasOwnProperty(r)) {
|
|
123
|
+
let s = a;
|
|
124
|
+
typeof e[r] == "boolean" && (s = I(s)), e[r] = s;
|
|
128
125
|
}
|
|
129
126
|
});
|
|
130
|
-
}, mergeWrapperAdData: function(
|
|
127
|
+
}, mergeWrapperAdData: function(i, e) {
|
|
131
128
|
var t;
|
|
132
|
-
|
|
133
|
-
const r = (e.creatives || []).filter((n) => n && n.type === "companion"),
|
|
129
|
+
i.errorURLTemplates = e.errorURLTemplates.concat(i.errorURLTemplates), i.impressionURLTemplates = e.impressionURLTemplates.concat(i.impressionURLTemplates), i.extensions = e.extensions.concat(i.extensions), e.viewableImpression.length > 0 && (i.viewableImpression = [...i.viewableImpression, ...e.viewableImpression]), i.followAdditionalWrappers = e.followAdditionalWrappers, i.allowMultipleAds = e.allowMultipleAds, i.fallbackOnNoAd = e.fallbackOnNoAd;
|
|
130
|
+
const r = (e.creatives || []).filter((n) => n && n.type === "companion"), a = r.reduce((n, c) => ((c.variations || []).forEach((u) => {
|
|
134
131
|
(u.companionClickTrackingURLTemplates || []).forEach((d) => {
|
|
135
132
|
f.containsTemplateObject(d, n) || n.push(d);
|
|
136
133
|
});
|
|
137
134
|
}), n), []);
|
|
138
|
-
|
|
135
|
+
i.creatives = r.concat(i.creatives);
|
|
139
136
|
const s = e.videoClickTrackingURLTemplates && e.videoClickTrackingURLTemplates.length, o = e.videoCustomClickURLTemplates && e.videoCustomClickURLTemplates.length;
|
|
140
|
-
if (
|
|
137
|
+
if (i.creatives.forEach((n) => {
|
|
141
138
|
if (e.trackingEvents && e.trackingEvents[n.type]) for (const c in e.trackingEvents[n.type]) {
|
|
142
139
|
const u = e.trackingEvents[n.type][c];
|
|
143
140
|
Array.isArray(n.trackingEvents[c]) || (n.trackingEvents[c] = []), n.trackingEvents[c] = n.trackingEvents[c].concat(u);
|
|
144
141
|
}
|
|
145
|
-
n.type === "linear" && (s && (n.videoClickTrackingURLTemplates = n.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)), o && (n.videoCustomClickURLTemplates = n.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)), !e.videoClickThroughURLTemplate || n.videoClickThroughURLTemplate !== null && n.videoClickThroughURLTemplate !== void 0 || (n.videoClickThroughURLTemplate = e.videoClickThroughURLTemplate)), n.type === "companion" &&
|
|
146
|
-
c.companionClickTrackingURLTemplates = f.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates,
|
|
142
|
+
n.type === "linear" && (s && (n.videoClickTrackingURLTemplates = n.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)), o && (n.videoCustomClickURLTemplates = n.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)), !e.videoClickThroughURLTemplate || n.videoClickThroughURLTemplate !== null && n.videoClickThroughURLTemplate !== void 0 || (n.videoClickThroughURLTemplate = e.videoClickThroughURLTemplate)), n.type === "companion" && a.length && (n.variations || []).forEach((c) => {
|
|
143
|
+
c.companionClickTrackingURLTemplates = f.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates, a);
|
|
147
144
|
});
|
|
148
|
-
}), e.adVerifications && (
|
|
145
|
+
}), e.adVerifications && (i.adVerifications = i.adVerifications.concat(e.adVerifications)), e.blockedAdCategories && (i.blockedAdCategories = i.blockedAdCategories.concat(e.blockedAdCategories)), (t = e.creatives) !== null && t !== void 0 && t.length) {
|
|
149
146
|
const n = e.creatives.filter((c) => {
|
|
150
147
|
var u;
|
|
151
148
|
return ((u = c.icons) === null || u === void 0 ? void 0 : u.length) && !c.mediaFiles.length;
|
|
152
149
|
});
|
|
153
|
-
n.length && (
|
|
150
|
+
n.length && (i.creatives = i.creatives.concat(n));
|
|
154
151
|
}
|
|
155
152
|
} };
|
|
156
|
-
function
|
|
153
|
+
function Q(i, e) {
|
|
157
154
|
const t = function() {
|
|
158
155
|
let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
159
|
-
const { id:
|
|
160
|
-
return { id:
|
|
156
|
+
const { id: a, adId: s, sequence: o, apiFramework: n } = N(r);
|
|
157
|
+
return { id: a, adId: s, sequence: o, apiFramework: n, type: "companion", required: null, variations: [] };
|
|
161
158
|
}(e);
|
|
162
|
-
return t.required =
|
|
163
|
-
const
|
|
159
|
+
return t.required = i.getAttribute("required") || null, t.variations = l.childrenByName(i, "Companion").map((r) => {
|
|
160
|
+
const a = function() {
|
|
164
161
|
let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
165
162
|
return { id: n.id || null, adType: "companionAd", width: n.width || 0, height: n.height || 0, assetWidth: n.assetWidth || null, assetHeight: n.assetHeight || null, expandedWidth: n.expandedWidth || null, expandedHeight: n.expandedHeight || null, apiFramework: n.apiFramework || null, adSlotId: n.adSlotId || null, pxratio: n.pxratio || "1", renderingMode: n.renderingMode || "default", staticResources: [], htmlResources: [], iframeResources: [], adParameters: null, altText: null, companionClickThroughURLTemplate: null, companionClickTrackingURLTemplates: [], trackingEvents: {} };
|
|
166
163
|
}(l.parseAttributes(r));
|
|
167
|
-
|
|
164
|
+
a.htmlResources = l.childrenByName(r, "HTMLResource").reduce((n, c) => {
|
|
168
165
|
const u = l.parseNodeText(c);
|
|
169
166
|
return u ? n.concat(u) : n;
|
|
170
|
-
}, []),
|
|
167
|
+
}, []), a.iframeResources = l.childrenByName(r, "IFrameResource").reduce((n, c) => {
|
|
171
168
|
const u = l.parseNodeText(c);
|
|
172
169
|
return u ? n.concat(u) : n;
|
|
173
|
-
}, []),
|
|
170
|
+
}, []), a.staticResources = l.childrenByName(r, "StaticResource").reduce((n, c) => {
|
|
174
171
|
const u = l.parseNodeText(c);
|
|
175
172
|
return u ? n.concat({ url: u, creativeType: c.getAttribute("creativeType") || null }) : n;
|
|
176
|
-
}, []),
|
|
173
|
+
}, []), a.altText = l.parseNodeText(l.childByName(r, "AltText")) || null;
|
|
177
174
|
const s = l.childByName(r, "TrackingEvents");
|
|
178
175
|
s && l.childrenByName(s, "Tracking").forEach((n) => {
|
|
179
176
|
const c = n.getAttribute("event"), u = l.parseNodeText(n);
|
|
180
|
-
c && u && (Array.isArray(
|
|
181
|
-
}),
|
|
177
|
+
c && u && (Array.isArray(a.trackingEvents[c]) || (a.trackingEvents[c] = []), a.trackingEvents[c].push(u));
|
|
178
|
+
}), a.companionClickTrackingURLTemplates = l.childrenByName(r, "CompanionClickTracking").map((n) => ({ id: n.getAttribute("id") || null, url: l.parseNodeText(n) })), a.companionClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "CompanionClickThrough")) || null;
|
|
182
179
|
const o = l.childByName(r, "AdParameters");
|
|
183
|
-
return o && (
|
|
180
|
+
return o && (a.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), a;
|
|
184
181
|
}), t;
|
|
185
182
|
}
|
|
186
|
-
function
|
|
183
|
+
function X(i, e) {
|
|
187
184
|
let t;
|
|
188
185
|
const r = function() {
|
|
189
186
|
let c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
190
|
-
const { id: u, adId: d, sequence:
|
|
191
|
-
return { id: u, adId: d, sequence:
|
|
187
|
+
const { id: u, adId: d, sequence: g, apiFramework: m } = N(c);
|
|
188
|
+
return { id: u, adId: d, sequence: g, apiFramework: m, type: "linear", duration: 0, skipDelay: null, mediaFiles: [], mezzanine: null, interactiveCreativeFile: null, closedCaptionFiles: [], videoClickThroughURLTemplate: null, videoClickTrackingURLTemplates: [], videoCustomClickURLTemplates: [], adParameters: null, icons: [], trackingEvents: {} };
|
|
192
189
|
}(e);
|
|
193
|
-
r.duration = l.parseDuration(l.parseNodeText(l.childByName(
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
else if (
|
|
197
|
-
const c = parseInt(
|
|
190
|
+
r.duration = l.parseDuration(l.parseNodeText(l.childByName(i, "Duration")));
|
|
191
|
+
const a = i.getAttribute("skipoffset");
|
|
192
|
+
if (a == null) r.skipDelay = null;
|
|
193
|
+
else if (a.charAt(a.length - 1) === "%" && r.duration !== -1) {
|
|
194
|
+
const c = parseInt(a, 10);
|
|
198
195
|
r.skipDelay = r.duration * (c / 100);
|
|
199
|
-
} else r.skipDelay = l.parseDuration(
|
|
200
|
-
const s = l.childByName(
|
|
196
|
+
} else r.skipDelay = l.parseDuration(a);
|
|
197
|
+
const s = l.childByName(i, "VideoClicks");
|
|
201
198
|
if (s) {
|
|
202
199
|
const c = l.childByName(s, "ClickThrough");
|
|
203
200
|
r.videoClickThroughURLTemplate = c ? { id: c.getAttribute("id") || null, url: l.parseNodeText(c) } : null, l.childrenByName(s, "ClickTracking").forEach((u) => {
|
|
@@ -206,79 +203,79 @@ function le(a, e) {
|
|
|
206
203
|
r.videoCustomClickURLTemplates.push({ id: u.getAttribute("id") || null, url: l.parseNodeText(u) });
|
|
207
204
|
});
|
|
208
205
|
}
|
|
209
|
-
const o = l.childByName(
|
|
210
|
-
o && (r.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), l.childrenByName(
|
|
206
|
+
const o = l.childByName(i, "AdParameters");
|
|
207
|
+
o && (r.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), l.childrenByName(i, "TrackingEvents").forEach((c) => {
|
|
211
208
|
l.childrenByName(c, "Tracking").forEach((u) => {
|
|
212
209
|
let d = u.getAttribute("event");
|
|
213
|
-
const
|
|
214
|
-
if (d &&
|
|
210
|
+
const g = l.parseNodeText(u);
|
|
211
|
+
if (d && g) {
|
|
215
212
|
if (d === "progress") {
|
|
216
213
|
if (t = u.getAttribute("offset"), !t) return;
|
|
217
214
|
d = t.charAt(t.length - 1) === "%" ? "progress-".concat(t) : "progress-".concat(l.parseDuration(t));
|
|
218
215
|
}
|
|
219
|
-
Array.isArray(r.trackingEvents[d]) || (r.trackingEvents[d] = []), r.trackingEvents[d].push(
|
|
216
|
+
Array.isArray(r.trackingEvents[d]) || (r.trackingEvents[d] = []), r.trackingEvents[d].push(g);
|
|
220
217
|
}
|
|
221
218
|
});
|
|
222
|
-
}), l.childrenByName(
|
|
219
|
+
}), l.childrenByName(i, "MediaFiles").forEach((c) => {
|
|
223
220
|
l.childrenByName(c, "MediaFile").forEach((h) => {
|
|
224
221
|
r.mediaFiles.push(function(p) {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
222
|
+
const v = { 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 };
|
|
223
|
+
v.id = p.getAttribute("id"), v.fileURL = l.parseNodeText(p), v.deliveryType = p.getAttribute("delivery"), v.codec = p.getAttribute("codec"), v.mimeType = p.getAttribute("type"), v.mediaType = p.getAttribute("mediaType") || "2D", v.apiFramework = p.getAttribute("apiFramework"), v.fileSize = parseInt(p.getAttribute("fileSize") || 0), v.bitrate = parseInt(p.getAttribute("bitrate") || 0), v.minBitrate = parseInt(p.getAttribute("minBitrate") || 0), v.maxBitrate = parseInt(p.getAttribute("maxBitrate") || 0), v.width = parseInt(p.getAttribute("width") || 0), v.height = parseInt(p.getAttribute("height") || 0);
|
|
224
|
+
const R = p.getAttribute("scalable");
|
|
225
|
+
R && typeof R == "string" && (v.scalable = l.parseBoolean(R));
|
|
229
226
|
const A = p.getAttribute("maintainAspectRatio");
|
|
230
|
-
return A && typeof A == "string" && (
|
|
227
|
+
return A && typeof A == "string" && (v.maintainAspectRatio = l.parseBoolean(A)), v;
|
|
231
228
|
}(h));
|
|
232
229
|
});
|
|
233
230
|
const u = l.childByName(c, "InteractiveCreativeFile");
|
|
234
231
|
u && (r.interactiveCreativeFile = function(h) {
|
|
235
232
|
const p = function() {
|
|
236
|
-
let
|
|
237
|
-
return { type:
|
|
233
|
+
let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
234
|
+
return { type: v.type || null, apiFramework: v.apiFramework || null, variableDuration: l.parseBoolean(v.variableDuration), fileURL: null };
|
|
238
235
|
}(l.parseAttributes(h));
|
|
239
236
|
return p.fileURL = l.parseNodeText(h), p;
|
|
240
237
|
}(u));
|
|
241
238
|
const d = l.childByName(c, "ClosedCaptionFiles");
|
|
242
239
|
d && l.childrenByName(d, "ClosedCaptionFile").forEach((h) => {
|
|
243
240
|
const p = function() {
|
|
244
|
-
let
|
|
245
|
-
return { type:
|
|
241
|
+
let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
242
|
+
return { type: v.type || null, language: v.language || null, fileURL: null };
|
|
246
243
|
}(l.parseAttributes(h));
|
|
247
244
|
p.fileURL = l.parseNodeText(h), r.closedCaptionFiles.push(p);
|
|
248
245
|
});
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
let
|
|
246
|
+
const g = l.childByName(c, "Mezzanine"), m = function(h, p) {
|
|
247
|
+
const v = {};
|
|
248
|
+
let R = !1;
|
|
252
249
|
return p.forEach((A) => {
|
|
253
|
-
h && h.getAttribute(A) ?
|
|
254
|
-
}),
|
|
255
|
-
}(
|
|
250
|
+
h && h.getAttribute(A) ? v[A] = h.getAttribute(A) : R = !0;
|
|
251
|
+
}), R ? null : v;
|
|
252
|
+
}(g, ["delivery", "type", "width", "height"]);
|
|
256
253
|
if (m) {
|
|
257
254
|
const h = { id: null, fileURL: null, delivery: null, codec: null, type: null, width: 0, height: 0, fileSize: 0, mediaType: "2D" };
|
|
258
|
-
h.id =
|
|
255
|
+
h.id = g.getAttribute("id"), h.fileURL = l.parseNodeText(g), h.delivery = m.delivery, h.codec = g.getAttribute("codec"), h.type = m.type, h.width = parseInt(m.width, 10), h.height = parseInt(m.height, 10), h.fileSize = parseInt(g.getAttribute("fileSize"), 10), h.mediaType = g.getAttribute("mediaType") || "2D", r.mezzanine = h;
|
|
259
256
|
}
|
|
260
257
|
});
|
|
261
|
-
const n = l.childByName(
|
|
258
|
+
const n = l.childByName(i, "Icons");
|
|
262
259
|
return n && l.childrenByName(n, "Icon").forEach((c) => {
|
|
263
260
|
r.icons.push(function(u) {
|
|
264
|
-
const d = { 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: [] };
|
|
261
|
+
const d = { program: null, height: 0, width: 0, xPosition: 0, yPosition: 0, apiFramework: null, offset: null, duration: 0, type: null, staticResource: null, htmlResource: null, iframeResource: null, pxratio: "1", iconClickThroughURLTemplate: null, iconClickTrackingURLTemplates: [], iconViewTrackingURLTemplate: null, iconClickFallbackImages: [], altText: null, hoverText: null };
|
|
265
262
|
d.program = u.getAttribute("program"), d.height = parseInt(u.getAttribute("height") || 0), d.width = parseInt(u.getAttribute("width") || 0), d.xPosition = function(m) {
|
|
266
263
|
return ["left", "right"].indexOf(m) !== -1 ? m : parseInt(m || 0);
|
|
267
264
|
}(u.getAttribute("xPosition")), d.yPosition = function(m) {
|
|
268
265
|
return ["top", "bottom"].indexOf(m) !== -1 ? m : parseInt(m || 0);
|
|
269
|
-
}(u.getAttribute("yPosition")), d.apiFramework = u.getAttribute("apiFramework"), d.pxratio = u.getAttribute("pxratio") || "1", d.offset = l.parseDuration(u.getAttribute("offset")), d.duration = l.parseDuration(u.getAttribute("duration")), l.childrenByName(u, "HTMLResource").forEach((m) => {
|
|
266
|
+
}(u.getAttribute("yPosition")), d.apiFramework = u.getAttribute("apiFramework"), d.pxratio = u.getAttribute("pxratio") || "1", d.offset = l.parseDuration(u.getAttribute("offset")), d.duration = l.parseDuration(u.getAttribute("duration")), d.altText = u.getAttribute("altText"), d.hoverText = u.getAttribute("hoverText"), l.childrenByName(u, "HTMLResource").forEach((m) => {
|
|
270
267
|
d.type = m.getAttribute("creativeType") || "text/html", d.htmlResource = l.parseNodeText(m);
|
|
271
268
|
}), l.childrenByName(u, "IFrameResource").forEach((m) => {
|
|
272
269
|
d.type = m.getAttribute("creativeType") || 0, d.iframeResource = l.parseNodeText(m);
|
|
273
270
|
}), l.childrenByName(u, "StaticResource").forEach((m) => {
|
|
274
271
|
d.type = m.getAttribute("creativeType") || 0, d.staticResource = l.parseNodeText(m);
|
|
275
272
|
});
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
278
|
-
d.iconClickThroughURLTemplate = l.parseNodeText(l.childByName(
|
|
273
|
+
const g = l.childByName(u, "IconClicks");
|
|
274
|
+
if (g) {
|
|
275
|
+
d.iconClickThroughURLTemplate = l.parseNodeText(l.childByName(g, "IconClickThrough")), l.childrenByName(g, "IconClickTracking").forEach((h) => {
|
|
279
276
|
d.iconClickTrackingURLTemplates.push({ id: h.getAttribute("id") || null, url: l.parseNodeText(h) });
|
|
280
277
|
});
|
|
281
|
-
const m = l.childByName(
|
|
278
|
+
const m = l.childByName(g, "IconClickFallbackImages");
|
|
282
279
|
m && l.childrenByName(m, "IconClickFallbackImage").forEach((h) => {
|
|
283
280
|
d.iconClickFallbackImages.push({ url: l.parseNodeText(h) || null, width: h.getAttribute("width") || null, height: h.getAttribute("height") || null });
|
|
284
281
|
});
|
|
@@ -287,181 +284,181 @@ function le(a, e) {
|
|
|
287
284
|
}(c));
|
|
288
285
|
}), r;
|
|
289
286
|
}
|
|
290
|
-
function
|
|
287
|
+
function Z(i, e) {
|
|
291
288
|
const t = function() {
|
|
292
289
|
let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
293
|
-
const { id:
|
|
294
|
-
return { id:
|
|
290
|
+
const { id: a, adId: s, sequence: o, apiFramework: n } = N(r);
|
|
291
|
+
return { id: a, adId: s, sequence: o, apiFramework: n, type: "nonlinear", variations: [], trackingEvents: {} };
|
|
295
292
|
}(e);
|
|
296
|
-
return l.childrenByName(
|
|
297
|
-
let
|
|
293
|
+
return l.childrenByName(i, "TrackingEvents").forEach((r) => {
|
|
294
|
+
let a, s;
|
|
298
295
|
l.childrenByName(r, "Tracking").forEach((o) => {
|
|
299
|
-
|
|
296
|
+
a = o.getAttribute("event"), s = l.parseNodeText(o), a && s && (Array.isArray(t.trackingEvents[a]) || (t.trackingEvents[a] = []), t.trackingEvents[a].push(s));
|
|
300
297
|
});
|
|
301
|
-
}), l.childrenByName(
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
298
|
+
}), l.childrenByName(i, "NonLinear").forEach((r) => {
|
|
299
|
+
const a = { 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 };
|
|
300
|
+
a.id = r.getAttribute("id") || null, a.width = r.getAttribute("width"), a.height = r.getAttribute("height"), a.expandedWidth = r.getAttribute("expandedWidth"), a.expandedHeight = r.getAttribute("expandedHeight"), a.scalable = l.parseBoolean(r.getAttribute("scalable")), a.maintainAspectRatio = l.parseBoolean(r.getAttribute("maintainAspectRatio")), a.minSuggestedDuration = l.parseDuration(r.getAttribute("minSuggestedDuration")), a.apiFramework = r.getAttribute("apiFramework"), l.childrenByName(r, "HTMLResource").forEach((o) => {
|
|
301
|
+
a.type = o.getAttribute("creativeType") || "text/html", a.htmlResource = l.parseNodeText(o);
|
|
305
302
|
}), l.childrenByName(r, "IFrameResource").forEach((o) => {
|
|
306
|
-
|
|
303
|
+
a.type = o.getAttribute("creativeType") || 0, a.iframeResource = l.parseNodeText(o);
|
|
307
304
|
}), l.childrenByName(r, "StaticResource").forEach((o) => {
|
|
308
|
-
|
|
305
|
+
a.type = o.getAttribute("creativeType") || 0, a.staticResource = l.parseNodeText(o);
|
|
309
306
|
});
|
|
310
307
|
const s = l.childByName(r, "AdParameters");
|
|
311
|
-
s && (
|
|
312
|
-
|
|
313
|
-
}), t.variations.push(
|
|
308
|
+
s && (a.adParameters = { value: l.parseNodeText(s), xmlEncoded: s.getAttribute("xmlEncoded") || null }), a.nonlinearClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "NonLinearClickThrough")), l.childrenByName(r, "NonLinearClickTracking").forEach((o) => {
|
|
309
|
+
a.nonlinearClickTrackingURLTemplates.push({ id: o.getAttribute("id") || null, url: l.parseNodeText(o) });
|
|
310
|
+
}), t.variations.push(a);
|
|
314
311
|
}), t;
|
|
315
312
|
}
|
|
316
|
-
function
|
|
313
|
+
function x(i) {
|
|
317
314
|
const e = [];
|
|
318
|
-
return
|
|
319
|
-
const r =
|
|
315
|
+
return i.forEach((t) => {
|
|
316
|
+
const r = K(t);
|
|
320
317
|
r && e.push(r);
|
|
321
318
|
}), e;
|
|
322
319
|
}
|
|
323
|
-
function
|
|
324
|
-
if (
|
|
325
|
-
const e = { name: null, value: null, attributes: {}, children: [] }, t =
|
|
326
|
-
if (e.name =
|
|
320
|
+
function K(i) {
|
|
321
|
+
if (i.nodeName === "#comment") return null;
|
|
322
|
+
const e = { name: null, value: null, attributes: {}, children: [] }, t = i.attributes, r = i.childNodes;
|
|
323
|
+
if (e.name = i.nodeName, i.attributes) {
|
|
327
324
|
for (const s in t) if (t.hasOwnProperty(s)) {
|
|
328
325
|
const o = t[s];
|
|
329
326
|
o.nodeName && o.nodeValue && (e.attributes[o.nodeName] = o.nodeValue);
|
|
330
327
|
}
|
|
331
328
|
}
|
|
332
329
|
for (const s in r) if (r.hasOwnProperty(s)) {
|
|
333
|
-
const o =
|
|
330
|
+
const o = K(r[s]);
|
|
334
331
|
o && e.children.push(o);
|
|
335
332
|
}
|
|
336
333
|
if (e.children.length === 0 || e.children.length === 1 && ["#cdata-section", "#text"].indexOf(e.children[0].name) >= 0) {
|
|
337
|
-
const s = l.parseNodeText(
|
|
334
|
+
const s = l.parseNodeText(i);
|
|
338
335
|
s !== "" && (e.value = s), e.children = [];
|
|
339
336
|
}
|
|
340
|
-
return (
|
|
341
|
-
var
|
|
337
|
+
return (a = e).value === null && Object.keys(a.attributes).length === 0 && a.children.length === 0 ? null : e;
|
|
338
|
+
var a;
|
|
342
339
|
}
|
|
343
|
-
function
|
|
344
|
-
return
|
|
340
|
+
function J(i) {
|
|
341
|
+
return i.getAttribute("AdID") || i.getAttribute("adID") || i.getAttribute("adId") || null;
|
|
345
342
|
}
|
|
346
|
-
const
|
|
347
|
-
function
|
|
348
|
-
if (!
|
|
349
|
-
const t =
|
|
350
|
-
t.length > 0 &&
|
|
343
|
+
const y = { 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"] } };
|
|
344
|
+
function S(i, e) {
|
|
345
|
+
if (!y[i.nodeName] || !y[i.nodeName].attributes) return;
|
|
346
|
+
const t = y[i.nodeName].attributes.filter((r) => !i.getAttribute(r));
|
|
347
|
+
t.length > 0 && k({ name: i.nodeName, parentName: i.parentNode.nodeName, attributes: t }, e);
|
|
351
348
|
}
|
|
352
|
-
function
|
|
353
|
-
const r =
|
|
354
|
-
if (!(!r ||
|
|
349
|
+
function V(i, e, t) {
|
|
350
|
+
const r = y[i.nodeName], a = !t && i.nodeName !== "Wrapper";
|
|
351
|
+
if (!(!r || a)) {
|
|
355
352
|
if (r.subElements) {
|
|
356
|
-
const s = r.subElements.filter((o) => !l.childByName(
|
|
357
|
-
s.length > 0 &&
|
|
353
|
+
const s = r.subElements.filter((o) => !l.childByName(i, o));
|
|
354
|
+
s.length > 0 && k({ name: i.nodeName, parentName: i.parentNode.nodeName, subElements: s }, e);
|
|
358
355
|
}
|
|
359
|
-
!t || !r.oneOfinLineResources || r.oneOfinLineResources.some((s) => l.childByName(
|
|
356
|
+
!t || !r.oneOfinLineResources || r.oneOfinLineResources.some((s) => l.childByName(i, s)) || k({ name: i.nodeName, parentName: i.parentNode.nodeName, oneOfResources: r.oneOfinLineResources }, e);
|
|
360
357
|
}
|
|
361
358
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
359
|
+
function D(i) {
|
|
360
|
+
return i.children && i.children.length !== 0;
|
|
364
361
|
}
|
|
365
|
-
function
|
|
366
|
-
let { name: t, parentName: r, attributes:
|
|
367
|
-
n +=
|
|
362
|
+
function k(i, e) {
|
|
363
|
+
let { name: t, parentName: r, attributes: a, subElements: s, oneOfResources: o } = i, n = "Element '".concat(t, "'");
|
|
364
|
+
n += a ? " missing required attribute(s) '".concat(a.join(", "), "' ") : s ? " missing required sub element(s) '".concat(s.join(", "), "' ") : o ? " must provide one of the following '".concat(o.join(", "), "' ") : " is empty", e("VAST-warning", { message: n, parentElement: r, specVersion: 4.1 });
|
|
368
365
|
}
|
|
369
|
-
const
|
|
370
|
-
if (e && e.nodeName) if (e.nodeName === "InLine" && (r = !0),
|
|
371
|
-
|
|
372
|
-
for (let
|
|
373
|
-
} else l.parseNodeText(e).length === 0 &&
|
|
374
|
-
}, hasSubElements:
|
|
375
|
-
function
|
|
366
|
+
const $ = { verifyRequiredValues: function i(e, t, r) {
|
|
367
|
+
if (e && e.nodeName) if (e.nodeName === "InLine" && (r = !0), S(e, t), D(e)) {
|
|
368
|
+
V(e, t, r);
|
|
369
|
+
for (let a = 0; a < e.children.length; a++) i(e.children[a], t, r);
|
|
370
|
+
} else l.parseNodeText(e).length === 0 && k({ name: e.nodeName, parentName: e.parentNode.nodeName }, t);
|
|
371
|
+
}, hasSubElements: D, emitMissingValueWarning: k, verifyRequiredAttributes: S, verifyRequiredSubElements: V };
|
|
372
|
+
function ee(i, e) {
|
|
376
373
|
let { allowMultipleAds: t, followAdditionalWrappers: r } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
377
|
-
const
|
|
374
|
+
const a = Array.from(i.childNodes).filter((s) => {
|
|
378
375
|
const o = s.nodeName.toLowerCase();
|
|
379
376
|
return o === "inline" || r !== !1 && o === "wrapper";
|
|
380
377
|
});
|
|
381
|
-
for (const s of
|
|
382
|
-
if (l.copyNodeAttribute("id",
|
|
383
|
-
if (s.nodeName === "InLine") return { ad:
|
|
378
|
+
for (const s of a) {
|
|
379
|
+
if (l.copyNodeAttribute("id", i, s), l.copyNodeAttribute("sequence", i, s), l.copyNodeAttribute("adType", i, s), s.nodeName === "Wrapper") return { ad: re(s, e), type: "WRAPPER" };
|
|
380
|
+
if (s.nodeName === "InLine") return { ad: te(s, e, { allowMultipleAds: t }), type: "INLINE" };
|
|
384
381
|
const o = s.nodeName.toLowerCase();
|
|
385
382
|
e("VAST-warning", { message: "<".concat(s.nodeName, o === "inline" ? "> must be written <InLine>" : "> must be written <Wrapper>"), wrongNode: s });
|
|
386
383
|
}
|
|
387
384
|
}
|
|
388
|
-
function
|
|
385
|
+
function te(i, e) {
|
|
389
386
|
let { allowMultipleAds: t } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
390
|
-
return t === !1 &&
|
|
387
|
+
return t === !1 && i.getAttribute("sequence") ? null : H(i, e);
|
|
391
388
|
}
|
|
392
|
-
function
|
|
389
|
+
function H(i, e) {
|
|
393
390
|
let t = [];
|
|
394
|
-
e &&
|
|
395
|
-
const r = Array.from(
|
|
391
|
+
e && $.verifyRequiredValues(i, e);
|
|
392
|
+
const r = Array.from(i.childNodes), a = function() {
|
|
396
393
|
let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
397
394
|
return { id: s.id || null, sequence: s.sequence || null, adType: s.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 };
|
|
398
|
-
}(l.parseAttributes(
|
|
395
|
+
}(l.parseAttributes(i));
|
|
399
396
|
return r.forEach((s) => {
|
|
400
397
|
switch (s.nodeName) {
|
|
401
398
|
case "Error":
|
|
402
|
-
|
|
399
|
+
a.errorURLTemplates.push(l.parseNodeText(s));
|
|
403
400
|
break;
|
|
404
401
|
case "Impression":
|
|
405
|
-
|
|
402
|
+
a.impressionURLTemplates.push({ id: s.getAttribute("id") || null, url: l.parseNodeText(s) });
|
|
406
403
|
break;
|
|
407
404
|
case "Creatives":
|
|
408
|
-
|
|
405
|
+
a.creatives = function(o) {
|
|
409
406
|
const n = [];
|
|
410
407
|
return o.forEach((c) => {
|
|
411
|
-
const u = { id: c.getAttribute("id") || null, adId:
|
|
412
|
-
let
|
|
408
|
+
const u = { id: c.getAttribute("id") || null, adId: J(c), sequence: c.getAttribute("sequence") || null, apiFramework: c.getAttribute("apiFramework") || null }, d = [];
|
|
409
|
+
let g;
|
|
413
410
|
l.childrenByName(c, "UniversalAdId").forEach((h) => {
|
|
414
411
|
const p = { idRegistry: h.getAttribute("idRegistry") || "unknown", value: l.parseNodeText(h) };
|
|
415
412
|
d.push(p);
|
|
416
413
|
});
|
|
417
414
|
const m = l.childByName(c, "CreativeExtensions");
|
|
418
|
-
m && (
|
|
415
|
+
m && (g = x(l.childrenByName(m, "CreativeExtension")));
|
|
419
416
|
for (const h in c.childNodes) {
|
|
420
417
|
const p = c.childNodes[h];
|
|
421
|
-
let
|
|
418
|
+
let v;
|
|
422
419
|
switch (p.nodeName) {
|
|
423
420
|
case "Linear":
|
|
424
|
-
|
|
421
|
+
v = X(p, u);
|
|
425
422
|
break;
|
|
426
423
|
case "NonLinearAds":
|
|
427
|
-
|
|
424
|
+
v = Z(p, u);
|
|
428
425
|
break;
|
|
429
426
|
case "CompanionAds":
|
|
430
|
-
|
|
427
|
+
v = Q(p, u);
|
|
431
428
|
}
|
|
432
|
-
|
|
429
|
+
v && (d && (v.universalAdIds = d), g && (v.creativeExtensions = g), n.push(v));
|
|
433
430
|
}
|
|
434
431
|
}), n;
|
|
435
432
|
}(l.childrenByName(s, "Creative"));
|
|
436
433
|
break;
|
|
437
434
|
case "Extensions": {
|
|
438
435
|
const o = l.childrenByName(s, "Extension");
|
|
439
|
-
|
|
436
|
+
a.extensions = x(o), a.adVerifications.length || (t = function(n) {
|
|
440
437
|
let c = null, u = [];
|
|
441
|
-
return n.some((d) => c = l.childByName(d, "AdVerifications")), c && (u =
|
|
438
|
+
return n.some((d) => c = l.childByName(d, "AdVerifications")), c && (u = O(l.childrenByName(c, "Verification"))), u;
|
|
442
439
|
}(o));
|
|
443
440
|
break;
|
|
444
441
|
}
|
|
445
442
|
case "AdVerifications":
|
|
446
|
-
|
|
443
|
+
a.adVerifications = O(l.childrenByName(s, "Verification"));
|
|
447
444
|
break;
|
|
448
445
|
case "AdSystem":
|
|
449
|
-
|
|
446
|
+
a.system = { value: l.parseNodeText(s), version: s.getAttribute("version") || null };
|
|
450
447
|
break;
|
|
451
448
|
case "AdTitle":
|
|
452
|
-
|
|
449
|
+
a.title = l.parseNodeText(s);
|
|
453
450
|
break;
|
|
454
451
|
case "AdServingId":
|
|
455
|
-
|
|
452
|
+
a.adServingId = l.parseNodeText(s);
|
|
456
453
|
break;
|
|
457
454
|
case "Category":
|
|
458
|
-
|
|
455
|
+
a.categories.push({ authority: s.getAttribute("authority") || null, value: l.parseNodeText(s) });
|
|
459
456
|
break;
|
|
460
457
|
case "Expires":
|
|
461
|
-
|
|
458
|
+
a.expires = parseInt(l.parseNodeText(s), 10);
|
|
462
459
|
break;
|
|
463
460
|
case "ViewableImpression":
|
|
464
|
-
|
|
461
|
+
a.viewableImpression.push(function(o) {
|
|
465
462
|
const n = (c, u) => {
|
|
466
463
|
const d = l.parseNodeText(u);
|
|
467
464
|
return d && c.push(d), c;
|
|
@@ -470,27 +467,27 @@ function Z(a, e) {
|
|
|
470
467
|
}(s));
|
|
471
468
|
break;
|
|
472
469
|
case "Description":
|
|
473
|
-
|
|
470
|
+
a.description = l.parseNodeText(s);
|
|
474
471
|
break;
|
|
475
472
|
case "Advertiser":
|
|
476
|
-
|
|
473
|
+
a.advertiser = { id: s.getAttribute("id") || null, value: l.parseNodeText(s) };
|
|
477
474
|
break;
|
|
478
475
|
case "Pricing":
|
|
479
|
-
|
|
476
|
+
a.pricing = { value: l.parseNodeText(s), model: s.getAttribute("model") || null, currency: s.getAttribute("currency") || null };
|
|
480
477
|
break;
|
|
481
478
|
case "Survey":
|
|
482
|
-
|
|
479
|
+
a.survey = { value: l.parseNodeText(s), type: s.getAttribute("type") || null };
|
|
483
480
|
break;
|
|
484
481
|
case "BlockedAdCategories":
|
|
485
|
-
|
|
482
|
+
a.blockedAdCategories.push({ authority: s.getAttribute("authority") || null, value: l.parseNodeText(s) });
|
|
486
483
|
}
|
|
487
|
-
}), t.length && (
|
|
484
|
+
}), t.length && (a.adVerifications = a.adVerifications.concat(t)), a;
|
|
488
485
|
}
|
|
489
|
-
function
|
|
490
|
-
const t =
|
|
491
|
-
t.followAdditionalWrappers = !r || l.parseBoolean(r), t.allowMultipleAds = !!
|
|
492
|
-
let o = l.childByName(
|
|
493
|
-
if (o ? t.nextWrapperURL = l.parseNodeText(o) : (o = l.childByName(
|
|
486
|
+
function re(i, e) {
|
|
487
|
+
const t = H(i, e), r = i.getAttribute("followAdditionalWrappers"), a = i.getAttribute("allowMultipleAds"), s = i.getAttribute("fallbackOnNoAd");
|
|
488
|
+
t.followAdditionalWrappers = !r || l.parseBoolean(r), t.allowMultipleAds = !!a && l.parseBoolean(a), t.fallbackOnNoAd = s ? l.parseBoolean(s) : null;
|
|
489
|
+
let o = l.childByName(i, "VASTAdTagURI");
|
|
490
|
+
if (o ? t.nextWrapperURL = l.parseNodeText(o) : (o = l.childByName(i, "VASTAdTagURL"), o && (t.nextWrapperURL = l.parseNodeText(l.childByName(o, "URL")))), t.creatives.forEach((n) => {
|
|
494
491
|
if (["linear", "nonlinear"].includes(n.type)) {
|
|
495
492
|
if (n.trackingEvents) {
|
|
496
493
|
t.trackingEvents || (t.trackingEvents = {}), t.trackingEvents[n.type] || (t.trackingEvents[n.type] = {});
|
|
@@ -509,11 +506,11 @@ function pe(a, e) {
|
|
|
509
506
|
}
|
|
510
507
|
}), t.nextWrapperURL) return t;
|
|
511
508
|
}
|
|
512
|
-
function
|
|
509
|
+
function O(i) {
|
|
513
510
|
const e = [];
|
|
514
|
-
return
|
|
515
|
-
const r = { resource: null, vendor: null, browserOptional: !1, apiFramework: null, type: null, parameters: null, trackingEvents: {} },
|
|
516
|
-
l.assignAttributes(t.attributes, r),
|
|
511
|
+
return i.forEach((t) => {
|
|
512
|
+
const r = { resource: null, vendor: null, browserOptional: !1, apiFramework: null, type: null, parameters: null, trackingEvents: {} }, a = Array.from(t.childNodes);
|
|
513
|
+
l.assignAttributes(t.attributes, r), a.forEach((o) => {
|
|
517
514
|
let { nodeName: n, textContent: c, attributes: u } = o;
|
|
518
515
|
switch (n) {
|
|
519
516
|
case "JavaScriptResource":
|
|
@@ -531,7 +528,7 @@ function j(a) {
|
|
|
531
528
|
}), e.push(r);
|
|
532
529
|
}), e;
|
|
533
530
|
}
|
|
534
|
-
class
|
|
531
|
+
class _ {
|
|
535
532
|
constructor() {
|
|
536
533
|
this._handlers = [];
|
|
537
534
|
}
|
|
@@ -541,10 +538,10 @@ class J {
|
|
|
541
538
|
return this._handlers.push({ event: e, handler: t }), this;
|
|
542
539
|
}
|
|
543
540
|
once(e, t) {
|
|
544
|
-
return this.on(e, function(r,
|
|
541
|
+
return this.on(e, function(r, a, s) {
|
|
545
542
|
const o = { fired: !1, wrapFn: void 0 };
|
|
546
543
|
function n() {
|
|
547
|
-
o.fired || (r.off(
|
|
544
|
+
o.fired || (r.off(a, o.wrapFn), o.fired = !0, s.bind(r)(...arguments));
|
|
548
545
|
}
|
|
549
546
|
return o.wrapFn = n, n;
|
|
550
547
|
}(this, e, t));
|
|
@@ -553,7 +550,7 @@ class J {
|
|
|
553
550
|
return this._handlers = this._handlers.filter((r) => r.event !== e || r.handler !== t), this;
|
|
554
551
|
}
|
|
555
552
|
emit(e) {
|
|
556
|
-
for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0),
|
|
553
|
+
for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0), a = 1; a < t; a++) r[a - 1] = arguments[a];
|
|
557
554
|
let s = !1;
|
|
558
555
|
return this._handlers.forEach((o) => {
|
|
559
556
|
o.event === "*" && (s = !0, o.handler(e, ...r)), o.event === e && (s = !0, o.handler(...r));
|
|
@@ -572,28 +569,28 @@ class J {
|
|
|
572
569
|
return this._handlers.map((e) => e.event);
|
|
573
570
|
}
|
|
574
571
|
}
|
|
575
|
-
let
|
|
576
|
-
const
|
|
577
|
-
!
|
|
578
|
-
},
|
|
579
|
-
class
|
|
572
|
+
let F = 0, E = 0;
|
|
573
|
+
const z = (i, e) => {
|
|
574
|
+
!i || !e || i <= 0 || e <= 0 || (E = (E * F + 8 * i / e) / ++F);
|
|
575
|
+
}, ie = { ERRORCODE: 900, extensions: [] }, P = "VAST response version not supported";
|
|
576
|
+
class ae extends _ {
|
|
580
577
|
constructor() {
|
|
581
578
|
let { fetcher: e } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
582
|
-
super(), this.maxWrapperDepth = null, this.rootErrorURLTemplates = [], this.errorURLTemplates = [], this.remainingAds = [], this.parsingOptions = {}, this.fetcher = e || null;
|
|
579
|
+
super(), this.maxWrapperDepth = null, this.rootErrorURLTemplates = [], this.errorURLTemplates = [], this.remainingAds = [], this.parsingOptions = {}, this.fetcher = e || null, this.keepFailedAdPod = !1;
|
|
583
580
|
}
|
|
584
581
|
trackVastError(e, t) {
|
|
585
|
-
for (var r = arguments.length,
|
|
586
|
-
this.emit("VAST-error", Object.assign({},
|
|
582
|
+
for (var r = arguments.length, a = new Array(r > 2 ? r - 2 : 0), s = 2; s < r; s++) a[s - 2] = arguments[s];
|
|
583
|
+
this.emit("VAST-error", Object.assign({}, ie, t, ...a)), f.track(e, t);
|
|
587
584
|
}
|
|
588
585
|
getErrorURLTemplates() {
|
|
589
586
|
return this.rootErrorURLTemplates.concat(this.errorURLTemplates);
|
|
590
587
|
}
|
|
591
588
|
getEstimatedBitrate() {
|
|
592
|
-
return
|
|
589
|
+
return E;
|
|
593
590
|
}
|
|
594
591
|
initParsingStatus() {
|
|
595
592
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
596
|
-
this.maxWrapperDepth = e.wrapperLimit || 10, this.parsingOptions = { allowMultipleAds: e.allowMultipleAds }, this.rootURL = "", this.resetParsingStatus(),
|
|
593
|
+
this.maxWrapperDepth = e.wrapperLimit || 10, this.parsingOptions = { allowMultipleAds: e.allowMultipleAds }, this.keepFailedAdPod = e.keepFailedAdPod || !1, this.rootURL = "", this.resetParsingStatus(), z(e.byteLength, e.requestDuration);
|
|
597
594
|
}
|
|
598
595
|
resetParsingStatus() {
|
|
599
596
|
this.errorURLTemplates = [], this.rootErrorURLTemplates = [], this.vastVersion = null;
|
|
@@ -609,21 +606,21 @@ class ve extends J {
|
|
|
609
606
|
}
|
|
610
607
|
buildVASTResponse(e) {
|
|
611
608
|
const t = function(r) {
|
|
612
|
-
let { ads:
|
|
613
|
-
return { ads:
|
|
609
|
+
let { ads: a, errorURLTemplates: s, version: o } = r;
|
|
610
|
+
return { ads: a || [], errorURLTemplates: s || [], version: o || null };
|
|
614
611
|
}({ ads: e, errorURLTemplates: this.getErrorURLTemplates(), version: this.vastVersion });
|
|
615
612
|
return this.completeWrapperResolving(t), t;
|
|
616
613
|
}
|
|
617
614
|
parseVastXml(e, t) {
|
|
618
|
-
let { isRootVAST: r = !1, url:
|
|
615
|
+
let { isRootVAST: r = !1, url: a = null, wrapperDepth: s = 0, allowMultipleAds: o, followAdditionalWrappers: n } = t;
|
|
619
616
|
if (!e || !e.documentElement || e.documentElement.nodeName !== "VAST") {
|
|
620
617
|
var c;
|
|
621
|
-
this.emit("VAST-ad-parsed", { type: "ERROR", url:
|
|
618
|
+
this.emit("VAST-ad-parsed", { type: "ERROR", url: a, wrapperDepth: s });
|
|
622
619
|
const m = (e == null || (c = e.documentElement) === null || c === void 0 ? void 0 : c.nodeName) === "VideoAdServingTemplate";
|
|
623
|
-
throw new Error(m ?
|
|
620
|
+
throw new Error(m ? P : "Invalid VAST XMLDocument");
|
|
624
621
|
}
|
|
625
|
-
const u = [], d = e.documentElement.childNodes,
|
|
626
|
-
r &&
|
|
622
|
+
const u = [], d = e.documentElement.childNodes, g = e.documentElement.getAttribute("version");
|
|
623
|
+
r && g && (this.vastVersion = g);
|
|
627
624
|
for (const m in d) {
|
|
628
625
|
const h = d[m];
|
|
629
626
|
if (h.nodeName === "Error") {
|
|
@@ -632,86 +629,86 @@ class ve extends J {
|
|
|
632
629
|
} else if (h.nodeName === "Ad") {
|
|
633
630
|
if (this.vastVersion && parseFloat(this.vastVersion) < 3) o = !0;
|
|
634
631
|
else if (o === !1 && u.length > 1) break;
|
|
635
|
-
const p =
|
|
636
|
-
p.ad ? (u.push(p.ad), this.emit("VAST-ad-parsed", { type: p.type, url:
|
|
632
|
+
const p = ee(h, this.emit.bind(this), { allowMultipleAds: o, followAdditionalWrappers: n });
|
|
633
|
+
p.ad ? (u.push(p.ad), this.emit("VAST-ad-parsed", { type: p.type, url: a, wrapperDepth: s, adIndex: u.length - 1, vastVersion: g })) : this.trackVastError(this.getErrorURLTemplates(), { ERRORCODE: 101 });
|
|
637
634
|
}
|
|
638
635
|
}
|
|
639
636
|
return u;
|
|
640
637
|
}
|
|
641
638
|
parse(e) {
|
|
642
|
-
let { url: t = null, resolveAll: r = !0, wrapperSequence:
|
|
639
|
+
let { url: t = null, resolveAll: r = !0, wrapperSequence: a = null, previousUrl: s = null, wrapperDepth: o = 0, isRootVAST: n = !1, followAdditionalWrappers: c, allowMultipleAds: u } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, d = [];
|
|
643
640
|
this.vastVersion && parseFloat(this.vastVersion) < 3 && n && (u = !0);
|
|
644
641
|
try {
|
|
645
642
|
d = this.parseVastXml(e, { isRootVAST: n, url: t, wrapperDepth: o, allowMultipleAds: u, followAdditionalWrappers: c });
|
|
646
|
-
} catch (
|
|
647
|
-
return Promise.reject(
|
|
643
|
+
} catch (g) {
|
|
644
|
+
return Promise.reject(g);
|
|
648
645
|
}
|
|
649
|
-
if (d.length === 1 &&
|
|
650
|
-
const
|
|
651
|
-
|
|
646
|
+
if (d.length === 1 && a != null && (d[0].sequence = a), r === !1) {
|
|
647
|
+
const g = l.getSortedAdPods(d), m = l.getStandAloneAds(d);
|
|
648
|
+
g.length ? d = g : m.length && (d = [m.shift()]), this.remainingAds = m;
|
|
652
649
|
}
|
|
653
650
|
return this.resolveAds(d, { wrapperDepth: o, previousUrl: s, url: t });
|
|
654
651
|
}
|
|
655
652
|
resolveAds() {
|
|
656
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { wrapperDepth: t, previousUrl: r, url:
|
|
653
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { wrapperDepth: t, previousUrl: r, url: a } = arguments.length > 1 ? arguments[1] : void 0;
|
|
657
654
|
const s = [];
|
|
658
|
-
return r =
|
|
655
|
+
return r = a, e.forEach((o) => {
|
|
659
656
|
const n = this.resolveWrappers(o, t, r);
|
|
660
657
|
s.push(n);
|
|
661
658
|
}), Promise.all(s).then((o) => f.flatten(o));
|
|
662
659
|
}
|
|
663
660
|
resolveWrappers(e, t, r) {
|
|
664
|
-
const
|
|
661
|
+
const a = { ...e };
|
|
665
662
|
return new Promise((s) => {
|
|
666
663
|
var o;
|
|
667
|
-
if (t++, !
|
|
668
|
-
if (!this.fetcher) return
|
|
669
|
-
if (t >= this.maxWrapperDepth) return
|
|
670
|
-
|
|
671
|
-
const n = (o = this.parsingOptions.allowMultipleAds) !== null && o !== void 0 ? o :
|
|
672
|
-
this.fetcher.fetchVAST({ url:
|
|
673
|
-
if (delete
|
|
674
|
-
d.forEach((
|
|
675
|
-
|
|
664
|
+
if (t++, !a.nextWrapperURL) return delete a.nextWrapperURL, s(a);
|
|
665
|
+
if (!this.fetcher) return a.VASTAdTagURI = a.nextWrapperURL, delete a.nextWrapperURL, s(a);
|
|
666
|
+
if (t >= this.maxWrapperDepth) return a.errorCode = 302, delete a.nextWrapperURL, s(a);
|
|
667
|
+
a.nextWrapperURL = l.resolveVastAdTagURI(a.nextWrapperURL, r);
|
|
668
|
+
const n = (o = this.parsingOptions.allowMultipleAds) !== null && o !== void 0 ? o : a.allowMultipleAds, c = a.sequence;
|
|
669
|
+
this.fetcher.fetchVAST({ url: a.nextWrapperURL, emitter: this.emit.bind(this), maxWrapperDepth: this.maxWrapperDepth }).then((u) => this.parse(u, { url: a.nextWrapperURL, previousUrl: r, wrapperSequence: c, wrapperDepth: t, followAdditionalWrappers: a.followAdditionalWrappers, allowMultipleAds: n }).then((d) => {
|
|
670
|
+
if (delete a.nextWrapperURL, d.length === 0) return a.creatives = [], s(a);
|
|
671
|
+
d.forEach((g) => {
|
|
672
|
+
g && l.mergeWrapperAdData(g, a);
|
|
676
673
|
}), s(d);
|
|
677
674
|
})).catch((u) => {
|
|
678
|
-
|
|
675
|
+
a.errorCode = u.message === P ? 102 : 301, a.errorMessage = u.message, s(a);
|
|
679
676
|
});
|
|
680
677
|
});
|
|
681
678
|
}
|
|
682
679
|
completeWrapperResolving(e) {
|
|
683
680
|
if (e.ads.length === 0) this.trackVastError(e.errorURLTemplates, { ERRORCODE: 303 });
|
|
684
681
|
else for (let t = e.ads.length - 1; t >= 0; t--) {
|
|
685
|
-
const r = e.ads[t],
|
|
686
|
-
var o;
|
|
687
|
-
return ((o = s.mediaFiles) === null || o === void 0 ? void 0 : o.length) > 0;
|
|
682
|
+
const r = e.ads[t], a = !r.creatives.some((s) => {
|
|
683
|
+
var o, n;
|
|
684
|
+
return ((o = s.mediaFiles) === null || o === void 0 ? void 0 : o.length) > 0 || ((n = s.variations) === null || n === void 0 ? void 0 : n.length) > 0;
|
|
688
685
|
});
|
|
689
|
-
!r.errorCode && !
|
|
686
|
+
!r.errorCode && !a || r.VASTAdTagURI || (this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates), { ERRORCODE: r.errorCode || 303 }, { ERRORMESSAGE: r.errorMessage || "" }, { extensions: r.extensions }, { system: r.system }), this.keepFailedAdPod && r.sequence ? r.hasFailed = !0 : e.ads.splice(t, 1));
|
|
690
687
|
}
|
|
691
688
|
}
|
|
692
689
|
}
|
|
693
|
-
let
|
|
694
|
-
const
|
|
695
|
-
return this.data[
|
|
696
|
-
}, setItem(
|
|
697
|
-
this.data[
|
|
698
|
-
}, removeItem(
|
|
699
|
-
delete this.data[
|
|
690
|
+
let T = null;
|
|
691
|
+
const se = { data: {}, length: 0, getItem(i) {
|
|
692
|
+
return this.data[i];
|
|
693
|
+
}, setItem(i, e) {
|
|
694
|
+
this.data[i] = e, this.length = Object.keys(this.data).length;
|
|
695
|
+
}, removeItem(i) {
|
|
696
|
+
delete this.data[i], this.length = Object.keys(this.data).length;
|
|
700
697
|
}, clear() {
|
|
701
698
|
this.data = {}, this.length = 0;
|
|
702
699
|
} };
|
|
703
|
-
class
|
|
700
|
+
class ne {
|
|
704
701
|
constructor() {
|
|
705
702
|
this.storage = this.initStorage();
|
|
706
703
|
}
|
|
707
704
|
initStorage() {
|
|
708
|
-
if (
|
|
705
|
+
if (T) return T;
|
|
709
706
|
try {
|
|
710
|
-
|
|
707
|
+
T = typeof window < "u" && window !== null ? window.localStorage || window.sessionStorage : null;
|
|
711
708
|
} catch {
|
|
712
|
-
|
|
709
|
+
T = null;
|
|
713
710
|
}
|
|
714
|
-
return
|
|
711
|
+
return T && !this.isStorageDisabled(T) || (T = se, T.clear()), T;
|
|
715
712
|
}
|
|
716
713
|
isStorageDisabled(e) {
|
|
717
714
|
const t = "__VASTStorage__";
|
|
@@ -735,31 +732,31 @@ class Te {
|
|
|
735
732
|
return this.storage.clear();
|
|
736
733
|
}
|
|
737
734
|
}
|
|
738
|
-
const
|
|
735
|
+
const b = 12e4, oe = { get: async function(i, e) {
|
|
739
736
|
try {
|
|
740
737
|
const t = new AbortController(), r = setTimeout(() => {
|
|
741
|
-
throw t.abort(), new Error("URLHandler: Request timed out after ".concat(e.timeout ||
|
|
742
|
-
}, e.timeout ||
|
|
738
|
+
throw t.abort(), new Error("URLHandler: Request timed out after ".concat(e.timeout || b, " ms (408)"));
|
|
739
|
+
}, e.timeout || b), a = await fetch(i, { ...e, signal: t.signal, credentials: e.withCredentials ? "include" : "omit" }).finally(() => {
|
|
743
740
|
clearTimeout(r);
|
|
744
741
|
}), s = function(o) {
|
|
745
742
|
return f.isBrowserEnvironment() && window.location.protocol === "https:" && o.url.includes("http://") ? "URLHandler: Cannot go from HTTPS to HTTP." : o.status === 200 && o.ok ? null : "URLHandler: ".concat(o.statusText, " (").concat(o.status, ")");
|
|
746
|
-
}(
|
|
747
|
-
return s ? { error: new Error(s), statusCode:
|
|
743
|
+
}(a);
|
|
744
|
+
return s ? { error: new Error(s), statusCode: a.status } : async function(o) {
|
|
748
745
|
const n = await o.text();
|
|
749
746
|
let c;
|
|
750
|
-
return c = f.isBrowserEnvironment() ? new DOMParser() : new (await import("./index-
|
|
751
|
-
}(
|
|
747
|
+
return c = f.isBrowserEnvironment() ? new DOMParser() : new (await import("./index-l-eyvmpL.js").then((u) => u.i)).DOMParser(), { xml: c.parseFromString(n, "text/xml"), details: { byteLength: n.length, statusCode: o.status, rawXml: n } };
|
|
748
|
+
}(a);
|
|
752
749
|
} catch (t) {
|
|
753
750
|
return { error: t, statusCode: t.name === "AbortError" ? 408 : null };
|
|
754
751
|
}
|
|
755
752
|
} };
|
|
756
|
-
class
|
|
753
|
+
class le {
|
|
757
754
|
constructor() {
|
|
758
755
|
this.URLTemplateFilters = [];
|
|
759
756
|
}
|
|
760
757
|
setOptions() {
|
|
761
758
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
762
|
-
this.urlHandler = e.urlHandler || e.urlhandler ||
|
|
759
|
+
this.urlHandler = e.urlHandler || e.urlhandler || oe, this.fetchingOptions = { ...e.fetchOptions, timeout: e.timeout || b, withCredentials: !!e.withCredentials };
|
|
763
760
|
}
|
|
764
761
|
addURLTemplateFilter(e) {
|
|
765
762
|
typeof e == "function" && this.URLTemplateFilters.push(e);
|
|
@@ -775,20 +772,20 @@ class Re {
|
|
|
775
772
|
}
|
|
776
773
|
async fetchVAST(e) {
|
|
777
774
|
var t;
|
|
778
|
-
let { url: r, maxWrapperDepth:
|
|
775
|
+
let { url: r, maxWrapperDepth: a, emitter: s, wrapperDepth: o = 0, previousUrl: n = null, wrapperAd: c = null } = e;
|
|
779
776
|
const u = Date.now();
|
|
780
777
|
this.URLTemplateFilters.forEach((m) => {
|
|
781
778
|
r = m(r);
|
|
782
|
-
}), s("VAST-resolving", { url: r, previousUrl: n, wrapperDepth: o, maxWrapperDepth:
|
|
783
|
-
const d = await this.urlHandler.get(r, this.fetchingOptions),
|
|
784
|
-
if (s("VAST-resolved", { url: r, previousUrl: n, wrapperDepth: o, error: (d == null ? void 0 : d.error) || null, duration:
|
|
779
|
+
}), s("VAST-resolving", { url: r, previousUrl: n, wrapperDepth: o, maxWrapperDepth: a, timeout: this.fetchingOptions.timeout, wrapperAd: c });
|
|
780
|
+
const d = await this.urlHandler.get(r, this.fetchingOptions), g = Math.round(Date.now() - u);
|
|
781
|
+
if (s("VAST-resolved", { url: r, previousUrl: n, wrapperDepth: o, error: (d == null ? void 0 : d.error) || null, duration: g, statusCode: (d == null ? void 0 : d.statusCode) || null, ...d == null ? void 0 : d.details }), z(d == null || (t = d.details) === null || t === void 0 ? void 0 : t.byteLength, g), d.error) throw new Error(d.error);
|
|
785
782
|
return d.xml;
|
|
786
783
|
}
|
|
787
784
|
}
|
|
788
|
-
class
|
|
785
|
+
class ce {
|
|
789
786
|
constructor() {
|
|
790
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : new
|
|
791
|
-
this.cappingFreeLunch = e, this.cappingMinimumTimeInterval = t, this.fetcher = new
|
|
787
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : new ne();
|
|
788
|
+
this.cappingFreeLunch = e, this.cappingMinimumTimeInterval = t, this.fetcher = new le(), this.vastParser = new ae({ fetcher: this.fetcher }), this.storage = r, this.lastSuccessfulAd === void 0 && (this.lastSuccessfulAd = 0), this.totalCalls === void 0 && (this.totalCalls = 0), this.totalCallsTimeout === void 0 && (this.totalCallsTimeout = 0);
|
|
792
789
|
}
|
|
793
790
|
addURLTemplateFilter(e) {
|
|
794
791
|
this.fetcher.addURLTemplateFilter(e);
|
|
@@ -836,29 +833,33 @@ class ke {
|
|
|
836
833
|
get(e) {
|
|
837
834
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
838
835
|
const r = Date.now();
|
|
839
|
-
return t.hasOwnProperty("resolveAll") || (t.resolveAll = !1), this.totalCallsTimeout < r ? (this.totalCalls = 1, this.totalCallsTimeout = r + 36e5) : this.totalCalls++, new Promise((
|
|
836
|
+
return t.hasOwnProperty("resolveAll") || (t.resolveAll = !1), this.totalCallsTimeout < r ? (this.totalCalls = 1, this.totalCallsTimeout = r + 36e5) : this.totalCalls++, new Promise((a, s) => {
|
|
840
837
|
if (this.cappingFreeLunch >= this.totalCalls) return s(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls, "/").concat(this.cappingFreeLunch)));
|
|
841
838
|
const o = r - this.lastSuccessfulAd;
|
|
842
839
|
if (o < 0) this.lastSuccessfulAd = 0;
|
|
843
840
|
else if (o < this.cappingMinimumTimeInterval) return s(new Error("VAST call canceled – (".concat(this.cappingMinimumTimeInterval, ")ms minimum interval reached")));
|
|
844
841
|
this.vastParser.initParsingStatus(t), this.fetcher.setOptions(t), this.vastParser.rootURL = e, this.fetcher.fetchVAST({ url: e, emitter: this.vastParser.emit.bind(this.vastParser), maxWrapperDepth: this.vastParser.maxWrapperDepth }).then((n) => (t.previousUrl = e, t.isRootVAST = !0, t.url = e, this.vastParser.parse(n, t).then((c) => {
|
|
845
842
|
const u = this.vastParser.buildVASTResponse(c);
|
|
846
|
-
|
|
843
|
+
a(u);
|
|
847
844
|
}))).catch((n) => s(n));
|
|
848
845
|
});
|
|
849
846
|
}
|
|
850
847
|
}
|
|
851
|
-
class
|
|
848
|
+
class ue extends _ {
|
|
852
849
|
constructor(e, t, r) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
this.trackingEvents[
|
|
850
|
+
var a;
|
|
851
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, o = arguments.length > 4 && arguments[4] !== void 0 && arguments[4];
|
|
852
|
+
super(), this.ad = t, this.creative = r, this.variation = s, this.muted = o, this.impressed = !1, this.skippable = !1, this.trackingEvents = {}, this.trackedProgressEvents = [], this.lastPercentage = 0, this._alreadyTriggeredQuartiles = {}, this.emitAlwaysEvents = ["creativeView", "start", "firstQuartile", "midpoint", "thirdQuartile", "complete", "resume", "pause", "rewind", "skip", "closeLinear", "close"];
|
|
853
|
+
for (const n in this.creative.trackingEvents) {
|
|
854
|
+
const c = this.creative.trackingEvents[n];
|
|
855
|
+
this.trackingEvents[n] = c.slice(0);
|
|
858
856
|
}
|
|
859
|
-
(
|
|
860
|
-
|
|
861
|
-
|
|
857
|
+
this.viewableImpressionTrackers = ((a = this.ad.viewableImpression) === null || a === void 0 ? void 0 : a.reduce((n, c) => (n.notViewable.push(...c.notViewable), n.viewUndetermined.push(...c.viewUndetermined), n.viewable.push(...c.viewable), n), { notViewable: [], viewUndetermined: [], viewable: [] })) || {}, Object.entries(this.viewableImpressionTrackers).forEach((n) => {
|
|
858
|
+
let [c, u] = n;
|
|
859
|
+
u.length && (this.trackingEvents[c] = u);
|
|
860
|
+
}), function(n) {
|
|
861
|
+
return n.type === "linear";
|
|
862
|
+
}(this.creative) ? this._initLinearTracking() : this._initVariationTracking(), e && this.on("start", () => {
|
|
862
863
|
e.lastSuccessfulAd = Date.now();
|
|
863
864
|
});
|
|
864
865
|
}
|
|
@@ -882,8 +883,8 @@ class De extends J {
|
|
|
882
883
|
setProgress(e) {
|
|
883
884
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = !(arguments.length > 2 && arguments[2] !== void 0) || arguments[2];
|
|
884
885
|
if (!f.isValidTimeValue(e) || typeof t != "object") return void this.emit("TRACKER-error", { message: "One given setProgress parameter has the wrong type. progress: ".concat(e, ", macros: ").concat(f.formatMacrosValues(t)) });
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
886
|
+
const a = this.skipDelay || -1;
|
|
887
|
+
if (a === -1 || this.skippable || (a > e ? this.emit("skip-countdown", a - e) : (this.skippable = !0, this.emit("skip-countdown", 0))), this.assetDuration > 0) {
|
|
887
888
|
const s = Math.round(e / this.assetDuration * 100), o = [];
|
|
888
889
|
if (e > 0) {
|
|
889
890
|
o.push("start");
|
|
@@ -899,8 +900,8 @@ class De extends J {
|
|
|
899
900
|
this.progress = e;
|
|
900
901
|
}
|
|
901
902
|
isQuartileReached(e, t, r) {
|
|
902
|
-
let
|
|
903
|
-
return t <= r && !this._alreadyTriggeredQuartiles[e] && (
|
|
903
|
+
let a = !1;
|
|
904
|
+
return t <= r && !this._alreadyTriggeredQuartiles[e] && (a = !0), a;
|
|
904
905
|
}
|
|
905
906
|
setMuted(e) {
|
|
906
907
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
@@ -926,22 +927,16 @@ class De extends J {
|
|
|
926
927
|
typeof e == "object" ? this.impressed || (this.impressed = !0, this.trackURLs(this.ad.impressionURLTemplates, e), this.track("creativeView", { macros: e })) : this.emit("TRACKER-error", { message: "trackImpression parameter has the wrong type. macros: ".concat(e) });
|
|
927
928
|
}
|
|
928
929
|
trackViewableImpression() {
|
|
929
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
930
|
-
typeof e == "object" ? this.
|
|
931
|
-
this.trackURLs(t.viewable, e);
|
|
932
|
-
}) : this.emit("TRACKER-error", { message: "trackViewableImpression given macros has the wrong type. macros: ".concat(e) });
|
|
930
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
931
|
+
typeof e == "object" ? this.track("viewable", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackViewableImpression given macros has the wrong type. macros: ".concat(e) });
|
|
933
932
|
}
|
|
934
933
|
trackNotViewableImpression() {
|
|
935
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
936
|
-
typeof e == "object" ? this.
|
|
937
|
-
this.trackURLs(t.notViewable, e);
|
|
938
|
-
}) : this.emit("TRACKER-error", { message: "trackNotViewableImpression given macros has the wrong type. macros: ".concat(e) });
|
|
934
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
935
|
+
typeof e == "object" ? this.track("notViewable", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackNotViewableImpression given macros has the wrong type. macros: ".concat(e) });
|
|
939
936
|
}
|
|
940
937
|
trackUndeterminedImpression() {
|
|
941
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
942
|
-
typeof e == "object" ? this.
|
|
943
|
-
this.trackURLs(t.viewUndetermined, e);
|
|
944
|
-
}) : this.emit("TRACKER-error", { message: "trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e) });
|
|
938
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
939
|
+
typeof e == "object" ? this.track("viewUndetermined", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e) });
|
|
945
940
|
}
|
|
946
941
|
error() {
|
|
947
942
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
@@ -986,9 +981,9 @@ class De extends J {
|
|
|
986
981
|
if (!e) throw new Error("No vendor provided, unable to find associated verificationNotExecuted");
|
|
987
982
|
const r = this.ad.adVerifications.find((s) => s.vendor === e);
|
|
988
983
|
if (!r) throw new Error("No associated verification element found for vendor: ".concat(e));
|
|
989
|
-
const
|
|
990
|
-
if (
|
|
991
|
-
const s =
|
|
984
|
+
const a = r.trackingEvents;
|
|
985
|
+
if (a && a.verificationNotExecuted) {
|
|
986
|
+
const s = a.verificationNotExecuted;
|
|
992
987
|
this.trackURLs(s, t), this.emit("verificationNotExecuted", { trackingURLTemplates: s });
|
|
993
988
|
}
|
|
994
989
|
}
|
|
@@ -1012,15 +1007,15 @@ class De extends J {
|
|
|
1012
1007
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1013
1008
|
if (e !== null && typeof e != "string" || typeof t != "object") return void this.emit("TRACKER-error", { message: "One given click parameter has the wrong type. fallbackClickThroughURL: ".concat(e, ", macros: ").concat(f.formatMacrosValues(t)) });
|
|
1014
1009
|
this.clickTrackingURLTemplates && this.clickTrackingURLTemplates.length && this.trackURLs(this.clickTrackingURLTemplates, t);
|
|
1015
|
-
const r = this.clickThroughURLTemplate || e,
|
|
1010
|
+
const r = this.clickThroughURLTemplate || e, a = { ...t };
|
|
1016
1011
|
if (r) {
|
|
1017
|
-
this.progress && (
|
|
1018
|
-
const s = f.resolveURLTemplates([r],
|
|
1012
|
+
this.progress && (a.ADPLAYHEAD = this.progressFormatted());
|
|
1013
|
+
const s = f.resolveURLTemplates([r], a)[0];
|
|
1019
1014
|
this.emit("clickthrough", s);
|
|
1020
1015
|
}
|
|
1021
1016
|
}
|
|
1022
1017
|
trackProgressEvents(e, t, r) {
|
|
1023
|
-
const
|
|
1018
|
+
const a = parseFloat(e.split("-")[1]);
|
|
1024
1019
|
Object.entries(this.trackingEvents).filter((s) => {
|
|
1025
1020
|
let [o] = s;
|
|
1026
1021
|
return o.startsWith("progress-");
|
|
@@ -1029,7 +1024,7 @@ class De extends J {
|
|
|
1029
1024
|
return { name: o, time: parseFloat(o.split("-")[1]), urls: n };
|
|
1030
1025
|
}).filter((s) => {
|
|
1031
1026
|
let { time: o } = s;
|
|
1032
|
-
return o <=
|
|
1027
|
+
return o <= a && o > this.progress;
|
|
1033
1028
|
}).forEach((s) => {
|
|
1034
1029
|
let { name: o, urls: n } = s;
|
|
1035
1030
|
!r && this.trackedProgressEvents.includes(o) || (this.emit(o, { trackingURLTemplates: n }), this.trackURLs(n, t), r ? delete this.trackingEvents[o] : this.trackedProgressEvents.push(o));
|
|
@@ -1039,258 +1034,27 @@ class De extends J {
|
|
|
1039
1034
|
let { macros: t = {}, once: r = !1 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1040
1035
|
if (typeof t != "object") return void this.emit("TRACKER-error", { message: "track given macros has the wrong type. macros: ".concat(t) });
|
|
1041
1036
|
e === "closeLinear" && !this.trackingEvents[e] && this.trackingEvents.close && (e = "close"), e.startsWith("progress-") && !e.endsWith("%") && this.trackProgressEvents(e, t, r);
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1037
|
+
const a = this.trackingEvents[e], s = this.emitAlwaysEvents.indexOf(e) > -1;
|
|
1038
|
+
a ? (this.emit(e, { trackingURLTemplates: a }), this.trackURLs(a, t)) : s && this.emit(e, null), r && (delete this.trackingEvents[e], s && this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e), 1));
|
|
1044
1039
|
}
|
|
1045
1040
|
trackURLs(e) {
|
|
1046
1041
|
var t;
|
|
1047
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {},
|
|
1042
|
+
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1048
1043
|
const { validUrls: s, invalidUrls: o } = f.filterUrlTemplates(e);
|
|
1049
1044
|
o.length && this.emit("TRACKER-error", { message: "Provided urls are malformed. url: ".concat(o) });
|
|
1050
1045
|
const n = { ...r };
|
|
1051
|
-
this.linear && (this.creative && this.creative.mediaFiles && this.creative.mediaFiles[0] && this.creative.mediaFiles[0].fileURL && (n.ASSETURI = this.creative.mediaFiles[0].fileURL), this.progress && (n.ADPLAYHEAD = this.progressFormatted())), (t = this.creative) !== null && t !== void 0 && (t = t.universalAdIds) !== null && t !== void 0 && t.length && (n.UNIVERSALADID = this.creative.universalAdIds.map((c) => c.idRegistry.concat(" ", c.value)).join(",")), this.ad && (this.ad.sequence && (n.PODSEQUENCE = this.ad.sequence), this.ad.adType && (n.ADTYPE = this.ad.adType), this.ad.adServingId && (n.ADSERVINGID = this.ad.adServingId), this.ad.categories && this.ad.categories.length && (n.ADCATEGORIES = this.ad.categories.map((c) => c.value).join(",")), this.ad.blockedAdCategories && this.ad.blockedAdCategories.length && (n.BLOCKEDADCATEGORIES = this.ad.blockedAdCategories.map((c) => c.value).join(","))), f.track(s, n,
|
|
1046
|
+
this.linear && (this.creative && this.creative.mediaFiles && this.creative.mediaFiles[0] && this.creative.mediaFiles[0].fileURL && (n.ASSETURI = this.creative.mediaFiles[0].fileURL), this.progress && (n.ADPLAYHEAD = this.progressFormatted())), (t = this.creative) !== null && t !== void 0 && (t = t.universalAdIds) !== null && t !== void 0 && t.length && (n.UNIVERSALADID = this.creative.universalAdIds.map((c) => c.idRegistry.concat(" ", c.value)).join(",")), this.ad && (this.ad.sequence && (n.PODSEQUENCE = this.ad.sequence), this.ad.adType && (n.ADTYPE = this.ad.adType), this.ad.adServingId && (n.ADSERVINGID = this.ad.adServingId), this.ad.categories && this.ad.categories.length && (n.ADCATEGORIES = this.ad.categories.map((c) => c.value).join(",")), this.ad.blockedAdCategories && this.ad.blockedAdCategories.length && (n.BLOCKEDADCATEGORIES = this.ad.blockedAdCategories.map((c) => c.value).join(","))), f.track(s, n, a);
|
|
1052
1047
|
}
|
|
1053
1048
|
convertToTimecode(e) {
|
|
1054
1049
|
if (!f.isValidTimeValue(e)) return "";
|
|
1055
|
-
const t = 1e3 * e, r = Math.floor(t / 36e5),
|
|
1056
|
-
return "".concat(f.addLeadingZeros(r, 2), ":").concat(f.addLeadingZeros(
|
|
1050
|
+
const t = 1e3 * e, r = Math.floor(t / 36e5), a = Math.floor(t / 6e4 % 60), s = Math.floor(t / 1e3 % 60), o = Math.floor(t % 1e3);
|
|
1051
|
+
return "".concat(f.addLeadingZeros(r, 2), ":").concat(f.addLeadingZeros(a, 2), ":").concat(f.addLeadingZeros(s, 2), ".").concat(f.addLeadingZeros(o, 3));
|
|
1057
1052
|
}
|
|
1058
1053
|
progressFormatted() {
|
|
1059
1054
|
return this.convertToTimecode(this.progress);
|
|
1060
1055
|
}
|
|
1061
1056
|
}
|
|
1062
|
-
class ye {
|
|
1063
|
-
constructor(e) {
|
|
1064
|
-
this.id = e.getAttribute("id"), this.allowMultipleAds = e.getAttribute("allowMultipleAds"), this.followRedirects = e.getAttribute("followRedirects"), this.vastAdData = null, this.adTagURI = null, this.customData = null;
|
|
1065
|
-
for (const t in e.childNodes) {
|
|
1066
|
-
const r = e.childNodes[t];
|
|
1067
|
-
switch (r.localName) {
|
|
1068
|
-
case "AdTagURI":
|
|
1069
|
-
this.adTagURI = {
|
|
1070
|
-
templateType: r.getAttribute("templateType"),
|
|
1071
|
-
uri: (r.textContent || r.text || "").trim()
|
|
1072
|
-
};
|
|
1073
|
-
break;
|
|
1074
|
-
case "VASTAdData":
|
|
1075
|
-
for (this.vastAdData = r.firstChild; this.vastAdData && this.vastAdData.nodeType !== 1; )
|
|
1076
|
-
this.vastAdData = this.vastAdData.nextSibling;
|
|
1077
|
-
break;
|
|
1078
|
-
case "CustomAdData":
|
|
1079
|
-
this.customData = r;
|
|
1080
|
-
break;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
function ee(a, e) {
|
|
1086
|
-
const t = [];
|
|
1087
|
-
for (const r in a.childNodes) {
|
|
1088
|
-
const i = a.childNodes[r];
|
|
1089
|
-
(i.nodeName === e || e === `vmap:${i.nodeName}` || i.nodeName === `vmap:${e}`) && t.push(i);
|
|
1090
|
-
}
|
|
1091
|
-
return t;
|
|
1092
|
-
}
|
|
1093
|
-
function Ee(a) {
|
|
1094
|
-
if (!a || !a.childNodes)
|
|
1095
|
-
return {};
|
|
1096
|
-
const e = a.childNodes, t = [];
|
|
1097
|
-
for (const i in e) {
|
|
1098
|
-
const s = e[i];
|
|
1099
|
-
s.nodeName === "#cdata-section" && t.push(s);
|
|
1100
|
-
}
|
|
1101
|
-
if (t && t.length > 0)
|
|
1102
|
-
try {
|
|
1103
|
-
return JSON.parse(t[0].data);
|
|
1104
|
-
} catch {
|
|
1105
|
-
}
|
|
1106
|
-
let r = "";
|
|
1107
|
-
for (const i in e) {
|
|
1108
|
-
const s = e[i];
|
|
1109
|
-
switch (s.nodeName) {
|
|
1110
|
-
case "#text":
|
|
1111
|
-
r += s.textContent.trim();
|
|
1112
|
-
break;
|
|
1113
|
-
case "#cdata-section":
|
|
1114
|
-
r += s.data;
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
return r;
|
|
1119
|
-
}
|
|
1120
|
-
function C(a) {
|
|
1121
|
-
const e = {
|
|
1122
|
-
attributes: {},
|
|
1123
|
-
children: {},
|
|
1124
|
-
value: {}
|
|
1125
|
-
};
|
|
1126
|
-
e.value = Ee(a);
|
|
1127
|
-
const t = a.attributes;
|
|
1128
|
-
if (t)
|
|
1129
|
-
for (const i in t) {
|
|
1130
|
-
const s = t[i];
|
|
1131
|
-
s.nodeName && s.nodeValue !== void 0 && s.nodeValue !== null && (e.attributes[s.nodeName] = s.nodeValue);
|
|
1132
|
-
}
|
|
1133
|
-
const r = a.childNodes;
|
|
1134
|
-
if (r)
|
|
1135
|
-
for (const i in r) {
|
|
1136
|
-
const s = r[i];
|
|
1137
|
-
s.nodeName && s.nodeName.substring(0, 1) !== "#" && (e.children[s.nodeName] = C(s));
|
|
1138
|
-
}
|
|
1139
|
-
return e;
|
|
1140
|
-
}
|
|
1141
|
-
class be {
|
|
1142
|
-
constructor(e) {
|
|
1143
|
-
this.timeOffset = e.getAttribute("timeOffset"), this.breakType = e.getAttribute("breakType"), this.breakId = e.getAttribute("breakId"), this.repeatAfter = e.getAttribute("repeatAfter"), this.adSource = null, this.trackingEvents = [], this.extensions = [];
|
|
1144
|
-
for (const t in e.childNodes) {
|
|
1145
|
-
const r = e.childNodes[t];
|
|
1146
|
-
switch (r.localName) {
|
|
1147
|
-
case "AdSource":
|
|
1148
|
-
this.adSource = new ye(r);
|
|
1149
|
-
break;
|
|
1150
|
-
case "TrackingEvents":
|
|
1151
|
-
for (const i in r.childNodes) {
|
|
1152
|
-
const s = r.childNodes[i];
|
|
1153
|
-
s.localName === "Tracking" && this.trackingEvents.push({
|
|
1154
|
-
event: s.getAttribute("event"),
|
|
1155
|
-
uri: (s.textContent || s.text || "").trim()
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
break;
|
|
1159
|
-
case "Extensions":
|
|
1160
|
-
this.extensions = ee(r, "Extension").map(
|
|
1161
|
-
(i) => C(i)
|
|
1162
|
-
);
|
|
1163
|
-
break;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
track(e, t) {
|
|
1168
|
-
for (const r in this.trackingEvents) {
|
|
1169
|
-
const i = this.trackingEvents[r];
|
|
1170
|
-
if (i.event === e) {
|
|
1171
|
-
let { uri: s } = i;
|
|
1172
|
-
i.event === "error" && (s = s.replace("[ERRORCODE]", t)), this.tracker(s);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
// Easy to overwrite tracker client for unit testing
|
|
1177
|
-
tracker(e) {
|
|
1178
|
-
if (typeof window < "u" && window !== null) {
|
|
1179
|
-
const t = new Image();
|
|
1180
|
-
t.src = e;
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
class Ne {
|
|
1185
|
-
constructor(e) {
|
|
1186
|
-
if (!e || !e.documentElement || e.documentElement.localName !== "VMAP")
|
|
1187
|
-
throw new Error("Not a VMAP document");
|
|
1188
|
-
this.version = e.documentElement.getAttribute("version"), this.adBreaks = [], this.extensions = [];
|
|
1189
|
-
for (const t in e.documentElement.childNodes) {
|
|
1190
|
-
const r = e.documentElement.childNodes[t];
|
|
1191
|
-
switch (r.localName) {
|
|
1192
|
-
case "AdBreak":
|
|
1193
|
-
this.adBreaks.push(new be(r));
|
|
1194
|
-
break;
|
|
1195
|
-
case "Extensions":
|
|
1196
|
-
this.extensions = ee(r, "Extension").map(
|
|
1197
|
-
(i) => C(i)
|
|
1198
|
-
);
|
|
1199
|
-
break;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
const we = (a, e) => {
|
|
1205
|
-
const t = goog.pal, r = new t.ConsentSettings();
|
|
1206
|
-
r.allowStorage = !1;
|
|
1207
|
-
const i = new t.NonceLoader(r);
|
|
1208
|
-
return async () => {
|
|
1209
|
-
try {
|
|
1210
|
-
const o = new URL(e), n = new t.NonceRequest();
|
|
1211
|
-
let c = localStorage.getItem("sl-device-id") || x(), u = sessionStorage.getItem("sl-ad-session-id");
|
|
1212
|
-
u || (u = x(), sessionStorage.setItem("sl-ad-session-id", u)), ae(c) || (c = S(`https://${c}`, S.URL)), o.searchParams.get("url") || o.searchParams.set("url", "https://streamlayer.io"), o.searchParams.get("description_url") || o.searchParams.set("description_url", "https://streamlayer.io"), n.adWillAutoPlay = o.searchParams.get("vpa") === "auto", n.adWillPlayMuted = o.searchParams.get("vpmute") === "1", n.continuousPlayback = !0, n.descriptionUrl = o.searchParams.get("description_url"), n.iconsSupported = !0, n.sessionId = c, n.supportedApiFrameworks = "2,7,9", n.videoHeight = a.clientHeight, n.videoWidth = a.clientWidth;
|
|
1213
|
-
const d = await i.loadNonceManager(n);
|
|
1214
|
-
return o.searchParams.get("is_lat") === "[placeholder]" && o.searchParams.set("is_lat", "1"), o.searchParams.get("rdid") === "[placeholder]" && o.searchParams.set("rdid", c), o.searchParams.get("correlator") === "[placeholder]" && o.searchParams.set("correlator", u), o.searchParams.set("wta", "1"), o.searchParams.set("givn", d.getNonce()), {
|
|
1215
|
-
url: o,
|
|
1216
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1217
|
-
manager: d
|
|
1218
|
-
};
|
|
1219
|
-
} catch (o) {
|
|
1220
|
-
console.log("AdsManager could not be started", o);
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
|
-
};
|
|
1224
|
-
}, Le = new ke(), Ce = (a) => a.creatives.find((e) => e.mediaFiles), Ue = (a) => {
|
|
1225
|
-
var t;
|
|
1226
|
-
const e = a == null ? void 0 : a.mediaFiles;
|
|
1227
|
-
return e != null && e.length && ((t = e.find((r) => r.fileURL)) == null ? void 0 : t.fileURL) || "";
|
|
1228
|
-
}, k = ie({
|
|
1229
|
-
ads: [],
|
|
1230
|
-
autoplay: !0,
|
|
1231
|
-
muted: !1,
|
|
1232
|
-
nonceManager: void 0
|
|
1233
|
-
}), Ve = (a, e) => {
|
|
1234
|
-
const [t, r] = re(), i = U(Date.now()), s = U(Date.now());
|
|
1235
|
-
return I(() => {
|
|
1236
|
-
if (!e || !(a != null && a.current))
|
|
1237
|
-
return;
|
|
1238
|
-
const o = we(a.current, e), n = Date.now();
|
|
1239
|
-
i.current = n, k.set({
|
|
1240
|
-
...k.get(),
|
|
1241
|
-
nonceManager: void 0
|
|
1242
|
-
}), o().then((c) => {
|
|
1243
|
-
i.current === n && c && (r(c.url), k.set({
|
|
1244
|
-
...k.get(),
|
|
1245
|
-
nonceManager: c.manager
|
|
1246
|
-
}));
|
|
1247
|
-
}).catch((c) => {
|
|
1248
|
-
console.error(c);
|
|
1249
|
-
});
|
|
1250
|
-
}, [a, e]), I(() => {
|
|
1251
|
-
const o = async (n, c) => {
|
|
1252
|
-
let u = [];
|
|
1253
|
-
if (n.searchParams.get("output") === "vmap") {
|
|
1254
|
-
const h = await fetch(n.toString()), p = new DOMParser(), g = await h.text(), T = p.parseFromString(g, "text/xml");
|
|
1255
|
-
u = new Ne(T).adBreaks.map((b) => b.adSource.adTagURI.uri);
|
|
1256
|
-
} else
|
|
1257
|
-
u = [n.toString()];
|
|
1258
|
-
const d = await Promise.all(
|
|
1259
|
-
u.map((h, p) => Le.get(h).then((g) => {
|
|
1260
|
-
if (s.current === c) {
|
|
1261
|
-
const T = g.ads.find((te) => te.creatives.length > 0);
|
|
1262
|
-
if (!T)
|
|
1263
|
-
return;
|
|
1264
|
-
const A = Ce(T), b = Ue(A);
|
|
1265
|
-
return {
|
|
1266
|
-
creative: A,
|
|
1267
|
-
order: p,
|
|
1268
|
-
mediaFileUrl: b,
|
|
1269
|
-
ad: T,
|
|
1270
|
-
raw: g
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
}))
|
|
1274
|
-
), v = n.searchParams.get("vpa") !== "click", m = n.searchParams.get("vpmute") === "1";
|
|
1275
|
-
k.set({
|
|
1276
|
-
...k.get(),
|
|
1277
|
-
ads: d.filter((h) => !!h),
|
|
1278
|
-
autoplay: v,
|
|
1279
|
-
muted: m
|
|
1280
|
-
});
|
|
1281
|
-
};
|
|
1282
|
-
if (t) {
|
|
1283
|
-
const n = Date.now();
|
|
1284
|
-
s.current = n, o(t, n);
|
|
1285
|
-
}
|
|
1286
|
-
return () => {
|
|
1287
|
-
s.current = 0;
|
|
1288
|
-
};
|
|
1289
|
-
}, [t]), k;
|
|
1290
|
-
};
|
|
1291
1057
|
export {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
Ve as u,
|
|
1295
|
-
De as z
|
|
1058
|
+
ce as _,
|
|
1059
|
+
ue as z
|
|
1296
1060
|
};
|