@tryghost/portal 2.69.10 → 2.69.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tryghost/portal",
3
3
  "type": "module",
4
- "version": "2.69.10",
4
+ "version": "2.69.11",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -61,7 +61,8 @@
61
61
  },
62
62
  "nx": {
63
63
  "tags": [
64
- "i18n"
64
+ "i18n",
65
+ "public-app"
65
66
  ]
66
67
  },
67
68
  "scripts": {
package/umd/portal.min.js CHANGED
@@ -4517,5 +4517,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
4517
4517
  }
4518
4518
  `;function K0({site:t}){return mc+q0+D1+J1+sj+F1()+M1+N1+O1+Vf+d0+qj+f0()+Ic+m0+Z0+J0+y0+C0+E0+j0+P0+N0+l0+Y0+A0+L0+G0+V0}const wd=class wd extends Xe.Component{constructor(e){super(e),this.state={email:"",token:void 0}}componentDidMount(){const{member:e}=this.context;e&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(e){e.preventDefault(),this.doSignin()}doSignin(){this.setState(e=>({errors:Di({fields:this.getInputFields({state:e})})}),async()=>{const{email:e,phonenumber:a,errors:o,token:s}=this.state,{redirect:u}=this.context.pageData??{};o&&Object.values(o).filter(m=>!!m).length>0||this.context.doAction("signin",{email:e,phonenumber:a,redirect:u,token:s})})}handleInputChange(e,a){const o=a.name;this.setState({[o]:e.target.value})}onKeyDown(e){e.keyCode===13&&this.handleSignin(e)}getInputFields({state:e}){const a=e.errors||{};return[{type:"email",value:e.email,placeholder:w("jamie@example.com"),label:w("Email"),name:"email",required:!0,errorMessage:a.email||"",autoFocus:!0},{type:"text",value:e.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:e}=this.context;let a=!1;const o=e==="signin:running";let s=w(o?"Sending login link...":"Continue");const u=!!o;return e==="signin:failed"&&(s=w("Retry"),a=!0),l.jsx(mt,{dataTestId:"signin",retry:a,style:{width:"100%"},onClick:d=>this.handleSignin(d),disabled:u,brandColor:this.context.brandColor,label:s,isRunning:o})}renderSignupMessage(){const{brandColor:e}=this.context;return l.jsxs("div",{className:"gh-portal-signup-message",children:[l.jsx("div",{children:w("Don't have an account?")}),l.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:e},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:l.jsx("span",{children:w("Sign up")})})]})}renderForm(){const{site:e}=this.context,a=ts({site:e})&&na({site:e});return ka({site:e})?l.jsxs("section",{children:[l.jsx("div",{className:"gh-portal-section",children:l.jsx($o,{fields:this.getInputFields({state:this.state}),onChange:(o,s)=>this.handleInputChange(o,s),onKeyDown:(o,s)=>this.onKeyDown(o,s)})}),l.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),a&&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:w("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:e}=this.context,a=e.icon;return a?l.jsx("img",{className:"gh-portal-signup-logo",src:a,alt:this.context.site.title}):ka({site:e})?null:l.jsx(zg,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:e}=this.context,a=e.title;return ka({site:e})?l.jsx("h1",{className:"gh-portal-main-title",children:w("Sign in")}):l.jsx("h1",{className:"gh-portal-main-title",children:a})}renderFormHeader(){return l.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return l.jsxs(l.Fragment,{children:[l.jsx(pt,{}),l.jsx("div",{className:"gh-portal-logged-out-form-container",children:l.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};wd.contextType=ve;let nd=wd;const X0=({handleSignout:t,supportAddress:e=""})=>{const a=`mailto:${e}`;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:o=>t(o),children:w("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:a,target:"_blank",rel:"noopener noreferrer",children:w("Contact support")})})})})]})},Q0=()=>{const{member:t,brandColor:e}=z.useContext(ve),a=t.avatar_image;return l.jsxs("header",{className:"gh-portal-account-header",children:[l.jsx(dc,{gravatar:a,style:{userIcon:{color:e,width:"56px",height:"56px",padding:"2px"}}}),l.jsx("h2",{className:"gh-portal-main-title",children:w("Your account")})]})},_0=()=>{const{site:t,action:e,brandColor:a,doAction:o}=z.useContext(ve);if(!ts({site:t})||!na({site:t}))return null;const s=["checkoutPlan:running"].includes(e),u=()=>{o("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return l.jsx(mt,{dataTestId:"view-plans",isRunning:s,label:w("View plans"),onClick:()=>u(),brandColor:a,style:{width:"100%"}})},eT=()=>{const{member:t,site:e}=z.useContext(ve),{paid_members_enabled:a}=e;if(!a||Ti({site:e}))return null;const o=on({member:t}),s=ba({member:t});if(s&&!o)return null;if(o){const u=o?.current_period_end,d=_r({member:t});if(Rn({member:t}))return d?l.jsx("div",{className:"gh-portal-section",style:{marginBottom:24},children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:w("Your gift subscription will expire on {expiryDate}",{expiryDate:d})})}):null;if(s&&d)return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:w("Your subscription will expire on {expiryDate}",{expiryDate:d})})});if(o?.cancel_at_period_end||s)return null;if(gc({sub:o})){const m=ga(o.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:w("Your subscription will start on {subscriptionStart}",{subscriptionStart:m})})})}return l.jsx("div",{className:"gh-portal-section",children:l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:w("Your subscription will renew on {renewalDate}",{renewalDate:ga(u)})})})}return l.jsxs("div",{className:"gh-portal-section",children:[l.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:w("You currently have a free membership, upgrade to a paid subscription for full access.")}),l.jsx(_0,{})]})},tT=()=>{const{member:t,doAction:e,action:a,brandColor:o}=z.useContext(ve),s=on({member:t});if(!s||!s.cancel_at_period_end)return null;const u=w("Resume subscription"),d=["continueSubscription:running"].includes(a),m=!!d,h=ga(s.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(Nt,{string:w("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:l.jsx("strong",{children:h})}})}),l.jsx(mt,{onClick:()=>{e("continueSubscription",{subscriptionId:s.id})},isRunning:d,disabled:m,isPrimary:!0,brandColor:o,label:u,style:{width:"100%"}})]})})},nT=()=>{const{member:t,site:e,doAction:a,action:o,brandColor:s}=z.useContext(ve);if(!(Rn({member:t})&&!pc({member:t,site:e})&&Pi({site:e}))||!_r({member:t}))return null;const m=o==="continueGiftSubscription:running";return l.jsx("div",{className:"gh-portal-cancelcontinue-container",children:l.jsxs("div",{className:"gh-portal-cancel-banner",children:[l.jsx("p",{style:{maxWidth:"none",margin:"0 0 16px",textAlign:"center",textWrap:"pretty"},children:w("Continue with a paid subscription anytime. Your remaining gift period will be added as a free trial.")}),l.jsx(mt,{onClick:()=>a("continueGiftSubscription"),isRunning:m,disabled:m,isPrimary:!0,brandColor:s,label:w("Continue subscription"),style:{width:"100%"}})]})})},aT=t=>z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...t},z.createElement("rect",{x:3,y:8,width:18,height:4,rx:1}),z.createElement("path",{d:"M12 8v13"}),z.createElement("path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}),z.createElement("path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5C9 3 12 8 12 8"}),z.createElement("path",{d:"M16.5 8a2.5 2.5 0 0 0 0-5C15 3 12 8 12 8"})),iT=t=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},z.createElement("defs",null,z.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),z.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"}),z.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"})),oT=()=>{const{member:t,site:e,doAction:a}=z.useContext(ve),o=()=>{const S=on({member:t});a("manageBilling",{subscriptionId:S.id})},s=()=>{Pi({site:e})&&a("switchPage",{page:"accountPlan",lastPage:"accountHome"})},u=({price:S,isComplimentary:I,subscription:A})=>{const{next_payment:D}=A||{};let U="";if(S){const{amount:ce=0,currency:pe,interval:xe}=S;U=`${Intl.NumberFormat("en",{currency:pe,style:"currency"}).format(ce/100)}/${w(xe)}`}const V=_r({member:t});if(Rn({member:t})&&V)return l.jsxs("p",{className:"gh-portal-account-discountcontainer",children:[l.jsx(aT,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:w("Gift subscription")}),l.jsx("span",{className:"gh-portal-account-expiry-separator",children:"-"}),l.jsx("span",{className:"gh-portal-account-expiry",children:w("Expires {expiryDate}",{expiryDate:V})})]});I&&(V?U=`${w("Complimentary")} - ${w("Expires {expiryDate}",{expiryDate:V})}`:U=w("Complimentary"));let ee="";if(gc({sub:A}))return ee="gh-portal-account-old-price",l.jsxs(l.Fragment,{children:[l.jsx("p",{className:ee,children:U}),l.jsx(rT,{subscription:A})]});let H=sT({nextPayment:D});H&&(ee="gh-portal-account-old-price");const re=()=>H?l.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[l.jsx(iT,{className:"gh-portal-account-tagicon"}),l.jsx("span",{children:H})]}):null;return l.jsxs(l.Fragment,{children:[l.jsx("p",{className:ee,children:U}),l.jsx(re,{})]})},d=({isPaid:S})=>{const I=Rn({member:t});if(I&&!Pi({site:e}))return null;const A=I&&!pc({member:t,site:e});return Ti({site:e})&&(!S||I&&!A)?null:A?l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>a("continueGiftSubscription"),"data-test-button":"continue-gift-subscription",children:w("Continue")}):l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:D=>s(),"data-test-button":"change-plan",children:w("Change")})},m=({defaultCardLast4:S})=>{if(S){const I=`**** **** **** ${S}`;return l.jsx("p",{children:I})}return null},h=({defaultCardLast4:S})=>{const{action:I}=z.useContext(ve),A=I==="manageBilling:running"?l.jsx(Ai,{className:"gh-portal-billing-button-loader"}):w("Update");return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:w("Billing info & receipts")}),l.jsx(m,{defaultCardLast4:S})]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:D=>o(),"data-test-button":"manage-billing",children:A})]})},f=on({member:t}),y=ba({member:t}),v=Rn({member:t}),x=Yn({member:t});if(f||y){const{price:S,default_payment_card_last4:I}=f||{};let A=w("Plan");return hc({member:t})&&(A=hc({member:t})),l.jsxs(l.Fragment,{children:[l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsxs("h3",{children:[A,f?.cancel_at_period_end&&l.jsx("span",{className:"gh-portal-canceled-badge",children:w("Canceled")})]}),l.jsx(u,{price:S,isComplimentary:y,subscription:f})]}),l.jsx(d,{isPaid:x})]}),!y&&!v&&l.jsx(h,{defaultCardLast4:I})]})}return null};function rT({subscription:t}){if(gc({sub:t})){const e=ga(t.trial_end_at);return l.jsx("p",{className:"gh-portal-account-discountcontainer",children:l.jsx("div",{children:l.jsx("span",{children:w("Free Trial – Ends {trialEnd}",{trialEnd:e})})})})}return null}function sT({nextPayment:t}){if(!t)return"";const e=t.discount;if(!e)return"";const a=e.end?w("Ends {offerEndDate}",{offerEndDate:ga(e.end)}):w("Forever");return`${`${Intl.NumberFormat("en",{currency:t.currency,style:"currency"}).format(t.amount/100)}/${w(t.interval)}`}${a?` — ${a}`:""}`}function lT(){const{member:t,site:e,doAction:a}=z.useContext(ve);let{newsletters:o}=t;const s=!!o?.length;let u=w(s?"Subscribed":"Unsubscribed");const d=m=>{m.preventDefault();const h=Qa({site:e}),f=t?.newsletters?.length?[]:h;a("updateNewsletterPreference",{newsletters:f})};return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[l.jsx("h3",{children:w("Email newsletter")}),l.jsxs("p",{children:[u," ",yc({member:t})&&s&&l.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>a("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:w("Not receiving emails?")})]})]}),l.jsx("div",{children:l.jsx(Yo,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:m=>{d(m)},checked:s})})]})}const ay=t=>z.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...t},z.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"}),z.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 uT(){return l.jsxs("p",{className:"gh-portal-email-notice",children:[l.jsx(ay,{className:"gh-portal-email-notice-icon"}),l.jsx("span",{className:"gh-mobile-only",children:w("You're not receiving emails")}),l.jsx("span",{className:"gh-desktop-only",children:w("You're currently not receiving emails")})]})}function cT(){const{doAction:t,member:e,site:a}=z.useContext(ve),o=Kf({member:e}),s=Po({site:a}),u=ns({site:a}),d=o?"emailSuppressed":"accountEmail",m=!s&&!u,h=()=>o||m?l.jsx(uT,{}):l.jsx("p",{children:w("Update your preferences")});return l.jsxs("section",{children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:w("Emails")}),h()]}),l.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{t("switchPage",{page:d,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:w("Manage")})]})}const dT=()=>{const{member:t,site:e}=z.useContext(ve),o=e.transistor_portal_settings||{enabled:e.transistor_portal_enabled===!0,heading:e.transistor_portal_heading,description:e.transistor_portal_description,button_text:e.transistor_portal_button_text,url_template:e.transistor_portal_url_template},s=o?.enabled===!0,u=t?.uuid,d=tg(),[m,h]=z.useState(d&&s);return z.useEffect(()=>{if(d){h(s);return}if(!s||!u){h(!1);return}h(!1);const f=new AbortController;return(async()=>{try{const v=await fetch(`https://partner.transistor.fm/ghost/member/${u}`,{signal:f.signal});if(v.ok){const x=await v.json();f.signal.aborted||h(x?.member===!0)}}catch(v){if(f.signal.aborted)return;console.warn("Error in Transistor request",v)}})(),()=>f.abort()},[s,u,d]),{transistor:{enabled:s,hasPodcasts:m,memberUuid:u,settings:o}}},mT=(t,e)=>No({site:t})&&Po({site:t})||ns({site:t})||Kf({member:e}),pT=t=>!No({site:t})&&Po({site:t})&&!ns({site:t}),hT=()=>{const{member:t,doAction:e,site:a}=z.useContext(ve),{name:o,email:s}=t,{transistor:u}=dT(),d=()=>{e("switchPage",{page:"accountProfile",lastPage:"accountHome"})},m=mT(a,t),h=pT(a);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:o||w("Account")}),l.jsx("p",{children:s})]}),l.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:f=>d(),children:w("Edit")})]}),l.jsx(oT,{}),m&&l.jsx(cT,{}),h&&l.jsx(lT,{}),u.enabled&&l.jsx(H0,{hasPodcasts:u.hasPodcasts,memberUuid:u.memberUuid,settings:u.settings})]})})},fT=()=>l.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[l.jsx(pt,{}),l.jsx(Q0,{}),l.jsxs("section",{className:"gh-portal-account-data",children:[l.jsx(eT,{}),l.jsx(nT,{}),l.jsx(tT,{}),l.jsx(hT,{})]})]}),xd=class xd extends Xe.Component{componentDidMount(){const{member:e,site:a}=this.context;ka({site:a})||this.context.doAction("signout"),e||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(e){e.preventDefault(),this.context.doAction("signout")}render(){const{member:e,site:a}=this.context,o=Ao({site:a});return!e||!ka({site:a})?null:l.jsxs("div",{className:"gh-portal-account-wrapper",children:[l.jsx(fT,{}),l.jsx(X0,{onClose:()=>this.context.doAction("closePopup"),handleSignout:s=>this.handleSignout(s),supportAddress:o})]})}};xd.contextType=ve;let ad=xd;const Sd=class Sd extends Xe.Component{constructor(e,a){super(e,a);const{name:o="",email:s=""}=a.member||{};this.state={name:o,email:s}}componentDidMount(){const{member:e}=this.context;e||this.context.doAction("switchPage",{page:"signin"})}handleSignout(e){e.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(e){e.preventDefault(),this.setState(a=>({errors:Di({fields:this.getInputFields({state:a})})}),()=>{const{email:a,name:o,errors:s}=this.state;s&&Object.values(s).filter(d=>!!d).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:a,name:o}))})}renderSaveButton(){const e=this.context.action==="updateProfile:running";let a=w("Save");this.context.action==="updateProfile:failed"&&(a=w("Retry"));const o=!!e;return l.jsx(mt,{dataTestId:"save-button",isRunning:e,onClick:s=>this.onProfileSave(s),disabled:o,brandColor:this.context.brandColor,label:a,style:{width:"100%"}})}renderDeleteAccountButton(){return l.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:w("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(Oi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:e=>this.onBack(e)}),l.jsx("h3",{className:"gh-portal-main-title",children:w("Account settings")})]})}renderUserAvatar(){const e=this.context.member&&this.context.member.avatar_image,a={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:a,children:l.jsx(dc,{gravatar:e,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(e,a){const o=a.name;this.setState({[o]:e.target.value})}getInputFields({state:e,fieldNames:a}){const o=e.errors||{},s=[{type:"text",value:e.name,placeholder:w("Jamie Larson"),label:w("Name"),name:"name",required:!1,errorMessage:o.name||""},{type:"email",value:e.email,placeholder:w("jamie@example.com"),label:w("Email"),name:"email",required:!0,errorMessage:o.email||""}];return a&&a.length>0?s.filter(u=>a.includes(u.name)):s}onKeyDown(e){e.keyCode===13&&this.onProfileSave(e)}renderProfileData(){return l.jsx("div",{className:"gh-portal-section",children:l.jsx($o,{fields:this.getInputFields({state:this.state}),onChange:(e,a)=>this.handleInputChange(e,a),onKeyDown:(e,a)=>this.onKeyDown(e,a)})})}render(){const{member:e}=this.context;return e?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pt,{}),this.renderHeader(),l.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};Sd.contextType=ve;let id=Sd;function gT(){const{brandColor:t,lastPage:e,doAction:a}=z.useContext(ve);return l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Oi,{brandColor:t,hidden:!e,onClick:()=>{a("back")}}),l.jsx("h3",{className:"gh-portal-main-title",children:w("Email preferences")})]})}function yT({newsletter:t,subscribedNewsletters:e,setSubscribedNewsletters:a}){const o=e.some(s=>s.id===t?.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:t.name}),l.jsx("p",{children:t?.description})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(Yo,{id:t.id,onToggle:(s,u)=>{let d=[];u?d=e.filter(m=>m.id!==t.id).concat(t):d=e.filter(m=>m.id!==t.id),a(d)},checked:o,dataTestId:"switch-input"})})]})}function bT({updateCommentNotifications:t,isCommentsEnabled:e,enableCommentNotifications:a}){const{doAction:o}=z.useContext(ve),s=!!a;if(!e)return null;const u=async(d,m)=>{await t(m),o("showPopupNotification",{action:"updated:success",message:w("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:w("Comments")}),l.jsx("p",{children:w("Get notified when someone replies to your comment")})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(Yo,{id:"comments",onToggle:u,checked:s,dataTestId:"switch-input"})})]})}function kT({updateUpdatesAndAnnouncements:t,canChangeUpdatesAndAnnouncements:e,enableUpdatesAndAnnouncements:a}){const{doAction:o,site:s}=z.useContext(ve),[u,d]=z.useState(!1);if(!e)return null;const m=async(h,f)=>{d(!0);try{await t(f),o("showPopupNotification",{action:"updated:success",message:w("Email preferences updated.")})}finally{d(!1)}};return l.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"updates-and-announcements-toggle",children:[l.jsxs("div",{className:"gh-portal-list-detail",children:[l.jsx("h3",{children:w("Updates & announcements")}),l.jsx("p",{children:w("Occasional updates from {siteTitle}",{siteTitle:s?.title})})]}),l.jsx("div",{style:{display:"flex",alignItems:"center"},children:l.jsx(Yo,{id:"updates-and-announcements",onToggle:m,checked:a,disabled:u,dataTestId:"switch-input"})})]})}function vT({subscribedNewsletters:t,setSubscribedNewsletters:e,hasNewslettersEnabled:a}){const{site:o}=z.useContext(ve),s=Qa({site:o});return a?s.map(u=>l.jsx(yT,{newsletter:u,subscribedNewsletters:t,setSubscribedNewsletters:e},u?.id)):null}function wT({site:t,isPaid:e}){return e?l.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:w("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:t?.title})}):null}function iy({hasNewslettersEnabled:t,notification:e,subscribedNewsletters:a,updateSubscribedNewsletters:o,updateCommentNotifications:s,updateUpdatesAndAnnouncements:u,unsubscribeAll:d,isPaidMember:m,isCommentsEnabled:h,enableCommentNotifications:f,canChangeUpdatesAndAnnouncements:y,enableUpdatesAndAnnouncements:v}){const{brandColor:x,doAction:S,member:I,site:A}=z.useContext(ve),D=z.useRef(!!a?.length).current,U=v!=null,V=U?v:D,ee=h&&!f||!h,ne=y&&!V||!y,H=!a?.length&&ee&&ne,ce=e||(()=>null);return l.jsxs("div",{className:"gh-portal-content with-footer",children:[l.jsx(pt,{}),l.jsx(gT,{}),l.jsx(ce,{}),l.jsx("div",{className:"gh-portal-section flex",children:l.jsxs("div",{className:"gh-portal-list",children:[l.jsx(vT,{hasNewslettersEnabled:t,subscribedNewsletters:a,setSubscribedNewsletters:pe=>{let xe=pe.map(L=>({id:L.id}));y&&!U?o(xe,V):o(xe)}}),l.jsx(bT,{isCommentsEnabled:h,enableCommentNotifications:f,updateCommentNotifications:s}),l.jsx(kT,{canChangeUpdatesAndAnnouncements:y,enableUpdatesAndAnnouncements:V,updateUpdatesAndAnnouncements:u})]})}),l.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:l.jsx(mt,{isRunning:!1,onClick:()=>{d()},disabled:H,brandColor:x,isPrimary:!1,label:w("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),l.jsxs("footer",{className:"gh-portal-action-footer"+(yc({member:I})?" gh-feature-suppressions":""),children:[l.jsx("div",{style:{width:"100%"},children:l.jsx(wT,{isPaid:m,site:A,subscribedNewsletters:a})}),yc({member:I})&&!H&&l.jsxs("div",{className:"gh-portal-footer-secondary",children:[l.jsx("span",{className:"gh-portal-footer-secondary-light",children:w("Not receiving emails?")}),l.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>S("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[w("Get help")," ",l.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function xT(){const{member:t,doAction:e,site:a,pageData:o}=z.useContext(ve);let s,u;o&&(s=o.newsletterUuid,u=o.action);const[d,m]=z.useState(!0),h=Qa({site:a}),f=Po({site:a});z.useEffect(()=>{t||e("switchPage",{page:"signin"})},[t,e]),z.useEffect(()=>{if(s&&u==="unsubscribe"){const V=t?.newsletters.filter(ee=>ee.uuid!==s);S(V),m(!1),e("updateNewsletterPreference",{newsletters:V})}},[]);const y=()=>{if(o.comments&&I){const ne=d?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ne}`,children:l.jsx(Nt,{string:w("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:t?.email})}})})})}const V=h?.find(ne=>ne.uuid===o.newsletterUuid);if(!V)return null;const ee=d?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ee}`,children:l.jsx(Nt,{string:w("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:t?.email}),newsletterName:l.jsx("strong",{children:V?.name})}})})})},v=[...t?.newsletters||[]],[x,S]=z.useState(v),{comments_enabled:I}=a,A=!!a.labs?.automations,{enable_comment_notifications:D,enable_updates_and_announcements:U}=t||{};return z.useEffect(()=>{S(t?.newsletters||[])},[t?.newsletters]),l.jsx(iy,{hasNewslettersEnabled:f,notification:s?y:null,subscribedNewsletters:x,updateSubscribedNewsletters:(V,ee)=>{S(V),e("updateNewsletterPreference",{newsletters:V,enableUpdatesAndAnnouncements:ee}),e("showPopupNotification",{action:"updated:success",message:w("Email preferences updated.")})},updateCommentNotifications:async V=>{e("updateNewsletterPreference",{enableCommentNotifications:V})},updateUpdatesAndAnnouncements:async V=>{e("updateNewsletterPreference",{enableUpdatesAndAnnouncements:V})},unsubscribeAll:()=>{S([]),e("showPopupNotification",{action:"updated:success",message:w("Unsubscribed from all emails.")});const V={newsletters:[]};I&&(V.enableCommentNotifications=!1),A&&(V.enableUpdatesAndAnnouncements=!1),e("updateNewsletterPreference",V)},isPaidMember:Yn({member:t}),isCommentsEnabled:I!=="off",enableCommentNotifications:D,canChangeUpdatesAndAnnouncements:A,enableUpdatesAndAnnouncements:U})}function ST(){const{site:t}=z.useContext(ve),e=t.icon;return e?l.jsx("img",{className:"gh-portal-unsubscribe-logo",src:e,alt:t.title}):null}function CT(){const{site:t}=z.useContext(ve),e=t.title||"";return l.jsxs("header",{className:"gh-portal-header",children:[l.jsx(ST,{}),l.jsx("h2",{className:"gh-portal-publication-title",children:e})]})}async function od({api:t,memberUuid:e,key:a,newsletters:o,enableCommentNotifications:s,enableUpdatesAndAnnouncements:u}){try{return await t.member.updateNewsletters({uuid:e,key:a,newsletters:o,enableCommentNotifications:s,enableUpdatesAndAnnouncements:u})}catch{}}function ET(){const{site:t,api:e,pageData:a,member:o,doAction:s}=z.useContext(ve),[u,d]=z.useState(),[m,h]=z.useState(!0),f=Qa({site:t}),y=f.filter(W=>W.subscribe_on_signup),[v,x]=z.useState(!1),[S,I]=z.useState(y),[A,D]=z.useState(!1),{comments_enabled:U}=t,V=!!t.labs?.automations,{enable_comment_notifications:ee=!1,enable_updates_and_announcements:ne}=u||{},H=Po({site:t}),re=async(W,K)=>{const ue={newsletters:W};K!==void 0&&(ue.enableUpdatesAndAnnouncements=K),o?s("updateNewsletterPreference",ue):await od({api:e,memberUuid:a.uuid,key:a.key,...ue}),I(W);const ye={action:"updated:success",message:w("Email preferences updated.")};s("showPopupNotification",ye)},ce=async W=>{let K;o?(await s("updateNewsletterPreference",{enableCommentNotifications:W}),K={...o,enable_comment_notifications:W}):K=await od({api:e,memberUuid:a.uuid,key:a.key,enableCommentNotifications:W}),d(K),s("showPopupNotification",{action:"updated:success",message:w("Comment preferences updated.")})},pe=async W=>{let K;o?(await s("updateNewsletterPreference",{enableUpdatesAndAnnouncements:W}),K={...o,enable_updates_and_announcements:W}):K=await od({api:e,memberUuid:a.uuid,key:a.key,enableUpdatesAndAnnouncements:W}),d(K),s("showPopupNotification",{action:"updated:success",message:w("Email preferences updated.")})},xe=async()=>{let W;o?(await s("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),W={...o},W.newsletters=[],W.enable_comment_notifications=!1,W.enable_updates_and_announcements=!1):W=await e.member.updateNewsletters({uuid:a.uuid,key:a.key,newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),I([]),d(W),s("showPopupNotification",{action:"updated:success",message:w("Unsubscribed from all emails.")})};if(z.useEffect(()=>{(async()=>{let W;try{W=await e.member.newsletters({uuid:a.uuid,key:a.key}),d(W??null),h(!1)}catch(ue){console.error("[PORTAL] Error fetching member newsletters",ue),d(null),h(!1);return}if(W===null)return;const K=W?.newsletters||[];I(K),f?.length===1&&!U&&!a.newsletterUuid?await re([]):a.newsletterUuid?await re(K?.filter(ue=>ue.uuid!==a.newsletterUuid)):a.comments&&U?await ce(!1):a.updatesAndAnnouncements&&V&&await pe(!1)})()},[U,V,a.uuid,a.newsletterUuid,a.comments,a.updatesAndAnnouncements,t.url,f?.length]),m)return l.jsx($i,{});if(!u)return l.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[l.jsx(pt,{}),l.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:l.jsx(Oc,{})}),l.jsx("h1",{className:"gh-portal-main-title",children:w("That didn't go to plan")}),l.jsx("div",{children:l.jsx("p",{className:"gh-portal-text-center",children:w("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),l.jsx(mt,{style:{width:"100%"},retry:!1,onClick:()=>s("closePopup"),disabled:!1,brandColor:"#000000",label:w("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if(f?.length===1&&!U&&!A)return l.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[l.jsx(pt,{}),l.jsx(CT,{}),l.jsx("h1",{className:"gh-portal-main-title",children:w("Successfully unsubscribed")}),l.jsxs("div",{children:[l.jsx("p",{className:"gh-portal-text-center",children:l.jsx(Nt,{string:w("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:l.jsx("strong",{children:u?.email})}})}),l.jsx("p",{className:"gh-portal-text-center",children:l.jsx(Nt,{string:w("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:()=>{D(!0)}})}})})]})]});const L=()=>{if(a.comments&&U){const ue=v?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ue}`,children:l.jsx(Nt,{string:w("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:l.jsx("strong",{children:u?.email})}})})})}if(a.updatesAndAnnouncements&&V){const ue=v?"gh-portal-hide":"";return l.jsx(l.Fragment,{children:l.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ue}`,children:l.jsx(Nt,{string:w("{memberEmail} will no longer receive updates & announcements."),mapping:{memberEmail:l.jsx("strong",{children:u?.email})}})})})}const W=f?.find(ue=>ue.uuid===a.newsletterUuid);if(!W)return null;const K=v?"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(Nt,{string:w("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:l.jsx("strong",{children:u?.email}),newsletterName:l.jsx("strong",{children:W?.name})}})})})};return l.jsx(iy,{hasNewslettersEnabled:H,notification:L,subscribedNewsletters:S,updateSubscribedNewsletters:async(W,K)=>{await re(W,K),x(!0)},updateCommentNotifications:ce,updateUpdatesAndAnnouncements:pe,unsubscribeAll:async()=>{await xe(),x(!0)},isPaidMember:u?.status!=="free",isCommentsEnabled:U!=="off",enableCommentNotifications:ee,canChangeUpdatesAndAnnouncements:V,enableUpdatesAndAnnouncements:ne})}function jT(){const{brandColor:t,lastPage:e,doAction:a,action:o,site:s}=z.useContext(ve);z.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(o)&&a("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(o)&&a("back"),["refreshMemberData:success"].includes(o)&&(No({site:s})||ns({site:s})?(a("switchPage",{page:"accountEmail",lastPage:"accountHome"}),a("showPopupNotification",{message:w("You have been successfully resubscribed")})):a("back"))},[o,a,s,w]);const u=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(o),d=()=>{a("removeEmailFromSuppressionList")};return l.jsxs("div",{className:"gh-email-suppressed-page",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Oi,{brandColor:t,hidden:!e,onClick:()=>{a("back")}}),l.jsx(pt,{})]}),l.jsx(ay,{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:w("Emails disabled")}),l.jsx("p",{children:w("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(mt,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:d,disabled:u,brandColor:t,label:w("Re-enable emails"),isRunning:u})]})}function TT(){const{brandColor:t,doAction:e,site:a,pageData:o}=z.useContext(ve),s=`mailto:${Ao({site:a})}`,u=o&&o.direct||!1;return l.jsxs("div",{className:"gh-email-suppression-faq",children:[!u&&l.jsxs("header",{className:"gh-portal-detail-header",children:[l.jsx(Oi,{brandColor:t,onClick:()=>{e("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),l.jsx(pt,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:w("Why has my email been disabled?")}),l.jsx("p",{children:w("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:w("Spam complaints")}),l.jsx("p",{children:w("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:w("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:w("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:w("Permanent failure (bounce)")}),l.jsx("p",{children:w("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:w("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:w("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:s,onClick:()=>{s&&window.open(s)},children:w("Need more help? Contact support")})})]})]})}function PT(){const{brandColor:t,doAction:e,site:a,lastPage:o,member:s,pageData:u}=z.useContext(ve),d=Ao({site:a}),m=`mailto:${d}`,h=KE({site:a}),f=u&&u.direct||!1;return l.jsxs("div",{className:"gh-email-receiving-faq",children:[l.jsxs("header",{className:"gh-portal-detail-header",children:[!f&&l.jsx(Oi,{brandColor:t,onClick:()=>{o?e("switchPage",{page:"accountHome"}):e("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),l.jsx(pt,{})]}),l.jsxs("div",{className:"gh-longform",children:[l.jsx("h3",{children:w("Help! I'm not receiving emails")}),l.jsx("p",{children:w("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),l.jsx("h4",{children:w("Verify your email address is correct")}),l.jsx("p",{children:l.jsx(Nt,{string:w("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:s.email}),button:l.jsx("button",{className:"gh-portal-btn-text",onClick:()=>e("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),l.jsx("h4",{children:w("Check spam & promotions folders")}),l.jsx("p",{children:w(`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:w("Create a new contact")}),l.jsx("p",{children:l.jsx(Nt,{string:w("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:h})}})}),l.jsx("h4",{children:w("Send an email and say hi!")}),l.jsx("p",{children:l.jsx(Nt,{string:w("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:h})}})}),l.jsx("h4",{children:w("Check with your mail provider")}),l.jsx("p",{children:l.jsx(Nt,{string:w("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:h})}})}),l.jsx("h4",{children:w("Get in touch for help")}),l.jsx("p",{children:l.jsx(Nt,{string:w("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:m,onClick:()=>{m&&window.open(m)},children:d})}})})]})]})}const zT=()=>{const[t,e]=z.useState(!0),[a,o]=z.useState(null),[s,u]=z.useState(null),{member:d,site:m}=z.useContext(ve);return z.useEffect(()=>{async function h(){const f=m.url,y=window.location.origin+window.location.pathname,v=d?`${y}?action=support&success=true`:`${y}#/portal/support/success`,x=y,S=ks({siteUrl:f});try{const I=await S.member.checkoutDonation({successUrl:v,cancelUrl:x,personalNote:w("Add a personal note")});I.url&&window.location.replace(I.url)}catch(I){I.type&&I.type==="DisabledFeatureError"?u(w("This site is not accepting payments at the moment.")):o(w("Something went wrong, please try again later.")),e(!1)}}m&&m.donations_enabled===!1?(u(w("This site is not accepting donations at the moment.")),e(!1)):h()},[]),t?l.jsx("div",{children:l.jsx($i,{})}):a?l.jsx(td,{error:a}):s?l.jsx(td,{error:s}):null},NT=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},Wo=(t,e)=>{const a=new URLSearchParams(e);return`${t}?${a.toString()}`},IT=({shareTitle:t,shareUrl:e})=>{const a=[t,e].filter(Boolean).join(`
4519
4519
 
4520
- `),o=[];return t&&o.push(`subject=${encodeURIComponent(t)}`),a&&o.push(`body=${encodeURIComponent(a)}`),`mailto:${o.length?`?${o.join("&")}`:""}`},AT=({shareTitle:t,shareUrl:e})=>Wo("https://www.linkedin.com/shareArticle",{mini:"true",url:e,title:t}),OT=()=>{const t=NT(),e=t.document,a=t.location,o=(I,A="content")=>e.querySelector(I)?.[A]||"",s=o('link[rel="canonical"]',"href")||a.origin+a.pathname+a.search,u=o('meta[property="og:title"]')||e.title||"",d=o('meta[property="og:description"]')||o('meta[name="description"]')||"",m=o('meta[property="og:image"]')||o('meta[name="twitter:image"]')||"",h=o('link[rel="icon"]',"href")||o('link[rel="shortcut icon"]',"href")||o('link[rel="apple-touch-icon"]',"href"),f=o('meta[name="author"]'),y=(f&&!/^https?:\/\//i.test(f)?f:"")||o('meta[name="twitter:creator"]')||"";let v=o('meta[property="og:site_name"]')||o('meta[name="application-name"]')||"";if(!v)try{v=new URL(s).hostname.replace(/^www\./,"")}catch{v=""}const x=[u,s].filter(Boolean).join(" ").trim(),S={twitter:Wo("https://twitter.com/intent/tweet",{url:s,text:u}),facebook:Wo("https://www.facebook.com/sharer/sharer.php",{u:s}),email:IT({shareTitle:u,shareUrl:s}),threads:Wo("https://www.threads.net/intent/post",{text:x}),linkedin:AT({shareTitle:u,shareUrl:s}),bluesky:Wo("https://bsky.app/intent/compose",{text:x})};return{shareUrl:s,shareTitle:u,shareExcerpt:d,shareImage:m,shareFavicon:h,shareSiteName:v,shareAuthor:y,socialLinks:S}},MT=()=>{const[t]=z.useState(OT);return t},DT=t=>z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...t},z.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"})),FT=t=>z.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",...t},z.createElement("circle",{cx:12,cy:12,r:1}),z.createElement("circle",{cx:19,cy:12,r:1}),z.createElement("circle",{cx:5,cy:12,r:1})),YT=t=>z.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",...t},z.createElement("defs",{id:"defs13"},z.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},z.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),z.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},z.createElement("g",{id:"g19"},z.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},z.createElement("g",{id:"g27",transform:"translate(600,350)"},z.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"})),z.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},z.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"})))))),RT=t=>z.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",...t},z.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"}),z.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"})),$T=t=>z.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...t},z.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),z.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"}),z.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"})),LT=t=>z.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},z.createElement("g",{clipPath:"url(#clip0_351_18008)"},z.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"})),z.createElement("defs",null,z.createElement("clipPath",{id:"clip0_351_18008"},z.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),UT=t=>z.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...t},z.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"})),rd={signin:nd,signup:Zc,accountHome:ad,accountPlan:Rc,accountProfile:id,accountEmail:xT,signupNewsletter:Lc,unsubscribe:ET,magiclink:Qc,loading:$i,offer:ed,feedback:S0,emailSuppressed:jT,emailSuppressionFAQ:TT,emailReceivingFAQ:PT,support:zT,supportSuccess:z0,supportError:td,recommendations:W0,gift:c0,giftRedemption:I0,giftSuccess:D0,share:()=>{const[t,e]=z.useState(!1),[a,o]=z.useState(!1),s=z.useRef(),u=z.useRef(null),{shareUrl:d,shareTitle:m,shareExcerpt:h,shareImage:f,shareFavicon:y,shareSiteName:v,shareAuthor:x,socialLinks:S}=MT();z.useEffect(()=>()=>{clearTimeout(s.current)},[]),z.useEffect(()=>{if(!a)return;const U=u.current?.ownerDocument||document,V=ne=>{u.current&&!u.current.contains(ne.target)&&(ne.stopPropagation(),ne.preventDefault(),o(!1))},ee=ne=>{ne.key==="Escape"&&o(!1)};return U.addEventListener("click",V,!0),U.addEventListener("keydown",ee),()=>{U.removeEventListener("click",V,!0),U.removeEventListener("keydown",ee)}},[a]);const I=async()=>{await _g(d)&&(e(!0),clearTimeout(s.current),s.current=setTimeout(()=>{e(!1)},2e3))},A=()=>{o(U=>!U)},D=()=>{o(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(pt,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:w("Share")})}),l.jsxs("div",{className:"gh-portal-share-preview",children:[f&&l.jsx("img",{className:"gh-portal-share-preview-image",src:f,alt:"","data-testid":"share-preview-image"}),l.jsxs("div",{className:"gh-portal-share-preview-content",children:[m&&l.jsx("h2",{className:"gh-portal-share-preview-title",children:m}),h&&l.jsx("p",{className:"gh-portal-share-preview-excerpt",children:h}),(y||v||x)&&l.jsxs("div",{className:"gh-portal-share-preview-footer",children:[y&&l.jsx("img",{className:"gh-portal-share-preview-favicon",src:y,alt:"","data-testid":"share-preview-favicon"}),l.jsxs("div",{className:"gh-portal-share-preview-meta",children:[v&&l.jsx("span",{className:"gh-portal-share-preview-site",children:v}),v&&x&&l.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),x&&l.jsx("span",{className:"gh-portal-share-preview-author",children:x})]})]})]})]}),l.jsxs("div",{className:"gh-portal-share-actions",children:[l.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:I,"aria-label":w(t?"Copied":"Copy link"),title:w(t?"Copied":"Copy link"),children:[t?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Ro,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(RT,{})}),l.jsx("span",{className:"gh-portal-share-label",children:w(t?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:S.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":w("X (Twitter)"),title:w("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(UT,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:S.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":w("LinkedIn"),title:w("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx($T,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:S.email,target:"_blank",rel:"noopener noreferrer","aria-label":w("Email"),title:w("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(Kc,{})})}),l.jsxs("div",{className:"gh-portal-share-more",ref:u,children:[l.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:A,"aria-label":w("More options"),title:w("More options"),"aria-haspopup":"menu","aria-expanded":a,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(FT,{})})}),a&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":w("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:S.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(YT,{})}),l.jsx("span",{children:w("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:S.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(LT,{})}),l.jsx("span",{children:w("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:S.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(DT,{})}),l.jsx("span",{children:w("Bluesky")})]})]})]})]})]})}},sd=function({page:t}){return Object.keys(rd).includes(t)?t:"signup"},oy=function({page:t}){return t.includes("account")},BT=function({page:t}){return t.includes("offer")},WT=t=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},z.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"})),Cd=class Cd extends Xe.Component{render(){return l.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",children:[l.jsx(WT,{}),"Powered by Ghost"]})}};Cd.contextType=ve;let vs=Cd;const ry=()=>({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 GT({message:t}){return Za()?l.jsx("div",{className:"gh-portal-cookiebanner",children:t}):null}const Ed=class Ed extends Xe.Component{componentDidMount(){this.node&&!gt(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=e=>{e.key==="Escape"&&this.dismissPopup(e)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(e){const a=e.target&&e.target.tagName;(a!=="INPUT"||a==="INPUT"&&!e?.target?.value)&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){this.node&&gt(["preview"])&&this.node?.clientHeight!==this.lastContainerHeight&&(this.lastContainerHeight=this.node?.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(e){const{page:a,otcRef:o}=this.context;gt(["preview"])||o&&a==="magiclink"||a==="giftRedemption"||a==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:e}=this.context;sd({page:e});const a=rd[e];return l.jsx(a,{})}renderPopupNotification(){const{popupNotification:e}=this.context;return!e||!e.type?null:l.jsx(_c,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:e,pageQuery:a,site:o,customSiteUrl:s,lastPage:u}=this.context,m=is({site:o,pageQuery:a}).length;sd({page:e});const f={...ry().page[e]};let y="",v="regular",x="",S=e;switch(e){case"signup":x="Cookies must be enabled in your browser to sign up.";break;case"signin":x="Cookies must be enabled in your browser to sign in.";break;case"accountHome":S="account-home";break;case"accountProfile":S="account-profile";break;case"accountPlan":S="account-plan";break;default:x="Cookies must be enabled in your browser.",S=e;break}m>1&&!$n({site:o})&&na({site:o,pageQuery:a})&&e==="signup"&&(S+=" full-size",v="full"),(e==="gift"||e==="giftSuccess"||e==="giftRedemption")&&(S+=" full-size",v="full"),e==="magiclink"&&u==="gift"&&(S+=" full-size giftRedemption",v="full");const I=zo({site:o});(I&&m>2||!I&&m>1)&&e==="accountPlan"&&(S+=" full-size",v="full"),(e==="emailSuppressionFAQ"||e==="emailReceivingFAQ")&&(S+=" large-size");let A="gh-portal-popup-container";gt(["preview"])&&(S+=" preview"),gt(["preview"],{customSiteUrl:s})&&!o.disableBackground&&(A+=" preview"),gt(["dev"])&&(A+=" dev");const D=`${A} ${y} ${S}`,U=e==="gift"||e==="giftSuccess"||e==="giftRedemption"||e==="magiclink"&&u==="gift";return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+S,onClick:V=>this.handlePopupClose(V),children:[this.renderPopupNotification(),l.jsxs("div",{className:D,style:f,ref:V=>this.node=V,tabIndex:-1,children:[l.jsx(GT,{message:x}),this.renderActivePage(),v==="full"&&!U?l.jsx("div",{className:"gh-portal-powered inside "+(gt(["preview"])?"hidden ":"")+S,children:l.jsx(vs,{})}):""]})]}),e!=="share"&&!U&&l.jsx("div",{className:"gh-portal-powered outside "+(gt(["preview"])?"hidden ":"")+S,children:l.jsx(vs,{})})]})}};Ed.contextType=ve;let ld=Ed;const jd=class jd extends Xe.Component{constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){const a=rd[e];return l.jsx(a,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();const{page:a}=this.context;a==="giftRedemption"||a==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:e,brandColor:a}=this.context,o=K0({site:e}),s=a?`:root { --brandcolor: ${a} }`+o:o;return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:s}}),l.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:e,site:a,customSiteUrl:o}=this.context,s=ry(),u=window.innerWidth<480,d={...s.frame.common};let m="gh-portal-popup-background";return gt(["preview"])&&(s.modalContainer.zIndex="3999997"),gt(["preview"],{customSiteUrl:o})&&!a.disableBackground&&(m+=" preview"),gt(["dev"])&&(m+=" dev"),l.jsx("div",{style:s.modalContainer,children:l.jsxs(uc,{style:d,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[l.jsx("div",{className:m,onClick:h=>this.handlePopupClose(h)}),l.jsx(ld,{isMobile:u})]})})}render(){const{showPopup:e}=this.context;return e?this.renderFrameContainer():null}};jd.contextType=ve;let ud=jd;ws({products:cd({numOfProducts:1})});function Bt(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function VT(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function ws({title:t="The Blueprint",description:e="Thoughts, stories and ideas.",logo:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:o="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:s="https://portal.localhost",plans:u={monthly:5e3,yearly:15e4,currency:"USD"},products:d=cd({numOfProducts:1}),portalProducts:m=d.map(L=>L.id),accentColor:h="#45C32E",portalPlans:f=["free","monthly","yearly"],membersSignupAccess:y="all",freePriceName:v="Free",freePriceDescription:x="Free preview",paidMembersEnabled:S=!0,portalButton:I=!0,portalName:A=!0,portalButtonIcon:D="icon-1",portalButtonSignupText:U="Subscribe now",portalButtonStyle:V="icon-and-text",membersSupportAddress:ee="support@example.com",editorDefaultEmailRecipients:ne="visibility",newsletters:H=[],posts:re=HT(),commentsEnabled:ce,recommendations:pe=[],recommendationsEnabled:xe}={}){return{title:t,description:e,logo:a,icon:o,accent_color:h,url:s,plans:u,products:d,portal_products:m,members_signup_access:y,free_price_name:v,free_price_description:x,paid_members_enabled:S,portal_button:I,portal_name:A,portal_plans:f,portal_button_icon:D,portal_button_signup_text:U,portal_button_style:V,members_support_address:ee,comments_enabled:ce!=="off",newsletters:H,recommendations:pe,recommendations_enabled:!!xe,editor_default_email_recipients:ne,posts:re}}function sy({name:t="Black Friday",code:e="black-friday",displayTitle:a="Black Friday Sale!",displayDescription:o="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:s="percent",cadence:u="month",amount:d=50,duration:m="repeating",durationInMonths:h=null,currencyRestriction:f=!1,currency:y=null,status:v="active",tierId:x="",tierName:S="Basic",redemptionType:I="signup"}={}){return{id:`offer_${Bt()}`,name:t,code:e,display_title:a,display_description:o,type:s,cadence:u,amount:d,duration:m,duration_in_months:h,currency_restriction:f,currency:y,status:v,tier:{id:`${x}`,name:S},redemption_type:I}}function Nn({name:t="Jamie Larson",email:e="jamie@example.com",firstname:a="Jamie",subscriptions:o=[],paid:s=!1,status:u,avatarImage:d="",subscribed:m=!0,email_suppression:h={suppressed:!1,info:null},newsletters:f=[]}={}){const y={uuid:VT(),email:e,name:t,firstname:a,paid:s,subscribed:m,avatar_image:d,subscriptions:o,email_suppression:h,newsletters:f};return u!==void 0?y.status=u:s?y.status="paid":y.status="free",y}function HT({numOfPosts:t=3}={}){const e=[];for(let a=0;a<t;a++)e.push(qT({title:`Post ${a+1}`,slug:`post-${a+1}`}));return e.slice(0,t)}function qT({id:t=`post_${Bt()}`,title:e="Post",excerpt:a="Post excerpt",slug:o="post",featured:s=!1}={}){return{id:t,title:e,excerpt:a,slug:o,featured:s}}function cd({numOfProducts:t=3}={}){const a=[Ui({name:"Bronze",description:"Access to all members articles",monthlyPrice:bn({interval:"month",amount:700}),yearlyPrice:bn({interval:"year",amount:7e3}),numOfBenefits:2}),Ui({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:bn({interval:"month",amount:1200}),yearlyPrice:bn({interval:"year",amount:12e3}),numOfBenefits:3}),Ui({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:bn({interval:"month",amount:18e3}),yearlyPrice:bn({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,t),o=ly({});return[...a,o]}function Ui({type:t="paid",name:e="Basic",description:a="",id:o=`product_${Bt()}`,monthlyPrice:s=bn(),yearlyPrice:u=bn({interval:"year"}),numOfBenefits:d=2,trialDays:m=null}){return{id:o,name:e,description:a,monthlyPrice:t==="free"?null:s,yearlyPrice:t==="free"?null:u,type:t,benefits:uy({numOfBenefits:d}),trial_days:m}}function ly({name:t="Free tier",description:e="Free tier description",id:a=`product_${Bt()}`,numOfBenefits:o=2}){return{id:a,name:t,type:"free",description:e,benefits:uy({numOfBenefits:o})}}function uy({numOfBenefits:t}){const e=Bt();return[xs({name:`Limited early adopter pricing #${e.substring(0,6)}`}),xs({name:`Latest gear reviews #${e.substring(6,12)}`}),xs({name:`Weekly email newsletter #${e.substring(12,18)}`}),xs({name:`Listen to my podcast #${e.substring(18)}`})].slice(0,t)}function xs({id:t=`benefit_${Bt()}`,name:e="Benefit"}){return{id:t,name:e}}function bn({interval:t="month",amount:e=t==="month"?500:5e3,nickname:a=t==="month"?"Monthly":"Yearly",description:o=null,currency:s="usd",active:u=!0,id:d=`price_${Bt()}`}={}){return{id:d,active:u,nickname:a,currency:s,amount:e,interval:t,description:o,stripe_price_id:`price_${Bt()}`,stripe_product_id:`prod_${Bt()}`,type:"recurring"}}function ti({id:t=`sub_${Bt()}`,status:e="active",currency:a="USD",interval:o="year",amount:s=o==="month"?500:5e3,nickname:u=o==="month"?"Monthly":"Yearly",cardLast4:d="4242",offer:m=JT,priceId:h=`price_${Bt()}`,startDate:f="2021-10-05T03:18:30.000Z",currentPeriodEnd:y="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:v=!1,trialEndAt:x=null,nextPayment:S=null,tier:I=null}={}){return{id:t,customer:{id:`cus_${Bt()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Bt()}`,nickname:u,amount:s,interval:o,currency:a},offer:m,status:e,start_date:f,default_payment_card_last4:d,cancel_at_period_end:v,cancellation_reason:null,current_period_end:y,trial_end_at:x,next_payment:S,tier:I,price:{id:`stripe_price_${Bt()}`,price_id:h,nickname:u,amount:s,interval:o,type:"recurring",currency:a,product:{id:`stripe_prod_${Bt()}`,product_id:`prod_${Bt()}`}}}}function cy(){const t=cd({numOfProducts:1}),e=t.map(o=>o.id);return ws({products:t,portalPlans:["free","monthly","yearly"],portalProducts:e})}cy();const ZT=ws({products:[Ui({numOfBenefits:2,type:"free"})]}),JT=sy({tierId:ZT.products[0]?.id});Nn({status:"free"}),Nn({status:"paid",paid:!0,subscriptions:[ti()]}),Nn({status:"comped",paid:!0,subscriptions:[]}),Nn({status:"comped",paid:!0,subscriptions:[ti({amount:0})]}),Nn({status:"paid",paid:!0,subscriptions:[ti({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),cy();const Ss=[ly({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Ui({name:"The Blueprint",description:"",monthlyPrice:bn({interval:"month",amount:500}),yearlyPrice:bn({interval:"year",amount:5e3}),numOfBenefits:3}),Ui({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:bn({interval:"month",amount:1200}),yearlyPrice:bn({interval:"year",amount:11e3}),numOfBenefits:4})],Cs=ws({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:Ss,portalProducts:Ss.map(t=>t.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",paidMembersEnabled:!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}]}),dy=sy({tierId:Cs.products[1]?.id}),Bi={free:Nn({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:Nn({paid:!0,status:"paid",subscriptions:[ti({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:Nn({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:Nn({paid:!0,status:"comped",subscriptions:[ti({amount:0})]}),preview:Nn({paid:!0,status:"paid",subscriptions:[ti({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function KT(){if(!Ss||!Ss[1])return null;let t=Cs?.products?.[1].monthlyPrice,e=Nn({paid:!0,status:"paid",subscriptions:[ti({offer:null,priceId:t?.id,status:"active",currency:t?.currency,interval:t?.interval,amount:t?.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:Cs,member:e}}function XT(t){const e=t.getAttribute("href"),a=new URL(e,window.location.origin),o=["#/portal","#/share"],s=o.some(d=>a.hash.startsWith(d)),u=o.some(d=>e.startsWith(d));!a.hash||!s||u||a.origin===window.location.origin&&t.setAttribute("href",a.hash)}const QT="CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION";function _T({data:t,state:e}){return{page:t.page,popupNotification:null,lastPage:t.lastPage||null,pageData:t.pageData||e.pageData}}function eP({state:t}){return{showPopup:!t.showPopup}}function tP({data:t}){return{showPopup:!0,reloadOnPopupClose:!1,page:t.page,...t.pageQuery?{pageQuery:t.pageQuery}:{},...t.pageData?{pageData:t.pageData}:{}}}function nP({state:t}){return t.lastPage?{page:t.lastPage}:my({state:t})}function my({state:t}){ya();const e={...t.pageData||{}};return delete e.redirect,{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:t.page==="magiclink"?"":t.page,pageData:e}}function aP({data:t,state:e}){const{action:a="openNotification",status:o="success",autoHide:s=!0,closeable:u=!0,duration:d=2600,message:m=""}=t||{},h=Oo({type:a,status:o,autoHide:s,closeable:u,duration:d,state:e,message:m});return{notification:h,notificationSequence:h.count}}function iP(){return{notification:null}}async function oP({api:t,state:e}){try{return await t.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:rt({type:"signout:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to log out, please try again")})}}}async function rP({data:t,api:e,state:a}){try{const o=await e.member.getIntegrityToken(),s={...t,emailType:"signin",integrityToken:o,includeOTC:!0},{otc_ref:u,inboxLinks:d}=await e.member.sendMagicLink(s);return{page:"magiclink",lastPage:"signin",...u?{otcRef:u}:{},inboxLinks:d,pageData:{...a.pageData||{},email:(t?.email||"").trim()}}}catch(o){return{action:"signin:failed",popupNotification:rt({type:"signin:failed",autoHide:!1,closeable:!0,state:a,status:"error",message:ta(o,w("Failed to log in, please try again"))})}}}function sP({data:t,state:e}){const a=(t?.email||"").trim(),o=t?.otcRef,s=t?.inboxLinks;return o?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:o,inboxLinks:s,pageData:{...e.pageData||{},email:a},popupNotification:null}:{}}async function lP({data:t,api:e}){const a=w("Failed to verify code, please try again");try{const o=await e.member.getIntegrityToken(),s=await e.member.verifyOTC({...t,integrityToken:o});return s.redirectUrl?window.location.assign(s.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:ta(s.errors?.[0],a)}}catch(o){return{action:"verifyOTC:failed",actionErrorMessage:ta(o,a)}}}async function uP({data:t,state:e,api:a}){try{let{plan:o,tierId:s,cadence:u,email:d,name:m,newsletters:h,offerId:f}=t;m=m?.trim();let y;if(o.toLowerCase()==="free"){const v=await a.member.getIntegrityToken();({inboxLinks:y}=await a.member.sendMagicLink({emailType:"signup",integrityToken:v,...t,name:m}))}else{const v=e.member?{checkoutType:"upgrade"}:void 0;return(!s||!u)&&({tierId:s,cadence:u}=Io({site:e?.site,priceId:o})),await a.member.checkoutPlan({plan:o,tierId:s,cadence:u,email:d,name:m,newsletters:h,offerId:f,metadata:v}),{page:"loading"}}return{page:"magiclink",lastPage:"signup",inboxLinks:y,pageData:{...e.pageData||{},email:(d||"").trim()}}}catch(o){if(o.code===QT)return e.member?{action:"signup:failed",popupNotification:rt({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("You already have an active subscription.")})}:{page:"magiclink",lastPage:"signin",pageData:{...e.pageData||{},email:(t?.email||"").trim()},popupNotification:null};const s=ta(o,w("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:rt({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:s})}}}async function cP({data:t,state:e,api:a}){try{let{email:o,name:s,giftToken:u}=t;if(s=s?.trim(),e.member){await a.gift.redeem({token:u});const y=await a.member.sessionData(),v=Oo({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:e,message:bg({member:y})});return ya(),{action:"redeemGift:success",member:y,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:v,notificationSequence:v.count}}const d=await a.member.getIntegrityToken(),m=new URL(e?.site?.url||window.location.href);m.search=new URLSearchParams({giftRedemption:"true"}).toString(),m.hash="";const{otc_ref:h,inboxLinks:f}=await a.member.sendMagicLink({email:(o||"").trim(),emailType:"subscribe",integrityToken:d,includeOTC:!0,redirect:m.href,giftToken:u,...s?{name:s}:{}});return{page:"magiclink",lastPage:"gift",...h?{otcRef:h}:{},inboxLinks:f,pageData:{...e.pageData||{},email:(o||"").trim(),redirect:m.href}}}catch(o){const s=Oo({type:"giftRedeem",status:"error",autoHide:!1,closeable:!0,state:e,message:hs(o)});return ya(),{action:"redeemGift:failed",showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:s,notificationSequence:s.count}}}async function dP({data:t,state:e,api:a}){try{let{plan:o,offerId:s,tierId:u,cadence:d}=t;(!u||!d)&&({tierId:u,cadence:d}=Io({site:e?.site,priceId:o})),await a.member.checkoutPlan({plan:o,tierId:u,cadence:d,offerId:s,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:rt({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to process checkout, please try again")})}}}async function mP({state:t,api:e}){try{await e.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:rt({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:w("Failed to process checkout, please try again")})}}}async function pP({data:t,state:e,api:a}){try{const{tierId:o,cadence:s,email:u}=t;return await a.member.checkoutGift({tierId:o,cadence:s,...u?{email:u}:{}}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:rt({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to process checkout, please try again")})}}}async function hP({data:t,state:e,api:a}){try{const{plan:o,planId:s,subscriptionId:u,cancelAtPeriodEnd:d}=t,{tierId:m,cadence:h}=Io({site:e?.site,priceId:s});await a.member.updateSubscription({planName:o,tierId:m,cadence:h,subscriptionId:u,cancelAtPeriodEnd:d,planId:s});const f=await a.member.sessionData(),y="updateSubscription:success";return{action:y,popupNotification:rt({type:y,autoHide:!0,closeable:!0,state:e,status:"success",message:w("Subscription plan updated successfully")}),page:"accountHome",member:f}}catch{return{action:"updateSubscription:failed",popupNotification:rt({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to update subscription, please try again")})}}}async function fP({data:t,state:e,api:a}){try{const{subscriptionId:o,cancellationReason:s}=t;return await a.member.updateSubscription({subscriptionId:o,smartCancel:!0,cancellationReason:s}),{action:"cancelSubscription:success",page:"accountHome",member:await a.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:rt({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to cancel subscription, please try again")})}}}async function gP({data:t,state:e,api:a}){try{const{subscriptionId:o}=t;return await a.member.updateSubscription({subscriptionId:o,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await a.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:rt({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to cancel subscription, please try again")})}}}async function yP({data:t,state:e,api:a}){try{const{offerId:o,subscriptionId:s}=t;return await a.member.applyOffer({offerId:o,subscriptionId:s}),{action:"applyOffer:success",page:"accountHome",member:await a.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:rt({type:"applyOffer:success",autoHide:!0,closeable:!0,state:e,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:rt({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:"Failed to apply offer, please try again"})}}}async function bP({data:t,state:e,api:a}){try{await a.member.editBilling(t)}catch{return{action:"editBilling:failed",popupNotification:rt({type:"editBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to update billing information, please try again")})}}}async function kP({data:t,state:e,api:a}){try{await a.member.manageBilling(t)}catch{return{action:"manageBilling:failed",popupNotification:rt({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to open billing portal, please try again")})}}}async function vP(){return{popupNotification:null}}async function wP({data:t,state:e}){let{action:a,message:o=""}=t;return a=a||"showPopupNotification:success",{popupNotification:rt({type:a,autoHide:!0,closeable:!0,state:e,status:"success",message:o})}}async function xP({data:t,state:e,api:a}){try{const{newsletters:o,enableCommentNotifications:s,enableUpdatesAndAnnouncements:u}=t;if(!o&&s===void 0&&u===void 0)return{};const d={};return o&&(d.newsletters=o),s!==void 0&&(d.enableCommentNotifications=s),u!==void 0&&(d.enableUpdatesAndAnnouncements=u),{action:"updateNewsletterPref:success",member:await a.member.update(d)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:rt({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:w("Failed to update newsletter settings")})}}}async function SP({state:t,api:e}){try{return await e.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:rt({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:t,status:"success",message:w("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:rt({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:w("Your email has failed to resubscribe, please try again")})}}}async function CP({data:t,state:e,api:a}){try{const{subscribed:o}=t,s=await a.member.update({subscribed:o});if(!s)throw new Error("Failed to update newsletter");const u="updateNewsletter:success";return{action:u,member:s,popupNotification:rt({type:u,autoHide:!0,closeable:!0,state:e,status:"success",message:w("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:rt({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:w("Failed to update newsletter settings")})}}}async function EP({data:t,state:e,api:a}){const{email:o}=t,s=qE({member:e.member});if(o!==s)try{return await a.member.updateEmailAddress({email:o}),{success:!0}}catch(u){return{success:!1,error:u}}return null}async function jP({data:t,state:e,api:a}){const o=t?.name?.trim();if(JE({member:e.member})!==o)try{const u=await a.member.update({name:o});if(!u)throw new Error("Failed to update member");return{member:u,success:!0}}catch(u){return{success:!1,error:u}}return null}async function TP({state:t,api:e}){if(t.member)try{const a=await e.member.sessionData();return a?{member:a,success:!0,action:"refreshMemberData:success"}:null}catch(a){return{success:!1,error:a,action:"refreshMemberData:failed"}}return null}async function PP({data:t,state:e,api:a}){const[o,s]=await Promise.all([jP({data:t,state:e,api:a}),EP({data:t,state:e,api:a})]);if(o&&s){if(s.success)return{action:"updateProfile:success",...o.success?{member:o.member}:{},page:"accountHome",popupNotification:rt({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:w("Check your inbox to verify email update")})};const u=o.success?w("Failed to send verification email"):w("Failed to update account data");return{action:"updateProfile:failed",...o.success?{member:o.member}:{},popupNotification:rt({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:u,state:e})}}else if(o){const u=o.success?"updateProfile:success":"updateProfile:failed",d=o.success?"success":"error",m=o.success?w("Account details updated successfully"):w("Failed to update account details");return{action:u,...o.success?{member:o.member}:{},...o.success?{page:"accountHome"}:{},popupNotification:rt({type:u,autoHide:o.success,closeable:!0,status:d,state:e,message:m})}}else if(s){const u=s.success?"updateProfile:success":"updateProfile:failed",d=s.success?"success":"error";let m="";return s.error?m=ta(s.error,w("Failed to send verification email")):m=w("Check your inbox to verify email update"),{action:u,...s.success?{page:"accountHome"}:{},popupNotification:rt({type:u,autoHide:s.success,closeable:!0,status:d,state:e,message:m})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:rt({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:w("Account details updated successfully")})}}async function zP({data:{siteUrl:t},state:e}){const a=ks({siteUrl:t,apiUrl:"not-defined"}),{member:o}=e,s=window.location.href,u=Zf(),d=await a.member.getIntegrityToken();return await a.member.sendMagicLink({emailType:"signup",name:o.name,email:o.email,autoRedirect:!1,integrityToken:d,customUrlHistory:e.site.outbound_link_tagging?[{time:Date.now(),referrerSource:u,referrerMedium:"Ghost Recommendations",referrerUrl:s}]:[]}),{}}function NP({data:{recommendationId:t},api:e}){try{const a=localStorage.getItem("ghost-recommendations-clicked"),o=a?JSON.parse(a):[];if(o.includes(t))return;o.push(t),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(o))}catch{}return e.recommendations.trackClicked({recommendationId:t}),{}}async function IP({data:{recommendationId:t},api:e}){return e.recommendations.trackSubscribed({recommendationId:t}),{}}const AP={togglePopup:eP,openPopup:tP,closePopup:my,switchPage:_T,openNotification:aP,closeNotification:iP,back:nP,signout:oP,signin:rP,startSigninOTCFromCustomForm:sP,verifyOTC:lP,signup:uP,redeemGift:cP,updateSubscription:hP,cancelSubscription:fP,continueSubscription:gP,applyOffer:yP,updateNewsletter:CP,updateProfile:PP,refreshMemberData:TP,clearPopupNotification:vP,editBilling:bP,manageBilling:kP,checkoutPlan:dP,continueGiftSubscription:mP,checkoutGift:pP,updateNewsletterPreference:xP,showPopupNotification:wP,removeEmailFromSuppressionList:SP,oneClickSubscribe:zP,trackRecommendationClicked:NP,trackRecommendationSubscribed:IP};async function OP({action:t,data:e,state:a,api:o}){const s=AP[t];return s?await s({data:e,state:a,api:o})||{}:{}}function py(t,e){t&&(t.innerText=e)}function MP(t,e,a){e.classList.add("error");const o=w("There was an error sending the email, please try again");py(a,ta(t,o))}async function DP({event:t,form:e,errorEl:a,siteUrl:o,submitHandler:s,doAction:u,captureException:d}){e.removeEventListener("submit",s),t.preventDefault(),a&&(a.innerText=""),e.classList.remove("success","invalid","error");let m=t.target.querySelector("input[data-members-email]"),h=t.target.querySelector("input[data-members-name]"),f=e?.dataset?.membersAutoredirect||"true",y=m?.value,v=(h?.value||"").trim()||void 0,x,S=[],I=[],A=t.target.querySelectorAll("input[data-members-label]")||[];for(let ne=0;ne<A.length;++ne)S.push(A[ne].value);let D=t.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let ne=0;ne<D.length;++ne)I.push({name:D[ne].value});e.dataset.membersForm&&(x=e.dataset.membersForm);const U=x==="signin"&&e?.dataset?.membersOtc==="true";e.classList.add("loading");const V=Ni(),ee={email:y,emailType:x,labels:S,name:v,autoRedirect:f==="true"};U&&(ee.includeOTC=!0),V&&(ee.urlHistory=V),D.length>0?ee.newsletters=I:(t.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(ee.newsletters=[]);try{const H=await(await fetch(`${o}/members/api/integrity-token/`,{method:"GET"})).text(),re=await fetch(`${o}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...ee,integrityToken:H})});if(e.addEventListener("submit",s),e.classList.remove("loading"),re.ok){e.classList.add("success");let ce;if(U)try{ce=await re.clone().json()}catch{ce=void 0}const pe=ce?.otc_ref;if(pe&&typeof u=="function")try{u("startSigninOTCFromCustomForm",{email:(y||"").trim(),otcRef:pe,inboxLinks:ce?.inboxLinks})}catch(xe){console.error(xe),d?.(xe)}}else{const ce=await zn.fromApiResponse(re),pe=ta(ce,w("Failed to send magic link email"));py(a,pe),e.classList.add("error")}}catch(ne){MP(ne,e,a)}}function FP({event:t,el:e,errorEl:a,siteUrl:o,site:s,member:u,clickHandler:d}){e.removeEventListener("click",d),t.preventDefault();let m=e.dataset.membersPlan,h=FE(s,m.toLowerCase()),f=e.dataset.membersSuccess,y=e.dataset.membersCancel,v,x;f&&(v=new URL(f,window.location.href).href),y&&(x=new URL(y,window.location.href).href),a&&(a.innerText=""),e.classList.add("loading");const S=u?{checkoutType:"upgrade"}:{},I=Ni();return I&&(S.urlHistory=I),fetch(`${o}/members/api/session`,{credentials:"same-origin"}).then(function(A){return A.ok?A.text():null}).then(function(A){return fetch(`${o}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...h,identity:A,successUrl:v,cancelUrl:x,metadata:S})}).then(function(D){if(!D.ok)throw new Error(w("Could not create Stripe checkout session"));return D.json()})}).then(function(A){return A.url?window.location.assign(A.url):window.Stripe(A.publicKey).redirectToCheckout({sessionId:A.sessionId}).then(function(U){if(U.error)throw new Error(U.error.message)})}).catch(function(A){console.error(A),e.addEventListener("click",d),e.classList.remove("loading"),a&&(a.innerText=A.message),e.classList.add("error")})}function YP({siteUrl:t,site:e={},member:a,offers:o=[],doAction:s,captureException:u}={}){if(!t)return;t=t.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(m){let h=m.querySelector("[data-members-error]");function f(y){DP({event:y,errorEl:h,form:m,siteUrl:t,submitHandler:f,doAction:s,captureException:u})}m.addEventListener("submit",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(m){let h=m.querySelector("[data-members-error]");function f(y){FP({el:m,event:y,errorEl:h,member:a,site:e,siteUrl:t,clickHandler:f})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(m){let h=m.querySelector("[data-members-error]"),f=m.dataset.membersSuccess,y=m.dataset.membersCancel,v,x;f&&(v=new URL(f,window.location.href).href),y&&(x=new URL(y,window.location.href).href);function S(I){m.removeEventListener("click",S),I.preventDefault(),h&&(h.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(A){return A.ok?A.text():null}).then(function(A){return fetch(`${t}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:A,successUrl:v,cancelUrl:x})}).then(function(D){if(!D.ok)throw new Error(w("Could not create Stripe checkout session"));return D.json()})}).then(function(A){return window.Stripe(A.publicKey).redirectToCheckout({sessionId:A.sessionId})}).then(function(A){if(A.error)throw new Error(w(A.error.message))}).catch(function(A){console.error(A),m.addEventListener("click",S),m.classList.remove("loading"),h&&(h.innerText=A.message),m.classList.add("error")})}m.addEventListener("click",S)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(m){let h=m.querySelector("[data-members-error]"),f=m.dataset.membersReturn,y;f&&(y=new URL(f,window.location.href).href);function v(x){m.removeEventListener("click",v),x.preventDefault(),h&&(h.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${t}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,returnUrl:y})}).then(function(I){if(!I.ok)throw new Error(w("Could not create Stripe billing portal session"));return I.json()})}).then(function(S){return window.location.assign(S.url)}).catch(function(S){console.error(S),m.addEventListener("click",v),m.classList.remove("loading"),h&&(h.innerText=S.message),m.classList.add("error")})}m.addEventListener("click",v)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(m){function h(f){m.removeEventListener("click",h),f.preventDefault(),m.classList.remove("error"),m.classList.add("loading"),fetch(`${t}/members/api/session`,{method:"DELETE"}).then(function(y){y.ok?window.location.replace(t):(m.addEventListener("click",h),m.classList.remove("loading"),m.classList.add("error"))})}m.addEventListener("click",h)});const d=(o||[]).some(m=>m.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(m){let h=m.parentElement.querySelector("[data-members-error]");function f(y){y.preventDefault();let v=m.dataset.membersCancelSubscription;if(d){s("openPopup",{page:"accountPlan",pageData:{subscriptionId:v,action:"cancel"}});return}return m.removeEventListener("click",f),m.classList.remove("error"),m.classList.add("loading"),h&&(h.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,smart_cancel:!0})})}).then(function(x){x.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),h&&(h.innerText=w("There was an error cancelling your subscription, please try again.")))})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(m){let h=m.parentElement.querySelector("[data-members-error]");function f(y){m.removeEventListener("click",f),y.preventDefault(),m.classList.remove("error"),m.classList.add("loading");let v=m.dataset.membersContinueSubscription;return h&&(h.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,cancel_at_period_end:!1})})}).then(function(x){x.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),h&&(h.innerText=w("There was an error continuing your subscription, please try again.")))})}m.addEventListener("click",f)})}const hy=t=>{try{return decodeURIComponent(t)}catch{return null}},RP={staleGiftRedemptionRequest:!0},$P={showPopup:!0,site:Cs,member:Bi.free,page:"accountEmail",...KT(),pageData:dy};function LP({site:t,children:e}){const{portal_sentry:a}=t||{};return a&&a.dsn?l.jsx(cu,{children:e}):l.jsx(l.Fragment,{children:e})}class UP extends Xe.Component{constructor(e){super(e),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:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,a){if(a.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=window.document?.body?.style?.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"&&a.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),YP({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Co})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(e=>{e.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e),document.body.appendChild(e);const a=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),a}setupCustomTriggerButton(){this.clickHandler=async o=>{o.preventDefault();const s=o.currentTarget,u=s&&s.dataset.portal,d=this.getPageFromLinkPath(u);if(!d)return;const{page:m,pageQuery:h,pageData:f}=d;if(this.state.initStatus==="success"){if(m==="gift"&&!Pi({site:this.state.site})){this.invalidateGiftRedemptionRequest(),ya();return}if(m==="giftRedemption"&&f?.token){const y=this.startGiftRedemptionRequest(f.token),v=await this.fetchGiftRedemptionData({token:f.token});if(!this.isCurrentGiftRedemptionRequest(y))return;this.setState(v);return}this.invalidateGiftRedemptionRequest(),h&&h!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:h}):this.dispatchAction("openPopup",{page:m,pageQuery:h,pageData:f})}};const e="[data-portal]",a="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(e)||[],this.customTriggerButtons.forEach(o=>{o.classList.add(a),o.removeEventListener("click",this.clickHandler),o.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){const e="gh-portal-open",a="gh-portal-close";this.customTriggerButtons?.forEach(o=>{const s=this.state.showPopup?e:a,u=this.state.showPopup?a:e;o.classList.add(s),o.classList.remove(u)})}startGiftRedemptionRequest(e){return this._redemptionRequestId+=1,this.currentRedemptionToken=e,{requestId:this._redemptionRequestId,token:e}}invalidateGiftRedemptionRequest(){this._redemptionRequestId+=1,this.currentRedemptionToken=null}isCurrentGiftRedemptionRequest({requestId:e,token:a}){return this._redemptionRequestId===e&&this.currentRedemptionToken===a}async initSetup(){try{const{site:e,member:a,offers:o,page:s,showPopup:u,popupNotification:d,notification:m,notificationSequence:h,lastPage:f,pageQuery:y,pageData:v}=await this.fetchData(),x=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||"en";Xr.changeLanguage(x);const S={site:e,member:a,offers:o,page:s,lastPage:f,pageQuery:y,showPopup:u,pageData:v,popupNotification:d,notification:m,notificationSequence:h,dir:Xr.dir()||"ltr",action:"init:success",initStatus:"success",locale:x};if(this.setState(S,()=>{this.handleSignupQuery({site:e,pageQuery:y,member:a})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!a){const I=document.querySelectorAll("[data-lexical-signup-form]");I.length>0&&I.forEach(A=>{A.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error("[Portal] Failed to initialize:",e),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:e,member:a,offers:o}=await this.fetchApiData(),{site:s,...u}=this.fetchDevData(),d=await this.fetchLinkData(e,a),{site:m,...h}=d?.staleGiftRedemptionRequest?{}:d,{site:f,...y}=this.fetchPreviewData(),{site:v,...x}=this.fetchNotificationData();return{member:a,offers:o,page:"",site:{...e,...m,...f,...v,...s,plans:{...(s||{}).plans,...(e||{}).plans,...(f||{}).plans}},...u,...h,...x,...y}}fetchDevData(){return gt(["dev"])&&!this.state.customSiteUrl?$P:gt(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(e=""){const a=new URLSearchParams(e),o={};for(let s of a.entries()){const u=s[0],d=decodeURIComponent(s[1]);u==="name"?o.name=d||"":u==="code"?o.code=d||"":u==="display_title"?o.display_title=d||"":u==="display_description"?o.display_description=d||"":u==="type"?o.type=d||"":u==="cadence"?o.cadence=d||"":u==="duration"?o.duration=d||"":u==="duration_in_months"&&!isNaN(Number(d))?o.duration_in_months=Number(d):u==="amount"&&!isNaN(Number(d))?o.amount=Number(d):u==="currency"?o.currency=d||"":u==="status"?o.status=d||"":u==="tier_id"?o.tier={id:d||dy.tier.id}:u==="redemption_type"&&(o.redemption_type=d||"signup")}if(o.redemption_type==="retention"){const s=Bi.preview?.subscriptions?.[0]?.id;return{page:"accountPlan",offers:[o],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:o}}fetchQueryStrData(e=""){const a=new URLSearchParams(e),o={site:{plans:{}}},s=[];let u,d=null,m,h,f;for(let y of a.entries()){const v=y[0],x=decodeURIComponent(y[1]);if(v==="button")o.site.portal_button=JSON.parse(x);else if(v==="name")o.site.portal_name=JSON.parse(x);else if(v==="isFree"&&JSON.parse(x))s.push("free");else if(v==="isMonthly"&&JSON.parse(x))s.push("monthly");else if(v==="isYearly"&&JSON.parse(x))s.push("yearly");else if(v==="portalPrices")u=x?x.split(","):[];else if(v==="portalProducts")d=x?x.split(","):[];else if(v==="page"&&x)o.page=x;else if(v==="accentColor"&&(x===""||x))o.site.accent_color=x;else if(v==="buttonIcon"&&x)o.site.portal_button_icon=x;else if(v==="signupButtonText")o.site.portal_button_signup_text=x||"";else if(v==="signupTermsHtml")o.site.portal_signup_terms_html=x||"";else if(v==="signupCheckboxRequired")o.site.portal_signup_checkbox_required=JSON.parse(x);else if(v==="buttonStyle"&&x)o.site.portal_button_style=x;else if(v==="monthlyPrice"&&!isNaN(Number(x)))o.site.plans.monthly=Number(x),m=Number(x);else if(v==="yearlyPrice"&&!isNaN(Number(x)))o.site.plans.yearly=Number(x),h=Number(x);else if(v==="currency"&&x){const S=x.toUpperCase();o.site.plans.currency=S,o.site.plans.currency_symbol=Pt(S),f=S}else v==="disableBackground"?o.site.disableBackground=JSON.parse(x):v==="membersSignupAccess"&&x?o.site.members_signup_access=x:v==="portalDefaultPlan"&&x?o.site.portal_default_plan=x:v==="transistorPortalSettings"&&x&&(o.site.transistor_portal_settings=JSON.parse(x))}return o.site.portal_plans=s,o.site.portal_products=d,u?o.site.portal_plans=u:m&&h&&f&&(o.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:f,amount:m,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:f,amount:h,type:"recurring",interval:"year"}]),o}fetchNotificationData(){const{type:e,status:a,duration:o,autoHide:s,closeable:u}=vg({billingOnly:!0})||{};return["stripe:billing-update"].includes(e)?a==="success"?{showPopup:!0,popupNotification:rt({type:e,status:a,duration:o,closeable:u,autoHide:s,state:this.state,message:a==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{const a=await this.GhostApi.gift.fetchRedemptionData({token:e});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:e,gift:a?.gifts?.[0]||null}}}catch(a){ya();const o=Oo({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:hs(a)});return{showPopup:!1,pageData:null,notification:o,notificationSequence:o.count}}}async fetchLinkData(e,a){this.invalidateGiftRedemptionRequest();const o=new URLSearchParams(window.location.search);if(o.get("stripe")==="gift-purchase-success"){const I=o.get("gift_token"),A=o.get("gift_tier"),D=o.get("gift_cadence");if(fs(["stripe","gift_token","gift_tier","gift_cadence"]),I)return{showPopup:!0,page:"giftSuccess",pageData:{token:I,tierId:A,cadence:D}}}if(o.get("action")==="unsubscribe")return o.get("key")&&o.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:o.get("uuid"),key:o.get("key"),newsletterUuid:o.get("newsletter"),comments:o.get("comments"),updatesAndAnnouncements:o.get("updatesandannouncements")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:o.get("newsletter"),action:"unsubscribe",redirect:e.url+"#/portal/account/newsletters"}};if($E({site:e})&&o.get("action")==="signup"&&o.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[s,u]=window.location.hash.substr(1).split("?"),d=new URLSearchParams(u??""),m=/^(?:(\w+?))?\/monthly$/,h=/^(?:(\w+?))?\/yearly$/,f=/^offers\/(\w+?)\/?$/,y=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,v=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,x=/^\/share\/?$/,S=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(s&&S.test(s)){const[,I,A]=s.match(S),D=parseInt(A);if(D===1||D===0)return a||d.get("uuid")&&d.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:a?null:d.get("uuid"),key:a?null:d.get("key"),postId:I,score:D}}:{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/feedback/${I}/${D}/`}}}if(s&&y.test(s)){const[,I]=s.match(y),A=hy(I);if(!A)return{};const D=this.startGiftRedemptionRequest(A),U=await this.fetchGiftRedemptionData({token:A});return this.isCurrentGiftRedemptionRequest(D)?U:RP}if(s&&x.test(s))return{showPopup:!0,page:"share"};if(s&&v.test(s)){const[,I]=s.match(v),{page:A,pageQuery:D,pageData:U}=this.getPageFromLinkPath(I,e)||{};if(!a&&A&&oy({page:A}))return{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/portal/${I}/`}};if(A==="gift"&&!Pi({site:e}))return ya(),{};const V=["accountPlan","accountProfile"].includes(A)?"accountHome":null,ee=!(["monthly","yearly"].includes(D)||m.test(D)||h.test(D)||f.test(D)),ne=d.get("redirect"),H=A==="signin"&&ne?{...U||{},redirect:ne}:U;return{showPopup:ee,...A?{page:A}:{},...D?{pageQuery:D}:{},...H?{pageData:H}:{},...V?{lastPage:V}:{}}}return{}}fetchPreviewData(){const[,e]=window.location.hash.substr(1).split("?");if(gt(["preview"])){let a={};try{gt(["offerPreview"])?a=this.fetchOfferQueryStrData(e):a=this.fetchQueryStrData(e)}catch(o){return Co(o),{}}return{...a,showPopup:!0}}return{}}getColorOverride(){const e=document.querySelector("script[data-ghost]");return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:e,customSiteUrl:a,apiUrl:o,apiKey:s}=this.props;try{this.GhostApi=this.props.api||ks({siteUrl:e,apiUrl:o,apiKey:s});const{site:u,member:d,offers:m}=await this.GhostApi.init(),h=this.getColorOverride();return h&&(u.accent_color=h),this.setupFirstPromoter({site:u,member:d}),this.setupSentry({site:u}),{site:u,member:d,offers:m}}catch(u){if(gt(["dev","test"],{customSiteUrl:a}))return{};throw u}}setupSentry({site:e}){if(gt(["test"]))return null;const{portal_sentry:a,portal_version:o,version:s}=e,d=`portal@2.69.10|ghost@${s}`;a&&a.dsn&&xC({dsn:a.dsn,environment:a.env||"development",release:d,beforeSend:m=>zE({event:m})?m:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:a}){if(gt(["test"]))return null;const o=ZE({site:e});let s=bc({site:e});if(s=s?.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),o&&s){const u=document.createElement("script");u.type="text/javascript",u.async=!0,u.src="https://cdn.firstpromoter.com/fprom.js",u.onload=u.onreadystatechange=function(){let m=this.readyState;if(!m||m==="complete"||m==="loaded")try{if(window.$FPROM.init(o,s),o1({member:a})){const h=a.email,f=a.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:h,uid:f});else{const y=window._fprom||[];window._fprom=y,y.push(["event","signup"]),y.push(["email",h]),y.push(["uid",f])}}}catch{}};const d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(u,d)}}async dispatchAction(e,a){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{const o=await OP({action:e,data:a,state:this.state,api:this.GhostApi});this.setState(o),o&&o.action&&!o.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(o){if(console.error(`[Portal] Failed to dispatch action: ${e}`,o),a&&a.throwErrors)throw o;const s=rt({type:`${e}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:o}});this.setState({action:`${e}:failed`,actionErrorMessage:ta(o,w("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:s})}}async updateStateForPreviewLinks(){const{site:e,...a}=this.fetchPreviewData(),o=await this.fetchLinkData(this.state.site,this.state.member);if(o?.staleGiftRedemptionRequest)return;const{site:s,...u}=o,d={site:{...this.state.site,...s||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(s||{}).plans,...(e||{}).plans}},...u,...a};this.handleSignupQuery({site:d.site,pageQuery:d.pageQuery}),this.setState(d)}async handleOfferQuery({site:e,offerId:a,member:o=this.state.member}){if(ya(),!(!Yn({member:o})||ba({member:o}))){const u=Oo({type:"offer:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:w("You already have an active subscription.")});await this.dispatchAction("closePopup"),this.setState({notification:u,notificationSequence:u.count});return}try{const d=(await this.GhostApi.site.offer({offerId:a}))?.offers[0];if(!d||!d.tier||wc({offer:d})||!_E({site:e,offer:d}))return;this.dispatchAction("openPopup",{page:"offer",pageData:d})}catch{}}handleSignupQuery({site:e,pageQuery:a,member:o}){const s=/^offers\/(\w+?)\/?$/;let u=a;if(s.test(a||"")){const[,m]=a.match(s);this.handleOfferQuery({site:e,offerId:m,member:o});return}_f({site:e,pageQuery:a})&&(u=_f({site:e,pageQuery:a}));const d=YE({site:e,priceId:u});if(a&&a!=="free"){ya();const m=d?.id||u;m!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:h,cadence:f}=Io({site:e,priceId:m});this.dispatchAction("signup",{plan:m,tierId:h,cadence:f})}}getPageFromLinkPath(e){const a=/^signup\/?(?:\/(\w+?))?\/?$/,o=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,s=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,u=/^offers\/(\w+?)\/?$/,d=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e==="")return{page:"default"};if(d.test(e)){const[,m]=e.match(d),h=hy(m);return h?{page:"giftRedemption",pageData:{token:h}}:null}else{if(u.test(e))return{pageQuery:e};if(e==="signup")return{page:"signup"};if(o.test(e)){const[,m]=e.match(o);return{page:"signup",pageQuery:`${m}/monthly`}}else if(s.test(e)){const[,m]=e.match(s);return{page:"signup",pageQuery:`${m}/yearly`}}else if(a.test(e)){const[,m]=e.match(a);return{page:"signup",pageQuery:m}}else{if(e==="signup/free")return{page:"signup",pageQuery:"free"};if(e==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(e==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(e==="signin")return{page:"signin"};if(e==="account")return{page:"accountHome"};if(e==="account/plans")return{page:"accountPlan"};if(e==="account/profile")return{page:"accountProfile"};if(e==="account/newsletters")return{page:"accountEmail"};if(e==="support")return{page:"support"};if(e==="support/success")return{page:"supportSuccess"};if(e==="support/error")return{page:"supportError"};if(e==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(e==="gift")return{page:"gift"};if(e==="share")return{page:"share"};if(e==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(e==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}}return{page:"default"}}getAccentColor(){const{accent_color:e}=this.state.site||{};return Hj(e)}getRetentionPreviewMember({site:e,offers:a}){const o=(a||[]).find(f=>wc({offer:f})),s=o?.tier?.id,u=s?Xa({site:e,productId:s}):null,d=u?o.cadence==="year"?u.yearlyPrice:u.monthlyPrice:null,m=Bi.preview,h=m?.subscriptions?.[0];return!h||!u||!d?m:{...m,subscriptions:[{...h,plan:{...h.plan,amount:d.amount,interval:d.interval,currency:d.currency.toUpperCase()},price:{...h.price,price_id:d.id,amount:d.amount,interval:d.interval,currency:d.currency,product:{...h.price?.product,product_id:u.id}},tier:{id:u.id,name:u.name}}]}}getContextPage({site:e,page:a,member:o}){if(!a||a==="default"){const s=$n({site:e})||!na({site:e})?"signin":"signup";a=o?"accountHome":s}return sd({page:a})}getContextMember({site:e,page:a,member:o,offers:s,pageData:u,customSiteUrl:d}){return gt(["dev","preview"],{customSiteUrl:d})?oy({page:a})||BT({page:a})?gt(["dev"],{customSiteUrl:d})?o||Bi.free:gt(["preview"])?a==="accountPlan"&&u?.action==="cancel"?this.getRetentionPreviewMember({site:e,offers:s}):Bi.preview:Bi.paid:null:o}getContextFromState(){const{site:e,member:a,offers:o,action:s,actionErrorMessage:u,page:d,lastPage:m,showPopup:h,pageQuery:f,pageData:y,popupNotification:v,notification:x,customSiteUrl:S,dir:I,scrollbarWidth:A,otcRef:D,inboxLinks:U}=this.state,V=this.getContextPage({site:e,page:d,member:a}),ee=this.getContextMember({site:e,page:V,member:a,offers:o,pageData:y,customSiteUrl:S});return{api:this.GhostApi,site:e,offers:o,action:s,actionErrorMessage:u,brandColor:this.getAccentColor(),page:V,pageQuery:f,pageData:y,member:ee,lastPage:m,showPopup:h,popupNotification:v,notification:x,customSiteUrl:S,dir:I,scrollbarWidth:A,otcRef:D,inboxLinks:U,doAction:(ne,H)=>this.dispatchAction(ne,H)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const e=o=>{const s=o.currentTarget.dataset.recommendation;s?this.dispatchAction("trackRecommendationClicked",{recommendationId:s}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},a=this.getRecommendationButtons();for(const o of a)o.addEventListener("click",e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"], a[href*="#/share"]').forEach(XT)}render(){return this.state.initStatus==="success"?l.jsx(LP,{site:this.state.site,children:l.jsxs(ve.Provider,{value:this.getContextFromState(),children:[l.jsx(ud,{}),l.jsx(Sc,{}),l.jsx(Dc,{})]})}):null}}const fy="ghost-portal-root";function BP(){const t=document.createElement("div");t.id=fy,t.setAttribute("data-testid","portal-root"),document.body.appendChild(t)}function WP(){const t=document.querySelector("script[data-ghost]");if(t){const e=t.dataset.i18n==="true",a=t.dataset.ghost,o=t.dataset.key,s=t.dataset.api,u=t.dataset.locale;return{siteUrl:a,apiKey:o,apiUrl:s,siteI18nEnabled:e,locale:u}}return{}}function GP(){const t=new URL(window.location.href);t.searchParams.get("token")&&(t.searchParams.delete("token"),window.history.replaceState({},document.title,t.href))}function VP(){const{siteUrl:t,apiKey:e,apiUrl:a,siteI18nEnabled:o,locale:s}=WP(),u=t||window.location.origin;BP(),GP(),Ik.render(l.jsx(Xe.StrictMode,{children:l.jsx(UP,{siteUrl:u,customSiteUrl:t,apiKey:e,apiUrl:a,siteI18nEnabled:o,locale:s})}),document.getElementById(fy))}VP()}));
4520
+ `),o=[];return t&&o.push(`subject=${encodeURIComponent(t)}`),a&&o.push(`body=${encodeURIComponent(a)}`),`mailto:${o.length?`?${o.join("&")}`:""}`},AT=({shareTitle:t,shareUrl:e})=>Wo("https://www.linkedin.com/shareArticle",{mini:"true",url:e,title:t}),OT=()=>{const t=NT(),e=t.document,a=t.location,o=(I,A="content")=>e.querySelector(I)?.[A]||"",s=o('link[rel="canonical"]',"href")||a.origin+a.pathname+a.search,u=o('meta[property="og:title"]')||e.title||"",d=o('meta[property="og:description"]')||o('meta[name="description"]')||"",m=o('meta[property="og:image"]')||o('meta[name="twitter:image"]')||"",h=o('link[rel="icon"]',"href")||o('link[rel="shortcut icon"]',"href")||o('link[rel="apple-touch-icon"]',"href"),f=o('meta[name="author"]'),y=(f&&!/^https?:\/\//i.test(f)?f:"")||o('meta[name="twitter:creator"]')||"";let v=o('meta[property="og:site_name"]')||o('meta[name="application-name"]')||"";if(!v)try{v=new URL(s).hostname.replace(/^www\./,"")}catch{v=""}const x=[u,s].filter(Boolean).join(" ").trim(),S={twitter:Wo("https://twitter.com/intent/tweet",{url:s,text:u}),facebook:Wo("https://www.facebook.com/sharer/sharer.php",{u:s}),email:IT({shareTitle:u,shareUrl:s}),threads:Wo("https://www.threads.net/intent/post",{text:x}),linkedin:AT({shareTitle:u,shareUrl:s}),bluesky:Wo("https://bsky.app/intent/compose",{text:x})};return{shareUrl:s,shareTitle:u,shareExcerpt:d,shareImage:m,shareFavicon:h,shareSiteName:v,shareAuthor:y,socialLinks:S}},MT=()=>{const[t]=z.useState(OT);return t},DT=t=>z.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...t},z.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"})),FT=t=>z.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",...t},z.createElement("circle",{cx:12,cy:12,r:1}),z.createElement("circle",{cx:19,cy:12,r:1}),z.createElement("circle",{cx:5,cy:12,r:1})),YT=t=>z.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",...t},z.createElement("defs",{id:"defs13"},z.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},z.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),z.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},z.createElement("g",{id:"g19"},z.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},z.createElement("g",{id:"g27",transform:"translate(600,350)"},z.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"})),z.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},z.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"})))))),RT=t=>z.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",...t},z.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"}),z.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"})),$T=t=>z.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...t},z.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),z.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"}),z.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"})),LT=t=>z.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},z.createElement("g",{clipPath:"url(#clip0_351_18008)"},z.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"})),z.createElement("defs",null,z.createElement("clipPath",{id:"clip0_351_18008"},z.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),UT=t=>z.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...t},z.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"})),rd={signin:nd,signup:Zc,accountHome:ad,accountPlan:Rc,accountProfile:id,accountEmail:xT,signupNewsletter:Lc,unsubscribe:ET,magiclink:Qc,loading:$i,offer:ed,feedback:S0,emailSuppressed:jT,emailSuppressionFAQ:TT,emailReceivingFAQ:PT,support:zT,supportSuccess:z0,supportError:td,recommendations:W0,gift:c0,giftRedemption:I0,giftSuccess:D0,share:()=>{const[t,e]=z.useState(!1),[a,o]=z.useState(!1),s=z.useRef(),u=z.useRef(null),{shareUrl:d,shareTitle:m,shareExcerpt:h,shareImage:f,shareFavicon:y,shareSiteName:v,shareAuthor:x,socialLinks:S}=MT();z.useEffect(()=>()=>{clearTimeout(s.current)},[]),z.useEffect(()=>{if(!a)return;const U=u.current?.ownerDocument||document,V=ne=>{u.current&&!u.current.contains(ne.target)&&(ne.stopPropagation(),ne.preventDefault(),o(!1))},ee=ne=>{ne.key==="Escape"&&o(!1)};return U.addEventListener("click",V,!0),U.addEventListener("keydown",ee),()=>{U.removeEventListener("click",V,!0),U.removeEventListener("keydown",ee)}},[a]);const I=async()=>{await _g(d)&&(e(!0),clearTimeout(s.current),s.current=setTimeout(()=>{e(!1)},2e3))},A=()=>{o(U=>!U)},D=()=>{o(!1)};return l.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[l.jsx(pt,{}),l.jsx("div",{className:"gh-portal-share-header",children:l.jsx("h1",{className:"gh-portal-main-title",children:w("Share")})}),l.jsxs("div",{className:"gh-portal-share-preview",children:[f&&l.jsx("img",{className:"gh-portal-share-preview-image",src:f,alt:"","data-testid":"share-preview-image"}),l.jsxs("div",{className:"gh-portal-share-preview-content",children:[m&&l.jsx("h2",{className:"gh-portal-share-preview-title",children:m}),h&&l.jsx("p",{className:"gh-portal-share-preview-excerpt",children:h}),(y||v||x)&&l.jsxs("div",{className:"gh-portal-share-preview-footer",children:[y&&l.jsx("img",{className:"gh-portal-share-preview-favicon",src:y,alt:"","data-testid":"share-preview-favicon"}),l.jsxs("div",{className:"gh-portal-share-preview-meta",children:[v&&l.jsx("span",{className:"gh-portal-share-preview-site",children:v}),v&&x&&l.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),x&&l.jsx("span",{className:"gh-portal-share-preview-author",children:x})]})]})]})]}),l.jsxs("div",{className:"gh-portal-share-actions",children:[l.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:I,"aria-label":w(t?"Copied":"Copy link"),title:w(t?"Copied":"Copy link"),children:[t?l.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:l.jsx(Ro,{})}):l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(RT,{})}),l.jsx("span",{className:"gh-portal-share-label",children:w(t?"Copied":"Copy link")})]}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:S.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":w("X (Twitter)"),title:w("X (Twitter)"),children:l.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:l.jsx(UT,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:S.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":w("LinkedIn"),title:w("LinkedIn"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx($T,{})})}),l.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:S.email,target:"_blank",rel:"noopener noreferrer","aria-label":w("Email"),title:w("Email"),children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(Kc,{})})}),l.jsxs("div",{className:"gh-portal-share-more",ref:u,children:[l.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:A,"aria-label":w("More options"),title:w("More options"),"aria-haspopup":"menu","aria-expanded":a,children:l.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:l.jsx(FT,{})})}),a&&l.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":w("More options"),children:[l.jsxs("a",{className:"gh-portal-share-more-item",href:S.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(YT,{})}),l.jsx("span",{children:w("Facebook")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:S.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(LT,{})}),l.jsx("span",{children:w("Threads")})]}),l.jsxs("a",{className:"gh-portal-share-more-item",href:S.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:D,children:[l.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:l.jsx(DT,{})}),l.jsx("span",{children:w("Bluesky")})]})]})]})]})]})}},sd=function({page:t}){return Object.keys(rd).includes(t)?t:"signup"},oy=function({page:t}){return t.includes("account")},BT=function({page:t}){return t.includes("offer")},WT=t=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},z.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"})),Cd=class Cd extends Xe.Component{render(){return l.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",children:[l.jsx(WT,{}),"Powered by Ghost"]})}};Cd.contextType=ve;let vs=Cd;const ry=()=>({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 GT({message:t}){return Za()?l.jsx("div",{className:"gh-portal-cookiebanner",children:t}):null}const Ed=class Ed extends Xe.Component{componentDidMount(){this.node&&!gt(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=e=>{e.key==="Escape"&&this.dismissPopup(e)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(e){const a=e.target&&e.target.tagName;(a!=="INPUT"||a==="INPUT"&&!e?.target?.value)&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){this.node&&gt(["preview"])&&this.node?.clientHeight!==this.lastContainerHeight&&(this.lastContainerHeight=this.node?.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(e){const{page:a,otcRef:o}=this.context;gt(["preview"])||o&&a==="magiclink"||a==="giftRedemption"||a==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:e}=this.context;sd({page:e});const a=rd[e];return l.jsx(a,{})}renderPopupNotification(){const{popupNotification:e}=this.context;return!e||!e.type?null:l.jsx(_c,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:e,pageQuery:a,site:o,customSiteUrl:s,lastPage:u}=this.context,m=is({site:o,pageQuery:a}).length;sd({page:e});const f={...ry().page[e]};let y="",v="regular",x="",S=e;switch(e){case"signup":x="Cookies must be enabled in your browser to sign up.";break;case"signin":x="Cookies must be enabled in your browser to sign in.";break;case"accountHome":S="account-home";break;case"accountProfile":S="account-profile";break;case"accountPlan":S="account-plan";break;default:x="Cookies must be enabled in your browser.",S=e;break}m>1&&!$n({site:o})&&na({site:o,pageQuery:a})&&e==="signup"&&(S+=" full-size",v="full"),(e==="gift"||e==="giftSuccess"||e==="giftRedemption")&&(S+=" full-size",v="full"),e==="magiclink"&&u==="gift"&&(S+=" full-size giftRedemption",v="full");const I=zo({site:o});(I&&m>2||!I&&m>1)&&e==="accountPlan"&&(S+=" full-size",v="full"),(e==="emailSuppressionFAQ"||e==="emailReceivingFAQ")&&(S+=" large-size");let A="gh-portal-popup-container";gt(["preview"])&&(S+=" preview"),gt(["preview"],{customSiteUrl:s})&&!o.disableBackground&&(A+=" preview"),gt(["dev"])&&(A+=" dev");const D=`${A} ${y} ${S}`,U=e==="gift"||e==="giftSuccess"||e==="giftRedemption"||e==="magiclink"&&u==="gift";return this.sendPortalPreviewReadyEvent(),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"gh-portal-popup-wrapper "+S,onClick:V=>this.handlePopupClose(V),children:[this.renderPopupNotification(),l.jsxs("div",{className:D,style:f,ref:V=>this.node=V,tabIndex:-1,children:[l.jsx(GT,{message:x}),this.renderActivePage(),v==="full"&&!U?l.jsx("div",{className:"gh-portal-powered inside "+(gt(["preview"])?"hidden ":"")+S,children:l.jsx(vs,{})}):""]})]}),e!=="share"&&!U&&l.jsx("div",{className:"gh-portal-powered outside "+(gt(["preview"])?"hidden ":"")+S,children:l.jsx(vs,{})})]})}};Ed.contextType=ve;let ld=Ed;const jd=class jd extends Xe.Component{constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){const a=rd[e];return l.jsx(a,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();const{page:a}=this.context;a==="giftRedemption"||a==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:e,brandColor:a}=this.context,o=K0({site:e}),s=a?`:root { --brandcolor: ${a} }`+o:o;return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:s}}),l.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:e,site:a,customSiteUrl:o}=this.context,s=ry(),u=window.innerWidth<480,d={...s.frame.common};let m="gh-portal-popup-background";return gt(["preview"])&&(s.modalContainer.zIndex="3999997"),gt(["preview"],{customSiteUrl:o})&&!a.disableBackground&&(m+=" preview"),gt(["dev"])&&(m+=" dev"),l.jsx("div",{style:s.modalContainer,children:l.jsxs(uc,{style:d,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[l.jsx("div",{className:m,onClick:h=>this.handlePopupClose(h)}),l.jsx(ld,{isMobile:u})]})})}render(){const{showPopup:e}=this.context;return e?this.renderFrameContainer():null}};jd.contextType=ve;let ud=jd;ws({products:cd({numOfProducts:1})});function Bt(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function VT(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function ws({title:t="The Blueprint",description:e="Thoughts, stories and ideas.",logo:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:o="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:s="https://portal.localhost",plans:u={monthly:5e3,yearly:15e4,currency:"USD"},products:d=cd({numOfProducts:1}),portalProducts:m=d.map(L=>L.id),accentColor:h="#45C32E",portalPlans:f=["free","monthly","yearly"],membersSignupAccess:y="all",freePriceName:v="Free",freePriceDescription:x="Free preview",paidMembersEnabled:S=!0,portalButton:I=!0,portalName:A=!0,portalButtonIcon:D="icon-1",portalButtonSignupText:U="Subscribe now",portalButtonStyle:V="icon-and-text",membersSupportAddress:ee="support@example.com",editorDefaultEmailRecipients:ne="visibility",newsletters:H=[],posts:re=HT(),commentsEnabled:ce,recommendations:pe=[],recommendationsEnabled:xe}={}){return{title:t,description:e,logo:a,icon:o,accent_color:h,url:s,plans:u,products:d,portal_products:m,members_signup_access:y,free_price_name:v,free_price_description:x,paid_members_enabled:S,portal_button:I,portal_name:A,portal_plans:f,portal_button_icon:D,portal_button_signup_text:U,portal_button_style:V,members_support_address:ee,comments_enabled:ce!=="off",newsletters:H,recommendations:pe,recommendations_enabled:!!xe,editor_default_email_recipients:ne,posts:re}}function sy({name:t="Black Friday",code:e="black-friday",displayTitle:a="Black Friday Sale!",displayDescription:o="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:s="percent",cadence:u="month",amount:d=50,duration:m="repeating",durationInMonths:h=null,currencyRestriction:f=!1,currency:y=null,status:v="active",tierId:x="",tierName:S="Basic",redemptionType:I="signup"}={}){return{id:`offer_${Bt()}`,name:t,code:e,display_title:a,display_description:o,type:s,cadence:u,amount:d,duration:m,duration_in_months:h,currency_restriction:f,currency:y,status:v,tier:{id:`${x}`,name:S},redemption_type:I}}function Nn({name:t="Jamie Larson",email:e="jamie@example.com",firstname:a="Jamie",subscriptions:o=[],paid:s=!1,status:u,avatarImage:d="",subscribed:m=!0,email_suppression:h={suppressed:!1,info:null},newsletters:f=[]}={}){const y={uuid:VT(),email:e,name:t,firstname:a,paid:s,subscribed:m,avatar_image:d,subscriptions:o,email_suppression:h,newsletters:f};return u!==void 0?y.status=u:s?y.status="paid":y.status="free",y}function HT({numOfPosts:t=3}={}){const e=[];for(let a=0;a<t;a++)e.push(qT({title:`Post ${a+1}`,slug:`post-${a+1}`}));return e.slice(0,t)}function qT({id:t=`post_${Bt()}`,title:e="Post",excerpt:a="Post excerpt",slug:o="post",featured:s=!1}={}){return{id:t,title:e,excerpt:a,slug:o,featured:s}}function cd({numOfProducts:t=3}={}){const a=[Ui({name:"Bronze",description:"Access to all members articles",monthlyPrice:bn({interval:"month",amount:700}),yearlyPrice:bn({interval:"year",amount:7e3}),numOfBenefits:2}),Ui({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:bn({interval:"month",amount:1200}),yearlyPrice:bn({interval:"year",amount:12e3}),numOfBenefits:3}),Ui({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:bn({interval:"month",amount:18e3}),yearlyPrice:bn({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,t),o=ly({});return[...a,o]}function Ui({type:t="paid",name:e="Basic",description:a="",id:o=`product_${Bt()}`,monthlyPrice:s=bn(),yearlyPrice:u=bn({interval:"year"}),numOfBenefits:d=2,trialDays:m=null}){return{id:o,name:e,description:a,monthlyPrice:t==="free"?null:s,yearlyPrice:t==="free"?null:u,type:t,benefits:uy({numOfBenefits:d}),trial_days:m}}function ly({name:t="Free tier",description:e="Free tier description",id:a=`product_${Bt()}`,numOfBenefits:o=2}){return{id:a,name:t,type:"free",description:e,benefits:uy({numOfBenefits:o})}}function uy({numOfBenefits:t}){const e=Bt();return[xs({name:`Limited early adopter pricing #${e.substring(0,6)}`}),xs({name:`Latest gear reviews #${e.substring(6,12)}`}),xs({name:`Weekly email newsletter #${e.substring(12,18)}`}),xs({name:`Listen to my podcast #${e.substring(18)}`})].slice(0,t)}function xs({id:t=`benefit_${Bt()}`,name:e="Benefit"}){return{id:t,name:e}}function bn({interval:t="month",amount:e=t==="month"?500:5e3,nickname:a=t==="month"?"Monthly":"Yearly",description:o=null,currency:s="usd",active:u=!0,id:d=`price_${Bt()}`}={}){return{id:d,active:u,nickname:a,currency:s,amount:e,interval:t,description:o,stripe_price_id:`price_${Bt()}`,stripe_product_id:`prod_${Bt()}`,type:"recurring"}}function ti({id:t=`sub_${Bt()}`,status:e="active",currency:a="USD",interval:o="year",amount:s=o==="month"?500:5e3,nickname:u=o==="month"?"Monthly":"Yearly",cardLast4:d="4242",offer:m=JT,priceId:h=`price_${Bt()}`,startDate:f="2021-10-05T03:18:30.000Z",currentPeriodEnd:y="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:v=!1,trialEndAt:x=null,nextPayment:S=null,tier:I=null}={}){return{id:t,customer:{id:`cus_${Bt()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Bt()}`,nickname:u,amount:s,interval:o,currency:a},offer:m,status:e,start_date:f,default_payment_card_last4:d,cancel_at_period_end:v,cancellation_reason:null,current_period_end:y,trial_end_at:x,next_payment:S,tier:I,price:{id:`stripe_price_${Bt()}`,price_id:h,nickname:u,amount:s,interval:o,type:"recurring",currency:a,product:{id:`stripe_prod_${Bt()}`,product_id:`prod_${Bt()}`}}}}function cy(){const t=cd({numOfProducts:1}),e=t.map(o=>o.id);return ws({products:t,portalPlans:["free","monthly","yearly"],portalProducts:e})}cy();const ZT=ws({products:[Ui({numOfBenefits:2,type:"free"})]}),JT=sy({tierId:ZT.products[0]?.id});Nn({status:"free"}),Nn({status:"paid",paid:!0,subscriptions:[ti()]}),Nn({status:"comped",paid:!0,subscriptions:[]}),Nn({status:"comped",paid:!0,subscriptions:[ti({amount:0})]}),Nn({status:"paid",paid:!0,subscriptions:[ti({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),cy();const Ss=[ly({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Ui({name:"The Blueprint",description:"",monthlyPrice:bn({interval:"month",amount:500}),yearlyPrice:bn({interval:"year",amount:5e3}),numOfBenefits:3}),Ui({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:bn({interval:"month",amount:1200}),yearlyPrice:bn({interval:"year",amount:11e3}),numOfBenefits:4})],Cs=ws({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:Ss,portalProducts:Ss.map(t=>t.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",paidMembersEnabled:!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}]}),dy=sy({tierId:Cs.products[1]?.id}),Bi={free:Nn({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:Nn({paid:!0,status:"paid",subscriptions:[ti({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:Nn({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:Nn({paid:!0,status:"comped",subscriptions:[ti({amount:0})]}),preview:Nn({paid:!0,status:"paid",subscriptions:[ti({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function KT(){if(!Ss||!Ss[1])return null;let t=Cs?.products?.[1].monthlyPrice,e=Nn({paid:!0,status:"paid",subscriptions:[ti({offer:null,priceId:t?.id,status:"active",currency:t?.currency,interval:t?.interval,amount:t?.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:Cs,member:e}}function XT(t){const e=t.getAttribute("href"),a=new URL(e,window.location.origin),o=["#/portal","#/share"],s=o.some(d=>a.hash.startsWith(d)),u=o.some(d=>e.startsWith(d));!a.hash||!s||u||a.origin===window.location.origin&&t.setAttribute("href",a.hash)}const QT="CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION";function _T({data:t,state:e}){return{page:t.page,popupNotification:null,lastPage:t.lastPage||null,pageData:t.pageData||e.pageData}}function eP({state:t}){return{showPopup:!t.showPopup}}function tP({data:t}){return{showPopup:!0,reloadOnPopupClose:!1,page:t.page,...t.pageQuery?{pageQuery:t.pageQuery}:{},...t.pageData?{pageData:t.pageData}:{}}}function nP({state:t}){return t.lastPage?{page:t.lastPage}:my({state:t})}function my({state:t}){ya();const e={...t.pageData||{}};return delete e.redirect,{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:t.page==="magiclink"?"":t.page,pageData:e}}function aP({data:t,state:e}){const{action:a="openNotification",status:o="success",autoHide:s=!0,closeable:u=!0,duration:d=2600,message:m=""}=t||{},h=Oo({type:a,status:o,autoHide:s,closeable:u,duration:d,state:e,message:m});return{notification:h,notificationSequence:h.count}}function iP(){return{notification:null}}async function oP({api:t,state:e}){try{return await t.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:rt({type:"signout:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to log out, please try again")})}}}async function rP({data:t,api:e,state:a}){try{const o=await e.member.getIntegrityToken(),s={...t,emailType:"signin",integrityToken:o,includeOTC:!0},{otc_ref:u,inboxLinks:d}=await e.member.sendMagicLink(s);return{page:"magiclink",lastPage:"signin",...u?{otcRef:u}:{},inboxLinks:d,pageData:{...a.pageData||{},email:(t?.email||"").trim()}}}catch(o){return{action:"signin:failed",popupNotification:rt({type:"signin:failed",autoHide:!1,closeable:!0,state:a,status:"error",message:ta(o,w("Failed to log in, please try again"))})}}}function sP({data:t,state:e}){const a=(t?.email||"").trim(),o=t?.otcRef,s=t?.inboxLinks;return o?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:o,inboxLinks:s,pageData:{...e.pageData||{},email:a},popupNotification:null}:{}}async function lP({data:t,api:e}){const a=w("Failed to verify code, please try again");try{const o=await e.member.getIntegrityToken(),s=await e.member.verifyOTC({...t,integrityToken:o});return s.redirectUrl?window.location.assign(s.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:ta(s.errors?.[0],a)}}catch(o){return{action:"verifyOTC:failed",actionErrorMessage:ta(o,a)}}}async function uP({data:t,state:e,api:a}){try{let{plan:o,tierId:s,cadence:u,email:d,name:m,newsletters:h,offerId:f}=t;m=m?.trim();let y;if(o.toLowerCase()==="free"){const v=await a.member.getIntegrityToken();({inboxLinks:y}=await a.member.sendMagicLink({emailType:"signup",integrityToken:v,...t,name:m}))}else{const v=e.member?{checkoutType:"upgrade"}:void 0;return(!s||!u)&&({tierId:s,cadence:u}=Io({site:e?.site,priceId:o})),await a.member.checkoutPlan({plan:o,tierId:s,cadence:u,email:d,name:m,newsletters:h,offerId:f,metadata:v}),{page:"loading"}}return{page:"magiclink",lastPage:"signup",inboxLinks:y,pageData:{...e.pageData||{},email:(d||"").trim()}}}catch(o){if(o.code===QT)return e.member?{action:"signup:failed",popupNotification:rt({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("You already have an active subscription.")})}:{page:"magiclink",lastPage:"signin",pageData:{...e.pageData||{},email:(t?.email||"").trim()},popupNotification:null};const s=ta(o,w("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:rt({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:s})}}}async function cP({data:t,state:e,api:a}){try{let{email:o,name:s,giftToken:u}=t;if(s=s?.trim(),e.member){await a.gift.redeem({token:u});const y=await a.member.sessionData(),v=Oo({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:e,message:bg({member:y})});return ya(),{action:"redeemGift:success",member:y,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:v,notificationSequence:v.count}}const d=await a.member.getIntegrityToken(),m=new URL(e?.site?.url||window.location.href);m.search=new URLSearchParams({giftRedemption:"true"}).toString(),m.hash="";const{otc_ref:h,inboxLinks:f}=await a.member.sendMagicLink({email:(o||"").trim(),emailType:"subscribe",integrityToken:d,includeOTC:!0,redirect:m.href,giftToken:u,...s?{name:s}:{}});return{page:"magiclink",lastPage:"gift",...h?{otcRef:h}:{},inboxLinks:f,pageData:{...e.pageData||{},email:(o||"").trim(),redirect:m.href}}}catch(o){const s=Oo({type:"giftRedeem",status:"error",autoHide:!1,closeable:!0,state:e,message:hs(o)});return ya(),{action:"redeemGift:failed",showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:s,notificationSequence:s.count}}}async function dP({data:t,state:e,api:a}){try{let{plan:o,offerId:s,tierId:u,cadence:d}=t;(!u||!d)&&({tierId:u,cadence:d}=Io({site:e?.site,priceId:o})),await a.member.checkoutPlan({plan:o,tierId:u,cadence:d,offerId:s,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:rt({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to process checkout, please try again")})}}}async function mP({state:t,api:e}){try{await e.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:rt({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:w("Failed to process checkout, please try again")})}}}async function pP({data:t,state:e,api:a}){try{const{tierId:o,cadence:s,email:u}=t;return await a.member.checkoutGift({tierId:o,cadence:s,...u?{email:u}:{}}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:rt({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to process checkout, please try again")})}}}async function hP({data:t,state:e,api:a}){try{const{plan:o,planId:s,subscriptionId:u,cancelAtPeriodEnd:d}=t,{tierId:m,cadence:h}=Io({site:e?.site,priceId:s});await a.member.updateSubscription({planName:o,tierId:m,cadence:h,subscriptionId:u,cancelAtPeriodEnd:d,planId:s});const f=await a.member.sessionData(),y="updateSubscription:success";return{action:y,popupNotification:rt({type:y,autoHide:!0,closeable:!0,state:e,status:"success",message:w("Subscription plan updated successfully")}),page:"accountHome",member:f}}catch{return{action:"updateSubscription:failed",popupNotification:rt({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to update subscription, please try again")})}}}async function fP({data:t,state:e,api:a}){try{const{subscriptionId:o,cancellationReason:s}=t;return await a.member.updateSubscription({subscriptionId:o,smartCancel:!0,cancellationReason:s}),{action:"cancelSubscription:success",page:"accountHome",member:await a.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:rt({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to cancel subscription, please try again")})}}}async function gP({data:t,state:e,api:a}){try{const{subscriptionId:o}=t;return await a.member.updateSubscription({subscriptionId:o,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await a.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:rt({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to cancel subscription, please try again")})}}}async function yP({data:t,state:e,api:a}){try{const{offerId:o,subscriptionId:s}=t;return await a.member.applyOffer({offerId:o,subscriptionId:s}),{action:"applyOffer:success",page:"accountHome",member:await a.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:rt({type:"applyOffer:success",autoHide:!0,closeable:!0,state:e,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:rt({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:"Failed to apply offer, please try again"})}}}async function bP({data:t,state:e,api:a}){try{await a.member.editBilling(t)}catch{return{action:"editBilling:failed",popupNotification:rt({type:"editBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to update billing information, please try again")})}}}async function kP({data:t,state:e,api:a}){try{await a.member.manageBilling(t)}catch{return{action:"manageBilling:failed",popupNotification:rt({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:w("Failed to open billing portal, please try again")})}}}async function vP(){return{popupNotification:null}}async function wP({data:t,state:e}){let{action:a,message:o=""}=t;return a=a||"showPopupNotification:success",{popupNotification:rt({type:a,autoHide:!0,closeable:!0,state:e,status:"success",message:o})}}async function xP({data:t,state:e,api:a}){try{const{newsletters:o,enableCommentNotifications:s,enableUpdatesAndAnnouncements:u}=t;if(!o&&s===void 0&&u===void 0)return{};const d={};return o&&(d.newsletters=o),s!==void 0&&(d.enableCommentNotifications=s),u!==void 0&&(d.enableUpdatesAndAnnouncements=u),{action:"updateNewsletterPref:success",member:await a.member.update(d)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:rt({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:w("Failed to update newsletter settings")})}}}async function SP({state:t,api:e}){try{return await e.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:rt({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:t,status:"success",message:w("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:rt({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:w("Your email has failed to resubscribe, please try again")})}}}async function CP({data:t,state:e,api:a}){try{const{subscribed:o}=t,s=await a.member.update({subscribed:o});if(!s)throw new Error("Failed to update newsletter");const u="updateNewsletter:success";return{action:u,member:s,popupNotification:rt({type:u,autoHide:!0,closeable:!0,state:e,status:"success",message:w("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:rt({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:w("Failed to update newsletter settings")})}}}async function EP({data:t,state:e,api:a}){const{email:o}=t,s=qE({member:e.member});if(o!==s)try{return await a.member.updateEmailAddress({email:o}),{success:!0}}catch(u){return{success:!1,error:u}}return null}async function jP({data:t,state:e,api:a}){const o=t?.name?.trim();if(JE({member:e.member})!==o)try{const u=await a.member.update({name:o});if(!u)throw new Error("Failed to update member");return{member:u,success:!0}}catch(u){return{success:!1,error:u}}return null}async function TP({state:t,api:e}){if(t.member)try{const a=await e.member.sessionData();return a?{member:a,success:!0,action:"refreshMemberData:success"}:null}catch(a){return{success:!1,error:a,action:"refreshMemberData:failed"}}return null}async function PP({data:t,state:e,api:a}){const[o,s]=await Promise.all([jP({data:t,state:e,api:a}),EP({data:t,state:e,api:a})]);if(o&&s){if(s.success)return{action:"updateProfile:success",...o.success?{member:o.member}:{},page:"accountHome",popupNotification:rt({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:w("Check your inbox to verify email update")})};const u=o.success?w("Failed to send verification email"):w("Failed to update account data");return{action:"updateProfile:failed",...o.success?{member:o.member}:{},popupNotification:rt({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:u,state:e})}}else if(o){const u=o.success?"updateProfile:success":"updateProfile:failed",d=o.success?"success":"error",m=o.success?w("Account details updated successfully"):w("Failed to update account details");return{action:u,...o.success?{member:o.member}:{},...o.success?{page:"accountHome"}:{},popupNotification:rt({type:u,autoHide:o.success,closeable:!0,status:d,state:e,message:m})}}else if(s){const u=s.success?"updateProfile:success":"updateProfile:failed",d=s.success?"success":"error";let m="";return s.error?m=ta(s.error,w("Failed to send verification email")):m=w("Check your inbox to verify email update"),{action:u,...s.success?{page:"accountHome"}:{},popupNotification:rt({type:u,autoHide:s.success,closeable:!0,status:d,state:e,message:m})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:rt({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:w("Account details updated successfully")})}}async function zP({data:{siteUrl:t},state:e}){const a=ks({siteUrl:t,apiUrl:"not-defined"}),{member:o}=e,s=window.location.href,u=Zf(),d=await a.member.getIntegrityToken();return await a.member.sendMagicLink({emailType:"signup",name:o.name,email:o.email,autoRedirect:!1,integrityToken:d,customUrlHistory:e.site.outbound_link_tagging?[{time:Date.now(),referrerSource:u,referrerMedium:"Ghost Recommendations",referrerUrl:s}]:[]}),{}}function NP({data:{recommendationId:t},api:e}){try{const a=localStorage.getItem("ghost-recommendations-clicked"),o=a?JSON.parse(a):[];if(o.includes(t))return;o.push(t),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(o))}catch{}return e.recommendations.trackClicked({recommendationId:t}),{}}async function IP({data:{recommendationId:t},api:e}){return e.recommendations.trackSubscribed({recommendationId:t}),{}}const AP={togglePopup:eP,openPopup:tP,closePopup:my,switchPage:_T,openNotification:aP,closeNotification:iP,back:nP,signout:oP,signin:rP,startSigninOTCFromCustomForm:sP,verifyOTC:lP,signup:uP,redeemGift:cP,updateSubscription:hP,cancelSubscription:fP,continueSubscription:gP,applyOffer:yP,updateNewsletter:CP,updateProfile:PP,refreshMemberData:TP,clearPopupNotification:vP,editBilling:bP,manageBilling:kP,checkoutPlan:dP,continueGiftSubscription:mP,checkoutGift:pP,updateNewsletterPreference:xP,showPopupNotification:wP,removeEmailFromSuppressionList:SP,oneClickSubscribe:zP,trackRecommendationClicked:NP,trackRecommendationSubscribed:IP};async function OP({action:t,data:e,state:a,api:o}){const s=AP[t];return s?await s({data:e,state:a,api:o})||{}:{}}function py(t,e){t&&(t.innerText=e)}function MP(t,e,a){e.classList.add("error");const o=w("There was an error sending the email, please try again");py(a,ta(t,o))}async function DP({event:t,form:e,errorEl:a,siteUrl:o,submitHandler:s,doAction:u,captureException:d}){e.removeEventListener("submit",s),t.preventDefault(),a&&(a.innerText=""),e.classList.remove("success","invalid","error");let m=t.target.querySelector("input[data-members-email]"),h=t.target.querySelector("input[data-members-name]"),f=e?.dataset?.membersAutoredirect||"true",y=m?.value,v=(h?.value||"").trim()||void 0,x,S=[],I=[],A=t.target.querySelectorAll("input[data-members-label]")||[];for(let ne=0;ne<A.length;++ne)S.push(A[ne].value);let D=t.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let ne=0;ne<D.length;++ne)I.push({name:D[ne].value});e.dataset.membersForm&&(x=e.dataset.membersForm);const U=x==="signin"&&e?.dataset?.membersOtc==="true";e.classList.add("loading");const V=Ni(),ee={email:y,emailType:x,labels:S,name:v,autoRedirect:f==="true"};U&&(ee.includeOTC=!0),V&&(ee.urlHistory=V),D.length>0?ee.newsletters=I:(t.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(ee.newsletters=[]);try{const H=await(await fetch(`${o}/members/api/integrity-token/`,{method:"GET"})).text(),re=await fetch(`${o}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...ee,integrityToken:H})});if(e.addEventListener("submit",s),e.classList.remove("loading"),re.ok){e.classList.add("success");let ce;if(U)try{ce=await re.clone().json()}catch{ce=void 0}const pe=ce?.otc_ref;if(pe&&typeof u=="function")try{u("startSigninOTCFromCustomForm",{email:(y||"").trim(),otcRef:pe,inboxLinks:ce?.inboxLinks})}catch(xe){console.error(xe),d?.(xe)}}else{const ce=await zn.fromApiResponse(re),pe=ta(ce,w("Failed to send magic link email"));py(a,pe),e.classList.add("error")}}catch(ne){MP(ne,e,a)}}function FP({event:t,el:e,errorEl:a,siteUrl:o,site:s,member:u,clickHandler:d}){e.removeEventListener("click",d),t.preventDefault();let m=e.dataset.membersPlan,h=FE(s,m.toLowerCase()),f=e.dataset.membersSuccess,y=e.dataset.membersCancel,v,x;f&&(v=new URL(f,window.location.href).href),y&&(x=new URL(y,window.location.href).href),a&&(a.innerText=""),e.classList.add("loading");const S=u?{checkoutType:"upgrade"}:{},I=Ni();return I&&(S.urlHistory=I),fetch(`${o}/members/api/session`,{credentials:"same-origin"}).then(function(A){return A.ok?A.text():null}).then(function(A){return fetch(`${o}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...h,identity:A,successUrl:v,cancelUrl:x,metadata:S})}).then(function(D){if(!D.ok)throw new Error(w("Could not create Stripe checkout session"));return D.json()})}).then(function(A){return A.url?window.location.assign(A.url):window.Stripe(A.publicKey).redirectToCheckout({sessionId:A.sessionId}).then(function(U){if(U.error)throw new Error(U.error.message)})}).catch(function(A){console.error(A),e.addEventListener("click",d),e.classList.remove("loading"),a&&(a.innerText=A.message),e.classList.add("error")})}function YP({siteUrl:t,site:e={},member:a,offers:o=[],doAction:s,captureException:u}={}){if(!t)return;t=t.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(m){let h=m.querySelector("[data-members-error]");function f(y){DP({event:y,errorEl:h,form:m,siteUrl:t,submitHandler:f,doAction:s,captureException:u})}m.addEventListener("submit",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(m){let h=m.querySelector("[data-members-error]");function f(y){FP({el:m,event:y,errorEl:h,member:a,site:e,siteUrl:t,clickHandler:f})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(m){let h=m.querySelector("[data-members-error]"),f=m.dataset.membersSuccess,y=m.dataset.membersCancel,v,x;f&&(v=new URL(f,window.location.href).href),y&&(x=new URL(y,window.location.href).href);function S(I){m.removeEventListener("click",S),I.preventDefault(),h&&(h.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(A){return A.ok?A.text():null}).then(function(A){return fetch(`${t}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:A,successUrl:v,cancelUrl:x})}).then(function(D){if(!D.ok)throw new Error(w("Could not create Stripe checkout session"));return D.json()})}).then(function(A){return window.Stripe(A.publicKey).redirectToCheckout({sessionId:A.sessionId})}).then(function(A){if(A.error)throw new Error(w(A.error.message))}).catch(function(A){console.error(A),m.addEventListener("click",S),m.classList.remove("loading"),h&&(h.innerText=A.message),m.classList.add("error")})}m.addEventListener("click",S)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(m){let h=m.querySelector("[data-members-error]"),f=m.dataset.membersReturn,y;f&&(y=new URL(f,window.location.href).href);function v(x){m.removeEventListener("click",v),x.preventDefault(),h&&(h.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${t}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,returnUrl:y})}).then(function(I){if(!I.ok)throw new Error(w("Could not create Stripe billing portal session"));return I.json()})}).then(function(S){return window.location.assign(S.url)}).catch(function(S){console.error(S),m.addEventListener("click",v),m.classList.remove("loading"),h&&(h.innerText=S.message),m.classList.add("error")})}m.addEventListener("click",v)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(m){function h(f){m.removeEventListener("click",h),f.preventDefault(),m.classList.remove("error"),m.classList.add("loading"),fetch(`${t}/members/api/session`,{method:"DELETE"}).then(function(y){y.ok?window.location.replace(t):(m.addEventListener("click",h),m.classList.remove("loading"),m.classList.add("error"))})}m.addEventListener("click",h)});const d=(o||[]).some(m=>m.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(m){let h=m.parentElement.querySelector("[data-members-error]");function f(y){y.preventDefault();let v=m.dataset.membersCancelSubscription;if(d){s("openPopup",{page:"accountPlan",pageData:{subscriptionId:v,action:"cancel"}});return}return m.removeEventListener("click",f),m.classList.remove("error"),m.classList.add("loading"),h&&(h.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,smart_cancel:!0})})}).then(function(x){x.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),h&&(h.innerText=w("There was an error cancelling your subscription, please try again.")))})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(m){let h=m.parentElement.querySelector("[data-members-error]");function f(y){m.removeEventListener("click",f),y.preventDefault(),m.classList.remove("error"),m.classList.add("loading");let v=m.dataset.membersContinueSubscription;return h&&(h.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,cancel_at_period_end:!1})})}).then(function(x){x.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),h&&(h.innerText=w("There was an error continuing your subscription, please try again.")))})}m.addEventListener("click",f)})}const hy=t=>{try{return decodeURIComponent(t)}catch{return null}},RP={staleGiftRedemptionRequest:!0},$P={showPopup:!0,site:Cs,member:Bi.free,page:"accountEmail",...KT(),pageData:dy};function LP({site:t,children:e}){const{portal_sentry:a}=t||{};return a&&a.dsn?l.jsx(cu,{children:e}):l.jsx(l.Fragment,{children:e})}class UP extends Xe.Component{constructor(e){super(e),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:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,a){if(a.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=window.document?.body?.style?.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"&&a.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),YP({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Co})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(e=>{e.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e),document.body.appendChild(e);const a=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),a}setupCustomTriggerButton(){this.clickHandler=async o=>{o.preventDefault();const s=o.currentTarget,u=s&&s.dataset.portal,d=this.getPageFromLinkPath(u);if(!d)return;const{page:m,pageQuery:h,pageData:f}=d;if(this.state.initStatus==="success"){if(m==="gift"&&!Pi({site:this.state.site})){this.invalidateGiftRedemptionRequest(),ya();return}if(m==="giftRedemption"&&f?.token){const y=this.startGiftRedemptionRequest(f.token),v=await this.fetchGiftRedemptionData({token:f.token});if(!this.isCurrentGiftRedemptionRequest(y))return;this.setState(v);return}this.invalidateGiftRedemptionRequest(),h&&h!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:h}):this.dispatchAction("openPopup",{page:m,pageQuery:h,pageData:f})}};const e="[data-portal]",a="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(e)||[],this.customTriggerButtons.forEach(o=>{o.classList.add(a),o.removeEventListener("click",this.clickHandler),o.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){const e="gh-portal-open",a="gh-portal-close";this.customTriggerButtons?.forEach(o=>{const s=this.state.showPopup?e:a,u=this.state.showPopup?a:e;o.classList.add(s),o.classList.remove(u)})}startGiftRedemptionRequest(e){return this._redemptionRequestId+=1,this.currentRedemptionToken=e,{requestId:this._redemptionRequestId,token:e}}invalidateGiftRedemptionRequest(){this._redemptionRequestId+=1,this.currentRedemptionToken=null}isCurrentGiftRedemptionRequest({requestId:e,token:a}){return this._redemptionRequestId===e&&this.currentRedemptionToken===a}async initSetup(){try{const{site:e,member:a,offers:o,page:s,showPopup:u,popupNotification:d,notification:m,notificationSequence:h,lastPage:f,pageQuery:y,pageData:v}=await this.fetchData(),x=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||"en";Xr.changeLanguage(x);const S={site:e,member:a,offers:o,page:s,lastPage:f,pageQuery:y,showPopup:u,pageData:v,popupNotification:d,notification:m,notificationSequence:h,dir:Xr.dir()||"ltr",action:"init:success",initStatus:"success",locale:x};if(this.setState(S,()=>{this.handleSignupQuery({site:e,pageQuery:y,member:a})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!a){const I=document.querySelectorAll("[data-lexical-signup-form]");I.length>0&&I.forEach(A=>{A.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error("[Portal] Failed to initialize:",e),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:e,member:a,offers:o}=await this.fetchApiData(),{site:s,...u}=this.fetchDevData(),d=await this.fetchLinkData(e,a),{site:m,...h}=d?.staleGiftRedemptionRequest?{}:d,{site:f,...y}=this.fetchPreviewData(),{site:v,...x}=this.fetchNotificationData();return{member:a,offers:o,page:"",site:{...e,...m,...f,...v,...s,plans:{...(s||{}).plans,...(e||{}).plans,...(f||{}).plans}},...u,...h,...x,...y}}fetchDevData(){return gt(["dev"])&&!this.state.customSiteUrl?$P:gt(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(e=""){const a=new URLSearchParams(e),o={};for(let s of a.entries()){const u=s[0],d=decodeURIComponent(s[1]);u==="name"?o.name=d||"":u==="code"?o.code=d||"":u==="display_title"?o.display_title=d||"":u==="display_description"?o.display_description=d||"":u==="type"?o.type=d||"":u==="cadence"?o.cadence=d||"":u==="duration"?o.duration=d||"":u==="duration_in_months"&&!isNaN(Number(d))?o.duration_in_months=Number(d):u==="amount"&&!isNaN(Number(d))?o.amount=Number(d):u==="currency"?o.currency=d||"":u==="status"?o.status=d||"":u==="tier_id"?o.tier={id:d||dy.tier.id}:u==="redemption_type"&&(o.redemption_type=d||"signup")}if(o.redemption_type==="retention"){const s=Bi.preview?.subscriptions?.[0]?.id;return{page:"accountPlan",offers:[o],pageData:{action:"cancel",subscriptionId:s}}}return{page:"offer",pageData:o}}fetchQueryStrData(e=""){const a=new URLSearchParams(e),o={site:{plans:{}}},s=[];let u,d=null,m,h,f;for(let y of a.entries()){const v=y[0],x=decodeURIComponent(y[1]);if(v==="button")o.site.portal_button=JSON.parse(x);else if(v==="name")o.site.portal_name=JSON.parse(x);else if(v==="isFree"&&JSON.parse(x))s.push("free");else if(v==="isMonthly"&&JSON.parse(x))s.push("monthly");else if(v==="isYearly"&&JSON.parse(x))s.push("yearly");else if(v==="portalPrices")u=x?x.split(","):[];else if(v==="portalProducts")d=x?x.split(","):[];else if(v==="page"&&x)o.page=x;else if(v==="accentColor"&&(x===""||x))o.site.accent_color=x;else if(v==="buttonIcon"&&x)o.site.portal_button_icon=x;else if(v==="signupButtonText")o.site.portal_button_signup_text=x||"";else if(v==="signupTermsHtml")o.site.portal_signup_terms_html=x||"";else if(v==="signupCheckboxRequired")o.site.portal_signup_checkbox_required=JSON.parse(x);else if(v==="buttonStyle"&&x)o.site.portal_button_style=x;else if(v==="monthlyPrice"&&!isNaN(Number(x)))o.site.plans.monthly=Number(x),m=Number(x);else if(v==="yearlyPrice"&&!isNaN(Number(x)))o.site.plans.yearly=Number(x),h=Number(x);else if(v==="currency"&&x){const S=x.toUpperCase();o.site.plans.currency=S,o.site.plans.currency_symbol=Pt(S),f=S}else v==="disableBackground"?o.site.disableBackground=JSON.parse(x):v==="membersSignupAccess"&&x?o.site.members_signup_access=x:v==="portalDefaultPlan"&&x?o.site.portal_default_plan=x:v==="transistorPortalSettings"&&x&&(o.site.transistor_portal_settings=JSON.parse(x))}return o.site.portal_plans=s,o.site.portal_products=d,u?o.site.portal_plans=u:m&&h&&f&&(o.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:f,amount:m,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:f,amount:h,type:"recurring",interval:"year"}]),o}fetchNotificationData(){const{type:e,status:a,duration:o,autoHide:s,closeable:u}=vg({billingOnly:!0})||{};return["stripe:billing-update"].includes(e)?a==="success"?{showPopup:!0,popupNotification:rt({type:e,status:a,duration:o,closeable:u,autoHide:s,state:this.state,message:a==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{const a=await this.GhostApi.gift.fetchRedemptionData({token:e});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:e,gift:a?.gifts?.[0]||null}}}catch(a){ya();const o=Oo({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:hs(a)});return{showPopup:!1,pageData:null,notification:o,notificationSequence:o.count}}}async fetchLinkData(e,a){this.invalidateGiftRedemptionRequest();const o=new URLSearchParams(window.location.search);if(o.get("stripe")==="gift-purchase-success"){const I=o.get("gift_token"),A=o.get("gift_tier"),D=o.get("gift_cadence");if(fs(["stripe","gift_token","gift_tier","gift_cadence"]),I)return{showPopup:!0,page:"giftSuccess",pageData:{token:I,tierId:A,cadence:D}}}if(o.get("action")==="unsubscribe")return o.get("key")&&o.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:o.get("uuid"),key:o.get("key"),newsletterUuid:o.get("newsletter"),comments:o.get("comments"),updatesAndAnnouncements:o.get("updatesandannouncements")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:o.get("newsletter"),action:"unsubscribe",redirect:e.url+"#/portal/account/newsletters"}};if($E({site:e})&&o.get("action")==="signup"&&o.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[s,u]=window.location.hash.substr(1).split("?"),d=new URLSearchParams(u??""),m=/^(?:(\w+?))?\/monthly$/,h=/^(?:(\w+?))?\/yearly$/,f=/^offers\/(\w+?)\/?$/,y=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,v=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,x=/^\/share\/?$/,S=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(s&&S.test(s)){const[,I,A]=s.match(S),D=parseInt(A);if(D===1||D===0)return a||d.get("uuid")&&d.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:a?null:d.get("uuid"),key:a?null:d.get("key"),postId:I,score:D}}:{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/feedback/${I}/${D}/`}}}if(s&&y.test(s)){const[,I]=s.match(y),A=hy(I);if(!A)return{};const D=this.startGiftRedemptionRequest(A),U=await this.fetchGiftRedemptionData({token:A});return this.isCurrentGiftRedemptionRequest(D)?U:RP}if(s&&x.test(s))return{showPopup:!0,page:"share"};if(s&&v.test(s)){const[,I]=s.match(v),{page:A,pageQuery:D,pageData:U}=this.getPageFromLinkPath(I,e)||{};if(!a&&A&&oy({page:A}))return{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/portal/${I}/`}};if(A==="gift"&&!Pi({site:e}))return ya(),{};const V=["accountPlan","accountProfile"].includes(A)?"accountHome":null,ee=!(["monthly","yearly"].includes(D)||m.test(D)||h.test(D)||f.test(D)),ne=d.get("redirect"),H=A==="signin"&&ne?{...U||{},redirect:ne}:U;return{showPopup:ee,...A?{page:A}:{},...D?{pageQuery:D}:{},...H?{pageData:H}:{},...V?{lastPage:V}:{}}}return{}}fetchPreviewData(){const[,e]=window.location.hash.substr(1).split("?");if(gt(["preview"])){let a={};try{gt(["offerPreview"])?a=this.fetchOfferQueryStrData(e):a=this.fetchQueryStrData(e)}catch(o){return Co(o),{}}return{...a,showPopup:!0}}return{}}getColorOverride(){const e=document.querySelector("script[data-ghost]");return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:e,customSiteUrl:a,apiUrl:o,apiKey:s}=this.props;try{this.GhostApi=this.props.api||ks({siteUrl:e,apiUrl:o,apiKey:s});const{site:u,member:d,offers:m}=await this.GhostApi.init(),h=this.getColorOverride();return h&&(u.accent_color=h),this.setupFirstPromoter({site:u,member:d}),this.setupSentry({site:u}),{site:u,member:d,offers:m}}catch(u){if(gt(["dev","test"],{customSiteUrl:a}))return{};throw u}}setupSentry({site:e}){if(gt(["test"]))return null;const{portal_sentry:a,portal_version:o,version:s}=e,d=`portal@2.69.11|ghost@${s}`;a&&a.dsn&&xC({dsn:a.dsn,environment:a.env||"development",release:d,beforeSend:m=>zE({event:m})?m:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:a}){if(gt(["test"]))return null;const o=ZE({site:e});let s=bc({site:e});if(s=s?.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),o&&s){const u=document.createElement("script");u.type="text/javascript",u.async=!0,u.src="https://cdn.firstpromoter.com/fprom.js",u.onload=u.onreadystatechange=function(){let m=this.readyState;if(!m||m==="complete"||m==="loaded")try{if(window.$FPROM.init(o,s),o1({member:a})){const h=a.email,f=a.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:h,uid:f});else{const y=window._fprom||[];window._fprom=y,y.push(["event","signup"]),y.push(["email",h]),y.push(["uid",f])}}}catch{}};const d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(u,d)}}async dispatchAction(e,a){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{const o=await OP({action:e,data:a,state:this.state,api:this.GhostApi});this.setState(o),o&&o.action&&!o.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(o){if(console.error(`[Portal] Failed to dispatch action: ${e}`,o),a&&a.throwErrors)throw o;const s=rt({type:`${e}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:o}});this.setState({action:`${e}:failed`,actionErrorMessage:ta(o,w("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:s})}}async updateStateForPreviewLinks(){const{site:e,...a}=this.fetchPreviewData(),o=await this.fetchLinkData(this.state.site,this.state.member);if(o?.staleGiftRedemptionRequest)return;const{site:s,...u}=o,d={site:{...this.state.site,...s||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(s||{}).plans,...(e||{}).plans}},...u,...a};this.handleSignupQuery({site:d.site,pageQuery:d.pageQuery}),this.setState(d)}async handleOfferQuery({site:e,offerId:a,member:o=this.state.member}){if(ya(),!(!Yn({member:o})||ba({member:o}))){const u=Oo({type:"offer:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:w("You already have an active subscription.")});await this.dispatchAction("closePopup"),this.setState({notification:u,notificationSequence:u.count});return}try{const d=(await this.GhostApi.site.offer({offerId:a}))?.offers[0];if(!d||!d.tier||wc({offer:d})||!_E({site:e,offer:d}))return;this.dispatchAction("openPopup",{page:"offer",pageData:d})}catch{}}handleSignupQuery({site:e,pageQuery:a,member:o}){const s=/^offers\/(\w+?)\/?$/;let u=a;if(s.test(a||"")){const[,m]=a.match(s);this.handleOfferQuery({site:e,offerId:m,member:o});return}_f({site:e,pageQuery:a})&&(u=_f({site:e,pageQuery:a}));const d=YE({site:e,priceId:u});if(a&&a!=="free"){ya();const m=d?.id||u;m!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:h,cadence:f}=Io({site:e,priceId:m});this.dispatchAction("signup",{plan:m,tierId:h,cadence:f})}}getPageFromLinkPath(e){const a=/^signup\/?(?:\/(\w+?))?\/?$/,o=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,s=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,u=/^offers\/(\w+?)\/?$/,d=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e==="")return{page:"default"};if(d.test(e)){const[,m]=e.match(d),h=hy(m);return h?{page:"giftRedemption",pageData:{token:h}}:null}else{if(u.test(e))return{pageQuery:e};if(e==="signup")return{page:"signup"};if(o.test(e)){const[,m]=e.match(o);return{page:"signup",pageQuery:`${m}/monthly`}}else if(s.test(e)){const[,m]=e.match(s);return{page:"signup",pageQuery:`${m}/yearly`}}else if(a.test(e)){const[,m]=e.match(a);return{page:"signup",pageQuery:m}}else{if(e==="signup/free")return{page:"signup",pageQuery:"free"};if(e==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(e==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(e==="signin")return{page:"signin"};if(e==="account")return{page:"accountHome"};if(e==="account/plans")return{page:"accountPlan"};if(e==="account/profile")return{page:"accountProfile"};if(e==="account/newsletters")return{page:"accountEmail"};if(e==="support")return{page:"support"};if(e==="support/success")return{page:"supportSuccess"};if(e==="support/error")return{page:"supportError"};if(e==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(e==="gift")return{page:"gift"};if(e==="share")return{page:"share"};if(e==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(e==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}}return{page:"default"}}getAccentColor(){const{accent_color:e}=this.state.site||{};return Hj(e)}getRetentionPreviewMember({site:e,offers:a}){const o=(a||[]).find(f=>wc({offer:f})),s=o?.tier?.id,u=s?Xa({site:e,productId:s}):null,d=u?o.cadence==="year"?u.yearlyPrice:u.monthlyPrice:null,m=Bi.preview,h=m?.subscriptions?.[0];return!h||!u||!d?m:{...m,subscriptions:[{...h,plan:{...h.plan,amount:d.amount,interval:d.interval,currency:d.currency.toUpperCase()},price:{...h.price,price_id:d.id,amount:d.amount,interval:d.interval,currency:d.currency,product:{...h.price?.product,product_id:u.id}},tier:{id:u.id,name:u.name}}]}}getContextPage({site:e,page:a,member:o}){if(!a||a==="default"){const s=$n({site:e})||!na({site:e})?"signin":"signup";a=o?"accountHome":s}return sd({page:a})}getContextMember({site:e,page:a,member:o,offers:s,pageData:u,customSiteUrl:d}){return gt(["dev","preview"],{customSiteUrl:d})?oy({page:a})||BT({page:a})?gt(["dev"],{customSiteUrl:d})?o||Bi.free:gt(["preview"])?a==="accountPlan"&&u?.action==="cancel"?this.getRetentionPreviewMember({site:e,offers:s}):Bi.preview:Bi.paid:null:o}getContextFromState(){const{site:e,member:a,offers:o,action:s,actionErrorMessage:u,page:d,lastPage:m,showPopup:h,pageQuery:f,pageData:y,popupNotification:v,notification:x,customSiteUrl:S,dir:I,scrollbarWidth:A,otcRef:D,inboxLinks:U}=this.state,V=this.getContextPage({site:e,page:d,member:a}),ee=this.getContextMember({site:e,page:V,member:a,offers:o,pageData:y,customSiteUrl:S});return{api:this.GhostApi,site:e,offers:o,action:s,actionErrorMessage:u,brandColor:this.getAccentColor(),page:V,pageQuery:f,pageData:y,member:ee,lastPage:m,showPopup:h,popupNotification:v,notification:x,customSiteUrl:S,dir:I,scrollbarWidth:A,otcRef:D,inboxLinks:U,doAction:(ne,H)=>this.dispatchAction(ne,H)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const e=o=>{const s=o.currentTarget.dataset.recommendation;s?this.dispatchAction("trackRecommendationClicked",{recommendationId:s}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},a=this.getRecommendationButtons();for(const o of a)o.addEventListener("click",e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"], a[href*="#/share"]').forEach(XT)}render(){return this.state.initStatus==="success"?l.jsx(LP,{site:this.state.site,children:l.jsxs(ve.Provider,{value:this.getContextFromState(),children:[l.jsx(ud,{}),l.jsx(Sc,{}),l.jsx(Dc,{})]})}):null}}const fy="ghost-portal-root";function BP(){const t=document.createElement("div");t.id=fy,t.setAttribute("data-testid","portal-root"),document.body.appendChild(t)}function WP(){const t=document.querySelector("script[data-ghost]");if(t){const e=t.dataset.i18n==="true",a=t.dataset.ghost,o=t.dataset.key,s=t.dataset.api,u=t.dataset.locale;return{siteUrl:a,apiKey:o,apiUrl:s,siteI18nEnabled:e,locale:u}}return{}}function GP(){const t=new URL(window.location.href);t.searchParams.get("token")&&(t.searchParams.delete("token"),window.history.replaceState({},document.title,t.href))}function VP(){const{siteUrl:t,apiKey:e,apiUrl:a,siteI18nEnabled:o,locale:s}=WP(),u=t||window.location.origin;BP(),GP(),Ik.render(l.jsx(Xe.StrictMode,{children:l.jsx(UP,{siteUrl:u,customSiteUrl:t,apiKey:e,apiUrl:a,siteI18nEnabled:o,locale:s})}),document.getElementById(fy))}VP()}));
4521
4521
  //# sourceMappingURL=portal.min.js.map