hypnagaga/docs/assets/AdSlot.stories-b78a1cd1.js
2024-02-28 18:25:00 +00:00

34 lines
10 KiB
JavaScript

import{S as E,i as I,s as C,o as m,b as i,e as u,n as T,f,D as N,g as w,m as h,t as b,h as k,j as A,y,d as v,C as x}from"./index-43e9a565.js";import{g as R,a as D}from"./spread-8a54911c.js";import{p as F,M as z,T as Q,S as U}from"./collect-stories-23d08061.js";import{g as L}from"./globals-7f7f1b26.js";import{t as j}from"./throttle-dfed7c30.js";import{B}from"./Block-db774151.js";import{w as V}from"./withParams-47e2ab71.js";import"./isObject-32699ff3.js";import"./now-bd49f550.js";import"./isSymbol-50749e90.js";const Y=`Add programmatic ads to your page.
> **IMPORTANT!** Make sure ads are only used on dotcom pages, never on embeds.
\`\`\`svelte
<script>
import { AdSlot, AdScripts } from '@reuters-graphics/graphics-components';
<\/script>
<!-- ALWAYS check if in an embed context! -->
{#if !embedded}
<!-- Include AdScripts only ONCE per page -->
<AdScripts />
{/if}
<!-- ... -->
{#if !embedded}
<AdSlot />
{/if}
<!-- ... -->
{#if !embedded}
<!-- Can add multiple ads to your page -->
<AdSlot />
{/if}
\`\`\`
`,P=(a,e=window.location.href)=>{a=a.replace(/[\[\]]/g,"\\$&");const t=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)").exec(e);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},G=600,K=()=>new Promise(a=>{const e=setTimeout(()=>{a("Resolved with timeout")},G),s=()=>{clearTimeout(e),window.__iasPET=window.__iasPET||{},window.__iasPET.queue=window.__iasPET.queue||[],window.__iasPET.pubId="931336",a("loaded")},t=document.createElement("script");t.src="//static.adsafeprotected.com/iasPET.1.js",t.setAttribute("async","async"),document.head.appendChild(t),t.onload=s,t.onerror=()=>{a("error")}}),q=(a,e)=>{const s=document.createElement("script");s.addEventListener("load",e),s.src=a,document.head.append(s)},W="ot_logs",H="ot_geolocation_mock",J="38cb75bd-fbe1-4ac8-b4af-e531ab368caf-test",X=()=>{window.freestar=window.freestar||{};const a=window.freestar;a.debug=!0,a.queue=a.queue||[],a.config=a.config||{},a.config.enabled_slots=[],a.initCallback=function(){a.config.enabled_slots.length===0?a.initCallbackCalled=!1:a.newAdSlots(a.config.enabled_slots)},a.config.channel="/4735792/reuters.com/home",window.initBootstrap({onetrust_logs:P(W)||"false",geolocation_mock:P(H)||"default",onetrust_script_id:J},e=>{const s=K();return Promise.all([s]).then(t=>{const[r]=t;return{...e,ias:r}})}),window.bootstrap.getResults(e=>{q("https://a.pub.network/reuters-com/pubfig.min.js"),window.googletag=window.googletag||{cmd:[]},window.googletag.cmd.push(()=>{var r;window.googletag.pubads().enableSingleRequest(),window.googletag.pubads().enableAsyncRendering(),window.googletag.pubads().collapseEmptyDivs(!0);const s=new URL(document.location.href).searchParams.get("adstest");s&&window.googletag.pubads().setTargeting("adstest",s);const t=(r=document.querySelector('meta[name="ad:template"]'))==null?void 0:r.content;t&&window.googletag.pubads().setTargeting("template",t)}),Array.isArray(window.graphicsAdQueue)||console.error("Ad queue not initialized!"),a.queue.push(function(){a.newAdSlots(window.graphicsAdQueue||[],"foobar")}),a.queue.push(function(){window.googletag.pubads().set("page_url","https://www.reuters.com/")})})},{document:g}=L;function Z(a){let e,s,t,r,l,d,c,p,o,n;return{c(){e=m("link"),s=m("link"),t=m("link"),r=m("link"),l=m("link"),d=m("link"),c=m("link"),p=m("link"),o=m("link"),n=m("link"),i(e,"rel","preconnect"),i(e,"href","https://a.pub.network/"),i(e,"crossorigin",""),i(s,"rel","preconnect"),i(s,"href","https://b.pub.network/"),i(s,"crossorigin",""),i(t,"rel","preconnect"),i(t,"href","https://c.pub.network/"),i(t,"crossorigin",""),i(r,"rel","preconnect"),i(r,"href","https://d.pub.network/"),i(r,"crossorigin",""),i(l,"rel","preconnect"),i(l,"href","https://c.amazon-adsystem.com"),i(l,"crossorigin",""),i(d,"rel","preconnect"),i(d,"href","https://s.amazon-adsystem.com"),i(d,"crossorigin",""),i(c,"rel","preconnect"),i(c,"href","https://btloader.com/"),i(c,"crossorigin",""),i(p,"rel","preconnect"),i(p,"href","https://api.btloader.com/"),i(p,"crossorigin",""),i(o,"rel","preconnect"),i(o,"href","https://confiant-integrations.global.ssl.fastly.net"),i(o,"crossorigin",""),i(n,"rel","stylesheet"),i(n,"href","https://a.pub.network/reuters-com/cls.css")},m(_,S){u(g.head,e),u(g.head,s),u(g.head,t),u(g.head,r),u(g.head,l),u(g.head,d),u(g.head,c),u(g.head,p),u(g.head,o),u(g.head,n)},p:T,i:T,o:T,d(_){f(e),f(s),f(t),f(r),f(l),f(d),f(c),f(p),f(o),f(n)}}}function ee(a){let e=0,s=!0;const t=(l=!0)=>{const d=document.getElementById("ot-sdk-btn-floating");d&&(l?(s=!0,d.style.bottom=""):(s=!1,d.style.bottom="-5rem"))},r=()=>{e>window.scrollY?s||t(!0):s&&window.scrollY>250&&t(!1),e=window.scrollY};return N(()=>{window.graphicsAdQueue=window.graphicsAdQueue||[],q("https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js",X),window.addEventListener("scroll",j(r,250),{passive:!0})}),[]}class M extends E{constructor(e){super(),I(this,e,ee,Z,C,{})}}M.__docgen={version:3,name:"AdScripts.svelte",data:[],computed:[],methods:[],components:[],description:null,keywords:[],events:[],slots:[],refs:[]};function te(a){let e,s,t,r,l,d,c,p;return{c(){e=m("div"),s=m("div"),s.textContent="Advertisement · Scroll to continue",t=y(),r=m("div"),l=m("div"),d=m("div"),c=m("div"),i(s,"class","ad-label svelte-1gzmm8s"),i(c,"data-freestar-ad",p=a[0]||null),i(c,"id",a[3]),i(c,"class","svelte-1gzmm8s"),i(d,"class","svelte-1gzmm8s"),i(l,"class","ad-slot__inner svelte-1gzmm8s"),i(r,"class","ad-container svelte-1gzmm8s"),i(e,"class","ad-block svelte-1gzmm8s")},m(o,n){v(o,e,n),u(e,s),u(e,t),u(e,r),u(r,l),u(l,d),u(d,c)},p(o,n){n&1&&p!==(p=o[0]||null)&&i(c,"data-freestar-ad",p)},d(o){o&&f(e)}}}function se(a){let e,s;return e=new B({props:{id:a[1],class:"freestar-adslot "+a[2],$$slots:{default:[te]},$$scope:{ctx:a}}}),{c(){w(e.$$.fragment)},m(t,r){h(e,t,r),s=!0},p(t,[r]){const l={};r&2&&(l.id=t[1]),r&4&&(l.class="freestar-adslot "+t[2]),r&129&&(l.$$scope={dirty:r,ctx:t}),e.$set(l)},i(t){s||(b(e.$$.fragment,t),s=!0)},o(t){k(e.$$.fragment,t),s=!1},d(t){A(e,t)}}}function ne(a,e,s){let{placementName:t="reuters_desktop_native_1"}=e,{dataFreestarAd:r="__970x250"}=e,{id:l=""}=e,{class:d="my-12"}=e;const c=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1),p="ad-"+c()+c(),o=n=>{switch(n){case"reuters_sponsorlogo":return"Sponsorlogo";case"reuters_mobile_mpu_1":return"mpu";default:return"native"}};return N(()=>{const _=new URLSearchParams(window.location.search).get("adstest");window.graphicsAdQueue=window.graphicsAdQueue||[],window.graphicsAdQueue.push({placementName:t,slotId:p,type:o(t),graphicId:window.location.pathname,adstest:_})}),a.$$set=n=>{"placementName"in n&&s(4,t=n.placementName),"dataFreestarAd"in n&&s(0,r=n.dataFreestarAd),"id"in n&&s(1,l=n.id),"class"in n&&s(2,d=n.class)},[r,l,d,p,t]}class $ extends E{constructor(e){super(),I(this,e,ne,se,C,{placementName:4,dataFreestarAd:0,id:1,class:2})}}$.__docgen={version:3,name:"AdSlot.svelte",data:[{keywords:[{name:"required",description:""}],visibility:"public",description:"The unique placement name from FreeStar dashboard.",name:"placementName",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"reuters_desktop_native_1"},{keywords:[],visibility:"public",description:"The unique slot Id from FreeStar dashboard.",name:"dataFreestarAd",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"__970x250"},{keywords:[],visibility:"public",description:"Add an ID to target with SCSS.",name:"id",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:""},{visibility:"public",description:"Add a class to target with SCSS.",keywords:[],name:"class",kind:"const",static:!1,readonly:!0,type:{kind:"type",text:"string",type:"string"},localName:"cls",defaultValue:"my-12"}],computed:[],methods:[],components:[],description:"",keywords:[{name:"component",description:"`AdSlot` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-AdSlot--default)"}],events:[],slots:[],refs:[]};function oe(a){let e,s,t,r,l,d,c;s=new M({});const p=[a[1]];let o={};for(let n=0;n<p.length;n+=1)o=x(o,p[n]);return r=new $({props:o}),d=new $({props:{placementName:"reuters_desktop_canvas",dataFreestarAd:"__970x250"}}),{c(){e=m("div"),w(s.$$.fragment),t=y(),w(r.$$.fragment),l=y(),w(d.$$.fragment)},m(n,_){v(n,e,_),h(s,e,null),u(e,t),h(r,e,null),u(e,l),h(d,e,null),c=!0},p(n,_){const S=_&2?R(p,[D(n[1])]):{};r.$set(S)},i(n){c||(b(s.$$.fragment,n),b(r.$$.fragment,n),b(d.$$.fragment,n),c=!0)},o(n){k(s.$$.fragment,n),k(r.$$.fragment,n),k(d.$$.fragment,n),c=!1},d(n){n&&f(e),A(s),A(r),A(d)}}}function ae(a){let e,s,t,r,l,d;const c=[a[0]];let p={};for(let o=0;o<c.length;o+=1)p=x(p,c[o]);return e=new z({props:p}),t=new Q({props:{$$slots:{default:[oe,({args:o})=>({1:o}),({args:o})=>o?2:0]},$$scope:{ctx:a}}}),l=new U({props:{name:"Default",args:{placementName:"reuters_desktop_native_1",dataFreestarAd:"__970x250"}}}),{c(){w(e.$$.fragment),s=y(),w(t.$$.fragment),r=y(),w(l.$$.fragment)},m(o,n){h(e,o,n),v(o,s,n),h(t,o,n),v(o,r,n),h(l,o,n),d=!0},p(o,[n]){const _=n&1?R(c,[D(o[0])]):{};e.$set(_);const S={};n&6&&(S.$$scope={dirty:n,ctx:o}),t.$set(S)},i(o){d||(b(e.$$.fragment,o),b(t.$$.fragment,o),b(l.$$.fragment,o),d=!0)},o(o){k(e.$$.fragment,o),k(t.$$.fragment,o),k(l.$$.fragment,o),d=!1},d(o){o&&(f(s),f(r)),A(e,o),A(t,o),A(l,o)}}}function re(a){return[{title:"Components/AdSlot",component:$,...V(Y),argTypes:{placementName:{control:"select",options:["reuters_desktop_native_1","reuters_desktop_canvas"]},dataFreestarAd:{control:"select",options:["__970x250"]}}}]}class ie extends E{constructor(e){super(),I(this,e,re,ae,C,{})}}const O=F(ie,{meta:{},stories:{"tpl:default":{name:"default",template:!0,source:`<div>
<AdScripts />
<AdSlot {...args} />
<AdSlot placementName="reuters_desktop_canvas" dataFreestarAd="__970x250" />
</div>`,hasArgs:!0},Default:{name:"Default",template:!1,source:"",hasArgs:!1}},allocatedIds:["default","Meta","Template","Story","componentDocs","AdScripts","AdSlot","withComponentDocs"]}),he=O.meta,be=["Default"],ke=O.stories.Default;export{ke as Default,be as __namedExportsOrder,he as default};
//# sourceMappingURL=AdSlot.stories-b78a1cd1.js.map