adgent-sdk 0.1.6 → 0.1.8
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/LICENSE +21 -0
- package/dist/adgent-sdk.es.js +88 -13
- package/dist/adgent-sdk.umd.js +2 -2
- package/dist/index.d.ts +16 -0
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asadbek Omonboyev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/adgent-sdk.es.js
CHANGED
|
@@ -754,10 +754,14 @@ var VASTParser = /* @__PURE__ */ function() {
|
|
|
754
754
|
value: function selectBestMediaFile(mediaFiles) {
|
|
755
755
|
var targetBitrate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2500;
|
|
756
756
|
if (mediaFiles.length === 0) return null;
|
|
757
|
-
var
|
|
757
|
+
var validFiles = mediaFiles.filter(function(mf) {
|
|
758
|
+
return mf.type.toLowerCase().startsWith("video/");
|
|
759
|
+
});
|
|
760
|
+
if (validFiles.length === 0) return null;
|
|
761
|
+
var mp4Files = validFiles.filter(function(mf) {
|
|
758
762
|
return mf.type.includes("mp4") || mf.type.includes("video/mp4");
|
|
759
763
|
});
|
|
760
|
-
var candidates = mp4Files.length > 0 ? mp4Files :
|
|
764
|
+
var candidates = mp4Files.length > 0 ? mp4Files : validFiles;
|
|
761
765
|
var sorted = _toConsumableArray(candidates).sort(function(a, b) {
|
|
762
766
|
var aBitrate = a.bitrate || 0;
|
|
763
767
|
var bBitrate = b.bitrate || 0;
|
|
@@ -1481,6 +1485,29 @@ var PlatformAdapter = /* @__PURE__ */ function() {
|
|
|
1481
1485
|
};
|
|
1482
1486
|
}
|
|
1483
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Open an external link in a new tab/window
|
|
1490
|
+
* Safe to call on all platforms (will just log on non-web)
|
|
1491
|
+
*/
|
|
1492
|
+
}, {
|
|
1493
|
+
key: "openExternalLink",
|
|
1494
|
+
value: function openExternalLink(url) {
|
|
1495
|
+
if (typeof window === "undefined") {
|
|
1496
|
+
this.debug("[Adgent] Cannot open link (server-side): ".concat(url));
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
if (this.platform !== Platform.Generic && this.platform !== Platform.Tizen && this.platform !== Platform.WebOS) {
|
|
1500
|
+
this.debug("[Adgent] Opening external links not supported on ".concat(this.platform, ": ").concat(url));
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
try {
|
|
1504
|
+
var win = window;
|
|
1505
|
+
win.open(url, "_blank");
|
|
1506
|
+
this.debug("[Adgent] Opened external link: ".concat(url));
|
|
1507
|
+
} catch (error) {
|
|
1508
|
+
this.debug("[Adgent] Failed to open external link: ".concat(error));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1484
1511
|
/**
|
|
1485
1512
|
* Show debug message using platform-specific native notifications
|
|
1486
1513
|
* Falls back to console.log
|
|
@@ -1812,6 +1839,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
1812
1839
|
__publicField4(this, "quartilesFired", /* @__PURE__ */ new Set());
|
|
1813
1840
|
__publicField4(this, "boundKeyHandler", null);
|
|
1814
1841
|
__publicField4(this, "focusTrap", null);
|
|
1842
|
+
__publicField4(this, "hasStarted", false);
|
|
1815
1843
|
this.config = __spreadValues4(__spreadValues4({}, DEFAULT_CONFIG), config);
|
|
1816
1844
|
this.platform = getPlatformAdapter();
|
|
1817
1845
|
this.parser = new VASTParser({
|
|
@@ -2022,6 +2050,10 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2022
2050
|
this.eventListeners.set("play", onPlay);
|
|
2023
2051
|
}
|
|
2024
2052
|
this.log("Video element created with src: ".concat(mediaFile.url));
|
|
2053
|
+
video.addEventListener("click", function() {
|
|
2054
|
+
_this.onAdClick();
|
|
2055
|
+
});
|
|
2056
|
+
video.style.cursor = "pointer";
|
|
2025
2057
|
}
|
|
2026
2058
|
/**
|
|
2027
2059
|
* Attempt autoplay with soft-fail handling
|
|
@@ -2087,6 +2119,38 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2087
2119
|
this.overlayElement = overlay;
|
|
2088
2120
|
button == null ? void 0 : button.focus();
|
|
2089
2121
|
}
|
|
2122
|
+
/**
|
|
2123
|
+
* Handle ad click (video element click)
|
|
2124
|
+
*/
|
|
2125
|
+
}, {
|
|
2126
|
+
key: "onAdClick",
|
|
2127
|
+
value: function onAdClick() {
|
|
2128
|
+
var _this3 = this;
|
|
2129
|
+
var _a, _b, _c, _d, _e;
|
|
2130
|
+
if (this.state.status !== PlaybackStatus.Playing) return;
|
|
2131
|
+
var linear = this.getFirstLinearCreative();
|
|
2132
|
+
if (!linear) return;
|
|
2133
|
+
var clickThrough = (_a = linear.videoClicks) == null ? void 0 : _a.clickThrough;
|
|
2134
|
+
var url = clickThrough == null ? void 0 : clickThrough.url;
|
|
2135
|
+
if (url) {
|
|
2136
|
+
this.log("Ad clicked. Opening: ".concat(url));
|
|
2137
|
+
(_b = this.videoElement) == null ? void 0 : _b.pause();
|
|
2138
|
+
this.showStartOverlay();
|
|
2139
|
+
var clickTracking = ((_c = linear.videoClicks) == null ? void 0 : _c.clickTracking) || [];
|
|
2140
|
+
clickTracking.forEach(function(tracking) {
|
|
2141
|
+
var _a2;
|
|
2142
|
+
if (tracking.url) (_a2 = _this3.tracker) == null ? void 0 : _a2.firePixel(tracking.url);
|
|
2143
|
+
});
|
|
2144
|
+
this.platform.openExternalLink(url);
|
|
2145
|
+
this.emit({
|
|
2146
|
+
type: "click",
|
|
2147
|
+
data: {
|
|
2148
|
+
url
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2151
|
+
(_e = (_d = this.config).onClick) == null ? void 0 : _e.call(_d, url);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2090
2154
|
/**
|
|
2091
2155
|
* Handle start button click (from overlay)
|
|
2092
2156
|
*/
|
|
@@ -2094,7 +2158,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2094
2158
|
key: "onStartClick",
|
|
2095
2159
|
value: function onStartClick() {
|
|
2096
2160
|
return __async2(this, null, /* @__PURE__ */ _regenerator().m(function _callee3() {
|
|
2097
|
-
var _t3;
|
|
2161
|
+
var _a, _t3;
|
|
2098
2162
|
return _regenerator().w(function(_context3) {
|
|
2099
2163
|
while (1) switch (_context3.p = _context3.n) {
|
|
2100
2164
|
case 0:
|
|
@@ -2107,7 +2171,17 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2107
2171
|
_context3.n = 2;
|
|
2108
2172
|
return this.videoElement.play();
|
|
2109
2173
|
case 2:
|
|
2110
|
-
this.
|
|
2174
|
+
if (this.hasStarted) {
|
|
2175
|
+
this.updateState({
|
|
2176
|
+
status: PlaybackStatus.Playing
|
|
2177
|
+
});
|
|
2178
|
+
this.emit({
|
|
2179
|
+
type: "resume"
|
|
2180
|
+
});
|
|
2181
|
+
(_a = this.tracker) == null ? void 0 : _a.track("resume");
|
|
2182
|
+
} else {
|
|
2183
|
+
this.handlePlaybackStart();
|
|
2184
|
+
}
|
|
2111
2185
|
_context3.n = 4;
|
|
2112
2186
|
break;
|
|
2113
2187
|
case 3:
|
|
@@ -2138,6 +2212,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2138
2212
|
key: "handlePlaybackStart",
|
|
2139
2213
|
value: function handlePlaybackStart() {
|
|
2140
2214
|
var _a, _b, _c, _d, _e;
|
|
2215
|
+
this.hasStarted = true;
|
|
2141
2216
|
this.updateState({
|
|
2142
2217
|
status: PlaybackStatus.Playing
|
|
2143
2218
|
});
|
|
@@ -2237,7 +2312,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2237
2312
|
}, {
|
|
2238
2313
|
key: "setupSkipButton",
|
|
2239
2314
|
value: function setupSkipButton() {
|
|
2240
|
-
var
|
|
2315
|
+
var _this4 = this;
|
|
2241
2316
|
var _a;
|
|
2242
2317
|
var linear = this.getFirstLinearCreative();
|
|
2243
2318
|
var skipOffset = (_a = this.config.skipOffset) != null ? _a : linear == null ? void 0 : linear.skipOffset;
|
|
@@ -2253,7 +2328,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2253
2328
|
skipBtn.style.cssText = "\n position: absolute;\n bottom: 20px;\n right: 20px;\n padding: 12px 24px;\n font-size: 16px;\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n border: 2px solid #fff;\n border-radius: 4px;\n cursor: pointer;\n z-index: 101;\n transition: opacity 0.3s;\n ";
|
|
2254
2329
|
skipBtn.textContent = "Skip in ".concat(skipOffset, "s");
|
|
2255
2330
|
skipBtn.addEventListener("click", function() {
|
|
2256
|
-
return
|
|
2331
|
+
return _this4.skip();
|
|
2257
2332
|
});
|
|
2258
2333
|
this.config.container.appendChild(skipBtn);
|
|
2259
2334
|
this.skipButtonElement = skipBtn;
|
|
@@ -2357,18 +2432,18 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2357
2432
|
}, {
|
|
2358
2433
|
key: "setupFocusManagement",
|
|
2359
2434
|
value: function setupFocusManagement() {
|
|
2360
|
-
var
|
|
2435
|
+
var _this5 = this;
|
|
2361
2436
|
this.focusTrap = document.createElement("div");
|
|
2362
2437
|
this.focusTrap.tabIndex = 0;
|
|
2363
2438
|
this.focusTrap.style.cssText = "position: absolute; opacity: 0; width: 0; height: 0;";
|
|
2364
2439
|
this.config.container.appendChild(this.focusTrap);
|
|
2365
2440
|
this.focusTrap.focus();
|
|
2366
2441
|
this.boundKeyHandler = function(e) {
|
|
2367
|
-
var action =
|
|
2442
|
+
var action = _this5.platform.normalizeKeyCode(e.keyCode);
|
|
2368
2443
|
if (action) {
|
|
2369
2444
|
e.preventDefault();
|
|
2370
2445
|
e.stopPropagation();
|
|
2371
|
-
|
|
2446
|
+
_this5.handleKeyAction(action);
|
|
2372
2447
|
}
|
|
2373
2448
|
};
|
|
2374
2449
|
document.addEventListener("keydown", this.boundKeyHandler, true);
|
|
@@ -2487,10 +2562,10 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2487
2562
|
}, {
|
|
2488
2563
|
key: "on",
|
|
2489
2564
|
value: function on(listener) {
|
|
2490
|
-
var
|
|
2565
|
+
var _this6 = this;
|
|
2491
2566
|
this.listeners.add(listener);
|
|
2492
2567
|
return function() {
|
|
2493
|
-
return
|
|
2568
|
+
return _this6.listeners["delete"](listener);
|
|
2494
2569
|
};
|
|
2495
2570
|
}
|
|
2496
2571
|
/**
|
|
@@ -2507,7 +2582,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2507
2582
|
}, {
|
|
2508
2583
|
key: "destroy",
|
|
2509
2584
|
value: function destroy() {
|
|
2510
|
-
var
|
|
2585
|
+
var _this7 = this;
|
|
2511
2586
|
var _a, _b, _c, _d, _e;
|
|
2512
2587
|
if (this.boundKeyHandler) {
|
|
2513
2588
|
document.removeEventListener("keydown", this.boundKeyHandler, true);
|
|
@@ -2516,7 +2591,7 @@ var AdPlayer = /* @__PURE__ */ function() {
|
|
|
2516
2591
|
if (this.videoElement) {
|
|
2517
2592
|
this.eventListeners.forEach(function(listener, event) {
|
|
2518
2593
|
var _a2;
|
|
2519
|
-
(_a2 =
|
|
2594
|
+
(_a2 = _this7.videoElement) == null ? void 0 : _a2.removeEventListener(event, listener);
|
|
2520
2595
|
});
|
|
2521
2596
|
this.eventListeners.clear();
|
|
2522
2597
|
this.videoElement.remove();
|
package/dist/adgent-sdk.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fast-xml-parser")):"function"==typeof define&&define.amd?define(["exports","fast-xml-parser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AdgentSDK={},e.FastXMLParser)}(this,function(e,t){"use strict";function
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fast-xml-parser")):"function"==typeof define&&define.amd?define(["exports","fast-xml-parser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AdgentSDK={},e.FastXMLParser)}(this,function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function o(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return l(c,"_invoke",function(r,n,i){var a,s,l,u=0,c=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return a=t,s=0,l=e,f.n=r,o}};function p(r,n){for(s=r,l=n,t=0;!d&&u&&!i&&t<c.length;t++){var i,a=c[t],p=f.p,h=a[2];r>3?(i=h===n)&&(l=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=r<2&&p<a[1])?(s=0,f.v=n,f.n=a[1]):p<h&&(i=r<3||a[0]>n||n>h)&&(a[4]=r,a[5]=n,f.n=h,s=0))}if(i||r>1)return o;throw d=!0,n}return function(i,c,h){if(u>1)throw TypeError("Generator is already running");for(d&&1===c&&p(c,h),s=c,l=h;(t=s<2?e:l)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,l)):f.n=l:f.v=l);try{if(u=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(d=f.n<0)?l:r.call(n,f))!==o)break}catch(v){a=e,s=1,l=v}finally{u=1}}return{value:t,done:d}}}(r,i,a),!0),c}var o={};function u(){}function c(){}function d(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(l(t={},n,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,i,"GeneratorFunction")),e.prototype=Object.create(p),e}return c.prototype=d,l(p,"constructor",d),l(d,"constructor",c),c.displayName="GeneratorFunction",l(d,i,"GeneratorFunction"),l(p),l(p,i,"Generator"),l(p,n,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(s=function(){return{w:a,m:h}})()}function l(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(a){i=0}(l=function(e,t,r,n){function a(t,r){l(e,t,function(e){return this._invoke(t,r,e)})}t?i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))})(e,t,r,n)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}var h,v,y=function(e){return e.Idle="idle",e.Loading="loading",e.Ready="ready",e.Playing="playing",e.Paused="paused",e.Completed="completed",e.Error="error",e.WaitingForInteraction="waiting_for_interaction",e}(y||{}),m=function(e){return e[e.XML_PARSING_ERROR=100]="XML_PARSING_ERROR",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_VERSION_NOT_SUPPORTED=102]="VAST_VERSION_NOT_SUPPORTED",e[e.GENERAL_WRAPPER_ERROR=300]="GENERAL_WRAPPER_ERROR",e[e.WRAPPER_TIMEOUT=301]="WRAPPER_TIMEOUT",e[e.WRAPPER_LIMIT_REACHED=302]="WRAPPER_LIMIT_REACHED",e[e.NO_VAST_RESPONSE=303]="NO_VAST_RESPONSE",e[e.GENERAL_LINEAR_ERROR=400]="GENERAL_LINEAR_ERROR",e[e.FILE_NOT_FOUND=401]="FILE_NOT_FOUND",e[e.MEDIA_TIMEOUT=402]="MEDIA_TIMEOUT",e[e.MEDIA_NOT_SUPPORTED=403]="MEDIA_NOT_SUPPORTED",e[e.GENERAL_COMPANION_ERROR=600]="GENERAL_COMPANION_ERROR",e[e.UNDEFINED_ERROR=900]="UNDEFINED_ERROR",e}(m||{}),g=Object.defineProperty,b=Object.defineProperties,k=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,A=function(e,t,r){return t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},T=function(e,t){for(var r in t||(t={}))w.call(t,r)&&A(e,r,t[r]);if(E){var n,i=a(E(t));try{for(i.s();!(n=i.n()).done;){r=n.value;S.call(t,r)&&A(e,r,t[r])}}catch(o){i.e(o)}finally{i.f()}}return e},P=function(e,t){return b(e,k(t))},O=function(e,t,r){return A(e,"symbol"!==f(t)?t+"":t,r)},R=function(e,t,r){return new Promise(function(n,i){var a=function(e){try{s(r.next(e))}catch(t){i(t)}},o=function(e){try{s(r.throw(e))}catch(t){i(t)}},s=function(e){return e.done?n(e.value):Promise.resolve(e.value).then(a,o)};s((r=r.apply(e,t)).next())})},x=function(){return i(function e(){var r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e),O(this,"config"),O(this,"xmlParser"),this.config={maxWrapperDepth:null!=(r=s.maxWrapperDepth)?r:5,timeout:null!=(i=s.timeout)?i:1e4,debug:null!=(a=s.debug)&&a,fetchFn:null!=(o=s.fetchFn)?o:fetch.bind(globalThis)},this.xmlParser=new t.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseAttributeValue:!0,trimValues:!0})},[{key:"parse",value:function(e){return R(this,null,s().m(function t(){var r,n,i;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this.fetchAndParse(e,0);case 1:return r=t.v,t.a(2,{success:!0,response:r});case 2:return t.p=2,i=t.v,n=i instanceof Error?i.message:"Unknown error",t.a(2,{success:!1,error:{code:m.GENERAL_WRAPPER_ERROR,message:n}})}},t,this,[[0,2]])}))}},{key:"fetchAndParse",value:function(e,t){return R(this,null,s().m(function r(){var n,i,a,o=this;return s().w(function(r){for(;;)switch(r.n){case 0:if(!(t>=this.config.maxWrapperDepth)){r.n=1;break}throw new Error("Wrapper limit exceeded (max: ".concat(this.config.maxWrapperDepth,")"));case 1:return this.log("Fetching VAST (depth: ".concat(t,"): ").concat(e)),r.n=2,this.fetchWithTimeout(e);case 2:return n=r.v,i=this.parseXml(n),r.n=3,Promise.all(i.ads.map(function(e){return R(o,null,s().m(function r(){var n;return s().w(function(r){for(;;)switch(r.n){case 0:if(!(null==(n=e.wrapper)?void 0:n.vastAdTagURI)){r.n=1;break}return r.a(2,this.resolveWrapper(e,t+1));case 1:return r.a(2,e)}},r,this)}))}));case 3:return a=r.v,r.a(2,P(T({},i),{ads:a.flat()}))}},r,this)}))}},{key:"resolveWrapper",value:function(e,t){return R(this,null,s().m(function r(){var n,i,a,o=this;return s().w(function(r){for(;;)switch(r.p=r.n){case 0:if(null==(n=e.wrapper)?void 0:n.vastAdTagURI){r.n=1;break}return r.a(2,[e]);case 1:return r.p=1,r.n=2,this.fetchAndParse(e.wrapper.vastAdTagURI,t);case 2:return i=r.v,r.a(2,i.ads.map(function(t){return o.mergeWrapperTracking(e,t)}));case 3:if(r.p=3,a=r.v,this.log("Wrapper resolution failed: ".concat(a)),!e.wrapper.fallbackOnNoAd){r.n=4;break}return r.a(2,[]);case 4:throw a;case 5:return r.a(2)}},r,this,[[1,3]])}))}},{key:"mergeWrapperTracking",value:function(e,t){var r=this;return P(T({},t),{impressions:[].concat(c(e.impressions),c(t.impressions)),errors:[].concat(c(e.errors),c(t.errors)),creatives:t.creatives.map(function(t){return P(T({},t),{linear:t.linear?P(T({},t.linear),{trackingEvents:[].concat(c(r.getWrapperTrackingEvents(e)),c(t.linear.trackingEvents))}):void 0})})})}},{key:"getWrapperTrackingEvents",value:function(e){var t,r,n=[],i=a(e.creatives);try{for(i.s();!(r=i.n()).done;){var o=r.value;(null==(t=o.linear)?void 0:t.trackingEvents)&&n.push.apply(n,c(o.linear.trackingEvents))}}catch(s){i.e(s)}finally{i.f()}return n}},{key:"fetchWithTimeout",value:function(e){return R(this,null,s().m(function t(){var r,n,i;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return r=new AbortController,n=setTimeout(function(){return r.abort()},this.config.timeout),t.p=1,t.n=2,this.config.fetchFn(e,{signal:r.signal});case 2:if((i=t.v).ok){t.n=3;break}throw new Error("HTTP ".concat(i.status,": ").concat(i.statusText));case 3:return t.a(2,i.text());case 4:return t.p=4,clearTimeout(n),t.f(4);case 5:return t.a(2)}},t,this,[[1,,4,5]])}))}},{key:"parseXml",value:function(e){var t=this.xmlParser.parse(e).VAST;if(!t)throw new Error("Invalid VAST: missing VAST element");return{version:t["@_version"]||"4.0",ads:this.parseAds(t.Ad),errors:this.parseErrors(t.Error)}}},{key:"parseAds",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return t.parseAd(e)}):[]}},{key:"parseAd",value:function(e){var t,r,n,i=!!e.Wrapper,a=e.InLine||e.Wrapper;return{id:e["@_id"]||"",sequence:e["@_sequence"],adSystem:(null==a?void 0:a.AdSystem)?{name:"string"==typeof a.AdSystem?a.AdSystem:a.AdSystem["#text"]||"",version:null==(t=a.AdSystem)?void 0:t["@_version"]}:void 0,adTitle:null==a?void 0:a.AdTitle,impressions:this.parseImpressions(null==a?void 0:a.Impression),errors:this.parseErrors(null==a?void 0:a.Error),creatives:this.parseCreatives(null==(r=null==a?void 0:a.Creatives)?void 0:r.Creative),wrapper:i?{vastAdTagURI:a.VASTAdTagURI,followAdditionalWrappers:!1!==a["@_followAdditionalWrappers"],allowMultipleAds:a["@_allowMultipleAds"],fallbackOnNoAd:a["@_fallbackOnNoAd"]}:void 0,inLine:i?void 0:{adTitle:(null==a?void 0:a.AdTitle)||"",description:null==a?void 0:a.Description,advertiser:null==a?void 0:a.Advertiser,creatives:this.parseCreatives(null==(n=null==a?void 0:a.Creatives)?void 0:n.Creative)}}}},{key:"parseImpressions",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],url:"string"==typeof e?e:e["#text"]||""}}):[]}},{key:"parseCreatives",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],sequence:e["@_sequence"],adId:e["@_adId"],linear:e.Linear?t.parseLinear(e.Linear):void 0}}):[]}},{key:"parseLinear",value:function(e){var t,r;return{duration:this.parseDuration(e.Duration),skipOffset:e["@_skipoffset"]?this.parseDuration(e["@_skipoffset"]):void 0,mediaFiles:this.parseMediaFiles(null==(t=e.MediaFiles)?void 0:t.MediaFile),trackingEvents:this.parseTrackingEvents(null==(r=e.TrackingEvents)?void 0:r.Tracking),videoClicks:e.VideoClicks?{clickThrough:e.VideoClicks.ClickThrough?{id:e.VideoClicks.ClickThrough["@_id"],url:"string"==typeof e.VideoClicks.ClickThrough?e.VideoClicks.ClickThrough:e.VideoClicks.ClickThrough["#text"]||""}:void 0}:void 0,adParameters:e.AdParameters}}},{key:"parseMediaFiles",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],url:"string"==typeof e?e:e["#text"]||"",delivery:e["@_delivery"]||"progressive",type:e["@_type"]||"video/mp4",width:parseInt(e["@_width"],10)||0,height:parseInt(e["@_height"],10)||0,bitrate:e["@_bitrate"]?parseInt(e["@_bitrate"],10):void 0,codec:e["@_codec"],scalable:e["@_scalable"],maintainAspectRatio:e["@_maintainAspectRatio"]}}):[]}},{key:"parseTrackingEvents",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return{event:e["@_event"],url:"string"==typeof e?e:e["#text"]||"",offset:e["@_offset"]?t.parseDuration(e["@_offset"]):void 0}}):[]}},{key:"parseErrors",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return"string"==typeof e?e:e["#text"]||""}):[]}},{key:"parseDuration",value:function(e){if("number"==typeof e)return e;if("string"!=typeof e)return 0;if(e.endsWith("%"))return parseFloat(e)/100;var t=e.match(/(\d+):(\d+):(\d+(?:\.\d+)?)/);if(t){var r=u(t,4),n=r[1],i=r[2],a=r[3];return 3600*parseInt(n,10)+60*parseInt(i,10)+parseFloat(a)}return parseFloat(e)||0}},{key:"selectBestMediaFile",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500;if(0===e.length)return null;var r=e.filter(function(e){return e.type.includes("mp4")||e.type.includes("video/mp4")});return c(r.length>0?r:e).sort(function(e,r){var n=e.bitrate||0,i=r.bitrate||0,a=e.height>1080?1e4:0,o=r.height>1080?1e4:0;return Math.abs(n-t)+a-(Math.abs(i-t)+o)})[0]||null}},{key:"aggregateTrackingEvents",value:function(e){var t,r,n=[],i=a(e);try{for(i.s();!(r=i.n()).done;){var o,s=a(r.value.creatives);try{for(s.s();!(o=s.n()).done;){var l=o.value;(null==(t=l.linear)?void 0:t.trackingEvents)&&n.push.apply(n,c(l.linear.trackingEvents))}}catch(u){s.e(u)}finally{s.f()}}}catch(u){i.e(u)}finally{i.f()}return n}},{key:"aggregateImpressions",value:function(e){var t,r=[],n=a(e);try{for(n.s();!(t=n.n()).done;){var i,o=a(t.value.impressions);try{for(o.s();!(i=o.n()).done;){var s=i.value;r.push(s.url)}}catch(l){o.e(l)}finally{o.f()}}}catch(l){n.e(l)}finally{n.f()}return r}},{key:"log",value:function(e){this.config.debug&&console.log("[VASTParser] ".concat(e))}}])}();function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e;return r=(r=r.replace(/\[TIMESTAMP\]/g,Date.now().toString())).replace(/\[CACHEBUSTING\]/g,Math.random().toString(36).substring(2,15)),t.assetUri&&(r=r.replace(/\[ASSETURI\]/g,encodeURIComponent(t.assetUri))),void 0!==t.contentPlayhead&&(r=r.replace(/\[CONTENTPLAYHEAD\]/g,_(t.contentPlayhead))),void 0!==t.adPlayhead&&(r=r.replace(/\[ADPLAYHEAD\]/g,_(t.adPlayhead))),void 0!==t.errorCode&&(r=r.replace(/\[ERRORCODE\]/g,t.errorCode.toString())),void 0!==t.breakPosition&&(r=r.replace(/\[BREAKPOSITION\]/g,t.breakPosition.toString())),t.adType&&(r=r.replace(/\[ADTYPE\]/g,t.adType)),r}function _(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),i=Math.floor(e%1*1e3);return t.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+":"+n.toString().padStart(2,"0")+"."+i.toString().padStart(3,"0")}var I=function(e){return e.WebOS="webos",e.Tizen="tizen",e.Vidaa="vidaa",e.WhaleOS="whaleos",e.FireTV="firetv",e.Roku="roku",e.Xbox="xbox",e.PlayStation="playstation",e.AndroidTV="androidtv",e.Vizio="vizio",e.Generic="generic",e}(I||{}),M=function(e){return e.Enter="enter",e.Back="back",e.Left="left",e.Right="right",e.Up="up",e.Down="down",e.Play="play",e.Pause="pause",e.PlayPause="playPause",e.Stop="stop",e.FastForward="fastForward",e.Rewind="rewind",e.Menu="menu",e.Info="info",e.Red="red",e.Green="green",e.Yellow="yellow",e.Blue="blue",e.ChannelUp="channelUp",e.ChannelDown="channelDown",e.VolumeUp="volumeUp",e.VolumeDown="volumeDown",e.Mute="mute",e}(M||{}),F=(o(o(o(o(o(o(o(o(o(o(h={},"webos",{13:"enter",461:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop",417:"fastForward",412:"rewind",457:"info",403:"red",404:"green",405:"yellow",406:"blue",33:"channelUp",34:"channelDown"}),"tizen",{13:"enter",10009:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",10252:"playPause",413:"stop",417:"fastForward",412:"rewind",457:"info",403:"red",404:"green",405:"yellow",406:"blue",427:"channelUp",428:"channelDown",447:"volumeUp",448:"volumeDown",449:"mute"}),"vidaa",{13:"enter",8:"back",27:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop",417:"fastForward",412:"rewind"}),"whaleos",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop"}),"firetv",{13:"enter",4:"back",27:"back",37:"left",38:"up",39:"right",40:"down",85:"playPause",126:"play",127:"pause",89:"rewind",90:"fastForward",82:"menu"}),"roku",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",179:"playPause",178:"stop",228:"fastForward",227:"rewind"}),"xbox",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down",195:"menu",196:"menu"}),"playstation",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down"}),"androidtv",{13:"enter",4:"back",27:"back",37:"left",38:"up",39:"right",40:"down",85:"playPause",126:"play",127:"pause",89:"rewind",90:"fastForward",82:"menu"}),"vizio",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause"}),o(h,"generic",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",32:"playPause",80:"play",83:"stop",77:"mute"})),L=(o(o(o(o(o(o(o(o(o(o(v={},"tizen",[/Tizen/i,/SMART-TV.*Samsung/i]),"webos",[/Web0S/i,/WebOS/i,/LG.*NetCast/i,/LGE.*TV/i]),"vidaa",[/Vidaa/i,/VIDAA/i,/Hisense/i]),"whaleos",[/WhaleTV/i,/Whale/i]),"firetv",[/AFT/i,/AFTS/i,/AFTM/i,/Amazon.*Fire/i]),"roku",[/Roku/i]),"xbox",[/Xbox/i,/Edge.*Xbox/i]),"playstation",[/PlayStation/i,/PS4/i,/PS5/i]),"androidtv",[/Android.*TV/i,/Chromecast/i,/BRAVIA/i,/SHIELD/i]),"vizio",[/VIZIO/i,/SmartCast/i]),o(v,"generic",[])),N=Object.defineProperty,D=Object.defineProperties,V=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,B=function(e,t,r){return t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},z=function(e,t){for(var r in t||(t={}))U.call(t,r)&&B(e,r,t[r]);if(j){var n,i=a(j(t));try{for(i.s();!(n=i.n()).done;){r=n.value;W.call(t,r)&&B(e,r,t[r])}}catch(o){i.e(o)}finally{i.f()}}return e},G=function(e,t){return D(e,V(t))},K=function(e,t,r){return B(e,"symbol"!==f(t)?t+"":t,r)},H=function(){return i(function e(){n(this,e),K(this,"platform"),K(this,"capabilities"),K(this,"deviceInfo"),K(this,"keyMap"),K(this,"reverseKeyMap"),this.platform=this.detectPlatform(),this.keyMap=F[this.platform],this.reverseKeyMap=this.buildReverseKeyMap(),this.capabilities=this.detectCapabilities(),this.deviceInfo=this.detectDeviceInfo()},[{key:"detectPlatform",value:function(){if("undefined"==typeof window||"undefined"==typeof navigator)return I.Generic;var e=navigator.userAgent,t=window;if(t.tizen)return I.Tizen;if(t.webOS||t.PalmSystem)return I.WebOS;for(var r=0,n=Object.entries(L);r<n.length;r++){var i=u(n[r],2),o=i[0],s=i[1];if(o!==I.Generic){var l,c=a(s);try{for(c.s();!(l=c.n()).done;){if(l.value.test(e))return o}}catch(d){c.e(d)}finally{c.f()}}}return I.Generic}},{key:"detectCapabilities",value:function(){var e="undefined"!=typeof navigator,t="undefined"!=typeof document,r="undefined"!=typeof window,n={sendBeacon:e&&"sendBeacon"in navigator,fetchKeepalive:"undefined"!=typeof fetch,mutedAutoplayRequired:!0,fullscreen:t&&("fullscreenEnabled"in document||"webkitFullscreenEnabled"in document),hardwareDecodeInfo:!1,hdr:!1,hdr10Plus:!1,dolbyVision:!1,dolbyAtmos:!1,hevc:this.isCodecSupported('video/mp4; codecs="hvc1"'),vp9:this.isCodecSupported('video/webm; codecs="vp9"'),av1:this.isCodecSupported('video/mp4; codecs="av01.0.05M.08"'),maxResolution:this.detectMaxResolution(),touch:r&&"ontouchstart"in window,voice:!1};switch(this.platform){case I.Tizen:return G(z({},n),{hardwareDecodeInfo:!0,hdr:!0,hevc:!0,voice:!0});case I.WebOS:return G(z({},n),{hardwareDecodeInfo:!0,hdr:!0,dolbyVision:!0,dolbyAtmos:!0,hevc:!0,voice:!0});case I.FireTV:return G(z({},n),{hdr:!0,hdr10Plus:!0,dolbyVision:!0,hevc:!0,voice:!0});case I.Roku:return G(z({},n),{hdr:!0,dolbyVision:!0,hevc:!0,voice:!0});case I.Xbox:return G(z({},n),{hdr:!0,dolbyVision:!0,dolbyAtmos:!0,hevc:!0,av1:!0,voice:!0});case I.PlayStation:return G(z({},n),{hdr:!0,hevc:!0});case I.AndroidTV:return G(z({},n),{hdr:!0,dolbyVision:!0,hevc:!0,vp9:!0,voice:!0});default:return n}}},{key:"detectDeviceInfo",value:function(){var e,t,r,n={platform:this.platform};"undefined"!=typeof window&&(n.screenWidth=null==(e=window.screen)?void 0:e.width,n.screenHeight=null==(t=window.screen)?void 0:t.height,n.devicePixelRatio=window.devicePixelRatio);var i=window;if(this.platform===I.Tizen&&(null==(r=i.tizen)?void 0:r.systeminfo))try{i.tizen.systeminfo.getPropertyValue("BUILD",function(e){n.model=e.model,n.manufacturer=e.manufacturer||"Samsung"})}catch(o){n.manufacturer="Samsung"}if(this.platform===I.WebOS&&i.webOSSystem)try{var a=i.webOSSystem.deviceInfo;n.model=null==a?void 0:a.modelName,n.manufacturer="LG",n.osVersion=null==a?void 0:a.version}catch(o){n.manufacturer="LG"}return n}},{key:"detectMaxResolution",value:function(){var e,t;if("undefined"==typeof window)return"unknown";var r=(null==(e=window.screen)?void 0:e.width)||0,n=(null==(t=window.screen)?void 0:t.height)||0,i=Math.max(r,n);return i>=3840?"4k":i>=1920?"1080p":i>=1280?"720p":"unknown"}},{key:"buildReverseKeyMap",value:function(){for(var e=new Map,t=0,r=Object.entries(this.keyMap);t<r.length;t++){var n=u(r[t],2),i=n[0],a=n[1],o=parseInt(i,10),s=e.get(a)||[];s.push(o),e.set(a,s)}return e}},{key:"normalizeKeyCode",value:function(e){var t;return null!=(t=this.keyMap[e])?t:null}},{key:"getKeyCodesForAction",value:function(e){return this.reverseKeyMap.get(e)||[]}},{key:"isCodecSupported",value:function(e){if("undefined"==typeof document)return!1;try{var t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t}catch(r){return!1}}},{key:"registerTizenKeys",value:function(){if(this.platform===I.Tizen){var e=window.tizen;if(null==e?void 0:e.tvinputdevice){["MediaPlay","MediaPause","MediaStop","MediaFastForward","MediaRewind","MediaPlayPause","ColorF0Red","ColorF1Green","ColorF2Yellow","ColorF3Blue","Info"].forEach(function(t){try{e.tvinputdevice.registerKey(t)}catch(r){}})}}}},{key:"registerWebOSKeys",value:function(){this.platform,I.WebOS}},{key:"getVideoAttributes",value:function(){var e={muted:!0,playsinline:!0,autoplay:!0,"webkit-playsinline":!0};switch(this.platform){case I.Tizen:e["data-samsung-immersive"]="true";break;case I.WebOS:e["data-lg-immersive"]="true";break;case I.FireTV:case I.AndroidTV:e["x-webkit-airplay"]="allow"}return e}},{key:"getRecommendedVideoSettings",value:function(){switch(this.platform){case I.Tizen:case I.WebOS:return{maxBitrate:15e3,preferredCodec:"hevc",maxResolution:"4k"};case I.FireTV:return{maxBitrate:1e4,preferredCodec:"hevc",maxResolution:"4k"};case I.Roku:return{maxBitrate:8e3,preferredCodec:"h264",maxResolution:"4k"};case I.Xbox:case I.PlayStation:return{maxBitrate:2e4,preferredCodec:"hevc",maxResolution:"4k"};default:return{maxBitrate:5e3,preferredCodec:"h264",maxResolution:"1080p"}}}},{key:"debug",value:function(e){if(console.log("[Adgent] ".concat(e)),this.platform===I.WebOS&&"undefined"!=typeof window){var t=window;t.webOS&&t.webOS.service&&t.webOS.service.request("luna://com.webos.notification",{method:"createToast",parameters:{message:"[Adgent] ".concat(e)},onSuccess:function(){},onFailure:function(){}})}}}])}(),q=null;function X(){return q||(q=new H),q}var Q=Object.defineProperty,Y=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,te=function(e,t,r){return t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},re=function(e,t){for(var r in t||(t={}))J.call(t,r)&&te(e,r,t[r]);if($){var n,i=a($(t));try{for(i.s();!(n=i.n()).done;){r=n.value;ee.call(t,r)&&te(e,r,t[r])}}catch(o){i.e(o)}finally{i.f()}}return e},ne=function(e,t,r){return te(e,"symbol"!==f(t)?t+"":t,r)},ie=function(){return i(function e(){var t,r,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e),ne(this,"config"),ne(this,"trackingEvents"),ne(this,"firedEvents"),ne(this,"macroContext"),this.config={debug:null!=(t=o.debug)&&t,retry:null!=(r=o.retry)&&r,maxRetries:null!=(i=o.maxRetries)?i:3},this.trackingEvents=this.groupEventsByType(a),this.firedEvents=new Set,this.macroContext={}},[{key:"groupEventsByType",value:function(e){var t,r=new Map,n=a(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=r.get(i.event)||[];o.push(i),r.set(i.event,o)}}catch(s){n.e(s)}finally{n.f()}return r}},{key:"updateMacroContext",value:function(e){this.macroContext=re(re({},this.macroContext),e)}},{key:"track",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.trackingEvents.get(e);if(r){var n,i=a(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,s="".concat(e,":").concat(o.url);if(t&&this.firedEvents.has(s))this.log("Skipping duplicate event: ".concat(e));else{var l=C(o.url,this.macroContext);this.firePixel(l),t&&this.firedEvents.add(s)}}}catch(u){i.e(u)}finally{i.f()}}else this.log("No tracking URLs for event: ".concat(e))}},{key:"firePixel",value:function(e){var t=X();this.log("Firing pixel: ".concat(e));try{if(t.capabilities.sendBeacon&&navigator.sendBeacon(e))return;if(t.capabilities.fetchKeepalive)return void fetch(e,{method:"GET",keepalive:!0,mode:"no-cors",credentials:"omit"}).catch(function(){});this.fireImageBeacon(e)}catch(r){this.log("Failed to fire pixel: ".concat(e))}}},{key:"fireImageBeacon",value:function(e){new Image(1,1).src=e}},{key:"fireImpressions",value:function(e){var t,r=a(e);try{for(r.s();!(t=r.n()).done;){var n=C(t.value,this.macroContext);this.firePixel(n)}}catch(i){r.e(i)}finally{r.f()}}},{key:"fireError",value:function(e,t){var r,n,i=(r=re({},this.macroContext),Y(r,Z({errorCode:t}))),o=a(e);try{for(o.s();!(n=o.n()).done;){var s=C(n.value,i);this.firePixel(s)}}catch(l){o.e(l)}finally{o.f()}}},{key:"reset",value:function(){this.firedEvents.clear()}},{key:"log",value:function(e){this.config.debug&&console.log("[AdTracker] ".concat(e))}}])}(),ae=Object.defineProperty,oe=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ue=function(e,t,r){return t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},ce=function(e,t){for(var r in t||(t={}))se.call(t,r)&&ue(e,r,t[r]);if(oe){var n,i=a(oe(t));try{for(i.s();!(n=i.n()).done;){r=n.value;le.call(t,r)&&ue(e,r,t[r])}}catch(o){i.e(o)}finally{i.f()}}return e},de=function(e,t,r){return ue(e,"symbol"!==f(t)?t+"":t,r)},fe=function(e,t,r){return new Promise(function(n,i){var a=function(e){try{s(r.next(e))}catch(t){i(t)}},o=function(e){try{s(r.throw(e))}catch(t){i(t)}},s=function(e){return e.done?n(e.value):Promise.resolve(e.value).then(a,o)};s((r=r.apply(e,t)).next())})},pe={targetBitrate:2500,maxWrapperDepth:5,timeout:1e4,debug:!1,skipButtonText:"Skip Ad"},he=function(){return i(function e(t){n(this,e),de(this,"config"),de(this,"platform"),de(this,"parser"),de(this,"videoElement",null),de(this,"overlayElement",null),de(this,"skipButtonElement",null),de(this,"progressElement",null),de(this,"tracker",null),de(this,"state"),de(this,"ads",[]),de(this,"listeners",new Set),de(this,"eventListeners",new Map),de(this,"quartilesFired",new Set),de(this,"boundKeyHandler",null),de(this,"focusTrap",null),this.config=ce(ce({},pe),t),this.platform=X(),this.parser=new x({maxWrapperDepth:this.config.maxWrapperDepth,timeout:this.config.timeout,debug:this.config.debug}),this.state={status:y.Idle,currentTime:0,duration:0,muted:!0,volume:1,canSkip:!1,skipCountdown:0,mediaFile:null,error:null},"tizen"===this.platform.platform&&this.platform.registerTizenKeys()},[{key:"init",value:function(){return fe(this,null,s().m(function e(){var t,r,n,i,a,o,l,u;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.config.container){e.n=1;break}throw new Error("Container element not found");case 1:return this.updateState({status:y.Loading}),e.p=2,e.n=3,this.parser.parse(this.config.vastUrl);case 3:if((n=e.v).success&&n.response){e.n=4;break}throw this.createError((null==(t=n.error)?void 0:t.code)||m.NO_VAST_RESPONSE,(null==(r=n.error)?void 0:r.message)||"Failed to parse VAST");case 4:if(this.ads=n.response.ads,0!==this.ads.length){e.n=5;break}throw this.createError(m.NO_VAST_RESPONSE,"No ads in VAST response");case 5:if(i=this.getFirstLinearCreative()){e.n=6;break}throw this.createError(m.GENERAL_LINEAR_ERROR,"No linear creative found");case 6:if(a=this.parser.selectBestMediaFile(i.mediaFiles,this.config.targetBitrate)){e.n=7;break}throw this.createError(m.FILE_NOT_FOUND,"No suitable media file found");case 7:return this.updateState({mediaFile:a}),o=this.parser.aggregateTrackingEvents(this.ads),this.tracker=new ie(o,{debug:this.config.debug}),this.tracker.updateMacroContext({assetUri:a.url}),this.createVideoElement(a),this.setupFocusManagement(),e.n=8,this.attemptAutoplay();case 8:e.n=10;break;case 9:e.p=9,u=e.v,l=u instanceof Error?this.createError(m.UNDEFINED_ERROR,u.message):u,this.handleError(l);case 10:return e.a(2)}},e,this,[[2,9]])}))}},{key:"getFirstLinearCreative",value:function(){var e,t=a(this.ads);try{for(t.s();!(e=t.n()).done;){var r,n=a(e.value.creatives);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.linear)return i.linear}}catch(o){n.e(o)}finally{n.f()}}}catch(o){t.e(o)}finally{t.f()}return null}},{key:"createVideoElement",value:function(e){var t=this,r=document.createElement("video"),n=this.platform.getVideoAttributes();Object.entries(n).forEach(function(e){var t=u(e,2),n=t[0],i=t[1];"boolean"==typeof i?i&&r.setAttribute(n,""):r.setAttribute(n,i)}),r.removeAttribute("src"),r.innerHTML="";var i=document.createElement("source");if(i.src=e.url,i.type=e.type||"video/mp4",r.appendChild(i),r.setAttribute("crossorigin","anonymous"),r.style.cssText="\n width: 100%;\n height: 100%;\n object-fit: contain;\n background: #000;\n ",r.addEventListener("loadedmetadata",function(){t.updateState({duration:r.duration,status:y.Ready}),t.emit({type:"loaded"})}),r.addEventListener("timeupdate",function(){t.handleTimeUpdate(r)}),r.addEventListener("ended",function(){t.handleComplete()}),r.addEventListener("error",function(){var e=r.error;t.handleError(t.createError(m.MEDIA_NOT_SUPPORTED,(null==e?void 0:e.message)||"Video playback error"))}),r.addEventListener("play",function(){t.updateState({status:y.Playing})}),r.addEventListener("pause",function(){var e;t.state.status!==y.Completed&&(t.updateState({status:y.Paused}),t.emit({type:"pause"}),null==(e=t.tracker)||e.track("pause"))}),this.config.container.appendChild(r),this.videoElement=r,this.config.debug){["loadstart","loadeddata","canplay","waiting","playing"].forEach(function(e){var n=function(){return t.log("Video ".concat(e))};r.addEventListener(e,n),t.eventListeners.set(e,n)});var a=function(){return t.log("Video play event")};r.addEventListener("play",a),this.eventListeners.set("play",a)}this.log("Video element created with src: ".concat(e.url))}},{key:"attemptAutoplay",value:function(){return fe(this,null,s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.videoElement){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this.videoElement.play();case 2:this.handlePlaybackStart(),e.n=4;break;case 3:e.p=3,t=e.v,console.error("[Adgent] Autoplay failed details:",t),this.log("Autoplay failed: ".concat(t)),this.showStartOverlay();case 4:return e.a(2)}},e,this,[[1,3]])}))}},{key:"showStartOverlay",value:function(){var e=this;if(this.updateState({status:y.WaitingForInteraction}),this.config.customStartOverlay)return this.overlayElement=this.config.customStartOverlay,void this.config.container.appendChild(this.overlayElement);var t=document.createElement("div");t.innerHTML='\n <div style="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: table;\n background: rgba(0, 0, 0, 0.5);\n z-index: 100;\n ">\n <div style="display: table-cell; vertical-align: middle; text-align: center;">\n <button id="adgent-start-btn" style="\n width: 80px;\n height: 80px;\n background: rgba(0, 0, 0, 0.7);\n border: 3px solid #fff;\n border-radius: 50%;\n cursor: pointer;\n display: inline-block;\n line-height: 80px;\n text-align: center;\n color: #fff;\n font-size: 40px;\n padding: 0 0 0 8px; /* Optical center for triangle */\n ">\n ▶\n </button>\n </div>\n </div>\n ',t.style.cssText="position: absolute; top: 0; left: 0; width: 100%; height: 100%;";var r=t.querySelector("#adgent-start-btn");null==r||r.addEventListener("click",function(){return e.onStartClick()}),this.config.container.style.position="relative",this.config.container.appendChild(t),this.overlayElement=t,null==r||r.focus()}},{key:"onStartClick",value:function(){return fe(this,null,s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.removeOverlay(),!this.videoElement){e.n=4;break}return e.p=1,e.n=2,this.videoElement.play();case 2:this.handlePlaybackStart(),e.n=4;break;case 3:e.p=3,t=e.v,this.handleError(this.createError(m.GENERAL_LINEAR_ERROR,"Playback failed: ".concat(t)));case 4:return e.a(2)}},e,this,[[1,3]])}))}},{key:"removeOverlay",value:function(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null)}},{key:"handlePlaybackStart",value:function(){var e,t,r,n,i;this.updateState({status:y.Playing}),this.emit({type:"start"}),null==(t=(e=this.config).onStart)||t.call(e);var a=this.parser.aggregateImpressions(this.ads);null==(r=this.tracker)||r.fireImpressions(a),null==(n=this.tracker)||n.track("start"),null==(i=this.tracker)||i.track("creativeView"),this.setupSkipButton(),this.setupProgressUI(),this.log("Playback started")}},{key:"handleTimeUpdate",value:function(e){var t,r,n,i=e.currentTime,a=e.duration;if(a&&!isNaN(a)){var o=i/a*100,s=this.calculateQuartile(o);this.updateState({currentTime:i,duration:a}),this.updateSkipCountdown(i),null==(t=this.tracker)||t.updateMacroContext({adPlayhead:i}),this.updateProgressUI(i,a);var l={currentTime:i,duration:a,percentage:o,quartile:s};this.emit({type:"progress",data:l}),null==(n=(r=this.config).onProgress)||n.call(r,l),this.fireQuartileEvents(o)}}},{key:"calculateQuartile",value:function(e){return e>=100?4:e>=75?3:e>=50?2:e>=25?1:0}},{key:"fireQuartileEvents",value:function(e){for(var t,r=0,n=[{threshold:25,event:"firstQuartile"},{threshold:50,event:"midpoint"},{threshold:75,event:"thirdQuartile"}];r<n.length;r++){var i=n[r],a=i.threshold,o=i.event;e>=a&&!this.quartilesFired.has(a)&&(this.quartilesFired.add(a),null==(t=this.tracker)||t.track(o),this.emit({type:"quartile",data:{quartile:o}}),this.log("Quartile fired: ".concat(o)))}}},{key:"setupSkipButton",value:function(){var e,t=this,r=this.getFirstLinearCreative(),n=null!=(e=this.config.skipOffset)?e:null==r?void 0:r.skipOffset;if(n&&!(n<=0)){this.updateState({skipCountdown:n,canSkip:!1});var i=document.createElement("button");i.id="adgent-skip-btn",i.style.cssText="\n position: absolute;\n bottom: 20px;\n right: 20px;\n padding: 12px 24px;\n font-size: 16px;\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n border: 2px solid #fff;\n border-radius: 4px;\n cursor: pointer;\n z-index: 101;\n transition: opacity 0.3s;\n ",i.textContent="Skip in ".concat(n,"s"),i.addEventListener("click",function(){return t.skip()}),this.config.container.appendChild(i),this.skipButtonElement=i}}},{key:"updateSkipCountdown",value:function(e){var t,r=this.getFirstLinearCreative(),n=null!=(t=this.config.skipOffset)?t:null==r?void 0:r.skipOffset;if(n&&this.skipButtonElement){var i=Math.max(0,n-e);this.updateState({skipCountdown:i}),i<=0&&!this.state.canSkip?(this.updateState({canSkip:!0}),this.skipButtonElement.textContent=this.config.skipButtonText,this.skipButtonElement.style.opacity="1",this.skipButtonElement.focus()):i>0&&(this.skipButtonElement.textContent="Skip in ".concat(Math.ceil(i),"s"),this.skipButtonElement.style.opacity="0.6")}}},{key:"skip",value:function(){var e,t,r;this.state.canSkip?(null==(e=this.tracker)||e.track("skip"),this.emit({type:"skip"}),null==(r=(t=this.config).onSkip)||r.call(t),this.destroy(),this.log("Ad skipped")):this.log("Skip not available yet")}},{key:"handleComplete",value:function(){var e,t,r;this.updateState({status:y.Completed}),null==(e=this.tracker)||e.track("complete"),this.emit({type:"complete"}),null==(r=(t=this.config).onComplete)||r.call(t),this.log("Ad completed")}},{key:"handleError",value:function(e){var t,r,n;this.updateState({status:y.Error,error:e});var i,o=[],s=a(this.ads);try{for(s.s();!(i=s.n()).done;){var l=i.value;o.push.apply(o,c(l.errors))}}catch(u){s.e(u)}finally{s.f()}null==(t=this.tracker)||t.fireError(o,e.code),this.emit({type:"error",data:e}),null==(n=(r=this.config).onError)||n.call(r,e),this.log("Error: ".concat(e.message))}},{key:"setupFocusManagement",value:function(){var e=this;this.focusTrap=document.createElement("div"),this.focusTrap.tabIndex=0,this.focusTrap.style.cssText="position: absolute; opacity: 0; width: 0; height: 0;",this.config.container.appendChild(this.focusTrap),this.focusTrap.focus(),this.boundKeyHandler=function(t){var r=e.platform.normalizeKeyCode(t.keyCode);r&&(t.preventDefault(),t.stopPropagation(),e.handleKeyAction(r))},document.addEventListener("keydown",this.boundKeyHandler,!0)}},{key:"setupProgressUI",value:function(){var e=document.createElement("div");e.style.cssText="\n position: absolute;\n top: 20px;\n left: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 14px;\n font-family: sans-serif;\n z-index: 101;\n display: block;\n white-space: nowrap;\n ",e.innerHTML='\n <span style="display: inline-block; vertical-align: middle; margin-right: 8px; background: #f4b400; color: #000; padding: 2px 4px; border-radius: 2px; font-weight: bold; font-size: 12px;">Ad</span>\n <span id="adgent-progress-text" style="display: inline-block; vertical-align: middle;">1 of '.concat(this.ads.length," • 0:00</span>\n "),this.config.container.appendChild(e),this.progressElement=e}},{key:"updateProgressUI",value:function(e,t){if(this.progressElement){var r=Math.ceil(t-e),n=Math.floor(r/60),i=r%60,a="".concat(n,":").concat(i.toString().padStart(2,"0")),o=this.progressElement.querySelector("#adgent-progress-text");if(o){o.textContent="".concat(1," of ").concat(this.ads.length," • ").concat(a)}}}},{key:"handleKeyAction",value:function(e){var t,r;switch(this.log("Key action: ".concat(e)),e){case M.Enter:this.state.status===y.WaitingForInteraction?this.onStartClick():this.state.canSkip&&this.skip();break;case M.Back:this.config.onClose?(this.log("Back pressed - user cancelling"),this.config.onClose(),this.destroy()):(this.log("Back pressed - skipping"),this.emit({type:"skip"}),this.config.onSkip&&this.config.onSkip(),this.destroy());break;case M.Play:null==(t=this.videoElement)||t.play();break;case M.Pause:null==(r=this.videoElement)||r.pause();case M.Left:case M.Right:case M.Up:case M.Down:}}},{key:"unmute",value:function(){var e;this.videoElement&&(this.videoElement.muted=!1,this.updateState({muted:!1}),null==(e=this.tracker)||e.track("unmute"),this.emit({type:"unmute"}))}},{key:"mute",value:function(){var e;this.videoElement&&(this.videoElement.muted=!0,this.updateState({muted:!0}),null==(e=this.tracker)||e.track("mute"),this.emit({type:"mute"}))}},{key:"on",value:function(e){var t=this;return this.listeners.add(e),function(){return t.listeners.delete(e)}}},{key:"getState",value:function(){return ce({},this.state)}},{key:"destroy",value:function(){var e,t,r,n,i,a=this;this.boundKeyHandler&&(document.removeEventListener("keydown",this.boundKeyHandler,!0),this.boundKeyHandler=null),this.videoElement&&(this.eventListeners.forEach(function(e,t){var r;null==(r=a.videoElement)||r.removeEventListener(t,e)}),this.eventListeners.clear(),this.videoElement.remove()),null==(e=this.overlayElement)||e.remove(),null==(t=this.skipButtonElement)||t.remove(),null==(r=this.progressElement)||r.remove(),null==(n=this.focusTrap)||n.remove(),this.videoElement=null,this.overlayElement=null,this.skipButtonElement=null,this.progressElement=null,this.focusTrap=null,null==(i=this.tracker)||i.reset(),this.quartilesFired.clear(),this.listeners.clear(),this.ads=[],this.emit({type:"destroy"}),this.log("Player destroyed")}},{key:"updateState",value:function(e){this.state=ce(ce({},this.state),e)}},{key:"emit",value:function(e){var t,r=a(this.listeners);try{for(r.s();!(t=r.n()).done;){var n=t.value;try{n(e)}catch(i){this.log("Listener error: ".concat(i))}}}catch(o){r.e(o)}finally{r.f()}}},{key:"createError",value:function(e,t){return{code:e,message:t,recoverable:arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}},{key:"log",value:function(e){this.config.debug&&this.platform.debug(e)}}])}();e.AdPlayer=he,e.AdTracker=ie,e.AdgentSDK=he,e.DEFAULT_KEY_CODES=F,e.KeyAction=M,e.PLATFORM_DETECTION_PATTERNS=L,e.Platform=I,e.PlatformAdapter=H,e.PlaybackStatus=y,e.VASTErrorCode=m,e.VASTParser=x,e.getPlatformAdapter=X,e.replaceMacros=C,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
+
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function a(n,r,i,a){var s=r&&r.prototype instanceof u?r:u,c=Object.create(s.prototype);return l(c,"_invoke",function(n,r,i){var a,s,l,u=0,c=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,l=e,f.n=n,o}};function p(n,r){for(s=n,l=r,t=0;!d&&u&&!i&&t<c.length;t++){var i,a=c[t],p=f.p,h=a[2];n>3?(i=h===r)&&(l=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<h&&(i=n<3||a[0]>r||r>h)&&(a[4]=n,a[5]=r,f.n=h,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,c,h){if(u>1)throw TypeError("Generator is already running");for(d&&1===c&&p(c,h),s=c,l=h;(t=s<2?e:l)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,l)):f.n=l:f.v=l);try{if(u=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==o)break}catch(v){a=e,s=1,l=v}finally{u=1}}return{value:t,done:d}}}(n,i,a),!0),c}var o={};function u(){}function c(){}function d(){}t=Object.getPrototypeOf;var f=[][r]?t(t([][r]())):(l(t={},r,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,i,"GeneratorFunction")),e.prototype=Object.create(p),e}return c.prototype=d,l(p,"constructor",d),l(d,"constructor",c),c.displayName="GeneratorFunction",l(d,i,"GeneratorFunction"),l(p),l(p,i,"Generator"),l(p,r,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(s=function(){return{w:a,m:h}})()}function l(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(a){i=0}(l=function(e,t,n,r){function a(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))})(e,t,n,r)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}var h,v,y=function(e){return e.Idle="idle",e.Loading="loading",e.Ready="ready",e.Playing="playing",e.Paused="paused",e.Completed="completed",e.Error="error",e.WaitingForInteraction="waiting_for_interaction",e}(y||{}),m=function(e){return e[e.XML_PARSING_ERROR=100]="XML_PARSING_ERROR",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_VERSION_NOT_SUPPORTED=102]="VAST_VERSION_NOT_SUPPORTED",e[e.GENERAL_WRAPPER_ERROR=300]="GENERAL_WRAPPER_ERROR",e[e.WRAPPER_TIMEOUT=301]="WRAPPER_TIMEOUT",e[e.WRAPPER_LIMIT_REACHED=302]="WRAPPER_LIMIT_REACHED",e[e.NO_VAST_RESPONSE=303]="NO_VAST_RESPONSE",e[e.GENERAL_LINEAR_ERROR=400]="GENERAL_LINEAR_ERROR",e[e.FILE_NOT_FOUND=401]="FILE_NOT_FOUND",e[e.MEDIA_TIMEOUT=402]="MEDIA_TIMEOUT",e[e.MEDIA_NOT_SUPPORTED=403]="MEDIA_NOT_SUPPORTED",e[e.GENERAL_COMPANION_ERROR=600]="GENERAL_COMPANION_ERROR",e[e.UNDEFINED_ERROR=900]="UNDEFINED_ERROR",e}(m||{}),g=Object.defineProperty,b=Object.defineProperties,k=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,A=function(e,t,n){return t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},T=function(e,t){for(var n in t||(t={}))w.call(t,n)&&A(e,n,t[n]);if(E){var r,i=a(E(t));try{for(i.s();!(r=i.n()).done;){n=r.value;S.call(t,n)&&A(e,n,t[n])}}catch(o){i.e(o)}finally{i.f()}}return e},P=function(e,t){return b(e,k(t))},O=function(e,t,n){return A(e,"symbol"!==f(t)?t+"":t,n)},R=function(e,t,n){return new Promise(function(r,i){var a=function(e){try{s(n.next(e))}catch(t){i(t)}},o=function(e){try{s(n.throw(e))}catch(t){i(t)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(a,o)};s((n=n.apply(e,t)).next())})},x=function(){return i(function e(){var n,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),O(this,"config"),O(this,"xmlParser"),this.config={maxWrapperDepth:null!=(n=s.maxWrapperDepth)?n:5,timeout:null!=(i=s.timeout)?i:1e4,debug:null!=(a=s.debug)&&a,fetchFn:null!=(o=s.fetchFn)?o:fetch.bind(globalThis)},this.xmlParser=new t.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseAttributeValue:!0,trimValues:!0})},[{key:"parse",value:function(e){return R(this,null,s().m(function t(){var n,r,i;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this.fetchAndParse(e,0);case 1:return n=t.v,t.a(2,{success:!0,response:n});case 2:return t.p=2,i=t.v,r=i instanceof Error?i.message:"Unknown error",t.a(2,{success:!1,error:{code:m.GENERAL_WRAPPER_ERROR,message:r}})}},t,this,[[0,2]])}))}},{key:"fetchAndParse",value:function(e,t){return R(this,null,s().m(function n(){var r,i,a,o=this;return s().w(function(n){for(;;)switch(n.n){case 0:if(!(t>=this.config.maxWrapperDepth)){n.n=1;break}throw new Error("Wrapper limit exceeded (max: ".concat(this.config.maxWrapperDepth,")"));case 1:return this.log("Fetching VAST (depth: ".concat(t,"): ").concat(e)),n.n=2,this.fetchWithTimeout(e);case 2:return r=n.v,i=this.parseXml(r),n.n=3,Promise.all(i.ads.map(function(e){return R(o,null,s().m(function n(){var r;return s().w(function(n){for(;;)switch(n.n){case 0:if(!(null==(r=e.wrapper)?void 0:r.vastAdTagURI)){n.n=1;break}return n.a(2,this.resolveWrapper(e,t+1));case 1:return n.a(2,e)}},n,this)}))}));case 3:return a=n.v,n.a(2,P(T({},i),{ads:a.flat()}))}},n,this)}))}},{key:"resolveWrapper",value:function(e,t){return R(this,null,s().m(function n(){var r,i,a,o=this;return s().w(function(n){for(;;)switch(n.p=n.n){case 0:if(null==(r=e.wrapper)?void 0:r.vastAdTagURI){n.n=1;break}return n.a(2,[e]);case 1:return n.p=1,n.n=2,this.fetchAndParse(e.wrapper.vastAdTagURI,t);case 2:return i=n.v,n.a(2,i.ads.map(function(t){return o.mergeWrapperTracking(e,t)}));case 3:if(n.p=3,a=n.v,this.log("Wrapper resolution failed: ".concat(a)),!e.wrapper.fallbackOnNoAd){n.n=4;break}return n.a(2,[]);case 4:throw a;case 5:return n.a(2)}},n,this,[[1,3]])}))}},{key:"mergeWrapperTracking",value:function(e,t){var n=this;return P(T({},t),{impressions:[].concat(c(e.impressions),c(t.impressions)),errors:[].concat(c(e.errors),c(t.errors)),creatives:t.creatives.map(function(t){return P(T({},t),{linear:t.linear?P(T({},t.linear),{trackingEvents:[].concat(c(n.getWrapperTrackingEvents(e)),c(t.linear.trackingEvents))}):void 0})})})}},{key:"getWrapperTrackingEvents",value:function(e){var t,n,r=[],i=a(e.creatives);try{for(i.s();!(n=i.n()).done;){var o=n.value;(null==(t=o.linear)?void 0:t.trackingEvents)&&r.push.apply(r,c(o.linear.trackingEvents))}}catch(s){i.e(s)}finally{i.f()}return r}},{key:"fetchWithTimeout",value:function(e){return R(this,null,s().m(function t(){var n,r,i;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=new AbortController,r=setTimeout(function(){return n.abort()},this.config.timeout),t.p=1,t.n=2,this.config.fetchFn(e,{signal:n.signal});case 2:if((i=t.v).ok){t.n=3;break}throw new Error("HTTP ".concat(i.status,": ").concat(i.statusText));case 3:return t.a(2,i.text());case 4:return t.p=4,clearTimeout(r),t.f(4);case 5:return t.a(2)}},t,this,[[1,,4,5]])}))}},{key:"parseXml",value:function(e){var t=this.xmlParser.parse(e).VAST;if(!t)throw new Error("Invalid VAST: missing VAST element");return{version:t["@_version"]||"4.0",ads:this.parseAds(t.Ad),errors:this.parseErrors(t.Error)}}},{key:"parseAds",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return t.parseAd(e)}):[]}},{key:"parseAd",value:function(e){var t,n,r,i=!!e.Wrapper,a=e.InLine||e.Wrapper;return{id:e["@_id"]||"",sequence:e["@_sequence"],adSystem:(null==a?void 0:a.AdSystem)?{name:"string"==typeof a.AdSystem?a.AdSystem:a.AdSystem["#text"]||"",version:null==(t=a.AdSystem)?void 0:t["@_version"]}:void 0,adTitle:null==a?void 0:a.AdTitle,impressions:this.parseImpressions(null==a?void 0:a.Impression),errors:this.parseErrors(null==a?void 0:a.Error),creatives:this.parseCreatives(null==(n=null==a?void 0:a.Creatives)?void 0:n.Creative),wrapper:i?{vastAdTagURI:a.VASTAdTagURI,followAdditionalWrappers:!1!==a["@_followAdditionalWrappers"],allowMultipleAds:a["@_allowMultipleAds"],fallbackOnNoAd:a["@_fallbackOnNoAd"]}:void 0,inLine:i?void 0:{adTitle:(null==a?void 0:a.AdTitle)||"",description:null==a?void 0:a.Description,advertiser:null==a?void 0:a.Advertiser,creatives:this.parseCreatives(null==(r=null==a?void 0:a.Creatives)?void 0:r.Creative)}}}},{key:"parseImpressions",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],url:"string"==typeof e?e:e["#text"]||""}}):[]}},{key:"parseCreatives",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],sequence:e["@_sequence"],adId:e["@_adId"],linear:e.Linear?t.parseLinear(e.Linear):void 0}}):[]}},{key:"parseLinear",value:function(e){var t,n;return{duration:this.parseDuration(e.Duration),skipOffset:e["@_skipoffset"]?this.parseDuration(e["@_skipoffset"]):void 0,mediaFiles:this.parseMediaFiles(null==(t=e.MediaFiles)?void 0:t.MediaFile),trackingEvents:this.parseTrackingEvents(null==(n=e.TrackingEvents)?void 0:n.Tracking),videoClicks:e.VideoClicks?{clickThrough:e.VideoClicks.ClickThrough?{id:e.VideoClicks.ClickThrough["@_id"],url:"string"==typeof e.VideoClicks.ClickThrough?e.VideoClicks.ClickThrough:e.VideoClicks.ClickThrough["#text"]||""}:void 0}:void 0,adParameters:e.AdParameters}}},{key:"parseMediaFiles",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return{id:e["@_id"],url:"string"==typeof e?e:e["#text"]||"",delivery:e["@_delivery"]||"progressive",type:e["@_type"]||"video/mp4",width:parseInt(e["@_width"],10)||0,height:parseInt(e["@_height"],10)||0,bitrate:e["@_bitrate"]?parseInt(e["@_bitrate"],10):void 0,codec:e["@_codec"],scalable:e["@_scalable"],maintainAspectRatio:e["@_maintainAspectRatio"]}}):[]}},{key:"parseTrackingEvents",value:function(e){var t=this;return e?(Array.isArray(e)?e:[e]).map(function(e){return{event:e["@_event"],url:"string"==typeof e?e:e["#text"]||"",offset:e["@_offset"]?t.parseDuration(e["@_offset"]):void 0}}):[]}},{key:"parseErrors",value:function(e){return e?(Array.isArray(e)?e:[e]).map(function(e){return"string"==typeof e?e:e["#text"]||""}):[]}},{key:"parseDuration",value:function(e){if("number"==typeof e)return e;if("string"!=typeof e)return 0;if(e.endsWith("%"))return parseFloat(e)/100;var t=e.match(/(\d+):(\d+):(\d+(?:\.\d+)?)/);if(t){var n=u(t,4),r=n[1],i=n[2],a=n[3];return 3600*parseInt(r,10)+60*parseInt(i,10)+parseFloat(a)}return parseFloat(e)||0}},{key:"selectBestMediaFile",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500;if(0===e.length)return null;var n=e.filter(function(e){return e.type.toLowerCase().startsWith("video/")});if(0===n.length)return null;var r=n.filter(function(e){return e.type.includes("mp4")||e.type.includes("video/mp4")});return c(r.length>0?r:n).sort(function(e,n){var r=e.bitrate||0,i=n.bitrate||0,a=e.height>1080?1e4:0,o=n.height>1080?1e4:0;return Math.abs(r-t)+a-(Math.abs(i-t)+o)})[0]||null}},{key:"aggregateTrackingEvents",value:function(e){var t,n,r=[],i=a(e);try{for(i.s();!(n=i.n()).done;){var o,s=a(n.value.creatives);try{for(s.s();!(o=s.n()).done;){var l=o.value;(null==(t=l.linear)?void 0:t.trackingEvents)&&r.push.apply(r,c(l.linear.trackingEvents))}}catch(u){s.e(u)}finally{s.f()}}}catch(u){i.e(u)}finally{i.f()}return r}},{key:"aggregateImpressions",value:function(e){var t,n=[],r=a(e);try{for(r.s();!(t=r.n()).done;){var i,o=a(t.value.impressions);try{for(o.s();!(i=o.n()).done;){var s=i.value;n.push(s.url)}}catch(l){o.e(l)}finally{o.f()}}}catch(l){r.e(l)}finally{r.f()}return n}},{key:"log",value:function(e){this.config.debug&&console.log("[VASTParser] ".concat(e))}}])}();function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e;return n=(n=n.replace(/\[TIMESTAMP\]/g,Date.now().toString())).replace(/\[CACHEBUSTING\]/g,Math.random().toString(36).substring(2,15)),t.assetUri&&(n=n.replace(/\[ASSETURI\]/g,encodeURIComponent(t.assetUri))),void 0!==t.contentPlayhead&&(n=n.replace(/\[CONTENTPLAYHEAD\]/g,_(t.contentPlayhead))),void 0!==t.adPlayhead&&(n=n.replace(/\[ADPLAYHEAD\]/g,_(t.adPlayhead))),void 0!==t.errorCode&&(n=n.replace(/\[ERRORCODE\]/g,t.errorCode.toString())),void 0!==t.breakPosition&&(n=n.replace(/\[BREAKPOSITION\]/g,t.breakPosition.toString())),t.adType&&(n=n.replace(/\[ADTYPE\]/g,t.adType)),n}function _(e){var t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60),i=Math.floor(e%1*1e3);return t.toString().padStart(2,"0")+":"+n.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+"."+i.toString().padStart(3,"0")}var I=function(e){return e.WebOS="webos",e.Tizen="tizen",e.Vidaa="vidaa",e.WhaleOS="whaleos",e.FireTV="firetv",e.Roku="roku",e.Xbox="xbox",e.PlayStation="playstation",e.AndroidTV="androidtv",e.Vizio="vizio",e.Generic="generic",e}(I||{}),M=function(e){return e.Enter="enter",e.Back="back",e.Left="left",e.Right="right",e.Up="up",e.Down="down",e.Play="play",e.Pause="pause",e.PlayPause="playPause",e.Stop="stop",e.FastForward="fastForward",e.Rewind="rewind",e.Menu="menu",e.Info="info",e.Red="red",e.Green="green",e.Yellow="yellow",e.Blue="blue",e.ChannelUp="channelUp",e.ChannelDown="channelDown",e.VolumeUp="volumeUp",e.VolumeDown="volumeDown",e.Mute="mute",e}(M||{}),F=(o(o(o(o(o(o(o(o(o(o(h={},"webos",{13:"enter",461:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop",417:"fastForward",412:"rewind",457:"info",403:"red",404:"green",405:"yellow",406:"blue",33:"channelUp",34:"channelDown"}),"tizen",{13:"enter",10009:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",10252:"playPause",413:"stop",417:"fastForward",412:"rewind",457:"info",403:"red",404:"green",405:"yellow",406:"blue",427:"channelUp",428:"channelDown",447:"volumeUp",448:"volumeDown",449:"mute"}),"vidaa",{13:"enter",8:"back",27:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop",417:"fastForward",412:"rewind"}),"whaleos",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause",413:"stop"}),"firetv",{13:"enter",4:"back",27:"back",37:"left",38:"up",39:"right",40:"down",85:"playPause",126:"play",127:"pause",89:"rewind",90:"fastForward",82:"menu"}),"roku",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",179:"playPause",178:"stop",228:"fastForward",227:"rewind"}),"xbox",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down",195:"menu",196:"menu"}),"playstation",{13:"enter",27:"back",37:"left",38:"up",39:"right",40:"down"}),"androidtv",{13:"enter",4:"back",27:"back",37:"left",38:"up",39:"right",40:"down",85:"playPause",126:"play",127:"pause",89:"rewind",90:"fastForward",82:"menu"}),"vizio",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",415:"play",19:"pause"}),o(h,"generic",{13:"enter",27:"back",8:"back",37:"left",38:"up",39:"right",40:"down",32:"playPause",80:"play",83:"stop",77:"mute"})),L=(o(o(o(o(o(o(o(o(o(o(v={},"tizen",[/Tizen/i,/SMART-TV.*Samsung/i]),"webos",[/Web0S/i,/WebOS/i,/LG.*NetCast/i,/LGE.*TV/i]),"vidaa",[/Vidaa/i,/VIDAA/i,/Hisense/i]),"whaleos",[/WhaleTV/i,/Whale/i]),"firetv",[/AFT/i,/AFTS/i,/AFTM/i,/Amazon.*Fire/i]),"roku",[/Roku/i]),"xbox",[/Xbox/i,/Edge.*Xbox/i]),"playstation",[/PlayStation/i,/PS4/i,/PS5/i]),"androidtv",[/Android.*TV/i,/Chromecast/i,/BRAVIA/i,/SHIELD/i]),"vizio",[/VIZIO/i,/SmartCast/i]),o(v,"generic",[])),N=Object.defineProperty,D=Object.defineProperties,V=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,B=function(e,t,n){return t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},z=function(e,t){for(var n in t||(t={}))j.call(t,n)&&B(e,n,t[n]);if(W){var r,i=a(W(t));try{for(i.s();!(r=i.n()).done;){n=r.value;U.call(t,n)&&B(e,n,t[n])}}catch(o){i.e(o)}finally{i.f()}}return e},G=function(e,t){return D(e,V(t))},K=function(e,t,n){return B(e,"symbol"!==f(t)?t+"":t,n)},H=function(){return i(function e(){r(this,e),K(this,"platform"),K(this,"capabilities"),K(this,"deviceInfo"),K(this,"keyMap"),K(this,"reverseKeyMap"),this.platform=this.detectPlatform(),this.keyMap=F[this.platform],this.reverseKeyMap=this.buildReverseKeyMap(),this.capabilities=this.detectCapabilities(),this.deviceInfo=this.detectDeviceInfo()},[{key:"detectPlatform",value:function(){if("undefined"==typeof window||"undefined"==typeof navigator)return I.Generic;var e=navigator.userAgent,t=window;if(t.tizen)return I.Tizen;if(t.webOS||t.PalmSystem)return I.WebOS;for(var n=0,r=Object.entries(L);n<r.length;n++){var i=u(r[n],2),o=i[0],s=i[1];if(o!==I.Generic){var l,c=a(s);try{for(c.s();!(l=c.n()).done;){if(l.value.test(e))return o}}catch(d){c.e(d)}finally{c.f()}}}return I.Generic}},{key:"detectCapabilities",value:function(){var e="undefined"!=typeof navigator,t="undefined"!=typeof document,n="undefined"!=typeof window,r={sendBeacon:e&&"sendBeacon"in navigator,fetchKeepalive:"undefined"!=typeof fetch,mutedAutoplayRequired:!0,fullscreen:t&&("fullscreenEnabled"in document||"webkitFullscreenEnabled"in document),hardwareDecodeInfo:!1,hdr:!1,hdr10Plus:!1,dolbyVision:!1,dolbyAtmos:!1,hevc:this.isCodecSupported('video/mp4; codecs="hvc1"'),vp9:this.isCodecSupported('video/webm; codecs="vp9"'),av1:this.isCodecSupported('video/mp4; codecs="av01.0.05M.08"'),maxResolution:this.detectMaxResolution(),touch:n&&"ontouchstart"in window,voice:!1};switch(this.platform){case I.Tizen:return G(z({},r),{hardwareDecodeInfo:!0,hdr:!0,hevc:!0,voice:!0});case I.WebOS:return G(z({},r),{hardwareDecodeInfo:!0,hdr:!0,dolbyVision:!0,dolbyAtmos:!0,hevc:!0,voice:!0});case I.FireTV:return G(z({},r),{hdr:!0,hdr10Plus:!0,dolbyVision:!0,hevc:!0,voice:!0});case I.Roku:return G(z({},r),{hdr:!0,dolbyVision:!0,hevc:!0,voice:!0});case I.Xbox:return G(z({},r),{hdr:!0,dolbyVision:!0,dolbyAtmos:!0,hevc:!0,av1:!0,voice:!0});case I.PlayStation:return G(z({},r),{hdr:!0,hevc:!0});case I.AndroidTV:return G(z({},r),{hdr:!0,dolbyVision:!0,hevc:!0,vp9:!0,voice:!0});default:return r}}},{key:"detectDeviceInfo",value:function(){var e,t,n,r={platform:this.platform};"undefined"!=typeof window&&(r.screenWidth=null==(e=window.screen)?void 0:e.width,r.screenHeight=null==(t=window.screen)?void 0:t.height,r.devicePixelRatio=window.devicePixelRatio);var i=window;if(this.platform===I.Tizen&&(null==(n=i.tizen)?void 0:n.systeminfo))try{i.tizen.systeminfo.getPropertyValue("BUILD",function(e){r.model=e.model,r.manufacturer=e.manufacturer||"Samsung"})}catch(o){r.manufacturer="Samsung"}if(this.platform===I.WebOS&&i.webOSSystem)try{var a=i.webOSSystem.deviceInfo;r.model=null==a?void 0:a.modelName,r.manufacturer="LG",r.osVersion=null==a?void 0:a.version}catch(o){r.manufacturer="LG"}return r}},{key:"detectMaxResolution",value:function(){var e,t;if("undefined"==typeof window)return"unknown";var n=(null==(e=window.screen)?void 0:e.width)||0,r=(null==(t=window.screen)?void 0:t.height)||0,i=Math.max(n,r);return i>=3840?"4k":i>=1920?"1080p":i>=1280?"720p":"unknown"}},{key:"buildReverseKeyMap",value:function(){for(var e=new Map,t=0,n=Object.entries(this.keyMap);t<n.length;t++){var r=u(n[t],2),i=r[0],a=r[1],o=parseInt(i,10),s=e.get(a)||[];s.push(o),e.set(a,s)}return e}},{key:"normalizeKeyCode",value:function(e){var t;return null!=(t=this.keyMap[e])?t:null}},{key:"getKeyCodesForAction",value:function(e){return this.reverseKeyMap.get(e)||[]}},{key:"isCodecSupported",value:function(e){if("undefined"==typeof document)return!1;try{var t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t}catch(n){return!1}}},{key:"registerTizenKeys",value:function(){if(this.platform===I.Tizen){var e=window.tizen;if(null==e?void 0:e.tvinputdevice){["MediaPlay","MediaPause","MediaStop","MediaFastForward","MediaRewind","MediaPlayPause","ColorF0Red","ColorF1Green","ColorF2Yellow","ColorF3Blue","Info"].forEach(function(t){try{e.tvinputdevice.registerKey(t)}catch(n){}})}}}},{key:"registerWebOSKeys",value:function(){this.platform,I.WebOS}},{key:"getVideoAttributes",value:function(){var e={muted:!0,playsinline:!0,autoplay:!0,"webkit-playsinline":!0};switch(this.platform){case I.Tizen:e["data-samsung-immersive"]="true";break;case I.WebOS:e["data-lg-immersive"]="true";break;case I.FireTV:case I.AndroidTV:e["x-webkit-airplay"]="allow"}return e}},{key:"getRecommendedVideoSettings",value:function(){switch(this.platform){case I.Tizen:case I.WebOS:return{maxBitrate:15e3,preferredCodec:"hevc",maxResolution:"4k"};case I.FireTV:return{maxBitrate:1e4,preferredCodec:"hevc",maxResolution:"4k"};case I.Roku:return{maxBitrate:8e3,preferredCodec:"h264",maxResolution:"4k"};case I.Xbox:case I.PlayStation:return{maxBitrate:2e4,preferredCodec:"hevc",maxResolution:"4k"};default:return{maxBitrate:5e3,preferredCodec:"h264",maxResolution:"1080p"}}}},{key:"openExternalLink",value:function(e){if("undefined"!=typeof window)if(this.platform===I.Generic||this.platform===I.Tizen||this.platform===I.WebOS)try{window.open(e,"_blank"),this.debug("[Adgent] Opened external link: ".concat(e))}catch(t){this.debug("[Adgent] Failed to open external link: ".concat(t))}else this.debug("[Adgent] Opening external links not supported on ".concat(this.platform,": ").concat(e));else this.debug("[Adgent] Cannot open link (server-side): ".concat(e))}},{key:"debug",value:function(e){if(console.log("[Adgent] ".concat(e)),this.platform===I.WebOS&&"undefined"!=typeof window){var t=window;t.webOS&&t.webOS.service&&t.webOS.service.request("luna://com.webos.notification",{method:"createToast",parameters:{message:"[Adgent] ".concat(e)},onSuccess:function(){},onFailure:function(){}})}}}])}(),q=null;function X(){return q||(q=new H),q}var Q=Object.defineProperty,Y=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,te=function(e,t,n){return t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},ne=function(e,t){for(var n in t||(t={}))J.call(t,n)&&te(e,n,t[n]);if($){var r,i=a($(t));try{for(i.s();!(r=i.n()).done;){n=r.value;ee.call(t,n)&&te(e,n,t[n])}}catch(o){i.e(o)}finally{i.f()}}return e},re=function(e,t,n){return te(e,"symbol"!==f(t)?t+"":t,n)},ie=function(){return i(function e(){var t,n,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,e),re(this,"config"),re(this,"trackingEvents"),re(this,"firedEvents"),re(this,"macroContext"),this.config={debug:null!=(t=o.debug)&&t,retry:null!=(n=o.retry)&&n,maxRetries:null!=(i=o.maxRetries)?i:3},this.trackingEvents=this.groupEventsByType(a),this.firedEvents=new Set,this.macroContext={}},[{key:"groupEventsByType",value:function(e){var t,n=new Map,r=a(e);try{for(r.s();!(t=r.n()).done;){var i=t.value,o=n.get(i.event)||[];o.push(i),n.set(i.event,o)}}catch(s){r.e(s)}finally{r.f()}return n}},{key:"updateMacroContext",value:function(e){this.macroContext=ne(ne({},this.macroContext),e)}},{key:"track",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.trackingEvents.get(e);if(n){var r,i=a(n);try{for(i.s();!(r=i.n()).done;){var o=r.value,s="".concat(e,":").concat(o.url);if(t&&this.firedEvents.has(s))this.log("Skipping duplicate event: ".concat(e));else{var l=C(o.url,this.macroContext);this.firePixel(l),t&&this.firedEvents.add(s)}}}catch(u){i.e(u)}finally{i.f()}}else this.log("No tracking URLs for event: ".concat(e))}},{key:"firePixel",value:function(e){var t=X();this.log("Firing pixel: ".concat(e));try{if(t.capabilities.sendBeacon&&navigator.sendBeacon(e))return;if(t.capabilities.fetchKeepalive)return void fetch(e,{method:"GET",keepalive:!0,mode:"no-cors",credentials:"omit"}).catch(function(){});this.fireImageBeacon(e)}catch(n){this.log("Failed to fire pixel: ".concat(e))}}},{key:"fireImageBeacon",value:function(e){new Image(1,1).src=e}},{key:"fireImpressions",value:function(e){var t,n=a(e);try{for(n.s();!(t=n.n()).done;){var r=C(t.value,this.macroContext);this.firePixel(r)}}catch(i){n.e(i)}finally{n.f()}}},{key:"fireError",value:function(e,t){var n,r,i=(n=ne({},this.macroContext),Y(n,Z({errorCode:t}))),o=a(e);try{for(o.s();!(r=o.n()).done;){var s=C(r.value,i);this.firePixel(s)}}catch(l){o.e(l)}finally{o.f()}}},{key:"reset",value:function(){this.firedEvents.clear()}},{key:"log",value:function(e){this.config.debug&&console.log("[AdTracker] ".concat(e))}}])}(),ae=Object.defineProperty,oe=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ue=function(e,t,n){return t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},ce=function(e,t){for(var n in t||(t={}))se.call(t,n)&&ue(e,n,t[n]);if(oe){var r,i=a(oe(t));try{for(i.s();!(r=i.n()).done;){n=r.value;le.call(t,n)&&ue(e,n,t[n])}}catch(o){i.e(o)}finally{i.f()}}return e},de=function(e,t,n){return ue(e,"symbol"!==f(t)?t+"":t,n)},fe=function(e,t,n){return new Promise(function(r,i){var a=function(e){try{s(n.next(e))}catch(t){i(t)}},o=function(e){try{s(n.throw(e))}catch(t){i(t)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(a,o)};s((n=n.apply(e,t)).next())})},pe={targetBitrate:2500,maxWrapperDepth:5,timeout:1e4,debug:!1,skipButtonText:"Skip Ad"},he=function(){return i(function e(t){r(this,e),de(this,"config"),de(this,"platform"),de(this,"parser"),de(this,"videoElement",null),de(this,"overlayElement",null),de(this,"skipButtonElement",null),de(this,"progressElement",null),de(this,"tracker",null),de(this,"state"),de(this,"ads",[]),de(this,"listeners",new Set),de(this,"eventListeners",new Map),de(this,"quartilesFired",new Set),de(this,"boundKeyHandler",null),de(this,"focusTrap",null),de(this,"hasStarted",!1),this.config=ce(ce({},pe),t),this.platform=X(),this.parser=new x({maxWrapperDepth:this.config.maxWrapperDepth,timeout:this.config.timeout,debug:this.config.debug}),this.state={status:y.Idle,currentTime:0,duration:0,muted:!0,volume:1,canSkip:!1,skipCountdown:0,mediaFile:null,error:null},"tizen"===this.platform.platform&&this.platform.registerTizenKeys()},[{key:"init",value:function(){return fe(this,null,s().m(function e(){var t,n,r,i,a,o,l,u;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.config.container){e.n=1;break}throw new Error("Container element not found");case 1:return this.updateState({status:y.Loading}),e.p=2,e.n=3,this.parser.parse(this.config.vastUrl);case 3:if((r=e.v).success&&r.response){e.n=4;break}throw this.createError((null==(t=r.error)?void 0:t.code)||m.NO_VAST_RESPONSE,(null==(n=r.error)?void 0:n.message)||"Failed to parse VAST");case 4:if(this.ads=r.response.ads,0!==this.ads.length){e.n=5;break}throw this.createError(m.NO_VAST_RESPONSE,"No ads in VAST response");case 5:if(i=this.getFirstLinearCreative()){e.n=6;break}throw this.createError(m.GENERAL_LINEAR_ERROR,"No linear creative found");case 6:if(a=this.parser.selectBestMediaFile(i.mediaFiles,this.config.targetBitrate)){e.n=7;break}throw this.createError(m.FILE_NOT_FOUND,"No suitable media file found");case 7:return this.updateState({mediaFile:a}),o=this.parser.aggregateTrackingEvents(this.ads),this.tracker=new ie(o,{debug:this.config.debug}),this.tracker.updateMacroContext({assetUri:a.url}),this.createVideoElement(a),this.setupFocusManagement(),e.n=8,this.attemptAutoplay();case 8:e.n=10;break;case 9:e.p=9,u=e.v,l=u instanceof Error?this.createError(m.UNDEFINED_ERROR,u.message):u,this.handleError(l);case 10:return e.a(2)}},e,this,[[2,9]])}))}},{key:"getFirstLinearCreative",value:function(){var e,t=a(this.ads);try{for(t.s();!(e=t.n()).done;){var n,r=a(e.value.creatives);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.linear)return i.linear}}catch(o){r.e(o)}finally{r.f()}}}catch(o){t.e(o)}finally{t.f()}return null}},{key:"createVideoElement",value:function(e){var t=this,n=document.createElement("video"),r=this.platform.getVideoAttributes();Object.entries(r).forEach(function(e){var t=u(e,2),r=t[0],i=t[1];"boolean"==typeof i?i&&n.setAttribute(r,""):n.setAttribute(r,i)}),n.removeAttribute("src"),n.innerHTML="";var i=document.createElement("source");if(i.src=e.url,i.type=e.type||"video/mp4",n.appendChild(i),n.setAttribute("crossorigin","anonymous"),n.style.cssText="\n width: 100%;\n height: 100%;\n object-fit: contain;\n background: #000;\n ",n.addEventListener("loadedmetadata",function(){t.updateState({duration:n.duration,status:y.Ready}),t.emit({type:"loaded"})}),n.addEventListener("timeupdate",function(){t.handleTimeUpdate(n)}),n.addEventListener("ended",function(){t.handleComplete()}),n.addEventListener("error",function(){var e=n.error;t.handleError(t.createError(m.MEDIA_NOT_SUPPORTED,(null==e?void 0:e.message)||"Video playback error"))}),n.addEventListener("play",function(){t.updateState({status:y.Playing})}),n.addEventListener("pause",function(){var e;t.state.status!==y.Completed&&(t.updateState({status:y.Paused}),t.emit({type:"pause"}),null==(e=t.tracker)||e.track("pause"))}),this.config.container.appendChild(n),this.videoElement=n,this.config.debug){["loadstart","loadeddata","canplay","waiting","playing"].forEach(function(e){var r=function(){return t.log("Video ".concat(e))};n.addEventListener(e,r),t.eventListeners.set(e,r)});var a=function(){return t.log("Video play event")};n.addEventListener("play",a),this.eventListeners.set("play",a)}this.log("Video element created with src: ".concat(e.url)),n.addEventListener("click",function(){t.onAdClick()}),n.style.cursor="pointer"}},{key:"attemptAutoplay",value:function(){return fe(this,null,s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.videoElement){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this.videoElement.play();case 2:this.handlePlaybackStart(),e.n=4;break;case 3:e.p=3,t=e.v,console.error("[Adgent] Autoplay failed details:",t),this.log("Autoplay failed: ".concat(t)),this.showStartOverlay();case 4:return e.a(2)}},e,this,[[1,3]])}))}},{key:"showStartOverlay",value:function(){var e=this;if(this.updateState({status:y.WaitingForInteraction}),this.config.customStartOverlay)return this.overlayElement=this.config.customStartOverlay,void this.config.container.appendChild(this.overlayElement);var t=document.createElement("div");t.innerHTML='\n <div style="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: table;\n background: rgba(0, 0, 0, 0.5);\n z-index: 100;\n ">\n <div style="display: table-cell; vertical-align: middle; text-align: center;">\n <button id="adgent-start-btn" style="\n width: 80px;\n height: 80px;\n background: rgba(0, 0, 0, 0.7);\n border: 3px solid #fff;\n border-radius: 50%;\n cursor: pointer;\n display: inline-block;\n line-height: 80px;\n text-align: center;\n color: #fff;\n font-size: 40px;\n padding: 0 0 0 8px; /* Optical center for triangle */\n ">\n ▶\n </button>\n </div>\n </div>\n ',t.style.cssText="position: absolute; top: 0; left: 0; width: 100%; height: 100%;";var n=t.querySelector("#adgent-start-btn");null==n||n.addEventListener("click",function(){return e.onStartClick()}),this.config.container.style.position="relative",this.config.container.appendChild(t),this.overlayElement=t,null==n||n.focus()}},{key:"onAdClick",value:function(){var e,t,n,r,i,a=this;if(this.state.status===y.Playing){var o=this.getFirstLinearCreative();if(o){var s=null==(e=o.videoClicks)?void 0:e.clickThrough,l=null==s?void 0:s.url;if(l)this.log("Ad clicked. Opening: ".concat(l)),null==(t=this.videoElement)||t.pause(),this.showStartOverlay(),((null==(n=o.videoClicks)?void 0:n.clickTracking)||[]).forEach(function(e){var t;e.url&&(null==(t=a.tracker)||t.firePixel(e.url))}),this.platform.openExternalLink(l),this.emit({type:"click",data:{url:l}}),null==(i=(r=this.config).onClick)||i.call(r,l)}}}},{key:"onStartClick",value:function(){return fe(this,null,s().m(function e(){var t,n;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.removeOverlay(),!this.videoElement){e.n=4;break}return e.p=1,e.n=2,this.videoElement.play();case 2:this.hasStarted?(this.updateState({status:y.Playing}),this.emit({type:"resume"}),null==(t=this.tracker)||t.track("resume")):this.handlePlaybackStart(),e.n=4;break;case 3:e.p=3,n=e.v,this.handleError(this.createError(m.GENERAL_LINEAR_ERROR,"Playback failed: ".concat(n)));case 4:return e.a(2)}},e,this,[[1,3]])}))}},{key:"removeOverlay",value:function(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null)}},{key:"handlePlaybackStart",value:function(){var e,t,n,r,i;this.hasStarted=!0,this.updateState({status:y.Playing}),this.emit({type:"start"}),null==(t=(e=this.config).onStart)||t.call(e);var a=this.parser.aggregateImpressions(this.ads);null==(n=this.tracker)||n.fireImpressions(a),null==(r=this.tracker)||r.track("start"),null==(i=this.tracker)||i.track("creativeView"),this.setupSkipButton(),this.setupProgressUI(),this.log("Playback started")}},{key:"handleTimeUpdate",value:function(e){var t,n,r,i=e.currentTime,a=e.duration;if(a&&!isNaN(a)){var o=i/a*100,s=this.calculateQuartile(o);this.updateState({currentTime:i,duration:a}),this.updateSkipCountdown(i),null==(t=this.tracker)||t.updateMacroContext({adPlayhead:i}),this.updateProgressUI(i,a);var l={currentTime:i,duration:a,percentage:o,quartile:s};this.emit({type:"progress",data:l}),null==(r=(n=this.config).onProgress)||r.call(n,l),this.fireQuartileEvents(o)}}},{key:"calculateQuartile",value:function(e){return e>=100?4:e>=75?3:e>=50?2:e>=25?1:0}},{key:"fireQuartileEvents",value:function(e){for(var t,n=0,r=[{threshold:25,event:"firstQuartile"},{threshold:50,event:"midpoint"},{threshold:75,event:"thirdQuartile"}];n<r.length;n++){var i=r[n],a=i.threshold,o=i.event;e>=a&&!this.quartilesFired.has(a)&&(this.quartilesFired.add(a),null==(t=this.tracker)||t.track(o),this.emit({type:"quartile",data:{quartile:o}}),this.log("Quartile fired: ".concat(o)))}}},{key:"setupSkipButton",value:function(){var e,t=this,n=this.getFirstLinearCreative(),r=null!=(e=this.config.skipOffset)?e:null==n?void 0:n.skipOffset;if(r&&!(r<=0)){this.updateState({skipCountdown:r,canSkip:!1});var i=document.createElement("button");i.id="adgent-skip-btn",i.style.cssText="\n position: absolute;\n bottom: 20px;\n right: 20px;\n padding: 12px 24px;\n font-size: 16px;\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n border: 2px solid #fff;\n border-radius: 4px;\n cursor: pointer;\n z-index: 101;\n transition: opacity 0.3s;\n ",i.textContent="Skip in ".concat(r,"s"),i.addEventListener("click",function(){return t.skip()}),this.config.container.appendChild(i),this.skipButtonElement=i}}},{key:"updateSkipCountdown",value:function(e){var t,n=this.getFirstLinearCreative(),r=null!=(t=this.config.skipOffset)?t:null==n?void 0:n.skipOffset;if(r&&this.skipButtonElement){var i=Math.max(0,r-e);this.updateState({skipCountdown:i}),i<=0&&!this.state.canSkip?(this.updateState({canSkip:!0}),this.skipButtonElement.textContent=this.config.skipButtonText,this.skipButtonElement.style.opacity="1",this.skipButtonElement.focus()):i>0&&(this.skipButtonElement.textContent="Skip in ".concat(Math.ceil(i),"s"),this.skipButtonElement.style.opacity="0.6")}}},{key:"skip",value:function(){var e,t,n;this.state.canSkip?(null==(e=this.tracker)||e.track("skip"),this.emit({type:"skip"}),null==(n=(t=this.config).onSkip)||n.call(t),this.destroy(),this.log("Ad skipped")):this.log("Skip not available yet")}},{key:"handleComplete",value:function(){var e,t,n;this.updateState({status:y.Completed}),null==(e=this.tracker)||e.track("complete"),this.emit({type:"complete"}),null==(n=(t=this.config).onComplete)||n.call(t),this.log("Ad completed")}},{key:"handleError",value:function(e){var t,n,r;this.updateState({status:y.Error,error:e});var i,o=[],s=a(this.ads);try{for(s.s();!(i=s.n()).done;){var l=i.value;o.push.apply(o,c(l.errors))}}catch(u){s.e(u)}finally{s.f()}null==(t=this.tracker)||t.fireError(o,e.code),this.emit({type:"error",data:e}),null==(r=(n=this.config).onError)||r.call(n,e),this.log("Error: ".concat(e.message))}},{key:"setupFocusManagement",value:function(){var e=this;this.focusTrap=document.createElement("div"),this.focusTrap.tabIndex=0,this.focusTrap.style.cssText="position: absolute; opacity: 0; width: 0; height: 0;",this.config.container.appendChild(this.focusTrap),this.focusTrap.focus(),this.boundKeyHandler=function(t){var n=e.platform.normalizeKeyCode(t.keyCode);n&&(t.preventDefault(),t.stopPropagation(),e.handleKeyAction(n))},document.addEventListener("keydown",this.boundKeyHandler,!0)}},{key:"setupProgressUI",value:function(){var e=document.createElement("div");e.style.cssText="\n position: absolute;\n top: 20px;\n left: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 14px;\n font-family: sans-serif;\n z-index: 101;\n display: block;\n white-space: nowrap;\n ",e.innerHTML='\n <span style="display: inline-block; vertical-align: middle; margin-right: 8px; background: #f4b400; color: #000; padding: 2px 4px; border-radius: 2px; font-weight: bold; font-size: 12px;">Ad</span>\n <span id="adgent-progress-text" style="display: inline-block; vertical-align: middle;">1 of '.concat(this.ads.length," • 0:00</span>\n "),this.config.container.appendChild(e),this.progressElement=e}},{key:"updateProgressUI",value:function(e,t){if(this.progressElement){var n=Math.ceil(t-e),r=Math.floor(n/60),i=n%60,a="".concat(r,":").concat(i.toString().padStart(2,"0")),o=this.progressElement.querySelector("#adgent-progress-text");if(o){o.textContent="".concat(1," of ").concat(this.ads.length," • ").concat(a)}}}},{key:"handleKeyAction",value:function(e){var t,n;switch(this.log("Key action: ".concat(e)),e){case M.Enter:this.state.status===y.WaitingForInteraction?this.onStartClick():this.state.canSkip&&this.skip();break;case M.Back:this.config.onClose?(this.log("Back pressed - user cancelling"),this.config.onClose(),this.destroy()):(this.log("Back pressed - skipping"),this.emit({type:"skip"}),this.config.onSkip&&this.config.onSkip(),this.destroy());break;case M.Play:null==(t=this.videoElement)||t.play();break;case M.Pause:null==(n=this.videoElement)||n.pause();case M.Left:case M.Right:case M.Up:case M.Down:}}},{key:"unmute",value:function(){var e;this.videoElement&&(this.videoElement.muted=!1,this.updateState({muted:!1}),null==(e=this.tracker)||e.track("unmute"),this.emit({type:"unmute"}))}},{key:"mute",value:function(){var e;this.videoElement&&(this.videoElement.muted=!0,this.updateState({muted:!0}),null==(e=this.tracker)||e.track("mute"),this.emit({type:"mute"}))}},{key:"on",value:function(e){var t=this;return this.listeners.add(e),function(){return t.listeners.delete(e)}}},{key:"getState",value:function(){return ce({},this.state)}},{key:"destroy",value:function(){var e,t,n,r,i,a=this;this.boundKeyHandler&&(document.removeEventListener("keydown",this.boundKeyHandler,!0),this.boundKeyHandler=null),this.videoElement&&(this.eventListeners.forEach(function(e,t){var n;null==(n=a.videoElement)||n.removeEventListener(t,e)}),this.eventListeners.clear(),this.videoElement.remove()),null==(e=this.overlayElement)||e.remove(),null==(t=this.skipButtonElement)||t.remove(),null==(n=this.progressElement)||n.remove(),null==(r=this.focusTrap)||r.remove(),this.videoElement=null,this.overlayElement=null,this.skipButtonElement=null,this.progressElement=null,this.focusTrap=null,null==(i=this.tracker)||i.reset(),this.quartilesFired.clear(),this.listeners.clear(),this.ads=[],this.emit({type:"destroy"}),this.log("Player destroyed")}},{key:"updateState",value:function(e){this.state=ce(ce({},this.state),e)}},{key:"emit",value:function(e){var t,n=a(this.listeners);try{for(n.s();!(t=n.n()).done;){var r=t.value;try{r(e)}catch(i){this.log("Listener error: ".concat(i))}}}catch(o){n.e(o)}finally{n.f()}}},{key:"createError",value:function(e,t){return{code:e,message:t,recoverable:arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}},{key:"log",value:function(e){this.config.debug&&this.platform.debug(e)}}])}();e.AdPlayer=he,e.AdTracker=ie,e.AdgentSDK=he,e.DEFAULT_KEY_CODES=F,e.KeyAction=M,e.PLATFORM_DETECTION_PATTERNS=L,e.Platform=I,e.PlatformAdapter=H,e.PlaybackStatus=y,e.VASTErrorCode=m,e.VASTParser=x,e.getPlatformAdapter=X,e.replaceMacros=C,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ declare class AdPlayer {
|
|
|
45
45
|
private quartilesFired;
|
|
46
46
|
private boundKeyHandler;
|
|
47
47
|
private focusTrap;
|
|
48
|
+
private hasStarted;
|
|
48
49
|
constructor(config: AdPlayerConfig);
|
|
49
50
|
/**
|
|
50
51
|
* Initialize the SDK: fetch VAST, create video element, attempt autoplay
|
|
@@ -68,6 +69,10 @@ declare class AdPlayer {
|
|
|
68
69
|
* Show interactive overlay for manual ad start (autoplay fallback)
|
|
69
70
|
*/
|
|
70
71
|
private showStartOverlay;
|
|
72
|
+
/**
|
|
73
|
+
* Handle ad click (video element click)
|
|
74
|
+
*/
|
|
75
|
+
private onAdClick;
|
|
71
76
|
/**
|
|
72
77
|
* Handle start button click (from overlay)
|
|
73
78
|
*/
|
|
@@ -456,10 +461,16 @@ export declare interface IPlatformAdapter {
|
|
|
456
461
|
*/
|
|
457
462
|
getKeyCodesForAction(action: KeyAction): number[];
|
|
458
463
|
/**
|
|
464
|
+
/**
|
|
459
465
|
* Check if a specific codec is supported
|
|
460
466
|
* @param codec - MIME type with codec (e.g., 'video/mp4; codecs="hvc1"')
|
|
461
467
|
*/
|
|
462
468
|
isCodecSupported(codec: string): boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Open an external link in a new tab/window
|
|
471
|
+
* @param url - The URL to open
|
|
472
|
+
*/
|
|
473
|
+
openExternalLink(url: string): void;
|
|
463
474
|
}
|
|
464
475
|
|
|
465
476
|
/** Remote control key actions */
|
|
@@ -642,6 +653,11 @@ export declare class PlatformAdapter implements IPlatformAdapter {
|
|
|
642
653
|
preferredCodec: string;
|
|
643
654
|
maxResolution: string;
|
|
644
655
|
};
|
|
656
|
+
/**
|
|
657
|
+
* Open an external link in a new tab/window
|
|
658
|
+
* Safe to call on all platforms (will just log on non-web)
|
|
659
|
+
*/
|
|
660
|
+
openExternalLink(url: string): void;
|
|
645
661
|
/**
|
|
646
662
|
* Show debug message using platform-specific native notifications
|
|
647
663
|
* Falls back to console.log
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adgent-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Lightweight, framework-agnostic VAST Player SDK for Smart TV platforms",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/adgent-sdk.umd.js",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"vidaa",
|
|
35
35
|
"sdk"
|
|
36
36
|
],
|
|
37
|
-
"author": "",
|
|
38
|
-
"license": "
|
|
37
|
+
"author": "Asadbek Omonboyev",
|
|
38
|
+
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"fast-xml-parser": "^4.3.4"
|
|
41
41
|
},
|