1import{j as e}from"./jsx-runtime-BsZe8PNh.js";import{r as i}from"./entry-client-DOYP2g6G.js";const W=({i18n:r,mainText:E,privacyPolicyUrl:F,successMessage:w,errorMessage:C,buttonClass:T,recaptchaSiteKey:_,currentLanguage:I,newsFeed:l})=>{const[f,R]=i.useState(""),[k,L]=i.useState(""),[j,M]=i.useState(""),[c,q]=i.useState(""),[a,G]=i.useState([]),[d,H]=i.useState(!1),[m,A]=i.useState(""),[p,O]=i.useState(""),[u,N]=i.useState(""),[$,B]=i.useState(!1),[P,b]=i.useState(!1),g=i.useRef(null),h=i.useRef(null);i.useEffect(()=>{const s="recaptcha-script";if(window.grecaptcha||document.getElementById(s))return;const t=document.createElement("script");t.id=s,t.src=`https://www.google.com/recaptcha/api.js?render=${_}`,t.async=!0,t.defer=!0,document.body.appendChild(t)},[]);const v=s=>{G(t=>t.includes(s)?t.filter(o=>o!==s):[...t,s])},V=()=>l!==4?l:a.length===2?3:a[0]||4,y=s=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s),D=()=>{let s=!0;return A(c.trim()&&y(c)?"":r.emailError),(!c.trim()||!y(c))&&(s=!1),O(d?"":r.gdprError),d||(s=!1),l===4&&a.length===0?(N(r.newsFeedError),s=!1):N(""),s},x=s=>{setTimeout(()=>{s.current&&s.current.focus()},0)},J=async s=>{if(s.preventDefault(),!D())return;const t=V(),n=window.grecaptcha;if(!n||!n.ready){console.error("Error: reCAPTCHA not loaded yet."),b(!0);return}n.ready(async()=>{try{const o=await n.execute(_,{action:"submit"}),S=await fetch("/api/subscription/cision",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({firstName:f,lastName:k,company:j,email:c,acceptGdpr:d,recaptchaToken:o,currentLanguage:I,newsFeed:t})}),z=await S.json();S.ok?(B(!0),x(g)):(console.error("Error:",z),b(!0),x(h))}catch(o){console.error("Error:",o),b(!0),x(h)}})};return $?e.jsx("div",{ref:g,tabIndex:-1,className:"cision-subscription-block__success-message","aria-live":"assertive",dangerouslySetInnerHTML:{__html:w}}):P?e.jsx("div",{ref:h,tabIndex:-1,className:"cision-subscription-block__error-message","aria-live":"assertive",dangerouslySetInnerHTML:{__html:C}}):e.jsxs("div",{className:"cision-subscription-block__container",children:[e.jsx("div",{className:"cision-subscription-block__main-text",dangerouslySetInnerHTML:{__html:E}}),e.jsxs("form",{onSubmit:J,noValidate:!0,className:"cision-subscription-block__form",children:[e.jsxs("div",{className:"cision-subscription-block__name-container",children:[e.jsxs("div",{className:"cision-subscription-block__first-name",children:[e.jsx("label",{htmlFor:"firstName",children:r.firstName}),e.jsx("input",{type:"text",id:"firstName",value:f,onChange:s=>R(s.target.value)})]}),e.jsxs("div",{className:"cision-subscription-block__last-name",children:[e.jsx("label",{htmlFor:"lastName",children:r.lastName}),e.jsx("input",{type:"text",id:"lastName",value:k,onChange:s=>L(s.target.value)})]})]}),e.jsxs("div",{className:"cision-subscription-block__company",children:[e.jsx("label",{htmlFor:"company",children:r.company}),e.jsx("input",{type:"text",id:"company",value:j,onChange:s=>M(s.target.value)})]}),e.jsxs("div",{className:"cision-subscription-block__email",children:[e.jsxs("label",{htmlFor:"email",children:[r.email,e.jsx("span",{className:"cision-subscription-block__required",children:"(*)"})]}),e.jsx("input",{type:"email",id:"email",value:c,onChange:s=>q(s.target.value),"aria-describedby":"email-error","aria-invalid":!!m,"aria-required":"true"}),m&&e.jsx("span",{id:"email-error",className:"cision-subscription-block__error",role:"alert","aria-live":"assertive",children:m})]}),l===4&&e.jsxs("div",{children:[e.jsxs("fieldset",{className:"cision-subscription-block__news-feeds",children:[e.jsx("div",{className:"cision-subscription-block__news-feeds-legend-container",children:e.jsxs("legend",{className:"cision-subscription-block__news-feeds-legend",children:[r.selectNewsFeed,e.jsx("span",{className:"cision-subscription-block__required",children:"(*)"})]})}),e.jsxs("label",{className:"cision-subscription-block__checkbox-container",htmlFor:"investorRelations",children:[e.jsx("input",{className:"cision-subscription-block__checkbox",type:"checkbox",id:"investorRelations",checked:a.includes(1),onChange:()=>v(1),"aria-describedby":"news-feed-error","aria-invalid":!!u}),r.investorRelations]}),e.jsxs("label",{className:"cision-subscription-block__checkbox-container",htmlFor:"coorSE",children:[e.jsx("input",{className:"cision-subscription-block__checkbox",type:"checkbox",id:"coorSE",checked:a.includes(2),onChange:()=>v(2),"aria-describedby":"news-feed-error","aria-invalid":!!u}),r.coorSE]})]}),u&&e.jsx("span",{id:"news-feed-error",className:"cision-subscription-block__error",role:"alert","aria-live":"assertive",children:u})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"cision-subscription-block__checkbox-container",htmlFor:"acceptGdpr",children:[e.jsx("input",{className:"cision-subscription-block__checkbox",type:"checkbox",id:"acceptGdpr",checked:d,onChange:s=>H(s.target.checked),"aria-describedby":"gdpr-error","aria-invalid":!!p,"aria-required":"true"}
1),e.jsxs("div",{children:[r.gdprText,e.jsx("a",{className:"cision-subscription-block__gdpr-link",href:F,"aria-label":r.gdprLinkText,children:r.gdprLinkText}),e.jsx("span",{className:"cision-subscription-block__required",children:"(*)"})]})]}),p&&e.jsx("span",{id:"gdpr-error",className:"cision-subscription-block__error",role:"alert","aria-live":"assertive",children:p})]}),e.jsx("div",{className:"cision-subscription-block__submit",children:e.jsx("button",{className:`button ${T}`,type:"submit",children:r.send})})]})]})};export{W 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.