hypnagaga/docs/assets/AdSlot.stories-9265d65e.js
2024-02-28 11:28:46 +00:00

35 lines
9.7 KiB
JavaScript

import{S as T,i as E,s as I,o as m,b as i,e as p,n as $,f,D as C,g as _,m as h,t as w,h as k,j as b,y as S,d as y,C as D}from"./index-43e9a565.js";import{g as x,a as P}from"./spread-8a54911c.js";import{p as O,M as j,T as M,S as Q}from"./collect-stories-23d08061.js";import{B as U}from"./Block-db774151.js";import{w as B}from"./withParams-47e2ab71.js";const L=`Display a FreeStar Ad Slot
Note: You must use this domain to access the story book:
\`http://localhost.arcpublishing.com:3000\`
This domain has been whitelisted on the Ad server. To setup the domain locally, add the following line to \`/etc/hosts\`:
\`\`\`
127.0.0.1 localhost localhost.arcpublishing.com
\`\`\`
\`\`\`svelte
<script>
import { AdSlot, AdScripts } from '@reuters-graphics/graphics-components';
<\/script>
<!-- Include only ONCE per page -->
<AdScripts />
<AdSlot
placementName="reuters_desktop_native"
slotId="reuters_desktop_native"
/>
<AdSlot
placementName="reuters_desktop_native"
slotId="reuters_desktop_native"
/>
\`\`\`
`,N=(s,e=window.location.href)=>{s=s.replace(/[\[\]]/g,"\\$&");const t=new RegExp("[?&]"+s+"(=([^&#]*)|&|#|$)").exec(e);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},V=600,z=()=>new Promise(s=>{const e=setTimeout(()=>{s("Resolved with timeout")},V),o=()=>{clearTimeout(e),window.__iasPET=window.__iasPET||{},window.__iasPET.queue=window.__iasPET.queue||[],window.__iasPET.pubId="931336",s("loaded")},t=document.createElement("script");t.src="//static.adsafeprotected.com/iasPET.1.js",t.setAttribute("async","async"),document.head.appendChild(t),t.onload=o,t.onerror=()=>{s("error")}}),R=(s,e)=>{const o=document.createElement("script");o.addEventListener("load",e),o.src=s,document.head.append(o)},G="ot_logs",K="ot_geolocation_mock",Y="38cb75bd-fbe1-4ac8-b4af-e531ab368caf-test",H=()=>{window.freestar=window.freestar||{};const s=window.freestar;s.debug=!0,s.queue=s.queue||[],s.config=s.config||{},s.config.enabled_slots=[],s.initCallback=function(){s.config.enabled_slots.length===0?s.initCallbackCalled=!1:s.newAdSlots(s.config.enabled_slots)},s.config.channel="/4735792/reuters.com/home",window.initBootstrap({onetrust_logs:N(G)||"false",geolocation_mock:N(K)||"default",onetrust_script_id:Y},e=>{const o=z();return Promise.all([o]).then(t=>{const[r]=t;return{...e,ias:r}})}),window.bootstrap.getResults(e=>{R("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 o=new URL(document.location.href).searchParams.get("adstest");o&&window.googletag.pubads().setTargeting("adstest",o);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!"),s.queue.push(function(){s.newAdSlots(window.graphicsAdQueue||[],"foobar")}),s.queue.push(function(){window.googletag.pubads().set("page_url","https://www.reuters.com/")})})};function J(s){let e,o,t,r,l,d,c,u,a,n;return{c(){e=m("link"),o=m("link"),t=m("link"),r=m("link"),l=m("link"),d=m("link"),c=m("link"),u=m("link"),a=m("link"),n=m("link"),i(e,"rel","preconnect"),i(e,"href","https://a.pub.network/"),i(e,"crossorigin",""),i(o,"rel","preconnect"),i(o,"href","https://b.pub.network/"),i(o,"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(u,"rel","preconnect"),i(u,"href","https://api.btloader.com/"),i(u,"crossorigin",""),i(a,"rel","preconnect"),i(a,"href","https://confiant-integrations.global.ssl.fastly.net"),i(a,"crossorigin",""),i(n,"rel","stylesheet"),i(n,"href","https://a.pub.network/reuters-com/cls.css")},m(g,A){p(document.head,e),p(document.head,o),p(document.head,t),p(document.head,r),p(document.head,l),p(document.head,d),p(document.head,c),p(document.head,u),p(document.head,a),p(document.head,n)},p:$,i:$,o:$,d(g){f(e),f(o),f(t),f(r),f(l),f(d),f(c),f(u),f(a),f(n)}}}function W(s){return C(()=>{window.graphicsAdQueue=window.graphicsAdQueue||[],R("https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js",H)}),[]}class q extends T{constructor(e){super(),E(this,e,W,J,I,{})}}q.__docgen={version:3,name:"AdScripts.svelte",data:[],computed:[],methods:[],components:[],description:null,keywords:[],events:[],slots:[],refs:[]};function X(s){let e,o,t,r,l,d;return{c(){e=m("div"),o=m("div"),o.textContent="Advertisement · Scroll to continue",t=S(),r=m("div"),l=m("div"),i(o,"class","ad-label svelte-15j751g"),i(l,"data-freestar-ad",d=s[0]||null),i(l,"id",s[3]),i(l,"class","svelte-15j751g"),i(r,"class","ad-container svelte-15j751g"),i(e,"class","ad-block svelte-15j751g")},m(c,u){y(c,e,u),p(e,o),p(e,t),p(e,r),p(r,l)},p(c,u){u&1&&d!==(d=c[0]||null)&&i(l,"data-freestar-ad",d)},d(c){c&&f(e)}}}function Z(s){let e,o;return e=new U({props:{id:s[1],class:"freestar-adslot "+s[2],$$slots:{default:[X]},$$scope:{ctx:s}}}),{c(){_(e.$$.fragment)},m(t,r){h(e,t,r),o=!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){o||(w(e.$$.fragment,t),o=!0)},o(t){k(e.$$.fragment,t),o=!1},d(t){b(e,t)}}}function ee(s,e,o){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),u="ad-"+c()+c(),a=n=>{switch(n){case"reuters_sponsorlogo":return"Sponsorlogo";case"reuters_mobile_mpu_1":return"mpu";default:return"native"}};return C(()=>{const g=new URLSearchParams(window.location.search).get("adstest");window.graphicsAdQueue=window.graphicsAdQueue||[],window.graphicsAdQueue.push({placementName:t,slotId:u,type:a(t),graphicId:window.location.pathname,adstest:g})}),s.$$set=n=>{"placementName"in n&&o(4,t=n.placementName),"dataFreestarAd"in n&&o(0,r=n.dataFreestarAd),"id"in n&&o(1,l=n.id),"class"in n&&o(2,d=n.class)},[r,l,d,u,t]}class v extends T{constructor(e){super(),E(this,e,ee,Z,I,{placementName:4,dataFreestarAd:0,id:1,class:2})}}v.__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 te(s){let e,o,t,r,l,d,c;o=new q({});const u=[s[1]];let a={};for(let n=0;n<u.length;n+=1)a=D(a,u[n]);return r=new v({props:a}),d=new v({props:{placementName:"reuters_desktop_canvas",dataFreestarAd:"__970x250"}}),{c(){e=m("div"),_(o.$$.fragment),t=S(),_(r.$$.fragment),l=S(),_(d.$$.fragment)},m(n,g){y(n,e,g),h(o,e,null),p(e,t),h(r,e,null),p(e,l),h(d,e,null),c=!0},p(n,g){const A=g&2?x(u,[P(n[1])]):{};r.$set(A)},i(n){c||(w(o.$$.fragment,n),w(r.$$.fragment,n),w(d.$$.fragment,n),c=!0)},o(n){k(o.$$.fragment,n),k(r.$$.fragment,n),k(d.$$.fragment,n),c=!1},d(n){n&&f(e),b(o),b(r),b(d)}}}function se(s){let e,o,t,r,l,d;const c=[s[0]];let u={};for(let a=0;a<c.length;a+=1)u=D(u,c[a]);return e=new j({props:u}),t=new M({props:{$$slots:{default:[te,({args:a})=>({1:a}),({args:a})=>a?2:0]},$$scope:{ctx:s}}}),l=new Q({props:{name:"Default",args:{placementName:"reuters_desktop_native_1",dataFreestarAd:"__970x250"}}}),{c(){_(e.$$.fragment),o=S(),_(t.$$.fragment),r=S(),_(l.$$.fragment)},m(a,n){h(e,a,n),y(a,o,n),h(t,a,n),y(a,r,n),h(l,a,n),d=!0},p(a,[n]){const g=n&1?x(c,[P(a[0])]):{};e.$set(g);const A={};n&6&&(A.$$scope={dirty:n,ctx:a}),t.$set(A)},i(a){d||(w(e.$$.fragment,a),w(t.$$.fragment,a),w(l.$$.fragment,a),d=!0)},o(a){k(e.$$.fragment,a),k(t.$$.fragment,a),k(l.$$.fragment,a),d=!1},d(a){a&&(f(o),f(r)),b(e,a),b(t,a),b(l,a)}}}function ne(s){return[{title:"Components/AdSlot",component:v,...B(L),argTypes:{placementName:{control:"select",options:["reuters_desktop_leaderboard_atf","reuters_desktop_native","reuters_desktop_canvas"]},dataFreestarAd:{control:"select",options:["__970x250"]}}}]}class oe extends T{constructor(e){super(),E(this,e,ne,se,I,{})}}const F=O(oe,{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"]}),ce=F.meta,ue=["Default"],pe=F.stories.Default;export{pe as Default,ue as __namedExportsOrder,ce as default};
//# sourceMappingURL=AdSlot.stories-9265d65e.js.map