!function(){"use strict";var e={243:function(e,t,o){o.d(t,{default:function(){return l}});const n="PMC: Piano: ",a=()=>{var e,t;return null===(t=null===(e=window.location)||void 0===e?void 0:e.search)||void 0===t?void 0:t.includes("pianoDebug")};let r;e=o.hmd(e);let i="";const s={initialized:!1,setDataForNewsletter:!1,targetElements:{paywall:".pmc-paywall",paywallFade:"a-article-nl-fade",overlay:"div[id=piano-paywall] .tp-container-inner"},signupURLs:{billboard:"https://cloud.email.billboard.com/signup/",sourcingjournal:"https://cloud.email.sourcingjournal.com/signup/",sportico:"https://cloud.email.sportico.com/signup/",wwd:"https://cloud.email.wwd.com/signup/",variety:"https://cloud.email.variety.com/signup/",rollingstone:"https://cloud.email.rollingstone.com/signup/"},modal:!0,emailInputFocused:!1,prepareExactTargetFormData:e=>{const t=Object.assign({__contextName:"FormPost",__executionContext:"Post"},e.data.formData),o=new FormData;for(let[e,n]of Object.entries(t))o.append(e,n);return o},sendSignupDataToExactTarget:e=>{const t=window.pmcPiano.newsletterForm,o=t.signupURLs[i];o||console.error(n,"Invaild brand for newsletter form submission",{brand:i,signupURLs:t.signupURLs}),fetch(o,{method:"POST",mode:"no-cors",body:e}).then((e=>{a()&&console.log(n,"POST request to ExactTarget successful:",e)})).catch((e=>{console.error(n,"Error sending formData to ExtactTarget:",e)}))},calculateTopOffset:()=>{var e,t,o,n;const a=(null===(e=document.querySelector("header"))||void 0===e?void 0:e.offsetHeight)||0,r=(null===(t=document.querySelector(".js-Header-contents"))||void 0===t?void 0:t.offsetHeight)||0,i=Math.max(a,r)+20,s=null===(o=document.querySelector(".pmc-paywall > .jw-state-playing"))||void 0===o?void 0:o.offsetHeight,l=null===(n=document.querySelector(".live-event-banner > .banner-regular"))||void 0===n?void 0:n.offsetHeight;if(window.innerWidth<768){if(s>0)return i+s;if(l>0)return i+l}return i},stickyDismissableRegwall:()=>{const e=window.pmcPiano.newsletterForm,t=document.querySelector(e.targetElements.paywall),o=document.querySelector(`${e.targetElements.overlay} iframe`);t&&o?(t.classList.add(e.targetElements.paywallFade),window.addEventListener("scroll",(()=>{const o=document.querySelector(e.targetElements.overlay),n=t.getBoundingClientRect().top+window.scrollY,a=e.calculateTopOffset();o.style.top="0",o.style.zIndex="2",o.style.transition="top 0.1s ease 0s";const r=(t.getBoundingClientRect().top<=a?Math.min(Math.max(0,window.scrollY+a-n),t.clientHeight-o.clientHeight):0)+(e.emailInputFocused?-150:0);o.style.position="absolute",o.style.top=`${r}px`}))):setTimeout(e.stickyDismissableRegwall)},registerPostMessageListener:()=>{const e=window.pmcPiano.newsletterForm;window.addEventListener("message",(t=>{var o,s;if(t.origin.includes("tinypass.com")&&"string"==typeof t.type)switch(t.data.type){case"piano_template_newsletter_close_button_clicked":null===(o=document.querySelector(e.targetElements.paywall))||void 0===o||o.classList.remove(e.targetElements.paywallFade),null===(s=document.querySelector(e.targetElements.overlay))||void 0===s||s.classList.add("lrv-a-hidden");break;case"piano_template_newsletter_email_input":e.emailInputFocused=t.data.focused,window.dispatchEvent(new Event("scroll",{bubbles:!0}));break;case"piano_template_newsletter_submit_button_clicked":i=t.data.brand,r=e.prepareExactTargetFormData(t),e.sendSignupDataToExactTarget(r);break;case"piano_regwall_register_button_clicked":i=t.data.brand,r=e.prepareExactTargetFormData(t),e.setDataForNewsletter=!0,a()&&console.log(n,"Data Stored for Registration",r)}}))},registrationSuccess:function(e){const t=e.user.email;t&&this.setDataForNewsletter&&(this.setDataForNewsletter=!1,a()&&console.log(n,"Registration success",e),r.set("EmailAddress",t),setTimeout(this.sendSignupDataToExactTarget(r),1e3))},initialize:()=>{const e=window.pmcPiano.newsletterForm;e.initialized?a()&&console.log(n,"Newsletter Form is already initialized"):(a()&&console.log(n,"Initializing Newsletter Form"),e.modal&&e.stickyDismissableRegwall(),e.registerPostMessageListener(),window.pmcPiano.callbacks.onRegistration(e.registrationSuccess.bind(e)),e.initialized=!0)}};var l=s;"undefined"!=typeof exports&&(e.exports=s)}},t={};function o(n){var a=t[n];if(void 0!==a)return a.exports;var r=t[n]={id:n,loaded:!1,exports:{}};return e[n](r,r.exports,o),r.loaded=!0,r.exports}o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var n=o(243);(window.pmcPiano=window.pmcPiano||{}).newsletterForm=n.default}();