1import{A as e,I as t,O as n,j as r}from"./chunk-KS7C4IRE-DIkipulk.js";import{t as i}from"./jsx-runtime-CsaOnxTR.js";import{l as a}from"./components-JSzoenoU.js";import{$i as o,$r as s,Aa as c,Ba as l,Gi as u,Ha as d,La as f,M as p,Na as m,Pa as h,Pr as g,Qr as _,Sn as v,Va as y,Vi as b,ea as x,ei as S,f as C,fa as w,m as T,ni as E,ta as D,zi as O,zn as k}from"./Elements-BJgAzht_.js";import{t as A}from"./withFeatureGate-C6wb3ko-.js";import{t as j}from"./PageLayout-VSFjvclv.js";import{t as M}from"./StatusHandler-BAQGTOm7.js";var N=t(r(),1),P=i(),F=e(function(){let{userInfo:e,isAuthenticated:t}=c(e=>e),r=n(),[i,F]=(0,N.useState)(null),[I,L]=(0,N.useState)(0),[R,z]=(0,N.useState)([]),[B,V]=(0,N.useState)(!0),H=A(m.MANAGE_NEWSLETTER_PAGE,async()=>{try{let t=await g(`consent/fetch`,`POST`,{email:e?.email_id??``},!1);if(t.success){let e=T(t.data.consents);z(e),L(e.length)}else L(0),F({type:s.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to load the page. Please refresh the page.`})}catch{L(0),F({type:s.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to load the page. Please refresh the page.`})}}),U=A(m.MANAGE_NEWSLETTER_PAGE,async t=>{h({eventCategory:f.NEWSLETTER_SIGN_UP,eventAction:`click -`,eventLabel:t.name}),await g(`consent/sync`,`POST`,{email:e?.email_id??``,consents:[{name:t.consent_name,status:`withdrawn`}]},!1).then(e=>{e.success?(L(I-1),z(R.filter(e=>e.id!==t.id)),h({eventCategory:f.NEWSLETTER_SIGN_UP,eventAction:`visible`,eventLabel:`you're unsubscribed`}),F({type:s.SUCCESS,message:`You've unsubscribed`,description:`Explore more newsletters on our newsletter page.`})):F({type:s.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to unsubscribe you. Please try again later.`})})});return(0,N.useEffect)(()=>{let e;return t?(V(!1),H()):(V(!0),e=setTimeout(()=>{console.info(`Session::No user session found. Redirecting...`),r(`/newsletter-signup`)},1e4)),()=>{e&&clearTimeout(e)}},[t,e?.email_id,r]),(0,P.jsx)(k,{enabled:m.MANAGE_NEWSLETTER_PAGE,fallback:(0,P.jsx)(M,{}),children:(0,P.jsxs)(j,{lb1Ad:void 0,gaData:{title:`Manage newsletters`},children:[(0,P.jsx)(`div`,{className:l(`container sticky top-72 mt-10 right-00 h-00 z-1000`,i===null?`hidden`:`block`),id:`newsletter-toast`,children:i!==null&&(0,P.jsx)(_,{type:i.type,message:i.message,descriptionMessage:i.description,duration:5e3,className:`absolute right-00 w-full tablet:w-fit tablet:mt-10`,handler:()=>{F(null)}})}),(0,P.jsx)(v,{title:`Newsletters`,url:`/newsletter-signup`,navigationItems:[{title:`Manage newsletters`,url:`/newsletter-manage`}]}),(0,P.jsx)(`div`,{className:`container`,children:B?(0,P.jsx)(`div`,{className:`flex justify-center items-center h-300 tablet:h-500`,children:(0,P.jsx)(E,{iconName:y.LOADER,className:`!icon-placeholder`,iconWidth:d.REGULAR})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`dynamic-padding-y `,children:[(0,P.jsx)(u,{category:o.TITLE,size:x.SM,style:D.REGULAR,testId:`newsletter-manage-intro-text-test-id`,className:`text-secondary inline-block`,children:`You are logged in as`}),` `,(0,P.jsx)(u,{category:o.TITLE,size:x.SM,style:D.SEMIBOLD,testId:`newsletter-manage-intro-text-email-test-id`,className:`inline-block text-secondary break-all `,children:w(e?.email_id??``)})]}),I>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(u,{category:o.TITLE,size:x.SM,style:D.BOLD,className:`text-secondary py-08 tablet:py-12 desktop:py-16`,children:[`You are subscribed to `,I,` `,I>1?`newsletters`:`newsletter`]}),(0,P.jsx)(`div`,{className:l(`newsletter-manage-list-container`),children:(0,P.jsx)(`div`,{className:`newsletter-grid`,children:p().map(e=>R.map(t=>{if(t.id===e.id)return(0,P.jsx)(C,{newsletter:e,button:(0,P.jsx)(`button`,{onClick:()=>{U(e)},children:(0,P.jsx)(E,{iconName:y.ACTION_REMOVE_OUTLINED,iconWidth:d.XL,className:`status-error-icon`})}),className:`newsletter-card`},e.id)}))})})]}):(0,P.jsxs)(`div`,{className:`h-300 tablet:h-500 w-full flex self-stretch flex-col gap-24 desktop:gap-32 items-center justify-center`,children:[(0,P.jsx)(u,{category:o.TITLE,size:x.SM,style:D.REGULAR,className:`text-secondary`,children:`You have no subscribed newsletters.`}),(0,P.jsx)(S,{fill:O.PRIMARY,type:b.TEXT_ONLY,handler:()=>{a&&r(`/newsletter-signup?ref=manage-newsletter`)},className:`w-fit`,text:`Explore newsletters`,textClassName:`font-secondary-label-lg-semibold`})]})]})})]})})});export{F 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.