@schibsted/advertory 2.47.2 → 2.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/core/aftenposten/es/index.css +1 -1
  2. package/core/aftenposten/es/index.d.ts +1 -0
  3. package/core/aftenposten/es/index.js +1 -1
  4. package/core/aftenposten/index.d.ts +1 -0
  5. package/core/aftenposten/index.js +1 -1
  6. package/core/aftonbladet/es/index.css +1 -1
  7. package/core/aftonbladet/es/index.d.ts +1 -0
  8. package/core/aftonbladet/es/index.js +1 -1
  9. package/core/aftonbladet/index.d.ts +1 -0
  10. package/core/aftonbladet/index.js +1 -1
  11. package/core/aftonbladetv2/es/index.d.ts +1 -0
  12. package/core/aftonbladetv2/es/index.js +1 -1
  13. package/core/bt/es/index.css +1 -1
  14. package/core/bt/es/index.d.ts +1 -0
  15. package/core/bt/es/index.js +1 -1
  16. package/core/bt/index.d.ts +1 -0
  17. package/core/bt/index.js +1 -1
  18. package/core/e24/es/index.css +1 -1
  19. package/core/e24/es/index.d.ts +1 -0
  20. package/core/e24/es/index.js +1 -1
  21. package/core/e24/index.d.ts +1 -0
  22. package/core/e24/index.js +1 -1
  23. package/core/e24v2/es/index.css +1 -1
  24. package/core/e24v2/es/index.d.ts +1 -0
  25. package/core/e24v2/es/index.js +1 -1
  26. package/core/fotbollskanalen/es/index.css +1 -1
  27. package/core/fotbollskanalen/es/index.d.ts +1 -0
  28. package/core/fotbollskanalen/es/index.js +1 -1
  29. package/core/fotbollskanalen/index.d.ts +1 -0
  30. package/core/fotbollskanalen/index.js +1 -1
  31. package/core/godare/index.d.ts +1 -0
  32. package/core/godare/index.js +1 -1
  33. package/core/godt/index.d.ts +1 -0
  34. package/core/godt/index.js +1 -1
  35. package/core/klart/index.d.ts +1 -0
  36. package/core/klart/index.js +1 -1
  37. package/core/koket/es/index.css +1 -1
  38. package/core/koket/es/index.d.ts +1 -0
  39. package/core/koket/es/index.js +1 -1
  40. package/core/koket/index.d.ts +1 -0
  41. package/core/koket/index.js +1 -1
  42. package/core/kompakt/index.d.ts +1 -0
  43. package/core/kompakt/index.js +1 -1
  44. package/core/minmote/index.d.ts +1 -0
  45. package/core/minmote/index.js +1 -1
  46. package/core/pent/index.d.ts +1 -0
  47. package/core/pent/index.js +1 -1
  48. package/core/sa/es/index.css +1 -1
  49. package/core/sa/es/index.d.ts +1 -0
  50. package/core/sa/es/index.js +1 -1
  51. package/core/sa/index.d.ts +1 -0
  52. package/core/sa/index.js +1 -1
  53. package/core/svd/es/index.css +1 -1
  54. package/core/svd/es/index.d.ts +1 -0
  55. package/core/svd/es/index.js +1 -1
  56. package/core/svd/index.d.ts +1 -0
  57. package/core/svd/index.js +1 -1
  58. package/core/tek/index.d.ts +1 -0
  59. package/core/tek/index.js +1 -1
  60. package/core/tv4/es/index.css +1 -1
  61. package/core/tv4/es/index.d.ts +1 -0
  62. package/core/tv4/es/index.js +1 -1
  63. package/core/tv4/index.d.ts +1 -0
  64. package/core/tv4/index.js +1 -1
  65. package/core/vg/es/index.css +1 -1
  66. package/core/vg/es/index.d.ts +1 -0
  67. package/core/vg/es/index.js +1 -1
  68. package/core/vg/index.d.ts +1 -0
  69. package/core/vg/index.js +1 -1
  70. package/core/vgv2/es/index.css +1 -1
  71. package/core/vgv2/es/index.d.ts +1 -0
  72. package/core/vgv2/es/index.js +1 -1
  73. package/features/ad-native/index.d.ts +1 -0
  74. package/features/brandmetrics/index.js +1 -1
  75. package/features/dr-edition/es/index.d.ts +1 -0
  76. package/features/dr-edition/es/index.js +1 -1
  77. package/features/dr-edition/index.d.ts +1 -0
  78. package/features/dr-edition/index.js +1 -1
  79. package/features/tracker/index.d.ts +1 -0
  80. package/features/tracker/index.js +1 -1
  81. package/package.json +1 -1
  82. package/sites/aftenposten/es/index.css +1 -1
  83. package/sites/aftonbladet/es/index.css +1 -1
  84. package/sites/aftonbladetv2/es/index.css +1 -1
  85. package/sites/bt/es/index.css +1 -1
  86. package/sites/e24/es/index.css +1 -1
  87. package/sites/e24v2/es/index.css +1 -1
  88. package/sites/sa/es/index.css +1 -1
  89. package/sites/svd/es/index.css +1 -1
  90. package/sites/vg/es/index.css +1 -1
  91. package/sites/vgv2/es/index.css +1 -1
  92. package/types/core/interface/tcf.d.ts +1 -1
  93. package/types/features/interface/tracker.d.ts +1 -0
@@ -170,6 +170,7 @@ interface PulseInstance {
170
170
  interface Tracker {
171
171
  clientId: string;
172
172
  instance: TrackerInstance;
173
+ hasherUrl?: string;
173
174
  }
174
175
  interface Pulse {
175
176
  clientId: string;
@@ -1 +1 @@
1
- "use strict";var e,t,r=require("react/jsx-runtime");function n(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}c((n=n.apply(e,t||[])).next())})}function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var i=o(function(){if(t)return e;t=1;var r=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?d((r=e,Array.isArray(r)?[]:{}),e,t):e;var r}function i(e,t,r){return e.concat(t).map(function(e){return o(e,r)})}function a(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function c(e,t,r){var n={};return r.isMergeableObject(e)&&a(e).forEach(function(t){n[t]=o(e[t],r)}),a(t).forEach(function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&r.isMergeableObject(t[i])?n[i]=function(e,t){if(!t.customMerge)return d;var r=t.customMerge(e);return"function"==typeof r?r:d}(i,r)(e[i],t[i],r):n[i]=o(t[i],r))}),n}function d(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||i,n.isMergeableObject=n.isMergeableObject||r,n.cloneUnlessOtherwiseSpecified=o;var a=Array.isArray(t);return a===Array.isArray(e)?a?n.arrayMerge(e,t,n):c(e,t,n):o(t,n)}return d.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,r){return d(e,r,t)},{})},e=d}());const a=["deviceType","pageType","placements","takeover","refreshConfig","editableConfiguration"],s={adRequested:()=>{},adAvailable:e=>{},adLoaded:e=>{},adNoBid:e=>{},adError:(e,t)=>{},adCollapse:()=>{},adRequestFailure:e=>{},adBadRequest:e=>{},adLoadedMediated:e=>{},adNoBidMediated:e=>{}};class c{set(e){this.config=e}modifyConfigProperties(e){if(!this.config)throw new Error("Config was accessed before it had been initialized.");const t={};for(const r of a){const n=e[r];void 0!==n&&(t[r]=n)}Object.assign(this.config,t),Object.prototype.hasOwnProperty.call(e,"pageOptions")&&void 0!==e.pageOptions&&(this.config.pageOptions=Object.assign(Object.assign({},this.config.pageOptions),e.pageOptions))}get(){if(!this.config)throw new Error("Config was accessed before it had been initialized.");return this.config}getHandlers(){if(!this.siteHandlers)throw new Error("Handlers were accessed before it had been initialized.");return this.siteHandlers}setHandlers(e){this.siteHandlers=i(c.DEFAULT_SITE_HANDLERS,e)}}c.DEFAULT_SITE_HANDLERS={siteEvents:s,initNativeAd:function(){}};const d=new c;d.modifyConfigProperties.bind(d);const u=(e,t)=>{location.search.includes("ast_debug=true")&&console.log("[Advertory LOG]: ",e)},l="cmp:loaded";let f,y=!1;const b=e=>{const t=!!(null==e?void 0:e.enabled),r=(null==e?void 0:e.timeout)||3e3,o=(i="bypass_tcf",new URLSearchParams(window.location.search).get(i));var i;const a=()=>{if(((e,t)=>e?!!t&&(u("TCF bypass param detected, returning consent: true"),!0):(u("TCF is not enabled, returning consent: true"),!0))(t,o))return!0;if(y)return null;if(!f)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=f.getConsentedToAllSync();return u(`TCF consented to all is: ${e}`),f.getConsentedToAllSync()};return{initConsentManager:()=>new Promise((e,t)=>{if(u("Getting TCF consent manager..."),window._tcf_)return u("TCF consent manager is already available"),f=window._tcf_,void e(f);u("TCF consent manager is not available");const n=()=>{u("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(f=window._tcf_,e(f)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(l,n),y=!0,t(new Error("Timeout waiting for CMP to load"))},r);u("Listening for CMP loaded event..."),document.addEventListener(l,n,{once:!0})}),getConsentSync:a,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){const e=a();return null!==e?e:yield new Promise((e,t)=>{try{if(!f)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");f.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}};!function(e){if("undefined"==typeof window)return;const t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t)}(".advertory-brandmetrics-survey{width:100%}");const m="advertory-brandmetrics-survey";exports.BrandMetricsSurvey=()=>r.jsx("div",{id:"brandmetrics-survey",className:"advertory-brandmetrics-survey"}),exports.loadBrandmetricsScript=()=>n(void 0,void 0,void 0,function*(){const{brandmetrics:{enabled:e,url:t}={},tcf:r}=d.get(),{getConsentSync:o}=b(r),i=o();if(!e||!t||!i)return;yield((e,...t)=>n(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((r,n)=>{const o=document.createElement("script");o.async=!0,o.src=e;const i=()=>{s(),r()},a=()=>{s(),n(new Error(`Failed to load ${e}`))},s=()=>{o.removeEventListener("load",i),o.removeEventListener("error",a),clearTimeout(c)};o.addEventListener("load",i),o.addEventListener("error",a);const c=setTimeout(()=>{s(),n(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(o)}).catch(e=>{console.error(e)}))}))(t);if(document.querySelector(`.${m}`))return window._brandmetrics=window._brandmetrics||[],void window._brandmetrics.push({cmd:"_loadsurvey"});new MutationObserver((e,t)=>{for(const r of e){if("childList"!==r.type)return;Array.from(r.addedNodes).some(e=>{var t;return null===(t=e.outerHTML)||void 0===t?void 0:t.includes(m)})&&(t.disconnect(),window._brandmetrics=window._brandmetrics||[],window._brandmetrics.push({cmd:"_loadsurvey"}))}}).observe(document,{childList:!0,subtree:!0,attributes:!0})});
1
+ "use strict";var e,t,n=require("react/jsx-runtime");function r(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})}function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var i=o(function(){if(t)return e;t=1;var n=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===r}(e)}(e)},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?d((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function i(e,t,n){return e.concat(t).map(function(e){return o(e,n)})}function a(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function c(e,t,n){var r={};return n.isMergeableObject(e)&&a(e).forEach(function(t){r[t]=o(e[t],n)}),a(t).forEach(function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return d;var n=t.customMerge(e);return"function"==typeof n?n:d}(i,n)(e[i],t[i],n):r[i]=o(t[i],n))}),r}function d(e,t,r){(r=r||{}).arrayMerge=r.arrayMerge||i,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=o;var a=Array.isArray(t);return a===Array.isArray(e)?a?r.arrayMerge(e,t,r):c(e,t,r):o(t,r)}return d.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return d(e,n,t)},{})},e=d}());const a=["deviceType","pageType","placements","takeover","refreshConfig","editableConfiguration"],s={adRequested:()=>{},adAvailable:e=>{},adLoaded:e=>{},adNoBid:e=>{},adError:(e,t)=>{},adCollapse:()=>{},adRequestFailure:e=>{},adBadRequest:e=>{},adLoadedMediated:e=>{},adNoBidMediated:e=>{}};class c{set(e){this.config=e}modifyConfigProperties(e){if(!this.config)throw new Error("Config was accessed before it had been initialized.");const t={};for(const n of a){const r=e[n];void 0!==r&&(t[n]=r)}Object.assign(this.config,t),Object.prototype.hasOwnProperty.call(e,"pageOptions")&&void 0!==e.pageOptions&&(this.config.pageOptions=Object.assign(Object.assign({},this.config.pageOptions),e.pageOptions))}get(){if(!this.config)throw new Error("Config was accessed before it had been initialized.");return this.config}getHandlers(){if(!this.siteHandlers)throw new Error("Handlers were accessed before it had been initialized.");return this.siteHandlers}setHandlers(e){this.siteHandlers=i(c.DEFAULT_SITE_HANDLERS,e)}}c.DEFAULT_SITE_HANDLERS={siteEvents:s,initNativeAd:function(){}};const d=new c;d.modifyConfigProperties.bind(d);const u=(e,t)=>{location.search.includes("ast_debug=true")&&console.log("[Advertory LOG]: ",e)},l="cmp:loaded";let f,y=!1;const b=e=>{const t=!!(null==e?void 0:e.enabled),n=(null==e?void 0:e.timeout)||3e3,o=(i="bypass_tcf",new URLSearchParams(window.location.search).get(i));var i;const a=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(u("TCF bypass param detected, returning consent: true"),!0):(u("TCF is not enabled, returning consent: true"),!0))(t,o))return!0;if(y)return null;if(!f)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const n=f.getConsentedToAllSync();return u(`TCF consented to all is: ${n}`),f.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(u("Getting TCF consent manager..."),window._tcf_)return u("TCF consent manager is already available"),f=window._tcf_,void e(f);u("TCF consent manager is not available");const r=()=>{u("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(f=window._tcf_,e(f)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(l,r),y=!0,t(new Error("Timeout waiting for CMP to load"))},n);u("Listening for CMP loaded event..."),document.addEventListener(l,r,{once:!0})}):Promise.resolve(null),getConsentSync:a,getConsentAsync:()=>r(void 0,void 0,void 0,function*(){const t=a();return!(null==e?void 0:e.enabled)||(null!==t?t:yield new Promise((e,t)=>{try{if(!f)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");f.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}}))})}};!function(e){if("undefined"==typeof window)return;const t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t)}(".advertory-brandmetrics-survey{width:100%}");const m="advertory-brandmetrics-survey";exports.BrandMetricsSurvey=()=>n.jsx("div",{id:"brandmetrics-survey",className:"advertory-brandmetrics-survey"}),exports.loadBrandmetricsScript=()=>r(void 0,void 0,void 0,function*(){const{brandmetrics:{enabled:e,url:t}={},tcf:n}=d.get(),{getConsentSync:o}=b(n),i=o();if(!e||!t||!i)return;yield((e,...t)=>r(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,r)=>{const o=document.createElement("script");o.async=!0,o.src=e;const i=()=>{s(),n()},a=()=>{s(),r(new Error(`Failed to load ${e}`))},s=()=>{o.removeEventListener("load",i),o.removeEventListener("error",a),clearTimeout(c)};o.addEventListener("load",i),o.addEventListener("error",a);const c=setTimeout(()=>{s(),r(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(o)}).catch(e=>{console.error(e)}))}))(t);if(document.querySelector(`.${m}`))return window._brandmetrics=window._brandmetrics||[],void window._brandmetrics.push({cmd:"_loadsurvey"});new MutationObserver((e,t)=>{for(const n of e){if("childList"!==n.type)return;Array.from(n.addedNodes).some(e=>{var t;return null===(t=e.outerHTML)||void 0===t?void 0:t.includes(m)})&&(t.disconnect(),window._brandmetrics=window._brandmetrics||[],window._brandmetrics.push({cmd:"_loadsurvey"}))}}).observe(document,{childList:!0,subtree:!0,attributes:!0})});
@@ -173,6 +173,7 @@ interface PulseInstance {
173
173
  interface Tracker {
174
174
  clientId: string;
175
175
  instance: TrackerInstance;
176
+ hasherUrl?: string;
176
177
  }
177
178
  interface Pulse {
178
179
  clientId: string;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";function n(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(e,t)=>n(void 0,void 0,void 0,function*(){const n=yield fetch(e,t);if(!n.ok)throw new Error(n.statusText);return yield n.json()}),post:(e,t,i)=>n(void 0,void 0,void 0,function*(){const n=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:t,body:n});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},r=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},o=["netboard","board"];class a{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),s=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return s.searchParams.append("editionName",r),o&&s.searchParams.append("urlData",o),a&&s.searchParams.append("excludedItems",a),l&&s.searchParams.append("spid",l),d&&s.searchParams.append("envid",d),s.toString()}fetchData(e){return n(this,void 0,void 0,function*(){var t,n;const o=yield this.identityFacade.getIdentityUser(),a=null!==(n=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==n?n:"",s=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:a,spid:s});try{r("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield i.get(d,e);return r("Fetch operation completed successfully."),t}catch(e){r("Error during fetch operation:",e)}return null})}}class s{getDrEditionUTMParams(e,t){var n;const{title:i,clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:a}=t,s=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:s},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,t){return n(this,void 0,void 0,function*(){const{id:n,autoplay:i,mute:r,videoLoop:o,vendor:a}=t.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:n,vgtvVendor:a,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const d=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},l=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))};class c{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,t){return n(this,void 0,void 0,function*(){var n,i;const{drEditionConfig:{containerSelector:o},renderAsBackfill:a=!1}=t,s=e.querySelector(o);if(!s)return void r(`Container with selector "${o}" not found.`);const c=yield this.drEditionService.fetchData(t);return(null==c?void 0:c.itemId)||a?!(null==c?void 0:c.itemId)&&a?(r("No Dr. Edition ads available to render. Collapsing whole placement."),void d(e.id)):((null==c?void 0:c.itemId)&&a&&(r("Dr. Edition ad available to render as a Xandr backfill."),l(e.id)),void(c&&(c.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(c.css,"style"),this.rendererManager.render(s,c,t),yield null===(n=this.videoManager)||void 0===n?void 0:n.handle(c,t),this.drEditionAds.push(c),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(c.itemId),this.observeAdView(e,c,t),null===(i=e.querySelector("a"))||void 0===i||i.addEventListener("pointerup",()=>null)))):(r("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(s),void this.showBackfill(e))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";l(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const u="cmp:loaded";let v,p=!1;const m=e=>{const t=!!(null==e?void 0:e.enabled),i=(null==e?void 0:e.timeout)||3e3,o=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const s=()=>{if(((e,t)=>e?!!t&&(r("TCF bypass param detected, returning consent: true"),!0):(r("TCF is not enabled, returning consent: true"),!0))(t,o))return!0;if(p)return null;if(!v)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=v.getConsentedToAllSync();return r(`TCF consented to all is: ${e}`),v.getConsentedToAllSync()};return{initConsentManager:()=>new Promise((e,t)=>{if(r("Getting TCF consent manager..."),window._tcf_)return r("TCF consent manager is already available"),v=window._tcf_,void e(v);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(v=window._tcf_,e(v)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(u,n),p=!0,t(new Error("Timeout waiting for CMP to load"))},i);r("Listening for CMP loaded event..."),document.addEventListener(u,n,{once:!0})}),getConsentSync:s,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){const e=s();return null!==e?e:yield new Promise((e,t)=>{try{if(!v)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");v.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},h="mobile";class g{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){if(!(null==t?void 0:t.itemId))return;const{getConsentSync:i}=m(n.tcf),r=!!i(),o=n.device===h?t.mobileHTML:t.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,e.querySelectorAll("a").forEach(e=>{var i,r,o;e.search=null!==(o=null===(r=(i=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(i,e,t,n))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,n)})}}class y{constructor(e){this.strategy=e}handle(e,t){return n(this,void 0,void 0,function*(){const{videoConfiguration:{id:n,preview:i}={}}=e;(n||i)&&(yield this.importScript(t),yield this.createVideoElement(e,t))})}importScript(e){return n(this,void 0,void 0,function*(){const t=e.drEditionConfig.videoScriptUrl,i=document.querySelector(`script[src="${t}"]`);if(t&&!window.autoplayQueue&&!i)try{yield((e,...t)=>n(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{s(),n()},a=()=>{s(),i(new Error(`Failed to load ${e}`))},s=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",a);const d=setTimeout(()=>{s(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)}catch(e){r("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,t){return n(this,void 0,void 0,function*(){const n=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,t))return;this.strategy.handleVideo(n,e),null==r||r.appendChild(n),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const s=document.querySelector(".dr-edition-preview .preview-video");return!!s&&(s.setAttribute("playsinline",""),!(!s||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,s),!0))}}class w{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,a,s;if(!this.pulse)return;const d=this.getEventInput(e,t,i,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackViewUIElement)||void 0===o||o.call(r,d):null===(s=null===(a=this.pulse)||void 0===a?void 0:a.trackElementView)||void 0===s||s.call(a,d)})}trackContentClick(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,a;if(!this.pulse)return;const s=this.getEventInput(e,t,i,"click");this.pulse.trackClickUIElement?null===(r=(n=this.pulse).trackClickUIElement)||void 0===r||r.call(n,s):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,s)})}}class f extends w{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:a,primaryPosition:s}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:s},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class E extends w{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,a,s,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),m=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=m?m:v,"@type":p,url:location.origin},tags:null===(d=null===(s=this.newsroomStrategy)||void 0===s?void 0:s.getTags)||void 0===d?void 0:d.call(s,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,a,s;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:m}={}}=t,h=Math.floor(Date.now()/1e3),g=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),w=this.getTeaserElementText(e,"image"),f=null!==(s=null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==a?a:p)&&void 0!==s?s:"";return{algorithm:d,clientName:l,probability:m,creativeId:c,device:n.device,editionId:u,itemId:v,link:f,placement:n.editionName,subtitle:y,time:h,title:g,type:i,imageUrl:w,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const b="vg",P="aftonbladet",I="e24",T="front",S=e=>n(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),C={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return n(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return q})})}})}};class L{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:a}}){yield n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const s=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=s)||l.forEach(e=>{C[e](c)});const u={id:t,node:i,autoplay:r,mute:o,vendor:a,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield S(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,s)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===T?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const k="https://www.aftonbladet.se/video-player-extras/latest/";class j{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const a={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${k}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${k}external-link.js`]:{name:"ExternalLink"}}};yield S(a),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}class A{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const M="se",N=(e,t,n)=>{const{publisher:i,pageType:r,country:o}=e,d={[b]:new s,[I]:new L,[P]:new j}[i]||new A,l=new(o===M?f:E)(n,d,r),u=new a(t,null==n?void 0:n.pulseTracker),v=new g(d,l),p=new y(d);return new c(u,v,p,l)},U=({editionName:n,fallbackTargetId:i,children:r,pulseData:o})=>{const a=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(o);return e("div",Object.assign({className:"dr-edition-wrapper","data-edition-name":n},a,{children:[t("div",{className:"inscreen-target"}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},D=()=>n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class V{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return n(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return r("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return n(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const _=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=N(n,i,r);e.forEach(e=>{var i,r,a;if(!e.isIntersecting)return;const s=e.target,d=null!==(i=s.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=s.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(a=s.dataset.pulsePrimaryposition)&&void 0!==a?a:"";o.fetchAndRenderAd(s,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(s)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},x=[],O=(e,t)=>n(void 0,void 0,void 0,function*(){var n;const{pulse:i,tcf:a,deviceType:s,drEdition:d,publisher:l,pageType:c,country:u}=e,v=((e,t)=>{var n;const{deviceType:i,placements:r,drEdition:{fallbackGlobalEditionName:a}={}}=e,s=r[i]||r.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=s.find(e=>e.id===d),c=o.some(e=>d.startsWith(e)),u=x.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(x.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,t);if(!v)return;if(!(null==i?void 0:i.instance))return void r("Pulse has not been passed as a prop, aborting");const p=yield D(),m=new V(p),h=N({publisher:l,pageType:c,country:u},m,null==i?void 0:i.instance),g=document.getElementById(t.targetId);if(!g||!d)return;g.classList.value="";const y=document.createElement("div");y.className=d.containerSelector.replace(/^[.#:[\]]+/,""),g.innerHTML=y.outerHTML;const w={editionName:(null===(n=null==v?void 0:v.drEdition)||void 0===n?void 0:n.editionName)||"",drEditionConfig:d,device:s,tcf:a,renderAsBackfill:!0};yield h.fetchAndRenderAd(g,w)}),B=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;const n=yield D(),i=new V(n);_({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)});const R=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var q=Object.freeze({__proto__:null,default:R});export{U as DrEdition,N as getDrEditionManager,B as handleDrEdition,O as handleDrEditionBackfill};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";function n(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(e,t)=>n(void 0,void 0,void 0,function*(){const n=yield fetch(e,t);if(!n.ok)throw new Error(n.statusText);return yield n.json()}),post:(e,t,i)=>n(void 0,void 0,void 0,function*(){const n=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:t,body:n});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},r=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},o=["netboard","board"];class a{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),s=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return s.searchParams.append("editionName",r),o&&s.searchParams.append("urlData",o),a&&s.searchParams.append("excludedItems",a),l&&s.searchParams.append("spid",l),d&&s.searchParams.append("envid",d),s.toString()}fetchData(e){return n(this,void 0,void 0,function*(){var t,n;const o=yield this.identityFacade.getIdentityUser(),a=null!==(n=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==n?n:"",s=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:a,spid:s});try{r("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield i.get(d,e);return r("Fetch operation completed successfully."),t}catch(e){r("Error during fetch operation:",e)}return null})}}class s{getDrEditionUTMParams(e,t){var n;const{title:i,clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:a}=t,s=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:s},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,t){return n(this,void 0,void 0,function*(){const{id:n,autoplay:i,mute:r,videoLoop:o,vendor:a}=t.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:n,vgtvVendor:a,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const d=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},l=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))};class c{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,t){return n(this,void 0,void 0,function*(){var n,i;const{drEditionConfig:{containerSelector:o},renderAsBackfill:a=!1}=t,s=e.querySelector(o);if(!s)return void r(`Container with selector "${o}" not found.`);const c=yield this.drEditionService.fetchData(t);return(null==c?void 0:c.itemId)||a?!(null==c?void 0:c.itemId)&&a?(r("No Dr. Edition ads available to render. Collapsing whole placement."),void d(e.id)):((null==c?void 0:c.itemId)&&a&&(r("Dr. Edition ad available to render as a Xandr backfill."),l(e.id)),void(c&&(c.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(c.css,"style"),this.rendererManager.render(s,c,t),yield null===(n=this.videoManager)||void 0===n?void 0:n.handle(c,t),this.drEditionAds.push(c),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(c.itemId),this.observeAdView(e,c,t),null===(i=e.querySelector("a"))||void 0===i||i.addEventListener("pointerup",()=>null)))):(r("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(s),void this.showBackfill(e))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";l(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const u="cmp:loaded";let v,p=!1;const m=e=>{const t=!!(null==e?void 0:e.enabled),i=(null==e?void 0:e.timeout)||3e3,o=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const s=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(r("TCF bypass param detected, returning consent: true"),!0):(r("TCF is not enabled, returning consent: true"),!0))(t,o))return!0;if(p)return null;if(!v)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const n=v.getConsentedToAllSync();return r(`TCF consented to all is: ${n}`),v.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(r("Getting TCF consent manager..."),window._tcf_)return r("TCF consent manager is already available"),v=window._tcf_,void e(v);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(v=window._tcf_,e(v)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(u,n),p=!0,t(new Error("Timeout waiting for CMP to load"))},i);r("Listening for CMP loaded event..."),document.addEventListener(u,n,{once:!0})}):Promise.resolve(null),getConsentSync:s,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){const t=s();return!(null==e?void 0:e.enabled)||(null!==t?t:yield new Promise((e,t)=>{try{if(!v)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");v.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}}))})}},h="mobile";class g{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){if(!(null==t?void 0:t.itemId))return;const{getConsentSync:i}=m(n.tcf),r=!!i(),o=n.device===h?t.mobileHTML:t.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,e.querySelectorAll("a").forEach(e=>{var i,r,o;e.search=null!==(o=null===(r=(i=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(i,e,t,n))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,n)})}}class y{constructor(e){this.strategy=e}handle(e,t){return n(this,void 0,void 0,function*(){const{videoConfiguration:{id:n,preview:i}={}}=e;(n||i)&&(yield this.importScript(t),yield this.createVideoElement(e,t))})}importScript(e){return n(this,void 0,void 0,function*(){const t=e.drEditionConfig.videoScriptUrl,i=document.querySelector(`script[src="${t}"]`);if(t&&!window.autoplayQueue&&!i)try{yield((e,...t)=>n(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{s(),n()},a=()=>{s(),i(new Error(`Failed to load ${e}`))},s=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",a);const d=setTimeout(()=>{s(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)}catch(e){r("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,t){return n(this,void 0,void 0,function*(){const n=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,t))return;this.strategy.handleVideo(n,e),null==r||r.appendChild(n),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const s=document.querySelector(".dr-edition-preview .preview-video");return!!s&&(s.setAttribute("playsinline",""),!(!s||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,s),!0))}}class w{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,a,s;if(!this.pulse)return;const d=this.getEventInput(e,t,i,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackViewUIElement)||void 0===o||o.call(r,d):null===(s=null===(a=this.pulse)||void 0===a?void 0:a.trackElementView)||void 0===s||s.call(a,d)})}trackContentClick(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,a;if(!this.pulse)return;const s=this.getEventInput(e,t,i,"click");this.pulse.trackClickUIElement?null===(r=(n=this.pulse).trackClickUIElement)||void 0===r||r.call(n,s):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,s)})}}class f extends w{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:a,primaryPosition:s}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:s},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class E extends w{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,a,s,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),m=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=m?m:v,"@type":p,url:location.origin},tags:null===(d=null===(s=this.newsroomStrategy)||void 0===s?void 0:s.getTags)||void 0===d?void 0:d.call(s,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,a,s;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:m}={}}=t,h=Math.floor(Date.now()/1e3),g=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),w=this.getTeaserElementText(e,"image"),f=null!==(s=null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==a?a:p)&&void 0!==s?s:"";return{algorithm:d,clientName:l,probability:m,creativeId:c,device:n.device,editionId:u,itemId:v,link:f,placement:n.editionName,subtitle:y,time:h,title:g,type:i,imageUrl:w,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const b="vg",P="aftonbladet",I="e24",T="front",S=e=>n(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),C={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return n(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return q})})}})}};class L{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:a}}){yield n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const s=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=s)||l.forEach(e=>{C[e](c)});const u={id:t,node:i,autoplay:r,mute:o,vendor:a,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield S(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,s)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===T?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const k="https://www.aftonbladet.se/video-player-extras/latest/";class j{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const a={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${k}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${k}external-link.js`]:{name:"ExternalLink"}}};yield S(a),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}class A{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const M="se",N=(e,t,n)=>{const{publisher:i,pageType:r,country:o}=e,d={[b]:new s,[I]:new L,[P]:new j}[i]||new A,l=new(o===M?f:E)(n,d,r),u=new a(t,null==n?void 0:n.pulseTracker),v=new g(d,l),p=new y(d);return new c(u,v,p,l)},U=({editionName:n,fallbackTargetId:i,children:r,pulseData:o})=>{const a=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(o);return e("div",Object.assign({className:"dr-edition-wrapper","data-edition-name":n},a,{children:[t("div",{className:"inscreen-target"}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},D=()=>n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class V{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return n(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return r("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return n(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const _=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=N(n,i,r);e.forEach(e=>{var i,r,a;if(!e.isIntersecting)return;const s=e.target,d=null!==(i=s.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=s.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(a=s.dataset.pulsePrimaryposition)&&void 0!==a?a:"";o.fetchAndRenderAd(s,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(s)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},x=[],O=(e,t)=>n(void 0,void 0,void 0,function*(){var n;const{pulse:i,tcf:a,deviceType:s,drEdition:d,publisher:l,pageType:c,country:u}=e,v=((e,t)=>{var n;const{deviceType:i,placements:r,drEdition:{fallbackGlobalEditionName:a}={}}=e,s=r[i]||r.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=s.find(e=>e.id===d),c=o.some(e=>d.startsWith(e)),u=x.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(x.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,t);if(!v)return;if(!(null==i?void 0:i.instance))return void r("Pulse has not been passed as a prop, aborting");const p=yield D(),m=new V(p),h=N({publisher:l,pageType:c,country:u},m,null==i?void 0:i.instance),g=document.getElementById(t.targetId);if(!g||!d)return;g.classList.value="";const y=document.createElement("div");y.className=d.containerSelector.replace(/^[.#:[\]]+/,""),g.innerHTML=y.outerHTML;const w={editionName:(null===(n=null==v?void 0:v.drEdition)||void 0===n?void 0:n.editionName)||"",drEditionConfig:d,device:s,tcf:a,renderAsBackfill:!0};yield h.fetchAndRenderAd(g,w)}),B=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;const n=yield D(),i=new V(n);_({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)});const R=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var q=Object.freeze({__proto__:null,default:R});export{U as DrEdition,N as getDrEditionManager,B as handleDrEdition,O as handleDrEditionBackfill};
@@ -173,6 +173,7 @@ interface PulseInstance {
173
173
  interface Tracker {
174
174
  clientId: string;
175
175
  instance: TrackerInstance;
176
+ hasherUrl?: string;
176
177
  }
177
178
  interface Pulse {
178
179
  clientId: string;
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime");function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const n={get:(e,n)=>t(void 0,void 0,void 0,function*(){const t=yield fetch(e,n);if(!t.ok)throw new Error(t.statusText);return yield t.json()}),post:(e,n,i)=>t(void 0,void 0,void 0,function*(){const t=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:n,body:t});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},i=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},r=["netboard","board"];class o{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),s=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return s.searchParams.append("editionName",r),o&&s.searchParams.append("urlData",o),a&&s.searchParams.append("excludedItems",a),l&&s.searchParams.append("spid",l),d&&s.searchParams.append("envid",d),s.toString()}fetchData(e){return t(this,void 0,void 0,function*(){var t,r;const o=yield this.identityFacade.getIdentityUser(),a=null!==(r=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==r?r:"",s=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:a,spid:s});try{i("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield n.get(d,e);return i("Fetch operation completed successfully."),t}catch(e){i("Error during fetch operation:",e)}return null})}}class a{getDrEditionUTMParams(e,t){var n;const{title:i,clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:a}=t,s=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:s},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,n){return t(this,void 0,void 0,function*(){const{id:t,autoplay:i,mute:r,videoLoop:o,vendor:a}=n.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:t,vgtvVendor:a,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const s=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},d=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))};class l{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,n){return t(this,void 0,void 0,function*(){var t,r;const{drEditionConfig:{containerSelector:o},renderAsBackfill:a=!1}=n,l=e.querySelector(o);if(!l)return void i(`Container with selector "${o}" not found.`);const c=yield this.drEditionService.fetchData(n);return(null==c?void 0:c.itemId)||a?!(null==c?void 0:c.itemId)&&a?(i("No Dr. Edition ads available to render. Collapsing whole placement."),void s(e.id)):((null==c?void 0:c.itemId)&&a&&(i("Dr. Edition ad available to render as a Xandr backfill."),d(e.id)),void(c&&(c.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(c.css,"style"),this.rendererManager.render(l,c,n),yield null===(t=this.videoManager)||void 0===t?void 0:t.handle(c,n),this.drEditionAds.push(c),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(c.itemId),this.observeAdView(e,c,n),null===(r=e.querySelector("a"))||void 0===r||r.addEventListener("pointerup",()=>null)))):(i("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(l),void this.showBackfill(e))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";d(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const c="cmp:loaded";let u,v=!1;const p=e=>{const n=!!(null==e?void 0:e.enabled),r=(null==e?void 0:e.timeout)||3e3,o=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const s=()=>{if(((e,t)=>e?!!t&&(i("TCF bypass param detected, returning consent: true"),!0):(i("TCF is not enabled, returning consent: true"),!0))(n,o))return!0;if(v)return null;if(!u)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=u.getConsentedToAllSync();return i(`TCF consented to all is: ${e}`),u.getConsentedToAllSync()};return{initConsentManager:()=>new Promise((e,t)=>{if(i("Getting TCF consent manager..."),window._tcf_)return i("TCF consent manager is already available"),u=window._tcf_,void e(u);i("TCF consent manager is not available");const n=()=>{i("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(u=window._tcf_,e(u)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(c,n),v=!0,t(new Error("Timeout waiting for CMP to load"))},r);i("Listening for CMP loaded event..."),document.addEventListener(c,n,{once:!0})}),getConsentSync:s,getConsentAsync:()=>t(void 0,void 0,void 0,function*(){const e=s();return null!==e?e:yield new Promise((e,t)=>{try{if(!u)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");u.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},m="mobile";class h{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){if(!(null==t?void 0:t.itemId))return;const{getConsentSync:i}=p(n.tcf),r=!!i(),o=n.device===m?t.mobileHTML:t.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,e.querySelectorAll("a").forEach(e=>{var i,r,o;e.search=null!==(o=null===(r=(i=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(i,e,t,n))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,n)})}}class g{constructor(e){this.strategy=e}handle(e,n){return t(this,void 0,void 0,function*(){const{videoConfiguration:{id:t,preview:i}={}}=e;(t||i)&&(yield this.importScript(n),yield this.createVideoElement(e,n))})}importScript(e){return t(this,void 0,void 0,function*(){const n=e.drEditionConfig.videoScriptUrl,r=document.querySelector(`script[src="${n}"]`);if(n&&!window.autoplayQueue&&!r)try{yield((e,...n)=>t(void 0,[e,...n],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{s(),n()},a=()=>{s(),i(new Error(`Failed to load ${e}`))},s=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",a);const d=setTimeout(()=>{s(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(n)}catch(e){i("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,n){return t(this,void 0,void 0,function*(){const t=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,n))return;this.strategy.handleVideo(t,e),null==r||r.appendChild(t),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const s=document.querySelector(".dr-edition-preview .preview-video");return!!s&&(s.setAttribute("playsinline",""),!(!s||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,s),!0))}}class y{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,a,s;if(!this.pulse)return;const d=this.getEventInput(e,n,i,"view");(null===(t=this.pulse)||void 0===t?void 0:t.trackViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackViewUIElement)||void 0===o||o.call(r,d):null===(s=null===(a=this.pulse)||void 0===a?void 0:a.trackElementView)||void 0===s||s.call(a,d)})}trackContentClick(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,a;if(!this.pulse)return;const s=this.getEventInput(e,n,i,"click");this.pulse.trackClickUIElement?null===(r=(t=this.pulse).trackClickUIElement)||void 0===r||r.call(t,s):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,s)})}}class w extends y{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:a,primaryPosition:s}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:s},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class f extends y{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,a,s,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),m=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=m?m:v,"@type":p,url:location.origin},tags:null===(d=null===(s=this.newsroomStrategy)||void 0===s?void 0:s.getTags)||void 0===d?void 0:d.call(s,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,a,s;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:m}={}}=t,h=Math.floor(Date.now()/1e3),g=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),w=this.getTeaserElementText(e,"image"),f=null!==(s=null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==a?a:p)&&void 0!==s?s:"";return{algorithm:d,clientName:l,probability:m,creativeId:c,device:n.device,editionId:u,itemId:v,link:f,placement:n.editionName,subtitle:y,time:h,title:g,type:i,imageUrl:w,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const E="vg",b="aftonbladet",P="e24",I="front",T=e=>t(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),S={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return t(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return _})})}})}};class C{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:a}}){yield t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const s=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=s)||l.forEach(e=>{S[e](c)});const u={id:n,node:i,autoplay:r,mute:o,vendor:a,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield T(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,s)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===I?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const L="https://www.aftonbladet.se/video-player-extras/latest/";class k{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const a={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${L}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${L}external-link.js`]:{name:"ExternalLink"}}};yield T(a),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}class j{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const A="se",M=(e,t,n)=>{const{publisher:i,pageType:r,country:s}=e,d={[E]:new a,[P]:new C,[b]:new k}[i]||new j,c=new(s===A?w:f)(n,d,r),u=new o(t,null==n?void 0:n.pulseTracker),v=new h(d,c),p=new g(d);return new l(u,v,p,c)},D=()=>t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class x{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return t(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return i("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return t(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const N=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=M(n,i,r);e.forEach(e=>{var i,r,a;if(!e.isIntersecting)return;const s=e.target,d=null!==(i=s.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=s.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(a=s.dataset.pulsePrimaryposition)&&void 0!==a?a:"";o.fetchAndRenderAd(s,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(s)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},U=[];const V=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var _=Object.freeze({__proto__:null,default:V});exports.DrEdition=({editionName:t,fallbackTargetId:n,children:i,pulseData:r})=>{const o=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(r);return e.jsxs("div",Object.assign({className:"dr-edition-wrapper","data-edition-name":t},o,{children:[e.jsx("div",{className:"inscreen-target"}),e.jsx("div",{className:"container"}),e.jsx("div",{className:"fallback","data-fallback-target-id":n,style:{display:"none"},children:i})]}))},exports.getDrEditionManager=M,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;const n=yield D(),i=new x(n);N({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)}),exports.handleDrEditionBackfill=(e,n)=>t(void 0,void 0,void 0,function*(){var t;const{pulse:o,tcf:a,deviceType:s,drEdition:d,publisher:l,pageType:c,country:u}=e,v=((e,t)=>{var n;const{deviceType:i,placements:o,drEdition:{fallbackGlobalEditionName:a}={}}=e,s=o[i]||o.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=s.find(e=>e.id===d),c=r.some(e=>d.startsWith(e)),u=U.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(U.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,n);if(!v)return;if(!(null==o?void 0:o.instance))return void i("Pulse has not been passed as a prop, aborting");const p=yield D(),m=new x(p),h=M({publisher:l,pageType:c,country:u},m,null==o?void 0:o.instance),g=document.getElementById(n.targetId);if(!g||!d)return;g.classList.value="";const y=document.createElement("div");y.className=d.containerSelector.replace(/^[.#:[\]]+/,""),g.innerHTML=y.outerHTML;const w={editionName:(null===(t=null==v?void 0:v.drEdition)||void 0===t?void 0:t.editionName)||"",drEditionConfig:d,device:s,tcf:a,renderAsBackfill:!0};yield h.fetchAndRenderAd(g,w)});
1
+ "use strict";var e=require("react/jsx-runtime");function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const n={get:(e,n)=>t(void 0,void 0,void 0,function*(){const t=yield fetch(e,n);if(!t.ok)throw new Error(t.statusText);return yield t.json()}),post:(e,n,i)=>t(void 0,void 0,void 0,function*(){const t=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:n,body:t});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},i=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},r=["netboard","board"];class o{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),s=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return s.searchParams.append("editionName",r),o&&s.searchParams.append("urlData",o),a&&s.searchParams.append("excludedItems",a),l&&s.searchParams.append("spid",l),d&&s.searchParams.append("envid",d),s.toString()}fetchData(e){return t(this,void 0,void 0,function*(){var t,r;const o=yield this.identityFacade.getIdentityUser(),a=null!==(r=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==r?r:"",s=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:a,spid:s});try{i("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield n.get(d,e);return i("Fetch operation completed successfully."),t}catch(e){i("Error during fetch operation:",e)}return null})}}class a{getDrEditionUTMParams(e,t){var n;const{title:i,clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:a}=t,s=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:s},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,n){return t(this,void 0,void 0,function*(){const{id:t,autoplay:i,mute:r,videoLoop:o,vendor:a}=n.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:t,vgtvVendor:a,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const s=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},d=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))};class l{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,n){return t(this,void 0,void 0,function*(){var t,r;const{drEditionConfig:{containerSelector:o},renderAsBackfill:a=!1}=n,l=e.querySelector(o);if(!l)return void i(`Container with selector "${o}" not found.`);const c=yield this.drEditionService.fetchData(n);return(null==c?void 0:c.itemId)||a?!(null==c?void 0:c.itemId)&&a?(i("No Dr. Edition ads available to render. Collapsing whole placement."),void s(e.id)):((null==c?void 0:c.itemId)&&a&&(i("Dr. Edition ad available to render as a Xandr backfill."),d(e.id)),void(c&&(c.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(c.css,"style"),this.rendererManager.render(l,c,n),yield null===(t=this.videoManager)||void 0===t?void 0:t.handle(c,n),this.drEditionAds.push(c),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(c.itemId),this.observeAdView(e,c,n),null===(r=e.querySelector("a"))||void 0===r||r.addEventListener("pointerup",()=>null)))):(i("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(l),void this.showBackfill(e))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";d(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const c="cmp:loaded";let u,v=!1;const p=e=>{const n=!!(null==e?void 0:e.enabled),r=(null==e?void 0:e.timeout)||3e3,o=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const s=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(i("TCF bypass param detected, returning consent: true"),!0):(i("TCF is not enabled, returning consent: true"),!0))(n,o))return!0;if(v)return null;if(!u)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=u.getConsentedToAllSync();return i(`TCF consented to all is: ${t}`),u.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(i("Getting TCF consent manager..."),window._tcf_)return i("TCF consent manager is already available"),u=window._tcf_,void e(u);i("TCF consent manager is not available");const n=()=>{i("CMP loaded, resolving consent manager..."),o&&clearTimeout(o),window._tcf_?(u=window._tcf_,e(u)):t(new Error("CMP loaded but window._tcf_ is not defined"))},o=setTimeout(()=>{document.removeEventListener(c,n),v=!0,t(new Error("Timeout waiting for CMP to load"))},r);i("Listening for CMP loaded event..."),document.addEventListener(c,n,{once:!0})}):Promise.resolve(null),getConsentSync:s,getConsentAsync:()=>t(void 0,void 0,void 0,function*(){const t=s();return!(null==e?void 0:e.enabled)||(null!==t?t:yield new Promise((e,t)=>{try{if(!u)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");u.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}}))})}},m="mobile";class h{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){if(!(null==t?void 0:t.itemId))return;const{getConsentSync:i}=p(n.tcf),r=!!i(),o=n.device===m?t.mobileHTML:t.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,e.querySelectorAll("a").forEach(e=>{var i,r,o;e.search=null!==(o=null===(r=(i=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(i,e,t,n))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,n)})}}class g{constructor(e){this.strategy=e}handle(e,n){return t(this,void 0,void 0,function*(){const{videoConfiguration:{id:t,preview:i}={}}=e;(t||i)&&(yield this.importScript(n),yield this.createVideoElement(e,n))})}importScript(e){return t(this,void 0,void 0,function*(){const n=e.drEditionConfig.videoScriptUrl,r=document.querySelector(`script[src="${n}"]`);if(n&&!window.autoplayQueue&&!r)try{yield((e,...n)=>t(void 0,[e,...n],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{s(),n()},a=()=>{s(),i(new Error(`Failed to load ${e}`))},s=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",a);const d=setTimeout(()=>{s(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(n)}catch(e){i("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,n){return t(this,void 0,void 0,function*(){const t=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,n))return;this.strategy.handleVideo(t,e),null==r||r.appendChild(t),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const s=document.querySelector(".dr-edition-preview .preview-video");return!!s&&(s.setAttribute("playsinline",""),!(!s||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,s),!0))}}class y{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,a,s;if(!this.pulse)return;const d=this.getEventInput(e,n,i,"view");(null===(t=this.pulse)||void 0===t?void 0:t.trackViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackViewUIElement)||void 0===o||o.call(r,d):null===(s=null===(a=this.pulse)||void 0===a?void 0:a.trackElementView)||void 0===s||s.call(a,d)})}trackContentClick(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,a;if(!this.pulse)return;const s=this.getEventInput(e,n,i,"click");this.pulse.trackClickUIElement?null===(r=(t=this.pulse).trackClickUIElement)||void 0===r||r.call(t,s):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,s)})}}class w extends y{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:a,primaryPosition:s}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:s},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class f extends y{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,a,s,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),m=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=m?m:v,"@type":p,url:location.origin},tags:null===(d=null===(s=this.newsroomStrategy)||void 0===s?void 0:s.getTags)||void 0===d?void 0:d.call(s,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,a,s;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:m}={}}=t,h=Math.floor(Date.now()/1e3),g=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),w=this.getTeaserElementText(e,"image"),f=null!==(s=null!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==a?a:p)&&void 0!==s?s:"";return{algorithm:d,clientName:l,probability:m,creativeId:c,device:n.device,editionId:u,itemId:v,link:f,placement:n.editionName,subtitle:y,time:h,title:g,type:i,imageUrl:w,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const E="vg",b="aftonbladet",P="e24",I="front",T=e=>t(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),S={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return t(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return _})})}})}};class C{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:a}}){yield t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const s=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=s)||l.forEach(e=>{S[e](c)});const u={id:n,node:i,autoplay:r,mute:o,vendor:a,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield T(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,s)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===I?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const L="https://www.aftonbladet.se/video-player-extras/latest/";class k{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const a={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${L}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${L}external-link.js`]:{name:"ExternalLink"}}};yield T(a),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}class j{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const A="se",M=(e,t,n)=>{const{publisher:i,pageType:r,country:s}=e,d={[E]:new a,[P]:new C,[b]:new k}[i]||new j,c=new(s===A?w:f)(n,d,r),u=new o(t,null==n?void 0:n.pulseTracker),v=new h(d,c),p=new g(d);return new l(u,v,p,c)},D=()=>t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class x{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return t(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return i("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return t(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const N=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=M(n,i,r);e.forEach(e=>{var i,r,a;if(!e.isIntersecting)return;const s=e.target,d=null!==(i=s.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=s.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(a=s.dataset.pulsePrimaryposition)&&void 0!==a?a:"";o.fetchAndRenderAd(s,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(s)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},U=[];const V=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var _=Object.freeze({__proto__:null,default:V});exports.DrEdition=({editionName:t,fallbackTargetId:n,children:i,pulseData:r})=>{const o=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(r);return e.jsxs("div",Object.assign({className:"dr-edition-wrapper","data-edition-name":t},o,{children:[e.jsx("div",{className:"inscreen-target"}),e.jsx("div",{className:"container"}),e.jsx("div",{className:"fallback","data-fallback-target-id":n,style:{display:"none"},children:i})]}))},exports.getDrEditionManager=M,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;const n=yield D(),i=new x(n);N({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)}),exports.handleDrEditionBackfill=(e,n)=>t(void 0,void 0,void 0,function*(){var t;const{pulse:o,tcf:a,deviceType:s,drEdition:d,publisher:l,pageType:c,country:u}=e,v=((e,t)=>{var n;const{deviceType:i,placements:o,drEdition:{fallbackGlobalEditionName:a}={}}=e,s=o[i]||o.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=s.find(e=>e.id===d),c=r.some(e=>d.startsWith(e)),u=U.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(U.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,n);if(!v)return;if(!(null==o?void 0:o.instance))return void i("Pulse has not been passed as a prop, aborting");const p=yield D(),m=new x(p),h=M({publisher:l,pageType:c,country:u},m,null==o?void 0:o.instance),g=document.getElementById(n.targetId);if(!g||!d)return;g.classList.value="";const y=document.createElement("div");y.className=d.containerSelector.replace(/^[.#:[\]]+/,""),g.innerHTML=y.outerHTML;const w={editionName:(null===(t=null==v?void 0:v.drEdition)||void 0===t?void 0:t.editionName)||"",drEditionConfig:d,device:s,tcf:a,renderAsBackfill:!0};yield h.fetchAndRenderAd(g,w)});
@@ -31,6 +31,7 @@ interface TrackerInstance {
31
31
  interface Tracker {
32
32
  clientId: string;
33
33
  instance: TrackerInstance;
34
+ hasherUrl?: string;
34
35
  }
35
36
  interface XandrPPIDProps {
36
37
  country: Country;
@@ -1 +1 @@
1
- "use strict";function i(i,e,t,n){return new(t||(t=Promise))(function(s,d){function r(i){try{a(n.next(i))}catch(i){d(i)}}function o(i){try{a(n.throw(i))}catch(i){d(i)}}function a(i){var e;i.done?s(i.value):(e=i.value,e instanceof t?e:new t(function(i){i(e)})).then(r,o)}a((n=n.apply(i,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e={get:(e,t)=>i(void 0,void 0,void 0,function*(){const i=yield fetch(e,t);if(!i.ok)throw new Error(i.statusText);return yield i.json()}),post:(e,t,n)=>i(void 0,void 0,void 0,function*(){const i=JSON.stringify(n),s=yield fetch(e,{method:"POST",headers:t,body:i});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},t=(i,e)=>{const t="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(e?console.log(t,i,e):console.log(t,i))},n=864e5,s=(()=>{const i=i=>{const e=window.localStorage.getItem(i);if(!e)return null;try{return JSON.parse(e)}catch(i){return t("Error with parsing localStorage data"),null}},e=(i,e)=>{window.localStorage.setItem(i,JSON.stringify(e))};return{get:i,set:e,setWithTimestamp:(i,t,s=n)=>{const d={data:t,expirationTime:(new Date).getTime()+s};e(i,JSON.stringify(d))},getByTimestamp:(e,s=n)=>{const d=i(e);if(!d)return null;if(!s)return d;try{const{expirationTime:i,data:e}=JSON.parse(d);return(new Date).getTime()<=i?e:null}catch(i){return t("Error with parsing localStorage data"),null}}}})(),d={NO:"no",SE:"se"},r="advertory:ppids-cache",o={[d.SE]:`SCH${d.SE.toUpperCase()}-EnvHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-EnvHash`},a={[d.SE]:`SCH${d.SE.toUpperCase()}-UserHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-UserHash`},l={[d.SE]:`sch${d.SE}-envhash-v3`,[d.NO]:`sch${d.NO}-envhash-v3`},p={[d.SE]:`sch${d.SE}-userhash-v3`,[d.NO]:`sch${d.NO}-userhash-v3`},u={[d.SE]:`'sch${d.SE}-iosid-v3'`,[d.NO]:`'sch${d.NO}-iosid-v3'`},c={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},h={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class v{constructor(){this.eids=[]}add(i,e){return i&&this.eids.push({id:i,source:e}),this}buildRyEids(){return this.eids.map(({id:i,source:e})=>({source:e,uids:[{id:i,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:i,source:e})=>`${e},${i}`).join("|")}buildNorstatPath(){const i=this.eids[0];return i?`${i.source}-${i.id}`:""}buildNorstatQuery(i){const e=new URLSearchParams;return this.eids.slice(1).forEach(({id:t,source:n})=>{e.append(i,`${n}-${t}`)}),e}}const I=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(e){return i(this,arguments,void 0,function*(i,e=1e4){var t,n;const s=yield Promise.race([new Promise(i=>{setTimeout(()=>i({xandr:{ppId1:"",ppId2:""}}),e)}),i.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(t=s.xandr)||void 0===t?void 0:t.ppId1,null===(n=s.xandr)||void 0===n?void 0:n.ppId2)})}getPPIDs(){var i,e;return null!==this.ppid1&&null!==this.ppid2||t("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(i=this.ppid1)&&void 0!==i?i:"",ppid2:null!==(e=this.ppid2)&&void 0!==e?e:""}}setPPIDs(i,e){this.ppid1=null!=i?i:"",this.ppid2=null!=e?e:""}},P=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(e,t){return i(this,void 0,void 0,function*(){var i,n,d,o,a,l,p,u,c,h;const v=s.get(r),I=yield this.getNewPPIDs(e,t);if(this.shouldHash(v,I)){const e=this.createHasherPayload(I),t=yield this.hashPPIDs(e);return t?(this.cachePPIDs(e,t,null===(i=I.idfv)||void 0===i?void 0:i.plain,null===(n=I.anId)||void 0===n?void 0:n.plain),void this.setPPIDs(null!==(d=t.userId)&&void 0!==d?d:"",null!==(o=t.environmentId)&&void 0!==o?o:"",null===(a=I.idfv)||void 0===a?void 0:a.plain,null===(l=I.anId)||void 0===l?void 0:l.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(p=null==v?void 0:v.userId.hashed)&&void 0!==p?p:"",null!==(u=null==v?void 0:v.environmentId.hashed)&&void 0!==u?u:"",null===(c=null==I?void 0:I.idfv)||void 0===c?void 0:c.plain,null===(h=null==I?void 0:I.anId)||void 0===h?void 0:h.plain)})}getPPIDs(){var i,e;return null!==this.ppid1&&null!==this.ppid2||t("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(i=this.ppid1)&&void 0!==i?i:"",ppid2:null!==(e=this.ppid2)&&void 0!==e?e:"",idfv:this.idfv,anId:this.anId}}setPPIDs(i,e,t,n){this.ppid1=null!=i?i:"",this.ppid2=null!=e?e:"",this.idfv=null!=t?t:null,this.anId=null!=n?n:null}shouldHash(i,e){var t,n;if(!i)return!0;for(const s in i){if((null===(t=i[s])||void 0===t?void 0:t.plain)!==(null===(n=e[s])||void 0===n?void 0:n.plain))return!0}return!1}cachePPIDs(i,e,t,n){const d=Object.assign(Object.assign({clientId:{plain:i.clientId},userId:{plain:i.userId,hashed:e.userId},environmentId:{plain:i.environmentId,hashed:e.environmentId},trackerType:{plain:i.trackerType},trackerVersion:{plain:i.trackerVersion}},t?{idfv:{plain:t}}:{}),n?{anId:{plain:n}}:{});s.set(r,d)}hashPPIDs(n){return i(this,void 0,void 0,function*(){try{const i=new Headers({"Content-Type":"application/json"});return yield e.post("https://hasher.schibsted.com/api/v1/hash",i,n)}catch(i){return t("Error with hashing PPIDs",i),null}})}getNewPPIDs(e,t){return i(this,arguments,void 0,function*({clientId:e,instance:t},n){const s=yield((e,t)=>i(void 0,void 0,void 0,function*(){const i=yield e.getUserId();return i?`${h[t]}:${i}`:null}))(t,n),d=yield(e=>i(void 0,void 0,void 0,function*(){const i=yield e.getEnvironmentId();return i?`sdrn:schibsted:environment:${i}`:null}))(t),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:e},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:i,trackerType:e,trackerVersion:t,userId:n,environmentId:s}){return{clientId:i.plain,trackerType:e.plain,trackerVersion:t.plain,userId:n.plain,environmentId:s.plain}}};exports.getPPIDLoggedInStatus=()=>{const{ppid1:i,ppid2:e}=I.getPPIDs();return{"aa-sch-schuserhash":i?"1":"0","aa-sch-schenvhash":e?"1":"0"}},exports.getPPIDNorstatString=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s}=P.getPPIDs(),d=(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s,idfv:d,anId:r}=P.getPPIDs();if(!t)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]).add(d,u[i]).add(r,c[i]).buildRyEids()}}]}}},exports.getUserIdsObject=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s,idfv:d,anId:r}=P.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]).add(d,u[i]).add(r,c[i]).buildEids()}]}},exports.getVideoPPIDs=e=>i(void 0,void 0,void 0,function*(){const{ppid1:i,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s}=P.getPPIDs(),d=(new v).add(t,o[e]).add(i,a[e]).add(s,l[e]).add(n,p[e]);return yield new Promise(i=>{i(d.buildVideoEids())})}),exports.setXandrPPIDs=e=>i(void 0,[e],void 0,function*({country:i,tracker:e,timeout:n=1e3}){if(!e)return;(yield Promise.allSettled([I.processPPIDs(e,n),P.processPPIDs(e,i)])).forEach((i,e)=>{if("rejected"===i.status){t(`Cannot fetch PPIDs v${e+2}`,i.reason)}})});
1
+ "use strict";function i(i,e,t,n){return new(t||(t=Promise))(function(s,d){function r(i){try{a(n.next(i))}catch(i){d(i)}}function o(i){try{a(n.throw(i))}catch(i){d(i)}}function a(i){var e;i.done?s(i.value):(e=i.value,e instanceof t?e:new t(function(i){i(e)})).then(r,o)}a((n=n.apply(i,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e={get:(e,t)=>i(void 0,void 0,void 0,function*(){const i=yield fetch(e,t);if(!i.ok)throw new Error(i.statusText);return yield i.json()}),post:(e,t,n)=>i(void 0,void 0,void 0,function*(){const i=JSON.stringify(n),s=yield fetch(e,{method:"POST",headers:t,body:i});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},t=(i,e)=>{const t="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(e?console.log(t,i,e):console.log(t,i))},n=864e5,s=(()=>{const i=i=>{const e=window.localStorage.getItem(i);if(!e)return null;try{return JSON.parse(e)}catch(i){return t("Error with parsing localStorage data"),null}},e=(i,e)=>{window.localStorage.setItem(i,JSON.stringify(e))};return{get:i,set:e,setWithTimestamp:(i,t,s=n)=>{const d={data:t,expirationTime:(new Date).getTime()+s};e(i,JSON.stringify(d))},getByTimestamp:(e,s=n)=>{const d=i(e);if(!d)return null;if(!s)return d;try{const{expirationTime:i,data:e}=JSON.parse(d);return(new Date).getTime()<=i?e:null}catch(i){return t("Error with parsing localStorage data"),null}}}})(),d={NO:"no",SE:"se"},r="advertory:ppids-cache",o={[d.SE]:`SCH${d.SE.toUpperCase()}-EnvHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-EnvHash`},a={[d.SE]:`SCH${d.SE.toUpperCase()}-UserHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-UserHash`},l={[d.SE]:`sch${d.SE}-envhash-v3`,[d.NO]:`sch${d.NO}-envhash-v3`},p={[d.SE]:`sch${d.SE}-userhash-v3`,[d.NO]:`sch${d.NO}-userhash-v3`},u={[d.SE]:`'sch${d.SE}-iosid-v3'`,[d.NO]:`'sch${d.NO}-iosid-v3'`},c={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},h={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class v{constructor(){this.eids=[]}add(i,e){return i&&this.eids.push({id:i,source:e}),this}buildRyEids(){return this.eids.map(({id:i,source:e})=>({source:e,uids:[{id:i,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:i,source:e})=>`${e},${i}`).join("|")}buildNorstatPath(){const i=this.eids[0];return i?`${i.source}-${i.id}`:""}buildNorstatQuery(i){const e=new URLSearchParams;return this.eids.slice(1).forEach(({id:t,source:n})=>{e.append(i,`${n}-${t}`)}),e}}const I=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(e){return i(this,arguments,void 0,function*(i,e=1e4){var t,n;const s=yield Promise.race([new Promise(i=>{setTimeout(()=>i({xandr:{ppId1:"",ppId2:""}}),e)}),i.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(t=s.xandr)||void 0===t?void 0:t.ppId1,null===(n=s.xandr)||void 0===n?void 0:n.ppId2)})}getPPIDs(){var i,e;return null!==this.ppid1&&null!==this.ppid2||t("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(i=this.ppid1)&&void 0!==i?i:"",ppid2:null!==(e=this.ppid2)&&void 0!==e?e:""}}setPPIDs(i,e){this.ppid1=null!=i?i:"",this.ppid2=null!=e?e:""}},P=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(e,t){return i(this,void 0,void 0,function*(){var i,n,d,o,a,l,p,u,c,h,v;const I=s.get(r),P=yield this.getNewPPIDs(e,t);if(this.shouldHash(I,P)){const t=null!==(i=e.hasherUrl)&&void 0!==i?i:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(P),r=yield this.hashPPIDs(s,t);return r?(this.cachePPIDs(s,r,null===(n=P.idfv)||void 0===n?void 0:n.plain,null===(d=P.anId)||void 0===d?void 0:d.plain),void this.setPPIDs(null!==(o=r.userId)&&void 0!==o?o:"",null!==(a=r.environmentId)&&void 0!==a?a:"",null===(l=P.idfv)||void 0===l?void 0:l.plain,null===(p=P.anId)||void 0===p?void 0:p.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==I?void 0:I.userId.hashed)&&void 0!==u?u:"",null!==(c=null==I?void 0:I.environmentId.hashed)&&void 0!==c?c:"",null===(h=null==P?void 0:P.idfv)||void 0===h?void 0:h.plain,null===(v=null==P?void 0:P.anId)||void 0===v?void 0:v.plain)})}getPPIDs(){var i,e;return null!==this.ppid1&&null!==this.ppid2||t("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(i=this.ppid1)&&void 0!==i?i:"",ppid2:null!==(e=this.ppid2)&&void 0!==e?e:"",idfv:this.idfv,anId:this.anId}}setPPIDs(i,e,t,n){this.ppid1=null!=i?i:"",this.ppid2=null!=e?e:"",this.idfv=null!=t?t:null,this.anId=null!=n?n:null}shouldHash(i,e){var t,n;if(!i)return!0;for(const s in i){if((null===(t=i[s])||void 0===t?void 0:t.plain)!==(null===(n=e[s])||void 0===n?void 0:n.plain))return!0}return!1}cachePPIDs(i,e,t,n){const d=Object.assign(Object.assign({clientId:{plain:i.clientId},userId:{plain:i.userId,hashed:e.userId},environmentId:{plain:i.environmentId,hashed:e.environmentId},trackerType:{plain:i.trackerType},trackerVersion:{plain:i.trackerVersion}},t?{idfv:{plain:t}}:{}),n?{anId:{plain:n}}:{});s.set(r,d)}hashPPIDs(n,s){return i(this,void 0,void 0,function*(){try{const i=new Headers({"Content-Type":"application/json"});return yield e.post(s,i,n)}catch(i){return t("Error with hashing PPIDs",i),null}})}getNewPPIDs(e,t){return i(this,arguments,void 0,function*({clientId:e,instance:t},n){const s=yield((e,t)=>i(void 0,void 0,void 0,function*(){const i=yield e.getUserId();return i?`${h[t]}:${i}`:null}))(t,n),d=yield(e=>i(void 0,void 0,void 0,function*(){const i=yield e.getEnvironmentId();return i?`sdrn:schibsted:environment:${i}`:null}))(t),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:e},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:i,trackerType:e,trackerVersion:t,userId:n,environmentId:s}){return{clientId:i.plain,trackerType:e.plain,trackerVersion:t.plain,userId:n.plain,environmentId:s.plain}}};exports.getPPIDLoggedInStatus=()=>{const{ppid1:i,ppid2:e}=I.getPPIDs();return{"aa-sch-schuserhash":i?"1":"0","aa-sch-schenvhash":e?"1":"0"}},exports.getPPIDNorstatString=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s}=P.getPPIDs(),d=(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s,idfv:d,anId:r}=P.getPPIDs();if(!t)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]).add(d,u[i]).add(r,c[i]).buildRyEids()}}]}}},exports.getUserIdsObject=i=>{const{ppid1:e,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s,idfv:d,anId:r}=P.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new v).add(t,o[i]).add(e,a[i]).add(s,l[i]).add(n,p[i]).add(d,u[i]).add(r,c[i]).buildEids()}]}},exports.getVideoPPIDs=e=>i(void 0,void 0,void 0,function*(){const{ppid1:i,ppid2:t}=I.getPPIDs(),{ppid1:n,ppid2:s}=P.getPPIDs(),d=(new v).add(t,o[e]).add(i,a[e]).add(s,l[e]).add(n,p[e]);return yield new Promise(i=>{i(d.buildVideoEids())})}),exports.setXandrPPIDs=e=>i(void 0,[e],void 0,function*({country:i,tracker:e,timeout:n=1e3}){if(!e)return;(yield Promise.allSettled([I.processPPIDs(e,n),P.processPPIDs(e,i)])).forEach((i,e)=>{if("rejected"===i.status){t(`Cannot fetch PPIDs v${e+2}`,i.reason)}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/advertory",
3
- "version": "2.47.2",
3
+ "version": "2.48.0",
4
4
  "scripts": {
5
5
  "build": "node node_modules/rollup/dist/bin/rollup -c rollup-config/default.mjs && npm run post:build",
6
6
  "build:dev": "MODE=dev NODE_OPTIONS=--max-old-space-size=131072 npm run build",