@tryghost/portal 2.68.20 → 2.68.21

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
@@ -2166,30 +2166,26 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2166
2166
  }
2167
2167
 
2168
2168
  .gh-portal-gift-redemption {
2169
- overflow: hidden;
2170
- }
2171
-
2172
- .gh-gift-redemption-panel {
2173
2169
  position: relative;
2174
- background: var(--white);
2175
- }
2176
-
2177
- .gh-gift-redemption-summary {
2178
- position: relative;
2179
- padding: 32px;
2180
- text-align: center;
2170
+ overflow: hidden;
2181
2171
  }
2182
2172
 
2183
- .gh-gift-redemption-summary:before {
2173
+ .gh-gift-redemption-bg {
2184
2174
  position: absolute;
2185
- content: "";
2186
- display: block;
2187
- background: var(--brandcolor);
2188
2175
  top: 0;
2189
- right: 0;
2190
- bottom: 0;
2191
2176
  left: 0;
2192
- opacity: 0.06;
2177
+ right: 0;
2178
+ height: 400px;
2179
+ background: linear-gradient(180deg, var(--brandcolor), transparent);
2180
+ opacity: 0.08;
2181
+ pointer-events: none;
2182
+ z-index: 0;
2183
+ }
2184
+
2185
+ .gh-gift-redemption-panel {
2186
+ position: relative;
2187
+ z-index: 1;
2188
+ padding: 40px 32px 32px;
2193
2189
  }
2194
2190
 
2195
2191
  .gh-gift-redemption-icon {
@@ -2198,15 +2194,21 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2198
2194
  justify-content: center;
2199
2195
  width: 48px;
2200
2196
  height: 48px;
2197
+ margin: -8px 0 0 -3px;
2201
2198
  color: var(--brandcolor);
2202
2199
  }
2203
2200
 
2201
+ html[dir="rtl"] .gh-gift-redemption-icon {
2202
+ margin: -8px -3px 0 0;
2203
+ }
2204
+
2204
2205
  .gh-gift-redemption-icon svg {
2205
2206
  width: 52px;
2206
2207
  height: 52px;
2207
2208
  }
2208
2209
 
2209
2210
  .gh-gift-redemption-kicker {
2211
+ margin-top: 0;
2210
2212
  font-size: 1.3rem;
2211
2213
  font-weight: 600;
2212
2214
  letter-spacing: 0.02em;
@@ -2216,19 +2218,18 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2216
2218
 
2217
2219
  .gh-gift-redemption-title {
2218
2220
  max-width: none;
2219
- margin: 16px auto 0;
2220
- font-size: 2.6rem;
2221
+ margin: 20px 0 0;
2222
+ font-size: 2.4rem;
2221
2223
  font-weight: 700;
2222
- line-height: 1.08;
2224
+ line-height: 1.1;
2223
2225
  letter-spacing: -0.015em;
2224
- white-space: nowrap;
2225
2226
  color: var(--grey0);
2226
2227
  }
2227
2228
 
2228
2229
  .gh-gift-redemption-plan {
2229
- margin-top: 10px;
2230
- font-size: 1.6rem;
2231
- color: var(--grey2);
2230
+ margin-top: 8px;
2231
+ font-size: 1.5rem;
2232
+ color: var(--grey3);
2232
2233
  }
2233
2234
 
2234
2235
  .gh-gift-redemption-tier {
@@ -2243,19 +2244,20 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2243
2244
  display: flex;
2244
2245
  flex-direction: column;
2245
2246
  gap: 8px;
2246
- max-width: 400px;
2247
- margin: 20px auto 0;
2247
+ margin-top: 20px;
2248
+ }
2249
+
2250
+ .gh-gift-redemption-form {
2251
+ margin-top: 36px;
2248
2252
  }
2249
2253
 
2250
2254
  .gh-gift-redemption-inline-cta {
2251
- margin: 28px auto 0;
2252
- max-width: 400px;
2255
+ margin-top: 36px;
2253
2256
  }
2254
2257
 
2255
2258
  .gh-gift-redemption-benefit {
2256
2259
  display: flex;
2257
2260
  align-items: flex-start;
2258
- justify-content: center;
2259
2261
  gap: 10px;
2260
2262
  color: var(--grey2);
2261
2263
  font-size: 1.45rem;
@@ -2266,7 +2268,7 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2266
2268
  .gh-gift-redemption-benefit svg {
2267
2269
  width: 14px;
2268
2270
  height: 14px;
2269
- margin-top: 2px;
2271
+ margin-top: 3px;
2270
2272
  color: var(--grey1);
2271
2273
  flex-shrink: 0;
2272
2274
  }
@@ -2276,30 +2278,21 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2276
2278
  flex-direction: row-reverse;
2277
2279
  }
2278
2280
 
2279
- .gh-gift-redemption-form {
2280
- padding: 22px 28px 28px;
2281
- background: var(--white);
2282
- }
2283
-
2284
2281
  .gh-gift-redemption-submit {
2285
2282
  width: 100%;
2286
2283
  height: 44px;
2284
+ margin-top: 20px;
2287
2285
  font-size: 1.5rem;
2288
2286
  font-weight: 600;
2289
2287
  }
2290
2288
 
2291
- .gh-gift-redemption-form .gh-gift-redemption-submit {
2292
- margin-top: 22px;
2293
- }
2294
-
2295
2289
  @media (max-width: 480px) {
2296
- .gh-gift-redemption-summary {
2297
- padding: 28px 24px 24px;
2290
+ .gh-gift-redemption-panel {
2291
+ padding: 32px 24px 24px;
2298
2292
  }
2299
2293
 
2300
2294
  .gh-gift-redemption-title {
2301
2295
  font-size: 2.1rem;
2302
- white-space: normal;
2303
2296
  }
2304
2297
 
2305
2298
  .gh-gift-redemption-benefit {
@@ -2310,11 +2303,11 @@ html[dir="rtl"] .gh-portal-offer-title h4 {
2310
2303
  text-align: right;
2311
2304
  }
2312
2305
 
2313
- .gh-gift-redemption-form {
2314
- padding: 20px 20px 22px;
2306
+ .gh-gift-redemption-bg {
2307
+ height: 300px;
2315
2308
  }
2316
2309
  }
2317
- `,XI=()=>{const{action:e,brandColor:t,doAction:n,member:a,pageData:i,site:o}=w.useContext(F),r=i==null?void 0:i.gift,s=!!a,c=ul({site:o}),[u,d]=w.useState((a==null?void 0:a.name)||""),[p,m]=w.useState((a==null?void 0:a.email)||""),[h,b]=w.useState({});if(w.useEffect(()=>{d((a==null?void 0:a.name)||""),m((a==null?void 0:a.email)||""),b({})},[a==null?void 0:a.email,a==null?void 0:a.name]),w.useEffect(()=>{c||(on(),n("closePopup"))},[n,c]),w.useEffect(()=>{!c||r||(n("openNotification",{action:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,message:ev()}),n("closePopup"))},[n,r,c]),!c||!r)return null;const v=[{type:"text",value:u,placeholder:g("Jamie Larson"),label:g("Your name"),name:"name",required:!1,errorMessage:h.name||"",tabIndex:1,autoFocus:!p},{type:"email",value:p,placeholder:g("jamie@example.com"),label:g("Your email"),name:"email",required:!0,errorMessage:h.email||"",tabIndex:2,autoFocus:!!p}],f=($,C)=>{b(z=>({...z,[C.name]:""})),C.name==="name"&&d($.target.value),C.name==="email"&&m($.target.value)},y=$=>{if($.keyCode===13){if(E)return;k($)}},k=$=>{if($.preventDefault(),E)return;if(s){n("redeemGift",{giftToken:i==null?void 0:i.token});return}const C=Zo({fields:v}),z=Object.values(C).some(T=>!!T);b(C),!z&&n("redeemGift",{email:p,name:u,giftToken:i==null?void 0:i.token})},E=e==="redeemGift:running",x=E?"Redeeming gift...":"Redeem gift membership";return l.jsxs("div",{className:"gh-portal-content gh-portal-gift-redemption",children:[l.jsx(he,{}),l.jsxs("div",{className:"gh-gift-redemption-panel",children:[l.jsxs("div",{className:"gh-gift-redemption-summary",children:[l.jsx("div",{className:"gh-gift-redemption-icon",children:l.jsx(zl,{})}),l.jsx("div",{className:"gh-gift-redemption-kicker",children:"Gift membership"}),l.jsx("h1",{className:"gh-gift-redemption-title",children:"You've been gifted a membership"}),l.jsxs("div",{className:"gh-gift-redemption-plan",children:[l.jsx("span",{className:"gh-gift-redemption-tier",children:r.tier.name}),l.jsx("span",{children:" · "}),l.jsx("span",{className:"gh-gift-redemption-cadence",children:r2(r)})]}),r.tier.benefits.length>0&&l.jsx("div",{className:"gh-gift-redemption-benefits",children:r.tier.benefits.map(($,C)=>{const z=typeof $=="string"?$:$==null?void 0:$.name,T=typeof $=="string"?$:($==null?void 0:$.id)||`gift-benefit-${C}`;return z?l.jsxs("div",{className:"gh-gift-redemption-benefit",children:[l.jsx(Ko,{}),l.jsx("span",{children:z})]},T):null})}),s&&l.jsx("div",{className:"gh-gift-redemption-inline-cta",children:l.jsx(ce,{brandColor:t,classes:"gh-gift-redemption-submit",label:x,onClick:k,style:{width:"100%"},disabled:E,isRunning:E})})]}),!s&&l.jsxs("div",{className:"gh-gift-redemption-form",children:[l.jsx(Jo,{fields:v,onChange:f,onKeyDown:y}),l.jsx(ce,{brandColor:t,classes:"gh-gift-redemption-submit",label:x,onClick:k,style:{width:"100%"},disabled:E,isRunning:E})]})]})]})},QI=`
2310
+ `,XI=()=>{const{action:e,brandColor:t,doAction:n,member:a,pageData:i,site:o}=w.useContext(F),r=i==null?void 0:i.gift,s=!!a,c=ul({site:o}),[u,d]=w.useState((a==null?void 0:a.name)||""),[p,m]=w.useState((a==null?void 0:a.email)||""),[h,b]=w.useState({});if(w.useEffect(()=>{d((a==null?void 0:a.name)||""),m((a==null?void 0:a.email)||""),b({})},[a==null?void 0:a.email,a==null?void 0:a.name]),w.useEffect(()=>{c||(on(),n("closePopup"))},[n,c]),w.useEffect(()=>{!c||r||(n("openNotification",{action:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,message:ev()}),n("closePopup"))},[n,r,c]),!c||!r)return null;const v=[{type:"text",value:u,placeholder:g("Jamie Larson"),label:g("Your name"),name:"name",required:!1,errorMessage:h.name||"",tabIndex:1,autoFocus:!p},{type:"email",value:p,placeholder:g("jamie@example.com"),label:g("Your email"),name:"email",required:!0,errorMessage:h.email||"",tabIndex:2,autoFocus:!!p}],f=($,C)=>{b(z=>({...z,[C.name]:""})),C.name==="name"&&d($.target.value),C.name==="email"&&m($.target.value)},y=$=>{if($.keyCode===13){if(E)return;k($)}},k=$=>{if($.preventDefault(),E)return;if(s){n("redeemGift",{giftToken:i==null?void 0:i.token});return}const C=Zo({fields:v}),z=Object.values(C).some(T=>!!T);b(C),!z&&n("redeemGift",{email:p,name:u,giftToken:i==null?void 0:i.token})},E=e==="redeemGift:running",x=E?"Redeeming gift...":"Redeem gift membership";return l.jsxs("div",{className:"gh-portal-content gh-portal-gift-redemption",children:[l.jsx(he,{}),l.jsx("div",{className:"gh-gift-redemption-bg"}),l.jsxs("div",{className:"gh-gift-redemption-panel",children:[l.jsx("div",{className:"gh-gift-redemption-icon",children:l.jsx(zl,{})}),l.jsx("div",{className:"gh-gift-redemption-kicker",children:"Gift membership"}),l.jsx("h1",{className:"gh-gift-redemption-title",children:"You've been gifted a membership"}),l.jsxs("div",{className:"gh-gift-redemption-plan",children:[l.jsx("span",{className:"gh-gift-redemption-tier",children:r.tier.name}),l.jsx("span",{children:" · "}),l.jsx("span",{className:"gh-gift-redemption-cadence",children:r2(r)})]}),r.tier.benefits.length>0&&l.jsx("div",{className:"gh-gift-redemption-benefits",children:r.tier.benefits.map(($,C)=>{const z=typeof $=="string"?$:$==null?void 0:$.name,T=typeof $=="string"?$:($==null?void 0:$.id)||`gift-benefit-${C}`;return z?l.jsxs("div",{className:"gh-gift-redemption-benefit",children:[l.jsx(Ko,{}),l.jsx("span",{children:z})]},T):null})}),s?l.jsx("div",{className:"gh-gift-redemption-inline-cta",children:l.jsx(ce,{brandColor:t,classes:"gh-gift-redemption-submit",label:x,onClick:k,style:{width:"100%"},disabled:E,isRunning:E})}):l.jsxs("div",{className:"gh-gift-redemption-form",children:[l.jsx(Jo,{fields:v,onChange:f,onKeyDown:y}),l.jsx(ce,{brandColor:t,classes:"gh-gift-redemption-submit",label:x,onClick:k,style:{width:"100%"},disabled:E,isRunning:E})]})]})]})},QI=`
2318
2311
  .gh-portal-content.gift {
2319
2312
  position: relative;
2320
2313
  padding-top: 0;
@@ -4255,5 +4248,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
4255
4248
  }
4256
4249
  `;function xz({site:e}){return em+vz+h2+T2+_2+f2()+p2+c2+m2+xk+NI+vI+OI()+gm+AI+wz+Sz+RI+VI+WI+GI+qI+ZI+QI+uz+oz+pz+yz+bz}const np=class np extends X.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:Zo({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:g("jamie@example.com"),label:g("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=g(a?"Sending login link...":"Continue");const o=!!a;return t==="signin:failed"&&(i=g("Retry"),n=!0),l.jsx(ce,{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:g("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:g("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=dl({site:t})&&rn({site:t});return Mn({site:t})?l.jsxs("section",{children:[l.jsx("div",{className:"gh-portal-section",children:l.jsx(Jo,{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:g("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}):Mn({site:t})?null:l.jsx(sv,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return Mn({site:t})?l.jsx("h1",{className:"gh-portal-main-title",children:g("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(he,{}),l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};np.contextType=F;let Rm=np;const Ez=({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:g("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:g("Contact support")})})})})]})},Cz=()=>{const{member:e,brandColor:t}=w.useContext(F),n=e.avatar_image;return l.jsxs("header",{className:"gh-portal-account-header",children:[l.jsx(Qd,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),l.jsx("h2",{className:"gh-portal-main-title",children:g("Your account")})]})},$z=()=>{const{site:e,action:t,brandColor:n,doAction:a}=w.useContext(F);if(!dl({site:e})||!rn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),o=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return l.jsx(ce,{dataTestId:"view-plans",isRunning:i,label:g("View plans"),onClick:()=>o(),brandColor:n,style:{width:"100%"}})},jz=()=>{const{member:e,site:t}=w.useContext(F),{is_stripe_configured:n}=t;if(!n||ri({site:t}))return null;const a=ot({member:e}),i=An({member:e});if(i&&!a)return null;if(a){const o=a==null?void 0:a.current_period_end,r=ll({member:e});if(sl({member:e}))return null;if(i&&r)return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:g("Your subscription will expire on {expiryDate}",{expiryDate:r})})});if(a!=null&&a.cancel_at_period_end||i)return null;if(am({sub:a})){const s=Nn(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:g("Your subscription will start on {subscriptionStart}",{subscriptionStart:s})})})}return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:g("Your subscription will renew on {renewalDate}",{renewalDate:Nn(o)})})})}return l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:g("You currently have a free membership, upgrade to a paid subscription for full access.")}),l.jsx($z,{})]})},Tz=()=>{const{member:e,doAction:t,action:n,brandColor:a}=w.useContext(F),i=ot({member:e});if(!i||!i.cancel_at_period_end)return null;const o=g("Resume subscription"),r=["continueSubscription:running"].includes(n),s=!!r,c=Nn(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(ze,{string:g("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:l.jsx("strong",{children:c})}})}),l.jsx(ce,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:r,disabled:s,isPrimary:!0,brandColor:a,label:o,style:{width:"100%"}})]})})},Pz=()=>{const{member:e,site:t,doAction:n,action:a,brandColor:i}=w.useContext(F);if(!sl({member:e})||$k({member:e,site:t}))return null;const o=ll({member:e});if(!o)return null;const r=a==="continueGiftSubscription:running";return l.jsx("div",{className:"gh-portal-cancelcontinue-container",children:l.jsxs("div",{className:"gh-portal-cancel-banner",children:[l.jsxs("p",{style:{maxWidth:"none",margin:"0 0 16px",textAlign:"center"},children:["Your gift subscription ends on ",l.jsx("strong",{children:o}),". Continue with a paid subscription to keep reading. Any remaining days will be added as free trial time."]}),l.jsx(ce,{onClick:()=>n("continueGiftSubscription"),isRunning:r,disabled:r,isPrimary:!0,brandColor:i,label:"Continue subscription",style:{width:"100%"}})]})})},Iz=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("defs",null,w.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),w.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),w.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),zz=()=>{const{member:e,site:t,doAction:n}=w.useContext(F),a=()=>{const m=ot({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:h,subscription:b})=>{const{next_payment:v}=b||{};let f="";if(m){const{amount:C=0,currency:z,interval:T}=m;f=`${Intl.NumberFormat("en",{currency:z,style:"currency"}).format(C/100)}/${g(T)}`}const y=ll({member:e});if(sl({member:e})&&y)return l.jsxs("p",{className:"gh-portal-account-discountcontainer",children:[l.jsx(zl,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:`${g("Gift subscription")} - ${g("Expires {expiryDate}",{expiryDate:y})}`})]});h&&(y?f=`${g("Complimentary")} - ${g("Expires {expiryDate}",{expiryDate:y})}`:f=g("Complimentary"));let k="";if(am({sub:b}))return k="gh-portal-account-old-price",l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:f}),l.jsx(Nz,{subscription:b})]});let x=Az({nextPayment:v});x&&(k="gh-portal-account-old-price");const $=()=>x?l.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[l.jsx(Iz,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:x})]}):null;return l.jsxs(l.Fragment,{children:[l.jsx("p",{className:k,children:f}),l.jsx($,{})]})},r=({isPaid:m})=>{const h=sl({member:e}),b=h&&!$k({member:e,site:t});return ri({site:t})&&(!m||h&&!b)?null:b?l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>n("continueGiftSubscription"),"data-test-button":"continue-gift-subscription",children:g("Continue")}):l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:v=>i(),"data-test-button":"change-plan",children:g("Change")})},s=({defaultCardLast4:m})=>{if(m){const h=`**** **** **** ${m}`;return l.jsx("p",{children:h})}return null},c=({defaultCardLast4:m,isComplimentary:h})=>{const{action:b}=w.useContext(F),v=b==="manageBilling:running"?l.jsx(ci,{className:"gh-portal-billing-button-loader"}):g("Update");return h?null:l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:g("Billing info & receipts")}),l.jsx(s,{defaultCardLast4:m})]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:f=>a(),"data-test-button":"manage-billing",children:v})]})},u=ot({member:e}),d=An({member:e}),p=Ut({member:e});if(u||d){const{price:m,default_payment_card_last4:h}=u||{};let b=g("Plan");return ml({site:t})&&tm({member:e})&&(b=tm({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:g("Canceled")})]}),l.jsx(o,{price:m,isComplimentary:d,subscription:u})]}),l.jsx(r,{isPaid:p})]}),l.jsx(c,{isComplimentary:d,defaultCardLast4:h})]})}return null};function Nz({subscription:e}){if(am({sub:e})){const t=Nn(e.trial_end_at);return l.jsx("p",{className:"gh-portal-account-discountcontainer",children:l.jsx("div",{children:l.jsx("span",{children:g("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function Az({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";const n=t.end?g("Ends {offerEndDate}",{offerEndDate:Nn(t.end)}):g("Forever");return`${`${Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100)}/${g(e.interval)}`}${n?` — ${n}`:""}`}function Mz(){const{member:e,site:t,doAction:n}=w.useContext(F);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let o=g(i?"Subscribed":"Unsubscribed");const r=s=>{var d;s.preventDefault();const c=ra({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:g("Email newsletter")}),l.jsxs("p",{children:[o," ",im({member:e})&&i&&l.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:g("Not receiving emails?")})]})]}),l.jsx("div",{children:l.jsx($l,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{r(s)},checked:i})})]})}const Mv=e=>w.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},w.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),w.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function Dz(){return l.jsxs("p",{className:"gh-portal-email-notice",children:[l.jsx(Mv,{className:"gh-portal-email-notice-icon"}),l.jsx("span",{className:"gh-mobile-only",children:g("You're not receiving emails")}),l.jsx("span",{className:"gh-desktop-only",children:g("You're currently not receiving emails")})]})}function Oz(){const{doAction:e,member:t,site:n}=w.useContext(F),a=Pk({member:t}),i=Lo({site:n}),o=pl({site:n}),r=a?"emailSuppressed":"accountEmail",s=!i&&!o,c=()=>a||s?l.jsx(Dz,{}):l.jsx("p",{children:g("Update your preferences")});return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:g("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:g("Manage")})]})}const Fz=()=>{const{member:e,site:t}=w.useContext(F),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=Mk(),[s,c]=w.useState(r&&i);return w.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}}},Rz=(e,t)=>Ho({site:e})&&Lo({site:e})||pl({site:e})||Pk({member:t}),_z=e=>!Ho({site:e})&&Lo({site:e})&&!pl({site:e}),Yz=()=>{const{member:e,doAction:t,site:n}=w.useContext(F),{name:a,email:i}=e,{transistor:o}=Fz(),r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=Rz(n,e),c=_z(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||g("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:g("Edit")})]}),l.jsx(zz,{}),s&&l.jsx(Oz,{}),c&&l.jsx(Mz,{}),o.enabled&&l.jsx(kz,{hasPodcasts:o.hasPodcasts,memberUuid:o.memberUuid,settings:o.settings})]})})},Lz=()=>l.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[l.jsx(he,{}),l.jsx(Cz,{}),l.jsxs("section",{className:"gh-portal-account-data",children:[l.jsx(jz,{}),l.jsx(Pz,{}),l.jsx(Tz,{}),l.jsx(Yz,{})]})]}),ap=class ap extends X.Component{componentDidMount(){const{member:t,site:n}=this.context;Mn({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=Vo({site:n});return!t||!Mn({site:n})?null:l.jsxs("div",{className:"gh-portal-account-wrapper",children:[l.jsx(Lz,{}),l.jsx(Ez,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ap.contextType=F;let _m=ap;const ip=class ip extends X.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:Zo({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=g("Save");this.context.action==="updateProfile:failed"&&(n=g("Retry"));const a=!!t;return l.jsx(ce,{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:g("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(ui,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),l.jsx("h3",{className:"gh-portal-main-title",children:g("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(Qd,{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:g("Jamie Larson"),label:g("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:g("jamie@example.com"),label:g("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(Jo,{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(he,{}),this.renderHeader(),l.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};ip.contextType=F;let Ym=ip;function Bz(){const{brandColor:e,lastPage:t,doAction:n}=w.useContext(F);return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(ui,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx("h3",{className:"gh-portal-main-title",children:g("Email preferences")})]})}function Uz({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($l,{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 Hz({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=w.useContext(F),i=!!n;if(!t)return null;const o=async(r,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:g("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:g("Comments")}),l.jsx("p",{children:g("Get notified when someone replies to your comment")})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx($l,{id:"comments",onToggle:o,checked:i,dataTestId:"switch-input"})})]})}function Vz({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=w.useContext(F),i=ra({site:a});return n?i.map(o=>l.jsx(Uz,{newsletter:o,subscribedNewsletters:e,setSubscribedNewsletters:t},o==null?void 0:o.id)):null}function Wz({site:e,isPaid:t}){return t?l.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:g("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Dv({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}=w.useContext(F),h=!(n!=null&&n.length)&&(s&&!c||!s),v=t||(()=>null);return l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(he,{}),l.jsx(Bz,{}),l.jsx(v,{}),l.jsx("div",{className:"gh-portal-section flex",children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsx(Vz,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:f=>{let y=f.map(k=>({id:k.id}));a(y)}}),l.jsx(Hz,{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(ce,{isRunning:!1,onClick:()=>{o()},disabled:h,brandColor:u,isPrimary:!1,label:g("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),l.jsxs("footer",{className:"gh-portal-action-footer"+(im({member:p})?" gh-feature-suppressions":""),children:[l.jsx("div",{style:{width:"100%"},children:l.jsx(Wz,{isPaid:r,site:m,subscribedNewsletters:n})}),im({member:p})&&!h&&l.jsxs("div",{className:"gh-portal-footer-secondary",children:[l.jsx("span",{className:"gh-portal-footer-secondary-light",children:g("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:[g("Get help")," ",l.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function Gz(){const{member:e,doAction:t,site:n,pageData:a}=w.useContext(F);let i,o;a&&(i=a.newsletterUuid,o=a.action);const[r,s]=w.useState(!0),c=ra({site:n}),u=Lo({site:n});w.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),w.useEffect(()=>{if(i&&o==="unsubscribe"){const f=e==null?void 0:e.newsletters.filter(y=>y.uuid!==i);h(f),s(!1),t("updateNewsletterPreference",{newsletters:f})}},[]);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(ze,{string:g("{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 f=c==null?void 0:c.find(k=>k.uuid===a.newsletterUuid);if(!f)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(ze,{string:g("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:l.jsx("strong",{children:f==null?void 0:f.name})}})})})},p=[...(e==null?void 0:e.newsletters)||[]],[m,h]=w.useState(p),{comments_enabled:b}=n,{enable_comment_notifications:v}=e||{};return w.useEffect(()=>{h((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),l.jsx(Dv,{hasNewslettersEnabled:u,notification:i?d:null,subscribedNewsletters:m,updateSubscribedNewsletters:f=>{h(f),t("updateNewsletterPreference",{newsletters:f}),t("showPopupNotification",{action:"updated:success",message:g("Email preferences updated.")})},updateCommentNotifications:async f=>{t("updateNewsletterPreference",{enableCommentNotifications:f})},unsubscribeAll:()=>{h([]),t("showPopupNotification",{action:"updated:success",message:g("Unsubscribed from all emails.")});const f={newsletters:[]};b&&(f.enableCommentNotifications=!1),t("updateNewsletterPreference",f)},isPaidMember:Ut({member:e}),isCommentsEnabled:b!=="off",enableCommentNotifications:v})}function Kz(){const{site:e}=w.useContext(F),t=e.icon;return t?l.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function qz(){const{site:e}=w.useContext(F),t=e.title||"";return l.jsxs("header",{className:"gh-portal-header",children:[l.jsx(Kz,{}),l.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Ov({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 Jz(){const{site:e,api:t,pageData:n,member:a,doAction:i}=w.useContext(F),[o,r]=w.useState(),[s,c]=w.useState(!0),u=ra({site:e}),d=u.filter(T=>T.subscribe_on_signup),[p,m]=w.useState(!1),[h,b]=w.useState(d),[v,f]=w.useState(!1),{comments_enabled:y}=e,{enable_comment_notifications:k=!1}=o||{},E=Lo({site:e}),x=async T=>{a?i("updateNewsletterPreference",{newsletters:T}):await Ov({api:t,memberUuid:n.uuid,key:n.key,newsletters:T}),b(T);const A={action:"updated:success",message:g("Email preferences updated.")};i("showPopupNotification",A)},$=async T=>{let A;a?(await i("updateNewsletterPreference",{enableCommentNotifications:T}),A={...a,enable_comment_notifications:T}):A=await Ov({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:T}),r(A),i("showPopupNotification",{action:"updated:success",message:g("Comment preferences updated.")})},C=async()=>{let T;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),T={...a},T.newsletters=[],T.enable_comment_notifications=!1):T=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),b([]),r(T),i("showPopupNotification",{action:"updated:success",message:g("Unsubscribed from all emails.")})};if(w.useEffect(()=>{(async()=>{let T;try{T=await t.member.newsletters({uuid:n.uuid,key:n.key}),r(T??null),c(!1)}catch(L){console.error("[PORTAL] Error fetching member newsletters",L),r(null),c(!1);return}if(T===null)return;const A=(T==null?void 0:T.newsletters)||[];b(A),(u==null?void 0:u.length)===1&&!y&&!n.newsletterUuid?await x([]):n.newsletterUuid?await x(A==null?void 0:A.filter(L=>L.uuid!==n.newsletterUuid)):n.comments&&y&&await $(!1)})()},[y,n.uuid,n.newsletterUuid,n.comments,e.url,u==null?void 0:u.length]),s)return l.jsx(gi,{});if(!o)return l.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[l.jsx(he,{}),l.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:l.jsx(bm,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:g("That didn't go to plan")}),l.jsx("div",{children:l.jsx("p",{className:"gh-portal-text-center",children:g("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),l.jsx(ce,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:g("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((u==null?void 0:u.length)===1&&!y&&!v)return l.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[l.jsx(he,{}),l.jsx(qz,{}),l.jsx("h1",{className:"gh-portal-main-title",children:g("Successfully unsubscribed")}),l.jsxs("div",{children:[l.jsx("p",{className:"gh-portal-text-center",children:l.jsx(ze,{string:g("{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(ze,{string:g("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:()=>{f(!0)}})}})})]})]});const z=()=>{if(n.comments&&y){const L=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${L}`,children:l.jsx(ze,{string:g("{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 T=u==null?void 0:u.find(L=>L.uuid===n.newsletterUuid);if(!T)return null;const A=p?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${A}`,children:l.jsx(ze,{string:g("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:o==null?void 0:o.email}),newsletterName:l.jsx("strong",{children:T==null?void 0:T.name})}})})})};return l.jsx(Dv,{hasNewslettersEnabled:E,notification:z,subscribedNewsletters:h,updateSubscribedNewsletters:async T=>{await x(T),m(!0)},updateCommentNotifications:$,unsubscribeAll:async()=>{await C(),m(!0)},isPaidMember:(o==null?void 0:o.status)!=="free",isCommentsEnabled:y!=="off",enableCommentNotifications:k})}function Zz(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=w.useContext(F);w.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(Ho({site:i})||pl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:g("You have been successfully resubscribed")})):n("back"))},[a,n,i,g]);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(ui,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),l.jsx(he,{})]}),l.jsx(Mv,{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:g("Emails disabled")}),l.jsx("p",{children:g("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(ce,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:r,disabled:o,brandColor:e,label:g("Re-enable emails"),isRunning:o})]})}function Xz(){const{brandColor:e,doAction:t,site:n,pageData:a}=w.useContext(F),i=`mailto:${Vo({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(ui,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),l.jsx(he,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:g("Why has my email been disabled?")}),l.jsx("p",{children:g("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:g("Spam complaints")}),l.jsx("p",{children:g("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:g("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:g("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:g("Permanent failure (bounce)")}),l.jsx("p",{children:g("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:g("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:g("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:g("Need more help? Contact support")})})]})]})}function Qz(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:o}=w.useContext(F),r=Vo({site:n}),s=`mailto:${r}`,c=jP({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(ui,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),l.jsx(he,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:g("Help! I'm not receiving emails")}),l.jsx("p",{children:g("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),l.jsx("h4",{children:g("Verify your email address is correct")}),l.jsx("p",{children:l.jsx(ze,{string:g("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:g("Check spam & promotions folders")}),l.jsx("p",{children:g(`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:g("Create a new contact")}),l.jsx("p",{children:l.jsx(ze,{string:g("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:g("Send an email and say hi!")}),l.jsx("p",{children:l.jsx(ze,{string:g("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:g("Check with your mail provider")}),l.jsx("p",{children:l.jsx(ze,{string:g("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:g("Get in touch for help")}),l.jsx("p",{children:l.jsx(ze,{string:g("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 eN=()=>{const[e,t]=w.useState(!0),[n,a]=w.useState(null),[i,o]=w.useState(null),{member:r,site:s}=w.useContext(F);return w.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,h=Il({siteUrl:u});try{const b=await h.member.checkoutDonation({successUrl:p,cancelUrl:m,personalNote:g("Add a personal note")});b.url&&window.location.replace(b.url)}catch(b){b.type&&b.type==="DisabledFeatureError"?o(g("This site is not accepting payments at the moment.")):a(g("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(o(g("This site is not accepting donations at the moment.")),t(!1)):c()},[]),e?l.jsx("div",{children:l.jsx(gi,{})}):n?l.jsx(Fm,{error:n}):i?l.jsx(Fm,{error:i}):null},tN=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},ir=(e,t)=>{const n=new URLSearchParams(t);return`${e}?${n.toString()}`},nN=({shareTitle:e,shareUrl:t})=>{const n=[e,t].filter(Boolean).join(`
4257
4250
 
4258
- `),a=[];return e&&a.push(`subject=${encodeURIComponent(e)}`),n&&a.push(`body=${encodeURIComponent(n)}`),`mailto:${a.length?`?${a.join("&")}`:""}`},aN=({shareTitle:e,shareUrl:t})=>ir("https://www.linkedin.com/shareArticle",{mini:"true",url:t,title:e}),iN=()=>{const e=tN(),t=e.document,n=e.location,a=(b,v="content")=>{var f;return((f=t.querySelector(b))==null?void 0:f[v])||""},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(),h={twitter:ir("https://twitter.com/intent/tweet",{url:i,text:o}),facebook:ir("https://www.facebook.com/sharer/sharer.php",{u:i}),email:nN({shareTitle:o,shareUrl:i}),threads:ir("https://www.threads.net/intent/post",{text:m}),linkedin:aN({shareTitle:o,shareUrl:i}),bluesky:ir("https://bsky.app/intent/compose",{text:m})};return{shareUrl:i,shareTitle:o,shareExcerpt:r,shareImage:s,shareFavicon:c,shareSiteName:p,shareAuthor:d,socialLinks:h}},oN=()=>{const[e]=w.useState(iN);return e},rN=e=>w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...e},w.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"})),sN=e=>w.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},w.createElement("circle",{cx:12,cy:12,r:1}),w.createElement("circle",{cx:19,cy:12,r:1}),w.createElement("circle",{cx:5,cy:12,r:1})),lN=e=>w.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},w.createElement("defs",{id:"defs13"},w.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},w.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),w.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},w.createElement("g",{id:"g19"},w.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},w.createElement("g",{id:"g27",transform:"translate(600,350)"},w.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"})),w.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},w.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"})))))),cN=e=>w.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},w.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"}),w.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"})),uN=e=>w.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...e},w.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),w.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"}),w.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"})),dN=e=>w.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("g",{clipPath:"url(#clip0_351_18008)"},w.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"})),w.createElement("defs",null,w.createElement("clipPath",{id:"clip0_351_18008"},w.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),mN=e=>w.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...e},w.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:Rm,signup:Nm,accountHome:_m,accountPlan:xm,accountProfile:Ym,accountEmail:Gz,signupNewsletter:Em,unsubscribe:Jz,magiclink:Mm,loading:gi,offer:Om,feedback:HI,emailSuppressed:Zz,emailSuppressionFAQ:Xz,emailReceivingFAQ:Qz,support:eN,supportSuccess:JI,supportError:Fm,recommendations:gz,gift:iz,giftRedemption:XI,giftSuccess:lz,share:()=>{const[e,t]=w.useState(!1),[n,a]=w.useState(!1),i=w.useRef(),o=w.useRef(null),{shareUrl:r,shareTitle:s,shareExcerpt:c,shareImage:u,shareFavicon:d,shareSiteName:p,shareAuthor:m,socialLinks:h}=oN();w.useEffect(()=>()=>{clearTimeout(i.current)},[]),w.useEffect(()=>{var x;if(!n)return;const y=((x=o.current)==null?void 0:x.ownerDocument)||document,k=$=>{o.current&&!o.current.contains($.target)&&($.stopPropagation(),$.preventDefault(),a(!1))},E=$=>{$.key==="Escape"&&a(!1)};return y.addEventListener("click",k,!0),y.addEventListener("keydown",E),()=>{y.removeEventListener("click",k,!0),y.removeEventListener("keydown",E)}},[n]);const b=async()=>{await Iv(r)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},v=()=>{a(y=>!y)},f=()=>{a(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(he,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:g("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}),p&&m&&l.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),m&&l.jsx("span",{className:"gh-portal-share-preview-author",children: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":g(e?"Copied":"Copy link"),title:g(e?"Copied":"Copy link"),children:[e?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Ko,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(cN,{})}),l.jsx("span",{className:"gh-portal-share-label",children:g(e?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:h.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":g("X (Twitter)"),title:g("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(mN,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:h.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":g("LinkedIn"),title:g("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(uN,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:h.email,target:"_blank",rel:"noopener noreferrer","aria-label":g("Email"),title:g("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(Am,{})})}),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:v,"aria-label":g("More options"),title:g("More options"),"aria-haspopup":"menu","aria-expanded":n,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(sN,{})})}),n&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":g("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:h.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(lN,{})}),l.jsx("span",{children:g("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:h.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(dN,{})}),l.jsx("span",{children:g("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:h.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(rN,{})}),l.jsx("span",{children:g("Bluesky")})]})]})]})]})]})}},Bm=function({page:e}){return Object.keys(Lm).includes(e)?e:"signup"},Fv=function({page:e}){return e.includes("account")},pN=function({page:e}){return e.includes("offer")},hN=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),op=class op extends X.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(hN,{}),"Powered by Ghost"]})}};op.contextType=F;let Nl=op;const Rv=()=>({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 fN({message:e}){return aa()?l.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const rp=class rp extends X.Component{componentDidMount(){this.node&&!pe(["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&&pe(["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;pe(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Bm({page:t});const n=Lm[t];return l.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:l.jsx(Dm,{})}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=fl({site:a,pageQuery:n}).length;Bm({page:t});const c={...Rv().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&&!Ht({site:a})&&rn({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",d="full"),t==="gift"&&(m+=" full-size",d="full");const h=Uo({site:a});(h&&r>2||!h&&r>1)&&t==="accountPlan"&&(m+=" full-size",d="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let b="gh-portal-popup-container";pe(["preview"])&&(m+=" preview"),pe(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),pe(["dev"])&&(b+=" dev");const v=`${b} ${u} ${m}`;return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:f=>this.handlePopupClose(f),children:[this.renderPopupNotification(),l.jsxs("div",{className:v,style:c,ref:f=>this.node=f,tabIndex:-1,children:[l.jsx(fN,{message:p}),this.renderActivePage(),d==="full"?l.jsx("div",{className:"gh-portal-powered inside "+(pe(["preview"])?"hidden ":"")+m,children:l.jsx(Nl,{})}):""]})]}),t!=="share"&&l.jsx("div",{className:"gh-portal-powered outside "+(pe(["preview"])?"hidden ":"")+m,children:l.jsx(Nl,{})})]})}};rp.contextType=F;let Um=rp;const sp=class sp extends X.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=xz({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=Rv(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return pe(["preview"])&&(i.modalContainer.zIndex="3999997"),pe(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),pe(["dev"])&&(s+=" dev"),l.jsx("div",{style:i.modalContainer,children:l.jsxs(Zd,{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}};sp.contextType=F;let Hm=sp;Al({products:Vm({numOfProducts:1})});function He(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function gN(){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 Al({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=Vm({numOfProducts:1}),portalProducts:s=r.map(L=>L.id),accentColor:c="#45C32E",portalPlans:u=["free","monthly","yearly"],membersSignupAccess:d="all",freePriceName:p="Free",freePriceDescription:m="Free preview",isStripeConfigured:h=!0,portalButton:b=!0,portalName:v=!0,portalButtonIcon:f="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:E="support@example.com",editorDefaultEmailRecipients:x="visibility",newsletters:$=[],posts:C=yN(),commentsEnabled:z,recommendations:T=[],recommendationsEnabled:A}={}){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:h,portal_button:b,portal_name:v,portal_plans:u,portal_button_icon:f,portal_button_signup_text:y,portal_button_style:k,members_support_address:E,comments_enabled:z!=="off",newsletters:$,recommendations:T,recommendations_enabled:!!A,editor_default_email_recipients:x,posts:C}}function _v({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:h="Basic",redemptionType:b="signup"}={}){return{id:`offer_${He()}`,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:h},redemption_type:b}}function It({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,status:o,avatarImage:r="",subscribed:s=!0,email_suppression:c={suppressed:!1,info:null},newsletters:u=[]}={}){const d={uuid:gN(),email:t,name:e,firstname:n,paid:i,subscribed:s,avatar_image:r,subscriptions:a,email_suppression:c,newsletters:u};return o!==void 0?d.status=o:i?d.status="paid":d.status="free",d}function yN({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(bN({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function bN({id:e=`post_${He()}`,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 Vm({numOfProducts:e=3}={}){const n=[yi({name:"Bronze",description:"Access to all members articles",monthlyPrice:St({interval:"month",amount:700}),yearlyPrice:St({interval:"year",amount:7e3}),numOfBenefits:2}),yi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:St({interval:"month",amount:1200}),yearlyPrice:St({interval:"year",amount:12e3}),numOfBenefits:3}),yi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:St({interval:"month",amount:18e3}),yearlyPrice:St({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Yv({});return[...n,a]}function yi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${He()}`,monthlyPrice:i=St(),yearlyPrice:o=St({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:Lv({numOfBenefits:r}),trial_days:s}}function Yv({name:e="Free tier",description:t="Free tier description",id:n=`product_${He()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Lv({numOfBenefits:a})}}function Lv({numOfBenefits:e}){const t=He();return[Ml({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Ml({name:`Latest gear reviews #${t.substring(6,12)}`}),Ml({name:`Weekly email newsletter #${t.substring(12,18)}`}),Ml({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Ml({id:e=`benefit_${He()}`,name:t="Benefit"}){return{id:e,name:t}}function St({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_${He()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${He()}`,stripe_product_id:`prod_${He()}`,type:"recurring"}}function ca({id:e=`sub_${He()}`,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=vN,priceId:c=`price_${He()}`,startDate:u="2021-10-05T03:18:30.000Z",currentPeriodEnd:d="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:m=null,nextPayment:h=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${He()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${He()}`,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:h,tier:b,price:{id:`stripe_price_${He()}`,price_id:c,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${He()}`,product_id:`prod_${He()}`}}}}function Bv(){const e=Vm({numOfProducts:1}),t=e.map(a=>a.id);return Al({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Bv();const kN=Al({products:[yi({numOfBenefits:2,type:"free"})]}),vN=_v({tierId:(Kv=kN.products[0])==null?void 0:Kv.id});It({status:"free"}),It({status:"paid",paid:!0,subscriptions:[ca()]}),It({status:"comped",paid:!0,subscriptions:[]}),It({status:"comped",paid:!0,subscriptions:[ca({amount:0})]}),It({status:"paid",paid:!0,subscriptions:[ca({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Bv();const Dl=[Yv({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),yi({name:"The Blueprint",description:"",monthlyPrice:St({interval:"month",amount:500}),yearlyPrice:St({interval:"year",amount:5e3}),numOfBenefits:3}),yi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:St({interval:"month",amount:1200}),yearlyPrice:St({interval:"year",amount:11e3}),numOfBenefits:4})],bi=Al({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:Dl,portalProducts:Dl.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}]}),Uv=_v({tierId:(qv=bi.products[1])==null?void 0:qv.id}),ki={free:It({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:It({paid:!0,status:"paid",subscriptions:[ca({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:It({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:It({paid:!0,status:"comped",subscriptions:[ca({amount:0})]}),preview:It({paid:!0,status:"paid",subscriptions:[ca({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function wN(){var n;if(!Dl||!Dl[1])return null;let e=(n=bi==null?void 0:bi.products)==null?void 0:n[1].monthlyPrice,t=It({paid:!0,status:"paid",subscriptions:[ca({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:bi,member:t}}function SN(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 xN({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function EN({state:e}){return{showPopup:!e.showPopup}}function CN({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function $N({state:e}){return e.lastPage?{page:e.lastPage}:Hv({state:e})}function Hv({state:e}){return on(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function jN({data:e,state:t}){const{action:n="openNotification",status:a="success",autoHide:i=!0,closeable:o=!0,duration:r=2600,message:s=""}=e||{},c=sm({type:n,status:a,autoHide:i,closeable:o,duration:r,state:t,message:s});return{notification:c,notificationSequence:c.count}}function TN(){return{notification:null}}async function PN({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:g("Failed to log out, please try again")})}}}async function IN({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:Bt(a,g("Failed to log in, please try again"))})}}}function zN({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 NN({data:e,api:t}){var a;const n=g("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:Bt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Bt(i,n)}}}async function AN({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}=sa({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=Bt(a,g("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 MN({data:e,state:t,api:n}){var a;try{let{email:i,name:o,giftToken:r}=e;if(o=o==null?void 0:o.trim(),t.member){await n.gift.redeem({token:r});const p=await n.member.sessionData(),m=sm({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:t,message:Qk({member:p})});return on(),{action:"redeemGift:success",member:p,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:m,notificationSequence:m.count}}const s=await n.member.getIntegrityToken(),c=new URL(((a=t==null?void 0:t.site)==null?void 0:a.url)||window.location.href);c.search=new URLSearchParams({giftRedemption:"true"}).toString(),c.hash="";const{otc_ref:u,inboxLinks:d}=await n.member.sendMagicLink({email:(i||"").trim(),emailType:"subscribe",integrityToken:s,includeOTC:!0,redirect:c.href,giftToken:r,...o?{name:o}:{}});return{page:"magiclink",lastPage:"giftRedemption",...u?{otcRef:u}:{},inboxLinks:d,pageData:{...t.pageData||{},email:(i||"").trim(),redirect:c.href}}}catch(i){return{action:"redeemGift:failed",popupNotification:re({type:"redeemGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:Bt(i,"Failed to redeem gift, please try again")})}}}async function DN({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=sa({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:g("Failed to process checkout, please try again")})}}}async function ON({state:e,api:t}){try{await t.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:re({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:g("Failed to process checkout, please try again")})}}}async function FN({data:e,state:t,api:n}){try{const{tierId:a,cadence:i}=e;return await n.member.checkoutGift({tierId:a,cadence:i}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:re({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:g("Failed to process checkout, please try again")})}}}async function RN({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:c}=sa({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:g("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:g("Failed to update subscription, please try again")})}}}async function _N({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:g("Failed to cancel subscription, please try again")})}}}async function YN({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:g("Failed to cancel subscription, please try again")})}}}async function LN({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 BN({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:g("Failed to update billing information, please try again")})}}}async function UN({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:g("Failed to open billing portal, please try again")})}}}async function HN(){return{popupNotification:null}}async function VN({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 WN({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:g("Failed to update newsletter settings")})}}}async function GN({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:g("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:re({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:g("Your email has failed to resubscribe, please try again")})}}}async function KN({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:g("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:g("Failed to update newsletter settings")})}}}async function qN({data:e,state:t,api:n}){const{email:a}=e,i=EP({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 JN({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if($P({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function ZN({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 XN({data:e,state:t,api:n}){const[a,i]=await Promise.all([JN({data:e,state:t,api:n}),qN({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:g("Check your inbox to verify email update")})};const o=a.success?g("Failed to send verification email"):g("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?g("Account details updated successfully"):g("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=Bt(i.error,g("Failed to send verification email")):s=g("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:g("Account details updated successfully")})}}async function QN({data:{siteUrl:e},state:t}){const n=Il({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=jk(),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 eA({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 tA({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const nA={togglePopup:EN,openPopup:CN,closePopup:Hv,switchPage:xN,openNotification:jN,closeNotification:TN,back:$N,signout:PN,signin:IN,startSigninOTCFromCustomForm:zN,verifyOTC:NN,signup:AN,redeemGift:MN,updateSubscription:RN,cancelSubscription:_N,continueSubscription:YN,applyOffer:LN,updateNewsletter:KN,updateProfile:XN,refreshMemberData:ZN,clearPopupNotification:HN,editBilling:BN,manageBilling:UN,checkoutPlan:DN,continueGiftSubscription:ON,checkoutGift:FN,updateNewsletterPreference:WN,showPopupNotification:VN,removeEmailFromSuppressionList:GN,oneClickSubscribe:QN,trackRecommendationClicked:eA,trackRecommendationSubscribed:tA};async function aA({action:e,data:t,state:n,api:a}){const i=nA[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Vv(e,t){e&&(e.innerText=t)}function iA(e,t,n){t.classList.add("error");const a=g("There was an error sending the email, please try again");Vv(n,Bt(e,a))}async function oA({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var x,$;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,h=[],b=[],v=e.target.querySelectorAll("input[data-members-label]")||[];for(let C=0;C<v.length;++C)h.push(v[C].value);let f=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let C=0;C<f.length;++C)b.push({name:f[C].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const y=m==="signin"&&(($=t==null?void 0:t.dataset)==null?void 0:$.membersOtc)==="true";t.classList.add("loading");const k=si(),E={email:d,emailType:m,labels:h,name:p,autoRedirect:u==="true"};y&&(E.includeOTC=!0),k&&(E.urlHistory=k),f.length>0?E.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(E.newsletters=[]);try{const z=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),T=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E,integrityToken:z})});if(t.addEventListener("submit",i),t.classList.remove("loading"),T.ok){t.classList.add("success");let A;if(y)try{A=await T.clone().json()}catch{A=void 0}const L=A==null?void 0:A.otc_ref;if(L&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(d||"").trim(),otcRef:L,inboxLinks:A==null?void 0:A.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const A=await Pt.fromApiResponse(T),L=Bt(A,g("Failed to send magic link email"));Vv(n,L),t.classList.add("error")}}catch(C){iA(C,t,n)}}function rA({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=pP(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 h=o?{checkoutType:"upgrade"}:{},b=si();return b&&(h.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,identity:v,successUrl:p,cancelUrl:m,metadata:h})}).then(function(f){if(!f.ok)throw new Error(g("Could not create Stripe checkout session"));return f.json()})}).then(function(v){return v.url?window.location.assign(v.url):window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(v){console.error(v),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=v.message),t.classList.add("error")})}function sA({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){oA({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){rA({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 h(b){s.removeEventListener("click",h),b.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:v,successUrl:p,cancelUrl:m})}).then(function(f){if(!f.ok)throw new Error(g("Could not create Stripe checkout session"));return f.json()})}).then(function(v){return window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId})}).then(function(v){if(v.error)throw new Error(g(v.error.message))}).catch(function(v){console.error(v),s.addEventListener("click",h),s.classList.remove("loading"),c&&(c.innerText=v.message),s.classList.add("error")})}s.addEventListener("click",h)}),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(h){return h.ok?h.text():null}).then(function(h){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:h,returnUrl:d})}).then(function(b){if(!b.ok)throw new Error(g("Could not create Stripe billing portal session"));return b.json()})}).then(function(h){return window.location.assign(h.url)}).catch(function(h){console.error(h),s.addEventListener("click",p),s.classList.remove("loading"),c&&(c.innerText=h.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=g("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=g("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",u)})}const Wv=e=>{try{return decodeURIComponent(e)}catch{return null}},lA={staleGiftRedemptionRequest:!0},cA={showPopup:!0,site:bi,member:ki.free,page:"accountEmail",...wN(),pageData:Uv};function uA({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?l.jsx(jd,{children:t}):l.jsx(l.Fragment,{children:t})}class dA extends X.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(),sA({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Ps})}}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"&&!ul({site:this.state.site})){this.invalidateGiftRedemptionRequest(),on();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";ol.changeLanguage(m);const h={site:t,member:n,offers:a,page:i,lastPage:u,pageQuery:d,showPopup:o,pageData:p,popupNotification:r,notification:s,notificationSequence:c,dir:ol.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:d,member:n}),this.setState(h),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const b=document.querySelectorAll("[data-lexical-signup-form]");b.length>0&&b.forEach(v=>{v.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 pe(["dev"])&&!this.state.customSiteUrl?cA:pe(["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||Uv.tier.id}:c==="redemption_type"&&(a.redemption_type=u||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=ki.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 h=m.toUpperCase();a.site.plans.currency=h,a.site.plans.currency_symbol=we(h),u=h}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}=Xk({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(!ul({site:t}))return on(),{};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){on();const o=sm({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:ev(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(Cl(["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(gP({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\/?$/,h=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&h.test(i)){const[,b,v]=i.match(h),f=parseInt(v);if(f===1||f===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:f}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${b}/${f}/`}}}if(i&&d.test(i)){const[,b]=i.match(d),v=Wv(b);if(!v)return{};const f=this.startGiftRedemptionRequest(v),y=await this.fetchGiftRedemptionData({site:t,token:v});return this.isCurrentGiftRedemptionRequest(f)?y:lA}if(i&&m.test(i))return{showPopup:!0,page:"share"};if(i&&p.test(i)){const[,b]=i.match(p),{page:v,pageQuery:f,pageData:y}=this.getPageFromLinkPath(b,t)||{};if(!n&&v&&Fv({page:v}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${b}/`}};if(v==="gift"&&!ul({site:t}))return on(),{};const k=["accountPlan","accountProfile"].includes(v)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(f)||s.test(f)||c.test(f)||u.test(f)),...v?{page:v}:{},...f?{pageQuery:f}:{},...y?{pageData:y}:{},...k?{lastPage:k}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(pe(["preview"])){let n={};return pe(["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||Il({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(pe(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(pe(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.68.20|ghost@${i}`;n&&n.dsn&&y0({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>rP({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(pe(["test"]))return null;const a=CP({site:t});let i=om({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),OP({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 aA({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:Bt(a,g("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(on(),!Ut({member:a})||An({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||cm({offer:r})||!IP({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=Dn({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}=sa({site:t,priceId:c.id});this.dispatchAction("checkoutPlan",{plan:c.id,offerId:n,tierId:u,cadence:d})}else{const{tierId:u,cadence:d}=sa({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}Nk({site:t,pageQuery:n})&&(o=Nk({site:t,pageQuery:n}));const r=hP({site:t,priceId:o});if(n&&n!=="free"){on();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:c,cadence:u}=sa({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=Wv(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 kI(t)}getRetentionPreviewMember({site:t,offers:n}){var u,d,p;const a=(n||[]).find(m=>cm({offer:m})),i=(u=a==null?void 0:a.tier)==null?void 0:u.id,o=i?Dn({site:t,productId:i}):null,r=o?a.cadence==="year"?o.yearlyPrice:o.monthlyPrice:null,s=ki.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=Ht({site:t})||!rn({site:t})?"signin":"signup";n=a?"accountHome":i}return Bm({page:n})}getContextMember({site:t,page:n,member:a,offers:i,pageData:o,customSiteUrl:r}){return pe(["dev","preview"],{customSiteUrl:r})?Fv({page:n})||pN({page:n})?pe(["dev"],{customSiteUrl:r})?a||ki.free:pe(["preview"])?n==="accountPlan"&&(o==null?void 0:o.action)==="cancel"?this.getRetentionPreviewMember({site:t,offers:i}):ki.preview:ki.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:h,dir:b,scrollbarWidth:v,otcRef:f,inboxLinks:y}=this.state,k=this.getContextPage({site:t,page:r,member:n}),E=this.getContextMember({site:t,page:k,member:n,offers:a,pageData:d,customSiteUrl:h});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:k,pageQuery:u,pageData:d,member:E,lastPage:s,showPopup:c,popupNotification:p,notification:m,customSiteUrl:h,dir:b,scrollbarWidth:v,otcRef:f,inboxLinks:y,doAction:(x,$)=>this.dispatchAction(x,$)}}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(SN)}render(){return this.state.initStatus==="success"?l.jsx(uA,{site:this.state.site,children:l.jsxs(F.Provider,{value:this.getContextFromState(),children:[l.jsx(Hm,{}),l.jsx(dm,{}),l.jsx(vm,{})]})}):null}}const Gv="ghost-portal-root";function mA(){const e=document.createElement("div");e.id=Gv,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function pA(){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 hA(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function fA(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=pA(),o=e||window.location.origin;mA(),hA(),$x.render(l.jsx(X.StrictMode,{children:l.jsx(dA,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Gv))}fA()});
4251
+ `),a=[];return e&&a.push(`subject=${encodeURIComponent(e)}`),n&&a.push(`body=${encodeURIComponent(n)}`),`mailto:${a.length?`?${a.join("&")}`:""}`},aN=({shareTitle:e,shareUrl:t})=>ir("https://www.linkedin.com/shareArticle",{mini:"true",url:t,title:e}),iN=()=>{const e=tN(),t=e.document,n=e.location,a=(b,v="content")=>{var f;return((f=t.querySelector(b))==null?void 0:f[v])||""},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(),h={twitter:ir("https://twitter.com/intent/tweet",{url:i,text:o}),facebook:ir("https://www.facebook.com/sharer/sharer.php",{u:i}),email:nN({shareTitle:o,shareUrl:i}),threads:ir("https://www.threads.net/intent/post",{text:m}),linkedin:aN({shareTitle:o,shareUrl:i}),bluesky:ir("https://bsky.app/intent/compose",{text:m})};return{shareUrl:i,shareTitle:o,shareExcerpt:r,shareImage:s,shareFavicon:c,shareSiteName:p,shareAuthor:d,socialLinks:h}},oN=()=>{const[e]=w.useState(iN);return e},rN=e=>w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...e},w.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"})),sN=e=>w.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},w.createElement("circle",{cx:12,cy:12,r:1}),w.createElement("circle",{cx:19,cy:12,r:1}),w.createElement("circle",{cx:5,cy:12,r:1})),lN=e=>w.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},w.createElement("defs",{id:"defs13"},w.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},w.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),w.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},w.createElement("g",{id:"g19"},w.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},w.createElement("g",{id:"g27",transform:"translate(600,350)"},w.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"})),w.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},w.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"})))))),cN=e=>w.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},w.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"}),w.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"})),uN=e=>w.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...e},w.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),w.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"}),w.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"})),dN=e=>w.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("g",{clipPath:"url(#clip0_351_18008)"},w.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"})),w.createElement("defs",null,w.createElement("clipPath",{id:"clip0_351_18008"},w.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),mN=e=>w.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...e},w.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:Rm,signup:Nm,accountHome:_m,accountPlan:xm,accountProfile:Ym,accountEmail:Gz,signupNewsletter:Em,unsubscribe:Jz,magiclink:Mm,loading:gi,offer:Om,feedback:HI,emailSuppressed:Zz,emailSuppressionFAQ:Xz,emailReceivingFAQ:Qz,support:eN,supportSuccess:JI,supportError:Fm,recommendations:gz,gift:iz,giftRedemption:XI,giftSuccess:lz,share:()=>{const[e,t]=w.useState(!1),[n,a]=w.useState(!1),i=w.useRef(),o=w.useRef(null),{shareUrl:r,shareTitle:s,shareExcerpt:c,shareImage:u,shareFavicon:d,shareSiteName:p,shareAuthor:m,socialLinks:h}=oN();w.useEffect(()=>()=>{clearTimeout(i.current)},[]),w.useEffect(()=>{var x;if(!n)return;const y=((x=o.current)==null?void 0:x.ownerDocument)||document,k=$=>{o.current&&!o.current.contains($.target)&&($.stopPropagation(),$.preventDefault(),a(!1))},E=$=>{$.key==="Escape"&&a(!1)};return y.addEventListener("click",k,!0),y.addEventListener("keydown",E),()=>{y.removeEventListener("click",k,!0),y.removeEventListener("keydown",E)}},[n]);const b=async()=>{await Iv(r)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},v=()=>{a(y=>!y)},f=()=>{a(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(he,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:g("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}),p&&m&&l.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),m&&l.jsx("span",{className:"gh-portal-share-preview-author",children: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":g(e?"Copied":"Copy link"),title:g(e?"Copied":"Copy link"),children:[e?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Ko,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(cN,{})}),l.jsx("span",{className:"gh-portal-share-label",children:g(e?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:h.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":g("X (Twitter)"),title:g("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(mN,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:h.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":g("LinkedIn"),title:g("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(uN,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:h.email,target:"_blank",rel:"noopener noreferrer","aria-label":g("Email"),title:g("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(Am,{})})}),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:v,"aria-label":g("More options"),title:g("More options"),"aria-haspopup":"menu","aria-expanded":n,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(sN,{})})}),n&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":g("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:h.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(lN,{})}),l.jsx("span",{children:g("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:h.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(dN,{})}),l.jsx("span",{children:g("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:h.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:f,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(rN,{})}),l.jsx("span",{children:g("Bluesky")})]})]})]})]})]})}},Bm=function({page:e}){return Object.keys(Lm).includes(e)?e:"signup"},Fv=function({page:e}){return e.includes("account")},pN=function({page:e}){return e.includes("offer")},hN=e=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},w.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),op=class op extends X.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(hN,{}),"Powered by Ghost"]})}};op.contextType=F;let Nl=op;const Rv=()=>({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 fN({message:e}){return aa()?l.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const rp=class rp extends X.Component{componentDidMount(){this.node&&!pe(["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&&pe(["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;pe(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Bm({page:t});const n=Lm[t];return l.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:l.jsx(Dm,{})}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=fl({site:a,pageQuery:n}).length;Bm({page:t});const c={...Rv().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&&!Ht({site:a})&&rn({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",d="full"),t==="gift"&&(m+=" full-size",d="full");const h=Uo({site:a});(h&&r>2||!h&&r>1)&&t==="accountPlan"&&(m+=" full-size",d="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let b="gh-portal-popup-container";pe(["preview"])&&(m+=" preview"),pe(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(b+=" preview"),pe(["dev"])&&(b+=" dev");const v=`${b} ${u} ${m}`;return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:f=>this.handlePopupClose(f),children:[this.renderPopupNotification(),l.jsxs("div",{className:v,style:c,ref:f=>this.node=f,tabIndex:-1,children:[l.jsx(fN,{message:p}),this.renderActivePage(),d==="full"?l.jsx("div",{className:"gh-portal-powered inside "+(pe(["preview"])?"hidden ":"")+m,children:l.jsx(Nl,{})}):""]})]}),t!=="share"&&l.jsx("div",{className:"gh-portal-powered outside "+(pe(["preview"])?"hidden ":"")+m,children:l.jsx(Nl,{})})]})}};rp.contextType=F;let Um=rp;const sp=class sp extends X.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=xz({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=Rv(),o=window.innerWidth<480,r={...i.frame.common};let s="gh-portal-popup-background";return pe(["preview"])&&(i.modalContainer.zIndex="3999997"),pe(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),pe(["dev"])&&(s+=" dev"),l.jsx("div",{style:i.modalContainer,children:l.jsxs(Zd,{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}};sp.contextType=F;let Hm=sp;Al({products:Vm({numOfProducts:1})});function He(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function gN(){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 Al({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=Vm({numOfProducts:1}),portalProducts:s=r.map(L=>L.id),accentColor:c="#45C32E",portalPlans:u=["free","monthly","yearly"],membersSignupAccess:d="all",freePriceName:p="Free",freePriceDescription:m="Free preview",isStripeConfigured:h=!0,portalButton:b=!0,portalName:v=!0,portalButtonIcon:f="icon-1",portalButtonSignupText:y="Subscribe now",portalButtonStyle:k="icon-and-text",membersSupportAddress:E="support@example.com",editorDefaultEmailRecipients:x="visibility",newsletters:$=[],posts:C=yN(),commentsEnabled:z,recommendations:T=[],recommendationsEnabled:A}={}){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:h,portal_button:b,portal_name:v,portal_plans:u,portal_button_icon:f,portal_button_signup_text:y,portal_button_style:k,members_support_address:E,comments_enabled:z!=="off",newsletters:$,recommendations:T,recommendations_enabled:!!A,editor_default_email_recipients:x,posts:C}}function _v({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:h="Basic",redemptionType:b="signup"}={}){return{id:`offer_${He()}`,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:h},redemption_type:b}}function It({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,status:o,avatarImage:r="",subscribed:s=!0,email_suppression:c={suppressed:!1,info:null},newsletters:u=[]}={}){const d={uuid:gN(),email:t,name:e,firstname:n,paid:i,subscribed:s,avatar_image:r,subscriptions:a,email_suppression:c,newsletters:u};return o!==void 0?d.status=o:i?d.status="paid":d.status="free",d}function yN({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(bN({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function bN({id:e=`post_${He()}`,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 Vm({numOfProducts:e=3}={}){const n=[yi({name:"Bronze",description:"Access to all members articles",monthlyPrice:St({interval:"month",amount:700}),yearlyPrice:St({interval:"year",amount:7e3}),numOfBenefits:2}),yi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:St({interval:"month",amount:1200}),yearlyPrice:St({interval:"year",amount:12e3}),numOfBenefits:3}),yi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:St({interval:"month",amount:18e3}),yearlyPrice:St({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Yv({});return[...n,a]}function yi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${He()}`,monthlyPrice:i=St(),yearlyPrice:o=St({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:Lv({numOfBenefits:r}),trial_days:s}}function Yv({name:e="Free tier",description:t="Free tier description",id:n=`product_${He()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Lv({numOfBenefits:a})}}function Lv({numOfBenefits:e}){const t=He();return[Ml({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Ml({name:`Latest gear reviews #${t.substring(6,12)}`}),Ml({name:`Weekly email newsletter #${t.substring(12,18)}`}),Ml({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Ml({id:e=`benefit_${He()}`,name:t="Benefit"}){return{id:e,name:t}}function St({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_${He()}`}={}){return{id:r,active:o,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${He()}`,stripe_product_id:`prod_${He()}`,type:"recurring"}}function ca({id:e=`sub_${He()}`,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=vN,priceId:c=`price_${He()}`,startDate:u="2021-10-05T03:18:30.000Z",currentPeriodEnd:d="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:p=!1,trialEndAt:m=null,nextPayment:h=null,tier:b=null}={}){return{id:e,customer:{id:`cus_${He()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${He()}`,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:h,tier:b,price:{id:`stripe_price_${He()}`,price_id:c,nickname:o,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${He()}`,product_id:`prod_${He()}`}}}}function Bv(){const e=Vm({numOfProducts:1}),t=e.map(a=>a.id);return Al({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Bv();const kN=Al({products:[yi({numOfBenefits:2,type:"free"})]}),vN=_v({tierId:(Kv=kN.products[0])==null?void 0:Kv.id});It({status:"free"}),It({status:"paid",paid:!0,subscriptions:[ca()]}),It({status:"comped",paid:!0,subscriptions:[]}),It({status:"comped",paid:!0,subscriptions:[ca({amount:0})]}),It({status:"paid",paid:!0,subscriptions:[ca({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Bv();const Dl=[Yv({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),yi({name:"The Blueprint",description:"",monthlyPrice:St({interval:"month",amount:500}),yearlyPrice:St({interval:"year",amount:5e3}),numOfBenefits:3}),yi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:St({interval:"month",amount:1200}),yearlyPrice:St({interval:"year",amount:11e3}),numOfBenefits:4})],bi=Al({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:Dl,portalProducts:Dl.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}]}),Uv=_v({tierId:(qv=bi.products[1])==null?void 0:qv.id}),ki={free:It({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:It({paid:!0,status:"paid",subscriptions:[ca({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:It({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:It({paid:!0,status:"comped",subscriptions:[ca({amount:0})]}),preview:It({paid:!0,status:"paid",subscriptions:[ca({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function wN(){var n;if(!Dl||!Dl[1])return null;let e=(n=bi==null?void 0:bi.products)==null?void 0:n[1].monthlyPrice,t=It({paid:!0,status:"paid",subscriptions:[ca({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:bi,member:t}}function SN(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 xN({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function EN({state:e}){return{showPopup:!e.showPopup}}function CN({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function $N({state:e}){return e.lastPage?{page:e.lastPage}:Hv({state:e})}function Hv({state:e}){return on(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function jN({data:e,state:t}){const{action:n="openNotification",status:a="success",autoHide:i=!0,closeable:o=!0,duration:r=2600,message:s=""}=e||{},c=sm({type:n,status:a,autoHide:i,closeable:o,duration:r,state:t,message:s});return{notification:c,notificationSequence:c.count}}function TN(){return{notification:null}}async function PN({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:g("Failed to log out, please try again")})}}}async function IN({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:Bt(a,g("Failed to log in, please try again"))})}}}function zN({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 NN({data:e,api:t}){var a;const n=g("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:Bt((a=o.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Bt(i,n)}}}async function AN({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}=sa({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=Bt(a,g("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 MN({data:e,state:t,api:n}){var a;try{let{email:i,name:o,giftToken:r}=e;if(o=o==null?void 0:o.trim(),t.member){await n.gift.redeem({token:r});const p=await n.member.sessionData(),m=sm({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:t,message:Qk({member:p})});return on(),{action:"redeemGift:success",member:p,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:m,notificationSequence:m.count}}const s=await n.member.getIntegrityToken(),c=new URL(((a=t==null?void 0:t.site)==null?void 0:a.url)||window.location.href);c.search=new URLSearchParams({giftRedemption:"true"}).toString(),c.hash="";const{otc_ref:u,inboxLinks:d}=await n.member.sendMagicLink({email:(i||"").trim(),emailType:"subscribe",integrityToken:s,includeOTC:!0,redirect:c.href,giftToken:r,...o?{name:o}:{}});return{page:"magiclink",lastPage:"giftRedemption",...u?{otcRef:u}:{},inboxLinks:d,pageData:{...t.pageData||{},email:(i||"").trim(),redirect:c.href}}}catch(i){return{action:"redeemGift:failed",popupNotification:re({type:"redeemGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:Bt(i,"Failed to redeem gift, please try again")})}}}async function DN({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:o,cadence:r}=e;(!o||!r)&&({tierId:o,cadence:r}=sa({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:g("Failed to process checkout, please try again")})}}}async function ON({state:e,api:t}){try{await t.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:re({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:g("Failed to process checkout, please try again")})}}}async function FN({data:e,state:t,api:n}){try{const{tierId:a,cadence:i}=e;return await n.member.checkoutGift({tierId:a,cadence:i}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:re({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:g("Failed to process checkout, please try again")})}}}async function RN({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:o,cancelAtPeriodEnd:r}=e,{tierId:s,cadence:c}=sa({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:g("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:g("Failed to update subscription, please try again")})}}}async function _N({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:g("Failed to cancel subscription, please try again")})}}}async function YN({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:g("Failed to cancel subscription, please try again")})}}}async function LN({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 BN({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:g("Failed to update billing information, please try again")})}}}async function UN({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:g("Failed to open billing portal, please try again")})}}}async function HN(){return{popupNotification:null}}async function VN({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 WN({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:g("Failed to update newsletter settings")})}}}async function GN({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:g("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:re({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:g("Your email has failed to resubscribe, please try again")})}}}async function KN({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:g("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:re({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:g("Failed to update newsletter settings")})}}}async function qN({data:e,state:t,api:n}){const{email:a}=e,i=EP({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 JN({data:e,state:t,api:n}){var o;const a=(o=e==null?void 0:e.name)==null?void 0:o.trim();if($P({member:t.member})!==a)try{const r=await n.member.update({name:a});if(!r)throw new Error("Failed to update member");return{member:r,success:!0}}catch(r){return{success:!1,error:r}}return null}async function ZN({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 XN({data:e,state:t,api:n}){const[a,i]=await Promise.all([JN({data:e,state:t,api:n}),qN({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:g("Check your inbox to verify email update")})};const o=a.success?g("Failed to send verification email"):g("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?g("Account details updated successfully"):g("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=Bt(i.error,g("Failed to send verification email")):s=g("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:g("Account details updated successfully")})}}async function QN({data:{siteUrl:e},state:t}){const n=Il({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,o=jk(),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 eA({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 tA({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const nA={togglePopup:EN,openPopup:CN,closePopup:Hv,switchPage:xN,openNotification:jN,closeNotification:TN,back:$N,signout:PN,signin:IN,startSigninOTCFromCustomForm:zN,verifyOTC:NN,signup:AN,redeemGift:MN,updateSubscription:RN,cancelSubscription:_N,continueSubscription:YN,applyOffer:LN,updateNewsletter:KN,updateProfile:XN,refreshMemberData:ZN,clearPopupNotification:HN,editBilling:BN,manageBilling:UN,checkoutPlan:DN,continueGiftSubscription:ON,checkoutGift:FN,updateNewsletterPreference:WN,showPopupNotification:VN,removeEmailFromSuppressionList:GN,oneClickSubscribe:QN,trackRecommendationClicked:eA,trackRecommendationSubscribed:tA};async function aA({action:e,data:t,state:n,api:a}){const i=nA[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Vv(e,t){e&&(e.innerText=t)}function iA(e,t,n){t.classList.add("error");const a=g("There was an error sending the email, please try again");Vv(n,Bt(e,a))}async function oA({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:o,captureException:r}){var x,$;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,h=[],b=[],v=e.target.querySelectorAll("input[data-members-label]")||[];for(let C=0;C<v.length;++C)h.push(v[C].value);let f=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let C=0;C<f.length;++C)b.push({name:f[C].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const y=m==="signin"&&(($=t==null?void 0:t.dataset)==null?void 0:$.membersOtc)==="true";t.classList.add("loading");const k=si(),E={email:d,emailType:m,labels:h,name:p,autoRedirect:u==="true"};y&&(E.includeOTC=!0),k&&(E.urlHistory=k),f.length>0?E.newsletters=b:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(E.newsletters=[]);try{const z=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),T=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E,integrityToken:z})});if(t.addEventListener("submit",i),t.classList.remove("loading"),T.ok){t.classList.add("success");let A;if(y)try{A=await T.clone().json()}catch{A=void 0}const L=A==null?void 0:A.otc_ref;if(L&&typeof o=="function")try{o("startSigninOTCFromCustomForm",{email:(d||"").trim(),otcRef:L,inboxLinks:A==null?void 0:A.inboxLinks})}catch(q){console.error(q),r==null||r(q)}}else{const A=await Pt.fromApiResponse(T),L=Bt(A,g("Failed to send magic link email"));Vv(n,L),t.classList.add("error")}}catch(C){iA(C,t,n)}}function rA({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=pP(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 h=o?{checkoutType:"upgrade"}:{},b=si();return b&&(h.urlHistory=b),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,identity:v,successUrl:p,cancelUrl:m,metadata:h})}).then(function(f){if(!f.ok)throw new Error(g("Could not create Stripe checkout session"));return f.json()})}).then(function(v){return v.url?window.location.assign(v.url):window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId}).then(function(y){if(y.error)throw new Error(y.error.message)})}).catch(function(v){console.error(v),t.addEventListener("click",r),t.classList.remove("loading"),n&&(n.innerText=v.message),t.classList.add("error")})}function sA({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){oA({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){rA({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 h(b){s.removeEventListener("click",h),b.preventDefault(),c&&(c.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(v){return v.ok?v.text():null}).then(function(v){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:v,successUrl:p,cancelUrl:m})}).then(function(f){if(!f.ok)throw new Error(g("Could not create Stripe checkout session"));return f.json()})}).then(function(v){return window.Stripe(v.publicKey).redirectToCheckout({sessionId:v.sessionId})}).then(function(v){if(v.error)throw new Error(g(v.error.message))}).catch(function(v){console.error(v),s.addEventListener("click",h),s.classList.remove("loading"),c&&(c.innerText=v.message),s.classList.add("error")})}s.addEventListener("click",h)}),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(h){return h.ok?h.text():null}).then(function(h){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:h,returnUrl:d})}).then(function(b){if(!b.ok)throw new Error(g("Could not create Stripe billing portal session"));return b.json()})}).then(function(h){return window.location.assign(h.url)}).catch(function(h){console.error(h),s.addEventListener("click",p),s.classList.remove("loading"),c&&(c.innerText=h.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=g("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=g("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",u)})}const Wv=e=>{try{return decodeURIComponent(e)}catch{return null}},lA={staleGiftRedemptionRequest:!0},cA={showPopup:!0,site:bi,member:ki.free,page:"accountEmail",...wN(),pageData:Uv};function uA({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?l.jsx(jd,{children:t}):l.jsx(l.Fragment,{children:t})}class dA extends X.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(),sA({siteUrl:r,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Ps})}}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"&&!ul({site:this.state.site})){this.invalidateGiftRedemptionRequest(),on();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";ol.changeLanguage(m);const h={site:t,member:n,offers:a,page:i,lastPage:u,pageQuery:d,showPopup:o,pageData:p,popupNotification:r,notification:s,notificationSequence:c,dir:ol.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:d,member:n}),this.setState(h),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const b=document.querySelectorAll("[data-lexical-signup-form]");b.length>0&&b.forEach(v=>{v.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 pe(["dev"])&&!this.state.customSiteUrl?cA:pe(["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||Uv.tier.id}:c==="redemption_type"&&(a.redemption_type=u||"signup")}if(a.redemption_type==="retention"){const s=(r=(o=(i=ki.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 h=m.toUpperCase();a.site.plans.currency=h,a.site.plans.currency_symbol=we(h),u=h}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}=Xk({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(!ul({site:t}))return on(),{};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){on();const o=sm({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:ev(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(Cl(["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(gP({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\/?$/,h=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&h.test(i)){const[,b,v]=i.match(h),f=parseInt(v);if(f===1||f===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:f}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${b}/${f}/`}}}if(i&&d.test(i)){const[,b]=i.match(d),v=Wv(b);if(!v)return{};const f=this.startGiftRedemptionRequest(v),y=await this.fetchGiftRedemptionData({site:t,token:v});return this.isCurrentGiftRedemptionRequest(f)?y:lA}if(i&&m.test(i))return{showPopup:!0,page:"share"};if(i&&p.test(i)){const[,b]=i.match(p),{page:v,pageQuery:f,pageData:y}=this.getPageFromLinkPath(b,t)||{};if(!n&&v&&Fv({page:v}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${b}/`}};if(v==="gift"&&!ul({site:t}))return on(),{};const k=["accountPlan","accountProfile"].includes(v)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(f)||s.test(f)||c.test(f)||u.test(f)),...v?{page:v}:{},...f?{pageQuery:f}:{},...y?{pageData:y}:{},...k?{lastPage:k}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if(pe(["preview"])){let n={};return pe(["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||Il({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(pe(["dev","test"],{customSiteUrl:n}))return{};throw o}}setupSentry({site:t}){if(pe(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,r=`portal@2.68.21|ghost@${i}`;n&&n.dsn&&y0({dsn:n.dsn,environment:n.env||"development",release:r,beforeSend:s=>rP({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if(pe(["test"]))return null;const a=CP({site:t});let i=om({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),OP({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 aA({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:Bt(a,g("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(on(),!Ut({member:a})||An({member:a}))try{const o=await this.GhostApi.site.offer({offerId:n}),r=o==null?void 0:o.offers[0];if(!r||!r.tier||cm({offer:r})||!IP({site:t,offer:r}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:o==null?void 0:o.offers[0]});else{const s=Dn({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}=sa({site:t,priceId:c.id});this.dispatchAction("checkoutPlan",{plan:c.id,offerId:n,tierId:u,cadence:d})}else{const{tierId:u,cadence:d}=sa({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}Nk({site:t,pageQuery:n})&&(o=Nk({site:t,pageQuery:n}));const r=hP({site:t,priceId:o});if(n&&n!=="free"){on();const s=(r==null?void 0:r.id)||o;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:c,cadence:u}=sa({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=Wv(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 kI(t)}getRetentionPreviewMember({site:t,offers:n}){var u,d,p;const a=(n||[]).find(m=>cm({offer:m})),i=(u=a==null?void 0:a.tier)==null?void 0:u.id,o=i?Dn({site:t,productId:i}):null,r=o?a.cadence==="year"?o.yearlyPrice:o.monthlyPrice:null,s=ki.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=Ht({site:t})||!rn({site:t})?"signin":"signup";n=a?"accountHome":i}return Bm({page:n})}getContextMember({site:t,page:n,member:a,offers:i,pageData:o,customSiteUrl:r}){return pe(["dev","preview"],{customSiteUrl:r})?Fv({page:n})||pN({page:n})?pe(["dev"],{customSiteUrl:r})?a||ki.free:pe(["preview"])?n==="accountPlan"&&(o==null?void 0:o.action)==="cancel"?this.getRetentionPreviewMember({site:t,offers:i}):ki.preview:ki.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:h,dir:b,scrollbarWidth:v,otcRef:f,inboxLinks:y}=this.state,k=this.getContextPage({site:t,page:r,member:n}),E=this.getContextMember({site:t,page:k,member:n,offers:a,pageData:d,customSiteUrl:h});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:o,brandColor:this.getAccentColor(),page:k,pageQuery:u,pageData:d,member:E,lastPage:s,showPopup:c,popupNotification:p,notification:m,customSiteUrl:h,dir:b,scrollbarWidth:v,otcRef:f,inboxLinks:y,doAction:(x,$)=>this.dispatchAction(x,$)}}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(SN)}render(){return this.state.initStatus==="success"?l.jsx(uA,{site:this.state.site,children:l.jsxs(F.Provider,{value:this.getContextFromState(),children:[l.jsx(Hm,{}),l.jsx(dm,{}),l.jsx(vm,{})]})}):null}}const Gv="ghost-portal-root";function mA(){const e=document.createElement("div");e.id=Gv,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function pA(){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 hA(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function fA(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=pA(),o=e||window.location.origin;mA(),hA(),$x.render(l.jsx(X.StrictMode,{children:l.jsx(dA,{siteUrl:o,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Gv))}fA()});
4259
4252
  //# sourceMappingURL=portal.min.js.map