@tryghost/portal 2.68.1 → 2.68.3

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/umd/portal.min.js CHANGED
@@ -2140,7 +2140,7 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2140
2140
  `,nP=()=>{const{doAction:e,brandColor:t,site:n}=v.useContext(_),a=h("Thank you for your support"),i=h("To continue to stay up to date, subscribe to {publication} below.",{publication:n==null?void 0:n.title}),o=h("Sign up");return l.jsxs("div",{className:"gh-portal-content gh-portal-tips-and-donations",children:[l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-signup-header",children:[n.icon?l.jsx("img",{className:"gh-portal-signup-logo",src:n.icon,alt:n.title}):l.jsx("div",{className:"gh-tips-and-donations-icon-success",children:l.jsx(eP,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:a})]}),l.jsx("p",{className:"gh-portal-text-center",children:i}),l.jsx(me,{style:{width:"100%"},retry:!1,onClick:()=>e("switchPage",{page:"signup"}),disabled:!1,brandColor:t,label:o,isRunning:!1,tabIndex:3,classes:"sticky bottom"}),l.jsxs("div",{className:"gh-portal-signup-message",children:[l.jsx("div",{children:h("Already a member?")}),l.jsx("button",{"data-test-button":"signin-switch","data-testid":"signin-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>e("switchPage",{page:"signin"}),children:l.jsx("span",{children:h("Sign in")})})]})]})},mk=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...e},v.createElement("rect",{x:3,y:8,width:18,height:4,rx:1}),v.createElement("path",{d:"M12 8v13"}),v.createElement("path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}),v.createElement("path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5C9 3 12 8 12 8"}),v.createElement("path",{d:"M16.5 8a2.5 2.5 0 0 0 0-5C15 3 12 8 12 8"})),aP="Gift could not be redeemed",iP="Gift link is not valid";function pk(e){const t=e!=null&&e.message&&e.message!=="Failed to load gift data"?e.message:iP;return{title:aP,subtitle:t}}const oP=`
2141
2141
  .gh-portal-popup-container.giftRedemption {
2142
2142
  width: calc(100vw - 24px);
2143
- max-width: 452px;
2143
+ max-width: 500px;
2144
2144
  padding: 0;
2145
2145
  overflow: hidden;
2146
2146
  }
@@ -2175,10 +2175,21 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2175
2175
  }
2176
2176
 
2177
2177
  .gh-gift-redemption-summary {
2178
- padding: 32px 32px 28px;
2178
+ position: relative;
2179
+ padding: 32px;
2179
2180
  text-align: center;
2180
- background: #fff5f5;
2181
- border-bottom: 1px solid #f1e7e4;
2181
+ }
2182
+
2183
+ .gh-gift-redemption-summary:before {
2184
+ position: absolute;
2185
+ content: "";
2186
+ display: block;
2187
+ background: var(--brandcolor);
2188
+ top: 0;
2189
+ right: 0;
2190
+ bottom: 0;
2191
+ left: 0;
2192
+ opacity: 0.06;
2182
2193
  }
2183
2194
 
2184
2195
  .gh-gift-redemption-icon {
@@ -2191,14 +2202,14 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2191
2202
  }
2192
2203
 
2193
2204
  .gh-gift-redemption-icon svg {
2194
- width: 40px;
2195
- height: 40px;
2205
+ width: 52px;
2206
+ height: 52px;
2196
2207
  }
2197
2208
 
2198
2209
  .gh-gift-redemption-kicker {
2199
- font-size: 1.15rem;
2200
- font-weight: 700;
2201
- letter-spacing: 0.14em;
2210
+ font-size: 1.3rem;
2211
+ font-weight: 600;
2212
+ letter-spacing: 0.02em;
2202
2213
  text-transform: uppercase;
2203
2214
  color: var(--brandcolor);
2204
2215
  }
@@ -2206,17 +2217,17 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2206
2217
  .gh-gift-redemption-title {
2207
2218
  max-width: none;
2208
2219
  margin: 16px auto 0;
2209
- font-size: 2.25rem;
2210
- font-weight: 800;
2220
+ font-size: 2.6rem;
2221
+ font-weight: 700;
2211
2222
  line-height: 1.08;
2212
- letter-spacing: -0.03em;
2223
+ letter-spacing: -0.015em;
2213
2224
  white-space: nowrap;
2214
2225
  color: var(--grey0);
2215
2226
  }
2216
2227
 
2217
2228
  .gh-gift-redemption-plan {
2218
2229
  margin-top: 10px;
2219
- font-size: 1.65rem;
2230
+ font-size: 1.6rem;
2220
2231
  color: var(--grey2);
2221
2232
  }
2222
2233
 
@@ -2232,14 +2243,14 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2232
2243
  display: flex;
2233
2244
  flex-direction: column;
2234
2245
  gap: 8px;
2235
- max-width: 302px;
2246
+ max-width: 400px;
2236
2247
  margin: 20px auto 0;
2237
2248
  }
2238
2249
 
2239
2250
  .gh-gift-redemption-benefit {
2240
2251
  display: flex;
2241
2252
  align-items: flex-start;
2242
- justify-content: flex-start;
2253
+ justify-content: center;
2243
2254
  gap: 10px;
2244
2255
  color: var(--grey2);
2245
2256
  font-size: 1.45rem;
@@ -2260,31 +2271,11 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2260
2271
  flex-direction: row-reverse;
2261
2272
  }
2262
2273
 
2263
- .gh-gift-redemption-benefit span {
2264
- display: block;
2265
- flex: 1;
2266
- min-width: 0;
2267
- overflow: hidden;
2268
- text-overflow: ellipsis;
2269
- white-space: nowrap;
2270
- }
2271
-
2272
2274
  .gh-gift-redemption-form {
2273
2275
  padding: 22px 28px 28px;
2274
2276
  background: var(--white);
2275
2277
  }
2276
2278
 
2277
- .gh-gift-redemption-form .gh-portal-input-label {
2278
- margin-bottom: 5px;
2279
- font-size: 1.25rem;
2280
- font-weight: 700;
2281
- color: var(--grey1);
2282
- }
2283
-
2284
- .gh-gift-redemption-form .gh-portal-input {
2285
- margin-bottom: 14px;
2286
- }
2287
-
2288
2279
  .gh-gift-redemption-submit {
2289
2280
  width: 100%;
2290
2281
  height: 44px;
@@ -2322,7 +2313,7 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2322
2313
  }
2323
2314
 
2324
2315
  .gh-portal-gift-success .gh-gift-success-icon {
2325
- margin: 24px auto 0;
2316
+ margin: 12px auto 0;
2326
2317
  text-align: center;
2327
2318
  color: var(--brandcolor);
2328
2319
  width: 56px;
@@ -2336,27 +2327,27 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2336
2327
 
2337
2328
  .gh-portal-gift-success h1.gh-portal-main-title {
2338
2329
  font-size: 32px;
2339
- margin-top: 20px;
2330
+ margin-top: 16px;
2340
2331
  }
2341
2332
 
2342
- .gh-portal-gift-success .gh-portal-text-center {
2343
- padding: 0 32px;
2344
- margin-top: 20px;
2333
+ .gh-portal-gift-success .gh-portal-main-subtitle {
2334
+ margin-top: 12px;
2345
2335
  }
2346
2336
 
2347
2337
  .gh-portal-gift-success .gh-gift-link-container {
2348
2338
  display: flex;
2349
2339
  align-items: center;
2350
- border: 1px solid var(--grey11);
2340
+ height: 48px;
2341
+ background-color: #f3f3f3;
2351
2342
  border-radius: 8px;
2352
- padding: 4px 4px 4px 16px;
2353
- margin: 20px 24px 0;
2343
+ padding: 6px 6px 6px 12px;
2344
+ margin-top: 24px;
2354
2345
  gap: 8px;
2355
2346
  }
2356
2347
 
2357
2348
  .gh-portal-gift-success .gh-gift-link-url {
2358
2349
  flex: 1;
2359
- font-size: 14px;
2350
+ font-size: 1.5rem;
2360
2351
  color: var(--grey1);
2361
2352
  overflow: hidden;
2362
2353
  text-overflow: ellipsis;
@@ -2368,38 +2359,34 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2368
2359
  .gh-portal-gift-success .gh-gift-copy-btn {
2369
2360
  display: flex;
2370
2361
  align-items: center;
2371
- gap: 6px;
2362
+ gap: 4px;
2363
+ height: 36px;
2372
2364
  background: var(--brandcolor);
2373
2365
  color: #fff;
2374
2366
  border: none;
2375
2367
  border-radius: 6px;
2376
- padding: 8px 16px;
2368
+ padding: 8px 16px 8px 14px;
2377
2369
  font-size: 14px;
2378
- font-weight: 600;
2370
+ font-weight: 500;
2379
2371
  cursor: pointer;
2380
2372
  white-space: nowrap;
2381
2373
  flex-shrink: 0;
2382
2374
  transition: opacity 0.15s ease;
2375
+ will-change: opacity;
2383
2376
  }
2384
2377
 
2385
2378
  .gh-portal-gift-success .gh-gift-copy-btn:hover {
2386
2379
  opacity: 0.9;
2387
2380
  }
2388
2381
 
2389
- .gh-portal-gift-success .gh-gift-copy-btn svg {
2390
- width: 14px;
2391
- height: 14px;
2392
- }
2393
-
2394
2382
  .gh-portal-gift-success .gh-gift-footer-text {
2395
- padding: 0 32px;
2396
- margin-top: 20px;
2397
- font-size: 13px;
2383
+ margin: 36px 0 0;
2384
+ font-size: 1.3rem;
2398
2385
  color: var(--grey7);
2399
2386
  text-align: center;
2400
2387
  line-height: 1.5;
2401
2388
  }
2402
- `,cP=()=>l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),uP=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),dP=()=>{const{site:e,pageData:t}=v.useContext(_),[n,a]=v.useState(!1),i=t==null?void 0:t.token,r=`${((e==null?void 0:e.url)||"").replace(/\/$/,"")}/#/portal/gift/redeem/${i}`,s=()=>{hk(r),a(!0),setTimeout(()=>a(!1),2e3)};return l.jsxs("div",{className:"gh-portal-content gh-portal-gift-success",children:[l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-signup-header",children:[l.jsx("div",{className:"gh-gift-success-icon",children:l.jsx(mk,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:"Gift ready to share!"})]}),l.jsx("p",{className:"gh-portal-text-center",children:"Share this link with the recipient to let them redeem their gift membership."}),l.jsxs("div",{className:"gh-gift-link-container",children:[l.jsx("span",{className:"gh-gift-link-url",children:r}),l.jsxs("button",{className:"gh-gift-copy-btn",onClick:s,type:"button",children:[n?l.jsx(uP,{}):l.jsx(cP,{}),n?"Copied":"Copy"]})]}),l.jsxs("p",{className:"gh-gift-footer-text",children:["This link can be redeemed once and expires in 365 days.",l.jsx("br",{}),"We've also sent a confirmation to your email with this link."]})]})},mP=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},v.createElement("title",null,"warning-stroke"),v.createElement("path",{d:"M13.313 2.275a1.5 1.5 0 0 0-2.626 0l-9.75 18A1.5 1.5 0 0 0 2.25 22.5h19.5a1.5 1.5 0 0 0 1.313-2.225zM12 18a.375.375 0 0 1 .375.375m-.75 0A.375.375 0 0 1 12 18m0 .75a.375.375 0 0 1-.375-.375m.75 0a.375.375 0 0 1-.375.375M12 15V8.25",style:{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5px"}})),pP=`
2389
+ `,cP=()=>l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",width:"14",height:"14",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),uP=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{margin:"1px -1px 0 -2px"},width:"16",height:"16",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),dP=()=>{const{site:e,pageData:t}=v.useContext(_),[n,a]=v.useState(!1),i=t==null?void 0:t.token,r=`${((e==null?void 0:e.url)||"").replace(/\/$/,"")}/#/portal/gift/redeem/${i}`,s=()=>{hk(r),a(!0),setTimeout(()=>a(!1),2e3)};return l.jsxs("div",{className:"gh-portal-content gh-portal-gift-success",children:[l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-signup-header",children:[l.jsx("div",{className:"gh-gift-success-icon",children:l.jsx(mk,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:"Gift ready to share!"}),l.jsx("p",{className:"gh-portal-main-subtitle gh-portal-text-center",children:"Share this link with the recipient to let them redeem their gift membership."})]}),l.jsxs("div",{className:"gh-gift-link-container",children:[l.jsx("span",{className:"gh-gift-link-url",children:r}),l.jsxs("button",{className:"gh-gift-copy-btn",onClick:s,type:"button",children:[n?l.jsx(uP,{}):l.jsx(cP,{}),n?"Copied":"Copy"]})]}),l.jsxs("p",{className:"gh-gift-footer-text",children:["This link can be redeemed once and expires in 365 days.",l.jsx("br",{}),"We've also sent a confirmation to your email with this link."]})]})},mP=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},v.createElement("title",null,"warning-stroke"),v.createElement("path",{d:"M13.313 2.275a1.5 1.5 0 0 0-2.626 0l-9.75 18A1.5 1.5 0 0 0 2.25 22.5h19.5a1.5 1.5 0 0 0 1.313-2.225zM12 18a.375.375 0 0 1 .375.375m-.75 0A.375.375 0 0 1 12 18m0 .75a.375.375 0 0 1-.375-.375m.75 0a.375.375 0 0 1-.375.375M12 15V8.25",style:{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5px"}})),pP=`
2403
2390
  .gh-portal-tips-and-donations .gh-tips-and-donations-icon-error {
2404
2391
  padding: 10px 0;
2405
2392
  text-align: center;
@@ -4128,7 +4115,7 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
4128
4115
  .gh-portal-hide {
4129
4116
  display: none;
4130
4117
  }
4131
- `;function $P({site:e}){return vd+xP+x1+O1+K1+C1()+S1+b1+w1+db+_T+$T+BT()+Dd+RT+CP+EP+HT+ZT+XT+QT+tP+oP+pP+lP+gP+vP+wP}const xm=class xm extends Z.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Oo({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:o}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:o,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:h("jamie@example.com"),label:h("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=h(a?"Sending login link...":"Continue");const o=!!a;return t==="signin:failed"&&(i=h("Retry"),n=!0),l.jsx(me,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:r=>this.handleSignin(r),disabled:o,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return l.jsxs("div",{className:"gh-portal-signup-message",children:[l.jsx("div",{children:h("Don't have an account?")}),l.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:l.jsx("span",{children:h("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=Ls({site:t})&&Qt({site:t});return zn({site:t})?l.jsxs("section",{children:[l.jsx("div",{className:"gh-portal-section",children:l.jsx(ti,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),l.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):l.jsx("section",{children:l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:h("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?l.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):zn({site:t})?null:l.jsx(Gb,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return zn({site:t})?l.jsx("h1",{className:"gh-portal-main-title",children:h("Sign in")}):l.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return l.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return l.jsxs(l.Fragment,{children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};xm.contextType=_;let om=xm;const jP=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return l.jsxs("footer",{className:"gh-portal-account-footer",children:[l.jsx("ul",{className:"gh-portal-account-footermenu",children:l.jsx("li",{children:l.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:h("Sign out")})})}),l.jsx("div",{className:"gh-portal-account-footerright",children:l.jsx("ul",{className:"gh-portal-account-footermenu",children:l.jsx("li",{children:l.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:h("Contact support")})})})})]})},TP=()=>{const{member:e,brandColor:t}=v.useContext(_),n=e.avatar_image;return l.jsxs("header",{className:"gh-portal-account-header",children:[l.jsx(kd,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),l.jsx("h2",{className:"gh-portal-main-title",children:h("Your account")})]})},PP=()=>{const{site:e,action:t,brandColor:n,doAction:a}=v.useContext(_);if(!Ls({site:e})||!Qt({site:e}))return null;const i=["checkoutPlan:running"].includes(t),o=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return l.jsx(me,{dataTestId:"view-plans",isRunning:i,label:h("View plans"),onClick:()=>o(),brandColor:n,style:{width:"100%"}})},zP=()=>{const{member:e,site:t}=v.useContext(_),{is_stripe_configured:n}=t;if(!n||Ja({site:t}))return null;const a=rt({member:e}),i=Pn({member:e});if(i&&!a)return null;if(a){const o=a==null?void 0:a.current_period_end;if(i&&wd({member:e})){const r=wd({member:e}),s=Xt(r);return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(xd({sub:a})){const r=Xt(a.trial_end_at);return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will start on {subscriptionStart}",{subscriptionStart:r})})})}return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will renew on {renewalDate}",{renewalDate:Xt(o)})})})}return l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("You currently have a free membership, upgrade to a paid subscription for full access.")}),l.jsx(PP,{})]})},IP=()=>{const{member:e,doAction:t,action:n,brandColor:a}=v.useContext(_),i=rt({member:e});if(!i||!i.cancel_at_period_end)return null;const o=h("Resume subscription"),r=["continueSubscription:running"].includes(n),s=!!r,c=Xt(i.current_period_end);return l.jsx("div",{className:"gh-portal-cancelcontinue-container",children:l.jsxs("div",{className:"gh-portal-cancel-banner",children:[l.jsx("p",{children:l.jsx($e,{string:h("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:l.jsx("strong",{children:c})}})}),l.jsx(me,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:r,disabled:s,isPrimary:!0,brandColor:a,label:o,style:{width:"100%"}})]})})},NP=e=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("defs",null,v.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),v.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"}),v.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"})),AP=()=>{const{member:e,site:t,doAction:n}=v.useContext(_),a=()=>{const m=rt({member:e});n("manageBilling",{subscriptionId:m.id})},i=()=>{const{is_stripe_configured:m}=t;m&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},o=({price:m,isComplimentary:f,subscription:b})=>{const{next_payment:w}=b||{};let g="";if(m){const{amount:E=0,currency:N,interval:z}=m;g=`${Intl.NumberFormat("en",{currency:N,style:"currency"}).format(E/100)}/${h(z)}`}const y=wd({member:e});f&&(y?g=`${h("Complimentary")} - ${h("Expires {expiryDate}",{expiryDate:y})}`:g=g?`${h("Complimentary")} (${g})`:h("Complimentary"));let k="";if(xd({sub:b}))return k="gh-portal-account-old-price",l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:g}),l.jsx(MP,{subscription:b})]});let x=DP({nextPayment:w});x&&(k="gh-portal-account-old-price");const T=()=>x?l.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[l.jsx(NP,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:x})]}):null;return l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:g}),l.jsx(T,{})]})},r=({isPaid:m})=>Ja({site:t})&&!m?null:l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:f=>i(),"data-test-button":"change-plan",children:h("Change")}),s=({defaultCardLast4:m})=>{if(m){const f=`**** **** **** ${m}`;return l.jsx("p",{children:f})}return null},c=({defaultCardLast4:m,isComplimentary:f})=>{const{action:b}=v.useContext(_),w=b==="manageBilling:running"?l.jsx(Xa,{className:"gh-portal-billing-button-loader"}):h("Update");return f?null:l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Billing info & receipts")}),l.jsx(s,{defaultCardLast4:m})]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>a(),"data-test-button":"manage-billing",children:w})]})},u=rt({member:e}),d=Pn({member:e}),p=Dt({member:e});if(u||d){const{price:m,default_payment_card_last4:f}=u||{};let b=h("Plan");return Bs({site:t})&&hb({member:e})&&(b=hb({member:e})),l.jsxs(l.Fragment,{children:[l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsxs("h3",{children:[b,(u==null?void 0:u.cancel_at_period_end)&&l.jsx("span",{className:"gh-portal-canceled-badge",children:h("Canceled")})]}),l.jsx(o,{price:m,isComplimentary:d,subscription:u})]}),l.jsx(r,{isPaid:p})]}),l.jsx(c,{isComplimentary:d,defaultCardLast4:f})]})}return null};function MP({subscription:e}){if(xd({sub:e})){const t=Xt(e.trial_end_at);return l.jsx("p",{className:"gh-portal-account-discountcontainer",children:l.jsx("div",{children:l.jsx("span",{children:h("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function DP({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";const n=t.end?h("Ends {offerEndDate}",{offerEndDate:Xt(t.end)}):h("Forever");return`${`${Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100)}/${h(e.interval)}`}${n?` — ${n}`:""}`}function FP(){const{member:e,site:t,doAction:n}=v.useContext(_);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let o=h(i?"Subscribed":"Unsubscribed");const r=s=>{var d;s.preventDefault();const c=ta({site:t}),u=(d=e==null?void 0:e.newsletters)!=null&&d.length?[]:c;n("updateNewsletterPreference",{newsletters:u})};return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[l.jsx("h3",{children:h("Email newsletter")}),l.jsxs("p",{children:[o," ",Cd({member:e})&&i&&l.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:h("Not receiving emails?")})]})]}),l.jsx("div",{children:l.jsx(tl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{r(s)},checked:i})})]})}const bk=e=>v.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},v.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"}),v.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 OP(){return l.jsxs("p",{className:"gh-portal-email-notice",children:[l.jsx(bk,{className:"gh-portal-email-notice-icon"}),l.jsx("span",{className:"gh-mobile-only",children:h("You're not receiving emails")}),l.jsx("span",{className:"gh-desktop-only",children:h("You're currently not receiving emails")})]})}function _P(){const{doAction:e,member:t,site:n}=v.useContext(_),a=yb({member:t}),i=jo({site:n}),o=Us({site:n}),r=a?"emailSuppressed":"accountEmail",s=!i&&!o,c=()=>a||s?l.jsx(OP,{}):l.jsx("p",{children:h("Update your preferences")});return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Emails")}),c()]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:r,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:h("Manage")})]})}const RP=()=>{const{member:e,site:t}=v.useContext(_),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,o=e==null?void 0:e.uuid,r=xb(),[s,c]=v.useState(r&&i);return v.useEffect(()=>{if(r){c(i);return}if(!i||!o){c(!1);return}c(!1);const u=new AbortController;return(async()=>{try{const p=await fetch(`https://partner.transistor.fm/ghost/member/${o}`,{signal:u.signal});if(p.ok){const m=await p.json();u.signal.aborted||c((m==null?void 0:m.member)===!0)}}catch(p){if(u.signal.aborted)return;console.warn("Error in Transistor request",p)}})(),()=>u.abort()},[i,o,r]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:o,settings:a}}},YP=(e,t)=>zo({site:e})&&jo({site:e})||Us({site:e})||yb({member:t}),LP=e=>!zo({site:e})&&jo({site:e})&&!Us({site:e}),BP=()=>{const{member:e,doAction:t,site:n}=v.useContext(_),{name:a,email:i}=e,{transistor:o}=RP(),r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=YP(n,e),c=LP(n);return l.jsx("div",{children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:a||h("Account")}),l.jsx("p",{children:i})]}),l.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:u=>r(),children:h("Edit")})]}),l.jsx(AP,{}),s&&l.jsx(_P,{}),c&&l.jsx(FP,{}),o.enabled&&l.jsx(SP,{hasPodcasts:o.hasPodcasts,memberUuid:o.memberUuid,settings:o.settings})]})})},UP=()=>l.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[l.jsx(pe,{}),l.jsx(TP,{}),l.jsxs("section",{className:"gh-portal-account-data",children:[l.jsx(zP,{}),l.jsx(IP,{}),l.jsx(BP,{})]})]}),Cm=class Cm extends Z.Component{componentDidMount(){const{member:t,site:n}=this.context;zn({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=Io({site:n});return!t||!zn({site:n})?null:l.jsxs("div",{className:"gh-portal-account-wrapper",children:[l.jsx(UP,{}),l.jsx(jP,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};Cm.contextType=_;let rm=Cm;const Em=class Em extends Z.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Oo({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(r=>!!r).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=h("Save");this.context.action==="updateProfile:failed"&&(n=h("Retry"));const a=!!t;return l.jsx(me,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return l.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:h("Delete account")})}renderAccountFooter(){return l.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),l.jsx("h3",{className:"gh-portal-main-title",children:h("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 l.jsx("div",{style:n,children:l.jsx(kd,{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:h("Jamie Larson"),label:h("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:h("jamie@example.com"),label:h("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(o=>n.includes(o.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return l.jsx("div",{className:"gh-portal-section",children:l.jsx(ti,{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?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pe,{}),this.renderHeader(),l.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};Em.contextType=_;let sm=Em;function HP(){const{brandColor:e,lastPage:t,doAction:n}=v.useContext(_);return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx("h3",{className:"gh-portal-main-title",children:h("Email preferences")})]})}function VP({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return l.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"newsletter-toggle",children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:e.name}),l.jsx("p",{children:e==null?void 0:e.description})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(tl,{id:e.id,onToggle:(i,o)=>{let r=[];o?r=t.filter(s=>s.id!==e.id).concat(e):r=t.filter(s=>s.id!==e.id),n(r)},checked:a,dataTestId:"switch-input"})})]})}function WP({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=v.useContext(_),i=!!n;if(!t)return null;const o=async(r,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:h("Comment preferences updated.")})};return l.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"comment-toggle",children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Comments")}),l.jsx("p",{children:h("Get notified when someone replies to your comment")})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(tl,{id:"comments",onToggle:o,checked:i,dataTestId:"switch-input"})})]})}function GP({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=v.useContext(_),i=ta({site:a});return n?i.map(o=>l.jsx(VP,{newsletter:o,subscribedNewsletters:e,setSubscribedNewsletters:t},o==null?void 0:o.id)):null}function KP({site:e,isPaid:t}){return t?l.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:h("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function kk({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:o,isPaidMember:r,isCommentsEnabled:s,enableCommentNotifications:c}){const{brandColor:u,doAction:d,member:p,site:m}=v.useContext(_),f=!(n!=null&&n.length)&&(s&&!c||!s),w=t||(()=>null);return l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pe,{}),l.jsx(HP,{}),l.jsx(w,{}),l.jsx("div",{className:"gh-portal-section flex",children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsx(GP,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:g=>{let y=g.map(k=>({id:k.id}));a(y)}}),l.jsx(WP,{isCommentsEnabled:s,enableCommentNotifications:c,updateCommentNotifications:i})]})}),l.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:l.jsx(me,{isRunning:!1,onClick:()=>{o()},disabled:f,brandColor:u,isPrimary:!1,label:h("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),l.jsxs("footer",{className:"gh-portal-action-footer"+(Cd({member:p})?" gh-feature-suppressions":""),children:[l.jsx("div",{style:{width:"100%"},children:l.jsx(KP,{isPaid:r,site:m,subscribedNewsletters:n})}),Cd({member:p})&&!f&&l.jsxs("div",{className:"gh-portal-footer-secondary",children:[l.jsx("span",{className:"gh-portal-footer-secondary-light",children:h("Not receiving emails?")}),l.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>d("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[h("Get help")," ",l.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function qP(){const{member:e,doAction:t,site:n,pageData:a}=v.useContext(_);let i,o;a&&(i=a.newsletterUuid,o=a.action);const[r,s]=v.useState(!0),c=ta({site:n}),u=jo({site:n});v.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),v.useEffect(()=>{if(i&&o==="unsubscribe"){const g=e==null?void 0:e.newsletters.filter(y=>y.uuid!==i);f(g),s(!1),t("updateNewsletterPreference",{newsletters:g})}},[]);const d=()=>{if(a.comments&&b){const k=r?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${k}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:e==null?void 0:e.email})}})})})}const g=c==null?void 0:c.find(k=>k.uuid===a.newsletterUuid);if(!g)return null;const y=r?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${y}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:l.jsx("strong",{children:g==null?void 0:g.name})}})})})},p=[...(e==null?void 0:e.newsletters)||[]],[m,f]=v.useState(p),{comments_enabled:b}=n,{enable_comment_notifications:w}=e||{};return v.useEffect(()=>{f((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),l.jsx(kk,{hasNewslettersEnabled:u,notification:i?d:null,subscribedNewsletters:m,updateSubscribedNewsletters:g=>{f(g),t("updateNewsletterPreference",{newsletters:g}),t("showPopupNotification",{action:"updated:success",message:h("Email preferences updated.")})},updateCommentNotifications:async g=>{t("updateNewsletterPreference",{enableCommentNotifications:g})},unsubscribeAll:()=>{f([]),t("showPopupNotification",{action:"updated:success",message:h("Unsubscribed from all emails.")});const g={newsletters:[]};b&&(g.enableCommentNotifications=!1),t("updateNewsletterPreference",g)},isPaidMember:Dt({member:e}),isCommentsEnabled:b!=="off",enableCommentNotifications:w})}function JP(){const{site:e}=v.useContext(_),t=e.icon;return t?l.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function ZP(){const{site:e}=v.useContext(_),t=e.title||"";return l.jsxs("header",{className:"gh-portal-header",children:[l.jsx(JP,{}),l.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function vk({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 XP(){const{site:e,api:t,pageData:n,member:a,doAction:i}=v.useContext(_),[o,r]=v.useState(),[s,c]=v.useState(!0),u=ta({site:e}),d=u.filter(z=>z.subscribe_on_signup),[p,m]=v.useState(!1),[f,b]=v.useState(d),[w,g]=v.useState(!1),{comments_enabled:y}=e,{enable_comment_notifications:k=!1}=o||{},C=jo({site:e}),x=async z=>{a?i("updateNewsletterPreference",{newsletters:z}):await vk({api:t,memberUuid:n.uuid,key:n.key,newsletters:z}),b(z);const j={action:"updated:success",message:h("Email preferences updated.")};i("showPopupNotification",j)},T=async z=>{let j;a?(await i("updateNewsletterPreference",{enableCommentNotifications:z}),j={...a,enable_comment_notifications:z}):j=await vk({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:z}),r(j),i("showPopupNotification",{action:"updated:success",message:h("Comment preferences updated.")})},E=async()=>{let z;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),z={...a},z.newsletters=[],z.enable_comment_notifications=!1):z=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),b([]),r(z),i("showPopupNotification",{action:"updated:success",message:h("Unsubscribed from all emails.")})};if(v.useEffect(()=>{(async()=>{let z;try{z=await t.member.newsletters({uuid:n.uuid,key:n.key}),r(z??null),c(!1)}catch(V){console.error("[PORTAL] Error fetching member newsletters",V),r(null),c(!1);return}if(z===null)return;const j=(z==null?void 0:z.newsletters)||[];b(j),(u==null?void 0:u.length)===1&&!y&&!n.newsletterUuid?await x([]):n.newsletterUuid?await x(j==null?void 0:j.filter(V=>V.uuid!==n.newsletterUuid)):n.comments&&y&&await T(!1)})()},[y,n.uuid,n.newsletterUuid,n.comments,e.url,u==null?void 0:u.length]),s)return l.jsx(ai,{});if(!o)return l.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:l.jsx(Od,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:h("That didn't go to plan")}),l.jsx("div",{children:l.jsx("p",{className:"gh-portal-text-center",children:h("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),l.jsx(me,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:h("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((u==null?void 0:u.length)===1&&!y&&!w)return l.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[l.jsx(pe,{}),l.jsx(ZP,{}),l.jsx("h1",{className:"gh-portal-main-title",children:h("Successfully unsubscribed")}),l.jsxs("div",{children:[l.jsx("p",{className:"gh-portal-text-center",children:l.jsx($e,{string:h("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email})}})}),l.jsx("p",{className:"gh-portal-text-center",children:l.jsx($e,{string:h("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:l.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{g(!0)}})}})})]})]});const N=()=>{if(n.comments&&y){const V=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${V}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email})}})})})}const z=u==null?void 0:u.find(V=>V.uuid===n.newsletterUuid);if(!z)return null;const j=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${j}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email}),newsletterName:l.jsx("strong",{children:z==null?void 0:z.name})}})})})};return l.jsx(kk,{hasNewslettersEnabled:C,notification:N,subscribedNewsletters:f,updateSubscribedNewsletters:async z=>{await x(z),m(!0)},updateCommentNotifications:T,unsubscribeAll:async()=>{await E(),m(!0)},isPaidMember:(o==null?void 0:o.status)!=="free",isCommentsEnabled:y!=="off",enableCommentNotifications:k})}function QP(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=v.useContext(_);v.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(zo({site:i})||Us({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:h("You have been successfully resubscribed")})):n("back"))},[a,n,i,h]);const o=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),r=()=>{n("removeEmailFromSuppressionList")};return l.jsxs("div",{className:"gh-email-suppressed-page",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx(pe,{})]}),l.jsx(bk,{className:"gh-email-suppressed-page-icon"}),l.jsxs("div",{className:"gh-email-suppressed-page-text",children:[l.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:h("Emails disabled")}),l.jsx("p",{children:h("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.")})]}),l.jsx(me,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:r,disabled:o,brandColor:e,label:h("Re-enable emails"),isRunning:o})]})}function e2(){const{brandColor:e,doAction:t,site:n,pageData:a}=v.useContext(_),i=`mailto:${Io({site:n})}`,o=a&&a.direct||!1;return l.jsxs("div",{className:"gh-email-suppression-faq",children:[!o&&l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),l.jsx(pe,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:h("Why has my email been disabled?")}),l.jsx("p",{children:h("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).")}),l.jsx("h4",{children:h("Spam complaints")}),l.jsx("p",{children:h("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:h("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.")}),l.jsx("h4",{children:h("Permanent failure (bounce)")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:h("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:l.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:h("Need more help? Contact support")})})]})]})}function t2(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:o}=v.useContext(_),r=Io({site:n}),s=`mailto:${r}`,c=_0({site:n}),u=o&&o.direct||!1;return l.jsxs("div",{className:"gh-email-receiving-faq",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[!u&&l.jsx(Qa,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),l.jsx(pe,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:h("Help! I'm not receiving emails")}),l.jsx("p",{children:h("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),l.jsx("h4",{children:h("Verify your email address is correct")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:i.email}),button:l.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),l.jsx("h4",{children:h("Check spam & promotions folders")}),l.jsx("p",{children:h(`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".`)}),l.jsx("h4",{children:h("Create a new contact")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Send an email and say hi!")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Check with your mail provider")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Get in touch for help")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:r})}})})]})]})}const n2=()=>{const[e,t]=v.useState(!0),[n,a]=v.useState(null),[i,o]=v.useState(null),{member:r,site:s}=v.useContext(_);return v.useEffect(()=>{async function c(){const u=s.url,d=window.location.origin+window.location.pathname,p=r?`${d}?action=support&success=true`:`${d}#/portal/support/success`,m=d,f=rl({siteUrl:u});try{const b=await f.member.checkoutDonation({successUrl:p,cancelUrl:m,personalNote:h("Add a personal note")});b.url&&window.location.replace(b.url)}catch(b){b.type&&b.type==="DisabledFeatureError"?o(h("This site is not accepting payments at the moment.")):a(h("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(o(h("This site is not accepting donations at the moment.")),t(!1)):c()},[]),e?l.jsx("div",{children:l.jsx(ai,{})}):n?l.jsx(im,{error:n}):i?l.jsx(im,{error:i}):null};function a2({product:e}){return!e.benefits||!e.benefits.length?null:l.jsx("div",{className:"gh-portal-product-benefits",children:e.benefits.map((t,n)=>{const a=(t==null?void 0:t.id)||`benefit-${n}`;return l.jsxs("div",{className:"gh-portal-product-benefit",children:[l.jsx(Do,{className:"gh-portal-benefit-checkmark",alt:""}),l.jsx("div",{className:"gh-portal-benefit-title",children:t.name})]},a)})})}function i2({product:e,selectedInterval:t}){const n=e.monthlyPrice,a=e.yearlyPrice;if(!n||!a)return null;const i=t==="month"?n:a,o=ke(i.currency),r=nl(n.amount,a.amount);return l.jsxs("div",{className:"gh-portal-product-card-pricecontainer",children:[l.jsxs("div",{className:"gh-portal-product-card-price-trial",children:[l.jsxs("div",{className:"gh-portal-product-price",children:[l.jsx("span",{className:"currency-sign"+(o.length>1?" long":""),children:o}),l.jsx("span",{className:"amount","data-testid":"product-amount",children:aa(Js(i.amount))})]}),t==="year"&&r>0&&l.jsxs("span",{className:"gh-portal-discount-label",children:[r,"% discount"]})]}),l.jsx("div",{className:"gh-portal-product-alternative-price",style:{display:"block"},children:"one-time payment"})]})}function o2({brandColor:e,product:t,selectedInterval:n,isDisabled:a,isPurchasing:i,onPurchase:o}){let r=t.description;return(!t.benefits||!t.benefits.length)&&!r&&(r="Full access"),l.jsxs("div",{className:"gh-portal-product-card","data-test-tier":"paid",children:[l.jsxs("div",{className:"gh-portal-product-card-header",children:[l.jsx("h4",{className:"gh-portal-product-name",children:t.name}),l.jsx(i2,{product:t,selectedInterval:n})]}),l.jsxs("div",{className:"gh-portal-product-card-details",children:[l.jsxs("div",{className:"gh-portal-product-card-detaildata",children:[r&&l.jsx("div",{className:"gh-portal-product-description","data-testid":"product-description",children:r}),l.jsx(a2,{product:t})]}),l.jsx("div",{className:"gh-portal-btn-product",children:l.jsx(me,{dataTestId:"purchase-gift",label:l.jsxs(l.Fragment,{children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"6px",verticalAlign:"middle"},children:[l.jsx("rect",{x:"3",y:"8",width:"18",height:"4",rx:"1"}),l.jsx("path",{d:"M12 8v13"}),l.jsx("path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}),l.jsx("path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"})]})," Gift this"]}),onClick:s=>o(s,t),disabled:a,isRunning:i,brandColor:e,style:{width:"100%"}})})]})]})}function r2({selectedInterval:e,setSelectedInterval:t,products:n}){const{site:a}=v.useContext(_),{portal_plans:i}=a,o=n.map(s=>{var c,u;return nl((c=s.monthlyPrice)==null?void 0:c.amount,(u=s.yearlyPrice)==null?void 0:u.amount)}),r=Math.max(...o);return!i.includes("monthly")||!i.includes("yearly")?null:l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-products-pricetoggle"+(e==="month"?" left":""),children:[l.jsx("button",{"data-test-button":"switch-monthly",className:"gh-portal-btn"+(e==="month"?" active":""),onClick:()=>t("month"),children:"1 month"}),l.jsxs("button",{"data-test-button":"switch-yearly",className:"gh-portal-btn"+(e==="year"?" active":""),onClick:()=>t("year"),children:["1 year",r>0&&l.jsxs("span",{className:"gh-portal-maximum-discount",children:["(save ",r,"%)"]})]})]})})}const s2=()=>{const{site:e,member:t,brandColor:n,action:a,doAction:i}=v.useContext(_),[o,r]=v.useState((t==null?void 0:t.email)||""),[s,c]=v.useState(""),[u,d]=v.useState(null),[p,m]=v.useState(null);if(!e)return l.jsx(ai,{});const{portal_plans:f,portal_default_plan:b}=e,w=Zs({portalPlans:f,portalDefaultPlan:b,selectedInterval:u}),g=To({site:e}).filter(N=>N.type==="paid");if(g.length===0){const N=e.icon;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"gh-portal-back-sitetitle",children:l.jsx(Fo,{})}),l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-content signup",children:[l.jsxs("header",{className:"gh-portal-signup-header",children:[N&&l.jsx("img",{className:"gh-portal-signup-logo",src:N,alt:e.title}),l.jsx("h1",{className:"gh-portal-main-title",children:e.title||""})]}),l.jsx("section",{children:l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-invite-only-notification",children:"Gift subscriptions are not available right now."})})})]})]})}const y=e.icon,k=e.title||"",C=a==="checkoutGift:running",x=Zn()||C,T=[{type:"email",value:o,placeholder:"jamie@example.com",label:"Your email",name:"email",required:!0,tabIndex:1,autoFocus:!0,errorMessage:s}],E=(N,z)=>{N.preventDefault();const j=Oo({fields:T});if(j.email){c(j.email);return}c(""),m(z.id),i("checkoutGift",{tierId:z.id,cadence:w,email:o})};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"gh-portal-back-sitetitle",children:l.jsx(Fo,{})}),l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-content signup",children:[l.jsxs("header",{className:"gh-portal-signup-header",children:[y&&l.jsx("img",{className:"gh-portal-signup-logo",src:y,alt:k}),l.jsx("h1",{className:"gh-portal-main-title",children:k}),l.jsx("p",{className:"gh-portal-main-subtitle",style:{fontSize:"1.7rem",marginTop:"8px"},children:"Give the gift of a membership"})]}),l.jsx("section",{className:"gh-portal-signup",children:l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsx(ti,{fields:T,onChange:N=>{r(N.target.value),s&&c("")}})}),l.jsxs("section",{className:"gh-portal-products",children:[l.jsx(r2,{selectedInterval:w,setSelectedInterval:d,products:g}),l.jsx("div",{className:"gh-portal-products-grid",children:g.map(N=>l.jsx(o2,{brandColor:n,product:N,selectedInterval:w,isDisabled:x,isPurchasing:C&&p===N.id,onPurchase:E},N.id))})]}),l.jsx("div",{className:"gh-portal-signup-message",children:l.jsx("div",{children:"Only redeemable by free or new members."})})]})})]})]})},l2=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},Ho=(e,t)=>{const n=new URLSearchParams(t);return`${e}?${n.toString()}`},c2=({shareTitle:e,shareUrl:t})=>{const n=[e,t].filter(Boolean).join(`
4118
+ `;function $P({site:e}){return vd+xP+x1+O1+K1+C1()+S1+b1+w1+db+_T+$T+BT()+Dd+RT+CP+EP+HT+ZT+XT+QT+tP+oP+pP+lP+gP+vP+wP}const xm=class xm extends Z.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Oo({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:o}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:o,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:h("jamie@example.com"),label:h("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=h(a?"Sending login link...":"Continue");const o=!!a;return t==="signin:failed"&&(i=h("Retry"),n=!0),l.jsx(me,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:r=>this.handleSignin(r),disabled:o,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return l.jsxs("div",{className:"gh-portal-signup-message",children:[l.jsx("div",{children:h("Don't have an account?")}),l.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:l.jsx("span",{children:h("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=Ls({site:t})&&Qt({site:t});return zn({site:t})?l.jsxs("section",{children:[l.jsx("div",{className:"gh-portal-section",children:l.jsx(ti,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),l.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):l.jsx("section",{children:l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:h("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?l.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):zn({site:t})?null:l.jsx(Gb,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return zn({site:t})?l.jsx("h1",{className:"gh-portal-main-title",children:h("Sign in")}):l.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return l.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return l.jsxs(l.Fragment,{children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};xm.contextType=_;let om=xm;const jP=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return l.jsxs("footer",{className:"gh-portal-account-footer",children:[l.jsx("ul",{className:"gh-portal-account-footermenu",children:l.jsx("li",{children:l.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:h("Sign out")})})}),l.jsx("div",{className:"gh-portal-account-footerright",children:l.jsx("ul",{className:"gh-portal-account-footermenu",children:l.jsx("li",{children:l.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:h("Contact support")})})})})]})},TP=()=>{const{member:e,brandColor:t}=v.useContext(_),n=e.avatar_image;return l.jsxs("header",{className:"gh-portal-account-header",children:[l.jsx(kd,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),l.jsx("h2",{className:"gh-portal-main-title",children:h("Your account")})]})},PP=()=>{const{site:e,action:t,brandColor:n,doAction:a}=v.useContext(_);if(!Ls({site:e})||!Qt({site:e}))return null;const i=["checkoutPlan:running"].includes(t),o=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return l.jsx(me,{dataTestId:"view-plans",isRunning:i,label:h("View plans"),onClick:()=>o(),brandColor:n,style:{width:"100%"}})},zP=()=>{const{member:e,site:t}=v.useContext(_),{is_stripe_configured:n}=t;if(!n||Ja({site:t}))return null;const a=rt({member:e}),i=Pn({member:e});if(i&&!a)return null;if(a){const o=a==null?void 0:a.current_period_end;if(i&&wd({member:e})){const r=wd({member:e}),s=Xt(r);return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(xd({sub:a})){const r=Xt(a.trial_end_at);return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will start on {subscriptionStart}",{subscriptionStart:r})})})}return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("Your subscription will renew on {renewalDate}",{renewalDate:Xt(o)})})})}return l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:h("You currently have a free membership, upgrade to a paid subscription for full access.")}),l.jsx(PP,{})]})},IP=()=>{const{member:e,doAction:t,action:n,brandColor:a}=v.useContext(_),i=rt({member:e});if(!i||!i.cancel_at_period_end)return null;const o=h("Resume subscription"),r=["continueSubscription:running"].includes(n),s=!!r,c=Xt(i.current_period_end);return l.jsx("div",{className:"gh-portal-cancelcontinue-container",children:l.jsxs("div",{className:"gh-portal-cancel-banner",children:[l.jsx("p",{children:l.jsx($e,{string:h("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:l.jsx("strong",{children:c})}})}),l.jsx(me,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:r,disabled:s,isPrimary:!0,brandColor:a,label:o,style:{width:"100%"}})]})})},NP=e=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("defs",null,v.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),v.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"}),v.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"})),AP=()=>{const{member:e,site:t,doAction:n}=v.useContext(_),a=()=>{const m=rt({member:e});n("manageBilling",{subscriptionId:m.id})},i=()=>{const{is_stripe_configured:m}=t;m&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},o=({price:m,isComplimentary:f,subscription:b})=>{const{next_payment:w}=b||{};let g="";if(m){const{amount:E=0,currency:N,interval:z}=m;g=`${Intl.NumberFormat("en",{currency:N,style:"currency"}).format(E/100)}/${h(z)}`}const y=wd({member:e});f&&(y?g=`${h("Complimentary")} - ${h("Expires {expiryDate}",{expiryDate:y})}`:g=g?`${h("Complimentary")} (${g})`:h("Complimentary"));let k="";if(xd({sub:b}))return k="gh-portal-account-old-price",l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:g}),l.jsx(MP,{subscription:b})]});let x=DP({nextPayment:w});x&&(k="gh-portal-account-old-price");const T=()=>x?l.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[l.jsx(NP,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:x})]}):null;return l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:g}),l.jsx(T,{})]})},r=({isPaid:m})=>Ja({site:t})&&!m?null:l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:f=>i(),"data-test-button":"change-plan",children:h("Change")}),s=({defaultCardLast4:m})=>{if(m){const f=`**** **** **** ${m}`;return l.jsx("p",{children:f})}return null},c=({defaultCardLast4:m,isComplimentary:f})=>{const{action:b}=v.useContext(_),w=b==="manageBilling:running"?l.jsx(Xa,{className:"gh-portal-billing-button-loader"}):h("Update");return f?null:l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Billing info & receipts")}),l.jsx(s,{defaultCardLast4:m})]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>a(),"data-test-button":"manage-billing",children:w})]})},u=rt({member:e}),d=Pn({member:e}),p=Dt({member:e});if(u||d){const{price:m,default_payment_card_last4:f}=u||{};let b=h("Plan");return Bs({site:t})&&hb({member:e})&&(b=hb({member:e})),l.jsxs(l.Fragment,{children:[l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsxs("h3",{children:[b,(u==null?void 0:u.cancel_at_period_end)&&l.jsx("span",{className:"gh-portal-canceled-badge",children:h("Canceled")})]}),l.jsx(o,{price:m,isComplimentary:d,subscription:u})]}),l.jsx(r,{isPaid:p})]}),l.jsx(c,{isComplimentary:d,defaultCardLast4:f})]})}return null};function MP({subscription:e}){if(xd({sub:e})){const t=Xt(e.trial_end_at);return l.jsx("p",{className:"gh-portal-account-discountcontainer",children:l.jsx("div",{children:l.jsx("span",{children:h("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function DP({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";const n=t.end?h("Ends {offerEndDate}",{offerEndDate:Xt(t.end)}):h("Forever");return`${`${Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100)}/${h(e.interval)}`}${n?` — ${n}`:""}`}function FP(){const{member:e,site:t,doAction:n}=v.useContext(_);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let o=h(i?"Subscribed":"Unsubscribed");const r=s=>{var d;s.preventDefault();const c=ta({site:t}),u=(d=e==null?void 0:e.newsletters)!=null&&d.length?[]:c;n("updateNewsletterPreference",{newsletters:u})};return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[l.jsx("h3",{children:h("Email newsletter")}),l.jsxs("p",{children:[o," ",Cd({member:e})&&i&&l.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:h("Not receiving emails?")})]})]}),l.jsx("div",{children:l.jsx(tl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{r(s)},checked:i})})]})}const bk=e=>v.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},v.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"}),v.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 OP(){return l.jsxs("p",{className:"gh-portal-email-notice",children:[l.jsx(bk,{className:"gh-portal-email-notice-icon"}),l.jsx("span",{className:"gh-mobile-only",children:h("You're not receiving emails")}),l.jsx("span",{className:"gh-desktop-only",children:h("You're currently not receiving emails")})]})}function _P(){const{doAction:e,member:t,site:n}=v.useContext(_),a=yb({member:t}),i=jo({site:n}),o=Us({site:n}),r=a?"emailSuppressed":"accountEmail",s=!i&&!o,c=()=>a||s?l.jsx(OP,{}):l.jsx("p",{children:h("Update your preferences")});return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Emails")}),c()]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:r,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:h("Manage")})]})}const RP=()=>{const{member:e,site:t}=v.useContext(_),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,o=e==null?void 0:e.uuid,r=xb(),[s,c]=v.useState(r&&i);return v.useEffect(()=>{if(r){c(i);return}if(!i||!o){c(!1);return}c(!1);const u=new AbortController;return(async()=>{try{const p=await fetch(`https://partner.transistor.fm/ghost/member/${o}`,{signal:u.signal});if(p.ok){const m=await p.json();u.signal.aborted||c((m==null?void 0:m.member)===!0)}}catch(p){if(u.signal.aborted)return;console.warn("Error in Transistor request",p)}})(),()=>u.abort()},[i,o,r]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:o,settings:a}}},YP=(e,t)=>zo({site:e})&&jo({site:e})||Us({site:e})||yb({member:t}),LP=e=>!zo({site:e})&&jo({site:e})&&!Us({site:e}),BP=()=>{const{member:e,doAction:t,site:n}=v.useContext(_),{name:a,email:i}=e,{transistor:o}=RP(),r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=YP(n,e),c=LP(n);return l.jsx("div",{children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:a||h("Account")}),l.jsx("p",{children:i})]}),l.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:u=>r(),children:h("Edit")})]}),l.jsx(AP,{}),s&&l.jsx(_P,{}),c&&l.jsx(FP,{}),o.enabled&&l.jsx(SP,{hasPodcasts:o.hasPodcasts,memberUuid:o.memberUuid,settings:o.settings})]})})},UP=()=>l.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[l.jsx(pe,{}),l.jsx(TP,{}),l.jsxs("section",{className:"gh-portal-account-data",children:[l.jsx(zP,{}),l.jsx(IP,{}),l.jsx(BP,{})]})]}),Cm=class Cm extends Z.Component{componentDidMount(){const{member:t,site:n}=this.context;zn({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=Io({site:n});return!t||!zn({site:n})?null:l.jsxs("div",{className:"gh-portal-account-wrapper",children:[l.jsx(UP,{}),l.jsx(jP,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};Cm.contextType=_;let rm=Cm;const Em=class Em extends Z.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Oo({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(r=>!!r).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=h("Save");this.context.action==="updateProfile:failed"&&(n=h("Retry"));const a=!!t;return l.jsx(me,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return l.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:h("Delete account")})}renderAccountFooter(){return l.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),l.jsx("h3",{className:"gh-portal-main-title",children:h("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 l.jsx("div",{style:n,children:l.jsx(kd,{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:h("Jamie Larson"),label:h("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:h("jamie@example.com"),label:h("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(o=>n.includes(o.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return l.jsx("div",{className:"gh-portal-section",children:l.jsx(ti,{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?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pe,{}),this.renderHeader(),l.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};Em.contextType=_;let sm=Em;function HP(){const{brandColor:e,lastPage:t,doAction:n}=v.useContext(_);return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx("h3",{className:"gh-portal-main-title",children:h("Email preferences")})]})}function VP({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return l.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"newsletter-toggle",children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:e.name}),l.jsx("p",{children:e==null?void 0:e.description})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(tl,{id:e.id,onToggle:(i,o)=>{let r=[];o?r=t.filter(s=>s.id!==e.id).concat(e):r=t.filter(s=>s.id!==e.id),n(r)},checked:a,dataTestId:"switch-input"})})]})}function WP({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=v.useContext(_),i=!!n;if(!t)return null;const o=async(r,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:h("Comment preferences updated.")})};return l.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"comment-toggle",children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:h("Comments")}),l.jsx("p",{children:h("Get notified when someone replies to your comment")})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(tl,{id:"comments",onToggle:o,checked:i,dataTestId:"switch-input"})})]})}function GP({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=v.useContext(_),i=ta({site:a});return n?i.map(o=>l.jsx(VP,{newsletter:o,subscribedNewsletters:e,setSubscribedNewsletters:t},o==null?void 0:o.id)):null}function KP({site:e,isPaid:t}){return t?l.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:h("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function kk({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:o,isPaidMember:r,isCommentsEnabled:s,enableCommentNotifications:c}){const{brandColor:u,doAction:d,member:p,site:m}=v.useContext(_),f=!(n!=null&&n.length)&&(s&&!c||!s),w=t||(()=>null);return l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pe,{}),l.jsx(HP,{}),l.jsx(w,{}),l.jsx("div",{className:"gh-portal-section flex",children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsx(GP,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:g=>{let y=g.map(k=>({id:k.id}));a(y)}}),l.jsx(WP,{isCommentsEnabled:s,enableCommentNotifications:c,updateCommentNotifications:i})]})}),l.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:l.jsx(me,{isRunning:!1,onClick:()=>{o()},disabled:f,brandColor:u,isPrimary:!1,label:h("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),l.jsxs("footer",{className:"gh-portal-action-footer"+(Cd({member:p})?" gh-feature-suppressions":""),children:[l.jsx("div",{style:{width:"100%"},children:l.jsx(KP,{isPaid:r,site:m,subscribedNewsletters:n})}),Cd({member:p})&&!f&&l.jsxs("div",{className:"gh-portal-footer-secondary",children:[l.jsx("span",{className:"gh-portal-footer-secondary-light",children:h("Not receiving emails?")}),l.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>d("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[h("Get help")," ",l.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function qP(){const{member:e,doAction:t,site:n,pageData:a}=v.useContext(_);let i,o;a&&(i=a.newsletterUuid,o=a.action);const[r,s]=v.useState(!0),c=ta({site:n}),u=jo({site:n});v.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),v.useEffect(()=>{if(i&&o==="unsubscribe"){const g=e==null?void 0:e.newsletters.filter(y=>y.uuid!==i);f(g),s(!1),t("updateNewsletterPreference",{newsletters:g})}},[]);const d=()=>{if(a.comments&&b){const k=r?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${k}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:e==null?void 0:e.email})}})})})}const g=c==null?void 0:c.find(k=>k.uuid===a.newsletterUuid);if(!g)return null;const y=r?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${y}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:l.jsx("strong",{children:g==null?void 0:g.name})}})})})},p=[...(e==null?void 0:e.newsletters)||[]],[m,f]=v.useState(p),{comments_enabled:b}=n,{enable_comment_notifications:w}=e||{};return v.useEffect(()=>{f((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),l.jsx(kk,{hasNewslettersEnabled:u,notification:i?d:null,subscribedNewsletters:m,updateSubscribedNewsletters:g=>{f(g),t("updateNewsletterPreference",{newsletters:g}),t("showPopupNotification",{action:"updated:success",message:h("Email preferences updated.")})},updateCommentNotifications:async g=>{t("updateNewsletterPreference",{enableCommentNotifications:g})},unsubscribeAll:()=>{f([]),t("showPopupNotification",{action:"updated:success",message:h("Unsubscribed from all emails.")});const g={newsletters:[]};b&&(g.enableCommentNotifications=!1),t("updateNewsletterPreference",g)},isPaidMember:Dt({member:e}),isCommentsEnabled:b!=="off",enableCommentNotifications:w})}function JP(){const{site:e}=v.useContext(_),t=e.icon;return t?l.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function ZP(){const{site:e}=v.useContext(_),t=e.title||"";return l.jsxs("header",{className:"gh-portal-header",children:[l.jsx(JP,{}),l.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function vk({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 XP(){const{site:e,api:t,pageData:n,member:a,doAction:i}=v.useContext(_),[o,r]=v.useState(),[s,c]=v.useState(!0),u=ta({site:e}),d=u.filter(z=>z.subscribe_on_signup),[p,m]=v.useState(!1),[f,b]=v.useState(d),[w,g]=v.useState(!1),{comments_enabled:y}=e,{enable_comment_notifications:k=!1}=o||{},C=jo({site:e}),x=async z=>{a?i("updateNewsletterPreference",{newsletters:z}):await vk({api:t,memberUuid:n.uuid,key:n.key,newsletters:z}),b(z);const j={action:"updated:success",message:h("Email preferences updated.")};i("showPopupNotification",j)},T=async z=>{let j;a?(await i("updateNewsletterPreference",{enableCommentNotifications:z}),j={...a,enable_comment_notifications:z}):j=await vk({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:z}),r(j),i("showPopupNotification",{action:"updated:success",message:h("Comment preferences updated.")})},E=async()=>{let z;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),z={...a},z.newsletters=[],z.enable_comment_notifications=!1):z=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),b([]),r(z),i("showPopupNotification",{action:"updated:success",message:h("Unsubscribed from all emails.")})};if(v.useEffect(()=>{(async()=>{let z;try{z=await t.member.newsletters({uuid:n.uuid,key:n.key}),r(z??null),c(!1)}catch(V){console.error("[PORTAL] Error fetching member newsletters",V),r(null),c(!1);return}if(z===null)return;const j=(z==null?void 0:z.newsletters)||[];b(j),(u==null?void 0:u.length)===1&&!y&&!n.newsletterUuid?await x([]):n.newsletterUuid?await x(j==null?void 0:j.filter(V=>V.uuid!==n.newsletterUuid)):n.comments&&y&&await T(!1)})()},[y,n.uuid,n.newsletterUuid,n.comments,e.url,u==null?void 0:u.length]),s)return l.jsx(ai,{});if(!o)return l.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:l.jsx(Od,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:h("That didn't go to plan")}),l.jsx("div",{children:l.jsx("p",{className:"gh-portal-text-center",children:h("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),l.jsx(me,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:h("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((u==null?void 0:u.length)===1&&!y&&!w)return l.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[l.jsx(pe,{}),l.jsx(ZP,{}),l.jsx("h1",{className:"gh-portal-main-title",children:h("Successfully unsubscribed")}),l.jsxs("div",{children:[l.jsx("p",{className:"gh-portal-text-center",children:l.jsx($e,{string:h("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email})}})}),l.jsx("p",{className:"gh-portal-text-center",children:l.jsx($e,{string:h("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:l.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{g(!0)}})}})})]})]});const N=()=>{if(n.comments&&y){const V=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${V}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email})}})})})}const z=u==null?void 0:u.find(V=>V.uuid===n.newsletterUuid);if(!z)return null;const j=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${j}`,children:l.jsx($e,{string:h("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email}),newsletterName:l.jsx("strong",{children:z==null?void 0:z.name})}})})})};return l.jsx(kk,{hasNewslettersEnabled:C,notification:N,subscribedNewsletters:f,updateSubscribedNewsletters:async z=>{await x(z),m(!0)},updateCommentNotifications:T,unsubscribeAll:async()=>{await E(),m(!0)},isPaidMember:(o==null?void 0:o.status)!=="free",isCommentsEnabled:y!=="off",enableCommentNotifications:k})}function QP(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=v.useContext(_);v.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(zo({site:i})||Us({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:h("You have been successfully resubscribed")})):n("back"))},[a,n,i,h]);const o=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),r=()=>{n("removeEmailFromSuppressionList")};return l.jsxs("div",{className:"gh-email-suppressed-page",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx(pe,{})]}),l.jsx(bk,{className:"gh-email-suppressed-page-icon"}),l.jsxs("div",{className:"gh-email-suppressed-page-text",children:[l.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:h("Emails disabled")}),l.jsx("p",{children:h("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.")})]}),l.jsx(me,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:r,disabled:o,brandColor:e,label:h("Re-enable emails"),isRunning:o})]})}function e2(){const{brandColor:e,doAction:t,site:n,pageData:a}=v.useContext(_),i=`mailto:${Io({site:n})}`,o=a&&a.direct||!1;return l.jsxs("div",{className:"gh-email-suppression-faq",children:[!o&&l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Qa,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),l.jsx(pe,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:h("Why has my email been disabled?")}),l.jsx("p",{children:h("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).")}),l.jsx("h4",{children:h("Spam complaints")}),l.jsx("p",{children:h("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:h("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.")}),l.jsx("h4",{children:h("Permanent failure (bounce)")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:h("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),l.jsx("p",{children:h("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.")}),l.jsx("p",{children:l.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:h("Need more help? Contact support")})})]})]})}function t2(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:o}=v.useContext(_),r=Io({site:n}),s=`mailto:${r}`,c=_0({site:n}),u=o&&o.direct||!1;return l.jsxs("div",{className:"gh-email-receiving-faq",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[!u&&l.jsx(Qa,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),l.jsx(pe,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:h("Help! I'm not receiving emails")}),l.jsx("p",{children:h("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),l.jsx("h4",{children:h("Verify your email address is correct")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:i.email}),button:l.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),l.jsx("h4",{children:h("Check spam & promotions folders")}),l.jsx("p",{children:h(`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".`)}),l.jsx("h4",{children:h("Create a new contact")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Send an email and say hi!")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Check with your mail provider")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("strong",{children:c})}})}),l.jsx("h4",{children:h("Get in touch for help")}),l.jsx("p",{children:l.jsx($e,{string:h("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:l.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:r})}})})]})]})}const n2=()=>{const[e,t]=v.useState(!0),[n,a]=v.useState(null),[i,o]=v.useState(null),{member:r,site:s}=v.useContext(_);return v.useEffect(()=>{async function c(){const u=s.url,d=window.location.origin+window.location.pathname,p=r?`${d}?action=support&success=true`:`${d}#/portal/support/success`,m=d,f=rl({siteUrl:u});try{const b=await f.member.checkoutDonation({successUrl:p,cancelUrl:m,personalNote:h("Add a personal note")});b.url&&window.location.replace(b.url)}catch(b){b.type&&b.type==="DisabledFeatureError"?o(h("This site is not accepting payments at the moment.")):a(h("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(o(h("This site is not accepting donations at the moment.")),t(!1)):c()},[]),e?l.jsx("div",{children:l.jsx(ai,{})}):n?l.jsx(im,{error:n}):i?l.jsx(im,{error:i}):null};function a2({product:e}){return!e.benefits||!e.benefits.length?null:l.jsx("div",{className:"gh-portal-product-benefits",children:e.benefits.map((t,n)=>{const a=(t==null?void 0:t.id)||`benefit-${n}`;return l.jsxs("div",{className:"gh-portal-product-benefit",children:[l.jsx(Do,{className:"gh-portal-benefit-checkmark",alt:""}),l.jsx("div",{className:"gh-portal-benefit-title",children:t.name})]},a)})})}function i2({product:e,selectedInterval:t}){const n=e.monthlyPrice,a=e.yearlyPrice;if(!n||!a)return null;const i=t==="month"?n:a,o=ke(i.currency),r=nl(n.amount,a.amount);return l.jsxs("div",{className:"gh-portal-product-card-pricecontainer",children:[l.jsxs("div",{className:"gh-portal-product-card-price-trial",children:[l.jsxs("div",{className:"gh-portal-product-price",children:[l.jsx("span",{className:"currency-sign"+(o.length>1?" long":""),children:o}),l.jsx("span",{className:"amount","data-testid":"product-amount",children:aa(Js(i.amount))})]}),t==="year"&&r>0&&l.jsxs("span",{className:"gh-portal-discount-label",children:[r,"% discount"]})]}),l.jsx("span",{style:{display:"block",opacity:"0.5"},children:"one-time payment"})]})}function o2({brandColor:e,product:t,selectedInterval:n,isDisabled:a,isPurchasing:i,onPurchase:o}){let r=t.description;return(!t.benefits||!t.benefits.length)&&!r&&(r="Full access"),l.jsxs("div",{className:"gh-portal-product-card","data-test-tier":"paid",children:[l.jsxs("div",{className:"gh-portal-product-card-header",children:[l.jsx("h4",{className:"gh-portal-product-name",children:t.name}),l.jsx(i2,{product:t,selectedInterval:n})]}),l.jsxs("div",{className:"gh-portal-product-card-details",children:[l.jsxs("div",{className:"gh-portal-product-card-detaildata",children:[r&&l.jsx("div",{className:"gh-portal-product-description","data-testid":"product-description",children:r}),l.jsx(a2,{product:t})]}),l.jsx("div",{className:"gh-portal-btn-product",children:l.jsx(me,{dataTestId:"purchase-gift",label:l.jsxs(l.Fragment,{children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"6px",verticalAlign:"middle"},children:[l.jsx("rect",{x:"3",y:"8",width:"18",height:"4",rx:"1"}),l.jsx("path",{d:"M12 8v13"}),l.jsx("path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}),l.jsx("path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"})]})," Gift this"]}),onClick:s=>o(s,t),disabled:a,isRunning:i,brandColor:e,style:{width:"100%"}})})]})]})}function r2({selectedInterval:e,setSelectedInterval:t,products:n}){const{site:a}=v.useContext(_),{portal_plans:i}=a,o=n.map(s=>{var c,u;return nl((c=s.monthlyPrice)==null?void 0:c.amount,(u=s.yearlyPrice)==null?void 0:u.amount)}),r=Math.max(...o);return!i.includes("monthly")||!i.includes("yearly")?null:l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-products-pricetoggle"+(e==="month"?" left":""),children:[l.jsx("button",{"data-test-button":"switch-monthly",className:"gh-portal-btn"+(e==="month"?" active":""),onClick:()=>t("month"),children:"1 month"}),l.jsxs("button",{"data-test-button":"switch-yearly",className:"gh-portal-btn"+(e==="year"?" active":""),onClick:()=>t("year"),children:["1 year",r>0&&l.jsxs("span",{className:"gh-portal-maximum-discount",children:["(save ",r,"%)"]})]})]})})}const s2=()=>{const{site:e,member:t,brandColor:n,action:a,doAction:i}=v.useContext(_),[o,r]=v.useState((t==null?void 0:t.email)||""),[s,c]=v.useState(""),[u,d]=v.useState(null),[p,m]=v.useState(null);if(!e)return l.jsx(ai,{});const{portal_plans:f,portal_default_plan:b}=e,w=Zs({portalPlans:f,portalDefaultPlan:b,selectedInterval:u}),g=To({site:e}).filter(N=>N.type==="paid");if(g.length===0){const N=e.icon;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"gh-portal-back-sitetitle",children:l.jsx(Fo,{})}),l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-content signup",children:[l.jsxs("header",{className:"gh-portal-signup-header",children:[N&&l.jsx("img",{className:"gh-portal-signup-logo",src:N,alt:e.title}),l.jsx("h1",{className:"gh-portal-main-title",children:e.title||""})]}),l.jsx("section",{children:l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-invite-only-notification",children:"Gift subscriptions are not available right now."})})})]})]})}const y=e.icon,k=e.title||"",C=a==="checkoutGift:running",x=Zn()||C,T=[{type:"email",value:o,placeholder:"jamie@example.com",label:"Your email",name:"email",required:!0,tabIndex:1,autoFocus:!0,errorMessage:s}],E=(N,z)=>{N.preventDefault();const j=Oo({fields:T});if(j.email){c(j.email);return}c(""),m(z.id),i("checkoutGift",{tierId:z.id,cadence:w,email:o})};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"gh-portal-back-sitetitle",children:l.jsx(Fo,{})}),l.jsx(pe,{}),l.jsxs("div",{className:"gh-portal-content signup",children:[l.jsxs("header",{className:"gh-portal-signup-header",children:[y&&l.jsx("img",{className:"gh-portal-signup-logo",src:y,alt:k}),l.jsx("h1",{className:"gh-portal-main-title",children:k}),l.jsx("p",{className:"gh-portal-main-subtitle",style:{fontSize:"1.7rem",marginTop:"8px"},children:"Give the gift of a membership"})]}),l.jsx("section",{className:"gh-portal-signup",children:l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsx(ti,{fields:T,onChange:N=>{r(N.target.value),s&&c("")}})}),l.jsxs("section",{className:"gh-portal-products",children:[l.jsx(r2,{selectedInterval:w,setSelectedInterval:d,products:g}),l.jsx("div",{className:"gh-portal-products-grid",children:g.map(N=>l.jsx(o2,{brandColor:n,product:N,selectedInterval:w,isDisabled:x,isPurchasing:C&&p===N.id,onPurchase:E},N.id))})]}),l.jsx("div",{className:"gh-portal-signup-message",children:l.jsx("div",{children:"Only redeemable by free or new members."})})]})})]})]})},l2=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},Ho=(e,t)=>{const n=new URLSearchParams(t);return`${e}?${n.toString()}`},c2=({shareTitle:e,shareUrl:t})=>{const n=[e,t].filter(Boolean).join(`
4132
4119
 
4133
- `),a=[];return e&&a.push(`subject=${encodeURIComponent(e)}`),n&&a.push(`body=${encodeURIComponent(n)}`),`mailto:${a.length?`?${a.join("&")}`:""}`},u2=({shareTitle:e,shareUrl:t})=>Ho("https://www.linkedin.com/shareArticle",{mini:"true",url:t,title:e}),d2=()=>{const e=l2(),t=e.document,n=e.location,a=(b,w="content")=>{var g;return((g=t.querySelector(b))==null?void 0:g[w])||""},i=a('link[rel="canonical"]',"href")||n.origin+n.pathname+n.search,o=a('meta[property="og:title"]')||t.title||"",r=a('meta[property="og:description"]')||a('meta[name="description"]')||"",s=a('meta[property="og:image"]')||a('meta[name="twitter:image"]')||"",c=a('link[rel="icon"]',"href")||a('link[rel="shortcut icon"]',"href")||a('link[rel="apple-touch-icon"]',"href"),u=a('meta[name="author"]'),d=(u&&!/^https?:\/\//i.test(u)?u:"")||a('meta[name="twitter:creator"]')||"";let p=a('meta[property="og:site_name"]')||a('meta[name="application-name"]')||"";if(!p)try{p=new URL(i).hostname.replace(/^www\./,"")}catch{p=""}const m=[o,i].filter(Boolean).join(" ").trim(),f={twitter:Ho("https://twitter.com/intent/tweet",{url:i,text:o}),facebook:Ho("https://www.facebook.com/sharer/sharer.php",{u:i}),email:c2({shareTitle:o,shareUrl:i}),threads:Ho("https://www.threads.net/intent/post",{text:m}),linkedin:u2({shareTitle:o,shareUrl:i}),bluesky:Ho("https://bsky.app/intent/compose",{text:m})};return{shareUrl:i,shareTitle:o,shareExcerpt:r,shareImage:s,shareFavicon:c,shareSiteName:p,shareAuthor:d,socialLinks:f}},m2=()=>{const[e]=v.useState(d2);return e},p2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...e},v.createElement("path",{fill:"#0085ff",d:"M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805zm36.254 0C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745z"})),h2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-ellipsis-icon lucide-ellipsis",...e},v.createElement("circle",{cx:12,cy:12,r:1}),v.createElement("circle",{cx:19,cy:12,r:1}),v.createElement("circle",{cx:5,cy:12,r:1})),f2=e=>v.createElement("svg",{id:"svg9",width:666.66669,height:666.66718,viewBox:"0 0 666.66668 666.66717",xmlns:"http://www.w3.org/2000/svg","xmlns:svg":"http://www.w3.org/2000/svg",...e},v.createElement("defs",{id:"defs13"},v.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},v.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),v.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},v.createElement("g",{id:"g19"},v.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},v.createElement("g",{id:"g27",transform:"translate(600,350)"},v.createElement("path",{d:"m 0,0 c 0,138.071 -111.929,250 -250,250 -138.071,0 -250,-111.929 -250,-250 0,-117.245 80.715,-215.622 189.606,-242.638 v 166.242 h -51.552 V 0 h 51.552 v 32.919 c 0,85.092 38.508,124.532 122.048,124.532 15.838,0 43.167,-3.105 54.347,-6.211 V 81.986 c -5.901,0.621 -16.149,0.932 -28.882,0.932 -40.993,0 -56.832,-15.528 -56.832,-55.9 V 0 h 81.659 l -14.028,-76.396 h -67.631 V -248.169 C -95.927,-233.218 0,-127.818 0,0",style:{fill:"#0866ff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path29"})),v.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},v.createElement("path",{d:"M 0,0 14.029,76.396 H -67.63 v 27.019 c 0,40.372 15.838,55.899 56.831,55.899 12.733,0 22.981,-0.31 28.882,-0.931 v 69.253 c -11.18,3.106 -38.509,6.212 -54.347,6.212 -83.539,0 -122.048,-39.441 -122.048,-124.533 V 76.396 h -51.552 V 0 h 51.552 v -166.242 c 19.343,-4.798 39.568,-7.362 60.394,-7.362 10.254,0 20.358,0.632 30.288,1.831 L -67.63,0 Z",style:{fill:"#ffffff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path33"})))))),g2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-link-icon lucide-link",...e},v.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),v.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),y2=e=>v.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...e},v.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),v.createElement("path",{d:"M0 183.4C0 84.9 82.4 5 184 5h2122c101.6 0 184 79.9 184 178.4v2133.3c0 98.5-82.4 178.3-184 178.3H184c-101.6 0-184-79.8-184-178.3z",fill:"#0a66c2"}),v.createElement("path",{d:"M756.7 2088.8v-1121H384.1v1121zm-186.2-1274c129.9 0 210.8-86.1 210.8-193.7-2.4-110-80.9-193.7-208.3-193.7-127.5 0-210.8 83.7-210.8 193.7 0 107.6 80.8 193.7 205.9 193.7zm392.4 1274h372.6v-626c0-33.5 2.4-67 12.3-90.9 26.9-67 88.2-136.3 191.2-136.3 134.8 0 188.7 102.8 188.7 253.5v599.6h372.6V1446c0-344.3-183.8-504.5-428.9-504.5-201 0-289.2 112.3-338.3 188.8h2.5V967.8H962.9c4.9 105.2 0 1121 0 1121z",fill:"#fff"})),b2=e=>v.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("g",{clipPath:"url(#clip0_351_18008)"},v.createElement("path",{d:"M13.0332 8.37917C12.96 8.34407 12.8856 8.3103 12.8103 8.27795C12.6791 5.86015 11.3579 4.47596 9.1396 4.4618C9.12955 4.46173 9.11955 4.46173 9.1095 4.46173C7.78265 4.46173 6.67913 5.0281 5.99992 6.05871L7.21993 6.89561C7.72733 6.12579 8.52364 5.96167 9.11008 5.96167C9.11686 5.96167 9.12366 5.96168 9.13036 5.96174C9.86078 5.96639 10.4119 6.17876 10.7687 6.59291C11.0283 6.89442 11.2019 7.31107 11.2879 7.8369C10.6403 7.72683 9.93993 7.69299 9.19122 7.73592C7.08214 7.8574 5.72624 9.08747 5.81731 10.7967C5.86352 11.6637 6.29544 12.4096 7.03346 12.8968C7.65745 13.3087 8.46111 13.5101 9.29635 13.4645C10.3994 13.4041 11.2647 12.9832 11.8684 12.2137C12.3268 11.6293 12.6168 10.872 12.7448 9.91782C13.2705 10.2351 13.6601 10.6525 13.8753 11.1544C14.2411 12.0075 14.2624 13.4094 13.1186 14.5523C12.1164 15.5535 10.9117 15.9866 9.09104 16C7.07147 15.9851 5.54409 15.3374 4.55103 14.0749C3.62111 12.8928 3.14053 11.1854 3.1226 9C3.14053 6.8146 3.62111 5.10714 4.55103 3.92503C5.54409 2.66262 7.07144 2.01495 9.09101 1.99994C11.1252 2.01506 12.6792 2.66585 13.7103 3.93435C14.2159 4.55641 14.597 5.3387 14.8483 6.25081L16.278 5.86936C15.9734 4.74665 15.4942 3.7792 14.842 2.97686C13.5201 1.35059 11.5869 0.517279 9.096 0.5H9.08603C6.60019 0.517219 4.68862 1.3537 3.40443 2.98619C2.26168 4.4389 1.67221 6.46024 1.65241 8.99402L1.65234 9L1.65241 9.00598C1.67221 11.5397 2.26168 13.5611 3.40443 15.0138C4.68862 16.6463 6.60019 17.4828 9.08603 17.5H9.096C11.306 17.4847 12.8638 16.9061 14.1472 15.6239C15.8262 13.9465 15.7756 11.8439 15.2222 10.5531C14.8252 9.62749 14.0683 8.8757 13.0332 8.37917ZM9.21739 11.9668C8.29301 12.0188 7.33268 11.6039 7.28533 10.7152C7.25023 10.0563 7.75426 9.32105 9.27412 9.23347C9.44817 9.22343 9.61897 9.21852 9.78676 9.21852C10.3388 9.21852 10.8553 9.27215 11.3248 9.3748C11.1497 11.562 10.1224 11.9171 9.21739 11.9668Z",fill:"black"})),v.createElement("defs",null,v.createElement("clipPath",{id:"clip0_351_18008"},v.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),k2=e=>v.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...e},v.createElement("path",{d:"M714.163 519.284L1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284zM569.165 687.828l-47.468-67.894-377.686-540.24h162.604l304.797 435.991 47.468 67.894 396.2 566.721H892.476L569.165 687.854z"})),lm={signin:om,signup:Qd,accountHome:rm,accountPlan:Bd,accountProfile:sm,accountEmail:qP,signupNewsletter:Ud,unsubscribe:XP,magiclink:tm,loading:ai,offer:am,feedback:JT,emailSuppressed:QP,emailSuppressionFAQ:e2,emailReceivingFAQ:t2,support:n2,supportSuccess:nP,supportError:im,recommendations:kP,gift:s2,giftRedemption:sP,giftSuccess:dP,share:()=>{const[e,t]=v.useState(!1),[n,a]=v.useState(!1),i=v.useRef(),o=v.useRef(null),{shareUrl:r,shareTitle:s,shareExcerpt:c,shareImage:u,shareFavicon:d,shareSiteName:p,shareAuthor:m,socialLinks:f}=m2();v.useEffect(()=>()=>{clearTimeout(i.current)},[]),v.useEffect(()=>{if(!n)return;const y=C=>{o.current&&!o.current.contains(C.target)&&a(!1)},k=C=>{C.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k)}},[n]);const b=async()=>{await hk(r)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},w=()=>{a(y=>!y)},g=()=>{a(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:h("Share")})}),l.jsxs("div",{className:"gh-portal-share-preview",children:[u&&l.jsx("img",{className:"gh-portal-share-preview-image",src:u,alt:"","data-testid":"share-preview-image"}),l.jsxs("div",{className:"gh-portal-share-preview-content",children:[s&&l.jsx("h2",{className:"gh-portal-share-preview-title",children:s}),c&&l.jsx("p",{className:"gh-portal-share-preview-excerpt",children:c}),(d||p||m)&&l.jsxs("div",{className:"gh-portal-share-preview-footer",children:[d&&l.jsx("img",{className:"gh-portal-share-preview-favicon",src:d,alt:"","data-testid":"share-preview-favicon"}),l.jsxs("div",{className:"gh-portal-share-preview-meta",children:[p&&l.jsx("span",{className:"gh-portal-share-preview-site",children:p}),m&&l.jsx("span",{className:"gh-portal-share-preview-author",children:p?`| ${m}`:m})]})]})]})]}),l.jsxs("div",{className:"gh-portal-share-actions",children:[l.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:b,"aria-label":h(e?"Copied":"Copy link"),title:h(e?"Copied":"Copy link"),children:[e?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Do,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(g2,{})}),l.jsx("span",{className:"gh-portal-share-label",children:h(e?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:f.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":h("X (Twitter)"),title:h("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(k2,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:f.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":h("LinkedIn"),title:h("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(y2,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:f.email,target:"_blank",rel:"noopener noreferrer","aria-label":h("Email"),title:h("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(em,{})})}),l.jsxs("div",{className:"gh-portal-share-more",ref:o,children:[l.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:w,"aria-label":h("More options"),title:h("More options"),"aria-haspopup":"menu","aria-expanded":n,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(h2,{})})}),n&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":h("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:f.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(f2,{})}),l.jsx("span",{children:h("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:f.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(b2,{})}),l.jsx("span",{children:h("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:f.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(p2,{})}),l.jsx("span",{children:h("Bluesky")})]})]})]})]})]})}},cm=function({page:e}){return Object.keys(lm).includes(e)?e:"signup"},wk=function({page:e}){return e.includes("account")},v2=function({page:e}){return e.includes("offer")},w2=e=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.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"})),$m=class $m extends Z.Component{render(){return l.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[l.jsx(w2,{}),"Powered by Ghost"]})}};$m.contextType=_;let sl=$m;const Sk=()=>({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 S2({message:e}){return Zn()?l.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const jm=class jm extends Z.Component{componentDidMount(){this.node&&!de(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&de(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;de(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;cm({page:t});const n=lm[t];return l.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:l.jsx(nm,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,r=Vs({site:a,pageQuery:n}).length;cm({page:t});const c={...Sk().page[t]};let u="",d="regular",p="",m=t;switch(t){case"signup":p="Cookies must be enabled in your browser to sign up.";break;case"signin":p="Cookies must be enabled in your browser to sign in.";break;case"accountHome":m="account-home";break;case"accountProfile":m="account-profile";break;case"accountPlan":m="account-plan";break;default:p="Cookies must be enabled in your browser.",m=t;break}r>1&&!Ft({site:a})&&Qt({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",d="full"),t==="gift"&&(m+=" full-size",d="full");const f=Po({site:a});(f&&r>2||!f&&r>1)&&t==="accountPlan"&&(m+=" full-size",d="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let b="gh-portal-popup-container";de(["preview"])&&(m+=" preview"),de(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),de(["dev"])&&(b+=" dev");const w=`${b} ${u} ${m}`;return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:g=>this.handlePopupClose(g),children:[this.renderPopupNotification(),l.jsxs("div",{className:w,style:c,ref:g=>this.node=g,tabIndex:-1,children:[l.jsx(S2,{message:p}),this.renderActivePage(),d==="full"?l.jsx("div",{className:"gh-portal-powered inside "+(de(["preview"])?"hidden ":"")+m,children:l.jsx(sl,{})}):""]})]}),t!=="share"&&l.jsx("div",{className:"gh-portal-powered outside "+(de(["preview"])?"hidden ":"")+m,children:l.jsx(sl,{})})]})}};jm.contextType=_;let um=jm;const Tm=class Tm extends Z.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=lm[t];return l.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=$P({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),l.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=Sk(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return de(["preview"])&&(i.modalContainer.zIndex="3999997"),de(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),de(["dev"])&&(s+=" dev"),l.jsx("div",{style:i.modalContainer,children:l.jsxs(yd,{style:r,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[l.jsx("div",{className:s,onClick:c=>this.handlePopupClose(c)}),l.jsx(um,{isMobile:o})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};Tm.contextType=_;let dm=Tm;ll({products:mm({numOfProducts:1})});function Oe(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function x2(){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 ll({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:o={monthly:5e3,yearly:15e4,currency:"USD"},products:r=mm({numOfProducts:1}),portalProducts:s=r.map(V=>V.id),accentColor:c="#45C32E",portalPlans:u=["free","monthly","yearly"],membersSignupAccess:d="all",freePriceName:p="Free",freePriceDescription:m="Free preview",isStripeConfigured:f=!0,portalButton:b=!0,portalName:w=!0,portalButtonIcon:g="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:C="support@example.com",editorDefaultEmailRecipients:x="visibility",newsletters:T=[],posts:E=C2(),commentsEnabled:N,recommendations:z=[],recommendationsEnabled:j}={}){return{title:e,description:t,logo:n,icon:a,accent_color:c,url:i,plans:o,products:r,portal_products:s,members_signup_access:d,free_price_name:p,free_price_description:m,is_stripe_configured:f,portal_button:b,portal_name:w,portal_plans:u,portal_button_icon:g,portal_button_signup_text:y,portal_button_style:k,members_support_address:C,comments_enabled:N!=="off",newsletters:T,recommendations:z,recommendations_enabled:!!j,editor_default_email_recipients:x,posts:E}}function xk({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:o="month",amount:r=50,duration:s="repeating",durationInMonths:c=null,currencyRestriction:u=!1,currency:d=null,status:p="active",tierId:m="",tierName:f="Basic",redemptionType:b="signup"}={}){return{id:`offer_${Oe()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:o,amount:r,duration:s,duration_in_months:c,currency_restriction:u,currency:d,status:p,tier:{id:`${m}`,name:f},redemption_type:b}}function Et({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:o="",subscribed:r=!0,email_suppression:s={suppressed:!1,info:null},newsletters:c=[]}={}){return{uuid:x2(),email:t,name:e,firstname:n,paid:i,subscribed:r,avatar_image:o,subscriptions:a,email_suppression:s,newsletters:c}}function C2({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(E2({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function E2({id:e=`post_${Oe()}`,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 mm({numOfProducts:e=3}={}){const n=[ii({name:"Bronze",description:"Access to all members articles",monthlyPrice:yt({interval:"month",amount:700}),yearlyPrice:yt({interval:"year",amount:7e3}),numOfBenefits:2}),ii({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:12e3}),numOfBenefits:3}),ii({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:yt({interval:"month",amount:18e3}),yearlyPrice:yt({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Ck({});return[...n,a]}function ii({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Oe()}`,monthlyPrice:i=yt(),yearlyPrice:o=yt({interval:"year"}),numOfBenefits:r=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:o,type:e,benefits:Ek({numOfBenefits:r}),trial_days:s}}function Ck({name:e="Free tier",description:t="Free tier description",id:n=`product_${Oe()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Ek({numOfBenefits:a})}}function Ek({numOfBenefits:e}){const t=Oe();return[cl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),cl({name:`Latest gear reviews #${t.substring(6,12)}`}),cl({name:`Weekly email newsletter #${t.substring(12,18)}`}),cl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function cl({id:e=`benefit_${Oe()}`,name:t="Benefit"}){return{id:e,name:t}}function yt({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:o=!0,id:r=`price_${Oe()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Oe()}`,stripe_product_id:`prod_${Oe()}`,type:"recurring"}}function ia({id:e=`sub_${Oe()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:o=a==="month"?"Monthly":"Yearly",cardLast4:r="4242",offer:s=j2,priceId:c=`price_${Oe()}`,startDate:u="2021-10-05T03:18:30.000Z",currentPeriodEnd:d="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:m=null,nextPayment:f=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${Oe()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Oe()}`,nickname:o,amount:i,interval:a,currency:n},offer:s,status:t,start_date:u,default_payment_card_last4:r,cancel_at_period_end:p,cancellation_reason:null,current_period_end:d,trial_end_at:m,next_payment:f,tier:b,price:{id:`stripe_price_${Oe()}`,price_id:c,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Oe()}`,product_id:`prod_${Oe()}`}}}}function $k(){const e=mm({numOfProducts:1}),t=e.map(a=>a.id);return ll({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}$k();const $2=ll({products:[ii({numOfBenefits:2,type:"free"})]}),j2=xk({tierId:(Nk=$2.products[0])==null?void 0:Nk.id});Et(),Et({paid:!0,subscriptions:[ia()]}),Et({paid:!0,subscriptions:[]}),Et({paid:!0,subscriptions:[ia({amount:0})]}),Et({paid:!0,subscriptions:[ia({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),$k();const ul=[Ck({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),ii({name:"The Blueprint",description:"",monthlyPrice:yt({interval:"month",amount:500}),yearlyPrice:yt({interval:"year",amount:5e3}),numOfBenefits:3}),ii({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:11e3}),numOfBenefits:4})],oi=ll({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:ul,portalProducts:ul.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}]}),jk=xk({tierId:(Ak=oi.products[1])==null?void 0:Ak.id}),ri={free:Et({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Et({paid:!0,subscriptions:[ia({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:Et({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Et({paid:!0,subscriptions:[ia({amount:0})]}),preview:Et({paid:!0,subscriptions:[ia({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function T2(){var n;if(!ul||!ul[1])return null;let e=(n=oi==null?void 0:oi.products)==null?void 0:n[1].monthlyPrice,t=Et({paid:!0,subscriptions:[ia({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:oi,member:t}}function P2(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin),a=["#/portal","#/share"],i=a.some(r=>n.hash.startsWith(r)),o=a.some(r=>t.startsWith(r));!n.hash||!i||o||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function z2({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function I2({state:e}){return{showPopup:!e.showPopup}}function N2({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function A2({state:e}){return e.lastPage?{page:e.lastPage}:Tk({state:e})}function Tk({state:e}){return Tn(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function M2({data:e,state:t}){const{action:n="openNotification",status:a="success",autoHide:i=!0,closeable:o=!0,duration:r=2600,message:s=""}=e||{},c=vb({type:n,status:a,autoHide:i,closeable:o,duration:r,state:t,message:s});return{notification:c,notificationSequence:c.count}}function D2(){return{notification:null}}async function F2({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:re({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to log out, please try again")})}}}async function O2({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:o,inboxLinks:r}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...o?{otcRef:o}:{},inboxLinks:r,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:re({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Zt(a,h("Failed to log in, please try again"))})}}}function _2({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 R2({data:e,api:t}){var a;const n=h("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),o=await t.member.verifyOTC({...e,integrityToken:i});return o.redirectUrl?window.location.assign(o.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Zt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Zt(i,n)}}}async function Y2({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u}=e;s=s==null?void 0:s.trim();let d;if(a.toLowerCase()==="free"){const p=await n.member.getIntegrityToken();({inboxLinks:d}=await n.member.sendMagicLink({emailType:"signup",integrityToken:p,...e,name:s}))}else return i&&o?await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u}):({tierId:i,cadence:o}=na({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:d,pageData:{...t.pageData||{},email:(r||"").trim()}}}catch(a){const i=Zt(a,h("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:re({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function L2({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=na({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:o,cadence:r,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:re({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to process checkout, please try again")})}}}async function B2({data:e,state:t,api:n}){try{const{tierId:a,cadence:i,email:o}=e;return await n.member.checkoutGift({tierId:a,cadence:i,email:o}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:re({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to process checkout, please try again")})}}}async function U2({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:c}=na({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:c,subscriptionId:o,cancelAtPeriodEnd:r,planId:i});const u=await n.member.sessionData(),d="updateSubscription:success";return{action:d,popupNotification:re({type:d,autoHide:!0,closeable:!0,state:t,status:"success",message:h("Subscription plan updated successfully")}),page:"accountHome",member:u}}catch{return{action:"updateSubscription:failed",popupNotification:re({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to update subscription, please try again")})}}}async function H2({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:re({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to cancel subscription, please try again")})}}}async function V2({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:re({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to cancel subscription, please try again")})}}}async function W2({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:re({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:re({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function G2({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:re({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to update billing information, please try again")})}}}async function K2({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:re({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to open billing portal, please try again")})}}}async function q2(){return{popupNotification:null}}async function J2({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:re({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function Z2({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const o={};return a&&(o.newsletters=a),i!==void 0&&(o.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(o)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:h("Failed to update newsletter settings")})}}}async function X2({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:re({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:h("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:re({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:h("Your email has failed to resubscribe, please try again")})}}}async function Q2({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const o="updateNewsletter:success";return{action:o,member:i,popupNotification:re({type:o,autoHide:!0,closeable:!0,state:t,status:"success",message:h("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:h("Failed to update newsletter settings")})}}}async function ez({data:e,state:t,api:n}){const{email:a}=e,i=D0({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(o){return{success:!1,error:o}}return null}async function tz({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if(O0({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function nz({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 az({data:e,state:t,api:n}){const[a,i]=await Promise.all([tz({data:e,state:t,api:n}),ez({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:re({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:h("Check your inbox to verify email update")})};const o=a.success?h("Failed to send verification email"):h("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:re({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:o,state:t})}}else if(a){const o=a.success?"updateProfile:success":"updateProfile:failed",r=a.success?"success":"error",s=a.success?h("Account details updated successfully"):h("Failed to update account details");return{action:o,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:re({type:o,autoHide:a.success,closeable:!0,status:r,state:t,message:s})}}else if(i){const o=i.success?"updateProfile:success":"updateProfile:failed",r=i.success?"success":"error";let s="";return i.error?s=Zt(i.error,h("Failed to send verification email")):s=h("Check your inbox to verify email update"),{action:o,...i.success?{page:"accountHome"}:{},popupNotification:re({type:o,autoHide:i.success,closeable:!0,status:r,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:re({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:h("Account details updated successfully")})}}async function iz({data:{siteUrl:e},state:t}){const n=rl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=fb(),r=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:r,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:o,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function oz({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 rz({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const sz={togglePopup:I2,openPopup:N2,closePopup:Tk,switchPage:z2,openNotification:M2,closeNotification:D2,back:A2,signout:F2,signin:O2,startSigninOTCFromCustomForm:_2,verifyOTC:R2,signup:Y2,updateSubscription:U2,cancelSubscription:H2,continueSubscription:V2,applyOffer:W2,updateNewsletter:Q2,updateProfile:az,refreshMemberData:nz,clearPopupNotification:q2,editBilling:G2,manageBilling:K2,checkoutPlan:L2,checkoutGift:B2,updateNewsletterPreference:Z2,showPopupNotification:J2,removeEmailFromSuppressionList:X2,oneClickSubscribe:iz,trackRecommendationClicked:oz,trackRecommendationSubscribed:rz};async function lz({action:e,data:t,state:n,api:a}){const i=sz[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Pk(e,t){e&&(e.innerText=t)}function cz(e,t,n){t.classList.add("error");const a=h("There was an error sending the email, please try again");Pk(n,Zt(e,a))}async function uz({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var x,T;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),c=e.target.querySelector("input[data-members-name]"),u=((x=t==null?void 0:t.dataset)==null?void 0:x.membersAutoredirect)||"true",d=s==null?void 0:s.value,p=((c==null?void 0:c.value)||"").trim()||void 0,m,f=[],b=[],w=e.target.querySelectorAll("input[data-members-label]")||[];for(let E=0;E<w.length;++E)f.push(w[E].value);let g=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let E=0;E<g.length;++E)b.push({name:g[E].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const y=m==="signin"&&((T=t==null?void 0:t.dataset)==null?void 0:T.membersOtc)==="true";t.classList.add("loading");const k=No(),C={email:d,emailType:m,labels:f,name:p,autoRedirect:u==="true"};y&&(C.includeOTC=!0),k&&(C.urlHistory=k),g.length>0?C.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(C.newsletters=[]);try{const N=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),z=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...C,integrityToken:N})});if(t.addEventListener("submit",i),t.classList.remove("loading"),z.ok){t.classList.add("success");let j;if(y)try{j=await z.clone().json()}catch{j=void 0}const V=j==null?void 0:j.otc_ref;if(V&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(d||"").trim(),otcRef:V,inboxLinks:j==null?void 0:j.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const j=await xt.fromApiResponse(z),V=Zt(j,h("Failed to send magic link email"));Pk(n,V),t.classList.add("error")}}catch(E){cz(E,t,n)}}function dz({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:o,clickHandler:r}){t.removeEventListener("click",r),e.preventDefault();let s=t.dataset.membersPlan,c=C0(i,s.toLowerCase()),u=t.dataset.membersSuccess,d=t.dataset.membersCancel,p,m;u&&(p=new URL(u,window.location.href).href),d&&(m=new URL(d,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const f=o?{checkoutType:"upgrade"}:{},b=No();return b&&(f.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(w){return w.ok?w.text():null}).then(function(w){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,identity:w,successUrl:p,cancelUrl:m,metadata:f})}).then(function(g){if(!g.ok)throw new Error(h("Could not create Stripe checkout session"));return g.json()})}).then(function(w){return w.url?window.location.assign(w.url):window.Stripe(w.publicKey).redirectToCheckout({sessionId:w.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(w){console.error(w),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=w.message),t.classList.add("error")})}function mz({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:o}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let c=s.querySelector("[data-members-error]");function u(d){uz({event:d,errorEl:c,form:s,siteUrl:e,submitHandler:u,doAction:i,captureException:o})}s.addEventListener("submit",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let c=s.querySelector("[data-members-error]");function u(d){dz({el:s,event:d,errorEl:c,member:n,site:t,siteUrl:e,clickHandler:u})}s.addEventListener("click",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let c=s.querySelector("[data-members-error]"),u=s.dataset.membersSuccess,d=s.dataset.membersCancel,p,m;u&&(p=new URL(u,window.location.href).href),d&&(m=new URL(d,window.location.href).href);function f(b){s.removeEventListener("click",f),b.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(w){return w.ok?w.text():null}).then(function(w){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:w,successUrl:p,cancelUrl:m})}).then(function(g){if(!g.ok)throw new Error(h("Could not create Stripe checkout session"));return g.json()})}).then(function(w){return window.Stripe(w.publicKey).redirectToCheckout({sessionId:w.sessionId})}).then(function(w){if(w.error)throw new Error(h(w.error.message))}).catch(function(w){console.error(w),s.addEventListener("click",f),s.classList.remove("loading"),c&&(c.innerText=w.message),s.classList.add("error")})}s.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let c=s.querySelector("[data-members-error]"),u=s.dataset.membersReturn,d;u&&(d=new URL(u,window.location.href).href);function p(m){s.removeEventListener("click",p),m.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:d})}).then(function(b){if(!b.ok)throw new Error(h("Could not create Stripe billing portal session"));return b.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),s.addEventListener("click",p),s.classList.remove("loading"),c&&(c.innerText=f.message),s.classList.add("error")})}s.addEventListener("click",p)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function c(u){s.removeEventListener("click",c),u.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(d){d.ok?window.location.replace(e):(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",c)});const r=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let c=s.parentElement.querySelector("[data-members-error]");function u(d){d.preventDefault();let p=s.dataset.membersCancelSubscription;if(r){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:p,action:"cancel"}});return}return s.removeEventListener("click",u),s.classList.remove("error"),s.classList.add("loading"),c&&(c.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",u),s.classList.remove("loading"),s.classList.add("error"),c&&(c.innerText=h("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let c=s.parentElement.querySelector("[data-members-error]");function u(d){s.removeEventListener("click",u),d.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let p=s.dataset.membersContinueSubscription;return c&&(c.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",u),s.classList.remove("loading"),s.classList.add("error"),c&&(c.innerText=h("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",u)})}const zk=e=>{try{return decodeURIComponent(e)}catch{return null}},pz={staleGiftRedemptionRequest:!0},hz={showPopup:!0,site:oi,member:ri.free,page:"accountEmail",...T2(),pageData:jk};function fz({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?l.jsx(rd,{children:t}):l.jsx(l.Fragment,{children:t})}class gz extends Z.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,o;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(o=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:o.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin,this.state.reloadOnPopupClose&&window.location.reload())}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:r}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),mz({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:hs})}}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=async a=>{a.preventDefault();const i=a.currentTarget,o=i&&i.dataset.portal,r=this.getPageFromLinkPath(o);if(!r)return;const{page:s,pageQuery:c,pageData:u}=r;if(this.state.initStatus==="success"){if(s==="gift"&&!Ys({site:this.state.site})){this.invalidateGiftRedemptionRequest(),Tn();return}if(s==="giftRedemption"&&(u!=null&&u.token)){const d=this.startGiftRedemptionRequest(u.token),p=await this.fetchGiftRedemptionData({site:this.state.site,token:u.token});if(!this.isCurrentGiftRedemptionRequest(d))return;this.setState(p);return}this.invalidateGiftRedemptionRequest(),c&&c!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:c}):this.dispatchAction("openPopup",{page:s,pageQuery:c,pageData:u})}};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const o=this.state.showPopup?t:n,r=this.state.showPopup?n:t;i.classList.add(o),i.classList.remove(r)})}startGiftRedemptionRequest(t){return this._redemptionRequestId+=1,this.currentRedemptionToken=t,{requestId:this._redemptionRequestId,token:t}}invalidateGiftRedemptionRequest(){this._redemptionRequestId+=1,this.currentRedemptionToken=null}isCurrentGiftRedemptionRequest({requestId:t,token:n}){return this._redemptionRequestId===t&&this.currentRedemptionToken===n}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:o,popupNotification:r,notification:s,notificationSequence:c,lastPage:u,pageQuery:d,pageData:p}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Os.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:u,pageQuery:d,showPopup:o,pageData:p,popupNotification:r,notification:s,notificationSequence:c,dir:Os.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:d,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const b=document.querySelectorAll("[data-lexical-signup-form]");b.length>0&&b.forEach(w=>{w.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...o}=this.fetchDevData(),r=await this.fetchLinkData(t,n),{site:s,...c}=r!=null&&r.staleGiftRedemptionRequest?{}:r,{site:u,...d}=this.fetchPreviewData(),{site:p,...m}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...s,...u,...p,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(u||{}).plans}},...o,...c,...m,...d}}fetchDevData(){return de(["dev"])&&!this.state.customSiteUrl?hz:de(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,o,r;const n=new URLSearchParams(t),a={};for(let s of n.entries()){const c=s[0],u=decodeURIComponent(s[1]);c==="name"?a.name=u||"":c==="code"?a.code=u||"":c==="display_title"?a.display_title=u||"":c==="display_description"?a.display_description=u||"":c==="type"?a.type=u||"":c==="cadence"?a.cadence=u||"":c==="duration"?a.duration=u||"":c==="duration_in_months"&&!isNaN(Number(u))?a.duration_in_months=Number(u):c==="amount"&&!isNaN(Number(u))?a.amount=Number(u):c==="currency"?a.currency=u||"":c==="status"?a.status=u||"":c==="tier_id"?a.tier={id:u||jk.tier.id}:c==="redemption_type"&&(a.redemption_type=u||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=ri.preview)==null?void 0:i.subscriptions)==null?void 0:o[0])==null?void 0:r.id;return{page:"accountPlan",offers:[a],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let o,r=null,s,c,u;for(let d of n.entries()){const p=d[0],m=decodeURIComponent(d[1]);if(p==="button")a.site.portal_button=JSON.parse(m);else if(p==="name")a.site.portal_name=JSON.parse(m);else if(p==="isFree"&&JSON.parse(m))i.push("free");else if(p==="isMonthly"&&JSON.parse(m))i.push("monthly");else if(p==="isYearly"&&JSON.parse(m))i.push("yearly");else if(p==="portalPrices")o=m?m.split(","):[];else if(p==="portalProducts")r=m?m.split(","):[];else if(p==="page"&&m)a.page=m;else if(p==="accentColor"&&(m===""||m))a.site.accent_color=m;else if(p==="buttonIcon"&&m)a.site.portal_button_icon=m;else if(p==="signupButtonText")a.site.portal_button_signup_text=m||"";else if(p==="signupTermsHtml")a.site.portal_signup_terms_html=m||"";else if(p==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(m);else if(p==="buttonStyle"&&m)a.site.portal_button_style=m;else if(p==="monthlyPrice"&&!isNaN(Number(m)))a.site.plans.monthly=Number(m),s=Number(m);else if(p==="yearlyPrice"&&!isNaN(Number(m)))a.site.plans.yearly=Number(m),c=Number(m);else if(p==="currency"&&m){const f=m.toUpperCase();a.site.plans.currency=f,a.site.plans.currency_symbol=ke(f),u=f}else p==="disableBackground"?a.site.disableBackground=JSON.parse(m):p==="membersSignupAccess"&&m?a.site.members_signup_access=m:p==="portalDefaultPlan"&&m?a.site.portal_default_plan=m:p==="transistorPortalSettings"&&m&&(a.site.transistor_portal_settings=JSON.parse(m))}return a.site.portal_plans=i,a.site.portal_products=r,o?a.site.portal_plans=o:s&&c&&u&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:u,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:u,amount:c,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:o}=Yb({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:re({type:t,status:n,duration:a,closeable:o,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({site:t,token:n}){var a;if(!Ys({site:t}))return Tn(),{};try{const i=await this.GhostApi.gift.fetchRedemptionData({token:n});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:n,gift:((a=i==null?void 0:i.gifts)==null?void 0:a[0])||null}}}catch(i){Tn();const o=vb({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:pk(i)});return{showPopup:!1,pageData:null,notification:o,notificationSequence:o.count}}}async fetchLinkData(t,n){this.invalidateGiftRedemptionRequest();const a=new URLSearchParams(window.location.search);if(a.get("stripe")==="gift-purchase-success"){const b=a.get("gift_token");if(el(["stripe","gift_token"]),b)return{showPopup:!0,page:"giftSuccess",pageData:{token:b}}}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(j0({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,o]=window.location.hash.substr(1).split("?"),r=new URLSearchParams(o??""),s=/^(?:(\w+?))?\/monthly$/,c=/^(?:(\w+?))?\/yearly$/,u=/^offers\/(\w+?)\/?$/,d=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,p=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,m=/^\/share\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,b,w]=i.match(f),g=parseInt(w);if(g===1||g===0)return n||r.get("uuid")&&r.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:r.get("uuid"),key:n?null:r.get("key"),postId:b,score:g}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${b}/${g}/`}}}if(i&&d.test(i)){const[,b]=i.match(d),w=zk(b);if(!w)return{};const g=this.startGiftRedemptionRequest(w),y=await this.fetchGiftRedemptionData({site:t,token:w});return this.isCurrentGiftRedemptionRequest(g)?y:pz}if(i&&m.test(i))return{showPopup:!0,page:"share"};if(i&&p.test(i)){const[,b]=i.match(p),{page:w,pageQuery:g,pageData:y}=this.getPageFromLinkPath(b,t)||{};if(!n&&w&&wk({page:w}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${b}/`}};if(w==="gift"&&!Ys({site:t}))return Tn(),{};const k=["accountPlan","accountProfile"].includes(w)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(g)||s.test(g)||c.test(g)||u.test(g)),...w?{page:w}:{},...g?{pageQuery:g}:{},...y?{pageData:y}:{},...k?{lastPage:k}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(de(["preview"])){let n={};return de(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||rl({siteUrl:t,apiUrl:a,apiKey:i});const{site:o,member:r,offers:s}=await this.GhostApi.init(),c=this.getColorOverride();return c&&(o.accent_color=c),this.setupFirstPromoter({site:o,member:r}),this.setupSentry({site:o}),{site:o,member:r,offers:s}}catch(o){if(de(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(de(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.68.1|ghost@${i}`;n&&n.dsn&&ej({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>y0({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(de(["test"]))return null;const a=F0({site:t});let i=Ed({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://cdn.firstpromoter.com/fprom.js",o.onload=o.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),G0({member:n})){const c=n.email,u=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:c,uid:u});else{const d=window._fprom||[];window._fprom=d,d.push(["event","signup"]),d.push(["email",c]),d.push(["uid",u])}}}catch{}};const r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(o,r)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await lz({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=re({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:Zt(a,h("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}async updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),a=await this.fetchLinkData(this.state.site,this.state.member);if(a!=null&&a.staleGiftRedemptionRequest)return;const{site:i,...o}=a,r={site:{...this.state.site,...i||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(i||{}).plans,...(t||{}).plans}},...o,...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(Tn(),!Dt({member:a})||Pn({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||Td({offer:r})||!L0({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=ea({site:t,productId:r.tier.id}),c=r.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:u,cadence:d}=na({site:t,priceId:c.id});this.dispatchAction("checkoutPlan",{plan:c.id,offerId:n,tierId:u,cadence:d})}else{const{tierId:u,cadence:d}=na({site:t,priceId:c.id});this.dispatchAction("signup",{plan:c.id,offerId:n,tierId:u,cadence:d})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let o=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}wb({site:t,pageQuery:n})&&(o=wb({site:t,pageQuery:n}));const r=E0({site:t,priceId:o});if(n&&n!=="free"){Tn();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:c,cadence:u}=na({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:c,cadence:u})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,o=/^offers\/(\w+?)\/?$/,r=/^gift\/redeem\/([^/?#]+)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t)){const[,s]=t.match(r),c=zk(s);return c?{page:"giftRedemption",pageData:{token:c}}:null}else{if(o.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,s]=t.match(a);return{page:"signup",pageQuery:`${s}/monthly`}}else if(i.test(t)){const[,s]=t.match(i);return{page:"signup",pageQuery:`${s}/yearly`}}else if(n.test(t)){const[,s]=t.match(n);return{page:"signup",pageQuery:s}}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==="gift")return{page:"gift"};if(t==="share")return{page:"share"};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 ET(t)}getRetentionPreviewMember({site:t,offers:n}){var u,d,p;const a=(n||[]).find(m=>Td({offer:m})),i=(u=a==null?void 0:a.tier)==null?void 0:u.id,o=i?ea({site:t,productId:i}):null,r=o?a.cadence==="year"?o.yearlyPrice:o.monthlyPrice:null,s=ri.preview,c=(d=s==null?void 0:s.subscriptions)==null?void 0:d[0];return!c||!o||!r?s:{...s,subscriptions:[{...c,plan:{...c.plan,amount:r.amount,interval:r.interval,currency:r.currency.toUpperCase()},price:{...c.price,price_id:r.id,amount:r.amount,interval:r.interval,currency:r.currency,product:{...(p=c.price)==null?void 0:p.product,product_id:o.id}},tier:{id:o.id,name:o.name}}]}}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ft({site:t})||!Qt({site:t})?"signin":"signup";n=a?"accountHome":i}return cm({page:n})}getContextMember({site:t,page:n,member:a,offers:i,pageData:o,customSiteUrl:r}){return de(["dev","preview"],{customSiteUrl:r})?wk({page:n})||v2({page:n})?de(["dev"],{customSiteUrl:r})?a||ri.free:de(["preview"])?n==="accountPlan"&&(o==null?void 0:o.action)==="cancel"?this.getRetentionPreviewMember({site:t,offers:i}):ri.preview:ri.paid:null:a}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:o,page:r,lastPage:s,showPopup:c,pageQuery:u,pageData:d,popupNotification:p,notification:m,customSiteUrl:f,dir:b,scrollbarWidth:w,otcRef:g,inboxLinks:y}=this.state,k=this.getContextPage({site:t,page:r,member:n}),C=this.getContextMember({site:t,page:k,member:n,offers:a,pageData:d,customSiteUrl:f});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:k,pageQuery:u,pageData:d,member:C,lastPage:s,showPopup:c,popupNotification:p,notification:m,customSiteUrl:f,dir:b,scrollbarWidth:w,otcRef:g,inboxLinks:y,doAction:(x,T)=>this.dispatchAction(x,T)}}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"], a[href*="#/share"]').forEach(P2)}render(){return this.state.initStatus==="success"?l.jsx(fz,{site:this.state.site,children:l.jsxs(_.Provider,{value:this.getContextFromState(),children:[l.jsx(dm,{}),l.jsx(zd,{}),l.jsx(Rd,{})]})}):null}}const Ik="ghost-portal-root";function yz(){const e=document.createElement("div");e.id=Ik,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function bz(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,o=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:o}}return{}}function kz(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function vz(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=bz(),o=e||window.location.origin;yz(),kz(),cS.render(l.jsx(Z.StrictMode,{children:l.jsx(gz,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Ik))}vz()});
4120
+ `),a=[];return e&&a.push(`subject=${encodeURIComponent(e)}`),n&&a.push(`body=${encodeURIComponent(n)}`),`mailto:${a.length?`?${a.join("&")}`:""}`},u2=({shareTitle:e,shareUrl:t})=>Ho("https://www.linkedin.com/shareArticle",{mini:"true",url:t,title:e}),d2=()=>{const e=l2(),t=e.document,n=e.location,a=(b,w="content")=>{var g;return((g=t.querySelector(b))==null?void 0:g[w])||""},i=a('link[rel="canonical"]',"href")||n.origin+n.pathname+n.search,o=a('meta[property="og:title"]')||t.title||"",r=a('meta[property="og:description"]')||a('meta[name="description"]')||"",s=a('meta[property="og:image"]')||a('meta[name="twitter:image"]')||"",c=a('link[rel="icon"]',"href")||a('link[rel="shortcut icon"]',"href")||a('link[rel="apple-touch-icon"]',"href"),u=a('meta[name="author"]'),d=(u&&!/^https?:\/\//i.test(u)?u:"")||a('meta[name="twitter:creator"]')||"";let p=a('meta[property="og:site_name"]')||a('meta[name="application-name"]')||"";if(!p)try{p=new URL(i).hostname.replace(/^www\./,"")}catch{p=""}const m=[o,i].filter(Boolean).join(" ").trim(),f={twitter:Ho("https://twitter.com/intent/tweet",{url:i,text:o}),facebook:Ho("https://www.facebook.com/sharer/sharer.php",{u:i}),email:c2({shareTitle:o,shareUrl:i}),threads:Ho("https://www.threads.net/intent/post",{text:m}),linkedin:u2({shareTitle:o,shareUrl:i}),bluesky:Ho("https://bsky.app/intent/compose",{text:m})};return{shareUrl:i,shareTitle:o,shareExcerpt:r,shareImage:s,shareFavicon:c,shareSiteName:p,shareAuthor:d,socialLinks:f}},m2=()=>{const[e]=v.useState(d2);return e},p2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...e},v.createElement("path",{fill:"#0085ff",d:"M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805zm36.254 0C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745z"})),h2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-ellipsis-icon lucide-ellipsis",...e},v.createElement("circle",{cx:12,cy:12,r:1}),v.createElement("circle",{cx:19,cy:12,r:1}),v.createElement("circle",{cx:5,cy:12,r:1})),f2=e=>v.createElement("svg",{id:"svg9",width:666.66669,height:666.66718,viewBox:"0 0 666.66668 666.66717",xmlns:"http://www.w3.org/2000/svg","xmlns:svg":"http://www.w3.org/2000/svg",...e},v.createElement("defs",{id:"defs13"},v.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},v.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),v.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},v.createElement("g",{id:"g19"},v.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},v.createElement("g",{id:"g27",transform:"translate(600,350)"},v.createElement("path",{d:"m 0,0 c 0,138.071 -111.929,250 -250,250 -138.071,0 -250,-111.929 -250,-250 0,-117.245 80.715,-215.622 189.606,-242.638 v 166.242 h -51.552 V 0 h 51.552 v 32.919 c 0,85.092 38.508,124.532 122.048,124.532 15.838,0 43.167,-3.105 54.347,-6.211 V 81.986 c -5.901,0.621 -16.149,0.932 -28.882,0.932 -40.993,0 -56.832,-15.528 -56.832,-55.9 V 0 h 81.659 l -14.028,-76.396 h -67.631 V -248.169 C -95.927,-233.218 0,-127.818 0,0",style:{fill:"#0866ff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path29"})),v.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},v.createElement("path",{d:"M 0,0 14.029,76.396 H -67.63 v 27.019 c 0,40.372 15.838,55.899 56.831,55.899 12.733,0 22.981,-0.31 28.882,-0.931 v 69.253 c -11.18,3.106 -38.509,6.212 -54.347,6.212 -83.539,0 -122.048,-39.441 -122.048,-124.533 V 76.396 h -51.552 V 0 h 51.552 v -166.242 c 19.343,-4.798 39.568,-7.362 60.394,-7.362 10.254,0 20.358,0.632 30.288,1.831 L -67.63,0 Z",style:{fill:"#ffffff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path33"})))))),g2=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-link-icon lucide-link",...e},v.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),v.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),y2=e=>v.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...e},v.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),v.createElement("path",{d:"M0 183.4C0 84.9 82.4 5 184 5h2122c101.6 0 184 79.9 184 178.4v2133.3c0 98.5-82.4 178.3-184 178.3H184c-101.6 0-184-79.8-184-178.3z",fill:"#0a66c2"}),v.createElement("path",{d:"M756.7 2088.8v-1121H384.1v1121zm-186.2-1274c129.9 0 210.8-86.1 210.8-193.7-2.4-110-80.9-193.7-208.3-193.7-127.5 0-210.8 83.7-210.8 193.7 0 107.6 80.8 193.7 205.9 193.7zm392.4 1274h372.6v-626c0-33.5 2.4-67 12.3-90.9 26.9-67 88.2-136.3 191.2-136.3 134.8 0 188.7 102.8 188.7 253.5v599.6h372.6V1446c0-344.3-183.8-504.5-428.9-504.5-201 0-289.2 112.3-338.3 188.8h2.5V967.8H962.9c4.9 105.2 0 1121 0 1121z",fill:"#fff"})),b2=e=>v.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("g",{clipPath:"url(#clip0_351_18008)"},v.createElement("path",{d:"M13.0332 8.37917C12.96 8.34407 12.8856 8.3103 12.8103 8.27795C12.6791 5.86015 11.3579 4.47596 9.1396 4.4618C9.12955 4.46173 9.11955 4.46173 9.1095 4.46173C7.78265 4.46173 6.67913 5.0281 5.99992 6.05871L7.21993 6.89561C7.72733 6.12579 8.52364 5.96167 9.11008 5.96167C9.11686 5.96167 9.12366 5.96168 9.13036 5.96174C9.86078 5.96639 10.4119 6.17876 10.7687 6.59291C11.0283 6.89442 11.2019 7.31107 11.2879 7.8369C10.6403 7.72683 9.93993 7.69299 9.19122 7.73592C7.08214 7.8574 5.72624 9.08747 5.81731 10.7967C5.86352 11.6637 6.29544 12.4096 7.03346 12.8968C7.65745 13.3087 8.46111 13.5101 9.29635 13.4645C10.3994 13.4041 11.2647 12.9832 11.8684 12.2137C12.3268 11.6293 12.6168 10.872 12.7448 9.91782C13.2705 10.2351 13.6601 10.6525 13.8753 11.1544C14.2411 12.0075 14.2624 13.4094 13.1186 14.5523C12.1164 15.5535 10.9117 15.9866 9.09104 16C7.07147 15.9851 5.54409 15.3374 4.55103 14.0749C3.62111 12.8928 3.14053 11.1854 3.1226 9C3.14053 6.8146 3.62111 5.10714 4.55103 3.92503C5.54409 2.66262 7.07144 2.01495 9.09101 1.99994C11.1252 2.01506 12.6792 2.66585 13.7103 3.93435C14.2159 4.55641 14.597 5.3387 14.8483 6.25081L16.278 5.86936C15.9734 4.74665 15.4942 3.7792 14.842 2.97686C13.5201 1.35059 11.5869 0.517279 9.096 0.5H9.08603C6.60019 0.517219 4.68862 1.3537 3.40443 2.98619C2.26168 4.4389 1.67221 6.46024 1.65241 8.99402L1.65234 9L1.65241 9.00598C1.67221 11.5397 2.26168 13.5611 3.40443 15.0138C4.68862 16.6463 6.60019 17.4828 9.08603 17.5H9.096C11.306 17.4847 12.8638 16.9061 14.1472 15.6239C15.8262 13.9465 15.7756 11.8439 15.2222 10.5531C14.8252 9.62749 14.0683 8.8757 13.0332 8.37917ZM9.21739 11.9668C8.29301 12.0188 7.33268 11.6039 7.28533 10.7152C7.25023 10.0563 7.75426 9.32105 9.27412 9.23347C9.44817 9.22343 9.61897 9.21852 9.78676 9.21852C10.3388 9.21852 10.8553 9.27215 11.3248 9.3748C11.1497 11.562 10.1224 11.9171 9.21739 11.9668Z",fill:"black"})),v.createElement("defs",null,v.createElement("clipPath",{id:"clip0_351_18008"},v.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),k2=e=>v.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...e},v.createElement("path",{d:"M714.163 519.284L1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284zM569.165 687.828l-47.468-67.894-377.686-540.24h162.604l304.797 435.991 47.468 67.894 396.2 566.721H892.476L569.165 687.854z"})),lm={signin:om,signup:Qd,accountHome:rm,accountPlan:Bd,accountProfile:sm,accountEmail:qP,signupNewsletter:Ud,unsubscribe:XP,magiclink:tm,loading:ai,offer:am,feedback:JT,emailSuppressed:QP,emailSuppressionFAQ:e2,emailReceivingFAQ:t2,support:n2,supportSuccess:nP,supportError:im,recommendations:kP,gift:s2,giftRedemption:sP,giftSuccess:dP,share:()=>{const[e,t]=v.useState(!1),[n,a]=v.useState(!1),i=v.useRef(),o=v.useRef(null),{shareUrl:r,shareTitle:s,shareExcerpt:c,shareImage:u,shareFavicon:d,shareSiteName:p,shareAuthor:m,socialLinks:f}=m2();v.useEffect(()=>()=>{clearTimeout(i.current)},[]),v.useEffect(()=>{if(!n)return;const y=C=>{o.current&&!o.current.contains(C.target)&&a(!1)},k=C=>{C.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k)}},[n]);const b=async()=>{await hk(r)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},w=()=>{a(y=>!y)},g=()=>{a(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(pe,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:h("Share")})}),l.jsxs("div",{className:"gh-portal-share-preview",children:[u&&l.jsx("img",{className:"gh-portal-share-preview-image",src:u,alt:"","data-testid":"share-preview-image"}),l.jsxs("div",{className:"gh-portal-share-preview-content",children:[s&&l.jsx("h2",{className:"gh-portal-share-preview-title",children:s}),c&&l.jsx("p",{className:"gh-portal-share-preview-excerpt",children:c}),(d||p||m)&&l.jsxs("div",{className:"gh-portal-share-preview-footer",children:[d&&l.jsx("img",{className:"gh-portal-share-preview-favicon",src:d,alt:"","data-testid":"share-preview-favicon"}),l.jsxs("div",{className:"gh-portal-share-preview-meta",children:[p&&l.jsx("span",{className:"gh-portal-share-preview-site",children:p}),m&&l.jsx("span",{className:"gh-portal-share-preview-author",children:p?`| ${m}`:m})]})]})]})]}),l.jsxs("div",{className:"gh-portal-share-actions",children:[l.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:b,"aria-label":h(e?"Copied":"Copy link"),title:h(e?"Copied":"Copy link"),children:[e?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Do,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(g2,{})}),l.jsx("span",{className:"gh-portal-share-label",children:h(e?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:f.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":h("X (Twitter)"),title:h("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(k2,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:f.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":h("LinkedIn"),title:h("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(y2,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:f.email,target:"_blank",rel:"noopener noreferrer","aria-label":h("Email"),title:h("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(em,{})})}),l.jsxs("div",{className:"gh-portal-share-more",ref:o,children:[l.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:w,"aria-label":h("More options"),title:h("More options"),"aria-haspopup":"menu","aria-expanded":n,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(h2,{})})}),n&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":h("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:f.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(f2,{})}),l.jsx("span",{children:h("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:f.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(b2,{})}),l.jsx("span",{children:h("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:f.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:g,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(p2,{})}),l.jsx("span",{children:h("Bluesky")})]})]})]})]})]})}},cm=function({page:e}){return Object.keys(lm).includes(e)?e:"signup"},wk=function({page:e}){return e.includes("account")},v2=function({page:e}){return e.includes("offer")},w2=e=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.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"})),$m=class $m extends Z.Component{render(){return l.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[l.jsx(w2,{}),"Powered by Ghost"]})}};$m.contextType=_;let sl=$m;const Sk=()=>({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 S2({message:e}){return Zn()?l.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const jm=class jm extends Z.Component{componentDidMount(){this.node&&!de(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&de(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;de(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;cm({page:t});const n=lm[t];return l.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:l.jsx(nm,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,r=Vs({site:a,pageQuery:n}).length;cm({page:t});const c={...Sk().page[t]};let u="",d="regular",p="",m=t;switch(t){case"signup":p="Cookies must be enabled in your browser to sign up.";break;case"signin":p="Cookies must be enabled in your browser to sign in.";break;case"accountHome":m="account-home";break;case"accountProfile":m="account-profile";break;case"accountPlan":m="account-plan";break;default:p="Cookies must be enabled in your browser.",m=t;break}r>1&&!Ft({site:a})&&Qt({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",d="full"),t==="gift"&&(m+=" full-size",d="full");const f=Po({site:a});(f&&r>2||!f&&r>1)&&t==="accountPlan"&&(m+=" full-size",d="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let b="gh-portal-popup-container";de(["preview"])&&(m+=" preview"),de(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),de(["dev"])&&(b+=" dev");const w=`${b} ${u} ${m}`;return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:g=>this.handlePopupClose(g),children:[this.renderPopupNotification(),l.jsxs("div",{className:w,style:c,ref:g=>this.node=g,tabIndex:-1,children:[l.jsx(S2,{message:p}),this.renderActivePage(),d==="full"?l.jsx("div",{className:"gh-portal-powered inside "+(de(["preview"])?"hidden ":"")+m,children:l.jsx(sl,{})}):""]})]}),t!=="share"&&l.jsx("div",{className:"gh-portal-powered outside "+(de(["preview"])?"hidden ":"")+m,children:l.jsx(sl,{})})]})}};jm.contextType=_;let um=jm;const Tm=class Tm extends Z.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=lm[t];return l.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=$P({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),l.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=Sk(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return de(["preview"])&&(i.modalContainer.zIndex="3999997"),de(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),de(["dev"])&&(s+=" dev"),l.jsx("div",{style:i.modalContainer,children:l.jsxs(yd,{style:r,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[l.jsx("div",{className:s,onClick:c=>this.handlePopupClose(c)}),l.jsx(um,{isMobile:o})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};Tm.contextType=_;let dm=Tm;ll({products:mm({numOfProducts:1})});function Oe(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function x2(){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 ll({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:o={monthly:5e3,yearly:15e4,currency:"USD"},products:r=mm({numOfProducts:1}),portalProducts:s=r.map(V=>V.id),accentColor:c="#45C32E",portalPlans:u=["free","monthly","yearly"],membersSignupAccess:d="all",freePriceName:p="Free",freePriceDescription:m="Free preview",isStripeConfigured:f=!0,portalButton:b=!0,portalName:w=!0,portalButtonIcon:g="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:C="support@example.com",editorDefaultEmailRecipients:x="visibility",newsletters:T=[],posts:E=C2(),commentsEnabled:N,recommendations:z=[],recommendationsEnabled:j}={}){return{title:e,description:t,logo:n,icon:a,accent_color:c,url:i,plans:o,products:r,portal_products:s,members_signup_access:d,free_price_name:p,free_price_description:m,is_stripe_configured:f,portal_button:b,portal_name:w,portal_plans:u,portal_button_icon:g,portal_button_signup_text:y,portal_button_style:k,members_support_address:C,comments_enabled:N!=="off",newsletters:T,recommendations:z,recommendations_enabled:!!j,editor_default_email_recipients:x,posts:E}}function xk({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:o="month",amount:r=50,duration:s="repeating",durationInMonths:c=null,currencyRestriction:u=!1,currency:d=null,status:p="active",tierId:m="",tierName:f="Basic",redemptionType:b="signup"}={}){return{id:`offer_${Oe()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:o,amount:r,duration:s,duration_in_months:c,currency_restriction:u,currency:d,status:p,tier:{id:`${m}`,name:f},redemption_type:b}}function Et({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:o="",subscribed:r=!0,email_suppression:s={suppressed:!1,info:null},newsletters:c=[]}={}){return{uuid:x2(),email:t,name:e,firstname:n,paid:i,subscribed:r,avatar_image:o,subscriptions:a,email_suppression:s,newsletters:c}}function C2({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(E2({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function E2({id:e=`post_${Oe()}`,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 mm({numOfProducts:e=3}={}){const n=[ii({name:"Bronze",description:"Access to all members articles",monthlyPrice:yt({interval:"month",amount:700}),yearlyPrice:yt({interval:"year",amount:7e3}),numOfBenefits:2}),ii({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:12e3}),numOfBenefits:3}),ii({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:yt({interval:"month",amount:18e3}),yearlyPrice:yt({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Ck({});return[...n,a]}function ii({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Oe()}`,monthlyPrice:i=yt(),yearlyPrice:o=yt({interval:"year"}),numOfBenefits:r=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:o,type:e,benefits:Ek({numOfBenefits:r}),trial_days:s}}function Ck({name:e="Free tier",description:t="Free tier description",id:n=`product_${Oe()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Ek({numOfBenefits:a})}}function Ek({numOfBenefits:e}){const t=Oe();return[cl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),cl({name:`Latest gear reviews #${t.substring(6,12)}`}),cl({name:`Weekly email newsletter #${t.substring(12,18)}`}),cl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function cl({id:e=`benefit_${Oe()}`,name:t="Benefit"}){return{id:e,name:t}}function yt({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:o=!0,id:r=`price_${Oe()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Oe()}`,stripe_product_id:`prod_${Oe()}`,type:"recurring"}}function ia({id:e=`sub_${Oe()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:o=a==="month"?"Monthly":"Yearly",cardLast4:r="4242",offer:s=j2,priceId:c=`price_${Oe()}`,startDate:u="2021-10-05T03:18:30.000Z",currentPeriodEnd:d="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:m=null,nextPayment:f=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${Oe()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Oe()}`,nickname:o,amount:i,interval:a,currency:n},offer:s,status:t,start_date:u,default_payment_card_last4:r,cancel_at_period_end:p,cancellation_reason:null,current_period_end:d,trial_end_at:m,next_payment:f,tier:b,price:{id:`stripe_price_${Oe()}`,price_id:c,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Oe()}`,product_id:`prod_${Oe()}`}}}}function $k(){const e=mm({numOfProducts:1}),t=e.map(a=>a.id);return ll({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}$k();const $2=ll({products:[ii({numOfBenefits:2,type:"free"})]}),j2=xk({tierId:(Nk=$2.products[0])==null?void 0:Nk.id});Et(),Et({paid:!0,subscriptions:[ia()]}),Et({paid:!0,subscriptions:[]}),Et({paid:!0,subscriptions:[ia({amount:0})]}),Et({paid:!0,subscriptions:[ia({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),$k();const ul=[Ck({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),ii({name:"The Blueprint",description:"",monthlyPrice:yt({interval:"month",amount:500}),yearlyPrice:yt({interval:"year",amount:5e3}),numOfBenefits:3}),ii({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:yt({interval:"month",amount:1200}),yearlyPrice:yt({interval:"year",amount:11e3}),numOfBenefits:4})],oi=ll({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:ul,portalProducts:ul.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}]}),jk=xk({tierId:(Ak=oi.products[1])==null?void 0:Ak.id}),ri={free:Et({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Et({paid:!0,subscriptions:[ia({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:Et({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Et({paid:!0,subscriptions:[ia({amount:0})]}),preview:Et({paid:!0,subscriptions:[ia({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function T2(){var n;if(!ul||!ul[1])return null;let e=(n=oi==null?void 0:oi.products)==null?void 0:n[1].monthlyPrice,t=Et({paid:!0,subscriptions:[ia({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:oi,member:t}}function P2(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin),a=["#/portal","#/share"],i=a.some(r=>n.hash.startsWith(r)),o=a.some(r=>t.startsWith(r));!n.hash||!i||o||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function z2({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function I2({state:e}){return{showPopup:!e.showPopup}}function N2({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function A2({state:e}){return e.lastPage?{page:e.lastPage}:Tk({state:e})}function Tk({state:e}){return Tn(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function M2({data:e,state:t}){const{action:n="openNotification",status:a="success",autoHide:i=!0,closeable:o=!0,duration:r=2600,message:s=""}=e||{},c=vb({type:n,status:a,autoHide:i,closeable:o,duration:r,state:t,message:s});return{notification:c,notificationSequence:c.count}}function D2(){return{notification:null}}async function F2({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:re({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to log out, please try again")})}}}async function O2({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:o,inboxLinks:r}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...o?{otcRef:o}:{},inboxLinks:r,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:re({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Zt(a,h("Failed to log in, please try again"))})}}}function _2({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 R2({data:e,api:t}){var a;const n=h("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),o=await t.member.verifyOTC({...e,integrityToken:i});return o.redirectUrl?window.location.assign(o.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Zt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Zt(i,n)}}}async function Y2({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u}=e;s=s==null?void 0:s.trim();let d;if(a.toLowerCase()==="free"){const p=await n.member.getIntegrityToken();({inboxLinks:d}=await n.member.sendMagicLink({emailType:"signup",integrityToken:p,...e,name:s}))}else return i&&o?await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u}):({tierId:i,cadence:o}=na({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:o,email:r,name:s,newsletters:c,offerId:u})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:d,pageData:{...t.pageData||{},email:(r||"").trim()}}}catch(a){const i=Zt(a,h("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:re({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function L2({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=na({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:o,cadence:r,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:re({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to process checkout, please try again")})}}}async function B2({data:e,state:t,api:n}){try{const{tierId:a,cadence:i,email:o}=e;return await n.member.checkoutGift({tierId:a,cadence:i,email:o}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:re({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to process checkout, please try again")})}}}async function U2({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:c}=na({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:c,subscriptionId:o,cancelAtPeriodEnd:r,planId:i});const u=await n.member.sessionData(),d="updateSubscription:success";return{action:d,popupNotification:re({type:d,autoHide:!0,closeable:!0,state:t,status:"success",message:h("Subscription plan updated successfully")}),page:"accountHome",member:u}}catch{return{action:"updateSubscription:failed",popupNotification:re({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to update subscription, please try again")})}}}async function H2({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:re({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to cancel subscription, please try again")})}}}async function V2({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:re({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to cancel subscription, please try again")})}}}async function W2({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:re({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:re({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function G2({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:re({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to update billing information, please try again")})}}}async function K2({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:re({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:h("Failed to open billing portal, please try again")})}}}async function q2(){return{popupNotification:null}}async function J2({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:re({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function Z2({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const o={};return a&&(o.newsletters=a),i!==void 0&&(o.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(o)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:h("Failed to update newsletter settings")})}}}async function X2({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:re({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:h("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:re({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:h("Your email has failed to resubscribe, please try again")})}}}async function Q2({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const o="updateNewsletter:success";return{action:o,member:i,popupNotification:re({type:o,autoHide:!0,closeable:!0,state:t,status:"success",message:h("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:h("Failed to update newsletter settings")})}}}async function ez({data:e,state:t,api:n}){const{email:a}=e,i=D0({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(o){return{success:!1,error:o}}return null}async function tz({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if(O0({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function nz({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 az({data:e,state:t,api:n}){const[a,i]=await Promise.all([tz({data:e,state:t,api:n}),ez({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:re({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:h("Check your inbox to verify email update")})};const o=a.success?h("Failed to send verification email"):h("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:re({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:o,state:t})}}else if(a){const o=a.success?"updateProfile:success":"updateProfile:failed",r=a.success?"success":"error",s=a.success?h("Account details updated successfully"):h("Failed to update account details");return{action:o,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:re({type:o,autoHide:a.success,closeable:!0,status:r,state:t,message:s})}}else if(i){const o=i.success?"updateProfile:success":"updateProfile:failed",r=i.success?"success":"error";let s="";return i.error?s=Zt(i.error,h("Failed to send verification email")):s=h("Check your inbox to verify email update"),{action:o,...i.success?{page:"accountHome"}:{},popupNotification:re({type:o,autoHide:i.success,closeable:!0,status:r,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:re({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:h("Account details updated successfully")})}}async function iz({data:{siteUrl:e},state:t}){const n=rl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=fb(),r=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:r,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:o,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function oz({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 rz({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const sz={togglePopup:I2,openPopup:N2,closePopup:Tk,switchPage:z2,openNotification:M2,closeNotification:D2,back:A2,signout:F2,signin:O2,startSigninOTCFromCustomForm:_2,verifyOTC:R2,signup:Y2,updateSubscription:U2,cancelSubscription:H2,continueSubscription:V2,applyOffer:W2,updateNewsletter:Q2,updateProfile:az,refreshMemberData:nz,clearPopupNotification:q2,editBilling:G2,manageBilling:K2,checkoutPlan:L2,checkoutGift:B2,updateNewsletterPreference:Z2,showPopupNotification:J2,removeEmailFromSuppressionList:X2,oneClickSubscribe:iz,trackRecommendationClicked:oz,trackRecommendationSubscribed:rz};async function lz({action:e,data:t,state:n,api:a}){const i=sz[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Pk(e,t){e&&(e.innerText=t)}function cz(e,t,n){t.classList.add("error");const a=h("There was an error sending the email, please try again");Pk(n,Zt(e,a))}async function uz({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var x,T;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),c=e.target.querySelector("input[data-members-name]"),u=((x=t==null?void 0:t.dataset)==null?void 0:x.membersAutoredirect)||"true",d=s==null?void 0:s.value,p=((c==null?void 0:c.value)||"").trim()||void 0,m,f=[],b=[],w=e.target.querySelectorAll("input[data-members-label]")||[];for(let E=0;E<w.length;++E)f.push(w[E].value);let g=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let E=0;E<g.length;++E)b.push({name:g[E].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const y=m==="signin"&&((T=t==null?void 0:t.dataset)==null?void 0:T.membersOtc)==="true";t.classList.add("loading");const k=No(),C={email:d,emailType:m,labels:f,name:p,autoRedirect:u==="true"};y&&(C.includeOTC=!0),k&&(C.urlHistory=k),g.length>0?C.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(C.newsletters=[]);try{const N=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),z=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...C,integrityToken:N})});if(t.addEventListener("submit",i),t.classList.remove("loading"),z.ok){t.classList.add("success");let j;if(y)try{j=await z.clone().json()}catch{j=void 0}const V=j==null?void 0:j.otc_ref;if(V&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(d||"").trim(),otcRef:V,inboxLinks:j==null?void 0:j.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const j=await xt.fromApiResponse(z),V=Zt(j,h("Failed to send magic link email"));Pk(n,V),t.classList.add("error")}}catch(E){cz(E,t,n)}}function dz({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:o,clickHandler:r}){t.removeEventListener("click",r),e.preventDefault();let s=t.dataset.membersPlan,c=C0(i,s.toLowerCase()),u=t.dataset.membersSuccess,d=t.dataset.membersCancel,p,m;u&&(p=new URL(u,window.location.href).href),d&&(m=new URL(d,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const f=o?{checkoutType:"upgrade"}:{},b=No();return b&&(f.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(w){return w.ok?w.text():null}).then(function(w){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,identity:w,successUrl:p,cancelUrl:m,metadata:f})}).then(function(g){if(!g.ok)throw new Error(h("Could not create Stripe checkout session"));return g.json()})}).then(function(w){return w.url?window.location.assign(w.url):window.Stripe(w.publicKey).redirectToCheckout({sessionId:w.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(w){console.error(w),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=w.message),t.classList.add("error")})}function mz({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:o}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let c=s.querySelector("[data-members-error]");function u(d){uz({event:d,errorEl:c,form:s,siteUrl:e,submitHandler:u,doAction:i,captureException:o})}s.addEventListener("submit",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let c=s.querySelector("[data-members-error]");function u(d){dz({el:s,event:d,errorEl:c,member:n,site:t,siteUrl:e,clickHandler:u})}s.addEventListener("click",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let c=s.querySelector("[data-members-error]"),u=s.dataset.membersSuccess,d=s.dataset.membersCancel,p,m;u&&(p=new URL(u,window.location.href).href),d&&(m=new URL(d,window.location.href).href);function f(b){s.removeEventListener("click",f),b.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(w){return w.ok?w.text():null}).then(function(w){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:w,successUrl:p,cancelUrl:m})}).then(function(g){if(!g.ok)throw new Error(h("Could not create Stripe checkout session"));return g.json()})}).then(function(w){return window.Stripe(w.publicKey).redirectToCheckout({sessionId:w.sessionId})}).then(function(w){if(w.error)throw new Error(h(w.error.message))}).catch(function(w){console.error(w),s.addEventListener("click",f),s.classList.remove("loading"),c&&(c.innerText=w.message),s.classList.add("error")})}s.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let c=s.querySelector("[data-members-error]"),u=s.dataset.membersReturn,d;u&&(d=new URL(u,window.location.href).href);function p(m){s.removeEventListener("click",p),m.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:d})}).then(function(b){if(!b.ok)throw new Error(h("Could not create Stripe billing portal session"));return b.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),s.addEventListener("click",p),s.classList.remove("loading"),c&&(c.innerText=f.message),s.classList.add("error")})}s.addEventListener("click",p)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function c(u){s.removeEventListener("click",c),u.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(d){d.ok?window.location.replace(e):(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",c)});const r=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let c=s.parentElement.querySelector("[data-members-error]");function u(d){d.preventDefault();let p=s.dataset.membersCancelSubscription;if(r){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:p,action:"cancel"}});return}return s.removeEventListener("click",u),s.classList.remove("error"),s.classList.add("loading"),c&&(c.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",u),s.classList.remove("loading"),s.classList.add("error"),c&&(c.innerText=h("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",u)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let c=s.parentElement.querySelector("[data-members-error]");function u(d){s.removeEventListener("click",u),d.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let p=s.dataset.membersContinueSubscription;return c&&(c.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${p}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",u),s.classList.remove("loading"),s.classList.add("error"),c&&(c.innerText=h("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",u)})}const zk=e=>{try{return decodeURIComponent(e)}catch{return null}},pz={staleGiftRedemptionRequest:!0},hz={showPopup:!0,site:oi,member:ri.free,page:"accountEmail",...T2(),pageData:jk};function fz({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?l.jsx(rd,{children:t}):l.jsx(l.Fragment,{children:t})}class gz extends Z.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,o;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(o=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:o.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin,this.state.reloadOnPopupClose&&window.location.reload())}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:r}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),mz({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:hs})}}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=async a=>{a.preventDefault();const i=a.currentTarget,o=i&&i.dataset.portal,r=this.getPageFromLinkPath(o);if(!r)return;const{page:s,pageQuery:c,pageData:u}=r;if(this.state.initStatus==="success"){if(s==="gift"&&!Ys({site:this.state.site})){this.invalidateGiftRedemptionRequest(),Tn();return}if(s==="giftRedemption"&&(u!=null&&u.token)){const d=this.startGiftRedemptionRequest(u.token),p=await this.fetchGiftRedemptionData({site:this.state.site,token:u.token});if(!this.isCurrentGiftRedemptionRequest(d))return;this.setState(p);return}this.invalidateGiftRedemptionRequest(),c&&c!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:c}):this.dispatchAction("openPopup",{page:s,pageQuery:c,pageData:u})}};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const o=this.state.showPopup?t:n,r=this.state.showPopup?n:t;i.classList.add(o),i.classList.remove(r)})}startGiftRedemptionRequest(t){return this._redemptionRequestId+=1,this.currentRedemptionToken=t,{requestId:this._redemptionRequestId,token:t}}invalidateGiftRedemptionRequest(){this._redemptionRequestId+=1,this.currentRedemptionToken=null}isCurrentGiftRedemptionRequest({requestId:t,token:n}){return this._redemptionRequestId===t&&this.currentRedemptionToken===n}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:o,popupNotification:r,notification:s,notificationSequence:c,lastPage:u,pageQuery:d,pageData:p}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Os.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:u,pageQuery:d,showPopup:o,pageData:p,popupNotification:r,notification:s,notificationSequence:c,dir:Os.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:d,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const b=document.querySelectorAll("[data-lexical-signup-form]");b.length>0&&b.forEach(w=>{w.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...o}=this.fetchDevData(),r=await this.fetchLinkData(t,n),{site:s,...c}=r!=null&&r.staleGiftRedemptionRequest?{}:r,{site:u,...d}=this.fetchPreviewData(),{site:p,...m}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...s,...u,...p,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(u||{}).plans}},...o,...c,...m,...d}}fetchDevData(){return de(["dev"])&&!this.state.customSiteUrl?hz:de(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){var i,o,r;const n=new URLSearchParams(t),a={};for(let s of n.entries()){const c=s[0],u=decodeURIComponent(s[1]);c==="name"?a.name=u||"":c==="code"?a.code=u||"":c==="display_title"?a.display_title=u||"":c==="display_description"?a.display_description=u||"":c==="type"?a.type=u||"":c==="cadence"?a.cadence=u||"":c==="duration"?a.duration=u||"":c==="duration_in_months"&&!isNaN(Number(u))?a.duration_in_months=Number(u):c==="amount"&&!isNaN(Number(u))?a.amount=Number(u):c==="currency"?a.currency=u||"":c==="status"?a.status=u||"":c==="tier_id"?a.tier={id:u||jk.tier.id}:c==="redemption_type"&&(a.redemption_type=u||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=ri.preview)==null?void 0:i.subscriptions)==null?void 0:o[0])==null?void 0:r.id;return{page:"accountPlan",offers:[a],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let o,r=null,s,c,u;for(let d of n.entries()){const p=d[0],m=decodeURIComponent(d[1]);if(p==="button")a.site.portal_button=JSON.parse(m);else if(p==="name")a.site.portal_name=JSON.parse(m);else if(p==="isFree"&&JSON.parse(m))i.push("free");else if(p==="isMonthly"&&JSON.parse(m))i.push("monthly");else if(p==="isYearly"&&JSON.parse(m))i.push("yearly");else if(p==="portalPrices")o=m?m.split(","):[];else if(p==="portalProducts")r=m?m.split(","):[];else if(p==="page"&&m)a.page=m;else if(p==="accentColor"&&(m===""||m))a.site.accent_color=m;else if(p==="buttonIcon"&&m)a.site.portal_button_icon=m;else if(p==="signupButtonText")a.site.portal_button_signup_text=m||"";else if(p==="signupTermsHtml")a.site.portal_signup_terms_html=m||"";else if(p==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(m);else if(p==="buttonStyle"&&m)a.site.portal_button_style=m;else if(p==="monthlyPrice"&&!isNaN(Number(m)))a.site.plans.monthly=Number(m),s=Number(m);else if(p==="yearlyPrice"&&!isNaN(Number(m)))a.site.plans.yearly=Number(m),c=Number(m);else if(p==="currency"&&m){const f=m.toUpperCase();a.site.plans.currency=f,a.site.plans.currency_symbol=ke(f),u=f}else p==="disableBackground"?a.site.disableBackground=JSON.parse(m):p==="membersSignupAccess"&&m?a.site.members_signup_access=m:p==="portalDefaultPlan"&&m?a.site.portal_default_plan=m:p==="transistorPortalSettings"&&m&&(a.site.transistor_portal_settings=JSON.parse(m))}return a.site.portal_plans=i,a.site.portal_products=r,o?a.site.portal_plans=o:s&&c&&u&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:u,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:u,amount:c,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:o}=Yb({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:re({type:t,status:n,duration:a,closeable:o,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({site:t,token:n}){var a;if(!Ys({site:t}))return Tn(),{};try{const i=await this.GhostApi.gift.fetchRedemptionData({token:n});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:n,gift:((a=i==null?void 0:i.gifts)==null?void 0:a[0])||null}}}catch(i){Tn();const o=vb({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:pk(i)});return{showPopup:!1,pageData:null,notification:o,notificationSequence:o.count}}}async fetchLinkData(t,n){this.invalidateGiftRedemptionRequest();const a=new URLSearchParams(window.location.search);if(a.get("stripe")==="gift-purchase-success"){const b=a.get("gift_token");if(el(["stripe","gift_token"]),b)return{showPopup:!0,page:"giftSuccess",pageData:{token:b}}}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(j0({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,o]=window.location.hash.substr(1).split("?"),r=new URLSearchParams(o??""),s=/^(?:(\w+?))?\/monthly$/,c=/^(?:(\w+?))?\/yearly$/,u=/^offers\/(\w+?)\/?$/,d=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,p=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,m=/^\/share\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,b,w]=i.match(f),g=parseInt(w);if(g===1||g===0)return n||r.get("uuid")&&r.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:r.get("uuid"),key:n?null:r.get("key"),postId:b,score:g}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${b}/${g}/`}}}if(i&&d.test(i)){const[,b]=i.match(d),w=zk(b);if(!w)return{};const g=this.startGiftRedemptionRequest(w),y=await this.fetchGiftRedemptionData({site:t,token:w});return this.isCurrentGiftRedemptionRequest(g)?y:pz}if(i&&m.test(i))return{showPopup:!0,page:"share"};if(i&&p.test(i)){const[,b]=i.match(p),{page:w,pageQuery:g,pageData:y}=this.getPageFromLinkPath(b,t)||{};if(!n&&w&&wk({page:w}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${b}/`}};if(w==="gift"&&!Ys({site:t}))return Tn(),{};const k=["accountPlan","accountProfile"].includes(w)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(g)||s.test(g)||c.test(g)||u.test(g)),...w?{page:w}:{},...g?{pageQuery:g}:{},...y?{pageData:y}:{},...k?{lastPage:k}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(de(["preview"])){let n={};return de(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||rl({siteUrl:t,apiUrl:a,apiKey:i});const{site:o,member:r,offers:s}=await this.GhostApi.init(),c=this.getColorOverride();return c&&(o.accent_color=c),this.setupFirstPromoter({site:o,member:r}),this.setupSentry({site:o}),{site:o,member:r,offers:s}}catch(o){if(de(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(de(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.68.3|ghost@${i}`;n&&n.dsn&&ej({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>y0({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(de(["test"]))return null;const a=F0({site:t});let i=Ed({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://cdn.firstpromoter.com/fprom.js",o.onload=o.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),G0({member:n})){const c=n.email,u=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:c,uid:u});else{const d=window._fprom||[];window._fprom=d,d.push(["event","signup"]),d.push(["email",c]),d.push(["uid",u])}}}catch{}};const r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(o,r)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await lz({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=re({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:Zt(a,h("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}async updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),a=await this.fetchLinkData(this.state.site,this.state.member);if(a!=null&&a.staleGiftRedemptionRequest)return;const{site:i,...o}=a,r={site:{...this.state.site,...i||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(i||{}).plans,...(t||{}).plans}},...o,...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(Tn(),!Dt({member:a})||Pn({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||Td({offer:r})||!L0({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=ea({site:t,productId:r.tier.id}),c=r.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:u,cadence:d}=na({site:t,priceId:c.id});this.dispatchAction("checkoutPlan",{plan:c.id,offerId:n,tierId:u,cadence:d})}else{const{tierId:u,cadence:d}=na({site:t,priceId:c.id});this.dispatchAction("signup",{plan:c.id,offerId:n,tierId:u,cadence:d})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let o=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}wb({site:t,pageQuery:n})&&(o=wb({site:t,pageQuery:n}));const r=E0({site:t,priceId:o});if(n&&n!=="free"){Tn();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:c,cadence:u}=na({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:c,cadence:u})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,o=/^offers\/(\w+?)\/?$/,r=/^gift\/redeem\/([^/?#]+)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t)){const[,s]=t.match(r),c=zk(s);return c?{page:"giftRedemption",pageData:{token:c}}:null}else{if(o.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,s]=t.match(a);return{page:"signup",pageQuery:`${s}/monthly`}}else if(i.test(t)){const[,s]=t.match(i);return{page:"signup",pageQuery:`${s}/yearly`}}else if(n.test(t)){const[,s]=t.match(n);return{page:"signup",pageQuery:s}}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==="gift")return{page:"gift"};if(t==="share")return{page:"share"};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 ET(t)}getRetentionPreviewMember({site:t,offers:n}){var u,d,p;const a=(n||[]).find(m=>Td({offer:m})),i=(u=a==null?void 0:a.tier)==null?void 0:u.id,o=i?ea({site:t,productId:i}):null,r=o?a.cadence==="year"?o.yearlyPrice:o.monthlyPrice:null,s=ri.preview,c=(d=s==null?void 0:s.subscriptions)==null?void 0:d[0];return!c||!o||!r?s:{...s,subscriptions:[{...c,plan:{...c.plan,amount:r.amount,interval:r.interval,currency:r.currency.toUpperCase()},price:{...c.price,price_id:r.id,amount:r.amount,interval:r.interval,currency:r.currency,product:{...(p=c.price)==null?void 0:p.product,product_id:o.id}},tier:{id:o.id,name:o.name}}]}}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ft({site:t})||!Qt({site:t})?"signin":"signup";n=a?"accountHome":i}return cm({page:n})}getContextMember({site:t,page:n,member:a,offers:i,pageData:o,customSiteUrl:r}){return de(["dev","preview"],{customSiteUrl:r})?wk({page:n})||v2({page:n})?de(["dev"],{customSiteUrl:r})?a||ri.free:de(["preview"])?n==="accountPlan"&&(o==null?void 0:o.action)==="cancel"?this.getRetentionPreviewMember({site:t,offers:i}):ri.preview:ri.paid:null:a}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:o,page:r,lastPage:s,showPopup:c,pageQuery:u,pageData:d,popupNotification:p,notification:m,customSiteUrl:f,dir:b,scrollbarWidth:w,otcRef:g,inboxLinks:y}=this.state,k=this.getContextPage({site:t,page:r,member:n}),C=this.getContextMember({site:t,page:k,member:n,offers:a,pageData:d,customSiteUrl:f});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:k,pageQuery:u,pageData:d,member:C,lastPage:s,showPopup:c,popupNotification:p,notification:m,customSiteUrl:f,dir:b,scrollbarWidth:w,otcRef:g,inboxLinks:y,doAction:(x,T)=>this.dispatchAction(x,T)}}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"], a[href*="#/share"]').forEach(P2)}render(){return this.state.initStatus==="success"?l.jsx(fz,{site:this.state.site,children:l.jsxs(_.Provider,{value:this.getContextFromState(),children:[l.jsx(dm,{}),l.jsx(zd,{}),l.jsx(Rd,{})]})}):null}}const Ik="ghost-portal-root";function yz(){const e=document.createElement("div");e.id=Ik,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function bz(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,o=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:o}}return{}}function kz(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function vz(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=bz(),o=e||window.location.origin;yz(),kz(),cS.render(l.jsx(Z.StrictMode,{children:l.jsx(gz,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Ik))}vz()});
4134
4121
  //# sourceMappingURL=portal.min.js.map