@mixpeek/prebid 1.0.0 → 1.0.2
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/CHANGELOG.md +1 -1
- package/ENDPOINTS.md +21 -27
- package/QUICKSTART.md +5 -5
- package/README.md +225 -333
- package/dist/mixpeekContextAdapter.js +1 -1
- package/dist/mixpeekContextAdapter.js.map +1 -1
- package/docs/MIGRATION_V2.md +4 -4
- package/docs/api-reference.md +1 -1
- package/docs/health-check.md +5 -5
- package/docs/integration-guide.md +5 -5
- package/package.json +10 -4
- package/src/api/mixpeekClient.js +133 -32
- package/src/config/constants.js +13 -8
- package/src/modules/mixpeekContextAdapter.js +55 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see mixpeekContextAdapter.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MixpeekContextAdapter=t():e.MixpeekContextAdapter=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>Ee});var r="undefined"!=typeof process&&process.env&&process.env.MIXPEEK_API_ENDPOINT?process.env.MIXPEEK_API_ENDPOINT:"undefined"!=typeof window&&window.MIXPEEK_API_ENDPOINT?window.MIXPEEK_API_ENDPOINT:"https://api.mixpeek.com",n={COLLECTIONS:"/v1/collections",DOCUMENTS:"/v1/collections/{collectionId}/documents",FEATURES:"/v1/collections/{collectionId}/documents/{documentId}/features",FEATURE_EXTRACTORS:"/v1/collections/features/extractors",RETRIEVERS:"/v1/retrievers/debug-inference"},o="auto",i="video",a="mixpeek_ctx_",c="Mixpeek-Prebid-Adapter/".concat("1.0.0");function u(e){return u="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},u(e)}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}const f=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.debug=!1,this.prefix="[".concat("mixpeek","]")},t=[{key:"setDebug",value:function(e){this.debug=e}},{key:"info",value:function(){if(this.debug){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[this.prefix].concat(r))}}},{key:"warn",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[this.prefix].concat(r))}},{key:"error",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[this.prefix].concat(r))}},{key:"group",value:function(e){this.debug&&console.group&&console.group("".concat(this.prefix," ").concat(e))}},{key:"groupEnd",value:function(){this.debug&&console.groupEnd&&console.groupEnd()}},{key:"time",value:function(e){this.debug&&console.time&&console.time("".concat(this.prefix," ").concat(e))}},{key:"timeEnd",value:function(e){this.debug&&console.timeEnd&&console.timeEnd("".concat(this.prefix," ").concat(e))}},{key:"table",value:function(e){this.debug&&console.table&&console.table(e)}}],t&&l(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function h(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(p(e)+" is not iterable")}function d(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return m(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(m(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,m(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,m(f,"constructor",l),m(l,"constructor",u),u.displayName="GeneratorFunction",m(l,o,"GeneratorFunction"),m(f),m(f,o,"Generator"),m(f,n,function(){return this}),m(f,"toString",function(){return"[object Generator]"}),(d=function(){return{w:i,m:h}})()}function m(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,r,n){function i(t,r){m(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},m(e,t,r,n)}function y(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return p="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},p(e)}function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function g(e){return null!==e&&"object"===p(e)&&!Array.isArray(e)}function b(e,t){var r=Object.assign({},e);return g(e)&&g(t)&&Object.keys(t).forEach(function(n){var o,i,a;g(t[n])&&n in e?r[n]=b(e[n],t[n]):Object.assign(r,(o={},i=n,a=t[n],(i=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(i))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,o))}),r}function w(e){var t=[];return e.apiKey&&"string"==typeof e.apiKey||t.push("apiKey is required and must be a string"),e.collectionId&&"string"==typeof e.collectionId||t.push("collectionId is required and must be a string"),e.timeout&&("number"!=typeof e.timeout||e.timeout<0)&&t.push("timeout must be a positive number"),e.cacheTTL&&("number"!=typeof e.cacheTTL||e.cacheTTL<0)&&t.push("cacheTTL must be a positive number"),t.length>0?{valid:!1,errors:t,code:"INVALID_CONFIG"}:{valid:!0}}function x(e){try{return new URL(e).hostname}catch(e){return""}}function _(e){return e?e.replace(/\s+/g," ").replace(/[\r\n\t]/g," ").trim():""}function A(){return"undefined"!=typeof window&&"undefined"!=typeof document}function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{return JSON.parse(e)}catch(e){return f.warn("Failed to parse JSON:",e),t}}function I(e){return k.apply(this,arguments)}function k(){var e;return e=d().m(function e(t){var r,n,o,i,a,c,u=arguments;return d().w(function(e){for(;;)switch(e.n){case 0:r=u.length>1&&void 0!==u[1]?u[1]:3,n=u.length>2&&void 0!==u[2]?u[2]:100,i=d().m(function e(){var i,a,u;return d().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t();case 1:return a=e.v,e.a(2,{v:a});case 2:if(e.p=2,u=e.v,o=u,!(c<r)){e.n=3;break}return i=n*Math.pow(2,c-1),f.warn("Attempt ".concat(c," failed, retrying in ").concat(i,"ms...")),e.n=3,new Promise(function(e){return setTimeout(e,i)});case 3:return e.a(2)}},e,null,[[0,2]])}),c=1;case 1:if(!(c<=r)){e.n=4;break}return e.d(h(i()),2);case 2:if(!(a=e.v)){e.n=3;break}return e.a(2,a.v);case 3:c++,e.n=1;break;case 4:throw o;case 5:return e.a(2)}},e)}),k=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){y(i,n,o,a,c,"next",e)}function c(e){y(i,n,o,a,c,"throw",e)}a(void 0)})},k.apply(this,arguments)}function E(e){return new Promise(function(t,r){setTimeout(function(){return r(new Error("Timeout"))},e)})}function C(e,t){return Promise.race([e,E(t)])}function O(){return Math.floor(Date.now()/1e3)}function j(e,t){return O()-e>t}function P(e){return P="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},P(e)}function T(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||B(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 B(e,t){if(e){if("string"==typeof e)return q(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)?q(e,t):void 0}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,D(n.key),n)}}function D(e){var t=function(e){if("object"!=P(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}const L=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.memoryCache=new Map,this.useLocalStorage=this._checkLocalStorageAvailable(),this.ttl=300},t=[{key:"_checkLocalStorageAvailable",value:function(){try{var e="__mixpeek_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return f.warn("localStorage not available, using memory cache only"),!1}}},{key:"_getCacheKey",value:function(e){return"".concat(a).concat("v1","_").concat(e)}},{key:"setTTL",value:function(e){this.ttl=e}},{key:"get",value:function(e){var t=this._getCacheKey(e);if(this.memoryCache.has(t)){var r=this.memoryCache.get(t);if(!j(r.timestamp,this.ttl))return f.info("Cache hit (memory):",e),r.data;f.info("Cache expired (memory):",e),this.memoryCache.delete(t)}if(this.useLocalStorage)try{var n=localStorage.getItem(t);if(n){var o=S(n);if(o&&!j(o.timestamp,this.ttl))return f.info("Cache hit (localStorage):",e),this.memoryCache.set(t,o),o.data;f.info("Cache expired (localStorage):",e),localStorage.removeItem(t)}}catch(e){f.warn("Error reading from localStorage:",e)}return f.info("Cache miss:",e),null}},{key:"set",value:function(e,t){var r=this._getCacheKey(e),n={data:t,timestamp:O()};try{return this.memoryCache.set(r,n),this.useLocalStorage&&localStorage.setItem(r,JSON.stringify(n)),f.info("Cached:",e),!0}catch(e){return f.warn("Error setting cache:",e),!1}}},{key:"remove",value:function(e){var t=this._getCacheKey(e);try{return this.memoryCache.delete(t),this.useLocalStorage&&localStorage.removeItem(t),f.info("Cache removed:",e),!0}catch(e){return f.warn("Error removing cache:",e),!1}}},{key:"clear",value:function(){try{return this.memoryCache.clear(),this.useLocalStorage&&Object.keys(localStorage).forEach(function(e){e.startsWith(a)&&localStorage.removeItem(e)}),f.info("Cache cleared"),!0}catch(e){return f.warn("Error clearing cache:",e),!1}}},{key:"getStats",value:function(){var e=0,t=0;if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(r){r.startsWith(a)&&(t++,e+=localStorage.getItem(r).length)})}catch(e){f.warn("Error getting cache stats:",e)}return{memoryCount:this.memoryCache.size,localStorageCount:t,localStorageSize:e,ttl:this.ttl}}},{key:"prune",value:function(){var e,t=this,r=0,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=B(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(this.memoryCache.entries());try{for(n.s();!(e=n.n()).done;){var o=T(e.value,2),i=o[0];j(o[1].timestamp,this.ttl)&&(this.memoryCache.delete(i),r++)}}catch(e){n.e(e)}finally{n.f()}if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(e){if(e.startsWith(a)){var n=S(localStorage.getItem(e));n&&j(n.timestamp,t.ttl)&&(localStorage.removeItem(e),r++)}})}catch(e){f.warn("Error pruning cache:",e)}return r>0&&f.info("Pruned ".concat(r," expired cache items")),r}}],t&&F(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function N(e){return N="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},N(e)}function M(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return R(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(R(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,R(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,R(f,"constructor",l),R(l,"constructor",u),u.displayName="GeneratorFunction",R(l,o,"GeneratorFunction"),R(f),R(f,o,"Generator"),R(f,n,function(){return this}),R(f,"toString",function(){return"[object Generator]"}),(M=function(){return{w:i,m:h}})()}function R(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}R=function(e,t,r,n){function i(t,r){R(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},R(e,t,r,n)}function G(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach(function(t){z(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function H(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function U(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){H(i,n,o,a,c,"next",e)}function c(e){H(i,n,o,a,c,"throw",e)}a(void 0)})}}function z(e,t,r){return(t=V(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,V(n.key),n)}}function V(e){var t=function(e){if("object"!=N(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==N(t)?t:t+""}const X=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.apiKey=t.apiKey||"",this.endpoint=t.endpoint||r,this.namespace=t.namespace||null,this.timeout=t.timeout||250,this.retryAttempts=t.retryAttempts||2},t=[{key:"configure",value:function(e){Object.assign(this,e)}},{key:"_buildHeaders",value:function(){var e=z(z(z({},"Content-Type","application/json"),"Authorization","Bearer ".concat(this.apiKey)),"User-Agent",c);return this.namespace&&(e["X-Namespace"]=this.namespace),e}},{key:"_request",value:(d=U(M().m(function e(t){var r,n,o,i,a,c,u,l=arguments;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=l.length>1&&void 0!==l[1]?l[1]:{},n="".concat(this.endpoint).concat(t),o=this._buildHeaders(),i=K(K({},r),{},{headers:K(K({},o),r.headers)}),f.info("API Request: ".concat(r.method||"GET"," ").concat(n)),f.time("API Request: ".concat(t)),e.p=1,e.n=2,C(fetch(n,i),this.timeout);case 2:if(a=e.v,f.timeEnd("API Request: ".concat(t)),a.ok){e.n=4;break}return e.n=3,this._handleErrorResponse(a);case 3:throw e.v;case 4:return e.n=5,a.json();case 5:return c=e.v,f.info("API Response:",{status:a.status,path:t}),e.a(2,c);case 6:if(e.p=6,u=e.v,f.timeEnd("API Request: ".concat(t)),"Timeout"!==u.message){e.n=7;break}throw{code:"API_TIMEOUT",message:"Request timeout after ".concat(this.timeout,"ms"),path:t};case 7:throw u;case 8:return e.a(2)}},e,this,[[1,6]])})),function(e){return d.apply(this,arguments)})},{key:"_handleErrorResponse",value:(h=U(M().m(function e(t){var r,n;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r="API error: ".concat(t.status," ").concat(t.statusText),e.p=1,e.n=2,t.json();case 2:n=e.v,r=n.message||n.error||r,e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2,{code:"API_ERROR",message:r,status:t.status})}},e,null,[[1,3]])})),function(e){return h.apply(this,arguments)})},{key:"createDocument",value:(s=U(M().m(function e(t,r){var o,i,a=this;return M().w(function(e){for(;;)if(0===e.n)return o=n.DOCUMENTS.replace("{collectionId}",t),i={object_id:r.objectId||v(),metadata:r.metadata||{},features:r.features||[]},e.a(2,I(function(){return a._request(o,{method:"POST",body:JSON.stringify(i)})},this.retryAttempts))},e,this)})),function(e,t){return s.apply(this,arguments)})},{key:"getDocument",value:(l=U(M().m(function e(t,r){var o;return M().w(function(e){for(;;)if(0===e.n)return o="".concat(n.DOCUMENTS.replace("{collectionId}",t),"/").concat(r),e.a(2,this._request(o,{method:"GET"}))},e,this)})),function(e,t){return l.apply(this,arguments)})},{key:"processContent",value:(u=U(M().m(function e(t,r){var n,o,i,a,c=this,u=arguments;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:[],f.group("Processing content with Mixpeek"),f.info("Collection:",t),f.info("Feature Extractors:",n),e.p=1,o=n.map(function(e){var t={feature_extractor_id:"string"==typeof e?e:e.feature_extractor_id};return"object"===N(e)&&e.payload?t.payload=e.payload:t.payload=c._buildFeaturePayload(r),t}),e.n=2,this.createDocument(t,{objectId:this._generateContentId(r),metadata:{url:r.url,title:r.title,timestamp:Date.now()},features:o});case 2:return i=e.v,f.info("Document created:",i.document_id),f.groupEnd(),e.a(2,i);case 3:throw e.p=3,a=e.v,f.error("Error processing content:",a),f.groupEnd(),a;case 4:return e.a(2)}},e,this,[[1,3]])})),function(e,t){return u.apply(this,arguments)})},{key:"_buildFeaturePayload",value:function(e){var t={};return e.text&&(t.text=e.text),e.url&&(t.url=e.url),e.src&&void 0!==e.duration&&(t.video_url=e.src,t.title=e.title,t.description=e.description),e.src&&e.width&&e.height&&!e.duration&&(t.image_url=e.src,t.alt_text=e.alt),e.metadata&&(t.metadata=e.metadata),t}},{key:"_generateContentId",value:function(e){return e.url?"url_".concat(e.url.split("?")[0]):e.src?"src_".concat(e.src.split("?")[0]):v()}},{key:"listFeatureExtractors",value:(a=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request(n.FEATURE_EXTRACTORS,{method:"GET"}))},e,this)})),function(){return a.apply(this,arguments)})},{key:"getFeatureExtractor",value:(i=U(M().m(function e(t){var r;return M().w(function(e){for(;;)if(0===e.n)return r=n.FEATURE_EXTRACTORS+"/".concat(t),e.a(2,this._request(r,{method:"GET"}))},e,this)})),function(e){return i.apply(this,arguments)})},{key:"healthCheck",value:(o=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request("/v1/health",{method:"GET"}))},e,this)})),function(){return o.apply(this,arguments)})}],t&&W(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,o,i,a,u,l,s,h,d}();function J(e){var t,r=e.querySelector("h1"),n=e.querySelector('[itemprop="headline"]');return _((null===(t=r||n)||void 0===t?void 0:t.textContent)||"")}function $(e){var t=e.querySelector('[itemprop="author"]')||e.querySelector('[rel="author"]')||e.querySelector(".author");return _((null==t?void 0:t.textContent)||"")}function Q(e){var t=e.querySelector('[itemprop="datePublished"]')||e.querySelector("time[datetime]");return(null==t?void 0:t.getAttribute("datetime"))||(null==t?void 0:t.textContent)||""}function Y(){return null!==document.querySelector("article")||null!==document.querySelector('[itemtype*="Article"]')||null!==document.querySelector('meta[property="og:type"][content="article"]')}function Z(e){if(e.src)return e.src;var t=e.querySelector("source");return t&&t.src?t.src:e.currentSrc?e.currentSrc:""}function ee(e){var t,r,n=e.getAttribute("data-title")||e.getAttribute("title")||e.getAttribute("aria-label");if(n)return _(n);var o=e.closest("[data-video-title]");if(o)return _(o.getAttribute("data-video-title"));var i=(null===(t=e.previousElementSibling)||void 0===t?void 0:t.querySelector("h1, h2, h3"))||(null===(r=e.parentElement)||void 0===r?void 0:r.querySelector("h1, h2, h3"));return i?_(i.textContent):""}function te(e){var t=e.getAttribute("data-description")||e.getAttribute("aria-description");if(t)return _(t);var r=e.closest("[data-video-description]");return r?_(r.getAttribute("data-video-description")):""}function re(e){var t={};return Array.from(e.attributes).forEach(function(e){if(e.name.startsWith("data-")){var r=e.name.replace("data-","").replace(/-/g,"_");t[r]=e.value}}),t}function ne(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return r>0?t/r:0}function oe(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ie(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)?ie(e,t):void 0}}(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 ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ae={node_technology:"IAB19",node_tech_computing:"IAB19",node_tech_ai:"IAB19-11",node_tech_artificial_intelligence:"IAB19-11",node_tech_machine_learning:"IAB19-11",node_tech_software:"IAB19-18",node_tech_hardware:"IAB19-19",node_tech_mobile:"IAB19-20",node_electronics_phones:"IAB19-20",node_tech_internet:"IAB19-21",sports:"IAB17",sports_football:"IAB17-3",sports_soccer:"IAB17-44",sports_basketball:"IAB17-4",sports_baseball:"IAB17-5",sports_tennis:"IAB17-37",news:"IAB12",news_politics:"IAB12-2",news_business:"IAB12-3",news_technology:"IAB12-6",business:"IAB13",business_finance:"IAB13-7",business_investing:"IAB13-5",entertainment:"IAB9",entertainment_movies:"IAB9-7",entertainment_tv:"IAB9-23",entertainment_music:"IAB9-8",health:"IAB7",health_fitness:"IAB7-18",health_nutrition:"IAB7-30",travel:"IAB20",travel_hotels:"IAB20-12",food:"IAB8",food_cooking:"IAB8-5",food_restaurants:"IAB8-9",automotive:"IAB2",automotive_cars:"IAB2",real_estate:"IAB21",education:"IAB5",fashion:"IAB18",fashion_beauty:"IAB18-1",home:"IAB10",home_garden:"IAB10-3",science:"IAB15",arts:"IAB1",arts_design:"IAB1-4"},ce={technology:"IAB19",tech:"IAB19",ai:"IAB19-11","artificial intelligence":"IAB19-11","machine learning":"IAB19-11",software:"IAB19-18",hardware:"IAB19-19",mobile:"IAB19-20",computing:"IAB19",sports:"IAB17",football:"IAB17-3",soccer:"IAB17-44",basketball:"IAB17-4",baseball:"IAB17-5",news:"IAB12",politics:"IAB12-2",business:"IAB13",finance:"IAB13-7",investing:"IAB13-5",entertainment:"IAB9",movies:"IAB9-7",television:"IAB9-23",music:"IAB9-8",gaming:"IAB9-30",health:"IAB7",fitness:"IAB7-18",wellness:"IAB7",nutrition:"IAB7-30",travel:"IAB20",food:"IAB8",automotive:"IAB2",cars:"IAB2","real estate":"IAB21",education:"IAB5",fashion:"IAB18",home:"IAB10",science:"IAB15",arts:"IAB1"};function ue(e){return!(!e||"string"!=typeof e)&&/^IAB\d+(-\d+)?$/.test(e)}function le(e){if(!e||"string"!=typeof e)return null;var t=e.match(/IAB\d+(-\d+)?/);return t?t[0]:null}function se(e){if(!e)return null;if(e.label){if(ue(e.label))return e.label;var t=le(e.label);if(t)return t}if(e.nodeId||e.node_id){var r=e.nodeId||e.node_id;if(ue(r))return r;var n=le(r);if(n)return n}if(e.nodeId||e.node_id){var o=(e.nodeId||e.node_id).toLowerCase();if(ae[o])return ae[o];for(var i=o.replace(/[_-]/g,""),a=0,c=Object.entries(ae);a<c.length;a++){var u=oe(c[a],2),l=u[0],s=u[1];if(l.replace(/[_-]/g,"")===i)return s}}if(e.label){var f=e.label.toLowerCase();if(ce[f])return ce[f];for(var h=0,d=Object.entries(ce);h<d.length;h++){var m=oe(d[h],2),y=m[0],p=m[1];if(f.includes(y))return p}}if(e.path)for(var v=Array.isArray(e.path)?e.path.join(" ").toLowerCase():e.path.toLowerCase(),g=0,b=Object.entries(ce);g<b.length;g++){var w=oe(b[g],2),x=w[0],_=w[1];if(v.includes(x))return _}return null}function fe(e){return fe="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},fe(e)}function he(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,de(n.key),n)}}function de(e){var t=function(e){if("object"!=fe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=fe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fe(t)?t:t+""}var me="mixpeek_prev_ad_v1";const ye=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.lastAd=null,this.storageAvailable=this._checkLocalStorage(),this._loadFromStorage()},t=[{key:"_checkLocalStorage",value:function(){if(!A())return!1;try{var e="__mixpeek_prev_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch(e){return!1}}},{key:"_loadFromStorage",value:function(){if(this.storageAvailable)try{var e=localStorage.getItem(me);if(e){var t=S(e);t&&"object"===fe(t)&&(this.lastAd=t)}}catch(e){f.warn("Failed to load previous ad from storage:",e)}}},{key:"_persist",value:function(){if(this.storageAvailable)try{localStorage.setItem(me,JSON.stringify(this.lastAd))}catch(e){f.warn("Failed to persist previous ad:",e)}}},{key:"record",value:function(e){var t,r;if(e&&"object"===fe(e)){var n={creativeId:e.creativeId||e.creative_id||null,bidder:e.bidder||e.bidderCode||null,adUnitCode:e.adUnitCode||null,cpm:"number"==typeof e.cpm?e.cpm:null,currency:e.currency||null,categories:Array.isArray(null===(t=e.meta)||void 0===t?void 0:t.adServerCatId)?e.meta.adServerCatId:null!==(r=e.meta)&&void 0!==r&&r.primaryCat?[e.meta.primaryCat]:[],timestamp:Date.now()};this.lastAd=n,this._persist()}}},{key:"getLast",value:function(){return this.lastAd}},{key:"clear",value:function(){if(this.lastAd=null,this.storageAvailable)try{localStorage.removeItem(me)}catch(e){}}}],t&&he(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function pe(e){return pe="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},pe(e)}function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(r),!0).forEach(function(t){be(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ve(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function be(e,t,r){return(t=Ie(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function we(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return xe(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(xe(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,xe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,xe(f,"constructor",l),xe(l,"constructor",u),u.displayName="GeneratorFunction",xe(l,o,"GeneratorFunction"),xe(f),xe(f,o,"Generator"),xe(f,n,function(){return this}),xe(f,"toString",function(){return"[object Generator]"}),(we=function(){return{w:i,m:h}})()}function xe(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}xe=function(e,t,r,n){function i(t,r){xe(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},xe(e,t,r,n)}function _e(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function Ae(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){_e(i,n,o,a,c,"next",e)}function c(e){_e(i,n,o,a,c,"throw",e)}a(void 0)})}}function Se(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ie(n.key),n)}}function Ie(e){var t=function(e){if("object"!=pe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=pe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==pe(t)?t:t+""}var ke=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={},this.client=null,this.initialized=!1,this.processing=!1,this.contextData=null,this.events={},this.healthCheckPerformed=!1},t=[{key:"init",value:(l=Ae(we().m(function e(t){var r,n;return we().w(function(e){for(;;)switch(e.n){case 0:if(f.info("Initializing Mixpeek Context Adapter"),f.group("Configuration"),(r=w(t)).valid){e.n=1;break}return f.error("Invalid configuration:",r.errors),f.groupEnd(),e.a(2,!1);case 1:if(this.config=b({endpoint:"https://api.mixpeek.com",timeout:250,cacheTTL:300,retryAttempts:2,mode:o,enableCache:!0,debug:!1,healthCheck:"lazy",featureExtractors:["taxonomy"],batchSize:1},t),f.setDebug(this.config.debug),this.client=new X({apiKey:this.config.apiKey,endpoint:this.config.endpoint,namespace:this.config.namespace,timeout:this.config.timeout,retryAttempts:this.config.retryAttempts}),this.config.enableCache&&L.setTTL(this.config.cacheTTL),f.table({"API Endpoint":this.config.endpoint,"Collection ID":this.config.collectionId,Namespace:this.config.namespace||"default",Mode:this.config.mode,Timeout:"".concat(this.config.timeout,"ms"),"Cache TTL":"".concat(this.config.cacheTTL,"s"),"Feature Extractors":this.config.featureExtractors.join(", "),"Health Check":this.config.healthCheck}),f.groupEnd(),"eager"!==this.config.healthCheck){e.n=3;break}return f.info("Performing health check..."),e.n=2,this._performHealthCheck();case 2:(n=e.v).healthy?f.info("Health check passed:",n.message):(f.warn("Health check failed, but continuing initialization"),f.warn("API may be unavailable:",n.error)),e.n=4;break;case 3:"lazy"===this.config.healthCheck&&f.info("Health check will be performed on first request");case 4:return this.initialized=!0,f.info("Mixpeek Context Adapter initialized successfully"),e.a(2,!0)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"_performHealthCheck",value:(u=Ae(we().m(function e(){var t,r,n,o;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,t=performance.now(),e.n=1,this.client.healthCheck();case 1:return r=e.v,n=performance.now()-t,e.a(2,{healthy:!0,status:r.status||"ok",version:r.version,latency:Math.round(n),message:"API responding in ".concat(Math.round(n),"ms")});case 2:return e.p=2,o=e.v,e.a(2,{healthy:!1,error:o.message,message:"API health check failed"})}},e,this,[[0,2]])})),function(){return u.apply(this,arguments)})},{key:"enrichAdUnits",value:(c=Ae(we().m(function e(t){var r,n,o,i,a;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.initialized){e.n=1;break}return f.warn("Adapter not initialized"),e.a(2,t);case 1:if(!this.processing){e.n=2;break}return f.warn("Already processing context"),e.a(2,t);case 2:return this.processing=!0,r=performance.now(),e.p=3,e.n=4,this.getContext();case 4:if(n=e.v){e.n=5;break}return f.warn("No context data available"),e.a(2,t);case 5:return this.contextData=n,o=this._injectTargetingKeys(t,n),i=performance.now()-r,f.info("Context enrichment completed in ".concat(i.toFixed(2),"ms")),i>100&&f.warn("Enrichment took ".concat(i.toFixed(2),"ms (threshold: ").concat(100,"ms)")),this._emitEvent("mixpeekContextReady",n),e.a(2,o);case 6:return e.p=6,a=e.v,f.error("Error enriching ad units:",a),this._emitEvent("mixpeekContextError",a),e.a(2,t);case 7:return e.p=7,this.processing=!1,e.f(7);case 8:return e.a(2)}},e,this,[[3,6,7,8]])})),function(e){return c.apply(this,arguments)})},{key:"getContext",value:(a=Ae(we().m(function e(){var t,r,n,o,i,a,c,u;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(f.time("getContext"),e.p=1,"lazy"!==this.config.healthCheck||this.healthCheckPerformed){e.n=3;break}return f.info("Performing lazy health check..."),e.n=2,this._performHealthCheck();case 2:t=e.v,this.healthCheckPerformed=!0,t.healthy?f.info("Health check passed:",t.message):(f.warn("Health check failed:",t.error),f.warn("Proceeding anyway, errors will be handled gracefully"));case 3:return r=this._detectContentMode(),f.info("Content mode:",r),e.n=4,this._extractContent(r);case 4:if(n=e.v){e.n=5;break}return f.warn("No content extracted"),f.timeEnd("getContext"),e.a(2,null);case 5:if(o=this._generateCacheKey(n,r),!this.config.enableCache){e.n=6;break}if(!(i=L.get(o))){e.n=6;break}return f.info("Using cached context"),f.timeEnd("getContext"),this._emitEvent("mixpeekContextCached",i),e.a(2,i);case 6:return f.info("Processing content with Mixpeek API"),this._emitEvent("mixpeekApiRequest",{content:n,mode:r}),e.n=7,this.client.processContent(this.config.collectionId,n,this.config.featureExtractors);case 7:return a=e.v,this._emitEvent("mixpeekApiResponse",a),c=this._parseContext(a,n,r),this.config.enableCache&&L.set(o,c),f.timeEnd("getContext"),e.a(2,c);case 8:throw e.p=8,u=e.v,f.error("Error getting context:",u),f.timeEnd("getContext"),u;case 9:return e.a(2)}},e,this,[[1,8]])})),function(){return a.apply(this,arguments)})},{key:"_detectContentMode",value:function(){return this.config.mode!==o?this.config.mode:null!==document.querySelector("video")||null!==document.querySelector('iframe[src*="youtube.com"]')||null!==document.querySelector('iframe[src*="vimeo.com"]')?i:(Y()||(e=document.querySelectorAll("img"),Array.from(e).some(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200})),"page");var e}},{key:"_extractContent",value:(n=Ae(we().m(function e(t){var r;return we().w(function(e){for(;;)switch(e.n){case 0:if(A()){e.n=1;break}return f.warn("Not in browser environment"),e.a(2,null);case 1:f.info("Extracting ".concat(t," content")),r=t,e.n=r===i?2:"image"===r?3:4;break;case 2:return e.a(2,this._extractVideoContent());case 3:return e.a(2,this._extractImageContent());case 4:return e.a(2,this._extractPageContent());case 5:return e.a(2)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"_extractPageContent",value:function(){var e=function(){f.time("extractPageContent");try{var e={url:window.location.href,domain:x(window.location.href),title:document.title,description:(i=document.querySelector('meta[name="description"]')||document.querySelector('meta[property="og:description"]'),i?_(i.content):""),text:(o=document.body.cloneNode(!0),o.querySelectorAll("script, style, iframe, nav, footer, aside, .ad, .advertisement").forEach(function(e){return e.remove()}),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e4;return!e||e.length<=t?e:(f.warn("Content truncated from ".concat(e.length," to ").concat(t," characters")),e.substring(0,t))}(_(o.textContent||o.innerText||""),5e4)),keywords:(n=document.querySelector('meta[name="keywords"]'),n?n.content.split(",").map(function(e){return e.trim()}).filter(Boolean):[]),ogTags:(r={},document.querySelectorAll('meta[property^="og:"]').forEach(function(e){var t=e.getAttribute("property").replace("og:","");r[t]=e.content}),r),structuredData:(t=[],document.querySelectorAll('script[type="application/ld+json"]').forEach(function(e){try{var r=JSON.parse(e.textContent);t.push(r)}catch(e){f.warn("Failed to parse structured data:",e)}}),t),language:document.documentElement.lang||"en"};return f.timeEnd("extractPageContent"),f.info("Extracted page content:",{url:e.url,textLength:e.text.length,keywords:e.keywords.length}),e}catch(e){return f.error("Error extracting page content:",e),f.timeEnd("extractPageContent"),null}var t,r,n,o,i}();if(!e)return null;if(Y()){var t=function(){try{var e=document.querySelector("article")||document.querySelector('[role="article"]')||document.querySelector(".article")||document.querySelector(".post");return e?{headline:J(e),author:$(e),datePublished:Q(e),content:_(e.textContent||e.innerText||"")}:null}catch(e){return f.warn("Error extracting article content:",e),null}}();if(t)return ge(ge({},e),{},{article:t})}var r=function(){var e,t,r,n=document.querySelector('meta[property="og:image"]');return n?{src:n.content,alt:(null===(e=document.querySelector('meta[property="og:image:alt"]'))||void 0===e?void 0:e.content)||"",width:parseInt((null===(t=document.querySelector('meta[property="og:image:width"]'))||void 0===t?void 0:t.content)||"0"),height:parseInt((null===(r=document.querySelector('meta[property="og:image:height"]'))||void 0===r?void 0:r.content)||"0")}:null}();return r&&(e.featuredImage=r),e}},{key:"_extractVideoContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"video";f.time("extractVideoContent");try{var t=function(e){return Array.from(document.querySelectorAll(e)).sort(function(e,t){var r=(e.videoWidth||e.width||0)*(e.videoHeight||e.height||0);return(t.videoWidth||t.width||0)*(t.videoHeight||t.height||0)-r})}(e);if(0===t.length)return f.info("No video elements found"),f.timeEnd("extractVideoContent"),null;var r=t[0],n={src:Z(r),poster:r.poster||"",title:ee(r),description:te(r),duration:r.duration||0,currentTime:r.currentTime||0,dimensions:{width:r.videoWidth||r.width||0,height:r.videoHeight||r.height||0},metadata:re(r)};return f.timeEnd("extractVideoContent"),f.info("Extracted video content:",{src:n.src,title:n.title,duration:n.duration}),n}catch(e){return f.error("Error extracting video content:",e),f.timeEnd("extractVideoContent"),null}}(this.config.videoSelector||"video");if(!e){var t=function(){var e=document.querySelector('iframe[src*="youtube.com"]');if(e){var t=e.src,r=t.match(/embed\/([^?]+)/);return{platform:"youtube",videoId:r?r[1]:"",src:t}}var n=document.querySelector('iframe[src*="vimeo.com"]');if(n){var o=n.src,i=o.match(/video\/(\d+)/);return{platform:"vimeo",videoId:i?i[1]:"",src:o}}return null}();return t?ge(ge({},t),{},{type:"embedded"}):null}return ge(ge({},e),{},{type:"native"})}},{key:"_extractImageContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;f.time("extractImages");try{var t=Array.from(document.querySelectorAll("img")).filter(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200}).filter(function(e){var t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility}).filter(function(e){return!e.closest('.ad, .advertisement, [id*="ad-"], [class*="ad-"]')}).sort(function(e,t){var r=(e.naturalWidth||e.width||0)*(e.naturalHeight||e.height||0);return(t.naturalWidth||t.width||0)*(t.naturalHeight||t.height||0)-r}).slice(0,e).map(function(e){return{src:e.src,alt:_(e.alt||""),title:_(e.title||""),width:e.naturalWidth||e.width||0,height:e.naturalHeight||e.height||0,aspectRatio:ne(e)}});return f.timeEnd("extractImages"),f.info("Extracted ".concat(t.length," images")),t}catch(e){return f.error("Error extracting images:",e),f.timeEnd("extractImages"),[]}}(this.config.maxImages||5);return 0===e.length?null:{images:e,primaryImage:e[0],count:e.length}}},{key:"_generateCacheKey",value:function(e,t){var r=t;if(e.url)r+="_".concat(e.url);else if(e.src)r+="_".concat(e.src);else if(e.images){var n;r+="_".concat((null===(n=e.images[0])||void 0===n?void 0:n.src)||"")}return function(e){var t=0;if(0===e.length)return t.toString();for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t).toString(36)}(r+="_".concat(this.config.featureExtractors.sort().join("_")))}},{key:"_parseContext",value:function(e,t,r){var n,o={documentId:e.document_id,mode:r,content:{url:t.url||t.src||"",title:t.title||"",type:r}};if(e.enrichments&&e.enrichments.taxonomies){var i=e.enrichments.taxonomies;if(i.length>0){var a=i[0];o.taxonomy={label:a.label,nodeId:a.node_id,path:a.path,score:a.score,all:i}}}return e.enrichments&&(e.enrichments.brand_safety&&(o.brandSafety=e.enrichments.brand_safety),e.enrichments.keywords&&(o.keywords=e.enrichments.keywords),e.enrichments.sentiment&&(o.sentiment=e.enrichments.sentiment),e.enrichments.embeddings&&(o.embeddingId=(null===(n=e.enrichments.embeddings[0])||void 0===n?void 0:n.id)||null)),o}},{key:"_injectTargetingKeys",value:function(e,t){var r=this._buildTargetingKeys(t);return f.info("Targeting keys:",r),e.map(function(e){return e.ortb2Imp||(e.ortb2Imp={}),e.ortb2Imp.ext||(e.ortb2Imp.ext={}),e.ortb2Imp.ext.data||(e.ortb2Imp.ext.data={}),Object.assign(e.ortb2Imp.ext.data,r),e.bids||(e.bids=[]),e.bids=e.bids.map(function(e){return e.params||(e.params={}),e.params.keywords||(e.params.keywords={}),Object.assign(e.params.keywords,r),e}),e})}},{key:"_buildTargetingKeys",value:function(e){var t,r={};if(e.taxonomy){r.hb_mixpeek_category=e.taxonomy.label,r.hb_mixpeek_node=e.taxonomy.nodeId,r.hb_mixpeek_path=Array.isArray(e.taxonomy.path)?e.taxonomy.path.join("/"):e.taxonomy.path,r.hb_mixpeek_score=e.taxonomy.score.toFixed(2);var n=e.taxonomy.label.match(/IAB\d+-\d+/);n&&(r.hb_mixpeek_taxonomy=n[0])}e.brandSafety&&(r.hb_mixpeek_safety="number"==typeof e.brandSafety?e.brandSafety.toFixed(2):(null===(t=e.brandSafety.score)||void 0===t?void 0:t.toFixed(2))||"0"),e.keywords&&(r.hb_mixpeek_keywords=Array.isArray(e.keywords)?e.keywords.slice(0,10).join(","):e.keywords),e.sentiment&&(r.hb_mixpeek_sentiment="string"==typeof e.sentiment?e.sentiment:e.sentiment.label||"neutral"),e.embeddingId&&(r.hb_mixpeek_embed=e.embeddingId);var o=ye.getLast();return o&&(o.creativeId&&(r.hb_mixpeek_prev_creative=String(o.creativeId)),o.bidder&&(r.hb_mixpeek_prev_bidder=String(o.bidder)),o.adUnitCode&&(r.hb_mixpeek_prev_adunit=String(o.adUnitCode)),Array.isArray(o.categories)&&o.categories.length>0&&(r.hb_mixpeek_prev_cat=o.categories.slice(0,5).join(","))),r}},{key:"formatForOrtb2SiteContent",value:function(e){var t;if(!e)return null;var r={};if(e.taxonomy){var n=se(e.taxonomy);n&&(r.cat=[n],r.cattax=6),e.taxonomy.label&&(r.genre=e.taxonomy.label)}return e.keywords&&(r.keywords=Array.isArray(e.keywords)?e.keywords.join(","):e.keywords),A()&&document.documentElement.lang&&(r.language=document.documentElement.lang),A()&&(document.title&&(r.title=document.title),window.location.href&&(r.url=window.location.href)),e.content&&(e.content.url&&!r.url&&(r.url=e.content.url),e.content.title&&!r.title&&(r.title=e.content.title)),r.ext={data:{mixpeek:{documentId:e.documentId,mode:e.mode,score:null===(t=e.taxonomy)||void 0===t?void 0:t.score,brandSafety:e.brandSafety,sentiment:e.sentiment,embeddingId:e.embeddingId}}},r}},{key:"formatForOrtb2Fragments",value:function(e){if(!e)return null;var t=this.formatForOrtb2SiteContent(e);return t?{global:{site:{content:t}}}:null}},{key:"formatAsDataSegments",value:function(e){if(!e||!e.taxonomy)return[];var t=[],r=se(e.taxonomy);return r&&t.push({id:r,name:e.taxonomy.label,value:e.taxonomy.score.toString()}),e.taxonomy.all&&Array.isArray(e.taxonomy.all)&&e.taxonomy.all.slice(1,5).forEach(function(e){var r=se(e);r&&t.push({id:r,name:e.label,value:e.score.toString()})}),t}},{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"_emitEvent",value:function(e,t){this.events[e]&&this.events[e].forEach(function(r){try{r(t)}catch(t){f.error("Error in event callback for ".concat(e,":"),t)}}),A()&&window.pbjs&&window.pbjs.emit(e,t)}},{key:"getContextData",value:function(){return this.contextData}},{key:"clearCache",value:function(){L.clear(),f.info("Cache cleared")}},{key:"getCacheStats",value:function(){return L.getStats()}},{key:"healthCheck",value:(r=Ae(we().m(function e(){var t,r;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.client){e.n=1;break}return e.a(2,{status:"error",message:"Client not initialized"});case 1:return e.p=1,e.n=2,this.client.healthCheck();case 2:return t=e.v,e.a(2,ge({status:"ok"},t));case 3:return e.p=3,r=e.v,e.a(2,{status:"error",message:r.message})}},e,this,[[1,3]])})),function(){return r.apply(this,arguments)})}],t&&Se(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a,c,u,l}());const Ee=ke;return A()&&(window.MixpeekContextAdapter=ke),t})());
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MixpeekContextAdapter=t():e.MixpeekContextAdapter=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>Pe});var r="undefined"!=typeof process&&process.env&&process.env.MIXPEEK_API_ENDPOINT?process.env.MIXPEEK_API_ENDPOINT:"undefined"!=typeof window&&window.MIXPEEK_API_ENDPOINT?window.MIXPEEK_API_ENDPOINT:"https://api.mixpeek.com",n={COLLECTIONS:"/v1/collections",DOCUMENTS:"/v1/collections/{collectionId}/documents",FEATURES:"/v1/collections/{collectionId}/documents/{documentId}/features",FEATURE_EXTRACTORS:"/v1/collections/features/extractors",RETRIEVERS:"/v1/retrievers/debug-inference"},o="auto",i="video",a="mixpeek_ctx_",c="Mixpeek-Prebid-Adapter/".concat("1.0.0");function u(e){return u="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},u(e)}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}const f=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.debug=!1,this.prefix="[".concat("mixpeek","]")},t=[{key:"setDebug",value:function(e){this.debug=e}},{key:"info",value:function(){if(this.debug){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[this.prefix].concat(r))}}},{key:"warn",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[this.prefix].concat(r))}},{key:"error",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[this.prefix].concat(r))}},{key:"group",value:function(e){this.debug&&console.group&&console.group("".concat(this.prefix," ").concat(e))}},{key:"groupEnd",value:function(){this.debug&&console.groupEnd&&console.groupEnd()}},{key:"time",value:function(e){this.debug&&console.time&&console.time("".concat(this.prefix," ").concat(e))}},{key:"timeEnd",value:function(e){this.debug&&console.timeEnd&&console.timeEnd("".concat(this.prefix," ").concat(e))}},{key:"table",value:function(e){this.debug&&console.table&&console.table(e)}}],t&&l(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function h(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(p(e)+" is not iterable")}function d(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return m(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(m(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,m(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,m(f,"constructor",l),m(l,"constructor",u),u.displayName="GeneratorFunction",m(l,o,"GeneratorFunction"),m(f),m(f,o,"Generator"),m(f,n,function(){return this}),m(f,"toString",function(){return"[object Generator]"}),(d=function(){return{w:i,m:h}})()}function m(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,r,n){function i(t,r){m(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},m(e,t,r,n)}function y(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return p="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},p(e)}function v(e){return null!==e&&"object"===p(e)&&!Array.isArray(e)}function g(e,t){var r=Object.assign({},e);return v(e)&&v(t)&&Object.keys(t).forEach(function(n){var o,i,a;v(t[n])&&n in e?r[n]=g(e[n],t[n]):Object.assign(r,(o={},i=n,a=t[n],(i=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(i))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,o))}),r}function b(e){var t=[];return e.apiKey&&"string"==typeof e.apiKey||t.push("apiKey is required and must be a string"),e.collectionId&&"string"==typeof e.collectionId||t.push("collectionId is required and must be a string"),e.timeout&&("number"!=typeof e.timeout||e.timeout<0)&&t.push("timeout must be a positive number"),e.cacheTTL&&("number"!=typeof e.cacheTTL||e.cacheTTL<0)&&t.push("cacheTTL must be a positive number"),t.length>0?{valid:!1,errors:t,code:"INVALID_CONFIG"}:{valid:!0}}function w(e){try{return new URL(e).hostname}catch(e){return""}}function x(e){return e?e.replace(/\s+/g," ").replace(/[\r\n\t]/g," ").trim():""}function _(){return"undefined"!=typeof window&&"undefined"!=typeof document}function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{return JSON.parse(e)}catch(e){return f.warn("Failed to parse JSON:",e),t}}function A(e){return k.apply(this,arguments)}function k(){var e;return e=d().m(function e(t){var r,n,o,i,a,c,u=arguments;return d().w(function(e){for(;;)switch(e.n){case 0:r=u.length>1&&void 0!==u[1]?u[1]:3,n=u.length>2&&void 0!==u[2]?u[2]:100,i=d().m(function e(){var i,a,u;return d().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t();case 1:return a=e.v,e.a(2,{v:a});case 2:if(e.p=2,u=e.v,o=u,!(c<r)){e.n=3;break}return i=n*Math.pow(2,c-1),f.warn("Attempt ".concat(c," failed, retrying in ").concat(i,"ms...")),e.n=3,new Promise(function(e){return setTimeout(e,i)});case 3:return e.a(2)}},e,null,[[0,2]])}),c=1;case 1:if(!(c<=r)){e.n=4;break}return e.d(h(i()),2);case 2:if(!(a=e.v)){e.n=3;break}return e.a(2,a.v);case 3:c++,e.n=1;break;case 4:throw o;case 5:return e.a(2)}},e)}),k=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){y(i,n,o,a,c,"next",e)}function c(e){y(i,n,o,a,c,"throw",e)}a(void 0)})},k.apply(this,arguments)}function I(e){return new Promise(function(t,r){setTimeout(function(){return r(new Error("Timeout"))},e)})}function E(e,t){return Promise.race([e,I(t)])}function C(){return Math.floor(Date.now()/1e3)}function j(e,t){return C()-e>t}function O(e){return O="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},O(e)}function P(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||T(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 T(e,t){if(e){if("string"==typeof e)return B(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)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function q(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,L(n.key),n)}}function L(e){var t=function(e){if("object"!=O(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==O(t)?t:t+""}const F=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.memoryCache=new Map,this.useLocalStorage=this._checkLocalStorageAvailable(),this.ttl=300},t=[{key:"_checkLocalStorageAvailable",value:function(){try{var e="__mixpeek_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return f.warn("localStorage not available, using memory cache only"),!1}}},{key:"_getCacheKey",value:function(e){return"".concat(a).concat("v1","_").concat(e)}},{key:"setTTL",value:function(e){this.ttl=e}},{key:"get",value:function(e){var t=this._getCacheKey(e);if(this.memoryCache.has(t)){var r=this.memoryCache.get(t);if(!j(r.timestamp,this.ttl))return f.info("Cache hit (memory):",e),r.data;f.info("Cache expired (memory):",e),this.memoryCache.delete(t)}if(this.useLocalStorage)try{var n=localStorage.getItem(t);if(n){var o=S(n);if(o&&!j(o.timestamp,this.ttl))return f.info("Cache hit (localStorage):",e),this.memoryCache.set(t,o),o.data;f.info("Cache expired (localStorage):",e),localStorage.removeItem(t)}}catch(e){f.warn("Error reading from localStorage:",e)}return f.info("Cache miss:",e),null}},{key:"set",value:function(e,t){var r=this._getCacheKey(e),n={data:t,timestamp:C()};try{return this.memoryCache.set(r,n),this.useLocalStorage&&localStorage.setItem(r,JSON.stringify(n)),f.info("Cached:",e),!0}catch(e){return f.warn("Error setting cache:",e),!1}}},{key:"remove",value:function(e){var t=this._getCacheKey(e);try{return this.memoryCache.delete(t),this.useLocalStorage&&localStorage.removeItem(t),f.info("Cache removed:",e),!0}catch(e){return f.warn("Error removing cache:",e),!1}}},{key:"clear",value:function(){try{return this.memoryCache.clear(),this.useLocalStorage&&Object.keys(localStorage).forEach(function(e){e.startsWith(a)&&localStorage.removeItem(e)}),f.info("Cache cleared"),!0}catch(e){return f.warn("Error clearing cache:",e),!1}}},{key:"getStats",value:function(){var e=0,t=0;if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(r){r.startsWith(a)&&(t++,e+=localStorage.getItem(r).length)})}catch(e){f.warn("Error getting cache stats:",e)}return{memoryCount:this.memoryCache.size,localStorageCount:t,localStorageSize:e,ttl:this.ttl}}},{key:"prune",value:function(){var e,t=this,r=0,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=T(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(this.memoryCache.entries());try{for(n.s();!(e=n.n()).done;){var o=P(e.value,2),i=o[0];j(o[1].timestamp,this.ttl)&&(this.memoryCache.delete(i),r++)}}catch(e){n.e(e)}finally{n.f()}if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(e){if(e.startsWith(a)){var n=S(localStorage.getItem(e));n&&j(n.timestamp,t.ttl)&&(localStorage.removeItem(e),r++)}})}catch(e){f.warn("Error pruning cache:",e)}return r>0&&f.info("Pruned ".concat(r," expired cache items")),r}}],t&&q(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function N(e){return N="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},N(e)}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function M(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return R(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(R(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,R(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,R(f,"constructor",l),R(l,"constructor",u),u.displayName="GeneratorFunction",R(l,o,"GeneratorFunction"),R(f),R(f,o,"Generator"),R(f,n,function(){return this}),R(f,"toString",function(){return"[object Generator]"}),(M=function(){return{w:i,m:h}})()}function R(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}R=function(e,t,r,n){function i(t,r){R(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},R(e,t,r,n)}function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach(function(t){z(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function H(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function U(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){H(i,n,o,a,c,"next",e)}function c(e){H(i,n,o,a,c,"throw",e)}a(void 0)})}}function z(e,t,r){return(t=V(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,V(n.key),n)}}function V(e){var t=function(e){if("object"!=N(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==N(t)?t:t+""}const X=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.apiKey=t.apiKey||"",this.endpoint=t.endpoint||r,this.namespace=t.namespace||null,this.timeout=t.timeout||250,this.retryAttempts=t.retryAttempts||2},t=[{key:"configure",value:function(e){Object.assign(this,e)}},{key:"_buildHeaders",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=z(z(z({},"Content-Type","application/json"),"Authorization","Bearer ".concat(this.apiKey)),"User-Agent",c);return this.namespace&&e&&(t["X-Namespace"]=this.namespace),t}},{key:"_request",value:(d=U(M().m(function e(t){var r,n,o,i,a,c,u,l=arguments;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=l.length>1&&void 0!==l[1]?l[1]:{},n="".concat(this.endpoint).concat(t),o=this._buildHeaders(),i=G(G({},r),{},{headers:G(G({},o),r.headers)}),f.info("API Request: ".concat(r.method||"GET"," ").concat(n)),f.time("API Request: ".concat(t)),e.p=1,e.n=2,E(fetch(n,i),this.timeout);case 2:if(a=e.v,f.timeEnd("API Request: ".concat(t)),a.ok){e.n=4;break}return e.n=3,this._handleErrorResponse(a);case 3:throw e.v;case 4:return e.n=5,a.json();case 5:return c=e.v,f.info("API Response:",{status:a.status,path:t}),e.a(2,c);case 6:if(e.p=6,u=e.v,f.timeEnd("API Request: ".concat(t)),"Timeout"!==u.message){e.n=7;break}throw{code:"API_TIMEOUT",message:"Request timeout after ".concat(this.timeout,"ms"),path:t};case 7:throw u;case 8:return e.a(2)}},e,this,[[1,6]])})),function(e){return d.apply(this,arguments)})},{key:"_handleErrorResponse",value:(h=U(M().m(function e(t){var r,n;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r="API error: ".concat(t.status," ").concat(t.statusText),e.p=1,e.n=2,t.json();case 2:n=e.v,r=n.message||n.error||r,e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2,{code:"API_ERROR",message:r,status:t.status})}},e,null,[[1,3]])})),function(e){return h.apply(this,arguments)})},{key:"createDocument",value:(s=U(M().m(function e(t,r){var o,i,a=this;return M().w(function(e){for(;;)if(0===e.n)return o=n.DOCUMENTS.replace("{collectionId}",t),i=G({collection_id:t},r.metadata),r.content&&(i.content=r.content),e.a(2,A(function(){return a._request(o,{method:"POST",body:JSON.stringify(i)})},this.retryAttempts))},e,this)})),function(e,t){return s.apply(this,arguments)})},{key:"getDocument",value:(l=U(M().m(function e(t,r){var o;return M().w(function(e){for(;;)if(0===e.n)return o="".concat(n.DOCUMENTS.replace("{collectionId}",t),"/").concat(r),e.a(2,this._request(o,{method:"GET"}))},e,this)})),function(e,t){return l.apply(this,arguments)})},{key:"processContent",value:(u=U(M().m(function e(t,r){var n,o,i;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return f.group("Processing content with Mixpeek"),f.info("Collection:",t),f.info("Content URL:",r.url),e.p=1,e.n=2,this.createDocument(t,{content:r.text||r.description||"",metadata:{url:r.url,title:r.title,timestamp:Date.now()}});case 2:return n=e.v,f.info("Document created:",n.document_id),o=this._buildLocalEnrichments(r),f.groupEnd(),e.a(2,{document_id:n.document_id,collection_id:n.collection_id,enrichments:o});case 3:return e.p=3,i=e.v,f.error("Error processing content:",i),f.groupEnd(),e.a(2,{document_id:null,collection_id:t,enrichments:this._buildLocalEnrichments(r)})}},e,this,[[1,3]])})),function(e,t){return u.apply(this,arguments)})},{key:"_buildLocalEnrichments",value:function(e){var t={};return e.text&&(t.keywords=this._extractKeywords(e.text)),e.text&&(t.sentiment=this._analyzeSentiment(e.text)),t.embeddings=[{id:"emb_".concat(this._generateContentId(e))}],t}},{key:"_extractKeywords",value:function(e){if(!e)return[];var t=new Set(["the","a","an","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","must","shall","can","need","dare","ought","used","to","of","in","for","on","with","at","by","from","as","into","through","during","before","after","above","below","between","under","again","further","then","once","here","there","when","where","why","how","all","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","s","t","just","don","now","and","but","or","if","this","that","these","those","it","its"]),r=e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(function(e){return e.length>3&&!t.has(e)}),n={};return r.forEach(function(e){n[e]=(n[e]||0)+1}),Object.entries(n).sort(function(e,t){return t[1]-e[1]}).slice(0,10).map(function(e){return function(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(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)?D(e,t):void 0}}(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.")}()}(e,1)[0]})}},{key:"_analyzeSentiment",value:function(e){if(!e)return{label:"neutral",score:.5};var t=e.toLowerCase(),r=0,n=0;["good","great","excellent","amazing","wonderful","fantastic","best","love","happy","positive","success","win","awesome","brilliant","perfect","beautiful","enjoy","exciting"].forEach(function(e){var n=new RegExp("\\b".concat(e,"\\b"),"gi"),o=t.match(n);o&&(r+=o.length)}),["bad","terrible","awful","horrible","worst","hate","sad","negative","fail","loss","poor","ugly","boring","disappointing","wrong","problem","issue","error"].forEach(function(e){var r=new RegExp("\\b".concat(e,"\\b"),"gi"),o=t.match(r);o&&(n+=o.length)});var o=r+n;if(0===o)return{label:"neutral",score:.5};var i=r/o,a="neutral";return i>.6?a="positive":i<.4&&(a="negative"),{label:a,score:i}}},{key:"_buildFeaturePayload",value:function(e){var t={};return e.text&&(t.text=e.text),e.url&&(t.url=e.url),e.src&&void 0!==e.duration&&(t.video_url=e.src,t.title=e.title,t.description=e.description),e.src&&e.width&&e.height&&!e.duration&&(t.image_url=e.src,t.alt_text=e.alt),e.metadata&&(t.metadata=e.metadata),t}},{key:"_generateContentId",value:function(e){return e.url?"url_".concat(e.url.split("?")[0]):e.src?"src_".concat(e.src.split("?")[0]):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},{key:"listFeatureExtractors",value:(a=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request(n.FEATURE_EXTRACTORS,{method:"GET"}))},e,this)})),function(){return a.apply(this,arguments)})},{key:"getFeatureExtractor",value:(i=U(M().m(function e(t){var r;return M().w(function(e){for(;;)if(0===e.n)return r=n.FEATURE_EXTRACTORS+"/".concat(t),e.a(2,this._request(r,{method:"GET"}))},e,this)})),function(e){return i.apply(this,arguments)})},{key:"healthCheck",value:(o=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request("/v1/health",{method:"GET"}))},e,this)})),function(){return o.apply(this,arguments)})}],t&&W(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,o,i,a,u,l,s,h,d}();function J(e){var t,r=e.querySelector("h1"),n=e.querySelector('[itemprop="headline"]');return x((null===(t=r||n)||void 0===t?void 0:t.textContent)||"")}function $(e){var t=e.querySelector('[itemprop="author"]')||e.querySelector('[rel="author"]')||e.querySelector(".author");return x((null==t?void 0:t.textContent)||"")}function Q(e){var t=e.querySelector('[itemprop="datePublished"]')||e.querySelector("time[datetime]");return(null==t?void 0:t.getAttribute("datetime"))||(null==t?void 0:t.textContent)||""}function Y(){return null!==document.querySelector("article")||null!==document.querySelector('[itemtype*="Article"]')||null!==document.querySelector('meta[property="og:type"][content="article"]')}function Z(e){if(e.src)return e.src;var t=e.querySelector("source");return t&&t.src?t.src:e.currentSrc?e.currentSrc:""}function ee(e){var t,r,n=e.getAttribute("data-title")||e.getAttribute("title")||e.getAttribute("aria-label");if(n)return x(n);var o=e.closest("[data-video-title]");if(o)return x(o.getAttribute("data-video-title"));var i=(null===(t=e.previousElementSibling)||void 0===t?void 0:t.querySelector("h1, h2, h3"))||(null===(r=e.parentElement)||void 0===r?void 0:r.querySelector("h1, h2, h3"));return i?x(i.textContent):""}function te(e){var t=e.getAttribute("data-description")||e.getAttribute("aria-description");if(t)return x(t);var r=e.closest("[data-video-description]");return r?x(r.getAttribute("data-video-description")):""}function re(e){var t={};return Array.from(e.attributes).forEach(function(e){if(e.name.startsWith("data-")){var r=e.name.replace("data-","").replace(/-/g,"_");t[r]=e.value}}),t}function ne(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return r>0?t/r:0}function oe(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ie(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)?ie(e,t):void 0}}(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 ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ae={node_technology:"IAB19",node_tech_computing:"IAB19",node_tech_ai:"IAB19-11",node_tech_artificial_intelligence:"IAB19-11",node_tech_machine_learning:"IAB19-11",node_tech_software:"IAB19-18",node_tech_hardware:"IAB19-19",node_tech_mobile:"IAB19-20",node_electronics_phones:"IAB19-20",node_tech_internet:"IAB19-21",sports:"IAB17",sports_football:"IAB17-3",sports_soccer:"IAB17-44",sports_basketball:"IAB17-4",sports_baseball:"IAB17-5",sports_tennis:"IAB17-37",news:"IAB12",news_politics:"IAB12-2",news_business:"IAB12-3",news_technology:"IAB12-6",business:"IAB13",business_finance:"IAB13-7",business_investing:"IAB13-5",entertainment:"IAB9",entertainment_movies:"IAB9-7",entertainment_tv:"IAB9-23",entertainment_music:"IAB9-8",health:"IAB7",health_fitness:"IAB7-18",health_nutrition:"IAB7-30",travel:"IAB20",travel_hotels:"IAB20-12",food:"IAB8",food_cooking:"IAB8-5",food_restaurants:"IAB8-9",automotive:"IAB2",automotive_cars:"IAB2",real_estate:"IAB21",education:"IAB5",fashion:"IAB18",fashion_beauty:"IAB18-1",home:"IAB10",home_garden:"IAB10-3",science:"IAB15",arts:"IAB1",arts_design:"IAB1-4"},ce={technology:"IAB19",tech:"IAB19",ai:"IAB19-11","artificial intelligence":"IAB19-11","machine learning":"IAB19-11",software:"IAB19-18",hardware:"IAB19-19",mobile:"IAB19-20",computing:"IAB19",sports:"IAB17",football:"IAB17-3",soccer:"IAB17-44",basketball:"IAB17-4",baseball:"IAB17-5",news:"IAB12",politics:"IAB12-2",business:"IAB13",finance:"IAB13-7",investing:"IAB13-5",entertainment:"IAB9",movies:"IAB9-7",television:"IAB9-23",music:"IAB9-8",gaming:"IAB9-30",health:"IAB7",fitness:"IAB7-18",wellness:"IAB7",nutrition:"IAB7-30",travel:"IAB20",food:"IAB8",automotive:"IAB2",cars:"IAB2","real estate":"IAB21",education:"IAB5",fashion:"IAB18",home:"IAB10",science:"IAB15",arts:"IAB1"};function ue(e){return!(!e||"string"!=typeof e)&&/^IAB\d+(-\d+)?$/.test(e)}function le(e){if(!e||"string"!=typeof e)return null;var t=e.match(/IAB\d+(-\d+)?/);return t?t[0]:null}function se(e){if(!e)return null;if(e.label){if(ue(e.label))return e.label;var t=le(e.label);if(t)return t}if(e.nodeId||e.node_id){var r=e.nodeId||e.node_id;if(ue(r))return r;var n=le(r);if(n)return n}if(e.nodeId||e.node_id){var o=(e.nodeId||e.node_id).toLowerCase();if(ae[o])return ae[o];for(var i=o.replace(/[_-]/g,""),a=0,c=Object.entries(ae);a<c.length;a++){var u=oe(c[a],2),l=u[0],s=u[1];if(l.replace(/[_-]/g,"")===i)return s}}if(e.label){var f=e.label.toLowerCase();if(ce[f])return ce[f];for(var h=0,d=Object.entries(ce);h<d.length;h++){var m=oe(d[h],2),y=m[0],p=m[1];if(f.includes(y))return p}}if(e.path)for(var v=Array.isArray(e.path)?e.path.join(" ").toLowerCase():e.path.toLowerCase(),g=0,b=Object.entries(ce);g<b.length;g++){var w=oe(b[g],2),x=w[0],_=w[1];if(v.includes(x))return _}return null}function fe(e){return fe="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},fe(e)}function he(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,de(n.key),n)}}function de(e){var t=function(e){if("object"!=fe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=fe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fe(t)?t:t+""}var me="mixpeek_prev_ad_v1";const ye=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.lastAd=null,this.storageAvailable=this._checkLocalStorage(),this._loadFromStorage()},t=[{key:"_checkLocalStorage",value:function(){if(!_())return!1;try{var e="__mixpeek_prev_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch(e){return!1}}},{key:"_loadFromStorage",value:function(){if(this.storageAvailable)try{var e=localStorage.getItem(me);if(e){var t=S(e);t&&"object"===fe(t)&&(this.lastAd=t)}}catch(e){f.warn("Failed to load previous ad from storage:",e)}}},{key:"_persist",value:function(){if(this.storageAvailable)try{localStorage.setItem(me,JSON.stringify(this.lastAd))}catch(e){f.warn("Failed to persist previous ad:",e)}}},{key:"record",value:function(e){var t,r;if(e&&"object"===fe(e)){var n={creativeId:e.creativeId||e.creative_id||null,bidder:e.bidder||e.bidderCode||null,adUnitCode:e.adUnitCode||null,cpm:"number"==typeof e.cpm?e.cpm:null,currency:e.currency||null,categories:Array.isArray(null===(t=e.meta)||void 0===t?void 0:t.adServerCatId)?e.meta.adServerCatId:null!==(r=e.meta)&&void 0!==r&&r.primaryCat?[e.meta.primaryCat]:[],timestamp:Date.now()};this.lastAd=n,this._persist()}}},{key:"getLast",value:function(){return this.lastAd}},{key:"clear",value:function(){if(this.lastAd=null,this.storageAvailable)try{localStorage.removeItem(me)}catch(e){}}}],t&&he(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function pe(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=ge(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}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 i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function ve(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,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||ge(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 ge(e,t){if(e){if("string"==typeof e)return be(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)?be(e,t):void 0}}function be(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function we(e){return we="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},we(e)}function xe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _e(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(r),!0).forEach(function(t){Se(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Se(e,t,r){return(t=je(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ae(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return ke(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(ke(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,ke(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,ke(f,"constructor",l),ke(l,"constructor",u),u.displayName="GeneratorFunction",ke(l,o,"GeneratorFunction"),ke(f),ke(f,o,"Generator"),ke(f,n,function(){return this}),ke(f,"toString",function(){return"[object Generator]"}),(Ae=function(){return{w:i,m:h}})()}function ke(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}ke=function(e,t,r,n){function i(t,r){ke(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},ke(e,t,r,n)}function Ie(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function Ee(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){Ie(i,n,o,a,c,"next",e)}function c(e){Ie(i,n,o,a,c,"throw",e)}a(void 0)})}}function Ce(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,je(n.key),n)}}function je(e){var t=function(e){if("object"!=we(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=we(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==we(t)?t:t+""}var Oe=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={},this.client=null,this.initialized=!1,this.processing=!1,this.contextData=null,this.events={},this.healthCheckPerformed=!1},t=[{key:"init",value:(l=Ee(Ae().m(function e(t){var r,n;return Ae().w(function(e){for(;;)switch(e.n){case 0:if(f.info("Initializing Mixpeek Context Adapter"),f.group("Configuration"),(r=b(t)).valid){e.n=1;break}return f.error("Invalid configuration:",r.errors),f.groupEnd(),e.a(2,!1);case 1:if(this.config=g({endpoint:"https://api.mixpeek.com",timeout:250,cacheTTL:300,retryAttempts:2,mode:o,enableCache:!0,debug:!1,healthCheck:"lazy",featureExtractors:["text_extractor_v1"],batchSize:1},t),f.setDebug(this.config.debug),this.client=new X({apiKey:this.config.apiKey,endpoint:this.config.endpoint,namespace:this.config.namespace,timeout:this.config.timeout,retryAttempts:this.config.retryAttempts}),this.config.enableCache&&F.setTTL(this.config.cacheTTL),f.table({"API Endpoint":this.config.endpoint,"Collection ID":this.config.collectionId,Namespace:this.config.namespace||"default",Mode:this.config.mode,Timeout:"".concat(this.config.timeout,"ms"),"Cache TTL":"".concat(this.config.cacheTTL,"s"),"Feature Extractors":this.config.featureExtractors.join(", "),"Health Check":this.config.healthCheck}),f.groupEnd(),"eager"!==this.config.healthCheck){e.n=3;break}return f.info("Performing health check..."),e.n=2,this._performHealthCheck();case 2:(n=e.v).healthy?f.info("Health check passed:",n.message):(f.warn("Health check failed, but continuing initialization"),f.warn("API may be unavailable:",n.error)),e.n=4;break;case 3:"lazy"===this.config.healthCheck&&f.info("Health check will be performed on first request");case 4:return this.initialized=!0,f.info("Mixpeek Context Adapter initialized successfully"),e.a(2,!0)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"_performHealthCheck",value:(u=Ee(Ae().m(function e(){var t,r,n,o;return Ae().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,t=performance.now(),e.n=1,this.client.healthCheck();case 1:return r=e.v,n=performance.now()-t,e.a(2,{healthy:!0,status:r.status||"ok",version:r.version,latency:Math.round(n),message:"API responding in ".concat(Math.round(n),"ms")});case 2:return e.p=2,o=e.v,e.a(2,{healthy:!1,error:o.message,message:"API health check failed"})}},e,this,[[0,2]])})),function(){return u.apply(this,arguments)})},{key:"enrichAdUnits",value:(c=Ee(Ae().m(function e(t){var r,n,o,i,a;return Ae().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.initialized){e.n=1;break}return f.warn("Adapter not initialized"),e.a(2,t);case 1:if(!this.processing){e.n=2;break}return f.warn("Already processing context"),e.a(2,t);case 2:return this.processing=!0,r=performance.now(),e.p=3,e.n=4,this.getContext();case 4:if(n=e.v){e.n=5;break}return f.warn("No context data available"),e.a(2,t);case 5:return this.contextData=n,o=this._injectTargetingKeys(t,n),i=performance.now()-r,f.info("Context enrichment completed in ".concat(i.toFixed(2),"ms")),i>100&&f.warn("Enrichment took ".concat(i.toFixed(2),"ms (threshold: ").concat(100,"ms)")),this._emitEvent("mixpeekContextReady",n),e.a(2,o);case 6:return e.p=6,a=e.v,f.error("Error enriching ad units:",a),this._emitEvent("mixpeekContextError",a),e.a(2,t);case 7:return e.p=7,this.processing=!1,e.f(7);case 8:return e.a(2)}},e,this,[[3,6,7,8]])})),function(e){return c.apply(this,arguments)})},{key:"getContext",value:(a=Ee(Ae().m(function e(){var t,r,n,o,i,a,c,u;return Ae().w(function(e){for(;;)switch(e.p=e.n){case 0:if(f.time("getContext"),e.p=1,"lazy"!==this.config.healthCheck||this.healthCheckPerformed){e.n=3;break}return f.info("Performing lazy health check..."),e.n=2,this._performHealthCheck();case 2:t=e.v,this.healthCheckPerformed=!0,t.healthy?f.info("Health check passed:",t.message):(f.warn("Health check failed:",t.error),f.warn("Proceeding anyway, errors will be handled gracefully"));case 3:return r=this._detectContentMode(),f.info("Content mode:",r),e.n=4,this._extractContent(r);case 4:if(n=e.v){e.n=5;break}return f.warn("No content extracted"),f.timeEnd("getContext"),e.a(2,null);case 5:if(o=this._generateCacheKey(n,r),!this.config.enableCache){e.n=6;break}if(!(i=F.get(o))){e.n=6;break}return f.info("Using cached context"),f.timeEnd("getContext"),this._emitEvent("mixpeekContextCached",i),e.a(2,i);case 6:return f.info("Processing content with Mixpeek API"),this._emitEvent("mixpeekApiRequest",{content:n,mode:r}),e.n=7,this.client.processContent(this.config.collectionId,n,this.config.featureExtractors);case 7:return a=e.v,this._emitEvent("mixpeekApiResponse",a),c=this._parseContext(a,n,r),this.config.enableCache&&F.set(o,c),f.timeEnd("getContext"),e.a(2,c);case 8:throw e.p=8,u=e.v,f.error("Error getting context:",u),f.timeEnd("getContext"),u;case 9:return e.a(2)}},e,this,[[1,8]])})),function(){return a.apply(this,arguments)})},{key:"_detectContentMode",value:function(){return this.config.mode!==o?this.config.mode:null!==document.querySelector("video")||null!==document.querySelector('iframe[src*="youtube.com"]')||null!==document.querySelector('iframe[src*="vimeo.com"]')?i:(Y()||(e=document.querySelectorAll("img"),Array.from(e).some(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200})),"page");var e}},{key:"_extractContent",value:(n=Ee(Ae().m(function e(t){var r;return Ae().w(function(e){for(;;)switch(e.n){case 0:if(_()){e.n=1;break}return f.warn("Not in browser environment"),e.a(2,null);case 1:f.info("Extracting ".concat(t," content")),r=t,e.n=r===i?2:"image"===r?3:4;break;case 2:return e.a(2,this._extractVideoContent());case 3:return e.a(2,this._extractImageContent());case 4:return e.a(2,this._extractPageContent());case 5:return e.a(2)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"_extractPageContent",value:function(){var e=function(){f.time("extractPageContent");try{var e={url:window.location.href,domain:w(window.location.href),title:document.title,description:(i=document.querySelector('meta[name="description"]')||document.querySelector('meta[property="og:description"]'),i?x(i.content):""),text:(o=document.body.cloneNode(!0),o.querySelectorAll("script, style, iframe, nav, footer, aside, .ad, .advertisement").forEach(function(e){return e.remove()}),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e4;return!e||e.length<=t?e:(f.warn("Content truncated from ".concat(e.length," to ").concat(t," characters")),e.substring(0,t))}(x(o.textContent||o.innerText||""),5e4)),keywords:(n=document.querySelector('meta[name="keywords"]'),n?n.content.split(",").map(function(e){return e.trim()}).filter(Boolean):[]),ogTags:(r={},document.querySelectorAll('meta[property^="og:"]').forEach(function(e){var t=e.getAttribute("property").replace("og:","");r[t]=e.content}),r),structuredData:(t=[],document.querySelectorAll('script[type="application/ld+json"]').forEach(function(e){try{var r=JSON.parse(e.textContent);t.push(r)}catch(e){f.warn("Failed to parse structured data:",e)}}),t),language:document.documentElement.lang||"en"};return f.timeEnd("extractPageContent"),f.info("Extracted page content:",{url:e.url,textLength:e.text.length,keywords:e.keywords.length}),e}catch(e){return f.error("Error extracting page content:",e),f.timeEnd("extractPageContent"),null}var t,r,n,o,i}();if(!e)return null;if(Y()){var t=function(){try{var e=document.querySelector("article")||document.querySelector('[role="article"]')||document.querySelector(".article")||document.querySelector(".post");return e?{headline:J(e),author:$(e),datePublished:Q(e),content:x(e.textContent||e.innerText||"")}:null}catch(e){return f.warn("Error extracting article content:",e),null}}();if(t)return _e(_e({},e),{},{article:t})}var r=function(){var e,t,r,n=document.querySelector('meta[property="og:image"]');return n?{src:n.content,alt:(null===(e=document.querySelector('meta[property="og:image:alt"]'))||void 0===e?void 0:e.content)||"",width:parseInt((null===(t=document.querySelector('meta[property="og:image:width"]'))||void 0===t?void 0:t.content)||"0"),height:parseInt((null===(r=document.querySelector('meta[property="og:image:height"]'))||void 0===r?void 0:r.content)||"0")}:null}();return r&&(e.featuredImage=r),e}},{key:"_extractVideoContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"video";f.time("extractVideoContent");try{var t=function(e){return Array.from(document.querySelectorAll(e)).sort(function(e,t){var r=(e.videoWidth||e.width||0)*(e.videoHeight||e.height||0);return(t.videoWidth||t.width||0)*(t.videoHeight||t.height||0)-r})}(e);if(0===t.length)return f.info("No video elements found"),f.timeEnd("extractVideoContent"),null;var r=t[0],n={src:Z(r),poster:r.poster||"",title:ee(r),description:te(r),duration:r.duration||0,currentTime:r.currentTime||0,dimensions:{width:r.videoWidth||r.width||0,height:r.videoHeight||r.height||0},metadata:re(r)};return f.timeEnd("extractVideoContent"),f.info("Extracted video content:",{src:n.src,title:n.title,duration:n.duration}),n}catch(e){return f.error("Error extracting video content:",e),f.timeEnd("extractVideoContent"),null}}(this.config.videoSelector||"video");if(!e){var t=function(){var e=document.querySelector('iframe[src*="youtube.com"]');if(e){var t=e.src,r=t.match(/embed\/([^?]+)/);return{platform:"youtube",videoId:r?r[1]:"",src:t}}var n=document.querySelector('iframe[src*="vimeo.com"]');if(n){var o=n.src,i=o.match(/video\/(\d+)/);return{platform:"vimeo",videoId:i?i[1]:"",src:o}}return null}();return t?_e(_e({},t),{},{type:"embedded"}):null}return _e(_e({},e),{},{type:"native"})}},{key:"_extractImageContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;f.time("extractImages");try{var t=Array.from(document.querySelectorAll("img")).filter(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200}).filter(function(e){var t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility}).filter(function(e){return!e.closest('.ad, .advertisement, [id*="ad-"], [class*="ad-"]')}).sort(function(e,t){var r=(e.naturalWidth||e.width||0)*(e.naturalHeight||e.height||0);return(t.naturalWidth||t.width||0)*(t.naturalHeight||t.height||0)-r}).slice(0,e).map(function(e){return{src:e.src,alt:x(e.alt||""),title:x(e.title||""),width:e.naturalWidth||e.width||0,height:e.naturalHeight||e.height||0,aspectRatio:ne(e)}});return f.timeEnd("extractImages"),f.info("Extracted ".concat(t.length," images")),t}catch(e){return f.error("Error extracting images:",e),f.timeEnd("extractImages"),[]}}(this.config.maxImages||5);return 0===e.length?null:{images:e,primaryImage:e[0],count:e.length}}},{key:"_generateCacheKey",value:function(e,t){var r=t;if(e.url)r+="_".concat(e.url);else if(e.src)r+="_".concat(e.src);else if(e.images){var n;r+="_".concat((null===(n=e.images[0])||void 0===n?void 0:n.src)||"")}return function(e){var t=0;if(0===e.length)return t.toString();for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t).toString(36)}(r+="_".concat(this.config.featureExtractors.sort().join("_")))}},{key:"_parseContext",value:function(e,t,r){var n={documentId:e.document_id,mode:r,content:{url:t.url||t.src||"",title:t.title||"",type:r}};if(e.enrichments&&e.enrichments.taxonomies){var o=e.enrichments.taxonomies;if(o.length>0){var i=o[0];n.taxonomy={label:i.label,nodeId:i.node_id,path:i.path,score:i.score,all:o}}}if(e.enrichments){if(e.enrichments.brand_safety)n.brandSafety=e.enrichments.brand_safety;else if(e.enrichments.sentiment){var a="object"===we(e.enrichments.sentiment)?e.enrichments.sentiment.score:.5;n.brandSafety={score:a>.5?.8+.4*(a-.5):.5+.6*a,level:a>.6?"safe":a<.4?"caution":"neutral"}}var c;e.enrichments.keywords&&(n.keywords=e.enrichments.keywords),e.enrichments.sentiment&&(n.sentiment=e.enrichments.sentiment),e.enrichments.embeddings&&(n.embeddingId=(null===(c=e.enrichments.embeddings[0])||void 0===c?void 0:c.id)||null)}return!n.taxonomy&&n.keywords&&n.keywords.length>0&&(n.taxonomy={label:this._inferCategoryFromKeywords(n.keywords),nodeId:"kw_".concat(n.keywords[0]),path:["Content",this._inferCategoryFromKeywords(n.keywords)],score:.7}),n}},{key:"_inferCategoryFromKeywords",value:function(e){for(var t=e.map(function(e){return e.toLowerCase()}),r=0,n=Object.entries({Technology:["technology","software","computer","digital","tech","programming","code","developer","app","mobile","phone","smartphone"],Business:["business","company","market","finance","investment","stock","economy","corporate","startup","entrepreneur"],Sports:["sports","game","team","player","football","basketball","soccer","baseball","tennis","golf","match"],Entertainment:["movie","film","music","celebrity","actor","singer","show","concert","entertainment","tv","television"],Health:["health","medical","doctor","hospital","medicine","disease","fitness","wellness","diet","nutrition"],News:["news","breaking","report","politics","government","election","policy","world","international"],Science:["science","research","study","experiment","discovery","scientist","physics","chemistry","biology"],Automotive:["car","vehicle","auto","automotive","driving","electric","engine","motor","truck"],Travel:["travel","vacation","hotel","flight","destination","tourism","trip","adventure"],Food:["food","recipe","cooking","restaurant","cuisine","chef","meal","dinner","lunch"]});r<n.length;r++){var o,i=ve(n[r],2),a=i[0],c=i[1],u=pe(t);try{for(u.s();!(o=u.n()).done;){var l=o.value;if(c.includes(l))return a}}catch(e){u.e(e)}finally{u.f()}}return"General"}},{key:"_injectTargetingKeys",value:function(e,t){var r=this._buildTargetingKeys(t);return f.info("Targeting keys:",r),e.map(function(e){return e.ortb2Imp||(e.ortb2Imp={}),e.ortb2Imp.ext||(e.ortb2Imp.ext={}),e.ortb2Imp.ext.data||(e.ortb2Imp.ext.data={}),Object.assign(e.ortb2Imp.ext.data,r),e.bids||(e.bids=[]),e.bids=e.bids.map(function(e){return e.params||(e.params={}),e.params.keywords||(e.params.keywords={}),Object.assign(e.params.keywords,r),e}),e})}},{key:"_buildTargetingKeys",value:function(e){var t,r={};if(e.taxonomy){r.hb_mixpeek_category=e.taxonomy.label,r.hb_mixpeek_node=e.taxonomy.nodeId,r.hb_mixpeek_path=Array.isArray(e.taxonomy.path)?e.taxonomy.path.join("/"):e.taxonomy.path,r.hb_mixpeek_score=e.taxonomy.score.toFixed(2);var n=e.taxonomy.label.match(/IAB\d+-\d+/);n&&(r.hb_mixpeek_taxonomy=n[0])}e.brandSafety&&(r.hb_mixpeek_safety="number"==typeof e.brandSafety?e.brandSafety.toFixed(2):(null===(t=e.brandSafety.score)||void 0===t?void 0:t.toFixed(2))||"0"),e.keywords&&(r.hb_mixpeek_keywords=Array.isArray(e.keywords)?e.keywords.slice(0,10).join(","):e.keywords),e.sentiment&&(r.hb_mixpeek_sentiment="string"==typeof e.sentiment?e.sentiment:e.sentiment.label||"neutral"),e.embeddingId&&(r.hb_mixpeek_embed=e.embeddingId);var o=ye.getLast();return o&&(o.creativeId&&(r.hb_mixpeek_prev_creative=String(o.creativeId)),o.bidder&&(r.hb_mixpeek_prev_bidder=String(o.bidder)),o.adUnitCode&&(r.hb_mixpeek_prev_adunit=String(o.adUnitCode)),Array.isArray(o.categories)&&o.categories.length>0&&(r.hb_mixpeek_prev_cat=o.categories.slice(0,5).join(","))),r}},{key:"formatForOrtb2SiteContent",value:function(e){var t;if(!e)return null;var r={};if(e.taxonomy){var n=se(e.taxonomy);n&&(r.cat=[n],r.cattax=6),e.taxonomy.label&&(r.genre=e.taxonomy.label)}return e.keywords&&(r.keywords=Array.isArray(e.keywords)?e.keywords.join(","):e.keywords),_()&&document.documentElement.lang&&(r.language=document.documentElement.lang),_()&&(document.title&&(r.title=document.title),window.location.href&&(r.url=window.location.href)),e.content&&(e.content.url&&!r.url&&(r.url=e.content.url),e.content.title&&!r.title&&(r.title=e.content.title)),r.ext={data:{mixpeek:{documentId:e.documentId,mode:e.mode,score:null===(t=e.taxonomy)||void 0===t?void 0:t.score,brandSafety:e.brandSafety,sentiment:e.sentiment,embeddingId:e.embeddingId}}},r}},{key:"formatForOrtb2Fragments",value:function(e){if(!e)return null;var t=this.formatForOrtb2SiteContent(e);return t?{global:{site:{content:t}}}:null}},{key:"formatAsDataSegments",value:function(e){if(!e||!e.taxonomy)return[];var t=[],r=se(e.taxonomy);return r&&t.push({id:r,name:e.taxonomy.label,value:e.taxonomy.score.toString()}),e.taxonomy.all&&Array.isArray(e.taxonomy.all)&&e.taxonomy.all.slice(1,5).forEach(function(e){var r=se(e);r&&t.push({id:r,name:e.label,value:e.score.toString()})}),t}},{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"_emitEvent",value:function(e,t){this.events[e]&&this.events[e].forEach(function(r){try{r(t)}catch(t){f.error("Error in event callback for ".concat(e,":"),t)}}),_()&&window.pbjs&&window.pbjs.emit(e,t)}},{key:"getContextData",value:function(){return this.contextData}},{key:"clearCache",value:function(){F.clear(),f.info("Cache cleared")}},{key:"getCacheStats",value:function(){return F.getStats()}},{key:"healthCheck",value:(r=Ee(Ae().m(function e(){var t,r;return Ae().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.client){e.n=1;break}return e.a(2,{status:"error",message:"Client not initialized"});case 1:return e.p=1,e.n=2,this.client.healthCheck();case 2:return t=e.v,e.a(2,_e({status:"ok"},t));case 3:return e.p=3,r=e.v,e.a(2,{status:"error",message:r.message})}},e,this,[[1,3]])})),function(){return r.apply(this,arguments)})}],t&&Ce(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a,c,u,l}());const Pe=Oe;return _()&&(window.MixpeekContextAdapter=Oe),t})());
|
|
3
3
|
//# sourceMappingURL=mixpeekContextAdapter.js.map
|