@tryghost/portal 2.64.10 → 2.64.12

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.64.10",
3
+ "version": "2.64.12",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/TryGhost/Ghost",
6
6
  "author": "Ghost Foundation",
@@ -110,7 +110,6 @@
110
110
  },
111
111
  "devDependencies": {
112
112
  "@babel/eslint-parser": "7.28.4",
113
- "dompurify": "3.3.1",
114
113
  "@doist/react-interpolate": "2.2.1",
115
114
  "@sentry/react": "7.120.4",
116
115
  "@testing-library/jest-dom": "6.9.1",
@@ -121,8 +120,9 @@
121
120
  "@vitest/ui": "3.2.4",
122
121
  "concurrently": "8.2.2",
123
122
  "cross-fetch": "4.1.0",
123
+ "dompurify": "3.3.1",
124
124
  "eslint-plugin-i18next": "6.1.3",
125
- "jsdom": "24.1.3",
125
+ "jsdom": "28.1.0",
126
126
  "react": "17.0.2",
127
127
  "react-dom": "17.0.2",
128
128
  "vite": "5.4.20",
package/umd/portal.min.js CHANGED
@@ -5308,6 +5308,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
5308
5308
  padding: 6px 12px;
5309
5309
  }
5310
5310
 
5311
+ .gh-portal-retention-offer {
5312
+ margin-top: -24px !important;
5313
+ }
5314
+
5315
+ .gh-portal-retention-offer > p {
5316
+ max-width: 400px;
5317
+ margin-inline: auto;
5318
+ }
5319
+
5311
5320
  .gh-portal-retention-offer-price {
5312
5321
  display: flex;
5313
5322
  align-items: center;
@@ -6655,18 +6664,21 @@ html[dir="rtl"] .gh-portal-btn-site-title-back span {
6655
6664
  animation: none !important;
6656
6665
  }
6657
6666
 
6658
- .gh-portal-popup-wrapper.preview.offer {
6667
+ .gh-portal-popup-wrapper.preview.offer,
6668
+ .gh-portal-popup-wrapper.preview.account-plan {
6659
6669
  padding-top: 0;
6660
6670
  }
6661
6671
 
6662
- .gh-portal-popup-container.preview.offer {
6672
+ .gh-portal-popup-container.preview.offer,
6673
+ .gh-portal-popup-container.preview.account-plan {
6663
6674
  max-width: 420px;
6664
6675
  transform: scale(0.9);
6665
- margin-top: 3.2vw;
6676
+ margin: 3.2vw auto 0;
6666
6677
  }
6667
6678
 
6668
6679
  @media (max-width: 480px) {
6669
- .gh-portal-popup-container.preview.offer {
6680
+ .gh-portal-popup-container.preview.offer,
6681
+ .gh-portal-popup-container.preview.account-plan {
6670
6682
  transform-origin: top;
6671
6683
  margin-top: 0;
6672
6684
  }
@@ -7206,6 +7218,13 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
7206
7218
  overflow: auto;
7207
7219
  justify-content: flex-start;
7208
7220
  }
7221
+
7222
+ .gh-portal-popup-wrapper.full-size .gh-portal-popup-container.preview.account-plan {
7223
+ max-width: 420px;
7224
+ width: auto;
7225
+ margin: 3.2vw auto 0;
7226
+ transform: scale(0.9);
7227
+ }
7209
7228
  }
7210
7229
 
7211
7230
  @media (max-width: 480px) {
@@ -7264,7 +7283,8 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
7264
7283
  margin-bottom: 0;
7265
7284
  }
7266
7285
 
7267
- .gh-portal-popup-container.preview:not(.full-size).offer {
7286
+ .gh-portal-popup-container.preview:not(.full-size).offer,
7287
+ .gh-portal-popup-container.preview:not(.full-size).account-plan {
7268
7288
  max-height: 860px;
7269
7289
  padding-bottom: 0 !important;
7270
7290
  }
@@ -7537,5 +7557,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
7537
7557
  .gh-portal-hide {
7538
7558
  display: none;
7539
7559
  }
7540
- `;function C5({site:e}){return Xm+x5+gL+KL+i6+FL()+fL+dL+hL+Rw+G6+D6+Z6()+cp+K6+E5+S5+Q6+o5+s5+l5+c5+p5+g5+v5}const ih=class ih extends re.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:Bl({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,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:v("jamie@example.com"),label:v("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=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,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:v("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:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=zl({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Yl,{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:v("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}):ea({site:t})?null:u.jsx($x,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:v("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(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};ih.contextType=H;let Up=ih;const $5=({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:v("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:v("Contact support")})})})})]})},j5=()=>{const{member:e,brandColor:t}=C.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Zm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},T5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(H);if(!zl({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},P5=()=>{var r,o;const{member:e,site:t}=C.useContext(H),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=St({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const s=a==null?void 0:a.current_period_end;if(i&&ep({member:e})){const c=ep({member:e}),m=an(c);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:m})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(ap({sub:a})){const c=an(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:v("Your subscription will start on {subscriptionStart}",{subscriptionStart:c})})})}const l=Kw({sub:a})?(o=(r=a==null?void 0:a.next_payment)==null?void 0:r.discount)==null?void 0:o.end:s;return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will renew on {renewalDate}",{renewalDate:an(l)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(T5,{})]})},z5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(H),i=St({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:an(m)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},qx=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),C.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"}),C.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"})),A5=()=>{const{member:e,site:t,doAction:n}=C.useContext(H),a=()=>{const p=St({member:e});n("manageBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:g,subscription:k})=>{const{next_payment:S}=k||{};let b="";if(p){const{amount:R=0,currency:_,interval:D}=p;b=`${Intl.NumberFormat("en",{currency:_,style:"currency"}).format(R/100)}/${v(D)}`}const w=ep({member:e});g&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";if(ap({sub:k}))return E="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(N5,{subscription:k})]});if(Kw({sub:k}))return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(I5,{nextPayment:S,subscription:k})]});let M=M5({nextPayment:S});M&&(E="gh-portal-account-old-price");const z=()=>M?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(qx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:M})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const g=`**** **** **** ${p}`;return u.jsx("p",{children:g})}return null},l=({defaultCardLast4:p,isComplimentary:g})=>{const{action:k}=C.useContext(H),S=k==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return g?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:S})]})},c=St({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:g}=c||{};let k=v("Plan");return Al({site:t})&&Bw({member:e})&&(k=Bw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:g})]})}return null};function N5({subscription:e}){if(ap({sub:e})){const t=an(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function I5({nextPayment:e,subscription:t}){var s,l;const n=((s=t==null?void 0:t.offer)==null?void 0:s.duration_in_months)??0,a=(l=e==null?void 0:e.discount)==null?void 0:l.end,i=a?an(a):null,r=n===1?"1 month free":`${n} months free`,o=i?`${r} - Renews ${i}`:r;return u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(qx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:o})]})}function M5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("Ends {offerEndDate}",{offerEndDate:an(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function F5(){const{member:e,site:t,doAction:n}=C.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({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:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ip({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Rl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Jx=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},C.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"}),C.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 D5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Jx,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function O5(){const{doAction:e,member:t,site:n}=C.useContext(H),a=Ww({member:t}),i=oo({site:n}),r=Nl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(D5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:v("Manage")})]})}const _5=()=>{const{member:e,site:t}=C.useContext(H),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,r=e==null?void 0:e.uuid,o=ex(),[s,l]=C.useState(o&&i);return C.useEffect(()=>{if(o){l(i);return}if(!i||!r){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const f=await fetch(`https://partner.transistor.fm/ghost/member/${r}`,{signal:c.signal});if(f.ok){const p=await f.json();c.signal.aborted||l((p==null?void 0:p.member)===!0)}}catch(f){if(c.signal.aborted)return;console.warn("Error in Transistor request",f)}})(),()=>c.abort()},[i,r,o]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:r,settings:a}}},R5=(e,t)=>lo({site:e})&&oo({site:e})||Nl({site:e})||Ww({member:t}),U5=e=>!lo({site:e})&&oo({site:e})&&!Nl({site:e}),L5=()=>{const{member:e,doAction:t,site:n}=C.useContext(H),{name:a,email:i}=e,{transistor:r}=_5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=R5(n,e),l=U5(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||v("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>o(),children:v("Edit")})]}),u.jsx(A5,{}),s&&u.jsx(O5,{}),l&&u.jsx(F5,{}),r.enabled&&u.jsx(w5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid,settings:r.settings})]})})},Y5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(j5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(P5,{}),u.jsx(z5,{}),u.jsx(L5,{})]})]}),rh=class rh extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({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||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(Y5,{}),u.jsx($5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};rh.contextType=H;let Lp=rh;const oh=class oh extends re.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:Bl({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=v("Save");this.context.action==="updateProfile:failed"&&(n=v("Retry"));const a=!!t;return u.jsx(ze,{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:v("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(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:v("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(Zm,{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:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Yl,{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(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};oh.contextType=H;let Yp=oh;function B5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(H);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Email preferences")})]})}function V5({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(Rl,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function H5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("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:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Rl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function W5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(V5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function G5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Zx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=C.useContext(H),g=!(n!=null&&n.length)&&(s&&!l||!s),S=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(B5,{}),u.jsx(S,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(W5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(H5,{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(ze,{isRunning:!1,onClick:()=>{r()},disabled:g,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ip({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(G5,{isPaid:o,site:p,subscribedNewsletters:n})}),ip({member:f})&&!g&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("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:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function K5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);g(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:v("{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 b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[p,g]=C.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:S}=e||{};return C.useEffect(()=>{g((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Zx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{g(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{g([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:S})}function q5(){const{site:e}=C.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function J5(){const{site:e}=C.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(q5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Xx({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 Z5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(H),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=C.useState(!1),[g,k]=C.useState(m),[S,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),j=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Xx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},M=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Xx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await j([]):n.newsletterUuid?await j(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await M(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(wo,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(mp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!S)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(J5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("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:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Zx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:g,updateSubscribedNewsletters:async _=>{await j(_),p(!0)},updateCommentNotifications:M,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function X5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(H);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Nl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Jx,{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:v("Emails disabled")}),u.jsx("p",{children:v("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(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:v("Re-enable emails"),isRunning:r})]})}function Q5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(H),i=`mailto:${co({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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:v("Spam complaints")}),u.jsx("p",{children:v("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:v("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:v("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:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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:v("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:v("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:v("Need more help? Contact support")})})]})]})}function eY(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(H),o=co({site:n}),s=`mailto:${o}`,l=JU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:o})}})})]})]})}const Bp={signin:Up,signup:Fp,accountHome:Lp,accountPlan:Ep,accountProfile:Yp,accountEmail:K5,signupNewsletter:Cp,unsubscribe:Z5,magiclink:Dp,loading:wo,offer:_p,feedback:r5,emailSuppressed:X5,emailSuppressionFAQ:Q5,emailReceivingFAQ:eY,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(H);return C.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,g=Gl({siteUrl:c});try{const k=await g.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(wo,{})}):n?u.jsx(Rp,{error:n}):i?u.jsx(Rp,{error:i}):null},supportSuccess:d5,supportError:Rp,recommendations:k5},Vp=function({page:e}){return Object.keys(Bp).includes(e)?e:"signup"},Qx=function({page:e}){return e.includes("account")},tY=function({page:e}){return e.includes("offer")},nY=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.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"})),sh=class sh extends re.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(nY,{}),"Powered by Ghost"]})}};sh.contextType=H;let Kl=sh;const eE=()=>({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 aY({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const lh=class lh extends re.Component{componentDidMount(){this.node&&!$e(["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&&$e(["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;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Vp({page:t});const n=Bp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Op,{})}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,o=Fl({site:a,pageQuery:n}).length;Vp({page:t});const l={...eE().page[t]};let c="",m="regular",f="",p=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!on({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const g=so({site:a});(g&&o>2||!g&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const S=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:S,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(aY,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Kl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Kl,{})})]})}};lh.contextType=H;let Hp=lh;const uh=class uh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Bp[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=C5({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=eE(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(qm,{style:o,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(Hp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};uh.contextType=H;let Wp=uh;ql({products:Gp({numOfProducts:1})});function at(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function iY(){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 ql({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:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Gp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:g=!0,portalButton:k=!0,portalName:S=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:j="visibility",newsletters:M=[],posts:z=rY(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:m,free_price_name:f,free_price_description:p,is_stripe_configured:g,portal_button:k,portal_name:S,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:M,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:j,posts:z}}function tE({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:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:f="active",tierId:p="",tierName:g="Basic",redemptionType:k="signup"}={}){return{id:`offer_${at()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:f,tier:{id:`${p}`,name:g},redemption_type:k}}function Ht({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:iY(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function rY({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(oY({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function oY({id:e=`post_${at()}`,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 Gp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=nE({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${at()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:aE({numOfBenefits:o}),trial_days:s}}function nE({name:e="Free tier",description:t="Free tier description",id:n=`product_${at()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:aE({numOfBenefits:a})}}function aE({numOfBenefits:e}){const t=at();return[Jl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Jl({name:`Latest gear reviews #${t.substring(6,12)}`}),Jl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Jl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Jl({id:e=`benefit_${at()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${at()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${at()}`,stripe_product_id:`prod_${at()}`,type:"recurring"}}function Na({id:e=`sub_${at()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=lY,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:g=null,tier:k=null}={}){return{id:e,customer:{id:`cus_${at()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${at()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:m,trial_end_at:p,next_payment:g,tier:k,price:{id:`stripe_price_${at()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${at()}`,product_id:`prod_${at()}`}}}}function iE(){const e=Gp({numOfProducts:1}),t=e.map(a=>a.id);return ql({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}iE();const sY=ql({products:[Oi({numOfBenefits:2,type:"free"})]}),lY=tE({tierId:(uE=sY.products[0])==null?void 0:uE.id});Ht(),Ht({paid:!0,subscriptions:[Na()]}),Ht({paid:!0,subscriptions:[]}),Ht({paid:!0,subscriptions:[Na({amount:0})]}),Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),iE();const Zl=[nE({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=ql({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:Zl,portalProducts:Zl.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}]}),rE=tE({tierId:(cE=_i.products[1])==null?void 0:cE.id}),Eo={free:Ht({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Ht({paid:!0,subscriptions:[Na({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:Ht({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Ht({paid:!0,subscriptions:[Na({amount:0})]}),preview:Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function uY(){var n;if(!Zl||!Zl[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Ht({paid:!0,subscriptions:[Na({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:_i,member:t}}function cY(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 dY({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function mY({state:e}){return{showPopup:!e.showPopup}}function pY({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function hY({state:e}){return e.lastPage?{page:e.lastPage}:oE({state:e})}function oE({state:e}){return Qm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function fY({data:e}){return{showNotification:!0,...e}}function gY(){return{showNotification:!1}}async function yY({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to log out, please try again")})}}}async function bY({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},inboxLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:En(a,v("Failed to log in, please try again"))})}}}function kY({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 vY({data:e,api:t}){var a;const n=v("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:En((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:En(i,n)}}}async function wY({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=En(a,v("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function xY({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to process checkout, please try again")})}}}async function EY({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update subscription, please try again")})}}}async function SY({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()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function CY({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()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function $Y({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:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function jY({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update billing information, please try again")})}}}async function TY({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to open billing portal, please try again")})}}}async function PY(){return{popupNotification:null}}async function zY({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function AY({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function NY({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function IY({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 r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function MY({data:e,state:t,api:n}){const{email:a}=e,i=GU({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function FY({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(qU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function DY({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 OY({data:e,state:t,api:n}){const[a,i]=await Promise.all([FY({data:e,state:t,api:n}),MY({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?v("Account details updated successfully"):v("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=En(i.error,v("Failed to send verification email")):s=v("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Account details updated successfully")})}}async function _Y({data:{siteUrl:e},state:t}){const n=Gl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Vw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function RY({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 UY({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const LY={togglePopup:mY,openPopup:pY,closePopup:oE,switchPage:dY,openNotification:fY,closeNotification:gY,back:hY,signout:yY,signin:bY,startSigninOTCFromCustomForm:kY,verifyOTC:vY,signup:wY,updateSubscription:EY,cancelSubscription:SY,continueSubscription:CY,applyOffer:$Y,updateNewsletter:IY,updateProfile:OY,refreshMemberData:DY,clearPopupNotification:PY,editBilling:jY,manageBilling:TY,checkoutPlan:xY,updateNewsletterPreference:AY,showPopupNotification:zY,removeEmailFromSuppressionList:NY,oneClickSubscribe:_Y,trackRecommendationClicked:RY,trackRecommendationSubscribed:UY};async function YY({action:e,data:t,state:n,api:a}){const i=LY[e];return i?await i({data:t,state:n,api:a})||{}:{}}function sE(e,t){e&&(e.innerText=t)}function BY(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");sE(n,En(e,a))}async function VY({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var j,M;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=((j=t==null?void 0:t.dataset)==null?void 0:j.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,g=[],k=[],S=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<S.length;++z)g.push(S[z].value);let b=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 z=0;z<b.length;++z)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((M=t==null?void 0:t.dataset)==null?void 0:M.membersOtc)==="true";t.classList.add("loading");const E=mo(),P={email:m,emailType:p,labels:g,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:X,inboxLinks:D==null?void 0:D.inboxLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await xn.fromApiResponse(_),X=En(D,v("Failed to send magic link email"));sE(n,X),t.classList.add("error")}}catch(z){BY(z,t,n)}}function HY({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=OU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const g=r?{checkoutType:"upgrade"}:{},k=mo();return k&&(g.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:S,successUrl:f,cancelUrl:p,metadata:g})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(S){return S.url?window.location.assign(S.url):window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(S){console.error(S),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=S.message),t.classList.add("error")})}function WY({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:r}={}){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){VY({event:m,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:r})}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){HY({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,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href);function g(k){s.removeEventListener("click",g),k.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,successUrl:f,cancelUrl:p})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(S){return window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId})}).then(function(S){if(S.error)throw new Error(v(S.error.message))}).catch(function(S){console.error(S),s.addEventListener("click",g),s.classList.remove("loading"),l&&(l.innerText=S.message),s.classList.add("error")})}s.addEventListener("click",g)}),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 f(p){s.removeEventListener("click",f),p.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(g){return g.ok?g.text():null}).then(function(g){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:g,returnUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create Stripe billing portal session"));return k.json()})}).then(function(g){return window.location.assign(g.url)}).catch(function(g){console.error(g),s.addEventListener("click",f),s.classList.remove("loading"),l&&(l.innerText=g.message),s.classList.add("error")})}s.addEventListener("click",f)}),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 o=(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 f=s.dataset.membersCancelSubscription;if(o){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:f,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(p){return p.ok?p.text():null}).then(function(p){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:p,smart_cancel:!0})})}).then(function(p){p.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=v("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 f=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(p){return p.ok?p.text():null}).then(function(p){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:p,cancel_at_period_end:!1})})}).then(function(p){p.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=v("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const GY={showPopup:!0,site:_i,member:Eo.free,page:"accountEmail",...uY(),pageData:rE};function KY({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Bd,{children:t}):u.jsx(u.Fragment,{children:t})}class qY extends re.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,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.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)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),WY({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Ks})}}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,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,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 r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Tl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Tl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(g=>{g.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,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?GY:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,r,o;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||rE.tier.id}:l==="redemption_type"&&(a.redemption_type=c||"signup")}if(a.redemption_type==="retention"){const s=(o=(r=(i=Eo.preview)==null?void 0:i.subscriptions)==null?void 0:r[0])==null?void 0:o.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 r,o=null,s,l,c;for(let m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const g=p.toUpperCase();a.site.plans.currency=g,a.site.plans.currency_symbol=De(g),c=g}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p?a.site.portal_default_plan=p:f==="transistorPortalSettings"&&p&&(a.site.transistor_portal_settings=JSON.parse(p))}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r: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:r}=rx({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,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(UU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,g]=i.match(f),k=parseInt(g);if(k===1||k===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:g,pageQuery:k,pageData:S}=this.getPageFromLinkPath(p,t)||{};if(!n&&g&&Qx({page:g}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${p}/`}};const b=["accountPlan","accountProfile"].includes(g)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...g?{page:g}:{},...k?{pageQuery:k}:{},...S?{pageData:S}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["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||Gl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.64.10|ghost@${i}`;n&&n.dsn&&ET({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>AU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=KU({site:t});let i=rp({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),iL({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 o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await YY({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=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:En(a,v("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),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Qm(),!rn({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||!o.tier||Qw({offer:o})||!QU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({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 r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}Zw({site:t,pageQuery:n})&&(r=Zw({site:t,pageQuery:n}));const o=_U({site:t,priceId:r});if(n&&n!=="free"){Qm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({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\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}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 F6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=on({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Vp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?Qx({page:t})||tY({page:t})?$e(["dev"],{customSiteUrl:a})?n||Eo.free:$e(["preview"])?Eo.preview:Eo.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:g,scrollbarWidth:k,otcRef:S,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:g,scrollbarWidth:k,otcRef:S,inboxLinks:b,doAction:(P,j)=>this.dispatchAction(P,j)}}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(cY)}render(){return this.state.initStatus==="success"?u.jsx(KY,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Wp,{}),u.jsx(up,{}),u.jsx(fp,{})]})}):null}}const lE="ghost-portal-root";function JY(){const e=document.createElement("div");e.id=lE,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function ZY(){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,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function XY(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function QY(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=ZY(),r=e||window.location.origin;JY(),XY(),NC.render(u.jsx(re.StrictMode,{children:u.jsx(qY,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(lE))}QY()});
7560
+ `;function C5({site:e}){return Xm+x5+gL+KL+i6+FL()+fL+dL+hL+Rw+G6+D6+Z6()+cp+K6+E5+S5+Q6+o5+s5+l5+c5+p5+g5+v5}const ih=class ih extends re.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:Bl({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,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:v("jamie@example.com"),label:v("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=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,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:v("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:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=zl({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Yl,{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:v("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}):ea({site:t})?null:u.jsx($x,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:v("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(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};ih.contextType=H;let Up=ih;const $5=({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:v("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:v("Contact support")})})})})]})},j5=()=>{const{member:e,brandColor:t}=C.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Zm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},T5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(H);if(!zl({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},P5=()=>{var r,o;const{member:e,site:t}=C.useContext(H),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=St({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const s=a==null?void 0:a.current_period_end;if(i&&ep({member:e})){const c=ep({member:e}),m=an(c);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:m})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(ap({sub:a})){const c=an(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:v("Your subscription will start on {subscriptionStart}",{subscriptionStart:c})})})}const l=Kw({sub:a})?(o=(r=a==null?void 0:a.next_payment)==null?void 0:r.discount)==null?void 0:o.end:s;return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will renew on {renewalDate}",{renewalDate:an(l)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(T5,{})]})},z5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(H),i=St({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:an(m)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},qx=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),C.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"}),C.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"})),A5=()=>{const{member:e,site:t,doAction:n}=C.useContext(H),a=()=>{const p=St({member:e});n("manageBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:g,subscription:k})=>{const{next_payment:S}=k||{};let b="";if(p){const{amount:R=0,currency:_,interval:D}=p;b=`${Intl.NumberFormat("en",{currency:_,style:"currency"}).format(R/100)}/${v(D)}`}const w=ep({member:e});g&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";if(ap({sub:k}))return E="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(N5,{subscription:k})]});if(Kw({sub:k}))return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(I5,{nextPayment:S,subscription:k})]});let M=M5({nextPayment:S});M&&(E="gh-portal-account-old-price");const z=()=>M?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(qx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:M})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const g=`**** **** **** ${p}`;return u.jsx("p",{children:g})}return null},l=({defaultCardLast4:p,isComplimentary:g})=>{const{action:k}=C.useContext(H),S=k==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return g?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:S})]})},c=St({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:g}=c||{};let k=v("Plan");return Al({site:t})&&Bw({member:e})&&(k=Bw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:g})]})}return null};function N5({subscription:e}){if(ap({sub:e})){const t=an(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function I5({nextPayment:e,subscription:t}){var s,l;const n=((s=t==null?void 0:t.offer)==null?void 0:s.duration_in_months)??0,a=(l=e==null?void 0:e.discount)==null?void 0:l.end,i=a?an(a):null,r=n===1?"1 month free":`${n} months free`,o=i?`${r} - Renews ${i}`:r;return u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(qx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:o})]})}function M5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("Ends {offerEndDate}",{offerEndDate:an(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function F5(){const{member:e,site:t,doAction:n}=C.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({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:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ip({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Rl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Jx=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},C.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"}),C.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 D5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Jx,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function O5(){const{doAction:e,member:t,site:n}=C.useContext(H),a=Ww({member:t}),i=oo({site:n}),r=Nl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(D5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:v("Manage")})]})}const _5=()=>{const{member:e,site:t}=C.useContext(H),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,r=e==null?void 0:e.uuid,o=ex(),[s,l]=C.useState(o&&i);return C.useEffect(()=>{if(o){l(i);return}if(!i||!r){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const f=await fetch(`https://partner.transistor.fm/ghost/member/${r}`,{signal:c.signal});if(f.ok){const p=await f.json();c.signal.aborted||l((p==null?void 0:p.member)===!0)}}catch(f){if(c.signal.aborted)return;console.warn("Error in Transistor request",f)}})(),()=>c.abort()},[i,r,o]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:r,settings:a}}},R5=(e,t)=>lo({site:e})&&oo({site:e})||Nl({site:e})||Ww({member:t}),U5=e=>!lo({site:e})&&oo({site:e})&&!Nl({site:e}),L5=()=>{const{member:e,doAction:t,site:n}=C.useContext(H),{name:a,email:i}=e,{transistor:r}=_5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=R5(n,e),l=U5(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||v("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>o(),children:v("Edit")})]}),u.jsx(A5,{}),s&&u.jsx(O5,{}),l&&u.jsx(F5,{}),r.enabled&&u.jsx(w5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid,settings:r.settings})]})})},Y5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(j5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(P5,{}),u.jsx(z5,{}),u.jsx(L5,{})]})]}),rh=class rh extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({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||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(Y5,{}),u.jsx($5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};rh.contextType=H;let Lp=rh;const oh=class oh extends re.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:Bl({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=v("Save");this.context.action==="updateProfile:failed"&&(n=v("Retry"));const a=!!t;return u.jsx(ze,{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:v("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(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:v("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(Zm,{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:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Yl,{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(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};oh.contextType=H;let Yp=oh;function B5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(H);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Email preferences")})]})}function V5({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(Rl,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function H5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("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:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Rl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function W5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(V5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function G5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Zx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=C.useContext(H),g=!(n!=null&&n.length)&&(s&&!l||!s),S=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(B5,{}),u.jsx(S,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(W5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(H5,{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(ze,{isRunning:!1,onClick:()=>{r()},disabled:g,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ip({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(G5,{isPaid:o,site:p,subscribedNewsletters:n})}),ip({member:f})&&!g&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("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:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function K5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);g(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:v("{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 b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[p,g]=C.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:S}=e||{};return C.useEffect(()=>{g((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Zx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{g(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{g([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:S})}function q5(){const{site:e}=C.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function J5(){const{site:e}=C.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(q5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Xx({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 Z5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(H),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=C.useState(!1),[g,k]=C.useState(m),[S,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),j=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Xx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},M=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Xx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await j([]):n.newsletterUuid?await j(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await M(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(wo,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(mp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!S)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(J5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("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:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Zx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:g,updateSubscribedNewsletters:async _=>{await j(_),p(!0)},updateCommentNotifications:M,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function X5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(H);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Nl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Jx,{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:v("Emails disabled")}),u.jsx("p",{children:v("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(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:v("Re-enable emails"),isRunning:r})]})}function Q5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(H),i=`mailto:${co({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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:v("Spam complaints")}),u.jsx("p",{children:v("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:v("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:v("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:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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:v("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:v("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:v("Need more help? Contact support")})})]})]})}function eY(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(H),o=co({site:n}),s=`mailto:${o}`,l=JU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:o})}})})]})]})}const Bp={signin:Up,signup:Fp,accountHome:Lp,accountPlan:Ep,accountProfile:Yp,accountEmail:K5,signupNewsletter:Cp,unsubscribe:Z5,magiclink:Dp,loading:wo,offer:_p,feedback:r5,emailSuppressed:X5,emailSuppressionFAQ:Q5,emailReceivingFAQ:eY,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(H);return C.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,g=Gl({siteUrl:c});try{const k=await g.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(wo,{})}):n?u.jsx(Rp,{error:n}):i?u.jsx(Rp,{error:i}):null},supportSuccess:d5,supportError:Rp,recommendations:k5},Vp=function({page:e}){return Object.keys(Bp).includes(e)?e:"signup"},Qx=function({page:e}){return e.includes("account")},tY=function({page:e}){return e.includes("offer")},nY=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.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"})),sh=class sh extends re.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(nY,{}),"Powered by Ghost"]})}};sh.contextType=H;let Kl=sh;const eE=()=>({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 aY({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const lh=class lh extends re.Component{componentDidMount(){this.node&&!$e(["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&&$e(["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;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Vp({page:t});const n=Bp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Op,{})}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,o=Fl({site:a,pageQuery:n}).length;Vp({page:t});const l={...eE().page[t]};let c="",m="regular",f="",p=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!on({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const g=so({site:a});(g&&o>2||!g&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const S=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:S,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(aY,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Kl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Kl,{})})]})}};lh.contextType=H;let Hp=lh;const uh=class uh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Bp[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=C5({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=eE(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(qm,{style:o,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(Hp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};uh.contextType=H;let Wp=uh;ql({products:Gp({numOfProducts:1})});function at(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function iY(){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 ql({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:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Gp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:g=!0,portalButton:k=!0,portalName:S=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:j="visibility",newsletters:M=[],posts:z=rY(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:m,free_price_name:f,free_price_description:p,is_stripe_configured:g,portal_button:k,portal_name:S,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:M,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:j,posts:z}}function tE({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:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:f="active",tierId:p="",tierName:g="Basic",redemptionType:k="signup"}={}){return{id:`offer_${at()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:f,tier:{id:`${p}`,name:g},redemption_type:k}}function Ht({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:iY(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function rY({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(oY({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function oY({id:e=`post_${at()}`,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 Gp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=nE({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${at()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:aE({numOfBenefits:o}),trial_days:s}}function nE({name:e="Free tier",description:t="Free tier description",id:n=`product_${at()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:aE({numOfBenefits:a})}}function aE({numOfBenefits:e}){const t=at();return[Jl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Jl({name:`Latest gear reviews #${t.substring(6,12)}`}),Jl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Jl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Jl({id:e=`benefit_${at()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${at()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${at()}`,stripe_product_id:`prod_${at()}`,type:"recurring"}}function Na({id:e=`sub_${at()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=lY,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:g=null,tier:k=null}={}){return{id:e,customer:{id:`cus_${at()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${at()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:m,trial_end_at:p,next_payment:g,tier:k,price:{id:`stripe_price_${at()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${at()}`,product_id:`prod_${at()}`}}}}function iE(){const e=Gp({numOfProducts:1}),t=e.map(a=>a.id);return ql({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}iE();const sY=ql({products:[Oi({numOfBenefits:2,type:"free"})]}),lY=tE({tierId:(uE=sY.products[0])==null?void 0:uE.id});Ht(),Ht({paid:!0,subscriptions:[Na()]}),Ht({paid:!0,subscriptions:[]}),Ht({paid:!0,subscriptions:[Na({amount:0})]}),Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),iE();const Zl=[nE({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=ql({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:Zl,portalProducts:Zl.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}]}),rE=tE({tierId:(cE=_i.products[1])==null?void 0:cE.id}),Eo={free:Ht({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Ht({paid:!0,subscriptions:[Na({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:Ht({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Ht({paid:!0,subscriptions:[Na({amount:0})]}),preview:Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function uY(){var n;if(!Zl||!Zl[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Ht({paid:!0,subscriptions:[Na({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:_i,member:t}}function cY(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 dY({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function mY({state:e}){return{showPopup:!e.showPopup}}function pY({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function hY({state:e}){return e.lastPage?{page:e.lastPage}:oE({state:e})}function oE({state:e}){return Qm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function fY({data:e}){return{showNotification:!0,...e}}function gY(){return{showNotification:!1}}async function yY({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to log out, please try again")})}}}async function bY({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},inboxLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:En(a,v("Failed to log in, please try again"))})}}}function kY({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 vY({data:e,api:t}){var a;const n=v("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:En((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:En(i,n)}}}async function wY({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=En(a,v("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function xY({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to process checkout, please try again")})}}}async function EY({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update subscription, please try again")})}}}async function SY({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()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function CY({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()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function $Y({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:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function jY({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update billing information, please try again")})}}}async function TY({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to open billing portal, please try again")})}}}async function PY(){return{popupNotification:null}}async function zY({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function AY({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function NY({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function IY({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 r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function MY({data:e,state:t,api:n}){const{email:a}=e,i=GU({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function FY({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(qU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function DY({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 OY({data:e,state:t,api:n}){const[a,i]=await Promise.all([FY({data:e,state:t,api:n}),MY({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?v("Account details updated successfully"):v("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=En(i.error,v("Failed to send verification email")):s=v("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Account details updated successfully")})}}async function _Y({data:{siteUrl:e},state:t}){const n=Gl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Vw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function RY({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 UY({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const LY={togglePopup:mY,openPopup:pY,closePopup:oE,switchPage:dY,openNotification:fY,closeNotification:gY,back:hY,signout:yY,signin:bY,startSigninOTCFromCustomForm:kY,verifyOTC:vY,signup:wY,updateSubscription:EY,cancelSubscription:SY,continueSubscription:CY,applyOffer:$Y,updateNewsletter:IY,updateProfile:OY,refreshMemberData:DY,clearPopupNotification:PY,editBilling:jY,manageBilling:TY,checkoutPlan:xY,updateNewsletterPreference:AY,showPopupNotification:zY,removeEmailFromSuppressionList:NY,oneClickSubscribe:_Y,trackRecommendationClicked:RY,trackRecommendationSubscribed:UY};async function YY({action:e,data:t,state:n,api:a}){const i=LY[e];return i?await i({data:t,state:n,api:a})||{}:{}}function sE(e,t){e&&(e.innerText=t)}function BY(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");sE(n,En(e,a))}async function VY({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var j,M;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=((j=t==null?void 0:t.dataset)==null?void 0:j.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,g=[],k=[],S=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<S.length;++z)g.push(S[z].value);let b=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 z=0;z<b.length;++z)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((M=t==null?void 0:t.dataset)==null?void 0:M.membersOtc)==="true";t.classList.add("loading");const E=mo(),P={email:m,emailType:p,labels:g,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:X,inboxLinks:D==null?void 0:D.inboxLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await xn.fromApiResponse(_),X=En(D,v("Failed to send magic link email"));sE(n,X),t.classList.add("error")}}catch(z){BY(z,t,n)}}function HY({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=OU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const g=r?{checkoutType:"upgrade"}:{},k=mo();return k&&(g.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:S,successUrl:f,cancelUrl:p,metadata:g})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(S){return S.url?window.location.assign(S.url):window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(S){console.error(S),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=S.message),t.classList.add("error")})}function WY({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:r}={}){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){VY({event:m,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:r})}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){HY({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,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href);function g(k){s.removeEventListener("click",g),k.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,successUrl:f,cancelUrl:p})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(S){return window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId})}).then(function(S){if(S.error)throw new Error(v(S.error.message))}).catch(function(S){console.error(S),s.addEventListener("click",g),s.classList.remove("loading"),l&&(l.innerText=S.message),s.classList.add("error")})}s.addEventListener("click",g)}),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 f(p){s.removeEventListener("click",f),p.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(g){return g.ok?g.text():null}).then(function(g){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:g,returnUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create Stripe billing portal session"));return k.json()})}).then(function(g){return window.location.assign(g.url)}).catch(function(g){console.error(g),s.addEventListener("click",f),s.classList.remove("loading"),l&&(l.innerText=g.message),s.classList.add("error")})}s.addEventListener("click",f)}),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 o=(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 f=s.dataset.membersCancelSubscription;if(o){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:f,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(p){return p.ok?p.text():null}).then(function(p){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:p,smart_cancel:!0})})}).then(function(p){p.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=v("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 f=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(p){return p.ok?p.text():null}).then(function(p){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:p,cancel_at_period_end:!1})})}).then(function(p){p.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=v("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const GY={showPopup:!0,site:_i,member:Eo.free,page:"accountEmail",...uY(),pageData:rE};function KY({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Bd,{children:t}):u.jsx(u.Fragment,{children:t})}class qY extends re.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,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.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)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),WY({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Ks})}}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,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,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 r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Tl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Tl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(g=>{g.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,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?GY:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,r,o;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||rE.tier.id}:l==="redemption_type"&&(a.redemption_type=c||"signup")}if(a.redemption_type==="retention"){const s=(o=(r=(i=Eo.preview)==null?void 0:i.subscriptions)==null?void 0:r[0])==null?void 0:o.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 r,o=null,s,l,c;for(let m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const g=p.toUpperCase();a.site.plans.currency=g,a.site.plans.currency_symbol=De(g),c=g}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p?a.site.portal_default_plan=p:f==="transistorPortalSettings"&&p&&(a.site.transistor_portal_settings=JSON.parse(p))}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r: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:r}=rx({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,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(UU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,g]=i.match(f),k=parseInt(g);if(k===1||k===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:g,pageQuery:k,pageData:S}=this.getPageFromLinkPath(p,t)||{};if(!n&&g&&Qx({page:g}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${p}/`}};const b=["accountPlan","accountProfile"].includes(g)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...g?{page:g}:{},...k?{pageQuery:k}:{},...S?{pageData:S}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["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||Gl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.64.12|ghost@${i}`;n&&n.dsn&&ET({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>AU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=KU({site:t});let i=rp({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),iL({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 o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await YY({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=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:En(a,v("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),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Qm(),!rn({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||!o.tier||Qw({offer:o})||!QU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({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 r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}Zw({site:t,pageQuery:n})&&(r=Zw({site:t,pageQuery:n}));const o=_U({site:t,priceId:r});if(n&&n!=="free"){Qm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({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\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}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 F6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=on({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Vp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?Qx({page:t})||tY({page:t})?$e(["dev"],{customSiteUrl:a})?n||Eo.free:$e(["preview"])?Eo.preview:Eo.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:g,scrollbarWidth:k,otcRef:S,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:g,scrollbarWidth:k,otcRef:S,inboxLinks:b,doAction:(P,j)=>this.dispatchAction(P,j)}}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(cY)}render(){return this.state.initStatus==="success"?u.jsx(KY,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Wp,{}),u.jsx(up,{}),u.jsx(fp,{})]})}):null}}const lE="ghost-portal-root";function JY(){const e=document.createElement("div");e.id=lE,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function ZY(){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,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function XY(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function QY(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=ZY(),r=e||window.location.origin;JY(),XY(),NC.render(u.jsx(re.StrictMode,{children:u.jsx(qY,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(lE))}QY()});
7541
7561
  //# sourceMappingURL=portal.min.js.map