PageSourceSearch

https://www.scientificamerican.com/static/entry/renew.Cmi2wPBe.js

js scientificamerican.com collected 2026-09-24 07:38:11 UTC 11,970 bytes, 1 lines download raw bytes

1import{r as j,j as e}from"../chunks/vendor-react-DdEP1kCQ.js";import{D as z}from"../chunks/DefaultLayout-B4mESSua.js";import{p as B}from"../chunks/sciam-CvuG93yt.js";import{k as J,x as L,v as P,d as E}from"../chunks/core-Bpuic6mr.js";import{C as Z}from"../chunks/data-BmhhWP9E.js";import{P as R}from"../chunks/Debug-fCuJEt2r.js";import{R as H,f as T,E as V}from"../chunks/Form-CThyhD9U.js";import{N as i}from"../chunks/Notice-DIOat8pd.js";import{P as W}from"../chunks/PageHeader-BrXXj7Ar.js";import"../chunks/Header-DuP3RNUx.js";import"../chunks/sciam-B_IQ-Vo8.js";import"../chunks/vendor-shared-ShLQKC4n.js";import"../chunks/index-BGyKetH5.js";import"../chunks/Input-xTKQaCJR.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="777a9494-498f-4dbf-a129-078b559c213f",n._sentryDebugIdIdentifier="sentry-dbid-777a9494-498f-4dbf-a129-078b559c213f")}catch{}})();const S=(n="/")=>{const[t,s]=j.useState("https://www.scientificamerican.com"),[a,u]=j.useState(n),[p,m]=j.useState({});return j.useEffect(()=>{const{search:w,pathname:g,origin:d}=window.location;s(d),u(g);const o=new URLSearchParams(w),l={};for(const[c,y]of o.entries())l[c]=y;m(l)},[]),{host:t,path:a,params:p}},X=()=>{const[n,t]=j.useState(!1);return j.useEffect(()=>{t(n||window.location.search.includes("debug=hopper"))},[]),n},N=(n,t,s)=>{const a=new URL(t,n);return Object.entries(s).forEach(([u,p])=>u&&p&&a.searchParams.set(u,typeof p=="string"?p:"1")),a.toString()},I=n=>Number.isInteger(n)?n.toString():"",k=n=>new Date(n*1e3).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),K="select-NjqFg",Q="subscriptionList-AwaZo",ee="subscriptionItem-JHSAj",ne="subscriptionCard-yFUHR",te="heading-XThW6",se="expiry-NZCq-",_={select:K,subscriptionList:Q,subscriptionItem:ee,subscriptionCard:ne,heading:te,expiry:se};function re({subscriptions:n=[],couponId:t=null}){return e.jsxs("div",{className:_.select,children:[e.jsx("h2",{children:"Select a subscription to renew."}),e.jsx("ul",{className:_.subscriptionList,children:n.map(s=>{const a=B.find(u=>u.default_price_id===s.price_id);return e.jsx("li",{className:_.subscriptionItem,children:e.jsx(ie,{subscription:s,plan:a,href:`/renew/?subscription=${s.id}${t?`&coupon=${t}`:""}`})},s.id)})})]})}function ie({href:n,subscription:t,plan:s}){let a="";return s.is_giftable?a+=" (Gift)":s.is_trial?a+=" (Trial)":s.is_cds?a+=" (Magazine-linked)":s.enabled_in_portal||(a+=" (Granted)"),e.jsxs("a",{href:n,className:_.subscriptionCard,children:[e.jsxs("span",{className:_.heading,children:[s?.external_name,a]}),e.jsxs("span",{className:_.expiry,children:["Expires ",k(t.current_term_end)]})]})}const ae="renew-Z-L0-",oe="renewContent-jd3UV",ce="notices-M9o-q",le="estimate-0MA5g",ue="exception-uT7a6",de="link-lzmAn",pe="skeleton-B5Mlr",he="pulse-YJAwm",me="cardDisplay-M1uFD",fe="expired-GetPO",xe="actions-DZ8-q",be="error-SdROo",je="submitButton-lpq8I",we="button-jrATA baseBtn-ZNLef smallBtn-ebGz- baseBtn-ZNLef grayBtn--6SBS",ge="debug-wszmd",ye="renewalConsent-xPJza",r={renew:ae,renewContent:oe,notices:ce,estimate:le,exception:ue,link:de,skeleton:pe,pulse:he,cardDisplay:me,expired:fe,actions:xe,error:be,submitButton:je,button:we,debug:ge,renewalConsent:ye};function _e({couponId:n="",subscriptionId:t="",autoRenew:s=!0}){return e.jsxs("div",{className:r.renew,children:[e.jsx(W,{title:"Renew Your Subscription"}),e.jsx("div",{className:r.renewContent,children:e.jsx(Ce,{couponId:n,defaultSubscriptionId:t,autoRenew:s})})]})}function Ce({couponId:n="",defaultSubscriptionId:t="",autoRenew:s=!0}){const{host:a,params:u}=S(),{login:p}=J(),{isLoggedIn:m,activeSubscriptions:w,subscription:g,subscriptions:d,plans:o}=L(),l=d.filter(c=>!c.renewed_to&&(c.status==="non_renewing"||c.status==="in_trial"&&c.remaining_billing_cycles===0||c.serv_id&&o.find(y=>y.default_price_id===c.price_id)?.is_cds));if(t||l.length===1)return e.jsx(Ne,{couponId:n,subscriptionId:t||l[0].id,autoRenew:s});if(l.length>1)return e.jsx(re,{subscriptions:l,couponId:n});if(m&&!d.length)return e.jsxs(i,{type:"info",className:r.exception,children:[e.jsx(i.Content,{children:e.jsx("p",{children:"You do not have any subscriptions associated with your account."})}),e.jsx("a",{href:"/getsciam/",className:r.link,children:"Check out our current offers"})]});if(g&&w.length<=1){const c=d[0],f=((!!c&&o.find(h=>h.default_price_id===c.price_id))?.external_name||"").replace(/ Subscription$/i,"");if(c.status==="cancelled")return e.jsxs(i,{type:"error",className:r.exception,children:[e.jsxs(i.Content,{children:["Your ",f," subscription has already ended. You may purchase a new subscription at any time."]}),e.jsx("p",{children:e.jsx("a",{href:"/getsciam/",className:r.link,children:"Check out our current offers"})})]});if(c.status==="active"||c.status==="in_trial"&&c.remaining_billing_cycles!==0||c.renewed_to)return e.jsxs(i,{type:"info",className:r.exception,children:[e.jsx(i.Content,{children:e.jsxs("p",{children:["Your ",f," subscription is already set to renew on"," ",k(c.current_term_end||c.trial_end),"."]})}),e.jsx("p",{children:e.jsx("a",{href:"/account/",className:r.link,children:"View your subscription details"})})]});if(c.status==="future"&&c.renewed_from){const h=d.find(x=>x.id===c.renewed_from);return e.jsx(i,{type:"info",className:r.exception,children:e.jsxs(i.Content,{children:["Your ",f," subscription will renew on"," ",k(h.current_term_end),"."]})})}return e.jsxs(i,{type:"warn",className:r.exception,children:[e.jsx(i.Content,{children:e.jsxs("p",{children:["Your ",f," subscription is not eligible for renewal."]})}),e.jsxs("p",{children:[e.jsx("a",{href:"/account/",children:"Go to your account"})," to learn more."]})]})}return m?e.jsxs(i,{type:"warn",className:r.exception,children:[e.jsx(i.Content,{children:e.jsx("p",{children:"You do not have any subscriptions eligible for renewal."})}),e.jsxs("p",{children:[e.jsx("a",{href:"/account/",children:"Go to your account"})," to learn more."]})]}):e.jsx(i,{type:"info",className:r.exception,children:e.jsxs(i.Content,{children:[e.jsxs("p",{style:{marginBottom:"1em"},children:["If you were brought to this page from a magazine flyer,"," ",e.jsx("a",{className:r.link,href:Z,"data-click-position":"renew-page-not-logged-in-user-to-cds-renew",children:"click here to manage your subscription"}),"."]}),e.jsx("br",{}),e.jsxs("p",{children:["Otherwise,"," ",e.jsx("a",{href:`/login/?returnTo=${encodeURIComponent(N(a,"/renew/",u).replace(a,""))}`,onClick:c=>{c.preventDefault(),p()},className:r.link,children:"log in"})," ","to renew your subscription."]})]})})}function Ne({couponId:n="",subscriptionId:t="",autoRenew:s=!0}){const{isLoggedIn:a,plans:u}=L(),p=X(),[m,w]=j.useState(s===!1),g=ke(s),d={method:"POST",authMode:"require",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription_id:t,coupon_id:n||void 0,auto_renew:s})},o=P("/auth/chargebee/checkout/estimate-renewal/",{...d,immediate:!!a&&!!t}),l=P("/auth/chargebee/checkout/renewal/",d);if(!a)return e.jsx(i,{type:"warn",children:e.jsx(i.Content,{children:e.jsx("p",{children:"You must be logged in to renew your subscription. Please log in to continue."})})});if(l.data?.object==="subscription")return e.jsx(i,{className:r.renew,type:"success",children:e.jsxs(i.Content,{children:[e.jsx("h2",{children:"Renewal Successful"}),e.jsx("p",{children:"Your subscription has been successfully renewed."}),e.jsxs("p",{children:["You can view your updated subscription details ",e.jsx("a",{href:"/account/",children:"here"}),"."]})]})});const y=t&&u.length?u.find(b=>b.sub_id===t):void 0,f=o.data?.plan_id||void 0,h=f?B.find(b=>b.id===f):null,x=o.data&&"estimate"in o.data,U=o.data&&"error"in o.data,Y=!!o.error,F=x&&n&&o.data?.coupon_id!==n,v=x&&o.data?.card,O=v&&v.status!=="valid",C=o.data?.redirect==="checkout",M=l.data?!l.data?.id:!!l.error;async function $(){const b=await l.refetch();if(!b?.id||!b.status)return;const D=o.data?.estimate?.next_invoice_estimate||{},q=new URLSearchParams(window.location.search).get("returnTo"),G=N(window.location.origin,"/renewed/",{plan:h?.id||"",price_id:h?.default_price_id||"",sub_total:I(D?.sub_total),total:I(D?.total),product:h?.legacy_resource_id,returnTo:q||void 0});window.location.href=G}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:E(r.estimate,T.form),children:[e.jsxs("div",{className:r.notices,children:[O&&e.jsx(i,{type:"warn",children:e.jsx(i.Content,{children:"Your current payment method will expire before your subscription renewal date. You will need to update your payment information during checkout."})}),F&&e.jsx(i,{type:"warn",children:e.jsx(i.Content,{children:"The coupon provided either does not exist or is not applicable to this renew
1al."})})]}),C&&e.jsx("p",{className:r.summary,children:"The invoice below is an estimate subject to additional taxes based on the billing details you provide."}),e.jsx(Se,{defaultPlan:h||y,data:o.data,loading:o.loading,error:o.error}),e.jsx(De,{data:o.data?.card}),M&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(A,{data:l.data,error:l.error})]}),x&&s&&!C&&e.jsx("div",{className:E(T.renewalConsent,r.renewalConsent),children:e.jsx(H,{plan:h,flow:"renewal",fallbackPlanUrl:g,inputProps:{onChange:()=>w(!m)}})})]}),e.jsxs("div",{className:r.actions,children:[Y&&e.jsx("button",{className:r.submitButton,onClick:()=>{o.refetch()},children:"Try again"}),U&&e.jsx("a",{className:r.submitButton,href:"/account/",children:"Go to your account"}),x&&!C&&e.jsx("button",{className:r.submitButton,disabled:o.loading||l.loading||!m,onClick:b=>{$()},children:"Renew Subscription"}),x&&e.jsx(ve,{renewedFromId:t,primary:C,planId:o.data?.plan_id,couponId:o.data?.coupon_id})]}),p&&e.jsxs("details",{className:r.debug,children:[e.jsx("summary",{children:"Debug info"}),e.jsx("span",{children:"Input"}),e.jsx(R,{children:JSON.parse(d.body)}),o.data&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Estimate"}),e.jsx(R,{children:o.data})]})]})]})}const ke=n=>{const{host:t,params:s}=S();if(!n)return"";const{coupon:a,...u}=s;return N(t,"/renew/",{...u,auto_renew:"0"})};function Se({data:n,loading:t,error:s,defaultPlan:a}){return t&&!n?.estimate?e.jsx("div",{className:r.skeleton,children:"Loading estimate..."}):n?.error||s?e.jsx(A,{data:n,error:s}):e.jsx(V,{data:n?.estimate,flow:"renewal",defaultPlan:a,loading:t,knownTaxIssues:n?.redirect==="checkout"?["Tax will be calculated during checkout"]:void 0})}function A({data:n,error:t}){return t?e.jsx(i,{type:"error",children:e.jsx(i.Content,{className:r.error,children:t.message||"Error: "+t.toString()})}):n?.error?e.jsx(i,{type:"error",children:e.jsx(i.Content,{className:r.error,children:n.message||"Error: "+n.error})}):null}function ve({primary:n=!1,planId:t="",couponId:s="",renewedFromId:a=""}){const{host:u,params:p}=S(),{subscription:m,coupon:w,auto_renew:g,...d}=p;return e.jsx("a",{className:n?r.submitButton:r.link,href:N(u,"/checkout/",{plan:t,coupon:s,renew:a,...d}),children:n?"Proceed to Checkout":"Update payment details"})}function De({data:n}){return n?.last4?e.jsx("div",{className:`${r.cardDisplay} ${r[n.status||"unknown"]}`,children:e.jsxs("p",{children:[{visa:"Visa",mastercard:"MasterCard",american_express:"American Express",discover:"Discover",jcb:"JCB",diners_club:"Diners Club",bancontact:"Bancontact",cmr_falabella:"CMR Falabella",tarjeta_naranja:"Tarjeta Naranja",nativa:"Nativa",cencosud:"Cencosud",cabal:"Cabal",argencard:"Argencard",elo:"Elo",hipercard:"Hipercard",carnet:"Carnet",rupay:"RuPay",maestro:"Maestro",dankort:"Dankort",cartes_bancaires:"Cartes Bancaires"}[n.card_type]||"Card"," ","ending in ",n.last4," (",n.expiry_month,"/",n.expiry_year,")"]})}):null}function qe({coupon:n,subscription:t,auto_renew:s,navbar_offer:a}){return e.jsx(z,{showCta:a,children:e.jsx(_e,{couponId:n,subscriptionId:t,autoRenew:s})})}export{qe 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.