@tryghost/portal 2.66.0 → 2.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/portal",
3
- "version": "2.66.0",
3
+ "version": "2.66.1",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/TryGhost/Ghost",
6
6
  "author": "Ghost Foundation",
package/umd/portal.min.js CHANGED
@@ -3223,7 +3223,9 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
3223
3223
  .gh-portal-popup-wrapper.full-size .gh-portal-popup-container.preview.account-plan {
3224
3224
  max-width: 420px;
3225
3225
  width: auto;
3226
+ height: auto;
3226
3227
  margin: 3.2vw auto 0;
3228
+ padding-bottom: 24px;
3227
3229
  transform: scale(0.9);
3228
3230
  }
3229
3231
  }
@@ -3558,5 +3560,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
3558
3560
  .gh-portal-hide {
3559
3561
  display: none;
3560
3562
  }
3561
- `;function sP({site:e}){return dd+iP+Z$+P1+Y1+g1()+J$+W$+q$+ib+PT+bT+AT()+Sd+zT+oP+rP+MT+UT+BT+HT+WT+qT+QT+nP}const gm=class gm extends Z.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Gs({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:o}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:o,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:f("jamie@example.com"),label:f("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=f(a?"Sending login link...":"Continue");const o=!!a;return t==="signin:failed"&&(i=f("Retry"),n=!0),u.jsx(fe,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:r=>this.handleSignin(r),disabled:o,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:f("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:f("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=As({site:t})&&Xt({site:t});return Pn({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ws,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:f("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):Pn({site:t})?null:u.jsx(Ub,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return Pn({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:f("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(we,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};gm.contextType=_;let Qd=gm;const lP=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:f("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:f("Contact support")})})})})]})},uP=()=>{const{member:e,brandColor:t}=w.useContext(_),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(cd,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:f("Your account")})]})},cP=()=>{const{site:e,action:t,brandColor:n,doAction:a}=w.useContext(_);if(!As({site:e})||!Xt({site:e}))return null;const i=["checkoutPlan:running"].includes(t),o=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(fe,{dataTestId:"view-plans",isRunning:i,label:f("View plans"),onClick:()=>o(),brandColor:n,style:{width:"100%"}})},dP=()=>{const{member:e,site:t}=w.useContext(_),{is_stripe_configured:n}=t;if(!n||Ka({site:t}))return null;const a=rt({member:e}),i=Tn({member:e});if(i&&!a)return null;if(a){const o=a==null?void 0:a.current_period_end;if(i&&pd({member:e})){const r=pd({member:e}),s=Dt(r);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(fd({sub:a})){const r=Dt(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will start on {subscriptionStart}",{subscriptionStart:r})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will renew on {renewalDate}",{renewalDate:Dt(o)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(cP,{})]})},mP=()=>{const{member:e,doAction:t,action:n,brandColor:a}=w.useContext(_),i=rt({member:e});if(!i||!i.cancel_at_period_end)return null;const o=f("Resume subscription"),r=["continueSubscription:running"].includes(n),s=!!r,l=Dt(i.current_period_end);return u.jsx("div",{className:"gh-portal-cancelcontinue-container",children:u.jsxs("div",{className:"gh-portal-cancel-banner",children:[u.jsx("p",{children:u.jsx(Oe,{string:f("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:u.jsx("strong",{children:l})}})}),u.jsx(fe,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:r,disabled:s,isPrimary:!0,brandColor:a,label:o,style:{width:"100%"}})]})})},pP=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("defs",null,w.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),w.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),w.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),hP=()=>{const{member:e,site:t,doAction:n}=w.useContext(_),a=()=>{const d=rt({member:e});n("manageBilling",{subscriptionId:d.id})},i=()=>{const{is_stripe_configured:d}=t;d&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},o=({price:d,isComplimentary:h,subscription:b})=>{const{next_payment:v}=b||{};let g="";if(d){const{amount:C=0,currency:N,interval:I}=d;g=`${Intl.NumberFormat("en",{currency:N,style:"currency"}).format(C/100)}/${f(I)}`}const y=pd({member:e});h&&(y?g=`${f("Complimentary")} - ${f("Expires {expiryDate}",{expiryDate:y})}`:g=g?`${f("Complimentary")} (${g})`:f("Complimentary"));let k="";if(fd({sub:b}))return k="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:k,children:g}),u.jsx(fP,{subscription:b})]});let E=gP({nextPayment:v,currentPeriodEnd:b==null?void 0:b.current_period_end});E&&(k="gh-portal-account-old-price");const z=()=>E?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(pP,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:E})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:k,children:g}),u.jsx(z,{})]})},r=({isPaid:d})=>Ka({site:t})&&!d?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:h=>i(),"data-test-button":"change-plan",children:f("Change")}),s=({defaultCardLast4:d})=>{if(d){const h=`**** **** **** ${d}`;return u.jsx("p",{children:h})}return null},l=({defaultCardLast4:d,isComplimentary:h})=>{const{action:b}=w.useContext(_),v=b==="manageBilling:running"?u.jsx(Ja,{className:"gh-portal-billing-button-loader"}):f("Update");return h?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:d})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>a(),"data-test-button":"manage-billing",children:v})]})},c=rt({member:e}),m=Tn({member:e}),p=Mt({member:e});if(c||m){const{price:d,default_payment_card_last4:h}=c||{};let b=f("Plan");return Ds({site:t})&&sb({member:e})&&(b=sb({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsxs("h3",{children:[b,(c==null?void 0:c.cancel_at_period_end)&&u.jsx("span",{className:"gh-portal-canceled-badge",children:f("Canceled")})]}),u.jsx(o,{price:d,isComplimentary:m,subscription:c})]}),u.jsx(r,{isPaid:p})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:h})]})}return null};function fP({subscription:e}){if(fd({sub:e})){const t=Dt(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:f("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function gP({nextPayment:e,currentPeriodEnd:t}){if(!e)return"";const n=e.discount;if(!n)return"";let a="";return n.duration==="forever"?a=f("Forever"):n.duration==="repeating"&&n.end?a=f("Ends {offerEndDate}",{offerEndDate:Dt(n.end)}):n.duration==="once"&&t&&(a=f("Ends {offerEndDate}",{offerEndDate:Dt(t)})),`${`${Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100)}/${f(e.interval)}`}${a?` — ${a}`:""}`}function yP(){const{member:e,site:t,doAction:n}=w.useContext(_);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let o=f(i?"Subscribed":"Unsubscribed");const r=s=>{var m;s.preventDefault();const l=Xn({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:f("Email newsletter")}),u.jsxs("p",{children:[o," ",gd({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:f("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Bs,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{r(s)},checked:i})})]})}const dk=e=>w.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},w.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),w.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function bP(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(dk,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:f("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:f("You're currently not receiving emails")})]})}function kP(){const{doAction:e,member:t,site:n}=w.useContext(_),a=cb({member:t}),i=So({site:n}),o=Ms({site:n}),r=a?"emailSuppressed":"accountEmail",s=!i&&!o,l=()=>a||s?u.jsx(bP,{}):u.jsx("p",{children:f("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:r,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:f("Manage")})]})}const vP=()=>{const{member:e,site:t}=w.useContext(_),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,o=e==null?void 0:e.uuid,r=gb(),[s,l]=w.useState(r&&i);return w.useEffect(()=>{if(r){l(i);return}if(!i||!o){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const p=await fetch(`https://partner.transistor.fm/ghost/member/${o}`,{signal:c.signal});if(p.ok){const d=await p.json();c.signal.aborted||l((d==null?void 0:d.member)===!0)}}catch(p){if(c.signal.aborted)return;console.warn("Error in Transistor request",p)}})(),()=>c.abort()},[i,o,r]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:o,settings:a}}},wP=(e,t)=>xo({site:e})&&So({site:e})||Ms({site:e})||cb({member:t}),SP=e=>!xo({site:e})&&So({site:e})&&!Ms({site:e}),EP=()=>{const{member:e,doAction:t,site:n}=w.useContext(_),{name:a,email:i}=e,{transistor:o}=vP(),r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=wP(n,e),l=SP(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||f("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>r(),children:f("Edit")})]}),u.jsx(hP,{}),s&&u.jsx(kP,{}),l&&u.jsx(yP,{}),o.enabled&&u.jsx(aP,{hasPodcasts:o.hasPodcasts,memberUuid:o.memberUuid,settings:o.settings})]})})},xP=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(we,{}),u.jsx(uP,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(dP,{}),u.jsx(mP,{}),u.jsx(EP,{})]})]}),ym=class ym extends Z.Component{componentDidMount(){const{member:t,site:n}=this.context;Pn({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=Co({site:n});return!t||!Pn({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(xP,{}),u.jsx(lP,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ym.contextType=_;let Xd=ym;const bm=class bm extends Z.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Gs({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(r=>!!r).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=f("Save");this.context.action==="updateProfile:failed"&&(n=f("Retry"));const a=!!t;return u.jsx(fe,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:f("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:f("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(cd,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:f("Jamie Larson"),label:f("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:f("jamie@example.com"),label:f("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(o=>n.includes(o.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ws,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(we,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};bm.contextType=_;let em=bm;function CP(){const{brandColor:e,lastPage:t,doAction:n}=w.useContext(_);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:f("Email preferences")})]})}function jP({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Bs,{id:e.id,onToggle:(i,o)=>{let r=[];o?r=t.filter(s=>s.id!==e.id).concat(e):r=t.filter(s=>s.id!==e.id),n(r)},checked:a,dataTestId:"switch-input"})})]})}function $P({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=w.useContext(_),i=!!n;if(!t)return null;const o=async(r,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:f("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Comments")}),u.jsx("p",{children:f("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Bs,{id:"comments",onToggle:o,checked:i,dataTestId:"switch-input"})})]})}function TP({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=w.useContext(_),i=Xn({site:a});return n?i.map(o=>u.jsx(jP,{newsletter:o,subscribedNewsletters:e,setSubscribedNewsletters:t},o==null?void 0:o.id)):null}function PP({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:f("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function mk({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:o,isPaidMember:r,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:p,site:d}=w.useContext(_),h=!(n!=null&&n.length)&&(s&&!l||!s),v=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(we,{}),u.jsx(CP,{}),u.jsx(v,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(TP,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:g=>{let y=g.map(k=>({id:k.id}));a(y)}}),u.jsx($P,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(fe,{isRunning:!1,onClick:()=>{o()},disabled:h,brandColor:c,isPrimary:!1,label:f("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(gd({member:p})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(PP,{isPaid:r,site:d,subscribedNewsletters:n})}),gd({member:p})&&!h&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:f("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[f("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function zP(){const{member:e,doAction:t,site:n,pageData:a}=w.useContext(_);let i,o;a&&(i=a.newsletterUuid,o=a.action);const[r,s]=w.useState(!0),l=Xn({site:n}),c=So({site:n});w.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),w.useEffect(()=>{if(i&&o==="unsubscribe"){const g=e==null?void 0:e.newsletters.filter(y=>y.uuid!==i);h(g),s(!1),t("updateNewsletterPreference",{newsletters:g})}},[]);const m=()=>{if(a.comments&&b){const k=r?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${k}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const g=l==null?void 0:l.find(k=>k.uuid===a.newsletterUuid);if(!g)return null;const y=r?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${y}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:g==null?void 0:g.name})}})})})},p=[...(e==null?void 0:e.newsletters)||[]],[d,h]=w.useState(p),{comments_enabled:b}=n,{enable_comment_notifications:v}=e||{};return w.useEffect(()=>{h((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(mk,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:d,updateSubscribedNewsletters:g=>{h(g),t("updateNewsletterPreference",{newsletters:g}),t("showPopupNotification",{action:"updated:success",message:f("Email preferences updated.")})},updateCommentNotifications:async g=>{t("updateNewsletterPreference",{enableCommentNotifications:g})},unsubscribeAll:()=>{h([]),t("showPopupNotification",{action:"updated:success",message:f("Unsubscribed from all emails.")});const g={newsletters:[]};b&&(g.enableCommentNotifications=!1),t("updateNewsletterPreference",g)},isPaidMember:Mt({member:e}),isCommentsEnabled:b!=="off",enableCommentNotifications:v})}function IP(){const{site:e}=w.useContext(_),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function NP(){const{site:e}=w.useContext(_),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(IP,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function pk({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function AP(){const{site:e,api:t,pageData:n,member:a,doAction:i}=w.useContext(_),[o,r]=w.useState(),[s,l]=w.useState(!0),c=Xn({site:e}),m=c.filter(I=>I.subscribe_on_signup),[p,d]=w.useState(!1),[h,b]=w.useState(m),[v,g]=w.useState(!1),{comments_enabled:y}=e,{enable_comment_notifications:k=!1}=o||{},x=So({site:e}),E=async I=>{a?i("updateNewsletterPreference",{newsletters:I}):await pk({api:t,memberUuid:n.uuid,key:n.key,newsletters:I}),b(I);const $={action:"updated:success",message:f("Email preferences updated.")};i("showPopupNotification",$)},z=async I=>{let $;a?(await i("updateNewsletterPreference",{enableCommentNotifications:I}),$={...a,enable_comment_notifications:I}):$=await pk({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:I}),r($),i("showPopupNotification",{action:"updated:success",message:f("Comment preferences updated.")})},C=async()=>{let I;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),I={...a},I.newsletters=[],I.enable_comment_notifications=!1):I=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),b([]),r(I),i("showPopupNotification",{action:"updated:success",message:f("Unsubscribed from all emails.")})};if(w.useEffect(()=>{(async()=>{let I;try{I=await t.member.newsletters({uuid:n.uuid,key:n.key}),r(I??null),l(!1)}catch(V){console.error("[PORTAL] Error fetching member newsletters",V),r(null),l(!1);return}if(I===null)return;const $=(I==null?void 0:I.newsletters)||[];b($),(c==null?void 0:c.length)===1&&!y&&!n.newsletterUuid?await E([]):n.newsletterUuid?await E($==null?void 0:$.filter(V=>V.uuid!==n.newsletterUuid)):n.comments&&y&&await z(!1)})()},[y,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(Mo,{});if(!o)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(we,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(xd,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:f("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:f("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(fe,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:f("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!y&&!v)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(we,{}),u.jsx(NP,{}),u.jsx("h1",{className:"gh-portal-main-title",children:f("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(Oe,{string:f("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{g(!0)}})}})})]})]});const N=()=>{if(n.comments&&y){const V=p?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${V}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email})}})})})}const I=c==null?void 0:c.find(V=>V.uuid===n.newsletterUuid);if(!I)return null;const $=p?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${$}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email}),newsletterName:u.jsx("strong",{children:I==null?void 0:I.name})}})})})};return u.jsx(mk,{hasNewslettersEnabled:x,notification:N,subscribedNewsletters:h,updateSubscribedNewsletters:async I=>{await E(I),d(!0)},updateCommentNotifications:z,unsubscribeAll:async()=>{await C(),d(!0)},isPaidMember:(o==null?void 0:o.status)!=="free",isCommentsEnabled:y!=="off",enableCommentNotifications:k})}function DP(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=w.useContext(_);w.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(xo({site:i})||Ms({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:f("You have been successfully resubscribed")})):n("back"))},[a,n,i,f]);const o=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),r=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(we,{})]}),u.jsx(dk,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:f("Emails disabled")}),u.jsx("p",{children:f("You're not receiving emails because you either marked a recent message as spam, or because messages could not be delivered to your provided email address.")})]}),u.jsx(fe,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:r,disabled:o,brandColor:e,label:f("Re-enable emails"),isRunning:o})]})}function MP(){const{brandColor:e,doAction:t,site:n,pageData:a}=w.useContext(_),i=`mailto:${Co({site:n})}`,o=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!o&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(we,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:f("Why has my email been disabled?")}),u.jsx("p",{children:f("Newsletters can be disabled on your account for two reasons: A previous email was marked as spam, or attempting to send an email resulted in a permanent failure (bounce).")}),u.jsx("h4",{children:f("Spam complaints")}),u.jsx("p",{children:f("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:f("If the spam complaint was accidental, or you would like to begin receiving emails again, you can resubscribe to emails by clicking the button on the previous screen.")}),u.jsx("p",{children:f("Once resubscribed, if you still don't see emails in your inbox, check your spam folder. Some inbox providers keep a record of previous spam complaints and will continue to flag emails. If this happens, mark the latest newsletter as 'Not spam' to move it back to your primary inbox.")}),u.jsx("h4",{children:f("Permanent failure (bounce)")}),u.jsx("p",{children:f("When an inbox fails to accept an email it is commonly called a bounce. In many cases, this can be temporary. However, in some cases, a bounced email can be returned as a permanent failure when an email address is invalid or non-existent.")}),u.jsx("p",{children:f("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:f("If you would like to start receiving emails again, the best next steps are to check your email address on file for any issues and then click resubscribe on the previous screen.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:f("Need more help? Contact support")})})]})]})}function OP(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:o}=w.useContext(_),r=Co({site:n}),s=`mailto:${r}`,l=z$({site:n}),c=o&&o.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Za,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(we,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:f("Help! I'm not receiving emails")}),u.jsx("p",{children:f("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:f("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(Oe,{string:f("The email address we have for you is {memberEmail} — if that's not correct, you can update it in your <button>account settings area</button>."),mapping:{memberEmail:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:f("Check spam & promotions folders")}),u.jsx("p",{children:f(`Make sure emails aren't accidentally ending up in the Spam or Promotions folders of your inbox. If they are, click on "Mark as not spam" and/or "Move to inbox".`)}),u.jsx("h4",{children:f("Create a new contact")}),u.jsx("p",{children:u.jsx(Oe,{string:f("In your email client add {senderEmail} to your contacts list. This signals to your mail provider that emails sent from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(Oe,{string:f("Send an email to {senderEmail} and say hello. This can also help signal to your mail provider that emails to and from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Check with your mail provider")}),u.jsx("p",{children:u.jsx(Oe,{string:f("If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from {senderEmail}"),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Get in touch for help")}),u.jsx("p",{children:u.jsx(Oe,{string:f("If you've completed all these checks and you're still not receiving emails, you can reach out to get support by contacting {supportAddress}."),mapping:{supportAddress:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:r})}})})]})]})}const tm={signin:Qd,signup:Gd,accountHome:Xd,accountPlan:Md,accountProfile:em,accountEmail:zP,signupNewsletter:Fd,unsubscribe:AP,magiclink:Kd,loading:Mo,offer:Jd,feedback:LT,emailSuppressed:DP,emailSuppressionFAQ:MP,emailReceivingFAQ:OP,support:()=>{const[e,t]=w.useState(!0),[n,a]=w.useState(null),[i,o]=w.useState(null),{member:r,site:s}=w.useContext(_);return w.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,p=r?`${m}?action=support&success=true`:`${m}#/portal/support/success`,d=m,h=Zs({siteUrl:c});try{const b=await h.member.checkoutDonation({successUrl:p,cancelUrl:d,personalNote:f("Add a personal note")});b.url&&window.location.replace(b.url)}catch(b){b.type&&b.type==="DisabledFeatureError"?o(f("This site is not accepting payments at the moment.")):a(f("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(o(f("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(Mo,{})}):n?u.jsx(Zd,{error:n}):i?u.jsx(Zd,{error:i}):null},supportSuccess:GT,supportError:Zd,recommendations:tP},nm=function({page:e}){return Object.keys(tm).includes(e)?e:"signup"},hk=function({page:e}){return e.includes("account")},FP=function({page:e}){return e.includes("offer")},_P=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),km=class km extends Z.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(_P,{}),"Powered by Ghost"]})}};km.contextType=_;let Qs=km;const fk=()=>({modalContainer:{zIndex:"3999999",position:"fixed",left:"0",top:"0",width:"100%",height:"100%",overflow:"hidden"},frame:{common:{margin:"auto",position:"relative",padding:"0",outline:"0",width:"100%",opacity:"1",overflow:"hidden",height:"100%"}},page:{links:{width:"600px"}}});function RP({message:e}){return Ga()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const vm=class vm extends Z.Component{componentDidMount(){this.node&&!de(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&de(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;de(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;nm({page:t});const n=tm[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(qd,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,r=_s({site:a,pageQuery:n}).length;nm({page:t});const l={...fk().page[t]};let c="",m="regular",p="",d=t;switch(t){case"signup":p="Cookies must be enabled in your browser to sign up.";break;case"signin":p="Cookies must be enabled in your browser to sign in.";break;case"accountHome":d="account-home";break;case"accountProfile":d="account-profile";break;case"accountPlan":d="account-plan";break;default:p="Cookies must be enabled in your browser.",d=t;break}r>1&&!Ot({site:a})&&Xt({site:a,pageQuery:n})&&t==="signup"&&(d+=" full-size",m="full");const h=Eo({site:a});(h&&r>2||!h&&r>1)&&t==="accountPlan"&&(d+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(d+=" large-size");let b="gh-portal-popup-container";de(["preview"])&&(d+=" preview"),de(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),de(["dev"])&&(b+=" dev");const v=`${b} ${c} ${d}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+d,onClick:g=>this.handlePopupClose(g),children:[this.renderPopupNotification(),u.jsxs("div",{className:v,style:l,ref:g=>this.node=g,tabIndex:-1,children:[u.jsx(RP,{message:p}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+(de(["preview"])?"hidden ":"")+d,children:u.jsx(Qs,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+(de(["preview"])?"hidden ":"")+d,children:u.jsx(Qs,{})})]})}};vm.contextType=_;let am=vm;const wm=class wm extends Z.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=tm[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=sP({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=fk(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return de(["preview"])&&(i.modalContainer.zIndex="3999997"),de(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),de(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(ld,{style:r,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(am,{isMobile:o})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};wm.contextType=_;let im=wm;Xs({products:om({numOfProducts:1})});function Fe(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function YP(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Xs({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:o={monthly:5e3,yearly:15e4,currency:"USD"},products:r=om({numOfProducts:1}),portalProducts:s=r.map(V=>V.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:p="Free",freePriceDescription:d="Free preview",isStripeConfigured:h=!0,portalButton:b=!0,portalName:v=!0,portalButtonIcon:g="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:x="support@example.com",editorDefaultEmailRecipients:E="visibility",newsletters:z=[],posts:C=LP(),commentsEnabled:N,recommendations:I=[],recommendationsEnabled:$}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:o,products:r,portal_products:s,members_signup_access:m,free_price_name:p,free_price_description:d,is_stripe_configured:h,portal_button:b,portal_name:v,portal_plans:c,portal_button_icon:g,portal_button_signup_text:y,portal_button_style:k,members_support_address:x,comments_enabled:N!=="off",newsletters:z,recommendations:I,recommendations_enabled:!!$,editor_default_email_recipients:E,posts:C}}function gk({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:o="month",amount:r=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:p="active",tierId:d="",tierName:h="Basic",redemptionType:b="signup"}={}){return{id:`offer_${Fe()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:o,amount:r,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:p,tier:{id:`${d}`,name:h},redemption_type:b}}function xt({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:o="",subscribed:r=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:YP(),email:t,name:e,firstname:n,paid:i,subscribed:r,avatar_image:o,subscriptions:a,email_suppression:s,newsletters:l}}function LP({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(UP({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function UP({id:e=`post_${Fe()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function om({numOfProducts:e=3}={}){const n=[ei({name:"Bronze",description:"Access to all members articles",monthlyPrice:yt({interval:"month",amount:700}),yearlyPrice:yt({interval:"year",amount:7e3}),numOfBenefits:2}),ei({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:12e3}),numOfBenefits:3}),ei({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:yt({interval:"month",amount:18e3}),yearlyPrice:yt({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=yk({});return[...n,a]}function ei({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Fe()}`,monthlyPrice:i=yt(),yearlyPrice:o=yt({interval:"year"}),numOfBenefits:r=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:o,type:e,benefits:bk({numOfBenefits:r}),trial_days:s}}function yk({name:e="Free tier",description:t="Free tier description",id:n=`product_${Fe()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:bk({numOfBenefits:a})}}function bk({numOfBenefits:e}){const t=Fe();return[el({name:`Limited early adopter pricing #${t.substring(0,6)}`}),el({name:`Latest gear reviews #${t.substring(6,12)}`}),el({name:`Weekly email newsletter #${t.substring(12,18)}`}),el({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function el({id:e=`benefit_${Fe()}`,name:t="Benefit"}){return{id:e,name:t}}function yt({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:o=!0,id:r=`price_${Fe()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Fe()}`,stripe_product_id:`prod_${Fe()}`,type:"recurring"}}function ta({id:e=`sub_${Fe()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:o=a==="month"?"Monthly":"Yearly",cardLast4:r="4242",offer:s=HP,priceId:l=`price_${Fe()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:d=null,nextPayment:h=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${Fe()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Fe()}`,nickname:o,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:r,cancel_at_period_end:p,cancellation_reason:null,current_period_end:m,trial_end_at:d,next_payment:h,tier:b,price:{id:`stripe_price_${Fe()}`,price_id:l,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Fe()}`,product_id:`prod_${Fe()}`}}}}function kk(){const e=om({numOfProducts:1}),t=e.map(a=>a.id);return Xs({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}kk();const BP=Xs({products:[ei({numOfBenefits:2,type:"free"})]}),HP=gk({tierId:(xk=BP.products[0])==null?void 0:xk.id});xt(),xt({paid:!0,subscriptions:[ta()]}),xt({paid:!0,subscriptions:[]}),xt({paid:!0,subscriptions:[ta({amount:0})]}),xt({paid:!0,subscriptions:[ta({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),kk();const tl=[yk({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),ei({name:"The Blueprint",description:"",monthlyPrice:yt({interval:"month",amount:500}),yearlyPrice:yt({interval:"year",amount:5e3}),numOfBenefits:3}),ei({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:11e3}),numOfBenefits:4})],ti=Xs({title:"The Blueprint",description:"Thoughts, stories and ideas.",logo:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",accentColor:"#45C32E",url:"https://portal.localhost",plans:{monthly:5e3,yearly:15e4,currency:"USD"},products:tl,portalProducts:tl.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),vk=gk({tierId:(Ck=ti.products[1])==null?void 0:Ck.id}),Fo={free:xt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:xt({paid:!0,subscriptions:[ta({status:"active",currency:"USD",interval:"year",amount:5e3,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]}),complimentary:xt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:xt({paid:!0,subscriptions:[ta({amount:0})]}),preview:xt({paid:!0,subscriptions:[ta({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function VP(){var n;if(!tl||!tl[1])return null;let e=(n=ti==null?void 0:ti.products)==null?void 0:n[1].monthlyPrice,t=xt({paid:!0,subscriptions:[ta({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:ti,member:t}}function WP(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function GP({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function KP({state:e}){return{showPopup:!e.showPopup}}function qP({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function JP({state:e}){return e.lastPage?{page:e.lastPage}:wk({state:e})}function wk({state:e}){return md(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function ZP({data:e}){return{showNotification:!0,...e}}function QP(){return{showNotification:!1}}async function XP({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:le({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to log out, please try again")})}}}async function ez({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:o,inboxLinks:r}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...o?{otcRef:o}:{},inboxLinks:r,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:le({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Qt(a,f("Failed to log in, please try again"))})}}}function tz({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.inboxLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function nz({data:e,api:t}){var a;const n=f("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),o=await t.member.verifyOTC({...e,integrityToken:i});return o.redirectUrl?window.location.assign(o.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Qt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Qt(i,n)}}}async function az({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const p=await n.member.getIntegrityToken();({inboxLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:p,...e,name:s}))}else return i&&o?await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:o}=ea({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:m,pageData:{...t.pageData||{},email:(r||"").trim()}}}catch(a){const i=Qt(a,f("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:le({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function iz({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=ea({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:o,cadence:r,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:le({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to process checkout, please try again")})}}}async function oz({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:l}=ea({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:o,cancelAtPeriodEnd:r,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:le({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:f("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:le({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to update subscription, please try again")})}}}async function rz({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:le({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to cancel subscription, please try again")})}}}async function sz({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:le({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to cancel subscription, please try again")})}}}async function lz({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:le({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:le({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function uz({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:le({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to update billing information, please try again")})}}}async function cz({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:le({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to open billing portal, please try again")})}}}async function dz(){return{popupNotification:null}}async function mz({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:le({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function pz({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const o={};return a&&(o.newsletters=a),i!==void 0&&(o.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(o)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:le({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:f("Failed to update newsletter settings")})}}}async function hz({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:le({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:f("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:le({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:f("Your email has failed to resubscribe, please try again")})}}}async function fz({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const o="updateNewsletter:success";return{action:o,member:i,popupNotification:le({type:o,autoHide:!0,closeable:!0,state:t,status:"success",message:f("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:le({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:f("Failed to update newsletter settings")})}}}async function gz({data:e,state:t,api:n}){const{email:a}=e,i=$$({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(o){return{success:!1,error:o}}return null}async function yz({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if(P$({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function bz({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function kz({data:e,state:t,api:n}){const[a,i]=await Promise.all([yz({data:e,state:t,api:n}),gz({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:le({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:f("Check your inbox to verify email update")})};const o=a.success?f("Failed to send verification email"):f("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:le({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:o,state:t})}}else if(a){const o=a.success?"updateProfile:success":"updateProfile:failed",r=a.success?"success":"error",s=a.success?f("Account details updated successfully"):f("Failed to update account details");return{action:o,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:le({type:o,autoHide:a.success,closeable:!0,status:r,state:t,message:s})}}else if(i){const o=i.success?"updateProfile:success":"updateProfile:failed",r=i.success?"success":"error";let s="";return i.error?s=Qt(i.error,f("Failed to send verification email")):s=f("Check your inbox to verify email update"),{action:o,...i.success?{page:"accountHome"}:{},popupNotification:le({type:o,autoHide:i.success,closeable:!0,status:r,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:le({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:f("Account details updated successfully")})}}async function vz({data:{siteUrl:e},state:t}){const n=Zs({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=lb(),r=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:r,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:o,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function wz({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function Sz({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const Ez={togglePopup:KP,openPopup:qP,closePopup:wk,switchPage:GP,openNotification:ZP,closeNotification:QP,back:JP,signout:XP,signin:ez,startSigninOTCFromCustomForm:tz,verifyOTC:nz,signup:az,updateSubscription:oz,cancelSubscription:rz,continueSubscription:sz,applyOffer:lz,updateNewsletter:fz,updateProfile:kz,refreshMemberData:bz,clearPopupNotification:dz,editBilling:uz,manageBilling:cz,checkoutPlan:iz,updateNewsletterPreference:pz,showPopupNotification:mz,removeEmailFromSuppressionList:hz,oneClickSubscribe:vz,trackRecommendationClicked:wz,trackRecommendationSubscribed:Sz};async function xz({action:e,data:t,state:n,api:a}){const i=Ez[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Sk(e,t){e&&(e.innerText=t)}function Cz(e,t,n){t.classList.add("error");const a=f("There was an error sending the email, please try again");Sk(n,Qt(e,a))}async function jz({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var E,z;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=((E=t==null?void 0:t.dataset)==null?void 0:E.membersAutoredirect)||"true",m=s==null?void 0:s.value,p=((l==null?void 0:l.value)||"").trim()||void 0,d,h=[],b=[],v=e.target.querySelectorAll("input[data-members-label]")||[];for(let C=0;C<v.length;++C)h.push(v[C].value);let g=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let C=0;C<g.length;++C)b.push({name:g[C].value});t.dataset.membersForm&&(d=t.dataset.membersForm);const y=d==="signin"&&((z=t==null?void 0:t.dataset)==null?void 0:z.membersOtc)==="true";t.classList.add("loading");const k=jo(),x={email:m,emailType:d,labels:h,name:p,autoRedirect:c==="true"};y&&(x.includeOTC=!0),k&&(x.urlHistory=k),g.length>0?x.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(x.newsletters=[]);try{const N=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),I=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,integrityToken:N})});if(t.addEventListener("submit",i),t.classList.remove("loading"),I.ok){t.classList.add("success");let $;if(y)try{$=await I.clone().json()}catch{$=void 0}const V=$==null?void 0:$.otc_ref;if(V&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:V,inboxLinks:$==null?void 0:$.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const $=await Zt.fromApiResponse(I),V=Qt($,f("Failed to send magic link email"));Sk(n,V),t.classList.add("error")}}catch(C){Cz(C,t,n)}}function $z({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:o,clickHandler:r}){t.removeEventListener("click",r),e.preventDefault();let s=t.dataset.membersPlan,l=g$(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,p,d;c&&(p=new URL(c,window.location.href).href),m&&(d=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const h=o?{checkoutType:"upgrade"}:{},b=jo();return b&&(h.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:v,successUrl:p,cancelUrl:d,metadata:h})}).then(function(g){if(!g.ok)throw new Error(f("Could not create Stripe checkout session"));return g.json()})}).then(function(v){return v.url?window.location.assign(v.url):window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(v){console.error(v),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=v.message),t.classList.add("error")})}function Tz({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:o}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let l=s.querySelector("[data-members-error]");function c(m){jz({event:m,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:o})}s.addEventListener("submit",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let l=s.querySelector("[data-members-error]");function c(m){$z({el:s,event:m,errorEl:l,member:n,site:t,siteUrl:e,clickHandler:c})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersSuccess,m=s.dataset.membersCancel,p,d;c&&(p=new URL(c,window.location.href).href),m&&(d=new URL(m,window.location.href).href);function h(b){s.removeEventListener("click",h),b.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:v,successUrl:p,cancelUrl:d})}).then(function(g){if(!g.ok)throw new Error(f("Could not create Stripe checkout session"));return g.json()})}).then(function(v){return window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId})}).then(function(v){if(v.error)throw new Error(f(v.error.message))}).catch(function(v){console.error(v),s.addEventListener("click",h),s.classList.remove("loading"),l&&(l.innerText=v.message),s.classList.add("error")})}s.addEventListener("click",h)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersReturn,m;c&&(m=new URL(c,window.location.href).href);function p(d){s.removeEventListener("click",p),d.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(h){return h.ok?h.text():null}).then(function(h){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:h,returnUrl:m})}).then(function(b){if(!b.ok)throw new Error(f("Could not create Stripe billing portal session"));return b.json()})}).then(function(h){return window.location.assign(h.url)}).catch(function(h){console.error(h),s.addEventListener("click",p),s.classList.remove("loading"),l&&(l.innerText=h.message),s.classList.add("error")})}s.addEventListener("click",p)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function l(c){s.removeEventListener("click",l),c.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(m){m.ok?window.location.replace(e):(s.addEventListener("click",l),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",l)});const r=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(m){m.preventDefault();let p=s.dataset.membersCancelSubscription;if(r){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:p,action:"cancel"}});return}return s.removeEventListener("click",c),s.classList.remove("error"),s.classList.add("loading"),l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(d){return d.ok?d.text():null}).then(function(d){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:d,smart_cancel:!0})})}).then(function(d){d.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=f("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(m){s.removeEventListener("click",c),m.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let p=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(d){return d.ok?d.text():null}).then(function(d){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:d,cancel_at_period_end:!1})})}).then(function(d){d.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=f("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const Pz={showPopup:!0,site:ti,member:Fo.free,page:"accountEmail",...VP(),pageData:vk};function zz({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Zc,{children:t}):u.jsx(u.Fragment,{children:t})}class Iz extends Z.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,o;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(o=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:o.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin,this.state.reloadOnPopupClose&&window.location.reload())}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:r}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),Tz({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:ss})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,o=i&&i.dataset.portal,{page:r,pageQuery:s,pageData:l}=this.getPageFromLinkPath(o)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:r,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const o=this.state.showPopup?t:n,r=this.state.showPopup?n:t;i.classList.add(o),i.classList.remove(r)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:o,popupNotification:r,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";zs.changeLanguage(m);const p={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:o,pageData:c,popupNotification:r,dir:zs.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(p),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const d=document.querySelectorAll("[data-lexical-signup-form]");d.length>0&&d.forEach(h=>{h.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...o}=this.fetchDevData(),{site:r,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...p}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...r,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...o,...s,...p,...c}}fetchDevData(){return de(["dev"])&&!this.state.customSiteUrl?Pz:de(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,o,r;const n=new URLSearchParams(t),a={};for(let s of n.entries()){const l=s[0],c=decodeURIComponent(s[1]);l==="name"?a.name=c||"":l==="code"?a.code=c||"":l==="display_title"?a.display_title=c||"":l==="display_description"?a.display_description=c||"":l==="type"?a.type=c||"":l==="cadence"?a.cadence=c||"":l==="duration"?a.duration=c||"":l==="duration_in_months"&&!isNaN(Number(c))?a.duration_in_months=Number(c):l==="amount"&&!isNaN(Number(c))?a.amount=Number(c):l==="currency"?a.currency=c||"":l==="status"?a.status=c||"":l==="tier_id"?a.tier={id:c||vk.tier.id}:l==="redemption_type"&&(a.redemption_type=c||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=Fo.preview)==null?void 0:i.subscriptions)==null?void 0:o[0])==null?void 0:r.id;return{page:"accountPlan",offers:[a],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let o,r=null,s,l,c;for(let m of n.entries()){const p=m[0],d=decodeURIComponent(m[1]);if(p==="button")a.site.portal_button=JSON.parse(d);else if(p==="name")a.site.portal_name=JSON.parse(d);else if(p==="isFree"&&JSON.parse(d))i.push("free");else if(p==="isMonthly"&&JSON.parse(d))i.push("monthly");else if(p==="isYearly"&&JSON.parse(d))i.push("yearly");else if(p==="portalPrices")o=d?d.split(","):[];else if(p==="portalProducts")r=d?d.split(","):[];else if(p==="page"&&d)a.page=d;else if(p==="accentColor"&&(d===""||d))a.site.accent_color=d;else if(p==="buttonIcon"&&d)a.site.portal_button_icon=d;else if(p==="signupButtonText")a.site.portal_button_signup_text=d||"";else if(p==="signupTermsHtml")a.site.portal_signup_terms_html=d||"";else if(p==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(d);else if(p==="buttonStyle"&&d)a.site.portal_button_style=d;else if(p==="monthlyPrice"&&!isNaN(Number(d)))a.site.plans.monthly=Number(d),s=Number(d);else if(p==="yearlyPrice"&&!isNaN(Number(d)))a.site.plans.yearly=Number(d),l=Number(d);else if(p==="currency"&&d){const h=d.toUpperCase();a.site.plans.currency=h,a.site.plans.currency_symbol=ve(h),c=h}else p==="disableBackground"?a.site.disableBackground=JSON.parse(d):p==="membersSignupAccess"&&d?a.site.members_signup_access=d:p==="portalDefaultPlan"&&d?a.site.portal_default_plan=d:p==="transistorPortalSettings"&&d&&(a.site.transistor_portal_settings=JSON.parse(d))}return a.site.portal_plans=i,a.site.portal_products=r,o?a.site.portal_plans=o:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:o}=wb({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:le({type:t,status:n,duration:a,closeable:o,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(k$({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,o]=window.location.hash.substr(1).split("?"),r=new URLSearchParams(o??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,p=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&p.test(i)){const[,d,h]=i.match(p),b=parseInt(h);if(b===1||b===0)return n||r.get("uuid")&&r.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:r.get("uuid"),key:n?null:r.get("key"),postId:d,score:b}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${d}/${b}/`}}}if(i&&m.test(i)){const[,d]=i.match(m),{page:h,pageQuery:b,pageData:v}=this.getPageFromLinkPath(d,t)||{};if(!n&&h&&hk({page:h}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${d}/`}};const g=["accountPlan","accountProfile"].includes(h)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(b)||s.test(b)||l.test(b)||c.test(b)),...h?{page:h}:{},...b?{pageQuery:b}:{},...v?{pageData:v}:{},...g?{lastPage:g}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(de(["preview"])){let n={};return de(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Zs({siteUrl:t,apiUrl:a,apiKey:i});const{site:o,member:r,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(o.accent_color=l),this.setupFirstPromoter({site:o,member:r}),this.setupSentry({site:o}),{site:o,member:r,offers:s}}catch(o){if(de(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(de(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.66.0|ghost@${i}`;n&&n.dsn&&Wj({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>u$({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(de(["test"]))return null;const a=T$({site:t});let i=yd({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://cdn.firstpromoter.com/fprom.js",o.onload=o.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),R$({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.push(["uid",c])}}}catch{}};const r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(o,r)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await xz({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=le({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:Qt(a,f("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(this.state.site,this.state.member),o={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:o.site,pageQuery:o.pageQuery}),this.setState(o)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(md(),!Mt({member:a})||Tn({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||fb({offer:r})||!A$({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=qa({site:t,productId:r.tier.id}),l=r.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=ea({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=ea({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let o=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}pb({site:t,pageQuery:n})&&(o=pb({site:t,pageQuery:n}));const r=y$({site:t,priceId:o});if(n&&n!=="free"){md();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=ea({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,o=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(o.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,r]=t.match(a);return{page:"signup",pageQuery:`${r}/monthly`}}else if(i.test(t)){const[,r]=t.match(i);return{page:"signup",pageQuery:`${r}/yearly`}}else if(n.test(t)){const[,r]=t.match(n);return{page:"signup",pageQuery:r}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return yT(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ot({site:t})||!Xt({site:t})?"signin":"signup";n=a?"accountHome":i}return nm({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return de(["dev","preview"],{customSiteUrl:a})?hk({page:t})||FP({page:t})?de(["dev"],{customSiteUrl:a})?n||Fo.free:de(["preview"])?Fo.preview:Fo.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:o,page:r,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:p,customSiteUrl:d,dir:h,scrollbarWidth:b,otcRef:v,inboxLinks:g}=this.state,y=this.getContextPage({site:t,page:r,member:n}),k=this.getContextMember({page:y,member:n,customSiteUrl:d});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:y,pageQuery:c,pageData:m,member:k,lastPage:s,showPopup:l,popupNotification:p,customSiteUrl:d,dir:h,scrollbarWidth:b,otcRef:v,inboxLinks:g,doAction:(x,E)=>this.dispatchAction(x,E)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(WP)}render(){return this.state.initStatus==="success"?u.jsx(zz,{site:this.state.site,children:u.jsxs(_.Provider,{value:this.getContextFromState(),children:[u.jsx(im,{}),u.jsx(wd,{}),u.jsx($d,{})]})}):null}}const Ek="ghost-portal-root";function Nz(){const e=document.createElement("div");e.id=Ek,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function Az(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,o=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:o}}return{}}function Dz(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function Mz(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=Az(),o=e||window.location.origin;Nz(),Dz(),tS.render(u.jsx(Z.StrictMode,{children:u.jsx(Iz,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Ek))}Mz()});
3563
+ `;function sP({site:e}){return dd+iP+Z$+P1+Y1+g1()+J$+W$+q$+ib+PT+bT+AT()+Sd+zT+oP+rP+MT+UT+BT+HT+WT+qT+QT+nP}const gm=class gm extends Z.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Gs({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:o}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:o,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:f("jamie@example.com"),label:f("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=f(a?"Sending login link...":"Continue");const o=!!a;return t==="signin:failed"&&(i=f("Retry"),n=!0),u.jsx(fe,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:r=>this.handleSignin(r),disabled:o,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:f("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:f("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=As({site:t})&&Xt({site:t});return Pn({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ws,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:f("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):Pn({site:t})?null:u.jsx(Ub,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return Pn({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:f("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(we,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};gm.contextType=_;let Qd=gm;const lP=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:f("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:f("Contact support")})})})})]})},uP=()=>{const{member:e,brandColor:t}=w.useContext(_),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(cd,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:f("Your account")})]})},cP=()=>{const{site:e,action:t,brandColor:n,doAction:a}=w.useContext(_);if(!As({site:e})||!Xt({site:e}))return null;const i=["checkoutPlan:running"].includes(t),o=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(fe,{dataTestId:"view-plans",isRunning:i,label:f("View plans"),onClick:()=>o(),brandColor:n,style:{width:"100%"}})},dP=()=>{const{member:e,site:t}=w.useContext(_),{is_stripe_configured:n}=t;if(!n||Ka({site:t}))return null;const a=rt({member:e}),i=Tn({member:e});if(i&&!a)return null;if(a){const o=a==null?void 0:a.current_period_end;if(i&&pd({member:e})){const r=pd({member:e}),s=Dt(r);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(fd({sub:a})){const r=Dt(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will start on {subscriptionStart}",{subscriptionStart:r})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("Your subscription will renew on {renewalDate}",{renewalDate:Dt(o)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:f("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(cP,{})]})},mP=()=>{const{member:e,doAction:t,action:n,brandColor:a}=w.useContext(_),i=rt({member:e});if(!i||!i.cancel_at_period_end)return null;const o=f("Resume subscription"),r=["continueSubscription:running"].includes(n),s=!!r,l=Dt(i.current_period_end);return u.jsx("div",{className:"gh-portal-cancelcontinue-container",children:u.jsxs("div",{className:"gh-portal-cancel-banner",children:[u.jsx("p",{children:u.jsx(Oe,{string:f("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:u.jsx("strong",{children:l})}})}),u.jsx(fe,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:r,disabled:s,isPrimary:!0,brandColor:a,label:o,style:{width:"100%"}})]})})},pP=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("defs",null,w.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),w.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),w.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),hP=()=>{const{member:e,site:t,doAction:n}=w.useContext(_),a=()=>{const d=rt({member:e});n("manageBilling",{subscriptionId:d.id})},i=()=>{const{is_stripe_configured:d}=t;d&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},o=({price:d,isComplimentary:h,subscription:b})=>{const{next_payment:v}=b||{};let g="";if(d){const{amount:C=0,currency:N,interval:I}=d;g=`${Intl.NumberFormat("en",{currency:N,style:"currency"}).format(C/100)}/${f(I)}`}const y=pd({member:e});h&&(y?g=`${f("Complimentary")} - ${f("Expires {expiryDate}",{expiryDate:y})}`:g=g?`${f("Complimentary")} (${g})`:f("Complimentary"));let k="";if(fd({sub:b}))return k="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:k,children:g}),u.jsx(fP,{subscription:b})]});let E=gP({nextPayment:v,currentPeriodEnd:b==null?void 0:b.current_period_end});E&&(k="gh-portal-account-old-price");const z=()=>E?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(pP,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:E})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:k,children:g}),u.jsx(z,{})]})},r=({isPaid:d})=>Ka({site:t})&&!d?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:h=>i(),"data-test-button":"change-plan",children:f("Change")}),s=({defaultCardLast4:d})=>{if(d){const h=`**** **** **** ${d}`;return u.jsx("p",{children:h})}return null},l=({defaultCardLast4:d,isComplimentary:h})=>{const{action:b}=w.useContext(_),v=b==="manageBilling:running"?u.jsx(Ja,{className:"gh-portal-billing-button-loader"}):f("Update");return h?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:d})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>a(),"data-test-button":"manage-billing",children:v})]})},c=rt({member:e}),m=Tn({member:e}),p=Mt({member:e});if(c||m){const{price:d,default_payment_card_last4:h}=c||{};let b=f("Plan");return Ds({site:t})&&sb({member:e})&&(b=sb({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsxs("h3",{children:[b,(c==null?void 0:c.cancel_at_period_end)&&u.jsx("span",{className:"gh-portal-canceled-badge",children:f("Canceled")})]}),u.jsx(o,{price:d,isComplimentary:m,subscription:c})]}),u.jsx(r,{isPaid:p})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:h})]})}return null};function fP({subscription:e}){if(fd({sub:e})){const t=Dt(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:f("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function gP({nextPayment:e,currentPeriodEnd:t}){if(!e)return"";const n=e.discount;if(!n)return"";let a="";return n.duration==="forever"?a=f("Forever"):n.duration==="repeating"&&n.end?a=f("Ends {offerEndDate}",{offerEndDate:Dt(n.end)}):n.duration==="once"&&t&&(a=f("Ends {offerEndDate}",{offerEndDate:Dt(t)})),`${`${Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100)}/${f(e.interval)}`}${a?` — ${a}`:""}`}function yP(){const{member:e,site:t,doAction:n}=w.useContext(_);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let o=f(i?"Subscribed":"Unsubscribed");const r=s=>{var m;s.preventDefault();const l=Xn({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:f("Email newsletter")}),u.jsxs("p",{children:[o," ",gd({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:f("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Bs,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{r(s)},checked:i})})]})}const dk=e=>w.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},w.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),w.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function bP(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(dk,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:f("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:f("You're currently not receiving emails")})]})}function kP(){const{doAction:e,member:t,site:n}=w.useContext(_),a=cb({member:t}),i=So({site:n}),o=Ms({site:n}),r=a?"emailSuppressed":"accountEmail",s=!i&&!o,l=()=>a||s?u.jsx(bP,{}):u.jsx("p",{children:f("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:r,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:f("Manage")})]})}const vP=()=>{const{member:e,site:t}=w.useContext(_),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,o=e==null?void 0:e.uuid,r=gb(),[s,l]=w.useState(r&&i);return w.useEffect(()=>{if(r){l(i);return}if(!i||!o){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const p=await fetch(`https://partner.transistor.fm/ghost/member/${o}`,{signal:c.signal});if(p.ok){const d=await p.json();c.signal.aborted||l((d==null?void 0:d.member)===!0)}}catch(p){if(c.signal.aborted)return;console.warn("Error in Transistor request",p)}})(),()=>c.abort()},[i,o,r]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:o,settings:a}}},wP=(e,t)=>xo({site:e})&&So({site:e})||Ms({site:e})||cb({member:t}),SP=e=>!xo({site:e})&&So({site:e})&&!Ms({site:e}),EP=()=>{const{member:e,doAction:t,site:n}=w.useContext(_),{name:a,email:i}=e,{transistor:o}=vP(),r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=wP(n,e),l=SP(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||f("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>r(),children:f("Edit")})]}),u.jsx(hP,{}),s&&u.jsx(kP,{}),l&&u.jsx(yP,{}),o.enabled&&u.jsx(aP,{hasPodcasts:o.hasPodcasts,memberUuid:o.memberUuid,settings:o.settings})]})})},xP=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(we,{}),u.jsx(uP,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(dP,{}),u.jsx(mP,{}),u.jsx(EP,{})]})]}),ym=class ym extends Z.Component{componentDidMount(){const{member:t,site:n}=this.context;Pn({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=Co({site:n});return!t||!Pn({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(xP,{}),u.jsx(lP,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ym.contextType=_;let Xd=ym;const bm=class bm extends Z.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Gs({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(r=>!!r).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=f("Save");this.context.action==="updateProfile:failed"&&(n=f("Retry"));const a=!!t;return u.jsx(fe,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:f("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:f("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(cd,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:f("Jamie Larson"),label:f("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:f("jamie@example.com"),label:f("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(o=>n.includes(o.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ws,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(we,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};bm.contextType=_;let em=bm;function CP(){const{brandColor:e,lastPage:t,doAction:n}=w.useContext(_);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:f("Email preferences")})]})}function jP({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Bs,{id:e.id,onToggle:(i,o)=>{let r=[];o?r=t.filter(s=>s.id!==e.id).concat(e):r=t.filter(s=>s.id!==e.id),n(r)},checked:a,dataTestId:"switch-input"})})]})}function $P({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=w.useContext(_),i=!!n;if(!t)return null;const o=async(r,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:f("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:f("Comments")}),u.jsx("p",{children:f("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Bs,{id:"comments",onToggle:o,checked:i,dataTestId:"switch-input"})})]})}function TP({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=w.useContext(_),i=Xn({site:a});return n?i.map(o=>u.jsx(jP,{newsletter:o,subscribedNewsletters:e,setSubscribedNewsletters:t},o==null?void 0:o.id)):null}function PP({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:f("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function mk({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:o,isPaidMember:r,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:p,site:d}=w.useContext(_),h=!(n!=null&&n.length)&&(s&&!l||!s),v=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(we,{}),u.jsx(CP,{}),u.jsx(v,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(TP,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:g=>{let y=g.map(k=>({id:k.id}));a(y)}}),u.jsx($P,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(fe,{isRunning:!1,onClick:()=>{o()},disabled:h,brandColor:c,isPrimary:!1,label:f("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(gd({member:p})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(PP,{isPaid:r,site:d,subscribedNewsletters:n})}),gd({member:p})&&!h&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:f("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[f("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function zP(){const{member:e,doAction:t,site:n,pageData:a}=w.useContext(_);let i,o;a&&(i=a.newsletterUuid,o=a.action);const[r,s]=w.useState(!0),l=Xn({site:n}),c=So({site:n});w.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),w.useEffect(()=>{if(i&&o==="unsubscribe"){const g=e==null?void 0:e.newsletters.filter(y=>y.uuid!==i);h(g),s(!1),t("updateNewsletterPreference",{newsletters:g})}},[]);const m=()=>{if(a.comments&&b){const k=r?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${k}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const g=l==null?void 0:l.find(k=>k.uuid===a.newsletterUuid);if(!g)return null;const y=r?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${y}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:g==null?void 0:g.name})}})})})},p=[...(e==null?void 0:e.newsletters)||[]],[d,h]=w.useState(p),{comments_enabled:b}=n,{enable_comment_notifications:v}=e||{};return w.useEffect(()=>{h((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(mk,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:d,updateSubscribedNewsletters:g=>{h(g),t("updateNewsletterPreference",{newsletters:g}),t("showPopupNotification",{action:"updated:success",message:f("Email preferences updated.")})},updateCommentNotifications:async g=>{t("updateNewsletterPreference",{enableCommentNotifications:g})},unsubscribeAll:()=>{h([]),t("showPopupNotification",{action:"updated:success",message:f("Unsubscribed from all emails.")});const g={newsletters:[]};b&&(g.enableCommentNotifications=!1),t("updateNewsletterPreference",g)},isPaidMember:Mt({member:e}),isCommentsEnabled:b!=="off",enableCommentNotifications:v})}function IP(){const{site:e}=w.useContext(_),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function NP(){const{site:e}=w.useContext(_),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(IP,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function pk({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function AP(){const{site:e,api:t,pageData:n,member:a,doAction:i}=w.useContext(_),[o,r]=w.useState(),[s,l]=w.useState(!0),c=Xn({site:e}),m=c.filter(I=>I.subscribe_on_signup),[p,d]=w.useState(!1),[h,b]=w.useState(m),[v,g]=w.useState(!1),{comments_enabled:y}=e,{enable_comment_notifications:k=!1}=o||{},x=So({site:e}),E=async I=>{a?i("updateNewsletterPreference",{newsletters:I}):await pk({api:t,memberUuid:n.uuid,key:n.key,newsletters:I}),b(I);const $={action:"updated:success",message:f("Email preferences updated.")};i("showPopupNotification",$)},z=async I=>{let $;a?(await i("updateNewsletterPreference",{enableCommentNotifications:I}),$={...a,enable_comment_notifications:I}):$=await pk({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:I}),r($),i("showPopupNotification",{action:"updated:success",message:f("Comment preferences updated.")})},C=async()=>{let I;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),I={...a},I.newsletters=[],I.enable_comment_notifications=!1):I=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),b([]),r(I),i("showPopupNotification",{action:"updated:success",message:f("Unsubscribed from all emails.")})};if(w.useEffect(()=>{(async()=>{let I;try{I=await t.member.newsletters({uuid:n.uuid,key:n.key}),r(I??null),l(!1)}catch(V){console.error("[PORTAL] Error fetching member newsletters",V),r(null),l(!1);return}if(I===null)return;const $=(I==null?void 0:I.newsletters)||[];b($),(c==null?void 0:c.length)===1&&!y&&!n.newsletterUuid?await E([]):n.newsletterUuid?await E($==null?void 0:$.filter(V=>V.uuid!==n.newsletterUuid)):n.comments&&y&&await z(!1)})()},[y,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(Mo,{});if(!o)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(we,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(xd,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:f("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:f("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(fe,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:f("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!y&&!v)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(we,{}),u.jsx(NP,{}),u.jsx("h1",{className:"gh-portal-main-title",children:f("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(Oe,{string:f("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{g(!0)}})}})})]})]});const N=()=>{if(n.comments&&y){const V=p?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${V}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email})}})})})}const I=c==null?void 0:c.find(V=>V.uuid===n.newsletterUuid);if(!I)return null;const $=p?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${$}`,children:u.jsx(Oe,{string:f("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:o==null?void 0:o.email}),newsletterName:u.jsx("strong",{children:I==null?void 0:I.name})}})})})};return u.jsx(mk,{hasNewslettersEnabled:x,notification:N,subscribedNewsletters:h,updateSubscribedNewsletters:async I=>{await E(I),d(!0)},updateCommentNotifications:z,unsubscribeAll:async()=>{await C(),d(!0)},isPaidMember:(o==null?void 0:o.status)!=="free",isCommentsEnabled:y!=="off",enableCommentNotifications:k})}function DP(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=w.useContext(_);w.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(xo({site:i})||Ms({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:f("You have been successfully resubscribed")})):n("back"))},[a,n,i,f]);const o=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),r=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(we,{})]}),u.jsx(dk,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:f("Emails disabled")}),u.jsx("p",{children:f("You're not receiving emails because you either marked a recent message as spam, or because messages could not be delivered to your provided email address.")})]}),u.jsx(fe,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:r,disabled:o,brandColor:e,label:f("Re-enable emails"),isRunning:o})]})}function MP(){const{brandColor:e,doAction:t,site:n,pageData:a}=w.useContext(_),i=`mailto:${Co({site:n})}`,o=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!o&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Za,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(we,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:f("Why has my email been disabled?")}),u.jsx("p",{children:f("Newsletters can be disabled on your account for two reasons: A previous email was marked as spam, or attempting to send an email resulted in a permanent failure (bounce).")}),u.jsx("h4",{children:f("Spam complaints")}),u.jsx("p",{children:f("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:f("If the spam complaint was accidental, or you would like to begin receiving emails again, you can resubscribe to emails by clicking the button on the previous screen.")}),u.jsx("p",{children:f("Once resubscribed, if you still don't see emails in your inbox, check your spam folder. Some inbox providers keep a record of previous spam complaints and will continue to flag emails. If this happens, mark the latest newsletter as 'Not spam' to move it back to your primary inbox.")}),u.jsx("h4",{children:f("Permanent failure (bounce)")}),u.jsx("p",{children:f("When an inbox fails to accept an email it is commonly called a bounce. In many cases, this can be temporary. However, in some cases, a bounced email can be returned as a permanent failure when an email address is invalid or non-existent.")}),u.jsx("p",{children:f("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:f("If you would like to start receiving emails again, the best next steps are to check your email address on file for any issues and then click resubscribe on the previous screen.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:f("Need more help? Contact support")})})]})]})}function OP(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:o}=w.useContext(_),r=Co({site:n}),s=`mailto:${r}`,l=z$({site:n}),c=o&&o.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Za,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(we,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:f("Help! I'm not receiving emails")}),u.jsx("p",{children:f("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:f("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(Oe,{string:f("The email address we have for you is {memberEmail} — if that's not correct, you can update it in your <button>account settings area</button>."),mapping:{memberEmail:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:f("Check spam & promotions folders")}),u.jsx("p",{children:f(`Make sure emails aren't accidentally ending up in the Spam or Promotions folders of your inbox. If they are, click on "Mark as not spam" and/or "Move to inbox".`)}),u.jsx("h4",{children:f("Create a new contact")}),u.jsx("p",{children:u.jsx(Oe,{string:f("In your email client add {senderEmail} to your contacts list. This signals to your mail provider that emails sent from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(Oe,{string:f("Send an email to {senderEmail} and say hello. This can also help signal to your mail provider that emails to and from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Check with your mail provider")}),u.jsx("p",{children:u.jsx(Oe,{string:f("If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from {senderEmail}"),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:f("Get in touch for help")}),u.jsx("p",{children:u.jsx(Oe,{string:f("If you've completed all these checks and you're still not receiving emails, you can reach out to get support by contacting {supportAddress}."),mapping:{supportAddress:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:r})}})})]})]})}const tm={signin:Qd,signup:Gd,accountHome:Xd,accountPlan:Md,accountProfile:em,accountEmail:zP,signupNewsletter:Fd,unsubscribe:AP,magiclink:Kd,loading:Mo,offer:Jd,feedback:LT,emailSuppressed:DP,emailSuppressionFAQ:MP,emailReceivingFAQ:OP,support:()=>{const[e,t]=w.useState(!0),[n,a]=w.useState(null),[i,o]=w.useState(null),{member:r,site:s}=w.useContext(_);return w.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,p=r?`${m}?action=support&success=true`:`${m}#/portal/support/success`,d=m,h=Zs({siteUrl:c});try{const b=await h.member.checkoutDonation({successUrl:p,cancelUrl:d,personalNote:f("Add a personal note")});b.url&&window.location.replace(b.url)}catch(b){b.type&&b.type==="DisabledFeatureError"?o(f("This site is not accepting payments at the moment.")):a(f("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(o(f("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(Mo,{})}):n?u.jsx(Zd,{error:n}):i?u.jsx(Zd,{error:i}):null},supportSuccess:GT,supportError:Zd,recommendations:tP},nm=function({page:e}){return Object.keys(tm).includes(e)?e:"signup"},hk=function({page:e}){return e.includes("account")},FP=function({page:e}){return e.includes("offer")},_P=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),km=class km extends Z.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(_P,{}),"Powered by Ghost"]})}};km.contextType=_;let Qs=km;const fk=()=>({modalContainer:{zIndex:"3999999",position:"fixed",left:"0",top:"0",width:"100%",height:"100%",overflow:"hidden"},frame:{common:{margin:"auto",position:"relative",padding:"0",outline:"0",width:"100%",opacity:"1",overflow:"hidden",height:"100%"}},page:{links:{width:"600px"}}});function RP({message:e}){return Ga()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const vm=class vm extends Z.Component{componentDidMount(){this.node&&!de(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&de(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;de(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;nm({page:t});const n=tm[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(qd,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,r=_s({site:a,pageQuery:n}).length;nm({page:t});const l={...fk().page[t]};let c="",m="regular",p="",d=t;switch(t){case"signup":p="Cookies must be enabled in your browser to sign up.";break;case"signin":p="Cookies must be enabled in your browser to sign in.";break;case"accountHome":d="account-home";break;case"accountProfile":d="account-profile";break;case"accountPlan":d="account-plan";break;default:p="Cookies must be enabled in your browser.",d=t;break}r>1&&!Ot({site:a})&&Xt({site:a,pageQuery:n})&&t==="signup"&&(d+=" full-size",m="full");const h=Eo({site:a});(h&&r>2||!h&&r>1)&&t==="accountPlan"&&(d+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(d+=" large-size");let b="gh-portal-popup-container";de(["preview"])&&(d+=" preview"),de(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),de(["dev"])&&(b+=" dev");const v=`${b} ${c} ${d}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+d,onClick:g=>this.handlePopupClose(g),children:[this.renderPopupNotification(),u.jsxs("div",{className:v,style:l,ref:g=>this.node=g,tabIndex:-1,children:[u.jsx(RP,{message:p}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+(de(["preview"])?"hidden ":"")+d,children:u.jsx(Qs,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+(de(["preview"])?"hidden ":"")+d,children:u.jsx(Qs,{})})]})}};vm.contextType=_;let am=vm;const wm=class wm extends Z.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=tm[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=sP({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=fk(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return de(["preview"])&&(i.modalContainer.zIndex="3999997"),de(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),de(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(ld,{style:r,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(am,{isMobile:o})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};wm.contextType=_;let im=wm;Xs({products:om({numOfProducts:1})});function Fe(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function YP(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Xs({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:o={monthly:5e3,yearly:15e4,currency:"USD"},products:r=om({numOfProducts:1}),portalProducts:s=r.map(V=>V.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:p="Free",freePriceDescription:d="Free preview",isStripeConfigured:h=!0,portalButton:b=!0,portalName:v=!0,portalButtonIcon:g="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:x="support@example.com",editorDefaultEmailRecipients:E="visibility",newsletters:z=[],posts:C=LP(),commentsEnabled:N,recommendations:I=[],recommendationsEnabled:$}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:o,products:r,portal_products:s,members_signup_access:m,free_price_name:p,free_price_description:d,is_stripe_configured:h,portal_button:b,portal_name:v,portal_plans:c,portal_button_icon:g,portal_button_signup_text:y,portal_button_style:k,members_support_address:x,comments_enabled:N!=="off",newsletters:z,recommendations:I,recommendations_enabled:!!$,editor_default_email_recipients:E,posts:C}}function gk({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:o="month",amount:r=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:p="active",tierId:d="",tierName:h="Basic",redemptionType:b="signup"}={}){return{id:`offer_${Fe()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:o,amount:r,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:p,tier:{id:`${d}`,name:h},redemption_type:b}}function xt({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:o="",subscribed:r=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:YP(),email:t,name:e,firstname:n,paid:i,subscribed:r,avatar_image:o,subscriptions:a,email_suppression:s,newsletters:l}}function LP({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(UP({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function UP({id:e=`post_${Fe()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function om({numOfProducts:e=3}={}){const n=[ei({name:"Bronze",description:"Access to all members articles",monthlyPrice:yt({interval:"month",amount:700}),yearlyPrice:yt({interval:"year",amount:7e3}),numOfBenefits:2}),ei({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:12e3}),numOfBenefits:3}),ei({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:yt({interval:"month",amount:18e3}),yearlyPrice:yt({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=yk({});return[...n,a]}function ei({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Fe()}`,monthlyPrice:i=yt(),yearlyPrice:o=yt({interval:"year"}),numOfBenefits:r=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:o,type:e,benefits:bk({numOfBenefits:r}),trial_days:s}}function yk({name:e="Free tier",description:t="Free tier description",id:n=`product_${Fe()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:bk({numOfBenefits:a})}}function bk({numOfBenefits:e}){const t=Fe();return[el({name:`Limited early adopter pricing #${t.substring(0,6)}`}),el({name:`Latest gear reviews #${t.substring(6,12)}`}),el({name:`Weekly email newsletter #${t.substring(12,18)}`}),el({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function el({id:e=`benefit_${Fe()}`,name:t="Benefit"}){return{id:e,name:t}}function yt({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:o=!0,id:r=`price_${Fe()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Fe()}`,stripe_product_id:`prod_${Fe()}`,type:"recurring"}}function ta({id:e=`sub_${Fe()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:o=a==="month"?"Monthly":"Yearly",cardLast4:r="4242",offer:s=HP,priceId:l=`price_${Fe()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:d=null,nextPayment:h=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${Fe()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Fe()}`,nickname:o,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:r,cancel_at_period_end:p,cancellation_reason:null,current_period_end:m,trial_end_at:d,next_payment:h,tier:b,price:{id:`stripe_price_${Fe()}`,price_id:l,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Fe()}`,product_id:`prod_${Fe()}`}}}}function kk(){const e=om({numOfProducts:1}),t=e.map(a=>a.id);return Xs({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}kk();const BP=Xs({products:[ei({numOfBenefits:2,type:"free"})]}),HP=gk({tierId:(xk=BP.products[0])==null?void 0:xk.id});xt(),xt({paid:!0,subscriptions:[ta()]}),xt({paid:!0,subscriptions:[]}),xt({paid:!0,subscriptions:[ta({amount:0})]}),xt({paid:!0,subscriptions:[ta({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),kk();const tl=[yk({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),ei({name:"The Blueprint",description:"",monthlyPrice:yt({interval:"month",amount:500}),yearlyPrice:yt({interval:"year",amount:5e3}),numOfBenefits:3}),ei({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:11e3}),numOfBenefits:4})],ti=Xs({title:"The Blueprint",description:"Thoughts, stories and ideas.",logo:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",accentColor:"#45C32E",url:"https://portal.localhost",plans:{monthly:5e3,yearly:15e4,currency:"USD"},products:tl,portalProducts:tl.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),vk=gk({tierId:(Ck=ti.products[1])==null?void 0:Ck.id}),Fo={free:xt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:xt({paid:!0,subscriptions:[ta({status:"active",currency:"USD",interval:"year",amount:5e3,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]}),complimentary:xt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:xt({paid:!0,subscriptions:[ta({amount:0})]}),preview:xt({paid:!0,subscriptions:[ta({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function VP(){var n;if(!tl||!tl[1])return null;let e=(n=ti==null?void 0:ti.products)==null?void 0:n[1].monthlyPrice,t=xt({paid:!0,subscriptions:[ta({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:ti,member:t}}function WP(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function GP({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function KP({state:e}){return{showPopup:!e.showPopup}}function qP({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function JP({state:e}){return e.lastPage?{page:e.lastPage}:wk({state:e})}function wk({state:e}){return md(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function ZP({data:e}){return{showNotification:!0,...e}}function QP(){return{showNotification:!1}}async function XP({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:le({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to log out, please try again")})}}}async function ez({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:o,inboxLinks:r}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...o?{otcRef:o}:{},inboxLinks:r,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:le({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Qt(a,f("Failed to log in, please try again"))})}}}function tz({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.inboxLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function nz({data:e,api:t}){var a;const n=f("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),o=await t.member.verifyOTC({...e,integrityToken:i});return o.redirectUrl?window.location.assign(o.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Qt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Qt(i,n)}}}async function az({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const p=await n.member.getIntegrityToken();({inboxLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:p,...e,name:s}))}else return i&&o?await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:o}=ea({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:m,pageData:{...t.pageData||{},email:(r||"").trim()}}}catch(a){const i=Qt(a,f("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:le({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function iz({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=ea({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:o,cadence:r,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:le({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to process checkout, please try again")})}}}async function oz({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:l}=ea({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:o,cancelAtPeriodEnd:r,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:le({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:f("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:le({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to update subscription, please try again")})}}}async function rz({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:le({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to cancel subscription, please try again")})}}}async function sz({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:le({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to cancel subscription, please try again")})}}}async function lz({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:le({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:le({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function uz({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:le({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to update billing information, please try again")})}}}async function cz({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:le({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:f("Failed to open billing portal, please try again")})}}}async function dz(){return{popupNotification:null}}async function mz({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:le({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function pz({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const o={};return a&&(o.newsletters=a),i!==void 0&&(o.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(o)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:le({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:f("Failed to update newsletter settings")})}}}async function hz({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:le({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:f("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:le({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:f("Your email has failed to resubscribe, please try again")})}}}async function fz({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const o="updateNewsletter:success";return{action:o,member:i,popupNotification:le({type:o,autoHide:!0,closeable:!0,state:t,status:"success",message:f("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:le({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:f("Failed to update newsletter settings")})}}}async function gz({data:e,state:t,api:n}){const{email:a}=e,i=$$({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(o){return{success:!1,error:o}}return null}async function yz({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if(P$({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function bz({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function kz({data:e,state:t,api:n}){const[a,i]=await Promise.all([yz({data:e,state:t,api:n}),gz({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:le({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:f("Check your inbox to verify email update")})};const o=a.success?f("Failed to send verification email"):f("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:le({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:o,state:t})}}else if(a){const o=a.success?"updateProfile:success":"updateProfile:failed",r=a.success?"success":"error",s=a.success?f("Account details updated successfully"):f("Failed to update account details");return{action:o,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:le({type:o,autoHide:a.success,closeable:!0,status:r,state:t,message:s})}}else if(i){const o=i.success?"updateProfile:success":"updateProfile:failed",r=i.success?"success":"error";let s="";return i.error?s=Qt(i.error,f("Failed to send verification email")):s=f("Check your inbox to verify email update"),{action:o,...i.success?{page:"accountHome"}:{},popupNotification:le({type:o,autoHide:i.success,closeable:!0,status:r,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:le({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:f("Account details updated successfully")})}}async function vz({data:{siteUrl:e},state:t}){const n=Zs({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=lb(),r=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:r,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:o,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function wz({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function Sz({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const Ez={togglePopup:KP,openPopup:qP,closePopup:wk,switchPage:GP,openNotification:ZP,closeNotification:QP,back:JP,signout:XP,signin:ez,startSigninOTCFromCustomForm:tz,verifyOTC:nz,signup:az,updateSubscription:oz,cancelSubscription:rz,continueSubscription:sz,applyOffer:lz,updateNewsletter:fz,updateProfile:kz,refreshMemberData:bz,clearPopupNotification:dz,editBilling:uz,manageBilling:cz,checkoutPlan:iz,updateNewsletterPreference:pz,showPopupNotification:mz,removeEmailFromSuppressionList:hz,oneClickSubscribe:vz,trackRecommendationClicked:wz,trackRecommendationSubscribed:Sz};async function xz({action:e,data:t,state:n,api:a}){const i=Ez[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Sk(e,t){e&&(e.innerText=t)}function Cz(e,t,n){t.classList.add("error");const a=f("There was an error sending the email, please try again");Sk(n,Qt(e,a))}async function jz({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var E,z;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=((E=t==null?void 0:t.dataset)==null?void 0:E.membersAutoredirect)||"true",m=s==null?void 0:s.value,p=((l==null?void 0:l.value)||"").trim()||void 0,d,h=[],b=[],v=e.target.querySelectorAll("input[data-members-label]")||[];for(let C=0;C<v.length;++C)h.push(v[C].value);let g=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let C=0;C<g.length;++C)b.push({name:g[C].value});t.dataset.membersForm&&(d=t.dataset.membersForm);const y=d==="signin"&&((z=t==null?void 0:t.dataset)==null?void 0:z.membersOtc)==="true";t.classList.add("loading");const k=jo(),x={email:m,emailType:d,labels:h,name:p,autoRedirect:c==="true"};y&&(x.includeOTC=!0),k&&(x.urlHistory=k),g.length>0?x.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(x.newsletters=[]);try{const N=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),I=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,integrityToken:N})});if(t.addEventListener("submit",i),t.classList.remove("loading"),I.ok){t.classList.add("success");let $;if(y)try{$=await I.clone().json()}catch{$=void 0}const V=$==null?void 0:$.otc_ref;if(V&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:V,inboxLinks:$==null?void 0:$.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const $=await Zt.fromApiResponse(I),V=Qt($,f("Failed to send magic link email"));Sk(n,V),t.classList.add("error")}}catch(C){Cz(C,t,n)}}function $z({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:o,clickHandler:r}){t.removeEventListener("click",r),e.preventDefault();let s=t.dataset.membersPlan,l=g$(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,p,d;c&&(p=new URL(c,window.location.href).href),m&&(d=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const h=o?{checkoutType:"upgrade"}:{},b=jo();return b&&(h.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:v,successUrl:p,cancelUrl:d,metadata:h})}).then(function(g){if(!g.ok)throw new Error(f("Could not create Stripe checkout session"));return g.json()})}).then(function(v){return v.url?window.location.assign(v.url):window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(v){console.error(v),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=v.message),t.classList.add("error")})}function Tz({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:o}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let l=s.querySelector("[data-members-error]");function c(m){jz({event:m,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:o})}s.addEventListener("submit",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let l=s.querySelector("[data-members-error]");function c(m){$z({el:s,event:m,errorEl:l,member:n,site:t,siteUrl:e,clickHandler:c})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersSuccess,m=s.dataset.membersCancel,p,d;c&&(p=new URL(c,window.location.href).href),m&&(d=new URL(m,window.location.href).href);function h(b){s.removeEventListener("click",h),b.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:v,successUrl:p,cancelUrl:d})}).then(function(g){if(!g.ok)throw new Error(f("Could not create Stripe checkout session"));return g.json()})}).then(function(v){return window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId})}).then(function(v){if(v.error)throw new Error(f(v.error.message))}).catch(function(v){console.error(v),s.addEventListener("click",h),s.classList.remove("loading"),l&&(l.innerText=v.message),s.classList.add("error")})}s.addEventListener("click",h)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersReturn,m;c&&(m=new URL(c,window.location.href).href);function p(d){s.removeEventListener("click",p),d.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(h){return h.ok?h.text():null}).then(function(h){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:h,returnUrl:m})}).then(function(b){if(!b.ok)throw new Error(f("Could not create Stripe billing portal session"));return b.json()})}).then(function(h){return window.location.assign(h.url)}).catch(function(h){console.error(h),s.addEventListener("click",p),s.classList.remove("loading"),l&&(l.innerText=h.message),s.classList.add("error")})}s.addEventListener("click",p)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function l(c){s.removeEventListener("click",l),c.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(m){m.ok?window.location.replace(e):(s.addEventListener("click",l),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",l)});const r=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(m){m.preventDefault();let p=s.dataset.membersCancelSubscription;if(r){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:p,action:"cancel"}});return}return s.removeEventListener("click",c),s.classList.remove("error"),s.classList.add("loading"),l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(d){return d.ok?d.text():null}).then(function(d){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:d,smart_cancel:!0})})}).then(function(d){d.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=f("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(m){s.removeEventListener("click",c),m.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let p=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(d){return d.ok?d.text():null}).then(function(d){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:d,cancel_at_period_end:!1})})}).then(function(d){d.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=f("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const Pz={showPopup:!0,site:ti,member:Fo.free,page:"accountEmail",...VP(),pageData:vk};function zz({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Zc,{children:t}):u.jsx(u.Fragment,{children:t})}class Iz extends Z.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,o;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(o=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:o.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin,this.state.reloadOnPopupClose&&window.location.reload())}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:r}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),Tz({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:ss})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,o=i&&i.dataset.portal,{page:r,pageQuery:s,pageData:l}=this.getPageFromLinkPath(o)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:r,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const o=this.state.showPopup?t:n,r=this.state.showPopup?n:t;i.classList.add(o),i.classList.remove(r)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:o,popupNotification:r,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";zs.changeLanguage(m);const p={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:o,pageData:c,popupNotification:r,dir:zs.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(p),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const d=document.querySelectorAll("[data-lexical-signup-form]");d.length>0&&d.forEach(h=>{h.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...o}=this.fetchDevData(),{site:r,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...p}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...r,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...o,...s,...p,...c}}fetchDevData(){return de(["dev"])&&!this.state.customSiteUrl?Pz:de(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,o,r;const n=new URLSearchParams(t),a={};for(let s of n.entries()){const l=s[0],c=decodeURIComponent(s[1]);l==="name"?a.name=c||"":l==="code"?a.code=c||"":l==="display_title"?a.display_title=c||"":l==="display_description"?a.display_description=c||"":l==="type"?a.type=c||"":l==="cadence"?a.cadence=c||"":l==="duration"?a.duration=c||"":l==="duration_in_months"&&!isNaN(Number(c))?a.duration_in_months=Number(c):l==="amount"&&!isNaN(Number(c))?a.amount=Number(c):l==="currency"?a.currency=c||"":l==="status"?a.status=c||"":l==="tier_id"?a.tier={id:c||vk.tier.id}:l==="redemption_type"&&(a.redemption_type=c||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=Fo.preview)==null?void 0:i.subscriptions)==null?void 0:o[0])==null?void 0:r.id;return{page:"accountPlan",offers:[a],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let o,r=null,s,l,c;for(let m of n.entries()){const p=m[0],d=decodeURIComponent(m[1]);if(p==="button")a.site.portal_button=JSON.parse(d);else if(p==="name")a.site.portal_name=JSON.parse(d);else if(p==="isFree"&&JSON.parse(d))i.push("free");else if(p==="isMonthly"&&JSON.parse(d))i.push("monthly");else if(p==="isYearly"&&JSON.parse(d))i.push("yearly");else if(p==="portalPrices")o=d?d.split(","):[];else if(p==="portalProducts")r=d?d.split(","):[];else if(p==="page"&&d)a.page=d;else if(p==="accentColor"&&(d===""||d))a.site.accent_color=d;else if(p==="buttonIcon"&&d)a.site.portal_button_icon=d;else if(p==="signupButtonText")a.site.portal_button_signup_text=d||"";else if(p==="signupTermsHtml")a.site.portal_signup_terms_html=d||"";else if(p==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(d);else if(p==="buttonStyle"&&d)a.site.portal_button_style=d;else if(p==="monthlyPrice"&&!isNaN(Number(d)))a.site.plans.monthly=Number(d),s=Number(d);else if(p==="yearlyPrice"&&!isNaN(Number(d)))a.site.plans.yearly=Number(d),l=Number(d);else if(p==="currency"&&d){const h=d.toUpperCase();a.site.plans.currency=h,a.site.plans.currency_symbol=ve(h),c=h}else p==="disableBackground"?a.site.disableBackground=JSON.parse(d):p==="membersSignupAccess"&&d?a.site.members_signup_access=d:p==="portalDefaultPlan"&&d?a.site.portal_default_plan=d:p==="transistorPortalSettings"&&d&&(a.site.transistor_portal_settings=JSON.parse(d))}return a.site.portal_plans=i,a.site.portal_products=r,o?a.site.portal_plans=o:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:o}=wb({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:le({type:t,status:n,duration:a,closeable:o,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(k$({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,o]=window.location.hash.substr(1).split("?"),r=new URLSearchParams(o??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,p=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&p.test(i)){const[,d,h]=i.match(p),b=parseInt(h);if(b===1||b===0)return n||r.get("uuid")&&r.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:r.get("uuid"),key:n?null:r.get("key"),postId:d,score:b}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${d}/${b}/`}}}if(i&&m.test(i)){const[,d]=i.match(m),{page:h,pageQuery:b,pageData:v}=this.getPageFromLinkPath(d,t)||{};if(!n&&h&&hk({page:h}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${d}/`}};const g=["accountPlan","accountProfile"].includes(h)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(b)||s.test(b)||l.test(b)||c.test(b)),...h?{page:h}:{},...b?{pageQuery:b}:{},...v?{pageData:v}:{},...g?{lastPage:g}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(de(["preview"])){let n={};return de(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Zs({siteUrl:t,apiUrl:a,apiKey:i});const{site:o,member:r,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(o.accent_color=l),this.setupFirstPromoter({site:o,member:r}),this.setupSentry({site:o}),{site:o,member:r,offers:s}}catch(o){if(de(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(de(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.66.1|ghost@${i}`;n&&n.dsn&&Wj({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>u$({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(de(["test"]))return null;const a=T$({site:t});let i=yd({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://cdn.firstpromoter.com/fprom.js",o.onload=o.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),R$({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.push(["uid",c])}}}catch{}};const r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(o,r)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await xz({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=le({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:Qt(a,f("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(this.state.site,this.state.member),o={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:o.site,pageQuery:o.pageQuery}),this.setState(o)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(md(),!Mt({member:a})||Tn({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||fb({offer:r})||!A$({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=qa({site:t,productId:r.tier.id}),l=r.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=ea({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=ea({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let o=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}pb({site:t,pageQuery:n})&&(o=pb({site:t,pageQuery:n}));const r=y$({site:t,priceId:o});if(n&&n!=="free"){md();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=ea({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,o=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(o.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,r]=t.match(a);return{page:"signup",pageQuery:`${r}/monthly`}}else if(i.test(t)){const[,r]=t.match(i);return{page:"signup",pageQuery:`${r}/yearly`}}else if(n.test(t)){const[,r]=t.match(n);return{page:"signup",pageQuery:r}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return yT(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ot({site:t})||!Xt({site:t})?"signin":"signup";n=a?"accountHome":i}return nm({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return de(["dev","preview"],{customSiteUrl:a})?hk({page:t})||FP({page:t})?de(["dev"],{customSiteUrl:a})?n||Fo.free:de(["preview"])?Fo.preview:Fo.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:o,page:r,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:p,customSiteUrl:d,dir:h,scrollbarWidth:b,otcRef:v,inboxLinks:g}=this.state,y=this.getContextPage({site:t,page:r,member:n}),k=this.getContextMember({page:y,member:n,customSiteUrl:d});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:y,pageQuery:c,pageData:m,member:k,lastPage:s,showPopup:l,popupNotification:p,customSiteUrl:d,dir:h,scrollbarWidth:b,otcRef:v,inboxLinks:g,doAction:(x,E)=>this.dispatchAction(x,E)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(WP)}render(){return this.state.initStatus==="success"?u.jsx(zz,{site:this.state.site,children:u.jsxs(_.Provider,{value:this.getContextFromState(),children:[u.jsx(im,{}),u.jsx(wd,{}),u.jsx($d,{})]})}):null}}const Ek="ghost-portal-root";function Nz(){const e=document.createElement("div");e.id=Ek,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function Az(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,o=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:o}}return{}}function Dz(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function Mz(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=Az(),o=e||window.location.origin;Nz(),Dz(),tS.render(u.jsx(Z.StrictMode,{children:u.jsx(Iz,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Ek))}Mz()});
3562
3564
  //# sourceMappingURL=portal.min.js.map