import{r as a,j as e,L as H,g as te,i as se,u as k,k as ae,l as ne,b as W,E as re,c as Y,N as z,B as A,v as K,d as le,e as ie,f as F}from"./index-pfF6EHbh.js";import{c as h,u as oe,v as O,g as ce,a as de,e as q,b as me}from"./clsx-v90M5fTH.js";var I;(function(t){t.DEV9278="dev9278"})(I||(I={}));const B=()=>({trackEvent:a.useCallback(async(s,n)=>{},[])}),ue=t=>a.createElement("svg",{width:9,height:12,viewBox:"0 0 9 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{d:"M7.68175 12L0.887695 6L7.68175 0L8.8877 1.065L3.29959 6L8.8877 10.935L7.68175 12Z",fill:"currentColor"})),G=({className:t,...s})=>e.jsxs(H,{className:h("text-primary inline-flex gap-sm items-center font-semibold",t),...s,children:[e.jsx(ue,{}),"Back"]}),pe=t=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{fill:"currentColor",d:"M10.72,19.9a8,8,0,0,1-6.5-9.79A7.77,7.77,0,0,1,10.4,4.16a8,8,0,0,1,9.49,6.52A1.54,1.54,0,0,0,21.38,12h.13a1.37,1.37,0,0,0,1.38-1.54,11,11,0,1,0-12.7,12.39A1.54,1.54,0,0,0,12,21.34h0A1.47,1.47,0,0,0,10.72,19.9Z"},a.createElement("animateTransform",{attributeName:"transform",type:"rotate",dur:"0.75s",values:"0 12 12;360 12 12",repeatCount:"indefinite"}))),R=({variant:t,loading:s,children:n,className:l,...r})=>e.jsxs("button",{className:h("inline-flex justify-center items-center cursor-pointer border rounded-md text-button font-semibold py-md px-[3.5rem] shadow-2dp transition-all leading-10",t==="primary"&&"text-white bg-primary border-primary-active hover:bg-primary-active",t==="primary"&&s&&"bg-primary-disabled",t==="success"&&"text-white bg-success border-success-active",l),...r,children:[s?e.jsx("span",{className:"absolute flex justify-center",children:e.jsx(pe,{className:"mr-sm w-lg h-lg text-white"})}):null,e.jsx("span",{className:h("flex items-center space-x-sm",{"opacity-0":s}),children:n})]}),xe=t=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{d:"M2.725 21C2.54167 21 2.375 20.9542 2.225 20.8625C2.075 20.7708 1.95834 20.65 1.875 20.5C1.79167 20.35 1.74584 20.1875 1.7375 20.0125C1.72917 19.8375 1.775 19.6667 1.875 19.5L11.125 3.5C11.225 3.33333 11.3542 3.20833 11.5125 3.125C11.6708 3.04167 11.8333 3 12 3C12.1667 3 12.3292 3.04167 12.4875 3.125C12.6458 3.20833 12.775 3.33333 12.875 3.5L22.125 19.5C22.225 19.6667 22.2708 19.8375 22.2625 20.0125C22.2542 20.1875 22.2083 20.35 22.125 20.5C22.0417 20.65 21.925 20.7708 21.775 20.8625C21.625 20.9542 21.4583 21 21.275 21H2.725ZM12 18C12.2833 18 12.5208 17.9042 12.7125 17.7125C12.9042 17.5208 13 17.2833 13 17C13 16.7167 12.9042 16.4792 12.7125 16.2875C12.5208 16.0958 12.2833 16 12 16C11.7167 16 11.4792 16.0958 11.2875 16.2875C11.0958 16.4792 11 16.7167 11 17C11 17.2833 11.0958 17.5208 11.2875 17.7125C11.4792 17.9042 11.7167 18 12 18ZM12 15C12.2833 15 12.5208 14.9042 12.7125 14.7125C12.9042 14.5208 13 14.2833 13 14V11C13 10.7167 12.9042 10.4792 12.7125 10.2875C12.5208 10.0958 12.2833 10 12 10C11.7167 10 11.4792 10.0958 11.2875 10.2875C11.0958 10.4792 11 10.7167 11 11V14C11 14.2833 11.0958 14.5208 11.2875 14.7125C11.4792 14.9042 11.7167 15 12 15Z",fill:"currentColor"})),V=({formErrors:t,className:s,...n})=>{if(t!=null&&t.length)return e.jsx("ul",{...n,className:h("text-chart-red",s),children:t.map((l,r)=>e.jsxs("li",{className:"flex gap-sm",children:[e.jsx(xe,{}),e.jsx("p",{children:l})]},r))})};var fe=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var s=document.activeElement,n=[],l=0;l"u"){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var u=U[s.format]||U.default;window.clipboardData.setData(u,t)}else d.clipboardData.clearData(),d.clipboardData.setData(s.format,t);s.onCopy&&(d.preventDefault(),s.onCopy(d.clipboardData))}),document.body.appendChild(c),i.selectNodeContents(c),o.addRange(i);var m=document.execCommand("copy");if(!m)throw new Error("copy command was unsuccessful");p=!0}catch(d){n&&console.error("unable to copy using execCommand: ",d),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(s.format||"text",t),s.onCopy&&s.onCopy(window.clipboardData),p=!0}catch(u){n&&console.error("unable to copy using clipboardData: ",u),n&&console.error("falling back to prompt"),l=ge("message"in s?s.message:ve),window.prompt(l,t)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(i):o.removeAllRanges()),c&&document.body.removeChild(c),r()}return p}var be=ye;const P=te(be),X=t=>a.createElement("svg",{width:15,height:17,viewBox:"0 0 15 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{d:"M12.75 13.5H4.5C4.0875 13.5 3.73438 13.3531 3.44063 13.0594C3.14688 12.7656 3 12.4125 3 12V1.5C3 1.0875 3.14688 0.734375 3.44063 0.440625C3.73438 0.146875 4.0875 0 4.5 0H9.75L14.25 4.5V12C14.25 12.4125 14.1031 12.7656 13.8094 13.0594C13.5156 13.3531 13.1625 13.5 12.75 13.5ZM9 5.25V1.5H4.5V12H12.75V5.25H9ZM1.5 16.5C1.0875 16.5 0.734375 16.3531 0.440625 16.0594C0.146875 15.7656 0 15.4125 0 15V4.5H1.5V15H9.75V16.5H1.5Z",fill:"currentColor",fillOpacity:.54})),J=t=>a.createElement("svg",{width:15,height:12,viewBox:"0 0 15 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{d:"M13.2375 0L5 8.39491L1.7625 5.10828L0 6.90446L5 12L15 1.80892L13.2375 0Z",fill:"currentColor"})),Z=3e3,Ce=({label:t,disabled:s,value:n,alias:l,maxRows:r=3,textAreaSelectedCallback:i,copyButtonClickedCallback:o,preventSelect:c=!1,...p})=>{const[m,d]=a.useState(!1),[u,j]=a.useState(1),x=a.useRef(null),f=a.useRef(null);a.useLayoutEffect(()=>{if(!f.current||!n)return;const{clientHeight:b,scrollHeight:E}=f.current;bN+1)},[u,n,r]);const w=()=>{d(!0),o&&o(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>d(!1),Z),P(n??"")},y=()=>{d(!0),i&&i(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>d(!1),Z),P(n??"")};a.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);function v(b){c&&b.preventDefault()}return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold block mb-sm",htmlFor:"forwardEmail",children:t}),e.jsxs("div",{className:h("grid grid-cols-1 gap-y-md","md:grid-cols-12 md:space-y-none md:space-x-md"),children:[e.jsx("textarea",{className:"col-span-12 resize-none break-all",ref:f,readOnly:!0,id:"forwardEmail",rows:u,cols:void 0,defaultValue:l??n,disabled:s,onSelect:i?()=>i(!0):void 0,onClick:y,onMouseDown:v,...p}),e.jsxs(R,{type:"button",variant:m?"success":"primary",onClick:w,className:"md:col-span-4 md:col-end-13 flex",children:[e.jsx("span",{className:"opacity-[54%]",children:m?e.jsx(J,{}):e.jsx(X,{})}),e.jsx("span",{children:m?"Copied":"Copy"})]})]})]})};var S=(t=>(t.Complaint="complaint",t.PrivacyPolicy="privacy-policy",t))(S||{});const D=()=>{const{setTitle:t,setFooterLinks:s,setHeader:n}=se();return{setTitle:a.useCallback(r=>{document.title=r,t(r)},[t]),setFooterLinks:s,setHeader:n}},we=()=>{const{pageData:t}=k();return t!=null&&t.privacy.url?e.jsx("a",{href:t.privacy.url,target:"_blank",rel:"noreferrer",children:"Privacy policy"}):t!=null&&t.privacy.content?e.jsx(H,{to:"privacy-policy",children:"Privacy policy"}):null},Q=({links:t})=>t?e.jsxs("nav",{className:"flex flex-col gap-sm text-xs space-y-md",children:[t.includes(S.Complaint)?e.jsx(H,{to:"complaint",children:"Still receiving emails after unsubscribing?"}):null,t.includes(S.PrivacyPolicy)?e.jsx(we,{}):null]}):e.jsx(e.Fragment,{}),je=({title:t,links:s,className:n,...l})=>{const{src:r}=oe(),i=t.length>50?"text-hero-verbose-custom md:text-hero-mobile":void 0;return e.jsxs("aside",{className:h("flex flex-col justify-between",n),...l,children:[e.jsxs("div",{children:[r?e.jsx("div",{className:"h-[90px] mb-sm md:mb-lg",children:e.jsx("img",{"data-testid":"custom-logo",src:r,alt:"",className:"max-w-full h-auto"})}):null,e.jsx("h1",{className:i,children:t})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Q,{links:s})})]})},Ee=t=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 21L12 2L23 21H1ZM19.53 19L12 5.99L4.47 19H19.53ZM11 16V18H13V16H11ZM11 10H13V14H11V10Z",fill:"currentColor"})),ke=({className:t})=>e.jsxs("div",{className:h("outline outline-1 outline-warning rounded-sm","bg-warning bg-opacity-subtle","flex gap-md p-lg w-fit","whitespace-pre-wrap",t),children:[e.jsx(Ee,{className:"text-warning flex-none",role:"img","aria-label":"Warning"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-bold",children:"Preview Only"})," — Previewing will not save your changes in the settings. Remember to save your changes."]})]}),Ne=()=>{const[t,s]=a.useState(""),[n,l]=a.useState(),[r,i]=a.useState(),{preview:o}=ae();return e.jsx("div",{className:h("flex h-full items-start justify-center bg-white","md:items-center md:bg-transparent md:overflow-y-auto"),children:e.jsxs("div",{className:"flex flex-col items-center md:m-auto",children:[o?e.jsx(ke,{className:"m-xl mb-none md:mx-md md:mb-lg"}):null,e.jsxs("div",{className:h("grid grid-cols-1 auto-rows-[min-content_1fr] max-w-container h-full m-auto","md:grid-cols-[40%_60%] md:auto-rows-auto md:min-h-[647px] md:h-auto md:p-md"),children:[e.jsxs("div",{className:h("flex flex-col p-[50px] pb-none","md:bg-gray-100 md:shadow-12dp md:rounded-l-lg md:p-[65px_60px]"),children:[r?e.jsx("div",{className:"md:hidden mb-lg",children:r}):void 0,e.jsx(je,{title:t,links:n,className:"flex-1"})]}),e.jsx(Se,{setTitle:s,header:r,setHeader:i,footerLinks:n,setFooterLinks:l})]})]})})},Se=({setTitle:t,header:s,setHeader:n,footerLinks:l,setFooterLinks:r})=>e.jsxs("main",{className:"bg-white p-[24px_50px_24px_50px] flex flex-col md:shadow-12dp md:rounded-r-lg md:p-[65px_60px]",children:[s?e.jsx("div",{className:"hidden md:block mb-lg",children:s}):void 0,e.jsx("div",{className:"flex-1",children:e.jsx(ne,{context:{setTitle:t,setFooterLinks:r,setHeader:n}})}),e.jsx("div",{className:"md:hidden mt-xl",children:e.jsx(Q,{links:l})})]}),Te=({disabled:t,onCompleted:s,...n})=>{const{campaignMailer:l}=k(),[r,i]=a.useState(""),[o,c]=a.useState(!1),[p,m]=a.useState(),{complaint:{checkEligibilityOptoutCollectionApi:d}}=W(),u=a.useCallback(async f=>{const w=window.location.hostname;if(l){c(!0);try{const y=await d(l.campaignId,{email:f,optoutDomain:w});y.eligible||m([y.reason.replace(/'/g,"")]),s(f,y)}catch(y){m(["Something went wrong"]),re({error:y})}finally{c(!1)}}},[l,s,d]),j=f=>{i(f.target.value)},x=async f=>{m(void 0),f.preventDefault();try{if(!O(r))throw new Error("Please enter a valid email address to unsubscribe.");await u(r)}catch(w){m([w.message])}};return e.jsxs("div",{...n,children:[e.jsx("h2",{className:"mb-lg",children:"Verify your email address"}),e.jsxs("form",{onSubmit:x,className:h("grid grid-cols-1 gap-y-md items-end","md:grid-cols-12 md:space-y-none"),noValidate:!0,children:[e.jsx("div",{className:"col-span-8 md:mr-md",children:e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{children:"Your email address"}),e.jsx("input",{type:"email",name:"email",value:r,disabled:t,onChange:j,className:h(p&&"error")})]})}),e.jsx("div",{className:"md:col-span-4",children:e.jsx(R,{variant:"primary","aria-label":o?"Continuing...":"Continue",type:"submit",loading:o,disabled:t||o,className:"w-full",children:"Continue"})}),e.jsx(V,{formErrors:p,className:"col-span-full"})]})]})},Le=({email:t,disabled:s,eligibility:n})=>{const{campaignMailer:l}=k(),r=t&&(l!=null&&l.legacyKey)&&(n!=null&&n.eligible)?ce(n.token,t,l==null?void 0:l.legacyKey):"",i=o=>{o.preventDefault()};return e.jsxs("div",{className:"space-y-lg",children:[e.jsx("h2",{children:"Forward the email"}),e.jsx("p",{className:"text-sm",children:"Please forward a copy of the email you received to the email address below to finalize your complaint."}),e.jsx("form",{onSubmit:i,children:e.jsx(Ce,{"data-testid":"complaint-collection__forward-email",label:"Forward the email to",name:"forwardEmail",value:r,disabled:s})})]})},Fe=()=>{const{setTitle:t,setHeader:s,setFooterLinks:n}=D(),[l,r]=a.useState("email"),[i,o]=a.useState(""),[c,p]=a.useState();a.useEffect(()=>{t("Lodge a complaint"),s(e.jsx(G,{to:"./"})),n([])},[n,s,t]);const m=(d,u)=>{o(d),p(u),u.eligible&&r("forward")};return e.jsxs("div",{className:"space-y-md",children:[e.jsx("p",{className:"text-sm",children:"If you have previously unsubscribed, you may lodge a complaint with our compliance team to investigate your case."}),e.jsx("p",{className:"text-sm",children:"Enter your email address below to begin."}),e.jsxs("ul",{className:"pt-xl steps",children:[e.jsx("li",{className:h("step",l==="email"?"step-primary":"step-completed"),children:e.jsx(Te,{disabled:l==="forward",onCompleted:m})}),e.jsx("li",{className:h("step",l==="forward"?"step-primary":"step-disabled"),children:e.jsx(Le,{email:i,eligibility:c,disabled:l==="email"})})]})]})},_=t=>a.createElement("svg",{width:15,height:12,viewBox:"0 0 15 12",xmlns:"http://www.w3.org/2000/svg",...t},a.createElement("path",{d:"M13.2375 0L5 8.39491L1.7625 5.10828L0 6.90446L5 12L15 1.80892L13.2375 0Z",fill:"currentColor"})),$=3e3,Ie=({label:t,disabled:s,value:n,alias:l,maxRows:r=3,textAreaSelectedCallback:i,copyButtonClickedCallback:o,preventSelect:c=!1,...p})=>{const[m,d]=a.useState(!1),[u,j]=a.useState(1),x=a.useRef(null),f=a.useRef(null);a.useLayoutEffect(()=>{if(!f.current||!n)return;const{clientHeight:b,scrollHeight:E}=f.current;bN+1)},[u,n,r]);const w=()=>{d(!0),o&&o(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>d(!1),$),P(n??"")},y=()=>{d(!0),i&&i(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>d(!1),$),P(n??"")};a.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);function v(b){c&&(i&&i(!0),b.preventDefault())}return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold block mb-sm",htmlFor:p.name,children:t}),e.jsxs("div",{className:h("grid grid-cols-1 gap-y-md","md:grid-cols-12 md:space-y-none md:space-x-md items-center"),children:[e.jsx("textarea",{className:"md:col-span-8 resize-none break-all",ref:f,readOnly:!0,id:p.name,rows:u,cols:void 0,defaultValue:l??n,disabled:s,onSelect:i?()=>i(!0):void 0,onClick:y,onMouseDown:v,...p}),e.jsxs(R,{type:"button",variant:m?"success":"primary",onClick:w,className:"md:col-span-4 md:col-end-13 flex",children:[e.jsx("span",{className:"opacity-[54%]",children:m?e.jsx(J,{}):e.jsx(X,{})}),e.jsx("span",{children:m?"Copied":"Copy"})]})]})]})},Re="/assets/forward-email-example-iEVl8DMo.png",Ae=({optoutKey:t})=>{const{campaignMailer:s,optoutPageTestId:n}=k(),[l,r]=a.useState(""),{legacy:{simpleTokenOptoutCollectionApi:i}}=W(),{trackEvent:o}=B(),[c,p]=a.useState(void 0),[m,d]=a.useState(void 0),[u,j]=a.useState(void 0),[x,f]=a.useState(void 0);if(a.useEffect(()=>{(async()=>{try{const b=await i(),E=de(b,t);r(E)}catch(b){reportError({error:b})}})()},[t,i]),a.useEffect(()=>{if(c||!m)return;const v=s==null?void 0:s.leafCampaignMailerId;v&&(p(!0),o("forward-email-textarea-selected-dev9287",{app:"modern",leafCampaignMailerId:v,userAgent:navigator.userAgent,testId:n??""}))},[o,m,c,s,n]),a.useEffect(()=>{if(u||!x)return;const v=s==null?void 0:s.leafCampaignMailerId;v&&(j(!0),o("forward-email-copy-button-clicked-dev9287",{app:"modern",leafCampaignMailerId:v,userAgent:navigator.userAgent,testId:n??""}))},[o,x,u,s,n]),!l)return null;const w=v=>{v.preventDefault()},y={display:"flex",justifyContent:"center",alignItems:"center",width:"32px",height:"32px",borderRadius:"50%",backgroundColor:"#2D4EC2",color:"white",fontSize:"16px",fontWeight:"bold"};return e.jsx("div",{"data-testid":"creative-collection-form",className:"space-y-xl",children:e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:"10px"},children:"Help us prevent unwanted emails in 2 easy steps:"}),e.jsx("br",{}),e.jsxs("div",{style:{display:"flex",marginBottom:"30px"},children:[e.jsx("div",{style:{minWidth:"32px",marginRight:"20px"},children:e.jsx("div",{style:y,children:"1"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[e.jsx("h2",{style:{marginBottom:5},children:"Copy our email address:"}),e.jsx("form",{onSubmit:w,children:e.jsx(Ie,{label:"",name:"forwardEmail",alias:"feedback@optout-feedback.com",value:l,textAreaSelectedCallback:d,copyButtonClickedCallback:f})})]})]}),e.jsxs("div",{style:{display:"flex"},children:[e.jsx("div",{style:{minWidth:"32px",marginRight:"20px"},children:e.jsx("div",{style:y,children:"2"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[e.jsx("h2",{style:{marginBottom:5},children:"Forward the email to us"}),e.jsx("p",{style:{marginBottom:"15px"},children:"Go back to your email, click forward, paste our email into the address field and hit send."}),e.jsx("div",{style:{width:"60%",minWidth:"250px"},children:e.jsx("img",{src:Re,alt:"step 2"})})]})]})]})})},Pe=()=>Ae,De=()=>{const{campaignMailer:t,pageData:s}=k(),{setTitle:n,setHeader:l,setFooterLinks:r}=D(),{state:i}=Y(),o="Request Compliance Review",c="You’re no longer subscribed";if(a.useEffect(()=>{n((s==null?void 0:s.confirmation.title)||o),l(void 0),r([S.Complaint,S.PrivacyPolicy])},[s,r,l,n]),!Me(i))return e.jsx(z,{to:"../"});const p=Pe(),{email:m,collectCreative:d}=i,u=s!=null&&s.confirmation.content?e.jsx("span",{children:s.confirmation.content}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"You have successfully unsubscribed using"}),e.jsx("span",{className:"font-bold",children:m})]});return e.jsxs("div",{"data-testid":"modern-app-confirmation",className:"h-full flex flex-col",children:[d?e.jsxs("h2",{className:"font-normal flex gap-md mt-md mb-xl md:mt-none text-success",children:[e.jsx(_,{className:"w-md h-md mt-[0.75rem]"}),e.jsx("span",{children:c})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("h2",{className:"flex flex-col items-center font-normal text-3xl",children:[e.jsx("div",{className:"bg-success rounded-full p-md text-white mb-md",children:e.jsx(_,{})}),u]})}),d&&t?e.jsx(p,{optoutKey:t.legacyKey}):null]})};function Me(t){return!!t&&typeof t=="object"&&"email"in t&&"collectCreative"in t}const He=()=>De,Oe=({onCompleted:t})=>{const{submitOptout:s,submitting:n,brandIntegrityStatus:l,optoutPageTestId:r,pageData:i,campaignMailer:o}=k(),{trackEvent:c}=B(),p=a.useCallback(g=>{if(l===A.Eligible)return g===void 0?`forward-email-checkbox-untouched${r?`-${r}`:""}`:g?`forward-email-checkbox-checked${r?`-${r}`:""}`:`forward-email-checkbox-unchecked${r?`-${r}`:""}`},[l,r]),[m,d]=a.useState(r===I.DEV9278?p(!0):void 0),[u,j]=a.useState(""),[x,f]=a.useState(),[w,y]=a.useState(r===I.DEV9278),[v,b]=a.useState(),E=a.useCallback(async g=>{K({email:g});const{collectFeedback:T,optoutAdRedirectUrl:ee}=await s(g,"",[],w,x);await t(g,T,ee)},[s,w,t,x]),N=g=>{d(p(g.target.checked)),y(g.target.checked)},M=g=>{j(g.target.value)},L=async g=>{b(void 0),g.preventDefault(),m&&(o!=null&&o.leafCampaignMailerId)&&await c(m,{app:"modern",leafCampaignMailerId:o.leafCampaignMailerId,userAgent:navigator.userAgent});try{if(!O(u))throw new Error("Please enter a valid email address to unsubscribe.");await E(u)}catch(T){b([T.message])}},{oneClickOptout:C}=q({submit:E});return a.useEffect(()=>{m===void 0&&d(p())},[l,p,m,r]),a.useEffect(()=>{C&&(j(C),f(!0))},[C]),e.jsxs("div",{children:[e.jsx("h2",{className:h("mb-xl",i!=null&&i.landing.content?void 0:"hidden md:block"),children:(i==null?void 0:i.landing.content)||"Enter your email address to unsubscribe"}),e.jsxs("form",{onSubmit:L,className:"space-y-xl",noValidate:!0,children:[e.jsx("div",{children:e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{children:"Your email address"}),e.jsx("input",{autoFocus:!0,type:"email",name:"email",value:u,onChange:M,className:h(v&&"error")})]})}),l===A.Eligible?e.jsx("div",{children:e.jsxs("label",{className:"flex items-start gap-[1.5rem]",children:[e.jsx("div",{children:e.jsx("input",{type:"checkbox",name:"collectCreative",checked:w,onChange:N})}),e.jsx("p",{className:"text-sm md:text-base max-w-[397px]",children:"Yes, I’ll forward the email I received to help improve the experience for others."})]})}):null,e.jsx("div",{children:e.jsx(R,{variant:"primary",type:"submit",name:"unsubscribe","aria-label":n?"Unsubscribing":"Unsubscribe",className:"w-full md:w-auto",loading:n,disabled:n,children:"Unsubscribe"})}),e.jsx(V,{formErrors:v})]})]})},Be=({onCompleted:t})=>{const{submitOptout:s,submitting:n,brandIntegrityStatus:l,pageData:r,campaignMailer:i}=k(),{trackEvent:o}=B(),c=a.useCallback(C=>{if(l===A.Eligible)return C===void 0?"forward-email-checkbox-untouched-dev9316":C?"forward-email-checkbox-checked-dev9316":"forward-email-checkbox-unchecked-dev9316"},[l]),[p,m]=a.useState(void 0),[d,u]=a.useState(""),[j,x]=a.useState(),[f,w]=a.useState(!1),[y,v]=a.useState(),b=a.useCallback(async C=>{K({email:C});const{collectFeedback:g,optoutAdRedirectUrl:T}=await s(C,"",[],f,j);await t(C,g,T)},[s,f,t,j]),E=C=>{m(c(C.target.checked)),w(C.target.checked)},N=C=>{u(C.target.value)},M=async C=>{v(void 0),C.preventDefault(),p&&(i!=null&&i.leafCampaignMailerId)&&await o(p,{app:"modern",leafCampaignMailerId:i.leafCampaignMailerId,userAgent:navigator.userAgent});try{if(!O(d))throw new Error("Please enter a valid email address to unsubscribe.");await b(d)}catch(g){v([g.message])}},{oneClickOptout:L}=q({submit:b});return a.useEffect(()=>{p===void 0&&m(c())},[l,c,p]),a.useEffect(()=>{L&&(u(L),x(!0))},[L]),e.jsxs("div",{children:[e.jsx("h2",{className:h("mb-xl",r!=null&&r.landing.content?void 0:"hidden md:block"),children:(r==null?void 0:r.landing.content)||"Enter your email address to unsubscribe"}),e.jsxs("form",{onSubmit:M,className:"space-y-xl",noValidate:!0,children:[e.jsx("div",{children:e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{children:"Your email address"}),e.jsx("input",{autoFocus:!0,type:"email",name:"email",value:d,onChange:N,className:h(y&&"error")})]})}),l===A.Eligible?e.jsx("div",{children:e.jsx("div",{children:e.jsxs("label",{className:"flex items-start gap-[1.5rem]",children:[e.jsx("div",{children:e.jsx("input",{type:"checkbox",name:"collectCreative",checked:f,onChange:E})}),e.jsx("p",{className:"text-sm md:text-base max-w-[397px]",children:"Request a Compliance Review of this email"})]})})}):null,e.jsx("div",{children:e.jsx(R,{variant:"primary",type:"submit",name:"unsubscribe","aria-label":n?"Unsubscribing":"Unsubscribe",className:"w-full md:w-auto",loading:n,disabled:n,children:"Unsubscribe"})}),e.jsx(V,{formErrors:y})]})]})},Ve=t=>t===I.DEV9278?Oe:Be,Ue=()=>{const{pageData:t,optoutPageTestId:s}=k(),{setTitle:n,setHeader:l,setFooterLinks:r}=D(),{redirect:i}=me(),o=le();a.useEffect(()=>{n((t==null?void 0:t.landing.title)||"We are sorry to see you go"),l(void 0),r([S.Complaint,S.PrivacyPolicy])},[t,r,l,n]);const c=async(m,d,u)=>{u&&!d?i(u):o("confirmation",{state:{email:m,collectCreative:d}})},p=Ve(s);return e.jsx(p,{onCompleted:c})},Ze=()=>{var r,i;const{pageData:t}=k(),{setTitle:s,setHeader:n,setFooterLinks:l}=D();return a.useEffect(()=>{s("Privacy policy"),n(e.jsx(G,{to:"./"})),l([])},[l,n,s]),t!=null&&t.privacy?(i=(r=t==null?void 0:t.privacy)==null?void 0:r.url)!=null&&i.length?(window.location.href=t.privacy.url,null):t.privacy.content?e.jsx("div",{className:"space-y-lg h-full md:max-h-[647px] pb-xl",children:e.jsx("div",{className:"h-full overflow-y-scroll whitespace-pre-wrap",children:t.privacy.content})}):e.jsx(z,{to:"../"}):null},_e=()=>{const t=Y(),[s,n]=a.useState(t),[l,r]=a.useState("fade-in"),i=()=>{l==="fade-out"&&(r("fade-in"),n(t))};a.useEffect(()=>{t!==s&&r("fade-out")},[t,s]);const o=He();return e.jsx("div",{id:"modern-app","data-testid":"modern-app",className:`${l}`,onAnimationEnd:i,children:e.jsx(ie,{location:s,children:e.jsxs(F,{path:"/:optoutKey",element:e.jsx(Ne,{}),children:[e.jsx(F,{index:!0,path:"*",element:e.jsx(Ue,{})}),e.jsx(F,{path:"confirmation",element:e.jsx(o,{})}),e.jsx(F,{path:"complaint",element:e.jsx(Fe,{})}),e.jsx(F,{path:"privacy-policy",element:e.jsx(Ze,{})})]})})})},Ye=_e;export{Ye as default};