@schibsted/advertory 2.63.14 → 2.63.15-server-side-rendering

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 (124) hide show
  1. package/core/aftenposten/es/index.css +1 -1
  2. package/core/aftenposten/es/index.d.ts +2 -0
  3. package/core/aftenposten/es/index.js +1 -1
  4. package/core/aftenposten/index.d.ts +2 -0
  5. package/core/aftenposten/index.js +1 -1
  6. package/core/aftenpostenv2/es/index.css +1 -1
  7. package/core/aftenpostenv2/es/index.d.ts +2 -0
  8. package/core/aftenpostenv2/es/index.js +1 -1
  9. package/core/aftonbladet/es/index.css +1 -1
  10. package/core/aftonbladet/es/index.d.ts +2 -0
  11. package/core/aftonbladet/es/index.js +1 -1
  12. package/core/aftonbladet/index.d.ts +2 -0
  13. package/core/aftonbladet/index.js +1 -1
  14. package/core/aftonbladetv2/es/index.css +1 -1
  15. package/core/aftonbladetv2/es/index.d.ts +2 -0
  16. package/core/aftonbladetv2/es/index.js +1 -1
  17. package/core/bt/es/index.css +1 -1
  18. package/core/bt/es/index.d.ts +2 -0
  19. package/core/bt/es/index.js +1 -1
  20. package/core/bt/index.d.ts +2 -0
  21. package/core/bt/index.js +1 -1
  22. package/core/e24/es/index.css +1 -1
  23. package/core/e24/es/index.d.ts +2 -0
  24. package/core/e24/es/index.js +1 -1
  25. package/core/e24/index.d.ts +2 -0
  26. package/core/e24/index.js +1 -1
  27. package/core/fotbollskanalen/es/index.css +1 -1
  28. package/core/fotbollskanalen/es/index.d.ts +2 -0
  29. package/core/fotbollskanalen/es/index.js +1 -1
  30. package/core/fotbollskanalen/index.d.ts +2 -0
  31. package/core/fotbollskanalen/index.js +1 -1
  32. package/core/godare/index.d.ts +2 -0
  33. package/core/godare/index.js +1 -1
  34. package/core/godt/index.d.ts +2 -0
  35. package/core/godt/index.js +1 -1
  36. package/core/klart/index.d.ts +2 -0
  37. package/core/klart/index.js +1 -1
  38. package/core/koket/es/index.css +1 -1
  39. package/core/koket/es/index.d.ts +2 -0
  40. package/core/koket/es/index.js +1 -1
  41. package/core/koket/index.d.ts +2 -0
  42. package/core/koket/index.js +1 -1
  43. package/core/kompakt/index.d.ts +2 -0
  44. package/core/kompakt/index.js +1 -1
  45. package/core/minmote/index.d.ts +2 -0
  46. package/core/minmote/index.js +1 -1
  47. package/core/pent/index.d.ts +2 -0
  48. package/core/pent/index.js +1 -1
  49. package/core/sa/es/index.css +1 -1
  50. package/core/sa/es/index.d.ts +2 -0
  51. package/core/sa/es/index.js +1 -1
  52. package/core/sa/index.d.ts +2 -0
  53. package/core/sa/index.js +1 -1
  54. package/core/svd/es/index.css +1 -1
  55. package/core/svd/es/index.d.ts +2 -0
  56. package/core/svd/es/index.js +1 -1
  57. package/core/svd/index.d.ts +2 -0
  58. package/core/svd/index.js +1 -1
  59. package/core/svdv2/es/index.css +1 -1
  60. package/core/svdv2/es/index.d.ts +2 -0
  61. package/core/svdv2/es/index.js +1 -1
  62. package/core/tek/index.d.ts +2 -0
  63. package/core/tek/index.js +1 -1
  64. package/core/tv4/es/index.css +1 -1
  65. package/core/tv4/es/index.d.ts +2 -0
  66. package/core/tv4/es/index.js +1 -1
  67. package/core/tv4/index.d.ts +2 -0
  68. package/core/tv4/index.js +1 -1
  69. package/core/tvnu/index.d.ts +2 -0
  70. package/core/tvnu/index.js +1 -1
  71. package/core/vg/es/index.css +1 -1
  72. package/core/vg/es/index.d.ts +2 -0
  73. package/core/vg/es/index.js +1 -1
  74. package/core/vg/index.d.ts +2 -0
  75. package/core/vg/index.js +1 -1
  76. package/core/vgv2/es/index.css +1 -1
  77. package/core/vgv2/es/index.d.ts +2 -0
  78. package/core/vgv2/es/index.js +1 -1
  79. package/features/ad-native/index.d.ts +2 -0
  80. package/features/ad-native/index.js +1 -1
  81. package/features/dr-edition/es/index.d.ts +2 -0
  82. package/features/dr-edition/index.d.ts +2 -0
  83. package/features/kilkaya/es/index.js +1 -1
  84. package/features/kilkaya/index.js +1 -1
  85. package/features/tracker/index.d.ts +4 -1
  86. package/features/tracker/index.js +1 -1
  87. package/package.json +1 -1
  88. package/sites/aftenposten/es/index.css +1 -1
  89. package/sites/aftenposten/index.js +1 -1
  90. package/sites/aftenpostenv2/es/index.css +1 -1
  91. package/sites/aftonbladet/es/index.css +1 -1
  92. package/sites/aftonbladetv2/es/index.css +1 -1
  93. package/sites/bt/es/index.css +1 -1
  94. package/sites/bt/index.js +1 -1
  95. package/sites/e24/es/index.css +1 -1
  96. package/sites/fotbollskanalen/es/index.css +1 -1
  97. package/sites/koket/es/index.css +1 -1
  98. package/sites/sa/es/index.css +1 -1
  99. package/sites/sa/index.js +1 -1
  100. package/sites/svd/es/index.css +1 -1
  101. package/sites/svd/index.js +1 -1
  102. package/sites/svdv2/es/index.css +1 -1
  103. package/sites/tv4/es/index.css +1 -1
  104. package/sites/tvnu/index.js +1 -1
  105. package/sites/vg/es/index.css +1 -1
  106. package/sites/vg/index.js +1 -1
  107. package/sites/vgv2/es/index.css +1 -1
  108. package/styles/vg/styles.css +1 -1
  109. package/styles/vgv2/styles.css +1 -1
  110. package/types/core/interface/config.d.ts +2 -0
  111. package/types/features/ad-native/sites/tvnu/templates/classic/index.d.ts +1 -1
  112. package/types/features/ad-server-side/banner-object.d.ts +4 -0
  113. package/types/features/ad-server-side/banner-object.test.d.ts +1 -0
  114. package/types/features/ad-server-side/constants.d.ts +2 -0
  115. package/types/features/ad-server-side/index.d.ts +4 -0
  116. package/types/features/ad-server-side/keywords.d.ts +3 -0
  117. package/types/features/ad-server-side/keywords.test.d.ts +1 -0
  118. package/types/features/ad-server-side/native-request.d.ts +42 -0
  119. package/types/features/ad-server-side/native-request.test.d.ts +1 -0
  120. package/types/features/ad-server-side/server-side-xandr-renderer.d.ts +3 -0
  121. package/types/features/ad-server-side/server-side-xandr-service.d.ts +7 -0
  122. package/types/features/interface/ad-server-side.d.ts +54 -0
  123. package/types/features/kilkaya/index.d.ts +2 -1
  124. package/types/features/tracker/index.d.ts +3 -2
@@ -284,6 +284,8 @@ interface Placement {
284
284
  drEdition?: DrEditionPlacementConfig;
285
285
  isBackfill?: boolean;
286
286
  takeoverCookieCapForSharedPlacement?: boolean;
287
+ serverSidePlacement?: boolean;
288
+ xandrPlacementId?: number;
287
289
  }
288
290
  interface Placements {
289
291
  desktop: Array<Placement>;
@@ -284,6 +284,8 @@ interface Placement {
284
284
  drEdition?: DrEditionPlacementConfig;
285
285
  isBackfill?: boolean;
286
286
  takeoverCookieCapForSharedPlacement?: boolean;
287
+ serverSidePlacement?: boolean;
288
+ xandrPlacementId?: number;
287
289
  }
288
290
  interface Placements {
289
291
  desktop: Array<Placement>;
@@ -1 +1 @@
1
- function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{s(i.next(e))}catch(e){o(e)}}function l(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,l)}s((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const t="vg";class n{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]}}class i{getPulseObjectId(){return""}getPulsePageId(e,t){return""}}class r{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t){return{}}parseKilkayaData(e){const t=e.querySelector("article");if(!t)return{};const n=t.dataset.k5aTeaserAnalytics;try{return n?JSON.parse(n):{}}catch(e){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()||""}getEventTarget(e){const{url:t,title:n,itemId:i}=this.parseKilkayaData(e);return{id:i,name:this.normalizePlacementTitle(null!=n?n:""),type:"Page",url:t}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,a,l,s,c;const d=new CustomEvent("advertory:partnerstudioAdImpression",{detail:{ad:null===(e=this.parseKilkayaData(t))||void 0===e?void 0:e.placement}});if(window.dispatchEvent(d),!this.pulse)return;const u=this.getEventInput(t,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(r=null===(i=this.pulse)||void 0===i?void 0:i.trackLegacyViewUIElement)||void 0===r||r.call(i,u):(null===(o=this.pulse)||void 0===o?void 0:o.trackViewUIElement)?null===(l=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===l||l.call(a,u):null===(c=null===(s=this.pulse)||void 0===s?void 0:s.trackElementView)||void 0===c||c.call(s,u)})}trackContentClick(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,a;if(!this.pulse)return;const l=this.getEventInput(t,"click");this.pulse.trackLegacyClickUIElement?null===(n=(e=this.pulse).trackLegacyClickUIElement)||void 0===n||n.call(e,l):this.pulse.trackClickUIElement?null===(r=(i=this.pulse).trackClickUIElement)||void 0===r||r.call(i,l):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,l)})}}class o extends r{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e){var t,n,i,r,o,a;const{clientName:l,creativeId:s,itemId:c,placement:d}=this.parseKilkayaData(e),u=this.mapPageType(this.pageType),v=null===(t=this.newsroomStrategy)||void 0===t?void 0:t.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(r=null===(i=null===(n=this.newsroomStrategy)||void 0===n?void 0:n.getPulseObjectId)||void 0===i?void 0:i.call(n))&&void 0!==r?r:d,"@type":"UIElement",position:d,elementType:"Article",custom:{customer:l,creativeId:null!=s?s:c},page:{"@id":null!=v?v:d,"@type":u,url:location.origin},tags:null===(a=null===(o=this.newsroomStrategy)||void 0===o?void 0:o.getTags)||void 0===a?void 0:a.call(o,e)}}getEventTarget(e){const{link:t,itemId:n,title:i}=this.parseKilkayaData(e);return{id:n,name:this.normalizePlacementTitle(null!=i?i:""),type:"Page",url:t}}getEventInput(e,t){return{object:this.getEventBaseData(e),partnerstudio:this.getEventPartnerstudioData(e,t),target:this.getEventTarget(e),provider:this.getProviderData()}}getEventPartnerstudioData(e,t){const n=this.parseKilkayaData(e);return Object.assign(Object.assign({},n),{type:t,tracking_type:"ad",xandrAdLoaded:!1})}getProviderData(){return{productTag:"partnerstudio"}}}const a="[data-k5a-teaser-analytics]",l=(e,t,n)=>{const i=document.querySelectorAll("k5a-stream");if(!i.length)return;const r=new o(e,t,n),l=new WeakMap,s=e=>{const t=l.get(e);t&&(t.disconnect(),l.delete(e))},c=new IntersectionObserver((e,t)=>{e.forEach(e=>{if(!e.isIntersecting)return;const n=e.target,i=n.querySelector(a);Boolean(null==i?void 0:i.dataset.k5aTeaserAnalytics)?(r.trackContentView(n),t.unobserve(e.target),s(n)):((e,t)=>{if(l.has(e))return;const n=new MutationObserver(()=>{const n=e.querySelector(a);Boolean(null==n?void 0:n.dataset.k5aTeaserAnalytics)&&(r.trackContentView(e),t.unobserve(e),s(e))});n.observe(e,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["data-k5a-teaser-analytics"]}),l.set(e,n)})(n,t)})},{threshold:.5});i.forEach(e=>{c.observe(e),e.addEventListener("click",()=>r.trackContentClick(e))})},s=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},c=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return s("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const r=e=>{i||(s("Resolving advertising permission value obtained"),i=!0,t(e))},o=setTimeout(()=>{s("Advertising permission timed out, resolving with false"),r(!1)},3e3);window._tcf_.onTcfReady(()=>{s("On Tcf Ready called, waiting for permission"),clearTimeout(o)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(o);const t=Number(e);s("Advertising permission value obtained asynchronously: ",e),r(Boolean(t))})}),d="no",u="se",v="cmp:loaded";let g,h=!1;const m=(t,n,i)=>{const r=!!(null==t?void 0:t.enabled),o=(null==t?void 0:t.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const m=()=>{if(!(null==t?void 0:t.enabled))return!0;if(((e,t)=>e?!!t&&(s("TCF bypass param detected, returning consent: true"),!0):(s("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(h)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return s(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==t?void 0:t.enabled)?new Promise((e,t)=>{if(s("Getting TCF consent manager..."),window._tcf_)return s("TCF consent manager is already available"),g=window._tcf_,void e(g);s("TCF consent manager is not available");const n=()=>{s("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(g=window._tcf_,e(g)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(v,n),h=!0,t(new Error("Timeout waiting for CMP to load"))},o);s("Listening for CMP loaded event..."),document.addEventListener(v,n,{once:!0})}):Promise.resolve(null),getConsentSync:m,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==t?void 0:t.schibstedAdChoicesOverrideValue)return s(`Schibsted Ad Choices override value is set, returning override value: ${t.schibstedAdChoicesOverrideValue}`),Boolean(Number(t.schibstedAdChoicesOverrideValue));const e=(null==t?void 0:t.schibstedAdChoicesEnabled)&&i===u,r=(null==t?void 0:t.schibstedAdChoicesEnabled)&&!n&&i===d;if(e||r)return s("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield c(t);if(!(null==t?void 0:t.enabled))return!0;const a=m();return null!==a?a:yield new Promise((e,t)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{s("TCF isConsentedToAll timed out, resolving with false"),n(!1)},o);g.onTcfReady(()=>{s("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),g.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}};class p{handleKilkayaStreamTracking({pulse:e,pageType:r,publisher:o}){if(!(null==e?void 0:e.instance))return;const a={[t]:new n}[o]||new i;l(e.instance,a,r)}injectKilkayaMeta(e){const t=document.createElement("script");t.textContent=`var k5aMeta = { consent: ${e} };`,document.head.appendChild(t)}observeForKilkayaBackfills(){document.addEventListener("K5A:EmptyStreamSlot",e=>{var t;const n=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.streamSlot;if(!n)return;const i=n.parentElement;i&&(s(`Kilkaya placement ${n.getAttribute("name")} has not been loaded, loading Xandr backfill`),this.showBackfill(i))})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";(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"))})(null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"")}loadKilkayaScript(t){return e(this,void 0,void 0,function*(){yield((t,...n)=>e(void 0,[t,...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=()=>{l(),n()},a=()=>{l(),i(new Error(`Failed to load ${e}`))},l=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(s)};r.addEventListener("load",o),r.addEventListener("error",a);const s=setTimeout(()=>{l(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)})}run(t){return e(this,void 0,void 0,function*(){const{tcf:n,isMobileApp:i,country:r,kilkaya:o}=t;if(!(null==o?void 0:o.enabled))return;const a=yield((t,n,i,...r)=>e(void 0,[t,n,i,...r],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return s(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return s(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=m(e,t,n);return(yield r())?(s(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(s(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}))(n,i,r,"kilkaya");a&&(this.observeForKilkayaBackfills(),this.injectKilkayaMeta(a),yield this.loadKilkayaScript(o.url),this.handleKilkayaStreamTracking(t))})}}const y=t=>e(void 0,void 0,void 0,function*(){const e=new p;yield e.run(t)});export{y as runKilkaya};
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{s(i.next(e))}catch(e){o(e)}}function l(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,l)}s((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i="vg";class r{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]}}class o{getPulseObjectId(){return""}getPulsePageId(e,t){return""}}class a{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t){return{}}parseKilkayaData(e){const t=e.querySelector("article");if(!t)return{};const n=t.dataset.k5aTeaserAnalytics;try{return n?JSON.parse(n):{}}catch(e){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()||""}getEventTarget(e){const{url:t,title:n,itemId:i}=this.parseKilkayaData(e);return{id:i,name:this.normalizePlacementTitle(null!=n?n:""),type:"Page",url:t}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e){return n(this,void 0,void 0,function*(){var t,n,i,r,o,a,l,s,c;const d=new CustomEvent("advertory:partnerstudioAdImpression",{detail:{ad:null===(t=this.parseKilkayaData(e))||void 0===t?void 0:t.placement}});if(window.dispatchEvent(d),!this.pulse)return;const u=this.getEventInput(e,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(r=null===(i=this.pulse)||void 0===i?void 0:i.trackLegacyViewUIElement)||void 0===r||r.call(i,u):(null===(o=this.pulse)||void 0===o?void 0:o.trackViewUIElement)?null===(l=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===l||l.call(a,u):null===(c=null===(s=this.pulse)||void 0===s?void 0:s.trackElementView)||void 0===c||c.call(s,u)})}trackContentClick(e){return n(this,void 0,void 0,function*(){var t,n,i,r,o,a;if(!this.pulse)return;const l=this.getEventInput(e,"click");this.pulse.trackLegacyClickUIElement?null===(n=(t=this.pulse).trackLegacyClickUIElement)||void 0===n||n.call(t,l):this.pulse.trackClickUIElement?null===(r=(i=this.pulse).trackClickUIElement)||void 0===r||r.call(i,l):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,l)})}}class l extends a{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e){var t,n,i,r,o,a;const{clientName:l,creativeId:s,itemId:c,placement:d}=this.parseKilkayaData(e),u=this.mapPageType(this.pageType),v=null===(t=this.newsroomStrategy)||void 0===t?void 0:t.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(r=null===(i=null===(n=this.newsroomStrategy)||void 0===n?void 0:n.getPulseObjectId)||void 0===i?void 0:i.call(n))&&void 0!==r?r:d,"@type":"UIElement",position:d,elementType:"Article",custom:{customer:l,creativeId:null!=s?s:c},page:{"@id":null!=v?v:d,"@type":u,url:location.origin},tags:null===(a=null===(o=this.newsroomStrategy)||void 0===o?void 0:o.getTags)||void 0===a?void 0:a.call(o,e)}}getEventTarget(e){const{link:t,itemId:n,title:i}=this.parseKilkayaData(e);return{id:n,name:this.normalizePlacementTitle(null!=i?i:""),type:"Page",url:t}}getEventInput(e,t){return{object:this.getEventBaseData(e),partnerstudio:this.getEventPartnerstudioData(e,t),target:this.getEventTarget(e),provider:this.getProviderData()}}getEventPartnerstudioData(e,t){const n=this.parseKilkayaData(e);return Object.assign(Object.assign({},n),{type:t,tracking_type:"ad",xandrAdLoaded:!1})}getProviderData(){return{productTag:"partnerstudio"}}}const s="[data-k5a-teaser-analytics]",c=(e,t,n)=>{const i=document.querySelectorAll("k5a-stream");if(!i.length)return;const r=new l(e,t,n),o=new WeakMap,a=e=>{const t=o.get(e);t&&(t.disconnect(),o.delete(e))},c=new IntersectionObserver((e,t)=>{e.forEach(e=>{if(!e.isIntersecting)return;const n=e.target,i=n.querySelector(s);Boolean(null==i?void 0:i.dataset.k5aTeaserAnalytics)?(r.trackContentView(n),t.unobserve(e.target),a(n)):((e,t)=>{if(o.has(e))return;const n=new MutationObserver(()=>{const n=e.querySelector(s);Boolean(null==n?void 0:n.dataset.k5aTeaserAnalytics)&&(r.trackContentView(e),t.unobserve(e),a(e))});n.observe(e,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["data-k5a-teaser-analytics"]}),o.set(e,n)})(n,t)})},{threshold:.5});i.forEach(e=>{c.observe(e),e.addEventListener("click",()=>r.trackContentClick(e))})},d=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},u=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return d("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const r=e=>{i||(d("Resolving advertising permission value obtained"),i=!0,t(e))},o=setTimeout(()=>{d("Advertising permission timed out, resolving with false"),r(!1)},3e3);window._tcf_.onTcfReady(()=>{d("On Tcf Ready called, waiting for permission"),clearTimeout(o)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(o);const t=Number(e);d("Advertising permission value obtained asynchronously: ",e),r(Boolean(t))})}),v="no",g="se",h="cmp:loaded";let m,p=!1;const y=(e,t,i)=>{const r=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const s=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(d("TCF bypass param detected, returning consent: true"),!0):(d("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(p)return null;if(!m)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=m.getConsentedToAllSync();return d(`TCF consented to all is: ${t}`),m.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(d("Getting TCF consent manager..."),window._tcf_)return d("TCF consent manager is already available"),m=window._tcf_,void e(m);d("TCF consent manager is not available");const n=()=>{d("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(m=window._tcf_,e(m)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(h,n),p=!0,t(new Error("Timeout waiting for CMP to load"))},o);d("Listening for CMP loaded event..."),document.addEventListener(h,n,{once:!0})}):Promise.resolve(null),getConsentSync:s,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return d(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const n=(null==e?void 0:e.schibstedAdChoicesEnabled)&&i===g,r=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!t&&i===v;if(n||r)return d("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield u(e);if(!(null==e?void 0:e.enabled))return!0;const a=s();return null!==a?a:yield new Promise((e,t)=>{try{if(!m)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{d("TCF isConsentedToAll timed out, resolving with false"),n(!1)},o);m.onTcfReady(()=>{d("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),m.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}};class f{handleKilkayaStreamTracking({pulse:e,pageType:t,publisher:n}){if(!(null==e?void 0:e.instance))return;const a={[i]:new r}[n]||new o;c(e.instance,a,t)}injectKilkayaMeta(e){const t=document.createElement("script");t.textContent=`var k5aMeta = { consent: ${e} };`,document.head.appendChild(t)}observeForKilkayaBackfills(){document.addEventListener("K5A:EmptyStreamSlot",e=>{var t;const n=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.streamSlot;if(!n)return;const i=n.parentElement;i&&(d(`Kilkaya placement ${n.getAttribute("name")} has not been loaded, loading Xandr backfill`),this.showBackfill(i))})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";(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"))})(null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"")}loadKilkayaScript(e){return n(this,void 0,void 0,function*(){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=()=>{l(),n()},a=()=>{l(),i(new Error(`Failed to load ${e}`))},l=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(s)};r.addEventListener("load",o),r.addEventListener("error",a);const s=setTimeout(()=>{l(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(e)})}run(e){return n(this,void 0,void 0,function*(){const{tcf:t,isMobileApp:i,country:r,kilkaya:o}=e;if(!(null==o?void 0:o.enabled))return;const a=yield((e,t,i,...r)=>n(void 0,[e,t,i,...r],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return d(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return d(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=y(e,t,n);return(yield r())?(d(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(d(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}))(t,i,r,"kilkaya");a&&(this.observeForKilkayaBackfills(),this.injectKilkayaMeta(a),yield this.loadKilkayaScript(o.url),this.handleKilkayaStreamTracking(e))})}}const w=({placementName:n,fallbackTargetId:i,children:r,pulseData:o,htmlAttributes:a})=>{const l=(e,t)=>{const n={};if(!e)return n;for(const[i,r]of Object.entries(e)){n[t?`${t}-${i}`:i]=String(r)}return n},s=l(o,"data-pulse"),c=l(a,"data");return e("div",Object.assign({className:"kilkaya-wrapper kilkaya-lock-height"},s,c,{children:[t("div",{className:"inscreen-target"}),t("k5a-stream",{name:n}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},b=e=>n(void 0,void 0,void 0,function*(){const t=new f;yield t.run(e)});export{w as Kilkaya,b as runKilkaya};
@@ -1 +1 @@
1
- "use strict";function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{s(i.next(e))}catch(e){o(e)}}function l(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,l)}s((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const t="vg";class n{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]}}class i{getPulseObjectId(){return""}getPulsePageId(e,t){return""}}class r{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t){return{}}parseKilkayaData(e){const t=e.querySelector("article");if(!t)return{};const n=t.dataset.k5aTeaserAnalytics;try{return n?JSON.parse(n):{}}catch(e){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()||""}getEventTarget(e){const{url:t,title:n,itemId:i}=this.parseKilkayaData(e);return{id:i,name:this.normalizePlacementTitle(null!=n?n:""),type:"Page",url:t}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,a,l,s,c;const d=new CustomEvent("advertory:partnerstudioAdImpression",{detail:{ad:null===(e=this.parseKilkayaData(t))||void 0===e?void 0:e.placement}});if(window.dispatchEvent(d),!this.pulse)return;const u=this.getEventInput(t,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(r=null===(i=this.pulse)||void 0===i?void 0:i.trackLegacyViewUIElement)||void 0===r||r.call(i,u):(null===(o=this.pulse)||void 0===o?void 0:o.trackViewUIElement)?null===(l=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===l||l.call(a,u):null===(c=null===(s=this.pulse)||void 0===s?void 0:s.trackElementView)||void 0===c||c.call(s,u)})}trackContentClick(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,a;if(!this.pulse)return;const l=this.getEventInput(t,"click");this.pulse.trackLegacyClickUIElement?null===(n=(e=this.pulse).trackLegacyClickUIElement)||void 0===n||n.call(e,l):this.pulse.trackClickUIElement?null===(r=(i=this.pulse).trackClickUIElement)||void 0===r||r.call(i,l):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,l)})}}class o extends r{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e){var t,n,i,r,o,a;const{clientName:l,creativeId:s,itemId:c,placement:d}=this.parseKilkayaData(e),u=this.mapPageType(this.pageType),v=null===(t=this.newsroomStrategy)||void 0===t?void 0:t.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(r=null===(i=null===(n=this.newsroomStrategy)||void 0===n?void 0:n.getPulseObjectId)||void 0===i?void 0:i.call(n))&&void 0!==r?r:d,"@type":"UIElement",position:d,elementType:"Article",custom:{customer:l,creativeId:null!=s?s:c},page:{"@id":null!=v?v:d,"@type":u,url:location.origin},tags:null===(a=null===(o=this.newsroomStrategy)||void 0===o?void 0:o.getTags)||void 0===a?void 0:a.call(o,e)}}getEventTarget(e){const{link:t,itemId:n,title:i}=this.parseKilkayaData(e);return{id:n,name:this.normalizePlacementTitle(null!=i?i:""),type:"Page",url:t}}getEventInput(e,t){return{object:this.getEventBaseData(e),partnerstudio:this.getEventPartnerstudioData(e,t),target:this.getEventTarget(e),provider:this.getProviderData()}}getEventPartnerstudioData(e,t){const n=this.parseKilkayaData(e);return Object.assign(Object.assign({},n),{type:t,tracking_type:"ad",xandrAdLoaded:!1})}getProviderData(){return{productTag:"partnerstudio"}}}const a="[data-k5a-teaser-analytics]",l=(e,t,n)=>{const i=document.querySelectorAll("k5a-stream");if(!i.length)return;const r=new o(e,t,n),l=new WeakMap,s=e=>{const t=l.get(e);t&&(t.disconnect(),l.delete(e))},c=new IntersectionObserver((e,t)=>{e.forEach(e=>{if(!e.isIntersecting)return;const n=e.target,i=n.querySelector(a);Boolean(null==i?void 0:i.dataset.k5aTeaserAnalytics)?(r.trackContentView(n),t.unobserve(e.target),s(n)):((e,t)=>{if(l.has(e))return;const n=new MutationObserver(()=>{const n=e.querySelector(a);Boolean(null==n?void 0:n.dataset.k5aTeaserAnalytics)&&(r.trackContentView(e),t.unobserve(e),s(e))});n.observe(e,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["data-k5a-teaser-analytics"]}),l.set(e,n)})(n,t)})},{threshold:.5});i.forEach(e=>{c.observe(e),e.addEventListener("click",()=>r.trackContentClick(e))})},s=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},c=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return s("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const r=e=>{i||(s("Resolving advertising permission value obtained"),i=!0,t(e))},o=setTimeout(()=>{s("Advertising permission timed out, resolving with false"),r(!1)},3e3);window._tcf_.onTcfReady(()=>{s("On Tcf Ready called, waiting for permission"),clearTimeout(o)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(o);const t=Number(e);s("Advertising permission value obtained asynchronously: ",e),r(Boolean(t))})}),d="no",u="se",v="cmp:loaded";let g,h=!1;const m=(t,n,i)=>{const r=!!(null==t?void 0:t.enabled),o=(null==t?void 0:t.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const m=()=>{if(!(null==t?void 0:t.enabled))return!0;if(((e,t)=>e?!!t&&(s("TCF bypass param detected, returning consent: true"),!0):(s("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(h)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return s(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==t?void 0:t.enabled)?new Promise((e,t)=>{if(s("Getting TCF consent manager..."),window._tcf_)return s("TCF consent manager is already available"),g=window._tcf_,void e(g);s("TCF consent manager is not available");const n=()=>{s("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(g=window._tcf_,e(g)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(v,n),h=!0,t(new Error("Timeout waiting for CMP to load"))},o);s("Listening for CMP loaded event..."),document.addEventListener(v,n,{once:!0})}):Promise.resolve(null),getConsentSync:m,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==t?void 0:t.schibstedAdChoicesOverrideValue)return s(`Schibsted Ad Choices override value is set, returning override value: ${t.schibstedAdChoicesOverrideValue}`),Boolean(Number(t.schibstedAdChoicesOverrideValue));const e=(null==t?void 0:t.schibstedAdChoicesEnabled)&&i===u,r=(null==t?void 0:t.schibstedAdChoicesEnabled)&&!n&&i===d;if(e||r)return s("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield c(t);if(!(null==t?void 0:t.enabled))return!0;const a=m();return null!==a?a:yield new Promise((e,t)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{s("TCF isConsentedToAll timed out, resolving with false"),n(!1)},o);g.onTcfReady(()=>{s("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),g.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}};class p{handleKilkayaStreamTracking({pulse:e,pageType:r,publisher:o}){if(!(null==e?void 0:e.instance))return;const a={[t]:new n}[o]||new i;l(e.instance,a,r)}injectKilkayaMeta(e){const t=document.createElement("script");t.textContent=`var k5aMeta = { consent: ${e} };`,document.head.appendChild(t)}observeForKilkayaBackfills(){document.addEventListener("K5A:EmptyStreamSlot",e=>{var t;const n=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.streamSlot;if(!n)return;const i=n.parentElement;i&&(s(`Kilkaya placement ${n.getAttribute("name")} has not been loaded, loading Xandr backfill`),this.showBackfill(i))})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";(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"))})(null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"")}loadKilkayaScript(t){return e(this,void 0,void 0,function*(){yield((t,...n)=>e(void 0,[t,...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=()=>{l(),n()},a=()=>{l(),i(new Error(`Failed to load ${e}`))},l=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(s)};r.addEventListener("load",o),r.addEventListener("error",a);const s=setTimeout(()=>{l(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)})}run(t){return e(this,void 0,void 0,function*(){const{tcf:n,isMobileApp:i,country:r,kilkaya:o}=t;if(!(null==o?void 0:o.enabled))return;const a=yield((t,n,i,...r)=>e(void 0,[t,n,i,...r],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return s(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return s(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=m(e,t,n);return(yield r())?(s(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(s(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}))(n,i,r,"kilkaya");a&&(this.observeForKilkayaBackfills(),this.injectKilkayaMeta(a),yield this.loadKilkayaScript(o.url),this.handleKilkayaStreamTracking(t))})}}exports.runKilkaya=t=>e(void 0,void 0,void 0,function*(){const e=new p;yield e.run(t)});
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{l(i.next(e))}catch(e){o(e)}}function s(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const n="vg";class i{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]}}class r{getPulseObjectId(){return""}getPulsePageId(e,t){return""}}class o{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t){return{}}parseKilkayaData(e){const t=e.querySelector("article");if(!t)return{};const n=t.dataset.k5aTeaserAnalytics;try{return n?JSON.parse(n):{}}catch(e){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()||""}getEventTarget(e){const{url:t,title:n,itemId:i}=this.parseKilkayaData(e);return{id:i,name:this.normalizePlacementTitle(null!=n?n:""),type:"Page",url:t}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e){return t(this,void 0,void 0,function*(){var t,n,i,r,o,a,s,l,c;const d=new CustomEvent("advertory:partnerstudioAdImpression",{detail:{ad:null===(t=this.parseKilkayaData(e))||void 0===t?void 0:t.placement}});if(window.dispatchEvent(d),!this.pulse)return;const u=this.getEventInput(e,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(r=null===(i=this.pulse)||void 0===i?void 0:i.trackLegacyViewUIElement)||void 0===r||r.call(i,u):(null===(o=this.pulse)||void 0===o?void 0:o.trackViewUIElement)?null===(s=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===s||s.call(a,u):null===(c=null===(l=this.pulse)||void 0===l?void 0:l.trackElementView)||void 0===c||c.call(l,u)})}trackContentClick(e){return t(this,void 0,void 0,function*(){var t,n,i,r,o,a;if(!this.pulse)return;const s=this.getEventInput(e,"click");this.pulse.trackLegacyClickUIElement?null===(n=(t=this.pulse).trackLegacyClickUIElement)||void 0===n||n.call(t,s):this.pulse.trackClickUIElement?null===(r=(i=this.pulse).trackClickUIElement)||void 0===r||r.call(i,s):null===(a=(o=this.pulse).trackElementClick)||void 0===a||a.call(o,s)})}}class a extends o{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e){var t,n,i,r,o,a;const{clientName:s,creativeId:l,itemId:c,placement:d}=this.parseKilkayaData(e),u=this.mapPageType(this.pageType),v=null===(t=this.newsroomStrategy)||void 0===t?void 0:t.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(r=null===(i=null===(n=this.newsroomStrategy)||void 0===n?void 0:n.getPulseObjectId)||void 0===i?void 0:i.call(n))&&void 0!==r?r:d,"@type":"UIElement",position:d,elementType:"Article",custom:{customer:s,creativeId:null!=l?l:c},page:{"@id":null!=v?v:d,"@type":u,url:location.origin},tags:null===(a=null===(o=this.newsroomStrategy)||void 0===o?void 0:o.getTags)||void 0===a?void 0:a.call(o,e)}}getEventTarget(e){const{link:t,itemId:n,title:i}=this.parseKilkayaData(e);return{id:n,name:this.normalizePlacementTitle(null!=i?i:""),type:"Page",url:t}}getEventInput(e,t){return{object:this.getEventBaseData(e),partnerstudio:this.getEventPartnerstudioData(e,t),target:this.getEventTarget(e),provider:this.getProviderData()}}getEventPartnerstudioData(e,t){const n=this.parseKilkayaData(e);return Object.assign(Object.assign({},n),{type:t,tracking_type:"ad",xandrAdLoaded:!1})}getProviderData(){return{productTag:"partnerstudio"}}}const s="[data-k5a-teaser-analytics]",l=(e,t,n)=>{const i=document.querySelectorAll("k5a-stream");if(!i.length)return;const r=new a(e,t,n),o=new WeakMap,l=e=>{const t=o.get(e);t&&(t.disconnect(),o.delete(e))},c=new IntersectionObserver((e,t)=>{e.forEach(e=>{if(!e.isIntersecting)return;const n=e.target,i=n.querySelector(s);Boolean(null==i?void 0:i.dataset.k5aTeaserAnalytics)?(r.trackContentView(n),t.unobserve(e.target),l(n)):((e,t)=>{if(o.has(e))return;const n=new MutationObserver(()=>{const n=e.querySelector(s);Boolean(null==n?void 0:n.dataset.k5aTeaserAnalytics)&&(r.trackContentView(e),t.unobserve(e),l(e))});n.observe(e,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["data-k5a-teaser-analytics"]}),o.set(e,n)})(n,t)})},{threshold:.5});i.forEach(e=>{c.observe(e),e.addEventListener("click",()=>r.trackContentClick(e))})},c=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},d=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return c("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const r=e=>{i||(c("Resolving advertising permission value obtained"),i=!0,t(e))},o=setTimeout(()=>{c("Advertising permission timed out, resolving with false"),r(!1)},3e3);window._tcf_.onTcfReady(()=>{c("On Tcf Ready called, waiting for permission"),clearTimeout(o)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(o);const t=Number(e);c("Advertising permission value obtained asynchronously: ",e),r(Boolean(t))})}),u="no",v="se",g="cmp:loaded";let h,m=!1;const p=(e,n,i)=>{const r=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,a=(s="bypass_tcf",new URLSearchParams(window.location.search).get(s));var s;const l=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(c("TCF bypass param detected, returning consent: true"),!0):(c("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(m)return null;if(!h)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=h.getConsentedToAllSync();return c(`TCF consented to all is: ${t}`),h.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(c("Getting TCF consent manager..."),window._tcf_)return c("TCF consent manager is already available"),h=window._tcf_,void e(h);c("TCF consent manager is not available");const n=()=>{c("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(h=window._tcf_,e(h)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(g,n),m=!0,t(new Error("Timeout waiting for CMP to load"))},o);c("Listening for CMP loaded event..."),document.addEventListener(g,n,{once:!0})}):Promise.resolve(null),getConsentSync:l,getConsentAsync:()=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return c(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const t=(null==e?void 0:e.schibstedAdChoicesEnabled)&&i===v,r=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!n&&i===u;if(t||r)return c("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield d(e);if(!(null==e?void 0:e.enabled))return!0;const a=l();return null!==a?a:yield new Promise((e,t)=>{try{if(!h)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{c("TCF isConsentedToAll timed out, resolving with false"),n(!1)},o);h.onTcfReady(()=>{c("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),h.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}};class y{handleKilkayaStreamTracking({pulse:e,pageType:t,publisher:o}){if(!(null==e?void 0:e.instance))return;const a={[n]:new i}[o]||new r;l(e.instance,a,t)}injectKilkayaMeta(e){const t=document.createElement("script");t.textContent=`var k5aMeta = { consent: ${e} };`,document.head.appendChild(t)}observeForKilkayaBackfills(){document.addEventListener("K5A:EmptyStreamSlot",e=>{var t;const n=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.streamSlot;if(!n)return;const i=n.parentElement;i&&(c(`Kilkaya placement ${n.getAttribute("name")} has not been loaded, loading Xandr backfill`),this.showBackfill(i))})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";(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"))})(null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"")}loadKilkayaScript(e){return t(this,void 0,void 0,function*(){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(l)};r.addEventListener("load",o),r.addEventListener("error",a);const l=setTimeout(()=>{s(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(e)})}run(e){return t(this,void 0,void 0,function*(){const{tcf:n,isMobileApp:i,country:r,kilkaya:o}=e;if(!(null==o?void 0:o.enabled))return;const a=yield((e,n,i,...r)=>t(void 0,[e,n,i,...r],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return c(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return c(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=p(e,t,n);return(yield r())?(c(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(c(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}))(n,i,r,"kilkaya");a&&(this.observeForKilkayaBackfills(),this.injectKilkayaMeta(a),yield this.loadKilkayaScript(o.url),this.handleKilkayaStreamTracking(e))})}}exports.Kilkaya=({placementName:t,fallbackTargetId:n,children:i,pulseData:r,htmlAttributes:o})=>{const a=(e,t)=>{const n={};if(!e)return n;for(const[i,r]of Object.entries(e)){n[t?`${t}-${i}`:i]=String(r)}return n},s=a(r,"data-pulse"),l=a(o,"data");return e.jsxs("div",Object.assign({className:"kilkaya-wrapper kilkaya-lock-height"},s,l,{children:[e.jsx("div",{className:"inscreen-target"}),e.jsx("k5a-stream",{name:t}),e.jsx("div",{className:"container"}),e.jsx("div",{className:"fallback","data-fallback-target-id":n,style:{display:"none"},children:i})]}))},exports.runKilkaya=e=>t(void 0,void 0,void 0,function*(){const t=new y;yield t.run(e)});
@@ -229,6 +229,8 @@ interface Placement {
229
229
  drEdition?: DrEditionPlacementConfig;
230
230
  isBackfill?: boolean;
231
231
  takeoverCookieCapForSharedPlacement?: boolean;
232
+ serverSidePlacement?: boolean;
233
+ xandrPlacementId?: number;
232
234
  }
233
235
  interface Placements {
234
236
  desktop: Array<Placement>;
@@ -439,6 +441,7 @@ declare const getUserIdsObject: (country: Country) => UserIdsObject;
439
441
  declare const getPPIDLoggedInStatus: () => PPIDLoggedInStatusKeywords;
440
442
  declare const getPPIDRelevantYieldConfig: (country: Country) => RelevantYieldPPIDConfig | object;
441
443
  declare const getPPIDNorstatString: (country: Country) => string;
444
+ declare const getOpenRtbEids: (country: Country) => Array<RelevantYieldEids>;
442
445
  declare const getVideoPPIDs: (country: Country) => Promise<string>;
443
446
 
444
- export { getPPIDLoggedInStatus, getPPIDNorstatString, getPPIDRelevantYieldConfig, getUserIdsObject, getVideoPPIDs, setXandrPPIDs };
447
+ export { getOpenRtbEids, getPPIDLoggedInStatus, getPPIDNorstatString, getPPIDRelevantYieldConfig, getUserIdsObject, getVideoPPIDs, setXandrPPIDs };
@@ -1 +1 @@
1
- "use strict";function e(e,i,n,t){return new(n||(n=Promise))(function(s,d){function r(e){try{a(t.next(e))}catch(e){d(e)}}function o(e){try{a(t.throw(e))}catch(e){d(e)}}function a(e){var i;e.done?s(e.value):(i=e.value,i instanceof n?i:new n(function(e){e(i)})).then(r,o)}a((t=t.apply(e,i||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(i,n)=>e(void 0,void 0,void 0,function*(){const e=yield fetch(i,n);if(!e.ok)throw new Error(e.statusText);return yield e.json()}),post:(i,n,t)=>e(void 0,void 0,void 0,function*(){const e=JSON.stringify(t),s=yield fetch(i,{method:"POST",headers:n,body:e});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},n=(e,i)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(i?console.log(n,e,i):console.log(n,e))},t=864e5,s=(()=>{const e=e=>{const i=window.localStorage.getItem(e);if(!i)return null;try{return JSON.parse(i)}catch(e){return n("Error with parsing localStorage data"),null}},i=(e,i)=>{window.localStorage.setItem(e,JSON.stringify(i))};return{get:e,set:i,setWithTimestamp:(e,n,s=t)=>{const d={data:n,expirationTime:(new Date).getTime()+s};i(e,JSON.stringify(d))},getByTimestamp:(i,s=t)=>{const d=e(i);if(!d)return null;if(!s)return d;try{const{expirationTime:e,data:i}=JSON.parse(d);return(new Date).getTime()<=e?i:null}catch(e){return n("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`},c={[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'`},p={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},v={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class h{constructor(){this.eids=[]}add(e,i){return e&&this.eids.push({id:e,source:i}),this}buildRyEids(){return this.eids.map(({id:e,source:i})=>({source:i,uids:[{id:e,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:e,source:i})=>`${i},${e}`).join("|")}buildNorstatPath(){const e=this.eids[0];return e?`${e.source}-${e.id}`:""}buildNorstatQuery(e){const i=new URLSearchParams;return this.eids.slice(1).forEach(({id:n,source:t})=>{i.append(e,`${t}-${n}`)}),i}}const f=e=>new Promise(i=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void i(!1);const t=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const i=Number(e);return n("Advertising permission value obtained synchronously: ",e),Boolean(i)})();if(null!==t)return void i(t);let s=!1;const d=e=>{s||(n("Resolving advertising permission value obtained"),s=!0,i(e))},r=setTimeout(()=>{n("Advertising permission timed out, resolving with false"),d(!1)},3e3);window._tcf_.onTcfReady(()=>{n("On Tcf Ready called, waiting for permission"),clearTimeout(r)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(r);const i=Number(e);n("Advertising permission value obtained asynchronously: ",e),d(Boolean(i))})}),P="cmp:loaded";let g,I=!1;const y=(i,t,s)=>{const r=!!(null==i?void 0:i.enabled),o=(null==i?void 0:i.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const c=()=>{if(!(null==i?void 0:i.enabled))return!0;if(((e,i)=>e?!!i&&(n("TCF bypass param detected, returning consent: true"),!0):(n("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(I)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return n(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==i?void 0:i.enabled)?new Promise((e,i)=>{if(n("Getting TCF consent manager..."),window._tcf_)return n("TCF consent manager is already available"),g=window._tcf_,void e(g);n("TCF consent manager is not available");const t=()=>{n("CMP loaded, resolving consent manager..."),s&&clearTimeout(s),window._tcf_?(g=window._tcf_,e(g)):i(new Error("CMP loaded but window._tcf_ is not defined"))},s=setTimeout(()=>{document.removeEventListener(P,t),I=!0,i(new Error("Timeout waiting for CMP to load"))},o);n("Listening for CMP loaded event..."),document.addEventListener(P,t,{once:!0})}):Promise.resolve(null),getConsentSync:c,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==i?void 0:i.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${i.schibstedAdChoicesOverrideValue}`),Boolean(Number(i.schibstedAdChoicesOverrideValue));const e=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.SE,r=(null==i?void 0:i.schibstedAdChoicesEnabled)&&!t&&s===d.NO;if(e||r)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield f(i);if(!(null==i?void 0:i.enabled))return!0;const a=c();return null!==a?a:yield new Promise((e,i)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let i=!1;const t=n=>{i||(i=!0,e(n))},s=setTimeout(()=>{n("TCF isConsentedToAll timed out, resolving with false"),t(!1)},o);g.onTcfReady(()=>{n("On Tcf Ready called, waiting for consent"),clearTimeout(s)}),g.isConsentedToAll(i=>{clearTimeout(s),e(i)})}catch(e){i(e)}})})}},m=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(i){return e(this,arguments,void 0,function*(e,i=1e4){var n,t;const s=yield Promise.race([new Promise(e=>{setTimeout(()=>e({xandr:{ppId1:"",ppId2:""}}),i)}),e.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(n=s.xandr)||void 0===n?void 0:n.ppId1,null===(t=s.xandr)||void 0===t?void 0:t.ppId2)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:""}}setPPIDs(e,i){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:""}},w=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(i,n){return e(this,void 0,void 0,function*(){var e,t,d,o,a,l,c,u,p,v,h;const f=s.get(r),P=yield this.getNewPPIDs(i,n);if(this.shouldHash(f,P)){const n=null!==(e=i.hasherUrl)&&void 0!==e?e:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(P),r=yield this.hashPPIDs(s,n);return r?(this.cachePPIDs(s,r,null===(t=P.idfv)||void 0===t?void 0:t.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===(c=P.anId)||void 0===c?void 0:c.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==f?void 0:f.userId.hashed)&&void 0!==u?u:"",null!==(p=null==f?void 0:f.environmentId.hashed)&&void 0!==p?p:"",null===(v=null==P?void 0:P.idfv)||void 0===v?void 0:v.plain,null===(h=null==P?void 0:P.anId)||void 0===h?void 0:h.plain)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:"",idfv:this.idfv,anId:this.anId}}setPPIDs(e,i,n,t){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:"",this.idfv=null!=n?n:null,this.anId=null!=t?t:null}shouldHash(e,i){var n,t;if(!e)return!0;for(const s in e){if((null===(n=e[s])||void 0===n?void 0:n.plain)!==(null===(t=i[s])||void 0===t?void 0:t.plain))return!0}return!1}cachePPIDs(e,i,n,t){const d=Object.assign(Object.assign({clientId:{plain:e.clientId},userId:{plain:e.userId,hashed:i.userId},environmentId:{plain:e.environmentId,hashed:i.environmentId},trackerType:{plain:e.trackerType},trackerVersion:{plain:e.trackerVersion}},n?{idfv:{plain:n}}:{}),t?{anId:{plain:t}}:{});s.set(r,d)}hashPPIDs(t,s){return e(this,void 0,void 0,function*(){try{const e=new Headers({"Content-Type":"application/json"});return yield i.post(s,e,t)}catch(e){return n("Error with hashing PPIDs",e),null}})}getNewPPIDs(i,n){return e(this,arguments,void 0,function*({clientId:i,instance:n},t){const s=yield((i,n)=>e(void 0,void 0,void 0,function*(){const e=yield i.getUserId();return e?`${v[n]}:${e}`:null}))(n,t),d=yield(i=>e(void 0,void 0,void 0,function*(){const e=yield i.getEnvironmentId();return e?`sdrn:schibsted:environment:${e}`:null}))(n),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:i},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:e,trackerType:i,trackerVersion:n,userId:t,environmentId:s}){return{clientId:e.plain,trackerType:i.plain,trackerVersion:n.plain,userId:t.plain,environmentId:s.plain}}};exports.getPPIDLoggedInStatus=()=>{const{ppid1:e,ppid2:i}=m.getPPIDs();return{"aa-sch-schuserhash":e?"1":"0","aa-sch-schenvhash":i?"1":"0"}},exports.getPPIDNorstatString=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();if(!n)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildRyEids()}}]}}},exports.getUserIdsObject=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildEids()}]}},exports.getVideoPPIDs=i=>e(void 0,void 0,void 0,function*(){const{ppid1:e,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[i]).add(e,a[i]).add(s,l[i]).add(t,c[i]);return yield new Promise(e=>{e(d.buildVideoEids())})}),exports.setXandrPPIDs=i=>e(void 0,void 0,void 0,function*(){const{tracker:t,tcf:s,country:d,isMobileApp:r}=i,o=yield((i,t,s,...d)=>e(void 0,[i,t,s,...d],void 0,function*(e,i,t,s="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return n(`Schibsted Consent to Pay is not enabled, returning true for ${s}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${s}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:d}=y(e,i,t);return(yield d())?(n(`Schibsted Ad Choices consent given according to TCF consent manager for ${s}`),!0):(n(`Schibsted Ad Choices consent not given according to TCF consent manager for ${s}`),!1)}))(s,r,d,"setXandrPPIDs");if(!o)return;if(!t)return;(yield Promise.allSettled([m.processPPIDs(t,null==s?void 0:s.timeout),w.processPPIDs(t,d)])).forEach((e,i)=>{if("rejected"===e.status){n(`Cannot fetch PPIDs v${i+2}`,e.reason)}})});
1
+ "use strict";function e(e,i,n,t){return new(n||(n=Promise))(function(s,d){function r(e){try{a(t.next(e))}catch(e){d(e)}}function o(e){try{a(t.throw(e))}catch(e){d(e)}}function a(e){var i;e.done?s(e.value):(i=e.value,i instanceof n?i:new n(function(e){e(i)})).then(r,o)}a((t=t.apply(e,i||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(i,n)=>e(void 0,void 0,void 0,function*(){const e=yield fetch(i,n);if(!e.ok)throw new Error(e.statusText);return yield e.json()}),post:(i,n,t)=>e(void 0,void 0,void 0,function*(){const e=JSON.stringify(t),s=yield fetch(i,{method:"POST",headers:n,body:e});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},n=(e,i)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(i?console.log(n,e,i):console.log(n,e))},t=864e5,s=(()=>{const e=e=>{const i=window.localStorage.getItem(e);if(!i)return null;try{return JSON.parse(i)}catch(e){return n("Error with parsing localStorage data"),null}},i=(e,i)=>{window.localStorage.setItem(e,JSON.stringify(i))};return{get:e,set:i,setWithTimestamp:(e,n,s=t)=>{const d={data:n,expirationTime:(new Date).getTime()+s};i(e,JSON.stringify(d))},getByTimestamp:(i,s=t)=>{const d=e(i);if(!d)return null;if(!s)return d;try{const{expirationTime:e,data:i}=JSON.parse(d);return(new Date).getTime()<=e?i:null}catch(e){return n("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`},c={[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'`},p={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},v={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class h{constructor(){this.eids=[]}add(e,i){return e&&this.eids.push({id:e,source:i}),this}buildRyEids(){return this.eids.map(({id:e,source:i})=>({source:i,uids:[{id:e,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:e,source:i})=>`${i},${e}`).join("|")}buildNorstatPath(){const e=this.eids[0];return e?`${e.source}-${e.id}`:""}buildNorstatQuery(e){const i=new URLSearchParams;return this.eids.slice(1).forEach(({id:n,source:t})=>{i.append(e,`${t}-${n}`)}),i}}const P=e=>new Promise(i=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void i(!1);const t=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const i=Number(e);return n("Advertising permission value obtained synchronously: ",e),Boolean(i)})();if(null!==t)return void i(t);let s=!1;const d=e=>{s||(n("Resolving advertising permission value obtained"),s=!0,i(e))},r=setTimeout(()=>{n("Advertising permission timed out, resolving with false"),d(!1)},3e3);window._tcf_.onTcfReady(()=>{n("On Tcf Ready called, waiting for permission"),clearTimeout(r)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(r);const i=Number(e);n("Advertising permission value obtained asynchronously: ",e),d(Boolean(i))})}),f="cmp:loaded";let g,I=!1;const y=(i,t,s)=>{const r=!!(null==i?void 0:i.enabled),o=(null==i?void 0:i.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const c=()=>{if(!(null==i?void 0:i.enabled))return!0;if(((e,i)=>e?!!i&&(n("TCF bypass param detected, returning consent: true"),!0):(n("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(I)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return n(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==i?void 0:i.enabled)?new Promise((e,i)=>{if(n("Getting TCF consent manager..."),window._tcf_)return n("TCF consent manager is already available"),g=window._tcf_,void e(g);n("TCF consent manager is not available");const t=()=>{n("CMP loaded, resolving consent manager..."),s&&clearTimeout(s),window._tcf_?(g=window._tcf_,e(g)):i(new Error("CMP loaded but window._tcf_ is not defined"))},s=setTimeout(()=>{document.removeEventListener(f,t),I=!0,i(new Error("Timeout waiting for CMP to load"))},o);n("Listening for CMP loaded event..."),document.addEventListener(f,t,{once:!0})}):Promise.resolve(null),getConsentSync:c,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==i?void 0:i.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${i.schibstedAdChoicesOverrideValue}`),Boolean(Number(i.schibstedAdChoicesOverrideValue));const e=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.SE,r=(null==i?void 0:i.schibstedAdChoicesEnabled)&&!t&&s===d.NO;if(e||r)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield P(i);if(!(null==i?void 0:i.enabled))return!0;const a=c();return null!==a?a:yield new Promise((e,i)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let i=!1;const t=n=>{i||(i=!0,e(n))},s=setTimeout(()=>{n("TCF isConsentedToAll timed out, resolving with false"),t(!1)},o);g.onTcfReady(()=>{n("On Tcf Ready called, waiting for consent"),clearTimeout(s)}),g.isConsentedToAll(i=>{clearTimeout(s),e(i)})}catch(e){i(e)}})})}},m=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(i){return e(this,arguments,void 0,function*(e,i=1e4){var n,t;const s=yield Promise.race([new Promise(e=>{setTimeout(()=>e({xandr:{ppId1:"",ppId2:""}}),i)}),e.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(n=s.xandr)||void 0===n?void 0:n.ppId1,null===(t=s.xandr)||void 0===t?void 0:t.ppId2)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:""}}setPPIDs(e,i){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:""}},w=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(i,n){return e(this,void 0,void 0,function*(){var e,t,d,o,a,l,c,u,p,v,h;const P=s.get(r),f=yield this.getNewPPIDs(i,n);if(this.shouldHash(P,f)){const n=null!==(e=i.hasherUrl)&&void 0!==e?e:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(f),r=yield this.hashPPIDs(s,n);return r?(this.cachePPIDs(s,r,null===(t=f.idfv)||void 0===t?void 0:t.plain,null===(d=f.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=f.idfv)||void 0===l?void 0:l.plain,null===(c=f.anId)||void 0===c?void 0:c.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==P?void 0:P.userId.hashed)&&void 0!==u?u:"",null!==(p=null==P?void 0:P.environmentId.hashed)&&void 0!==p?p:"",null===(v=null==f?void 0:f.idfv)||void 0===v?void 0:v.plain,null===(h=null==f?void 0:f.anId)||void 0===h?void 0:h.plain)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:"",idfv:this.idfv,anId:this.anId}}setPPIDs(e,i,n,t){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:"",this.idfv=null!=n?n:null,this.anId=null!=t?t:null}shouldHash(e,i){var n,t;if(!e)return!0;for(const s in e){if((null===(n=e[s])||void 0===n?void 0:n.plain)!==(null===(t=i[s])||void 0===t?void 0:t.plain))return!0}return!1}cachePPIDs(e,i,n,t){const d=Object.assign(Object.assign({clientId:{plain:e.clientId},userId:{plain:e.userId,hashed:i.userId},environmentId:{plain:e.environmentId,hashed:i.environmentId},trackerType:{plain:e.trackerType},trackerVersion:{plain:e.trackerVersion}},n?{idfv:{plain:n}}:{}),t?{anId:{plain:t}}:{});s.set(r,d)}hashPPIDs(t,s){return e(this,void 0,void 0,function*(){try{const e=new Headers({"Content-Type":"application/json"});return yield i.post(s,e,t)}catch(e){return n("Error with hashing PPIDs",e),null}})}getNewPPIDs(i,n){return e(this,arguments,void 0,function*({clientId:i,instance:n},t){const s=yield((i,n)=>e(void 0,void 0,void 0,function*(){const e=yield i.getUserId();return e?`${v[n]}:${e}`:null}))(n,t),d=yield(i=>e(void 0,void 0,void 0,function*(){const e=yield i.getEnvironmentId();return e?`sdrn:schibsted:environment:${e}`:null}))(n),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:i},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:e,trackerType:i,trackerVersion:n,userId:t,environmentId:s}){return{clientId:e.plain,trackerType:i.plain,trackerVersion:n.plain,userId:t.plain,environmentId:s.plain}}};exports.getOpenRtbEids=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs();return(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).buildRyEids()},exports.getPPIDLoggedInStatus=()=>{const{ppid1:e,ppid2:i}=m.getPPIDs();return{"aa-sch-schuserhash":e?"1":"0","aa-sch-schenvhash":i?"1":"0"}},exports.getPPIDNorstatString=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();if(!n)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildRyEids()}}]}}},exports.getUserIdsObject=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildEids()}]}},exports.getVideoPPIDs=i=>e(void 0,void 0,void 0,function*(){const{ppid1:e,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[i]).add(e,a[i]).add(s,l[i]).add(t,c[i]);return yield new Promise(e=>{e(d.buildVideoEids())})}),exports.setXandrPPIDs=i=>e(void 0,void 0,void 0,function*(){const{tracker:t,tcf:s,country:d,isMobileApp:r}=i,o=yield((i,t,s,...d)=>e(void 0,[i,t,s,...d],void 0,function*(e,i,t,s="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return n(`Schibsted Consent to Pay is not enabled, returning true for ${s}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${s}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:d}=y(e,i,t);return(yield d())?(n(`Schibsted Ad Choices consent given according to TCF consent manager for ${s}`),!0):(n(`Schibsted Ad Choices consent not given according to TCF consent manager for ${s}`),!1)}))(s,r,d,"setXandrPPIDs");if(!o)return;if(!t)return;(yield Promise.allSettled([m.processPPIDs(t,null==s?void 0:s.timeout),w.processPPIDs(t,d)])).forEach((e,i)=>{if("rejected"===e.status){n(`Cannot fetch PPIDs v${i+2}`,e.reason)}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/advertory",
3
- "version": "2.63.14",
3
+ "version": "2.63.15-server-side-rendering",
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",