
!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]="d07174c7-371d-5407-91a7-bf9831209038")}catch(e){}}();
import{j as e}from"./jsx-runtime-BjG_zV1W.js";import{r as u,u as ue,a as me}from"./index-D6da9p6-.js";import{_ as H}from"./index-CqJN8iQq.js";import{S as pe}from"./StatusInputs-JkVhk_jg.js";import{a as fe,u as he,L as xe}from"./PageProvider-1HDi89I5.js";import{u as ge}from"./useToast-DK42uF07.js";import{u as Y}from"./useTranslation-CfKJAmGY.js";import{u as Ee,d as ke,c as be}from"./components-PKPTORWS.js";import{c as N}from"./index-x2da_zcv.js";import{u as Q}from"./WebThemeContext-DttfuZxo.js";function Re(){return()=>{}}function Se(){return u.useSyncExternalStore(Re,()=>!0,()=>!1)}function ve({children:t,fallback:o=null}){return Se()?u.createElement(u.Fragment,null,t()):u.createElement(u.Fragment,null,o)}const _e="bhba",ot=.17,we=t=>{const[o]=Ee(),r=o.get("_bhba")||void 0;return t||r},Pe=({name:t,category:o,action:r,label:s=window.location.href,value:a=0,data:i={}})=>{const n={event:t,eventProps:{category:o,action:r,label:s,value:a,timestamp:new Date().toISOString(),...i}};typeof window.dataLayer<"u"&&window.dataLayer.push(n)},ye={pushEvent:Pe},je=t=>!!t.match(/(iPad|iPhone|iPod)/g);var L=(t=>(t.POPUP="popup",t.GATED="gated",t.FORM="form",t.NONE="none",t))(L||{});const Te=u.createContext(void 0),Fe=()=>{const t=u.useContext(Te);if(!t)throw new Error("useSignup must be used within a SignupProvider");return t},Ie=({children:t,email:o,setEmail:r,onEmailChange:s,isSubmitting:a,autoFocus:i})=>e.jsx(Te.Provider,{value:{email:o,setEmail:r,onEmailChange:s,isSubmitting:a,autoFocus:i},children:t}),Ae=({visitToken:t,referralId:o,boostAffiliateRecommendingPublicationId:r})=>e.jsx(ve,{fallback:e.jsx(e.Fragment,{}),children:()=>e.jsxs(e.Fragment,{children:[e.jsx("input",{hidden:!0,name:"ref",value:o||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"bhba",value:r||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"visit_token",value:t||"",onChange:()=>null})]})}),Oe=({type:t=L.NONE,onEmailChange:o,onSuccess:r,autoFocus:s=!1,premiumOfferId:a,children:i,bodyTextColor:m})=>{const{t:n}=Y(),d=ue(),{publication:c}=ke("root"),{setCookie:p,cookies:_,visitToken:w,referralId:l,currentPath:v}=fe(),E=we(_[_e]||void 0),{pathname:T}=me(),[C,F]=he(),M=u.useRef(null),[I,U]=u.useState(!1),R=be(),f=R.data,$=R.state==="submitting",k=c.web_template.signup_flow.filter(({enabled:g})=>g),S=k[0],P=k.length>0&&k?.[0]?.managed_type!=="custom",h=!!S&&!S.full_url.startsWith(c.url),W=t===L.POPUP,se=t===L.GATED,A=t===L.FORM,y=W||se||A,V=u.useMemo(()=>{if(y)return T;if(S){const g=S.href.split("?"),D=g[0],b=g[1]||"",B=new URLSearchParams(b);return B.set("email",C),`${D}?${B.toString()}`}return"/"},[S,T,C,y]),{double_opt_required:X,has_referral_program:ae,private:ie,require_subscriber_approval:le}=c,O=!!(X||ae&&l);ge(f?.toast),u.useEffect(()=>{if(f?.toast?.status==="success"&&(p({name:"email_capture_disabled",value:"true",days:30}),M?.current?.reset()),f?.dataLayerEvent&&ye.pushEvent(f.dataLayerEvent),!y&&f?.redirectTo&&P){const g={startedAt:new Date().toISOString(),currentIndex:0,nextIndex:1,redirects:k};localStorage.setItem(xe.SIGNUP_REDIRECTS,JSON.stringify(g))}!y&&f?.redirectTo&&(S&&h?setTimeout(()=>{if(je(navigator.userAgent))try{window.location=f?.redirectTo}catch{window.location=f?.redirectTo}else window.open(f?.redirectTo,"_blank"),d("/")},1e3):d(f?.redirectTo)),f?.redirectTo&&r&&r()},[f]);const Z=()=>c.require_subscriber_approval?n("notifications.subscribe.require_approval"):c.double_opt_required?n("notifications.subscribe.confirm"):n("notifications.subscribe.subscribed"),z=(g,D)=>{if(g.preventDefault(),c?.enable_signup_confirmation&&!I){H.error("Accept ToU & Privacy Policy.");return}const b=new FormData(g.currentTarget),B=b.get("visit_token"),ee=b.get("ref"),G=C?.trim();if(b.set("is_js_enabled","true"),b.set("accepted_tos",String(I)),b.set("email",G),!G){H.error("Please enter a valid email address");return}!B&&w&&b.set("visit_token",w),!ee&&l&&b.set("ref",l),D&&b.set("premium_offer_id",D),R.submit(b,{method:"post",action:"/create"})};return ie&&!le?null:e.jsx("div",{className:"flex w-full flex-col items-center",children:e.jsxs(R.Form,{ref:M,method:"post",action:"/create",className:"group w-full rounded-wt bg-transparent",onSubmit:g=>z(g,a),children:[e.jsx(Ae,{visitToken:w,referralId:l,boostAffiliateRecommendingPublicationId:E}),e.jsx("input",{name:"redirect_path",type:"hidden",value:V}),e.jsx("input",{name:"sent_from_orchid",type:"hidden",value:"true"}),e.jsx("input",{name:"fallback_path",type:"hidden",value:v}),e.jsx("input",{name:"double_opt",type:"hidden",value:O.toString()}),e.jsx("input",{name:"trigger_redirect",type:"hidden",value:P.toString()}),e.jsx(pe,{name:"subscribe",successMessage:Z(),errorMessage:n("errors.default")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx(Ie,{email:C,setEmail:F,onEmailChange:o,isSubmitting:$,autoFocus:s,children:i}),c?.enable_signup_confirmation&&e.jsxs("div",{className:"mt-3 flex flex-row space-x-2",children:[e.jsx("input",{type:"checkbox",className:"text-lp-main-signup-cta-color h-4 w-4 rounded border-gray-300 focus:ring-indigo-500",checked:I,onChange:()=>U(!I)}),!c?.terms_of_service||c?.terms_of_service.length==0?e.jsxs("p",{className:"text-xs font-medium",style:{color:m},children:[n("shared.cta.gdpr_signup_consent")," ",e.jsx("a",{href:"https://www.beehiiv.com/tou",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:n("footer.terms_of_use")})," ",n("shared.cta.and")," ",e.jsx("a",{href:"https://www.beehiiv.com/privacy",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:n("footer.privacy_policy")}),"."]}):e.jsxs("p",{className:"text-xs font-medium",style:{color:m},children:[n("shared.cta.gdpr_signup_consent")," ",n("shared.cta.sign_up")," ",e.jsx("a",{href:"/tos",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:n("meta.titles.tos")}),"."]})]})]})]})})};function De({title:t,titleId:o,...r},s){return u.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:s,"aria-labelledby":o},r),t?u.createElement("title",{id:o},t):null,u.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 Be=u.forwardRef(De),te=({color:t,children:o,iconEnabled:r,className:s,style:a={}})=>e.jsxs("div",{className:N("flex w-full items-center",s),style:a,children:[r&&e.jsx("div",{className:"pl-2",style:{color:t},children:e.jsx(Be,{className:"h-6 w-6"})}),o]}),re=({backgroundColor:t,fontFamily:o,fontSize:r,textColor:s,autoFocus:a,placeholderText:i,setEmail:m,onEmailChange:n,className:d})=>{const{t:c}=Y();return e.jsx("input",{type:"email",name:"email",autoComplete:"email",autoFocus:a,required:!0,style:{...t&&{borderColor:t},...o&&{fontFamily:o},color:"#111827"},className:N("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":!r||r==="lg"},{"text-sm focus:text-sm active:text-sm":r==="sm"},d),onChange:p=>{m(p.target.value),n&&n(p.target.value)},placeholder:i||c("subscribe.email_placeholder")||""})},oe=({className:t,children:o,style:r={}})=>{const{classes:s}=Q();return e.jsx("div",{style:r,className:N("flex w-full flex-col items-center sm:flex-row",t,s.radius),children:o})},qe=t=>{switch(t){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"}},ne=({isSubmitting:t,ctaText:o,backgroundColor:r,fontFamily:s,fontSize:a,textColor:i,className:m,borderColor:n,shouldAdjustRadius:d=!1})=>{const{t:c}=Y(),{classes:p}=Q(),_=o||c("shared.cta.subscribe");return e.jsx("input",{type:"submit",value:t?`${c("shared.actions.submitting")}...`:_,style:{...r&&{backgroundColor:r},...i&&{color:i},...s&&{fontFamily:s},...n&&{borderColor:n}},className:N("cursor-pointer px-5 py-3 font-semibold","w-full sm:w-auto",{"text-lg focus:text-lg active:text-lg sm:text-lg":!a||a==="lg"},{"text-sm focus:text-sm active:text-sm":a==="sm"},d?p.radius:qe(p.radius),m),disabled:t})},Le=({signupStyles:t,isSubmitting:o,autoFocus:r,setEmail:s,onEmailChange:a})=>{const{fontFamily:i,fontSize:m,buttonFontFamily:n,buttonBgColor:d,buttonTextColor:c,placeholderBgColor:p,placeholderTextColor:_,buttonText:w,placeholderText:l,borderEnabled:v,borderColor:E,emailIconEnabled:T}=t;return e.jsxs(oe,{style:{backgroundColor:p,border:v?`2px solid ${E}`:"none"},className:"overflow-hidden p-1",children:[e.jsx(te,{color:d||"",style:{backgroundColor:p},iconEnabled:T,children:e.jsx(re,{fontFamily:i,fontSize:m,autoFocus:r,setEmail:s,onEmailChange:a,placeholderText:l,textColor:_})}),e.jsx(ne,{isSubmitting:o,fontFamily:n,fontSize:m,ctaText:w,backgroundColor:d,textColor:c})]})},Me=t=>{switch(t){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"}},Ue=({signupStyles:t,isSubmitting:o,autoFocus:r,setEmail:s,onEmailChange:a})=>{const{webTheme:i}=Q(),{fontFamily:m,buttonFontFamily:n,buttonBgColor:d,buttonTextColor:c,placeholderBgColor:p,placeholderTextColor:_,buttonText:w,placeholderText:l,borderEnabled:v,borderColor:E,emailIconEnabled:T}=t,C=Me(i.radius);return e.jsxs(oe,{style:{backgroundColor:p,border:v?`2px solid ${E}`:"none"},className:"overflow-hidden",children:[e.jsx(te,{color:d||"",style:{backgroundColor:p},iconEnabled:T,children:e.jsx(re,{fontFamily:m,autoFocus:r,setEmail:s,onEmailChange:a,placeholderText:l,textColor:_})}),e.jsx(ne,{isSubmitting:o,fontFamily:n,ctaText:w,backgroundColor:d,textColor:c,className:C,shouldAdjustRadius:!0})]})},$e=({signupStyles:t,isSubmitting:o,autoFocus:r,setEmail:s,onEmailChange:a})=>{const{classes:i}=Q(),{fontFamily:m,buttonFontFamily:n,buttonBgColor:d,buttonTextColor:c,placeholderBgColor:p,placeholderTextColor:_,buttonText:w,placeholderText:l,borderEnabled:v,borderColor:E,emailIconEnabled:T}=t;return e.jsxs(oe,{className:"gap-2 overflow-hidden",children:[e.jsx(te,{color:d,iconEnabled:T,className:N(i.radius),style:{backgroundColor:p,border:v?`2px solid ${E}`:"none"},children:e.jsx(re,{fontFamily:m,autoFocus:r,setEmail:s,onEmailChange:a,placeholderText:l,textColor:_,className:"py-3"})}),e.jsx("div",{className:N("w-full sm:w-auto",i.radius),style:{backgroundColor:v?d:"",border:v?`2px solid ${d}`:"none"},children:e.jsx(ne,{isSubmitting:o,fontFamily:n,ctaText:w,backgroundColor:d,textColor:c})})]})},We=t=>!t||!["template-1","template-2","template-3"].includes(t)?"template-1":t,Ve=({signupStyles:t})=>{const o=We(t?.template),r={"template-1":Le,"template-2":Ue,"template-3":$e}[o],{isSubmitting:s,autoFocus:a,email:i,setEmail:m,onEmailChange:n}=Fe();return e.jsx(r,{signupStyles:t,autoFocus:a,isSubmitting:s,email:i,setEmail:m,onEmailChange:n})},nt=({signupStyles:t,type:o,premiumOfferId:r,onEmailChange:s,onSuccess:a,autoFocus:i})=>t?e.jsx(Oe,{type:o,premiumOfferId:r,onEmailChange:s,onSuccess:a,autoFocus:i,bodyTextColor:t.bodyTextColor,children:e.jsx(Ve,{signupStyles:t})}):null,de={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 Ge=(t=>(t.POPUP="popup",t.GATED="gated",t.FORM="form",t.NONE="none",t))(Ge||{});const Je=({visitToken:t,referralId:o,boostAffiliateRecommendingPublicationId:r})=>e.jsx(ve,{fallback:e.jsx(e.Fragment,{}),children:()=>e.jsxs(e.Fragment,{children:[e.jsx("input",{hidden:!0,name:"ref",value:o||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"bhba",value:r||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"visit_token",value:t||"",onChange:()=>null})]})}),st=({type:t="none",cta:o,publication:r,onEmailChange:s,onSuccess:a,isCustomLPTheme:i=!1,placeholderText:m,fontFamily:n,backgroundColor:d,textColor:c,autoFocus:p=!1,premiumOfferId:_,buttonPlacement:w="inline"})=>{const{t:l}=Y(),v=ue(),{setCookie:E,cookies:T,visitToken:C,referralId:F,currentPath:M}=fe(),I=we(T[_e]||void 0),{pathname:U}=me(),[R,f]=he(),$=u.useRef(null),q=w==="bottom",[k,S]=u.useState(!1),P=be(),h=P.data,W=P.state==="submitting",A=r.web_template.signup_flow.filter(({enabled:x})=>x),y=A[0],V=A.length>0&&A?.[0]?.managed_type!=="custom",X=!!y&&!y.full_url.startsWith(r.url),O=t==="popup"||t==="gated"||t==="form",Z=u.useMemo(()=>{if(O)return U;if(y){const x=y.href.split("?"),J=x[0],j=x[1]||"",K=new URLSearchParams(j);return K.set("email",R),`${J}?${K.toString()}`}return"/"},[y,U,R,O]),z=o||r.cta_text,{double_opt_required:g,has_referral_program:D,private:b,require_subscriber_approval:B}=r,ee=!!(g||D&&F);ge(h?.toast),u.useEffect(()=>{if(h?.toast?.status==="success"&&(E({name:"email_capture_disabled",value:"true",days:30}),$?.current?.reset()),h?.dataLayerEvent&&ye.pushEvent(h.dataLayerEvent),!O&&h?.redirectTo&&V){const x={startedAt:new Date().toISOString(),currentIndex:0,nextIndex:1,redirects:A};localStorage.setItem(xe.SIGNUP_REDIRECTS,JSON.stringify(x))}!O&&h?.redirectTo&&(y&&X?setTimeout(()=>{if(je(navigator.userAgent))try{window.location=h?.redirectTo}catch{window.location=h?.redirectTo}else window.open(h?.redirectTo,"_blank"),v("/")},1e3):v(h?.redirectTo)),h?.redirectTo&&a&&a()},[h]);const G=()=>r.require_subscriber_approval?l("notifications.subscribe.require_approval"):r.double_opt_required?l("notifications.subscribe.confirm"):l("notifications.subscribe.subscribed"),Ce=(x,J)=>{if(x.preventDefault(),r?.enable_signup_confirmation&&!k){H.error("Accept ToU & Privacy Policy.");return}const j=new FormData(x.currentTarget),K=j.get("visit_token"),Ne=j.get("ref"),ce=R?.trim();if(j.set("is_js_enabled","true"),j.set("accepted_tos",String(k)),j.set("email",ce),!ce){H.error("Please enter a valid email address");return}!K&&C&&j.set("visit_token",C),!Ne&&F&&j.set("ref",F),J&&j.set("premium_offer_id",J),P.submit(j,{method:"post",action:"/create"})};return b&&!B?null:e.jsx("div",{className:"flex w-full flex-col items-center space-y-4",children:e.jsxs(P.Form,{ref:$,method:"post",action:"/create",className:"group w-full rounded-wt bg-transparent",onSubmit:x=>Ce(x,_),children:[e.jsx(Je,{visitToken:C,referralId:F,boostAffiliateRecommendingPublicationId:I}),e.jsx("input",{name:"redirect_path",type:"hidden",value:Z}),e.jsx("input",{name:"sent_from_orchid",type:"hidden",value:"true"}),e.jsx("input",{name:"fallback_path",type:"hidden",value:M}),e.jsx("input",{name:"double_opt",type:"hidden",value:ee.toString()}),e.jsx("input",{name:"trigger_redirect",type:"hidden",value:V.toString()}),e.jsx(pe,{name:"subscribe",successMessage:G(),errorMessage:l("errors.default")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:N("w-full sm:mx-auto sm:flex",q?"flex flex-col items-center space-y-4":""),children:[e.jsx("div",{className:"w-full",children:e.jsx("input",{type:"email",name:"email",autoComplete:"email",autoFocus:p,required:!0,style:{...d&&{borderColor:d}},className:N(n?de[n]:"wt-button-font",i?"border-lp-main-signup-bg-color focus:border-lp-main-signup-bg-color":"border-wt-primary focus:border-wt-primary",q?"":"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=>{f(x.target.value),s&&s(x.target.value)},placeholder:m||l("subscribe.email_placeholder")||""})}),e.jsx("div",{className:N("mt-2 sm:mt-0",q?"w-full":""),children:e.jsx("input",{type:"submit",value:W?`${l("shared.actions.submitting")}...`:z,style:{...d&&{backgroundColor:d},...c&&{color:c}},className:N(n?de[n]:"wt-button-font",i?"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",q?"":"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:W})})]}),r?.enable_signup_confirmation&&e.jsxs("div",{className:"mt-3 flex flex-row space-x-2",children:[e.jsx("input",{type:"checkbox",className:"text-lp-main-signup-cta-color h-4 w-4 rounded border-gray-300 focus:ring-indigo-500",checked:k,onClick:()=>S(!k)}),!r?.terms_of_service||r?.terms_of_service.length==0?e.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[l("shared.cta.gdpr_signup_consent")," ",e.jsx("a",{href:"https://www.beehiiv.com/tou",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:l("footer.terms_of_use")})," ",l("shared.cta.and")," ",e.jsx("a",{href:"https://www.beehiiv.com/privacy",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:l("footer.privacy_policy")}),"."]}):e.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[l("shared.cta.gdpr_signup_consent")," ",l("shared.cta.sign_up")," ",e.jsx("a",{href:"/tos",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:l("meta.titles.tos")}),"."]})]})]})]})})};export{_e as B,st as C,nt as S,Ge as a,ot as b,ve as c};
//# sourceMappingURL=CreateAction-yeGKGPTV.js.map

//# debugId=d07174c7-371d-5407-91a7-bf9831209038
