
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de1dad18-03b9-5620-9314-4223f5a3dd09")}catch(e){}}();
import{j as t}from"./jsx-runtime-BjG_zV1W.js";import{r as s,u as Oe,a as De}from"./index-D6da9p6-.js";import{_ as se}from"./index-CqJN8iQq.js";import{S as $e}from"./StatusInputs-JkVhk_jg.js";import{a as Be,u as Ue,L as qe}from"./PageProvider-BtoiiMvA.js";import{u as Me}from"./useToast-DK42uF07.js";import{u as fe}from"./useTranslation-CfKJAmGY.js";import{u as Ze,d as et,c as me}from"./components-1fH5YjVo.js";import{c as q}from"./index-x2da_zcv.js";import{u as he}from"./WebThemeContext-DttfuZxo.js";const tt=({as:e="div",...o},n)=>t.jsx(e,{...o,ref:n}),rt=s.forwardRef(tt),nt="https://challenges.cloudflare.com/turnstile/v0/api.js",ye="cf-turnstile-script",ot="cf-turnstile",Te="onloadTurnstileCallback",We=e=>!!document.getElementById(e),st=({render:e="explicit",onLoadCallbackName:o=Te,scriptOptions:{nonce:n="",defer:r=!0,async:i=!0,id:d="",appendTo:m,onError:p,crossOrigin:c=""}={}})=>{const f=d||ye;if(We(f))return;const a=document.createElement("script");if(a.id=f,a.src=`${nt}?onload=${o}&render=${e}`,document.querySelector(`script[src="${a.src}"]`))return;a.defer=!!r,a.async=!!i,n&&(a.nonce=n),c&&(a.crossOrigin=c),p&&(a.onerror=p,delete window[o]),(m==="body"?document.body:document.getElementsByTagName("head")[0]).appendChild(a)},U={normal:{width:300,height:65},compact:{width:130,height:120},invisible:{width:0,height:0,overflow:"hidden"},auto:{},interactionOnly:{width:"fit-content",height:"auto",display:"flex"}};function at(e){let o;return e!=="invisible"&&e!=="auto"&&(o=e),o}function it(e=ye){const[o,n]=s.useState(!1);return s.useEffect(()=>{const r=()=>{We(e)&&n(!0)},i=new MutationObserver(r);return i.observe(document,{childList:!0,subtree:!0}),r(),()=>{i.disconnect()}},[e]),o}let ce="unloaded",ze;const ct=new Promise((e,o)=>{ze={resolve:e,reject:o},ce==="ready"&&e(void 0)}),lt=(e=Te)=>(ce==="unloaded"&&(ce="loading",window[e]=()=>{ze.resolve(),ce="ready",delete window[e]}),ct),je=s.forwardRef((e,o)=>{const{scriptOptions:n,options:r={},siteKey:i,onWidgetLoad:d,onSuccess:m,onExpire:p,onError:c,onBeforeInteractive:f,onAfterInteractive:a,onUnsupported:w,onLoadScript:N,id:E,style:b,as:h="div",injectScript:S=!0,...Y}=e,R=r.size||"normal",[F,I]=s.useState(r.execution==="execute"?U.invisible:r.appearance==="interaction-only"?U.interactionOnly:U[R]),y=s.useRef(null),[T,Q]=s.useState(!1),l=s.useRef(),M=s.useRef(!1),W=E||ot,O=n?.id||ye,P=it(O),ee=n?.onLoadCallbackName||Te,D=r.appearance||"always",C=s.useMemo(()=>({sitekey:i,action:r.action,cData:r.cData,callback:u=>{M.current=!0,m?.(u)},"error-callback":c,"expired-callback":p,"before-interactive-callback":f,"after-interactive-callback":a,"unsupported-callback":w,theme:r.theme||"auto",language:r.language||"auto",tabindex:r.tabIndex,"response-field":r.responseField,"response-field-name":r.responseFieldName,size:at(R),retry:r.retry||"auto","retry-interval":r.retryInterval||8e3,"refresh-expired":r.refreshExpired||"auto",execution:r.execution||"render",appearance:r.appearance||"always"}),[r.action,r.appearance,r.cData,r.execution,r.language,r.refreshExpired,r.responseField,r.responseFieldName,r.retry,r.retryInterval,r.tabIndex,r.theme,i,R]),v=s.useCallback(()=>typeof window<"u"&&!!window.turnstile,[]);return s.useEffect(function(){S&&!T&&st({onLoadCallbackName:ee,scriptOptions:{...n,id:O}})},[S,T,n,O]),s.useEffect(function(){ce!=="ready"&&lt(ee).then(()=>Q(!0)).catch(console.error)},[]),s.useEffect(function(){if(!y.current||!T)return;let j=!1;return(async()=>{if(j||!y.current)return;const H=window.turnstile.render(y.current,C);l.current=H,l.current&&d?.(l.current)})(),()=>{j=!0,l.current&&window.turnstile.remove(l.current)}},[W,T,C]),s.useImperativeHandle(o,()=>{const{turnstile:u}=window;return{getResponse(){if(!u?.getResponse||!l.current||!v()){console.warn("Turnstile has not been loaded");return}return u.getResponse(l.current)},async getResponsePromise(j=3e4,z=100){return new Promise((H,$)=>{let _;const g=async()=>{if(M.current&&window.turnstile&&l.current)try{const B=window.turnstile.getResponse(l.current);return _&&clearTimeout(_),B?H(B):$(new Error("No response received"))}catch(B){return _&&clearTimeout(_),console.warn("Failed to get response",B),$(new Error("Failed to get response"))}_||(_=setTimeout(()=>{_&&clearTimeout(_),$(new Error("Timeout"))},j)),await new Promise(B=>setTimeout(B,z)),await g()};g()})},reset(){if(!u?.reset||!l.current||!v()){console.warn("Turnstile has not been loaded");return}r.execution==="execute"&&I(U.invisible);try{M.current=!1,u.reset(l.current)}catch(j){console.warn(`Failed to reset Turnstile widget ${l}`,j)}},remove(){if(!u?.remove||!l.current||!v()){console.warn("Turnstile has not been loaded");return}I(U.invisible),M.current=!1,u.remove(l.current),l.current=null},render(){if(!u?.render||!y.current||!v()||l.current){console.warn("Turnstile has not been loaded or container not found");return}const j=u.render(y.current,C);return l.current=j,l.current&&d?.(l.current),r.execution!=="execute"&&I(U[R]),j},execute(){if(r.execution!=="execute"){console.warn('Execution mode is not set to "execute"');return}if(!u?.execute||!y.current||!l.current||!v()){console.warn("Turnstile has not been loaded or container not found");return}u.execute(y.current,C),I(U[R])},isExpired(){if(!u?.isExpired||!l.current||!v()){console.warn("Turnstile has not been loaded");return}return u.isExpired(l.current)}}},[l,r.execution,R,C,y,v,T,d]),s.useEffect(()=>{P&&!T&&window.turnstile&&Q(!0)},[T,P]),s.useEffect(()=>{I(r.execution==="execute"?U.invisible:D==="interaction-only"?U.interactionOnly:U[R])},[r.execution,R,D]),s.useEffect(()=>{!P||typeof N!="function"||N()},[P]),t.jsx(rt,{ref:y,as:h,id:W,style:{...F,...b},...Y})});je.displayName="Turnstile";function ut(){return()=>{}}function dt(){return s.useSyncExternalStore(ut,()=>!0,()=>!1)}function He({children:e,fallback:o=null}){return dt()?s.createElement(s.Fragment,null,e()):s.createElement(s.Fragment,null,o)}const Ke="bhba",$t=.17,Ve=e=>{const[o]=Ze(),n=o.get("_bhba")||void 0;return e||n},pt=({name:e,category:o,action:n,label:r=window.location.href,value:i=0,data:d={}})=>{const p={event:e,eventProps:{category:o,action:n,label:r,value:i,timestamp:new Date().toISOString(),...d}};typeof window.dataLayer<"u"&&window.dataLayer.push(p)},Ge={pushEvent:pt},Je=e=>!!e.match(/(iPad|iPhone|iPod)/g);var ie=(e=>(e.POPUP="popup",e.GATED="gated",e.FORM="form",e.NONE="none",e))(ie||{});const Ye=s.createContext(void 0),mt=()=>{const e=s.useContext(Ye);if(!e)throw new Error("useSignup must be used within a SignupProvider");return e},ft=({children:e,email:o,setEmail:n,onEmailChange:r,isSubmitting:i,autoFocus:d})=>t.jsx(Ye.Provider,{value:{email:o,setEmail:n,onEmailChange:r,isSubmitting:i,autoFocus:d},children:e}),ht=({visitToken:e,referralId:o,boostAffiliateRecommendingPublicationId:n,recaptchaToken:r})=>t.jsx(He,{fallback:t.jsx(t.Fragment,{}),children:()=>t.jsxs(t.Fragment,{children:[t.jsx("input",{hidden:!0,name:"ref",value:o||"",onChange:()=>null}),t.jsx("input",{hidden:!0,name:"bhba",value:n||"",onChange:()=>null}),t.jsx("input",{hidden:!0,name:"visit_token",value:e||"",onChange:()=>null}),t.jsx("input",{name:"cf-turnstile-response",type:"hidden",value:r||""})]})}),gt=({type:e=ie.NONE,onEmailChange:o,onSuccess:n,widgetId:r,autoFocus:i=!1,premiumOfferId:d,children:m,bodyTextColor:p})=>{const{t:c}=fe(),f=Oe(),{publication:a}=et("root"),{setCookie:w,cookies:N,visitToken:E,referralId:b,currentPath:h,recaptchaSiteKey:S}=Be(),Y=Ve(N[Ke]||void 0),{pathname:R}=De(),[F,I]=Ue(),y=s.useRef(null),[T,Q]=s.useState(!1),l=s.useRef(),[M,W]=s.useState(null),[O,P]=s.useState("interaction-only"),[ee,D]=s.useState("invisible"),C=a.web_template.enable_recaptcha,v=me(),u=v.data,j=v.state==="submitting",[z,H]=s.useState(0),[$,_]=s.useState(!1),g=me(),K=a.web_template.signup_flow.filter(({enabled:k})=>k),J=K[0],le=K.length>0&&K?.[0]?.managed_type!=="custom",ge=!!J&&!J.full_url.startsWith(a.url),ue=e===ie.POPUP,ke=e===ie.GATED,te=e===ie.FORM,A=ue||ke||te,de=s.useMemo(()=>{if(A)return R;if(J){const k=J.href.split("?"),ne=k[0],oe=k[1]||"",X=new URLSearchParams(oe);return X.set("email",F),`${ne}?${X.toString()}`}return"/"},[J,R,F,A]),{double_opt_required:xe,has_referral_program:Ne,private:Fe,require_subscriber_approval:Ie}=a,re=!!(xe||Ne&&b);Me(u?.toast),s.useEffect(()=>{if(u?.toast?.status==="success"&&(w({name:"email_capture_disabled",value:"true",days:30}),y?.current?.reset(),l?.current?.reset()),u?.dataLayerEvent&&(Ge.pushEvent(u.dataLayerEvent),C&&(P("interaction-only"),D("invisible"))),!A&&u?.redirectTo&&le){const k={startedAt:new Date().toISOString(),currentIndex:0,nextIndex:1,redirects:K};localStorage.setItem(qe.SIGNUP_REDIRECTS,JSON.stringify(k))}!A&&u?.redirectTo&&(J&&ge?setTimeout(()=>{if(Je(navigator.userAgent))try{window.location=u?.redirectTo}catch{window.location=u?.redirectTo}else window.open(u?.redirectTo,"_blank"),f("/")},1e3):f(u?.redirectTo)),u?.redirectTo&&n&&n()},[u]);const be=()=>a.require_subscriber_approval?c("notifications.subscribe.require_approval"):a.double_opt_required?c("notifications.subscribe.confirm"):c("notifications.subscribe.subscribed"),ve=(k,ne,oe,X)=>{if(k.preventDefault(),a?.enable_signup_confirmation&&!T){se.error("Accept ToU & Privacy Policy.");return}const L=new FormData(k.currentTarget),we=L.get("visit_token"),_e=L.get("ref"),x=F?.trim();if(L.set("is_js_enabled","true"),L.set("accepted_tos",String(T)),L.set("email",x),!x){se.error("Please enter a valid email address");return}if(ne&&!oe){if(se.error("Please wait for the CAPTCHA test to complete!"),P("always"),D("normal"),H(z+1),l?.current?.reset(),z>=1){const V=!!document?.getElementById(`cf-turnstile-script__${r}`),Z=new FormData;Z.set("message",`Multiple recaptcha errors attempting to sign up for ${a.name}, with email ${F}, error count at ${z+1}, and script in doc: ${V.toString()}`),g.submit(Z,{method:"post",action:"/logger"}),_(!0)}return}if($&&ne&&oe){const V=new FormData;V.set("message",`Successfully generated token on signup up for ${a.name} with email ${F} after ${z} failed attempts`),g.submit(V,{method:"post",action:"/logger"})}!we&&E&&L.set("visit_token",E),!_e&&b&&L.set("ref",b),X&&L.set("premium_offer_id",X),v.submit(L,{method:"post",action:"/create"})};return Fe&&!Ie?null:t.jsxs("div",{className:"flex w-full flex-col items-center",children:[t.jsxs(v.Form,{ref:y,method:"post",action:"/create",className:"group w-full rounded-wt bg-transparent",onSubmit:k=>ve(k,C,M,d),children:[t.jsx(ht,{visitToken:E,referralId:b,boostAffiliateRecommendingPublicationId:Y,recaptchaToken:M}),t.jsx("input",{name:"redirect_path",type:"hidden",value:de}),t.jsx("input",{name:"sent_from_orchid",type:"hidden",value:"true"}),t.jsx("input",{name:"fallback_path",type:"hidden",value:h}),t.jsx("input",{name:"is_recaptcha_enabled",type:"hidden",value:C.toString()}),t.jsx("input",{name:"double_opt",type:"hidden",value:re.toString()}),t.jsx("input",{name:"trigger_redirect",type:"hidden",value:le.toString()}),t.jsx($e,{name:"subscribe",successMessage:be(),errorMessage:c("errors.default")}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx(ft,{email:F,setEmail:I,onEmailChange:o,isSubmitting:j,autoFocus:i,children:m}),a?.enable_signup_confirmation&&t.jsxs("div",{className:"mt-3 flex flex-row space-x-2",children:[t.jsx("input",{type:"checkbox",className:"text-lp-main-signup-cta-color h-4 w-4 rounded border-gray-300 focus:ring-indigo-500",checked:T,onChange:()=>Q(!T)}),!a?.terms_of_service||a?.terms_of_service.length==0?t.jsxs("p",{className:"text-xs font-medium",style:{color:p},children:[c("shared.cta.gdpr_signup_consent")," ",t.jsx("a",{href:"https://www.beehiiv.com/tou",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:c("footer.terms_of_use")})," ",c("shared.cta.and")," ",t.jsx("a",{href:"https://www.beehiiv.com/privacy",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:c("footer.privacy_policy")}),"."]}):t.jsxs("p",{className:"text-xs font-medium",style:{color:p},children:[c("shared.cta.gdpr_signup_consent")," ",c("shared.cta.sign_up")," ",t.jsx("a",{href:"/tos",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:c("meta.titles.tos")}),"."]})]})]})]}),C&&t.jsx(je,{ref:l,siteKey:S||"",id:r,onSuccess:W,onUnsupported:()=>W("invalid-token"),onError:()=>W("invalid-token"),onBeforeInteractive:()=>D("normal"),options:{theme:"light",size:ee,appearance:O}})]})};function xt({title:e,titleId:o,...n},r){return s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":o},n),e?s.createElement("title",{id:o},e):null,s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75"}))}const bt=s.forwardRef(xt),Ee=({color:e,children:o,iconEnabled:n,className:r,style:i={}})=>t.jsxs("div",{className:q("flex w-full items-center",r),style:i,children:[n&&t.jsx("div",{className:"pl-2",style:{color:e},children:t.jsx(bt,{className:"h-6 w-6"})}),o]}),Se=({backgroundColor:e,fontFamily:o,fontSize:n,textColor:r,autoFocus:i,placeholderText:d,setEmail:m,onEmailChange:p,className:c})=>{const{t:f}=fe();return t.jsx("input",{type:"email",name:"email",autoComplete:"email",autoFocus:i,required:!0,style:{...e&&{borderColor:e},...o&&{fontFamily:o},color:"#111827"},className:q("wt-button-font z-10 w-full border-none bg-transparent placeholder-shown:text-ellipsis",{"text-lg focus:text-lg active:text-lg sm:text-lg":!n||n==="lg"},{"text-sm focus:text-sm active:text-sm":n==="sm"},c),onChange:a=>{m(a.target.value),p&&p(a.target.value)},placeholder:d||f("subscribe.email_placeholder")||""})},Re=({className:e,children:o,style:n={}})=>{const{classes:r}=he();return t.jsx("div",{style:n,className:q("flex w-full flex-col items-center sm:flex-row",e,r.radius),children:o})},vt=e=>{switch(e){case"rounded-none":return"rounded-none";case"rounded-sm":return"rounded-xs";case"rounded-md":return"rounded-sm";case"rounded-lg":return"rounded-md";case"rounded-xl":return"rounded-lg";case"rounded-2xl":return"rounded-xl";case"rounded-3xl":return"rounded-2xl";default:return"rounded-none"}},Ce=({isSubmitting:e,ctaText:o,backgroundColor:n,fontFamily:r,fontSize:i,textColor:d,className:m,borderColor:p,shouldAdjustRadius:c=!1})=>{const{t:f}=fe(),{classes:a}=he(),w=o||f("shared.cta.subscribe");return t.jsx("input",{type:"submit",value:e?`${f("shared.actions.submitting")}...`:w,style:{...n&&{backgroundColor:n},...d&&{color:d},...r&&{fontFamily:r},...p&&{borderColor:p}},className:q("cursor-pointer px-5 py-3 font-semibold","w-full sm:w-auto",{"text-lg focus:text-lg active:text-lg sm:text-lg":!i||i==="lg"},{"text-sm focus:text-sm active:text-sm":i==="sm"},c?a.radius:vt(a.radius),m),disabled:e})},wt=({signupStyles:e,isSubmitting:o,autoFocus:n,setEmail:r,onEmailChange:i})=>{const{fontFamily:d,fontSize:m,buttonFontFamily:p,buttonBgColor:c,buttonTextColor:f,placeholderBgColor:a,placeholderTextColor:w,buttonText:N,placeholderText:E,borderEnabled:b,borderColor:h,emailIconEnabled:S}=e;return t.jsxs(Re,{style:{backgroundColor:a,border:b?`2px solid ${h}`:"none"},className:"overflow-hidden p-1",children:[t.jsx(Ee,{color:c||"",style:{backgroundColor:a},iconEnabled:S,children:t.jsx(Se,{fontFamily:d,fontSize:m,autoFocus:n,setEmail:r,onEmailChange:i,placeholderText:E,textColor:w})}),t.jsx(Ce,{isSubmitting:o,fontFamily:p,fontSize:m,ctaText:N,backgroundColor:c,textColor:f})]})},_t=e=>{switch(e){case"none":return"rounded-none sm:rounded-r-none";case"sm":return"rounded-none sm:rounded-sm-r";case"md":return"rounded-none sm:rounded-md-r";case"lg":return"rounded-none sm:rounded-lg-r";case"xl":return"rounded-none sm:rounded-xl-r";case"2xl":return"rounded-none sm:rounded-2xl-r";case"3xl":return"rounded-none sm:rounded-3xl-r";default:return"rounded-none"}},yt=({signupStyles:e,isSubmitting:o,autoFocus:n,setEmail:r,onEmailChange:i})=>{const{webTheme:d}=he(),{fontFamily:m,buttonFontFamily:p,buttonBgColor:c,buttonTextColor:f,placeholderBgColor:a,placeholderTextColor:w,buttonText:N,placeholderText:E,borderEnabled:b,borderColor:h,emailIconEnabled:S}=e,Y=_t(d.radius);return t.jsxs(Re,{style:{backgroundColor:a,border:b?`2px solid ${h}`:"none"},className:"overflow-hidden",children:[t.jsx(Ee,{color:c||"",style:{backgroundColor:a},iconEnabled:S,children:t.jsx(Se,{fontFamily:m,autoFocus:n,setEmail:r,onEmailChange:i,placeholderText:E,textColor:w})}),t.jsx(Ce,{isSubmitting:o,fontFamily:p,ctaText:N,backgroundColor:c,textColor:f,className:Y,shouldAdjustRadius:!0})]})},Tt=({signupStyles:e,isSubmitting:o,autoFocus:n,setEmail:r,onEmailChange:i})=>{const{classes:d}=he(),{fontFamily:m,buttonFontFamily:p,buttonBgColor:c,buttonTextColor:f,placeholderBgColor:a,placeholderTextColor:w,buttonText:N,placeholderText:E,borderEnabled:b,borderColor:h,emailIconEnabled:S}=e;return t.jsxs(Re,{className:"gap-2 overflow-hidden",children:[t.jsx(Ee,{color:c,iconEnabled:S,className:q(d.radius),style:{backgroundColor:a,border:b?`2px solid ${h}`:"none"},children:t.jsx(Se,{fontFamily:m,autoFocus:n,setEmail:r,onEmailChange:i,placeholderText:E,textColor:w,className:"py-3"})}),t.jsx("div",{className:q("w-full sm:w-auto",d.radius),style:{backgroundColor:b?c:"",border:b?`2px solid ${c}`:"none"},children:t.jsx(Ce,{isSubmitting:o,fontFamily:p,ctaText:N,backgroundColor:c,textColor:f})})]})},jt=e=>!e||!["template-1","template-2","template-3"].includes(e)?"template-1":e,Et=({signupStyles:e})=>{const o=jt(e?.template),n={"template-1":wt,"template-2":yt,"template-3":Tt}[o],{isSubmitting:r,autoFocus:i,email:d,setEmail:m,onEmailChange:p}=mt();return t.jsx(n,{signupStyles:e,autoFocus:i,isSubmitting:r,email:d,setEmail:m,onEmailChange:p})},Bt=({signupStyles:e,type:o,widgetId:n,premiumOfferId:r,onEmailChange:i,onSuccess:d,autoFocus:m})=>e?t.jsx(gt,{type:o,widgetId:n,premiumOfferId:r,onEmailChange:i,onSuccess:d,autoFocus:m,bodyTextColor:e.bodyTextColor,children:t.jsx(Et,{signupStyles:e})}):null,Le={ariel:"font-ariel",bitter:"font-bitter",courier:"font-courier",didot:"font-didot",garamond:"font-garamond",georgia:"font-georgia",helvetica:"font-helvetica",lora:"font-lora","lucida-console":"font-lucida-console",merriweather:"font-merriweather",monaco:"font-monaco","helvetica-neue-condensed-black":"font-helvetica-neue-condensed-black","space-grotesk":"font-space-grotesk",montserrat:"font-montserrat","open-sans":"font-open_sans",palatino:"font-palatino","playfair-display":"font-playfair-display",poppins:"font-poppins",roboto:"font-roboto","times-new-roman":"font-times-new-roman","trebuchet-ms":"font-trebuchet-ms",verdana:"font-verdana"};var St=(e=>(e.POPUP="popup",e.GATED="gated",e.FORM="form",e.NONE="none",e))(St||{});const Rt=({visitToken:e,referralId:o,boostAffiliateRecommendingPublicationId:n,recaptchaToken:r})=>t.jsx(He,{fallback:t.jsx(t.Fragment,{}),children:()=>t.jsxs(t.Fragment,{children:[t.jsx("input",{hidden:!0,name:"ref",value:o||"",onChange:()=>null}),t.jsx("input",{hidden:!0,name:"bhba",value:n||"",onChange:()=>null}),t.jsx("input",{hidden:!0,name:"visit_token",value:e||"",onChange:()=>null}),t.jsx("input",{name:"cf-turnstile-response",type:"hidden",value:r||""})]})}),Ut=({type:e="none",cta:o,publication:n,onEmailChange:r,onSuccess:i,recaptchaSiteKey:d,widgetId:m,isCustomLPTheme:p=!1,placeholderText:c,fontFamily:f,backgroundColor:a,textColor:w,autoFocus:N=!1,premiumOfferId:E,buttonPlacement:b="inline"})=>{const{t:h}=fe(),S=Oe(),{setCookie:Y,cookies:R,visitToken:F,referralId:I,currentPath:y}=Be(),T=Ve(R[Ke]||void 0),{pathname:Q}=De(),[l,M]=Ue(),W=s.useRef(null),O=b==="bottom",[P,ee]=s.useState(!1),D=s.useRef(),[C,v]=s.useState(null),[u,j]=s.useState("interaction-only"),[z,H]=s.useState("invisible"),$=n.web_template.enable_recaptcha,_=me(),g=_.data,B=_.state==="submitting",[K,J]=s.useState(0),[le,ge]=s.useState(!1),ue=me(),te=n.web_template.signup_flow.filter(({enabled:x})=>x),A=te[0],de=te.length>0&&te?.[0]?.managed_type!=="custom",xe=!!A&&!A.full_url.startsWith(n.url),re=e==="popup"||e==="gated"||e==="form",be=s.useMemo(()=>{if(re)return Q;if(A){const x=A.href.split("?"),V=x[0],Z=x[1]||"",ae=new URLSearchParams(Z);return ae.set("email",l),`${V}?${ae.toString()}`}return"/"},[A,Q,l,re]),ve=o||n.cta_text,{double_opt_required:k,has_referral_program:ne,private:oe,require_subscriber_approval:X}=n,L=!!(k||ne&&I);Me(g?.toast),s.useEffect(()=>{if(g?.toast?.status==="success"&&(Y({name:"email_capture_disabled",value:"true",days:30}),W?.current?.reset(),D?.current?.reset()),g?.dataLayerEvent&&(Ge.pushEvent(g.dataLayerEvent),$&&(j("interaction-only"),H("invisible"))),!re&&g?.redirectTo&&de){const x={startedAt:new Date().toISOString(),currentIndex:0,nextIndex:1,redirects:te};localStorage.setItem(qe.SIGNUP_REDIRECTS,JSON.stringify(x))}!re&&g?.redirectTo&&(A&&xe?setTimeout(()=>{if(Je(navigator.userAgent))try{window.location=g?.redirectTo}catch{window.location=g?.redirectTo}else window.open(g?.redirectTo,"_blank"),S("/")},1e3):S(g?.redirectTo)),g?.redirectTo&&i&&i()},[g]);const we=()=>n.require_subscriber_approval?h("notifications.subscribe.require_approval"):n.double_opt_required?h("notifications.subscribe.confirm"):h("notifications.subscribe.subscribed"),_e=(x,V,Z,ae)=>{if(x.preventDefault(),n?.enable_signup_confirmation&&!P){se.error("Accept ToU & Privacy Policy.");return}const G=new FormData(x.currentTarget),Qe=G.get("visit_token"),Xe=G.get("ref"),Pe=l?.trim();if(G.set("is_js_enabled","true"),G.set("accepted_tos",String(P)),G.set("email",Pe),!Pe){se.error("Please enter a valid email address");return}if(V&&!Z){if(se.error("Please wait for the CAPTCHA test to complete!"),j("always"),H("normal"),J(K+1),D?.current?.reset(),K>=1){const pe=!!document?.getElementById(`cf-turnstile-script__${m}`),Ae=new FormData;Ae.set("message",`Multiple recaptcha errors attempting to sign up for ${n.name}, with email ${l}, error count at ${K+1}, and script in doc: ${pe.toString()}`),ue.submit(Ae,{method:"post",action:"/logger"}),ge(!0)}return}if(le&&V&&Z){const pe=new FormData;pe.set("message",`Successfully generated token on signup up for ${n.name} with email ${l} after ${K} failed attempts`),ue.submit(pe,{method:"post",action:"/logger"})}!Qe&&F&&G.set("visit_token",F),!Xe&&I&&G.set("ref",I),ae&&G.set("premium_offer_id",ae),_.submit(G,{method:"post",action:"/create"})};return oe&&!X?null:t.jsxs("div",{className:"flex w-full flex-col items-center space-y-4",children:[t.jsxs(_.Form,{ref:W,method:"post",action:"/create",className:"group w-full rounded-wt bg-transparent",onSubmit:x=>_e(x,$,C,E),children:[t.jsx(Rt,{visitToken:F,referralId:I,boostAffiliateRecommendingPublicationId:T,recaptchaToken:C}),t.jsx("input",{name:"redirect_path",type:"hidden",value:be}),t.jsx("input",{name:"sent_from_orchid",type:"hidden",value:"true"}),t.jsx("input",{name:"fallback_path",type:"hidden",value:y}),t.jsx("input",{name:"is_recaptcha_enabled",type:"hidden",value:$.toString()}),t.jsx("input",{name:"double_opt",type:"hidden",value:L.toString()}),t.jsx("input",{name:"trigger_redirect",type:"hidden",value:de.toString()}),t.jsx($e,{name:"subscribe",successMessage:we(),errorMessage:h("errors.default")}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:q("w-full sm:mx-auto sm:flex",O?"flex flex-col items-center space-y-4":""),children:[t.jsx("div",{className:"w-full",children:t.jsx("input",{type:"email",name:"email",autoComplete:"email",autoFocus:N,required:!0,style:{...a&&{borderColor:a}},className:q(f?Le[f]:"wt-button-font",p?"border-lp-main-signup-bg-color focus:border-lp-main-signup-bg-color":"border-wt-primary focus:border-wt-primary",O?"":"sm:rounded-r-none","block w-full rounded border-2 bg-white px-5 py-3 text-lg font-light text-black placeholder-gray-400 shadow-none placeholder:text-lg focus:outline-none"),onChange:x=>{M(x.target.value),r&&r(x.target.value)},placeholder:c||h("subscribe.email_placeholder")||""})}),t.jsx("div",{className:q("mt-2 sm:mt-0",O?"w-full":""),children:t.jsx("input",{type:"submit",value:B?`${h("shared.actions.submitting")}...`:ve,style:{...a&&{backgroundColor:a},...w&&{color:w}},className:q(f?Le[f]:"wt-button-font",p?"text-lp-main-signup-cta-color bg-lp-main-signup-bg-color text-lp-main-signup-text-color":"bg-wt-primary text-wt-text-on-primary",O?"":"sm:rounded-l-none","block h-full w-full cursor-pointer rounded border border-transparent px-5 py-3 !text-lg font-medium transition duration-200 sm:px-10 sm:text-base"),disabled:B})})]}),n?.enable_signup_confirmation&&t.jsxs("div",{className:"mt-3 flex flex-row space-x-2",children:[t.jsx("input",{type:"checkbox",className:"text-lp-main-signup-cta-color h-4 w-4 rounded border-gray-300 focus:ring-indigo-500",checked:P,onClick:()=>ee(!P)}),!n?.terms_of_service||n?.terms_of_service.length==0?t.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[h("shared.cta.gdpr_signup_consent")," ",t.jsx("a",{href:"https://www.beehiiv.com/tou",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:h("footer.terms_of_use")})," ",h("shared.cta.and")," ",t.jsx("a",{href:"https://www.beehiiv.com/privacy",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:h("footer.privacy_policy")}),"."]}):t.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[h("shared.cta.gdpr_signup_consent")," ",h("shared.cta.sign_up")," ",t.jsx("a",{href:"/tos",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:h("meta.titles.tos")}),"."]})]})]})]}),$&&t.jsx(je,{ref:D,siteKey:d||"",id:m,onSuccess:v,onUnsupported:()=>v("invalid-token"),onError:()=>v("invalid-token"),onBeforeInteractive:()=>H("normal"),options:{theme:"light",size:z,appearance:u}})]})};export{Ke as B,Ut as C,Bt as S,St as a,$t as b,He as c};
//# sourceMappingURL=CreateAction-DJseQcAV.js.map

//# debugId=de1dad18-03b9-5620-9314-4223f5a3dd09
