PageSourceSearch

https://www.scientificamerican.com/static/entry/newsletters.4y8_IUdl.js

js scientificamerican.com collected 2026-09-24 07:37:16 UTC 14,764 bytes, 1 lines download raw bytes

1import{r as u,j as e}from"../chunks/vendor-react-DdEP1kCQ.js";import{g as J,u as H}from"../chunks/data-BmhhWP9E.js";import{k as S,d as g,O as Q,F as V,p as N}from"../chunks/core-Bpuic6mr.js";import{u as K}from"../chunks/use-piano-auth-sync-token-DqoBG9VW.js";import"../chunks/Input-xTKQaCJR.js";import{b as $}from"../chunks/static.module-CAsgwhYU.js";import{L as ee}from"../chunks/Header-tkY3LBrW.js";import{D as te}from"../chunks/DefaultLayout-B4mESSua.js";import"../chunks/vendor-shared-ShLQKC4n.js";import"../chunks/sciam-CvuG93yt.js";import"../chunks/Header-DuP3RNUx.js";import"../chunks/sciam-B_IQ-Vo8.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new s.Error().stack;n&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[n]="f63242bd-07c8-4b46-9a0c-58a6dfd882a1",s._sentryDebugIdIdentifier="sentry-dbid-f63242bd-07c8-4b46-9a0c-58a6dfd882a1")}catch{}})();const se="container-AmiqW",ne="loggedOutOverlay-zhUNL",re="newsletterMainCard-VE8iu",ae="newsletterCard-73NJX",ie="label-Iz-Fc",oe="optOutLabel-XZxPR",ce="optedOutLabel-eUvZV",le="optOutSuccessLabel--wMQ2",de="resubscribeLink-U-BeS",ue="cardImage-c-AYz",me="cardContent-c1YBk",pe="cardGrid-ZtZ7C",ge="optOutCardGrid-w5A8s",fe="sectionHeader-Nfemz",he="toggle-Ye7ML",_e="toggle__primary-3t6Fl",be="toggle__slider-e-K62",ye="form__footer-txXOy",xe="sticky-RPhsH",ve="footer__section-Gc2ka",je="button-lapHt",we="button__primary-vB03H",Ce="button__text-HP2AX",Ne="status_message-GH71g",Se="status_message__error-fN9QW",Oe="modalOverlay-8H0XC",ke="modalContent-xWIZi",Ie="modalOptInContent-s9cdQ",Le="modalConfirmation-9ZyE5",Te="confirmButton-DChFp",Pe="cancelButton-J5ptv",t={container:se,loggedOutOverlay:ne,newsletterMainCard:re,newsletterCard:ae,label:ie,optOutLabel:oe,optedOutLabel:ce,optOutSuccessLabel:le,resubscribeLink:de,cardImage:ue,cardContent:me,cardGrid:pe,optOutCardGrid:ge,sectionHeader:fe,toggle:he,toggle__primary:_e,toggle__slider:be,form__footer:ye,sticky:xe,footer__section:ve,button:je,button__primary:we,button__text:Ce,status_message:Ne,status_message__error:Se,modalOverlay:Oe,modalContent:ke,modalOptInContent:Ie,modalConfirmation:Le,confirmButton:Te,cancelButton:Pe},Ee="/static/assets/TIS-BBlRsOIx.png",Ae="/static/assets/WIS-BObY12HI.png",Me="/static/assets/MIND-Cm2VZdrd.png",De="/static/assets/HEALTH-CGoGwzLg.png",Be="/static/assets/EARTH-CcC84FN1.png",He="/static/assets/TECH-Lyq3uVtN.png",Fe="/static/assets/SPACE-2oJbOEk8.png",ze="/static/assets/MATH-CT_5NPZA.jpg",Ge="/static/assets/universePhil-Bqd5biBS.jpg",Re="https://"+Object.create(globalThis.import_meta_env||null).PUBLIC_CDN_STATIC_DOMAIN+"/sciam/assets/CULTURED.jpg",y={marketing:[{name:"Scientific American products and services",slug:"internal_marketing_opt_in",description:"Receive special offers and promotions for Scientific American."},{name:"Third party partners",slug:"external_marketing_opt_in",description:"Receive limited promotions of products and services from our partners."}],today_in_science:{name:"Today In Science",slug:"today_in_science",description:"Experience the wonder of scientific discovery, from the tiniest details to the biggest questions, with our free daily newsletter, hosted by Andrea Gawrylewski, chief newsletter editor.",image:Ee},weekly_updates:[{name:"Proof Positive",slug:"proof_positive",description:"The math behind everyday life—and the joy of figuring things out. Plus, new math puzzles to challenge your brain. Delivered weekly.",image:ze},{name:"The Universe",slug:"column_the_universe",description:"Every Friday, astronomer Phil Plait brings the universe over your head down to Earth.",image:Ge},{name:"Cultured",slug:"cultured",description:"Does art imitate science—or the other way around? Emma Gometz explores the science of pop culture every Thursday in Cultured.",image:Re},{name:"The Week in Science",slug:"the_week_in_science",description:"The week's most important science news, selected by our editors every Friday.",image:Ae},{name:"Space & Physics",slug:"space_and_physics",description:"Wonders of the cosmos, physics, and quantum science, brought to you by our space editors on Thursday.",image:Fe},{name:"Mind & Brain",slug:"mind_and_brain",description:"Latest findings on the amazing human mind, cognition and science. Curated by our mind editor and delivered to you every Wednesday.",image:Me},{name:"Health & Medicine",slug:"health_and_biology",description:"Essential discoveries in health and medicine to optimize your well-being, brought to you by our health editors every Monday.",image:De},{name:"Earth & Environment",slug:"earth_and_environment",description:"A warming world, incredible animals, and all news on the environment, curated by our editors and delivered on Wednesdays.",image:Be},{name:"Technology",slug:"technology",description:"The cutting-edge world of AI, brain-computer interfaces, robotics and misinformation, curated for you by our tech editor every Tuesday.",image:He}],alerts:[{name:"Scientific American Magazine",slug:"scientific_american_magazine_issue_alert",description:"Our flagship monthly issue.",image:"/magazine-cover-redirect/"},{name:"Scientific American Special Editions",slug:"scientific_american_special_editions_issue_alert",description:"Editor-curated deep-dives into the most important science topics of our day.",image:"/magazine-cover-redirect/?slug=sa-special-editions"}]};function T({headerText:s}
1){return e.jsx("h2",{className:t.sectionHeader,children:s})}function We({title:s,description:n,image:r,onToggle:i,slug:c,selectedPreferences:o,defaultValues:l,isDisabled:a}){const{isLoggedIn:p}=S();return e.jsxs("div",{className:t.newsletterMainCard,children:[e.jsxs("div",{className:t.cardContent,children:[e.jsx("h2",{children:s}),e.jsx("p",{children:n}),e.jsx(z,{onToggle:i,slug:c,selectedPreferences:o,defaultValues:l,isDisabled:a})]}),e.jsx("div",{className:t.cardImage,children:e.jsx("img",{src:r,role:"presentation",alt:"",loading:"lazy",width:499,height:249})})]})}function P({title:s,description:n,image:r,onToggle:i,slug:c,defaultValues:o,selectedPreferences:l,isDisabled:a}){const{isLoggedIn:p}=S();return e.jsxs("div",{className:t.newsletterCard,children:[r&&e.jsx("div",{className:t.cardImage,children:e.jsx("img",{src:r,role:"presentation",alt:"",loading:"lazy",width:80,height:80})}),e.jsxs("div",{className:t.cardContent,children:[e.jsx("h2",{children:s}),e.jsx("p",{children:n})]}),e.jsx(z,{onToggle:i,slug:c,selectedPreferences:l,defaultValues:o,isDisabled:a})]})}const z=({slug:s,selectedPreferences:n,defaultValues:r,onToggle:i,isDisabled:c,...o})=>{let l=!1;return n[s]!==void 0?l=n[s]:l=r[s]??r?.lists?.[s]??!1,e.jsxs("label",{className:g(t.toggle,t.toggle__primary),children:[e.jsx("input",{type:"checkbox",...o,name:s,checked:l,onChange:a=>{i(s,a.target.checked)},disabled:c}),e.jsx("div",{className:t.toggle__slider})]})},Ue=({errors:s=!1,loading:n=!1,children:r,selectedPreferences:i})=>{const{isLoggedIn:c}=S();return e.jsx("div",{className:g(t.form__footer,c&&!s.length&&t.sticky||""),children:e.jsx("div",{className:g(t.actions,t.footer__section),children:r})})};function Ye({onToggle:s,defaultValues:n,selectedPreferences:r,hasUnsavedChanges:i,submissionStatus:c,optOutSuccessful:o,changeGlobalSuppression:l,isOptedOut:a,errors:p}){const{user:m,login:O,register:E}=S();u.useRef(),u.useId();const[k,I]=u.useState(!1),[A,x]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:g(t.container,$.staticPageBodyCopy),children:[!m&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[e.jsx("a",{href:"/account/",onClick:f=>{f.preventDefault(),O()},children:"Sign in"})," ","or"," ",e.jsx("a",{href:"/account/",onClick:f=>{f.preventDefault(),E()},children:"Register"})," ","to manage your newsletter and email alert preferences"]})}),m&&e.jsx("p",{children:"Manage your newsletter and email alert preferences."}),!a&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:m?"":t.loggedOutOverlay,children:[e.jsx("section",{className:t.sectionMainCard,children:e.jsx(We,{title:y.today_in_science.name,description:y.today_in_science.description,image:y.today_in_science.image,onToggle:s,slug:y.today_in_science.slug,defaultValues:n,selectedPreferences:r,isDisabled:!m})},y.today_in_science.name),e.jsx(T,{headerText:"Newsletters and Columns"}),e.jsx("section",{className:t.sectionWeeklyUpdates,children:e.jsx("div",{className:t.cardGrid,children:y.weekly_updates.map(({name:f,slug:h,description:v,image:_})=>e.jsx(P,{title:f,description:v,image:_,onToggle:s,slug:h,defaultValues:n,selectedPreferences:r,isDisabled:!m},h))})}),e.jsx(T,{headerText:"New Issue Alerts"}),e.jsx("section",{className:t.sectionNewIssueAlerts,children:e.jsx("div",{className:t.cardGrid,children:y.alerts.map(({name:f,slug:h,description:v,image:_})=>e.jsx(P,{title:f,description:v,image:_,onToggle:s,slug:h,defaultValues:n,selectedPreferences:r,isDisabled:!m},h))})}),e.jsx(T,{headerText:"Marketing"}),e.jsx("section",{className:t.sectionNewIssueAlerts,children:e.jsx("div",{className:t.cardGrid,children:y.marketing.map(({name:f,slug:h,description:v,image:_})=>e.jsx(P,{title:f,description:v,image:_,onToggle:s,slug:h,defaultValues:n,selectedPreferences:r,isDisabled:!m},h))})})]})}),m&&e.jsx(e.Fragment,{children:e.jsx(Ze,{isOptedOut:a,setShowOptOutModal:I,setShowOptInModal:x,changeGlobalSuppression:l,optOutSuccessful:o})}),m&&e.jsxs(Ue,{selectedPreferences:r,hasUnsavedChanges:i,children:[e.jsx("button",{type:"reset",className:g(t.button,t.button__text),children:"Reset"}),e.jsxs("div",{className:g(t.status_message),children:[p&&e.jsx("div",{className:g(t.status_message__error),children:e.jsx("p",{children:"There was an error saving your preferences."})}),c==="success"&&e.jsx("div",{className:g(t.status_message__success),children:e.jsx("p",{children:"Your preferences have been updated."})})]}),e.jsx("button",{type:"submit",className:g(t.button,t.button__primary,!i&&t.button__disabled||"",i&&t.button__success||""),disabled:!i,children:c==="loading"?"Saving":"Save"})]})]}),e.jsx(qe,{isOpen:k,isOptedOut:a,onClose:()=>I(!1),changeGlobalSuppression:l}),e.jsx(Xe,{isOpen:A,isOptedOut:a,onClose:()=>x(!1),changeGlobalSuppression:l})]})}function Ze({isOptedOut:s=!1,setShowOptOutModal:n,setShowOptInModal:r,changeGlobalSuppression:i,optOutSuccessful:c}){const o=s?e.jsxs(e.Fragment,{children:["You are currently unsubscribed from all emails. To resubscribe"," ",e.jsx("span",{className:t.resubscribeLink,children:"click here"})]}):"Unsubscribe from all emails";function l(a,p){return a&&p===!0?t.optOutSuccessLabel:a?t.optedOutLabel:t.optOutLabel}return e.jsx("div",{className:g(t.cardGrid,t.optOutCardGrid),children:e.jsx("div",{className:t.optOutCard,children:e.jsx("div",{className:t.cardContent,children:e.jsx("p",{className:g(t.label,l(s,c)),children:s&&c===!0?"You have been unsubscribed.":s?e.jsx("button",{type:"submit",onClick:a=>{a.preventDefault(),a.stopPropagation(),r(!0),i(!1)},children:o}):e.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),n(!0)},children:o})})})})})}function qe({isOpen:s,onClose:n,changeGlobalSuppression:r}){return s?e.jsx("div",{className:t.modalOverlay,onClick:n,children:e.jsxs("div",{className:g(t.modalContent,t.modalOptOutContent),onClick:i=>i.stopPropagation(),children:[e.jsx("h2",{className:t.modalConfirmation,children:"Are you sure you want to unsubscribe from all emails?"}),e.jsx("br",{}),e.jsx("button",{type:"submit",onClick:()=>{r(!0),n()},className:t.confirmButton,children:"Confirm"}),e.jsx("br",{}),e.jsx("button",{className:t.cancelButton,onClick:n,children:"Cancel"})]})}):null}function Xe({isOpen:s,onClose:n}){return s?e.jsx("div",{className:t.modalOverlay,onClick:n,children:e.jsxs("div",{className:g(t.modalContent,t.modalOptInContent),onClick:r=>r.stopPropagation(),children:[e.jsx("h2",{className:t.modalConfirmation,children:"Thank You!"}),e.jsx("br",{}),e.jsx("button",{className:t.cancelButton,onClick:n,children:"Close"})]})}):null}function Je(){const[s,n]=u.useState("");return u.useEffect(()=>{Q().then(r=>{n(r)})},[]),e.jsx("input",{type:"hidden",name:"csrftoken",value:s})}function F(s,n){let r={};for(let i in n)(s?.[i]??s?.lists?.[i]??!1)!==n[i]&&(r[i]=n[i]);return r}function Qe(s,n,r,i){let c=[],o=[],l=[];for(const[a,p]of Object.entries(s))p===!0&&c.push(a),p===!1&&o.push(a);for(const[a,p]of Object.entries(n.lists))p===!0&&l.push(a);c.length>0&&(N({event:"cleanup",user:{newsletters:null}}),N({event:"newsletter-signup",user:{newsletters:c.sort(),all_previous_newsletters:l.sort()}})),o.length>0&&(N({event:"cleanup",user:{newsletters:null}}),N({event:"newsletter-unsubscribe",user:{newsletters:o.sort(),all_previous_newsletters:l.sort()}})),r("newsletter_signup","newsletter-page",!1,{context_newsletters_added:c.sort(),context_newsletters_removed:o.sort(),context_email_suppressed:!1})}const Ve=(s,n,r={})=>{const i=Object.entries(r.lists).filter(([c,o])=>o===!0).map(([c,o])=>c).sort();s?(N({event:"newsletter-opt-out",user:{newsletters:"",all_previous_newsletters:i}}),n("email_suppressed","newsletter-page",!1,{context_email_suppressed:!0})):n("email_unsuppressed","newsletter-page",!1,{context_email_suppressed:!1})};function dt(){const{isLoading:s,isLoggedIn:n,login:r,user:i}=S(),{countEvent:c}=V(),[o,l]=u.useState({}),[a,p]=u.useState(void 0),[m,O]=u.useState({}),[E,k]=u.useState(void 0),[I,A]=u.useState(null),x=F(o,m),f=Object.keys(x).length>0,[h,v]=u.useState(!1),{env:_,token:L}=K(),[G,w]=u.useState(!1),[M,b]=u.useState(null),[R,D]=u.useState(!1);u.useEffect(()=>{i&&J(L,_).then(d=>{l(d),p(d.global_suppression),k(!1)})},[n]);const W=(d,j)=>
1{m[d]=j,O(m),v(!h),b(null)};function U(){const d=F(o,m);let j={lists:{...o.lists,...d},global_suppression:d.global_suppression??o.global_suppression};l(j),O({})}function Y(){if(M)return;let d={lists:{...x}};return H(d,L,_)}async function Z(d=!1){b("loading");const j=H({lists:{},global_suppression:d},L,_),C=a!==d;try{(await j).ok&&(b("success"),w(!1),p(d),k(C),C&&Ve(d,c,o),d===!0&&D(!0),d===!1&&D(!1))}catch(B){console.error("Failed to update global suppression.",B),b("error"),w(!0)}}const q=async d=>{d.preventDefault(),d.stopPropagation();const j=Y();b("loading");try{(await j).ok?(b("success"),w(!1),U(),Qe(x,o,c)):(b("error"),w(!0))}catch(C){console.error(C),b("error"),w(!0)}},X=n?"/platform/api/v2/emailpreferences/":"/platform/api/v2/emailpreference/subscribe/";return e.jsxs("form",{method:"POST",action:X,onSubmit:q,children:[e.jsx(Je,{}),e.jsxs(te,{children:[e.jsx(ee,{title:"Newsletters",description:""}),e.jsx(Ye,{onToggle:W,isOptedOut:a,changeGlobalSuppression:Z,defaultValues:o,selectedPreferences:m,hasUnsavedChanges:f,changedPreferences:x,submissionStatus:M,optOutSuccessful:R,errors:G})]})]})}export{dt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.