@tryghost/portal 2.72.11 → 2.72.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/umd/portal.min.js CHANGED
@@ -703,7 +703,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
703
703
  width: 38px !important;
704
704
  height: 22px !important;
705
705
  }
706
- `;function gf({id:e,label:t=``,onToggle:n,checked:r=!1,disabled:i=!1,dataTestId:a=`switch-input`,presentational:o=!1}){let[s,c]=(0,_.useState)(r);(0,_.useEffect)(()=>{c(r)},[r]);let l=(0,_.useRef)(null);(0,_.useEffect)(()=>{l.current&&l.current.checked!==s&&(l.current.checked=s)},[s,e]);let u=e=>{i||(c(e.target.checked),n(e,e.target.checked))},d=o?{"aria-hidden":!0}:{},f=o?{tabIndex:-1}:{"aria-label":t};return(0,q.jsx)(`div`,{className:`gh-portal-for-switch`,"data-test-switch":a,...d,children:(0,q.jsxs)(`label`,{className:`switch`,htmlFor:e,children:[(0,q.jsx)(`input`,{ref:l,type:`checkbox`,checked:s,disabled:i,id:e,onChange:u,...f}),(0,q.jsx)(`span`,{className:`input-toggle-component`,"data-testid":a})]})})}var _f=`.gh-portal-account-header{flex-direction:column;align-items:center;margin:0 0 32px;display:flex}.gh-portal-account-header .gh-portal-avatar{margin:6px 0 8px!important}.gh-portal-account-data{margin-bottom:40px}footer.gh-portal-account-footer{display:flex}.gh-portal-account-footer.paid{margin-top:12px}.gh-portal-account-footermenu{align-items:center;margin:0;padding:0;list-style:none;display:flex}.gh-portal-account-footerright{flex-grow:1;justify-content:flex-end;align-items:center;display:flex}.gh-portal-account-footermenu li{margin-inline-end:16px}.gh-portal-account-footermenu li:last-of-type{margin-inline-end:0}.gh-portal-freeaccount-newsletter{justify-content:space-between;align-items:center;margin-top:24px;display:flex}.gh-portal-freeaccount-newsletter .label{flex-direction:column;flex-grow:1;display:flex}.gh-portal-free-ctatext{margin-top:-12px}.gh-portal-cancelcontinue-container{margin:24px 0 32px}.gh-portal-cancel-banner{text-align:center;color:var(--grey1);border-radius:8px;margin-bottom:16px;padding:16px;font-size:1.4rem;line-height:1.5;position:relative}.gh-portal-cancel-banner:before{content:"";background:var(--brandcolor);opacity:.05;pointer-events:none;z-index:0;border-radius:8px;display:block;position:absolute;inset:0}.gh-portal-cancel-banner>*{z-index:1;position:relative}.gh-portal-cancel-banner p{max-width:320px;margin:0 auto 16px}.gh-portal-canceled-badge{letter-spacing:.05px;text-transform:uppercase;color:var(--grey6);background:color-mix(in srgb, var(--grey12) 60%, transparent);vertical-align:middle;border-radius:32px;margin-inline-start:6px;padding:6px 8px;font-size:1.1rem;font-weight:600;line-height:1em;display:inline-block;position:relative;top:-1px}.gh-portal-list-detail .gh-portal-email-notice{color:var(--red);letter-spacing:.2px;align-items:center;gap:5px;margin-top:6px;font-size:1.25rem;font-weight:500;display:flex}.gh-portal-email-notice-icon{width:20px;height:20px}.gh-portal-billing-button-loader{opacity:.6;width:32px;height:32px;margin-inline-end:-3px}.gh-portal-product-icon{border-radius:2px;width:52px;margin-inline-end:12px}.gh-portal-account-discountcontainer{flex-wrap:wrap;align-items:center;display:flex;position:relative}.gh-portal-account-expiry{white-space:nowrap}.gh-portal-account-expiry-separator{margin:0 4px}@media (width<=480px){.gh-portal-account-expiry-separator{display:none}.gh-portal-account-expiry{flex-basis:100%}}.gh-portal-account-old-price{text-decoration:line-through;color:var(--grey9)!important}.gh-portal-account-tagicon{width:16px;height:16px;color:var(--brandcolor);z-index:999;margin-inline-end:4px}@media (width<=390px){.gh-portal-account-footer{padding:0!important}}@media (width<=340px){.gh-portal-account-footer{flex-wrap:wrap;gap:12px;padding:0!important}.gh-portal-account-footer .gh-portal-account-footerright{justify-content:flex-start}}.gh-portal-gift-card{margin-top:16px}.gh-portal-gift-card-icon{stroke-width:2px;width:16px;height:16px;margin-inline-end:4px}`,vf=class extends _.Component{static contextType=J;closePopup=()=>{this.context.doAction(`closePopup`)};render(){let{brandColor:e,onClick:t}=this.props,n=e||this.context.brandColor;return(0,q.jsx)(`button`,{type:`button`,className:`gh-portal-closeicon-container`,"aria-label":`Close popup`,"data-testid":`close-popup`,"data-test-button":`close-popup`,onClick:t||this.closePopup,children:(0,q.jsx)(Hd,{className:`gh-portal-closeicon`,style:n?{color:n}:void 0,"aria-hidden":`true`})})}},yf=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,q.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,q.jsx)(`path`,{d:`M12 8v13`}),(0,q.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7`}),(0,q.jsx)(`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0-5C9 3 12 8 12 8`}),(0,q.jsx)(`path`,{d:`M16.5 8a2.5 2.5 0 0 0 0-5C15 3 12 8 12 8`})]}),bf=e=>{if(!e)return[];let t=`${e.replace(/\/$/,``)}/gift/assets`;return[`${t}/gift-card-orb.webp`,`${t}/gift-card-noise.webp`]},xf=e=>{bf(e).forEach(e=>{new Image().src=e})},Sf=({cardRef:e,duration:t,tierName:n,name:r,toName:i,fromName:a,giftValue:o,siteIcon:s,siteTitle:c})=>{let{site:l}=(0,_.useContext)(J),[u,d]=bf(l?.url),f=t&&n,p=r||i||a||o;return(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-frame`,children:(0,q.jsxs)(`div`,{ref:e,className:`gh-portal-gift-checkout-card`,style:u&&{"--gh-gift-orb":`url("${u}")`,"--gh-gift-noise":`url("${d}")`},children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-notch`,"aria-hidden":`true`}),f&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-meta`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-duration`,"data-testid":`gift-card-duration`,children:t}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-tier`,children:K(`{tierName} membership`,{tierName:n})})]}),p&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-details`,children:[r&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`Name`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:r})]}),i&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`To`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:i})]}),a&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`From`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:a})]}),o&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`Gift value`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,"data-testid":`gift-card-value`,children:o})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-site`,children:[s&&(0,q.jsx)(`img`,{className:`gh-portal-gift-checkout-card-site-icon`,src:s,alt:``}),(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-card-site-name`,children:c})]})]})})},Cf=[1,3,6,12];function wf(e,t){return t===12?e.yearlyPrice??null:e.monthlyPrice??null}function Tf(e){return!!e&&typeof e.amount==`number`&&Number.isSafeInteger(e.amount)&&e.amount>0&&typeof e.currency==`string`&&!!e.currency}function Ef({portalPlans:e,duration:t}){return t===12?e.includes(`yearly`):e.includes(`monthly`)}function Df(e,t){let n=wf(e,t);return Tf(n)?{...n,amount:t===12?n.amount:n.amount*t}:null}function Of({site:e,duration:t}){let{paid_members_enabled:n,portal_plans:r=[],portal_products:i,products:a=[]}=e||{};if(!n||!Ef({portalPlans:r,duration:t}))return[];let o=Array.isArray(i)?i:null;return a.filter(e=>e?.type===`paid`&&(!o||o.includes(e.id))&&!!Df(e,t)).map(e=>({product:e,amount:Df(e,t)?.amount??0})).sort((e,t)=>e.amount-t.amount).map(({product:e})=>e)}function kf({site:e}){return Cf.filter(t=>Of({site:e,duration:t}).length>0)}function Af({site:e}){return kf({site:e}).length>0}function jf({site:e}){return e?.portal_signup_gift_promotion===!0&&Af({site:e})}function Mf({site:e}){return e?.portal_account_gift_promotion===!0&&Af({site:e})}function Nf({availableDurations:e,portalDefaultPlan:t,selectedDuration:n}){if(n&&e.includes(n))return n;let r=t===`yearly`?12:1;return e.includes(r)?r:e[0]??null}var Pf=({className:e,lastPage:t})=>{let{brandColor:n,doAction:r,site:i}=(0,_.useContext)(J),a=jf({site:i});if((0,_.useEffect)(()=>{a&&xf(i?.url)},[a,i?.url]),!a)return null;let o=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{children:K(`Buying for someone else?`)}),(0,q.jsxs)(`button`,{className:`gh-portal-btn gh-portal-btn-link gh-portal-signup-message-gift`,"data-test-button":`gift-switch`,"data-testid":`gift-switch`,style:{color:n},type:`button`,onClick:()=>r(`switchPage`,{page:`gift`,lastPage:t}),children:[(0,q.jsx)(yf,{"aria-hidden":`true`,className:`gh-portal-signup-message-icon`}),(0,q.jsx)(`span`,{children:K(`Gift a membership`)})]})]});return e?(0,q.jsx)(`div`,{className:e,children:o}):o},Ff=e=>(0,q.jsx)(`svg`,{width:15,height:14,viewBox:`0 0 15 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,q.jsx)(`path`,{d:`M1 6.89286L6.10714 12L13.9643 1`,stroke:`#222222`,strokeWidth:2})});function If(e,t){if(isNaN(e)||isNaN(t))return 0;let n=e?100-Math.floor(t/12*100/e):0;return n>=1&&n<100?n:0}var Lf=()=>`
706
+ `;function gf({id:e,label:t=``,onToggle:n,checked:r=!1,disabled:i=!1,dataTestId:a=`switch-input`,presentational:o=!1}){let[s,c]=(0,_.useState)(r);(0,_.useEffect)(()=>{c(r)},[r]);let l=(0,_.useRef)(null);(0,_.useEffect)(()=>{l.current&&l.current.checked!==s&&(l.current.checked=s)},[s,e]);let u=e=>{i||(o||c(e.target.checked),n(e,e.target.checked))},d=o?{"aria-hidden":!0}:{},f=o?{tabIndex:-1}:{"aria-label":t};return(0,q.jsx)(`div`,{className:`gh-portal-for-switch`,"data-test-switch":a,...d,children:(0,q.jsxs)(`label`,{className:`switch`,htmlFor:e,children:[(0,q.jsx)(`input`,{ref:l,type:`checkbox`,checked:s,disabled:i,id:e,onChange:u,...f}),(0,q.jsx)(`span`,{className:`input-toggle-component`,"data-testid":a})]})})}var _f=`.gh-portal-account-header{flex-direction:column;align-items:center;margin:0 0 32px;display:flex}.gh-portal-account-header .gh-portal-avatar{margin:6px 0 8px!important}.gh-portal-account-data{margin-bottom:40px}footer.gh-portal-account-footer{display:flex}.gh-portal-account-footer.paid{margin-top:12px}.gh-portal-account-footermenu{align-items:center;margin:0;padding:0;list-style:none;display:flex}.gh-portal-account-footerright{flex-grow:1;justify-content:flex-end;align-items:center;display:flex}.gh-portal-account-footermenu li{margin-inline-end:16px}.gh-portal-account-footermenu li:last-of-type{margin-inline-end:0}.gh-portal-freeaccount-newsletter{justify-content:space-between;align-items:center;margin-top:24px;display:flex}.gh-portal-freeaccount-newsletter .label{flex-direction:column;flex-grow:1;display:flex}.gh-portal-free-ctatext{margin-top:-12px}.gh-portal-cancelcontinue-container{margin:24px 0 32px}.gh-portal-cancel-banner{text-align:center;color:var(--grey1);border-radius:8px;margin-bottom:16px;padding:16px;font-size:1.4rem;line-height:1.5;position:relative}.gh-portal-cancel-banner:before{content:"";background:var(--brandcolor);opacity:.05;pointer-events:none;z-index:0;border-radius:8px;display:block;position:absolute;inset:0}.gh-portal-cancel-banner>*{z-index:1;position:relative}.gh-portal-cancel-banner p{max-width:320px;margin:0 auto 16px}.gh-portal-canceled-badge{letter-spacing:.05px;text-transform:uppercase;color:var(--grey6);background:color-mix(in srgb, var(--grey12) 60%, transparent);vertical-align:middle;border-radius:32px;margin-inline-start:6px;padding:6px 8px;font-size:1.1rem;font-weight:600;line-height:1em;display:inline-block;position:relative;top:-1px}.gh-portal-list-detail .gh-portal-email-notice{color:var(--red);letter-spacing:.2px;align-items:center;gap:5px;margin-top:6px;font-size:1.25rem;font-weight:500;display:flex}.gh-portal-email-notice-icon{width:20px;height:20px}.gh-portal-billing-button-loader{opacity:.6;width:32px;height:32px;margin-inline-end:-3px}.gh-portal-product-icon{border-radius:2px;width:52px;margin-inline-end:12px}.gh-portal-account-discountcontainer{flex-wrap:wrap;align-items:center;display:flex;position:relative}.gh-portal-account-expiry{white-space:nowrap}.gh-portal-account-expiry-separator{margin:0 4px}@media (width<=480px){.gh-portal-account-expiry-separator{display:none}.gh-portal-account-expiry{flex-basis:100%}}.gh-portal-account-old-price{text-decoration:line-through;color:var(--grey9)!important}.gh-portal-account-tagicon{width:16px;height:16px;color:var(--brandcolor);z-index:999;margin-inline-end:4px}@media (width<=390px){.gh-portal-account-footer{padding:0!important}}@media (width<=340px){.gh-portal-account-footer{flex-wrap:wrap;gap:12px;padding:0!important}.gh-portal-account-footer .gh-portal-account-footerright{justify-content:flex-start}}.gh-portal-gift-card{margin-top:16px}.gh-portal-gift-card-icon{stroke-width:2px;width:16px;height:16px;margin-inline-end:4px}`,vf=class extends _.Component{static contextType=J;closePopup=()=>{this.context.doAction(`closePopup`)};render(){let{brandColor:e,onClick:t}=this.props,n=e||this.context.brandColor;return(0,q.jsx)(`button`,{type:`button`,className:`gh-portal-closeicon-container`,"aria-label":`Close popup`,"data-testid":`close-popup`,"data-test-button":`close-popup`,onClick:t||this.closePopup,children:(0,q.jsx)(Hd,{className:`gh-portal-closeicon`,style:n?{color:n}:void 0,"aria-hidden":`true`})})}},yf=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,q.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,q.jsx)(`path`,{d:`M12 8v13`}),(0,q.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7`}),(0,q.jsx)(`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0-5C9 3 12 8 12 8`}),(0,q.jsx)(`path`,{d:`M16.5 8a2.5 2.5 0 0 0 0-5C15 3 12 8 12 8`})]}),bf=e=>{if(!e)return[];let t=`${e.replace(/\/$/,``)}/gift/assets`;return[`${t}/gift-card-orb.webp`,`${t}/gift-card-noise.webp`]},xf=e=>{bf(e).forEach(e=>{new Image().src=e})},Sf=({cardRef:e,duration:t,tierName:n,name:r,toName:i,fromName:a,giftValue:o,siteIcon:s,siteTitle:c})=>{let{site:l}=(0,_.useContext)(J),[u,d]=bf(l?.url),f=t&&n,p=r||i||a||o;return(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-frame`,children:(0,q.jsxs)(`div`,{ref:e,className:`gh-portal-gift-checkout-card`,style:u&&{"--gh-gift-orb":`url("${u}")`,"--gh-gift-noise":`url("${d}")`},children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-notch`,"aria-hidden":`true`}),f&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-meta`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-duration`,"data-testid":`gift-card-duration`,children:t}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-tier`,children:K(`{tierName} membership`,{tierName:n})})]}),p&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-details`,children:[r&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`Name`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:r})]}),i&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`To`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:i})]}),a&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`From`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,children:a})]}),o&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-detail`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-label`,children:K(`Gift value`)}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-detail-value`,"data-testid":`gift-card-value`,children:o})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-card-site`,children:[s&&(0,q.jsx)(`img`,{className:`gh-portal-gift-checkout-card-site-icon`,src:s,alt:``}),(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-card-site-name`,children:c})]})]})})},Cf=[1,3,6,12];function wf(e,t){return t===12?e.yearlyPrice??null:e.monthlyPrice??null}function Tf(e){return!!e&&typeof e.amount==`number`&&Number.isSafeInteger(e.amount)&&e.amount>0&&typeof e.currency==`string`&&!!e.currency}function Ef({portalPlans:e,duration:t}){return t===12?e.includes(`yearly`):e.includes(`monthly`)}function Df(e,t){let n=wf(e,t);return Tf(n)?{...n,amount:t===12?n.amount:n.amount*t}:null}function Of({site:e,duration:t}){let{paid_members_enabled:n,portal_plans:r=[],portal_products:i,products:a=[]}=e||{};if(!n||!Ef({portalPlans:r,duration:t}))return[];let o=Array.isArray(i)?i:null;return a.filter(e=>e?.type===`paid`&&(!o||o.includes(e.id))&&!!Df(e,t)).map(e=>({product:e,amount:Df(e,t)?.amount??0})).sort((e,t)=>e.amount-t.amount).map(({product:e})=>e)}function kf({site:e}){return Cf.filter(t=>Of({site:e,duration:t}).length>0)}function Af({site:e}){return kf({site:e}).length>0}function jf({site:e}){return e?.portal_signup_gift_promotion===!0&&Af({site:e})}function Mf({site:e}){return e?.portal_account_gift_promotion===!0&&Af({site:e})}function Nf({availableDurations:e,portalDefaultPlan:t,selectedDuration:n}){if(n&&e.includes(n))return n;let r=t===`yearly`?12:1;return e.includes(r)?r:e[0]??null}var Pf=({className:e,lastPage:t})=>{let{brandColor:n,doAction:r,site:i}=(0,_.useContext)(J),a=jf({site:i});if((0,_.useEffect)(()=>{a&&xf(i?.url)},[a,i?.url]),!a)return null;let o=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{children:K(`Buying for someone else?`)}),(0,q.jsxs)(`button`,{className:`gh-portal-btn gh-portal-btn-link gh-portal-signup-message-gift`,"data-test-button":`gift-switch`,"data-testid":`gift-switch`,style:{color:n},type:`button`,onClick:()=>r(`switchPage`,{page:`gift`,lastPage:t}),children:[(0,q.jsx)(yf,{"aria-hidden":`true`,className:`gh-portal-signup-message-icon`}),(0,q.jsx)(`span`,{children:K(`Gift a membership`)})]})]});return e?(0,q.jsx)(`div`,{className:e,children:o}):o},Ff=e=>(0,q.jsx)(`svg`,{width:15,height:14,viewBox:`0 0 15 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,q.jsx)(`path`,{d:`M1 6.89286L6.10714 12L13.9643 1`,stroke:`#222222`,strokeWidth:2})});function If(e,t){if(isNaN(e)||isNaN(t))return 0;let n=e?100-Math.floor(t/12*100/e):0;return n>=1&&n<100?n:0}var Lf=()=>`
707
707
  .gh-portal-products {
708
708
  display: flex;
709
709
  flex-direction: column;
@@ -5688,7 +5688,7 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
5688
5688
  .gh-portal-hide {
5689
5689
  display: none;
5690
5690
  }
5691
- `;function eS({site:e}){return il+Zx+_f+ip+vp+Qp+yv+Lf({site:e})+hf+lf+pf+Xc+Pb+hb+Vb({site:e})+Vd+Lb+Qx+$x+hx+Sx+``+wx+Dx+kx+Lx+Mx+Vx+qx+Jx}var tS=class extends _.Component{static contextType=J;constructor(e){super(e),this.state={email:``,token:void 0}}componentDidMount(){let{member:e}=this.context;e&&this.context.doAction(`switchPage`,{page:`accountHome`})}handleSignin(e){e.preventDefault(),this.doSignin()}doSignin(){this.setState(e=>({errors:Nv({fields:this.getInputFields({state:e})})}),async()=>{let{email:e,phonenumber:t,errors:n,token:r}=this.state,{redirect:i}=this.context.pageData??{};n&&Object.values(n).filter(e=>!!e).length>0||this.context.doAction(`signin`,{email:e,phonenumber:t,redirect:i,token:r})})}handleInputChange(e,t){let n=t.name;this.setState({[n]:e.target.value})}onKeyDown(e){e.keyCode===13&&this.handleSignin(e)}getInputFields({state:e}){let t=e.errors||{};return[{type:`email`,value:e.email,placeholder:K(`jamie@example.com`),label:K(`Email`),name:`email`,required:!0,errorMessage:t.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(){let{action:e}=this.context,t=!1,n=e===`signin:running`,r=K(n?`Sending login link...`:`Continue`),i=!!n;return e===`signin:failed`&&(r=K(`Retry`),t=!0),(0,q.jsx)(df,{dataTestId:`signin`,retry:t,style:{width:`100%`},onClick:e=>this.handleSignin(e),disabled:i,brandColor:this.context.brandColor,label:r,isRunning:n})}renderSignupMessage(){let{brandColor:e}=this.context;return(0,q.jsxs)(`div`,{className:`gh-portal-signup-message`,children:[(0,q.jsx)(`div`,{children:K(`Don't have an account?`)}),(0,q.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:(0,q.jsx)(`span`,{children:K(`Sign up`)})})]})}renderForm(){let{site:e}=this.context,t=Jl({site:e})&&Wl({site:e});return ql({site:e})?(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(Pp,{fields:this.getInputFields({state:this.state}),onChange:(e,t)=>this.handleInputChange(e,t),onKeyDown:(e,t)=>this.onKeyDown(e,t)})}),(0,q.jsxs)(`footer`,{className:`gh-portal-signin-footer`,children:[this.renderSubmitButton(),t&&this.renderSignupMessage()]})]}):(0,q.jsx)(`section`,{children:(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-members-disabled-notification`,"data-testid":`members-disabled-notification-text`,children:K(`Memberships unavailable, contact the owner for access.`)})})})}renderSiteIcon(){let e={},{site:t}=this.context,n=t.icon;return n?(e.backgroundImage=`url(${n})`,(0,q.jsx)(`img`,{className:`gh-portal-signup-logo`,src:n,alt:this.context.site.title})):ql({site:t})?null:(0,q.jsx)(Pv,{className:`gh-portal-icon gh-portal-icon-invitation`})}renderSiteTitle(){let{site:e}=this.context,t=e.title;return ql({site:e})?(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Sign in`)}):(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:t})}renderFormHeader(){return(0,q.jsxs)(`header`,{className:`gh-portal-signin-header`,children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-logged-out-form-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-content signin`,children:[this.renderFormHeader(),this.renderForm()]})})]})}},nS=({handleSignout:e,supportAddress:t=``})=>{let n=`mailto:${t}`;return(0,q.jsxs)(`footer`,{className:`gh-portal-account-footer`,children:[(0,q.jsx)(`ul`,{className:`gh-portal-account-footermenu`,children:(0,q.jsx)(`li`,{children:(0,q.jsx)(`button`,{"data-test-button":`footer-signout`,className:`gh-portal-btn`,name:`logout`,"aria-label":`logout`,onClick:t=>e(t),children:K(`Sign out`)})})}),(0,q.jsx)(`div`,{className:`gh-portal-account-footerright`,children:(0,q.jsx)(`ul`,{className:`gh-portal-account-footermenu`,children:(0,q.jsx)(`li`,{children:(0,q.jsx)(`a`,{"data-test-link":`footer-support`,className:`gh-portal-btn gh-portal-btn-branded`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:K(`Contact support`)})})})})]})},rS=()=>{let{member:e,brandColor:t}=(0,_.useContext)(J),n=e.avatar_image;return(0,q.jsxs)(`header`,{className:`gh-portal-account-header`,children:[(0,q.jsx)(Qc,{gravatar:n,style:{userIcon:{color:t,width:`56px`,height:`56px`,padding:`2px`}}}),(0,q.jsx)(`h2`,{className:`gh-portal-main-title`,children:K(`Your account`)})]})},iS=()=>{let{site:e,action:t,brandColor:n,doAction:r}=(0,_.useContext)(J);if(!Jl({site:e})||!Wl({site:e}))return null;let i=[`checkoutPlan:running`].includes(t),a=()=>{r(`switchPage`,{page:`accountPlan`,lastPage:`accountHome`})};return(0,q.jsx)(df,{dataTestId:`view-plans`,isRunning:i,label:K(`View plans`),onClick:()=>a(),brandColor:n,style:{width:`100%`}})},aS=()=>{let{member:e,site:t}=(0,_.useContext)(J),{paid_members_enabled:n}=t;if(!n||zl({site:t}))return null;let r=Cl({member:e}),i=wl({member:e});if(i&&!r)return null;if(r){let t=r?.current_period_end,n=kl({member:e});return El({member:e})?n?(0,q.jsx)(`div`,{className:`gh-portal-section`,style:{marginBottom:24},children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your gift subscription will expire on {expiryDate}`,{expiryDate:n})})}):null:i&&n?(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will expire on {expiryDate}`,{expiryDate:n})})}):r?.cancel_at_period_end||i?null:gu({sub:r})?(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will start on {subscriptionStart}`,{subscriptionStart:ol(r.trial_end_at)})})}):(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will renew on {renewalDate}`,{renewalDate:ol(t)})})})}return(0,q.jsxs)(`div`,{className:`gh-portal-section`,children:[(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`You currently have a free membership, upgrade to a paid subscription for full access.`)}),(0,q.jsx)(iS,{})]})},oS=()=>{let{member:e,doAction:t,action:n,brandColor:r}=(0,_.useContext)(J),i=Cl({member:e});if(!i||!i.cancel_at_period_end)return null;let a=K(`Resume subscription`),o=[`continueSubscription:running`].includes(n),s=!!o,c=ol(i.current_period_end);return(0,q.jsx)(`div`,{className:`gh-portal-cancelcontinue-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-cancel-banner`,children:[(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`Your subscription has been canceled and will expire on {expiryDate}.`),mapping:{expiryDate:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(df,{onClick:()=>{t(`continueSubscription`,{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:!0,brandColor:r,label:a,style:{width:`100%`}})]})})},sS=()=>{let{member:e,site:t,doAction:n,action:r,brandColor:i}=(0,_.useContext)(J);if(!(El({member:e})&&!Al({member:e,site:t})&&Kl({site:t}))||!kl({member:e}))return null;let a=r===`continueGiftSubscription:running`;return(0,q.jsx)(`div`,{className:`gh-portal-cancelcontinue-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-cancel-banner`,children:[(0,q.jsx)(`p`,{style:{maxWidth:`none`,margin:`0 0 16px`,textAlign:`center`,textWrap:`pretty`},children:K(`Continue with a paid subscription anytime. Your remaining gift period will be added as a free trial.`)}),(0,q.jsx)(df,{onClick:()=>n(`continueGiftSubscription`),isRunning:a,disabled:a,isPrimary:!0,brandColor:i,label:K(`Continue subscription`),style:{width:`100%`}})]})})},cS=e=>(0,q.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`style`,{children:`.a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}`})}),(0,q.jsx)(`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`}),(0,q.jsx)(`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`})]}),lS=()=>{let{member:e,site:t,doAction:n}=(0,_.useContext)(J),r=()=>{let t=Cl({member:e});n(`manageBilling`,{subscriptionId:t.id})},i=()=>{Kl({site:t})&&n(`switchPage`,{page:`accountPlan`,lastPage:`accountHome`})},a=({price:t,isComplimentary:n,subscription:r})=>{let{next_payment:i}=r||{},a=``;if(t){let{amount:e=0,currency:n,interval:r}=t;a=`${Intl.NumberFormat(`en`,{currency:n,style:`currency`}).format(e/100)}/${K(r)}`}let o=kl({member:e});if(El({member:e})&&o)return(0,q.jsxs)(`p`,{className:`gh-portal-account-discountcontainer`,children:[(0,q.jsx)(yf,{className:`gh-portal-account-tagicon`}),(0,q.jsx)(`span`,{children:K(`Gift subscription`)}),(0,q.jsx)(`span`,{className:`gh-portal-account-expiry-separator`,children:`-`}),(0,q.jsx)(`span`,{className:`gh-portal-account-expiry`,children:K(`Expires {expiryDate}`,{expiryDate:o})})]});n&&(a=o?`${K(`Complimentary`)} - ${K(`Expires {expiryDate}`,{expiryDate:o})}`:K(`Complimentary`));let s=``;if(gu({sub:r}))return s=`gh-portal-account-old-price`,(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:s,children:a}),(0,q.jsx)(uS,{subscription:r})]});let c=dS({nextPayment:i});return c&&(s=`gh-portal-account-old-price`),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:s,children:a}),(0,q.jsx)(()=>c?(0,q.jsxs)(`p`,{className:`gh-portal-account-discountcontainer`,"data-testid":`offer-label`,children:[(0,q.jsx)(cS,{className:`gh-portal-account-tagicon`}),(0,q.jsx)(`span`,{children:c})]}):null,{})]})},o=({isPaid:r})=>{let a=El({member:e});if(a&&!Kl({site:t}))return null;let o=a&&!Al({member:e,site:t});return zl({site:t})&&(!r||a&&!o)?null:o?(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-btn-list`,onClick:e=>{e.stopPropagation(),n(`continueGiftSubscription`)},"data-test-button":`continue-gift-subscription`,children:K(`Continue`)}):(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-btn-list`,onClick:e=>{e.stopPropagation(),i(e)},"data-test-button":`change-plan`,children:K(`Change`)})},s=({defaultCardLast4:e})=>e?(0,q.jsx)(`p`,{children:`**** **** **** ${e}`}):null,c=({defaultCardLast4:e})=>{let{action:t}=(0,_.useContext)(J),n=t===`manageBilling:running`?(0,q.jsx)(cf,{className:`gh-portal-billing-button-loader`}):K(`Update`);return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Billing info & receipts`)}),(0,q.jsx)(s,{defaultCardLast4:e})]}),(0,q.jsx)(`span`,{className:`gh-portal-list-action`,"data-test-button":`manage-billing`,"aria-hidden":`true`,children:n})]})},l=Cl({member:e}),u=wl({member:e}),d=El({member:e}),f=Tl({member:e});if(l||u){let{price:t,default_payment_card_last4:n}=l||{},r=K(`Plan`);return Rl({member:e})&&(r=Rl({member:e})),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsxs)(`h3`,{children:[r,l?.cancel_at_period_end&&(0,q.jsx)(`span`,{className:`gh-portal-canceled-badge`,children:K(`Canceled`)})]}),(0,q.jsx)(a,{price:t,isComplimentary:u,subscription:l})]}),(0,q.jsx)(o,{isPaid:f})]}),!u&&!d&&(0,q.jsx)(c,{defaultCardLast4:n})]})}return null};function uS({subscription:e}){return gu({sub:e})?(0,q.jsx)(`p`,{className:`gh-portal-account-discountcontainer`,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(`span`,{children:K(`Free Trial – Ends {trialEnd}`,{trialEnd:ol(e.trial_end_at)})})})}):null}function dS({nextPayment:e}){if(!e)return``;let t=e.discount;if(!t)return``;let n=t.end?K(`Ends {offerEndDate}`,{offerEndDate:ol(t.end)}):K(`Forever`);return`${`${Intl.NumberFormat(`en`,{currency:e.currency,style:`currency`}).format(e.amount/100)}/${K(e.interval)}`}${n?` — ${n}`:``}`}function fS({site:e,member:t}){return Mf({site:e})&&Tl({member:t??void 0})&&!El({member:t??void 0})}function pS(){let{member:e,site:t,doAction:n}=(0,_.useContext)(J),r=fS({site:t,member:e});if((0,_.useEffect)(()=>{r&&xf(t?.url)},[r,t?.url]),!r)return null;let i=()=>{n(`switchPage`,{page:`gift`,lastPage:`accountHome`})};return(0,q.jsx)(`div`,{className:`gh-portal-list gh-portal-gift-card`,children:(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Gift membership`)}),(0,q.jsx)(`p`,{children:K(`For a friend or colleague`)})]}),(0,q.jsxs)(`span`,{"aria-hidden":`true`,className:`gh-portal-list-action`,"data-test-button":`give-gift-subscription`,children:[(0,q.jsx)(yf,{className:`gh-portal-gift-card-icon`}),K(`Buy`)]})]})})}function mS(){let{member:e,site:t,doAction:n}=(0,_.useContext)(J),{newsletters:r}=e,i=!!r?.length,a=K(i?`Subscribed`:`Unsubscribed`),o=()=>{let r=fu({site:t}),i=e?.newsletters?.length?[]:r;n(`updateNewsletterPreference`,{newsletters:i})};return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,"aria-pressed":i,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail email-newsletter`,children:[(0,q.jsx)(`h3`,{children:K(`Email newsletter`)}),(0,q.jsxs)(`p`,{children:[a,` `,Tu({member:e})&&i&&(0,q.jsx)(`button`,{className:`gh-portal-btn-text gh-email-faq-page-button`,onClick:e=>{e.stopPropagation(),n(`switchPage`,{page:`emailReceivingFAQ`,lastPage:`accountHome`})},children:K(`Not receiving emails?`)})]})]}),(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{dataTestId:`default-newsletter-toggle`,id:`default-newsletter-toggle`,label:K(`Email newsletter`),onToggle:e=>{o(e,i)},checked:i,presentational:!0})})]})}var hS=e=>(0,q.jsxs)(`svg`,{fill:`none`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,...e,children:[(0,q.jsx)(`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`}),(0,q.jsx)(`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 gS(){return(0,q.jsxs)(`p`,{className:`gh-portal-email-notice`,children:[(0,q.jsx)(hS,{className:`gh-portal-email-notice-icon`}),(0,q.jsx)(`span`,{className:`gh-mobile-only`,children:K(`You're not receiving emails`)}),(0,q.jsx)(`span`,{className:`gh-desktop-only`,children:K(`You're currently not receiving emails`)})]})}function _S(){let{doAction:e,member:t,site:n}=(0,_.useContext)(J),r=mu({member:t}),i=Ol({site:n}),a=Ql({site:n}),o=r?`emailSuppressed`:`accountEmail`,s=!i&&!a,c=()=>r||s?(0,q.jsx)(gS,{}):(0,q.jsx)(`p`,{children:K(`Update your preferences`)}),l=()=>{e(`switchPage`,{page:o,lastPage:`accountHome`})};return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:l,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Emails`)}),c()]}),(0,q.jsx)(`span`,{className:`gh-portal-list-action`,"data-test-button":`manage-newsletters`,"aria-hidden":`true`,children:K(`Manage`)})]})}var vS=()=>{let{member:e,site:t}=(0,_.useContext)(J),n=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},r=n?.enabled===!0,i=e?.uuid,a=Qu(),[o,s]=(0,_.useState)(a&&r);return(0,_.useEffect)(()=>{if(a){s(r);return}if(!r||!i){s(!1);return}s(!1);let e=new AbortController;return(async()=>{try{let t=await fetch(`https://partner.transistor.fm/ghost/member/${i}`,{signal:e.signal});if(t.ok){let n=await t.json();e.signal.aborted||s(n?.member===!0)}}catch(t){if(e.signal.aborted)return;console.warn(`Error in Transistor request`,t)}})(),()=>e.abort()},[r,i,a]),{transistor:{enabled:r,hasPodcasts:o,memberUuid:i,settings:n}}},yS=(e,t)=>pu({site:e})&&Ol({site:e})||Ql({site:e})||mu({member:t}),bS=e=>!pu({site:e})&&Ol({site:e})&&!Ql({site:e}),xS=()=>{let{member:e,doAction:t,site:n}=(0,_.useContext)(J),{name:r,email:i}=e,{transistor:a}=vS(),o=()=>{t(`switchPage`,{page:`accountProfile`,lastPage:`accountHome`})},s=yS(n,e),c=bS(n);return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-list`,children:[(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:r&&!Zl({site:n})?r:K(`Account`)}),(0,q.jsx)(`p`,{children:i})]}),(0,q.jsx)(`span`,{"data-test-button":`edit-profile`,className:`gh-portal-list-action`,"aria-hidden":`true`,children:K(`Edit`)})]}),(0,q.jsx)(lS,{}),s&&(0,q.jsx)(_S,{}),c&&(0,q.jsx)(mS,{}),a.enabled&&(0,q.jsx)(Xx,{hasPodcasts:a.hasPodcasts,memberUuid:a.memberUuid,settings:a.settings})]}),(0,q.jsx)(pS,{})]})},SS=()=>(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-account-main`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(rS,{}),(0,q.jsxs)(`section`,{className:`gh-portal-account-data`,children:[(0,q.jsx)(aS,{}),(0,q.jsx)(sS,{}),(0,q.jsx)(oS,{}),(0,q.jsx)(xS,{})]})]}),CS=class extends _.Component{static contextType=J;componentDidMount(){let{member:e,site:t}=this.context;ql({site:t})||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(){let{member:e,site:t}=this.context,n=Ou({site:t});return!e||!ql({site:t})?null:(0,q.jsxs)(`div`,{className:`gh-portal-account-wrapper`,children:[(0,q.jsx)(SS,{}),(0,q.jsx)(nS,{onClose:()=>this.context.doAction(`closePopup`),handleSignout:e=>this.handleSignout(e),supportAddress:n})]})}},wS=class extends _.Component{static contextType=J;constructor(e,t){super(e,t);let{name:n=``,email:r=``,metafields:i}=t.member||{};this.state={name:n,email:r,metafields:i?.custom||{}}}componentDidMount(){let{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(e=>({errors:Nv({fields:this.getInputFields({state:e})})}),()=>{let{email:e,name:t,errors:n}=this.state;if(!(n&&Object.values(n).filter(e=>!!e).length>0)){this.context.doAction(`clearPopupNotification`);let n=Yp(this.customFields(),this.state.metafields,this.context.member.metafields?.custom||{});this.context.doAction(`updateProfile`,{email:e,name:t,...n?{metafields:n}:{}})}})}renderSaveButton(){let e=this.context.action===`updateProfile:running`,t=K(`Save`);return this.context.action===`updateProfile:failed`&&(t=K(`Retry`)),(0,q.jsx)(df,{dataTestId:`save-button`,isRunning:e,onClick:e=>this.onProfileSave(e),disabled:!!e,brandColor:this.context.brandColor,label:t,style:{width:`100%`}})}renderDeleteAccountButton(){return(0,q.jsx)(`div`,{style:{cursor:`pointer`,color:`red`},role:`button`,children:K(`Delete account`)})}renderAccountFooter(){return(0,q.jsx)(`footer`,{className:`gh-portal-action-footer`,children:this.renderSaveButton()})}renderHeader(){return(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:e=>this.onBack(e)}),(0,q.jsx)(`h3`,{className:`gh-portal-main-title`,children:K(`Account settings`)})]})}renderUserAvatar(){return(0,q.jsx)(`div`,{style:{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`},children:(0,q.jsx)(Qc,{gravatar:this.context.member&&this.context.member.avatar_image,style:{userIcon:{color:`black`,width:`56px`,height:`56px`}}})})}handleInputChange(e,t){this.setState({[t.name]:e.target.value})}handleCustomFieldChange(e,t,n){this.setState(({metafields:r})=>({metafields:{...r,[e.key]:Xp(e,r[e.key],t,n)}}))}customFields(){return Gp(this.context.customFields)}getInputFields({state:e,fieldNames:t}){let n=e.errors||{},r=[{type:`text`,value:e.name,placeholder:K(`Jamie Larson`),label:K(`Name`),name:`name`,required:!1,errorMessage:n.name||``},{type:`email`,value:e.email,placeholder:K(`jamie@example.com`),label:K(`Email`),name:`email`,required:!0,errorMessage:n.email||``}];return t&&t.length>0?r.filter(e=>t.includes(e.name)):r}onKeyDown(e){e.keyCode===13&&this.onProfileSave(e)}renderProfileData(){let e=this.customFields();return(0,q.jsxs)(`div`,{className:`gh-portal-section`,children:[(0,q.jsx)(Pp,{fields:this.getInputFields({state:this.state}),onChange:(e,t)=>this.handleInputChange(e,t),onKeyDown:(e,t)=>this.onKeyDown(e,t)}),e.length>0&&(0,q.jsx)(sm,{errors:this.context.fieldErrors||{},fields:e,onChange:(e,t,n)=>this.handleCustomFieldChange(e,t,n),onKeyDown:e=>this.onKeyDown(e),values:this.state.metafields})]})}render(){let{member:e}=this.context;return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-content with-footer`,children:[this.renderHeader(),(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-section`,children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};function TS(){let{brandColor:e,lastPage:t,doAction:n}=(0,_.useContext)(J);return(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,hidden:!t,onClick:()=>{n(`back`)}}),(0,q.jsx)(`h3`,{className:`gh-portal-main-title`,children:K(`Email preferences`)})]})}function ES({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){let r=t.some(t=>t.id===e?.id),i=()=>{let i=[];i=r?t.filter(t=>t.id!==e.id):t.filter(t=>t.id!==e.id).concat(e),n(i)};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`newsletter-toggle`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:e.name}),(0,q.jsx)(`p`,{children:e?.description})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:e.id,label:e.name,onToggle:i,checked:r,dataTestId:`switch-input`,presentational:!0})})]})}function DS({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){let{doAction:r}=(0,_.useContext)(J),i=!!n,a=(0,_.useRef)(!1);if(!t)return null;let o=async()=>{if(!a.current){a.current=!0;try{await e(!i),r(`showPopupNotification`,{action:`updated:success`,message:K(`Comment preferences updated.`)})}finally{a.current=!1}}};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`comment-toggle`,role:`button`,tabIndex:0,"aria-pressed":i,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Comments`)}),(0,q.jsx)(`p`,{children:K(`Get notified when someone replies to your comment`)})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:`comments`,label:K(`Comments`),onToggle:o,checked:i,dataTestId:`switch-input`,presentational:!0})})]})}function OS({updateUpdatesAndAnnouncements:e,canChangeUpdatesAndAnnouncements:t,enableUpdatesAndAnnouncements:n}){let{doAction:r,site:i}=(0,_.useContext)(J),a=(0,_.useRef)(!1);if(!t)return null;let o=async()=>{if(!a.current){a.current=!0;try{await e(!n),r(`showPopupNotification`,{action:`updated:success`,message:K(`Email preferences updated.`)})}finally{a.current=!1}}};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`updates-and-announcements-toggle`,role:`button`,tabIndex:0,"aria-pressed":!!n,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Updates & announcements`)}),(0,q.jsx)(`p`,{children:K(`Occasional updates from {siteTitle}`,{siteTitle:i?.title})})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:`updates-and-announcements`,label:K(`Updates & announcements`),onToggle:o,checked:n,dataTestId:`switch-input`,presentational:!0})})]})}function kS({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){let{site:r}=(0,_.useContext)(J),i=fu({site:r});return n?i.map(n=>(0,q.jsx)(ES,{newsletter:n,subscribedNewsletters:e,setSubscribedNewsletters:t},n?.id)):null}function AS(){let{doAction:e}=(0,_.useContext)(J);return(0,q.jsxs)(`section`,{className:`gh-portal-list-help`,children:[(0,q.jsx)(`span`,{className:`gh-portal-list-help-label`,children:K(`Not receiving emails?`)}),(0,q.jsxs)(`button`,{className:`gh-portal-btn-text gh-email-faq-page-button`,onClick:()=>e(`switchPage`,{page:`emailReceivingFAQ`,pageData:{direct:!1}}),children:[K(`Get help`),` `,(0,q.jsx)(`span`,{className:`right-arrow`,children:`→`})]})]})}function jS({site:e,isPaid:t}){return t?(0,q.jsx)(`p`,{className:`gh-portal-btn-unsubscribe-note`,children:K(`Unsubscribing from emails will not cancel your paid subscription to {title}`,{title:e?.title})}):null}function MS({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:r,updateCommentNotifications:i,updateUpdatesAndAnnouncements:a,unsubscribeAll:o,isPaidMember:s,isCommentsEnabled:c,enableCommentNotifications:l,canChangeUpdatesAndAnnouncements:u,enableUpdatesAndAnnouncements:d}){let{brandColor:f,member:p,site:m}=(0,_.useContext)(J),h=(0,_.useRef)(!!n?.length).current,g=d!=null,v=g?d:h,y=c&&!l||!c,b=u&&!v||!u,x=!n?.length&&y&&b;return(0,q.jsxs)(`div`,{className:`gh-portal-content with-footer`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-email-preferences-header`,children:[(0,q.jsx)(TS,{}),(0,q.jsx)(t||(()=>null),{})]}),(0,q.jsx)(vf,{brandColor:f}),(0,q.jsx)(`div`,{className:`gh-portal-section flex`,children:(0,q.jsxs)(`div`,{className:`gh-portal-list`,children:[(0,q.jsx)(kS,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:e=>{let t=e.map(e=>({id:e.id}));u&&!g?r(t,v):r(t)}}),(0,q.jsx)(DS,{isCommentsEnabled:c,enableCommentNotifications:l,updateCommentNotifications:i}),(0,q.jsx)(OS,{canChangeUpdatesAndAnnouncements:u,enableUpdatesAndAnnouncements:v,updateUpdatesAndAnnouncements:a}),Tu({member:p})&&!x&&(0,q.jsx)(AS,{})]})}),(0,q.jsxs)(`div`,{className:`gh-portal-btn-unsubscribe`,children:[(0,q.jsx)(df,{isRunning:!1,onClick:()=>{o()},disabled:x,brandColor:f,isPrimary:!1,label:K(`Unsubscribe from all emails`),isDestructive:!0,style:{width:`100%`},dataTestId:`unsubscribe-from-all-emails`}),(0,q.jsx)(jS,{isPaid:s,site:m})]})]})}function NS(){let{member:e,doAction:t,site:n,pageData:r}=(0,_.useContext)(J),i,a;r&&(i=r.newsletterUuid,a=r.action);let[o,s]=(0,_.useState)(!0),c=fu({site:n}),l=Ol({site:n});(0,_.useEffect)(()=>{e||t(`switchPage`,{page:`signin`})},[e,t]),(0,_.useEffect)(()=>{if(i&&a===`unsubscribe`){let n=e?.newsletters.filter(e=>e.uuid!==i);f(n),s(!1),t(`updateNewsletterPreference`,{newsletters:n})}},[]);let u=()=>{if(r.comments&&p)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${o?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive emails when someone replies to your comments.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:e?.email})}})})});let t=c?.find(e=>e.uuid===r.newsletterUuid);return t?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${o?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive {newsletterName} newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:e?.email}),newsletterName:(0,q.jsx)(`strong`,{children:t?.name})}})})}):null},[d,f]=(0,_.useState)([...e?.newsletters||[]]),{comments_enabled:p}=n,m=!!n.labs?.automations,{enable_comment_notifications:h,enable_updates_and_announcements:g}=e||{};return(0,_.useEffect)(()=>{f(e?.newsletters||[])},[e?.newsletters]),(0,q.jsx)(MS,{hasNewslettersEnabled:l,notification:i?u:null,subscribedNewsletters:d,updateSubscribedNewsletters:(e,n)=>{f(e),t(`updateNewsletterPreference`,{newsletters:e,enableUpdatesAndAnnouncements:n}),t(`showPopupNotification`,{action:`updated:success`,message:K(`Email preferences updated.`)})},updateCommentNotifications:async e=>{t(`updateNewsletterPreference`,{enableCommentNotifications:e})},updateUpdatesAndAnnouncements:async e=>{t(`updateNewsletterPreference`,{enableUpdatesAndAnnouncements:e})},unsubscribeAll:()=>{f([]),t(`showPopupNotification`,{action:`updated:success`,message:K(`Unsubscribed from all emails.`)});let e={newsletters:[]};p&&(e.enableCommentNotifications=!1),m&&(e.enableUpdatesAndAnnouncements=!1),t(`updateNewsletterPreference`,e)},isPaidMember:Tl({member:e}),isCommentsEnabled:p!==`off`,enableCommentNotifications:h,canChangeUpdatesAndAnnouncements:m,enableUpdatesAndAnnouncements:g})}function PS(){let{site:e}=(0,_.useContext)(J),t=e.icon;return t?(0,q.jsx)(`img`,{className:`gh-portal-unsubscribe-logo`,src:t,alt:e.title}):null}function FS(){let{site:e}=(0,_.useContext)(J),t=e.title||``;return(0,q.jsxs)(`header`,{className:`gh-portal-header`,children:[(0,q.jsx)(PS,{}),(0,q.jsx)(`h2`,{className:`gh-portal-publication-title`,children:t})]})}function IS({message:e}){let{doAction:t}=(0,_.useContext)(J);return(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-feedback with-footer`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-feedback-icon gh-feedback-icon-error`,children:(0,q.jsx)(Wd,{})}),(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`That didn't go to plan`)}),(0,q.jsx)(`div`,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:e})}),(0,q.jsx)(df,{style:{width:`100%`},retry:!1,onClick:()=>t(`closePopup`),disabled:!1,brandColor:`#000000`,label:K(`Close`),isRunning:!1,tabIndex:3,classes:`sticky bottom`})]})}async function LS({api:e,memberUuid:t,key:n,newsletters:r,enableCommentNotifications:i,enableUpdatesAndAnnouncements:a}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:r,enableCommentNotifications:i,enableUpdatesAndAnnouncements:a})}catch{}}function RS(){let{site:e,api:t,pageData:n,member:r,doAction:i}=(0,_.useContext)(J),[a,o]=(0,_.useState)(),s=!!r&&r.uuid!==n.uuid,[c,l]=(0,_.useState)(!0),u=fu({site:e}),d=u.filter(e=>e.subscribe_on_signup),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(d),[g,v]=(0,_.useState)(!1),{comments_enabled:y}=e,b=!!e.labs?.automations,{enable_comment_notifications:x=!1,enable_updates_and_announcements:S}=a||{},C=Ol({site:e}),w=async(e,a)=>{let o={newsletters:e};a!==void 0&&(o.enableUpdatesAndAnnouncements=a),r?i(`updateNewsletterPreference`,o):await LS({api:t,memberUuid:n.uuid,key:n.key,...o}),h(e);let s={action:`updated:success`,message:K(`Email preferences updated.`)};i(`showPopupNotification`,s)},T=async e=>{let a;r?(await i(`updateNewsletterPreference`,{enableCommentNotifications:e}),a={...r,enable_comment_notifications:e}):a=await LS({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:e}),o(a),i(`showPopupNotification`,{action:`updated:success`,message:K(`Comment preferences updated.`)})},E=async e=>{let a;r?(await i(`updateNewsletterPreference`,{enableUpdatesAndAnnouncements:e}),a={...r,enable_updates_and_announcements:e}):a=await LS({api:t,memberUuid:n.uuid,key:n.key,enableUpdatesAndAnnouncements:e}),o(a),i(`showPopupNotification`,{action:`updated:success`,message:K(`Email preferences updated.`)})},D=async()=>{let e;r?(await i(`updateNewsletterPreference`,{newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),e={...r},e.newsletters=[],e.enable_comment_notifications=!1,e.enable_updates_and_announcements=!1):e=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),h([]),o(e),i(`showPopupNotification`,{action:`updated:success`,message:K(`Unsubscribed from all emails.`)})};return(0,_.useEffect)(()=>{(async()=>{if(s)return;let e;try{e=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(e??null),l(!1)}catch(e){console.error(`[PORTAL] Error fetching member newsletters`,e),o(null),l(!1);return}if(e===null)return;let r=e?.newsletters||[];h(r),u?.length===1&&!y&&!n.newsletterUuid?await w([]):n.newsletterUuid?await w(r?.filter(e=>e.uuid!==n.newsletterUuid)):n.comments&&y?await T(!1):n.updatesAndAnnouncements&&b&&await E(!1)})()},[y,b,s,n.uuid,n.newsletterUuid,n.comments,n.updatesAndAnnouncements,e.url,u?.length]),s?(0,q.jsx)(IS,{message:K(`This unsubscribe link belongs to a different email address than the one you are signed in with.`)}):c?(0,q.jsx)(mx,{}):a?u?.length===1&&!y&&!g?(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-unsubscribe with-footer`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(FS,{}),(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Successfully unsubscribed`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive this newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})}),(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:(0,q.jsx)(Bd,{string:K(`Didn't mean to do this? Manage your preferences <button>here</button>.`),mapping:{button:(0,q.jsx)(`button`,{className:`gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline`,onClick:()=>{v(!0)}})}})})]})]}):(0,q.jsx)(MS,{hasNewslettersEnabled:C,notification:()=>{if(n.comments&&y)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive emails when someone replies to your comments.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})})});if(n.updatesAndAnnouncements&&b)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive updates & announcements.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})})});let e=u?.find(e=>e.uuid===n.newsletterUuid);return e?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive {newsletterName} newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email}),newsletterName:(0,q.jsx)(`strong`,{children:e?.name})}})})}):null},subscribedNewsletters:m,updateSubscribedNewsletters:async(e,t)=>{await w(e,t),p(!0)},updateCommentNotifications:T,updateUpdatesAndAnnouncements:E,unsubscribeAll:async()=>{await D(),p(!0)},isPaidMember:a?.status!==`free`,isCommentsEnabled:y!==`off`,enableCommentNotifications:x,canChangeUpdatesAndAnnouncements:b,enableUpdatesAndAnnouncements:S}):(0,q.jsx)(IS,{message:K(`We couldn't unsubscribe you as the email address was not found. Please contact the site owner.`)})}function zS(){let{brandColor:e,lastPage:t,doAction:n,action:r,site:i}=(0,_.useContext)(J);(0,_.useEffect)(()=>{[`removeEmailFromSuppressionList:success`].includes(r)&&n(`refreshMemberData`),[`removeEmailFromSuppressionList:failed`,`refreshMemberData:failed`].includes(r)&&n(`back`),[`refreshMemberData:success`].includes(r)&&(pu({site:i})||Ql({site:i})?(n(`switchPage`,{page:`accountEmail`,lastPage:`accountHome`}),n(`showPopupNotification`,{message:K(`You have been successfully resubscribed`)})):n(`back`))},[r,n,i,K]);let a=[`removeEmailFromSuppressionList:running`,`refreshMemberData:running`].includes(r);return(0,q.jsxs)(`div`,{className:`gh-email-suppressed-page`,children:[(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,hidden:!t,onClick:()=>{n(`back`)}}),(0,q.jsx)(vf,{})]}),(0,q.jsx)(hS,{className:`gh-email-suppressed-page-icon`}),(0,q.jsxs)(`div`,{className:`gh-email-suppressed-page-text`,children:[(0,q.jsx)(`h3`,{className:`gh-portal-main-title gh-email-suppressed-page-title`,children:K(`Emails disabled`)}),(0,q.jsx)(`p`,{children:K(`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.`)})]}),(0,q.jsx)(df,{dataTestId:`resubscribe-email`,classes:`gh-portal-confirm-button`,onClick:()=>{n(`removeEmailFromSuppressionList`)},disabled:a,brandColor:e,label:K(`Re-enable emails`),isRunning:a})]})}function BS(){let{brandColor:e,doAction:t,site:n,pageData:r}=(0,_.useContext)(J),i=`mailto:${Ou({site:n})}`;return(0,q.jsxs)(`div`,{className:`gh-email-suppression-faq`,children:[!(r&&r.direct)&&(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,onClick:()=>{t(`switchPage`,{page:`emailSuppressed`,lastPage:`accountHome`})}}),(0,q.jsx)(vf,{})]}),(0,q.jsxs)(`div`,{className:`gh-longform`,children:[(0,q.jsx)(`h3`,{children:K(`Why has my email been disabled?`)}),(0,q.jsx)(`p`,{children:K(`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).`)}),(0,q.jsx)(`h4`,{children:K(`Spam complaints`)}),(0,q.jsx)(`p`,{children:K(`If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`h4`,{children:K(`Permanent failure (bounce)`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:K(`In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-btn-branded no-margin-right`,href:i,onClick:()=>{i&&window.open(i)},children:K(`Need more help? Contact support`)})})]})]})}function VS(){let{brandColor:e,doAction:t,site:n,lastPage:r,member:i,pageData:a}=(0,_.useContext)(J),o=Ou({site:n}),s=`mailto:${o}`,c=ku({site:n});return(0,q.jsxs)(`div`,{className:`gh-email-receiving-faq`,children:[(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[!(a&&a.direct)&&(0,q.jsx)(mf,{brandColor:e,onClick:()=>{r?t(`switchPage`,{page:`accountHome`}):t(`switchPage`,{page:`accountEmail`,lastPage:`accountHome`})}}),(0,q.jsx)(vf,{})]}),(0,q.jsxs)(`div`,{className:`gh-longform`,children:[(0,q.jsx)(`h3`,{children:K(`Help! I'm not receiving emails`)}),(0,q.jsx)(`p`,{children:K(`If you're not receiving the email newsletter you've subscribed to, here are a few things to check.`)}),(0,q.jsx)(`h4`,{children:K(`Verify your email address is correct`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:i.email}),button:(0,q.jsx)(`button`,{className:`gh-portal-btn-text`,onClick:()=>t(`switchPage`,{lastPage:`emailReceivingFAQ`,page:`accountProfile`})})}})}),(0,q.jsx)(`h4`,{children:K(`Check spam & promotions folders`)}),(0,q.jsx)(`p`,{children:K(`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".`)}),(0,q.jsx)(`h4`,{children:K(`Create a new contact`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(`h4`,{children:K(`Check with your mail provider`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(`h4`,{children:K(`Get in touch for help`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`a`,{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}var HS=()=>{let[e,t]=(0,_.useState)(!0),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),{member:o,site:s}=(0,_.useContext)(J);return(0,_.useEffect)(()=>{async function e(){let e=s.url,n=window.location.origin+window.location.pathname,i=o?`${n}?action=support&success=true`:`${n}#/portal/support/success`,c=n,l=px({siteUrl:e});try{let e=await l.member.checkoutDonation({successUrl:i,cancelUrl:c,personalNote:K(`Add a personal note`)});e.url&&window.location.replace(e.url)}catch(e){e.type&&e.type===`DisabledFeatureError`?a(K(`This site is not accepting payments at the moment.`)):r(K(`Something went wrong, please try again later.`)),t(!1)}}s&&s.donations_enabled===!1?(a(K(`This site is not accepting donations at the moment.`)),t(!1)):e()},[]),e?(0,q.jsx)(`div`,{children:(0,q.jsx)(mx,{})}):n?(0,q.jsx)(Rx,{error:n}):i?(0,q.jsx)(Rx,{error:i}):null};function US({initialState:e,key:t,parse:n}){let[r,i]=(0,_.useState)(()=>{let r=typeof e==`function`?e():e;try{let e=window.sessionStorage.getItem(t);return e===null?r:n(JSON.parse(e))??r}catch{return r}});return(0,_.useEffect)(()=>{try{window.sessionStorage.setItem(t,JSON.stringify(r))}catch{}},[t,r]),[r,i]}function WS({key:e}){try{window.sessionStorage.removeItem(e)}catch{}}var GS=Tv,KS=bp;function qS({deliveryDateError:e,deliveryMethod:t,effectiveDeliveryDate:n,giftMessage:r,maxDeliveryDate:i,maxMessageLength:a,minDeliveryDate:o,onChangeDeliveryDate:s,onChangeDeliveryMethod:c,onChangeGiftMessage:l,onChangeRecipientEmail:u,onChangeRecipientName:d,recipientEmailField:f,recipientNameField:p}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-label`,children:K(`How would you like to share this gift?`)}),(0,q.jsxs)(`div`,{"aria-label":K(`Delivery method`),className:`gh-portal-gift-duration-switch`,role:`radiogroup`,children:[(0,q.jsx)(`button`,{"aria-checked":t===`email`,className:`gh-portal-btn`+(t===`email`?` active`:``),"data-test-button":`delivery-method-email`,role:`radio`,type:`button`,onClick:()=>c(`email`),children:K(`Email it to them`)}),(0,q.jsx)(`button`,{"aria-checked":t===`link`,className:`gh-portal-btn`+(t===`link`?` active`:``),"data-test-button":`delivery-method-link`,role:`radio`,type:`button`,onClick:()=>c(`link`),children:K(`I'll share it myself`)})]})]}),(0,q.jsx)(`div`,{"aria-hidden":t!==`email`,className:`gh-portal-gift-checkout-reveal`,"data-open":t===`email`,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(KS,{...p,onChange:e=>d(e.target.value)}),(0,q.jsx)(KS,{...f,onChange:e=>u(e.target.value)}),(0,q.jsx)(`div`,{className:`gh-portal-input-labelcontainer`,children:(0,q.jsx)(`label`,{className:`gh-portal-input-label`,htmlFor:`gift-message`,children:K(`Optional message`)})}),(0,q.jsx)(`textarea`,{className:`gh-portal-input gh-portal-gift-checkout-textarea`,"data-test-input":`gift-message`,id:`gift-message`,maxLength:a,placeholder:K(`Add a short note to go with your gift`),value:r,onChange:e=>l(e.target.value)}),(0,q.jsx)(`div`,{"aria-hidden":r.length===0,className:`gh-portal-gift-checkout-reveal`,"data-open":r.length>0,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`p`,{className:`gh-portal-gift-checkout-message-count`,children:[r.length,`/`,a]})})}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-delivery-date`,children:[(0,q.jsx)(`div`,{className:`gh-portal-input-labelcontainer`,children:(0,q.jsx)(`label`,{className:`gh-portal-input-label`,htmlFor:`gift-delivery-date`,children:K(`Delivery date`)})}),(0,q.jsx)(GS,{ariaLabel:K(`Delivery date`),hasError:!!e,id:`gift-delivery-date`,max:i,min:o,minLabel:K(`Now`),value:n,onChange:s}),e&&(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-delivery-error`,children:e})]})]})})})]})}var JS=`ghost-portal-gift-form-state`;function YS({buyerName:e=``}={}){return{version:1,plan:{selectedDuration:null,selectedProductId:null,buyerEmail:``,buyerName:e,completed:!1},delivery:{method:`email`,emailDraft:{recipientEmail:``,recipientName:``,message:``,timing:{type:`immediate`}}}}}function XS(e,t){return typeof e==`string`&&e.length<=t}function ZS(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.plan,r=t.delivery,i=r?.emailDraft,a=i?.timing,o=n?.selectedDuration===null||Cf.includes(n?.selectedDuration),s=a?.type===`immediate`||a?.type===`scheduled`&&typeof a.date==`string`;return t.version!==1||!n||!r||!i||!o||!(n.selectedProductId===null||typeof n.selectedProductId==`string`)||!XS(n.buyerEmail,191)||!XS(n.buyerName,191)||typeof n.completed!=`boolean`||![`email`,`link`].includes(r.method)||!XS(i.recipientEmail,191)||!XS(i.recipientName,191)||!XS(i.message,250)||!s?null:t}function QS(){WS({key:JS})}var $S=bp;function eC({activeDuration:e,offeredDurations:t,onSelectDuration:n}){return t.length<2?null:(0,q.jsx)(`div`,{"aria-label":K(`Gift duration`),className:`gh-portal-gift-duration-switch`,role:`radiogroup`,children:t.map(t=>{let r=t===e;return(0,q.jsx)(`button`,{"aria-checked":r,className:`gh-portal-btn`+(r?` active`:``),"data-test-button":`switch-duration-${t}`,role:`radio`,type:`button`,onClick:()=>n(t),children:Gd({cadence:`month`,duration:t})},t)})})}function tC({activeDuration:e,activeDurationLabel:t,activeProduct:n,buyerEmailField:r,buyerNameField:i,isSingleTier:a,offeredDurations:o,onBuyerEmailChange:s,onBuyerNameChange:c,onSelectDuration:l,onSelectProduct:u,products:d,showBuyerEmail:f,showBuyerName:p,siteTitle:m,tierPriceLabel:h}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`header`,{className:`gh-portal-gift-checkout-header`,children:[(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Gift a membership`)}),(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-subtitle`,children:K(`Share a full membership to {siteTitle} with a friend or colleague`,{siteTitle:m})})]}),(p||f)&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[p&&(0,q.jsx)($S,{...i,onChange:e=>c(e.target.value)}),f&&(0,q.jsx)($S,{...r,onChange:e=>s(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-label`,children:K(a?`Membership details`:`Tier`)}),o.length>1?(0,q.jsx)(eC,{activeDuration:e,offeredDurations:o,onSelectDuration:l}):(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-single-duration`,"data-test-single-duration":!0,children:K(`{duration} membership`,{duration:t})})]}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-section`,children:(0,q.jsx)(`div`,{"aria-label":a?void 0:K(`Choose a tier`),className:`gh-portal-gift-checkout-tiers`+(a?` single`:``),role:a?void 0:`radiogroup`,children:d.map(t=>{let r=t.id===n.id,i=t.benefits||[];return(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-item`+(r&&!a?` selected`:``),children:[(0,q.jsxs)(`button`,{"aria-checked":a?void 0:r,className:`gh-portal-gift-checkout-tier`,"data-test-tier":t.name,role:a?void 0:`radio`,type:`button`,onClick:()=>u(t.id),children:[!a&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-tier-radio`}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-content`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-heading`,children:[(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-tier-name`,children:t.name}),(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-tier-price`,children:h(t,e)})]}),t.description&&(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-tier-description`,children:t.description})]})]}),i.length>0&&(0,q.jsx)(`div`,{"aria-hidden":!r,className:`gh-portal-gift-checkout-tier-benefits`,"data-open":r,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-tier-benefits-inner`,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-benefits`,children:i.map((e,t)=>{let n=e.id||`benefit-${t}`;return(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-benefit`,children:[(0,q.jsx)(Ff,{"aria-hidden":`true`,focusable:`false`}),(0,q.jsx)(`span`,{children:e.name})]},n)})})})})]},t.id)})})})]})}var nC=e=>(0,q.jsxs)(`svg`,{width:39,height:27,viewBox:`0 0 39 27`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsxs)(`g`,{fill:`currentColor`,children:[(0,q.jsx)(`path`,{d:`M9 0a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z`}),(0,q.jsx)(`path`,{d:`M18 7c0 10-4.8 17.2-13.4 20L3 22.4C9.4 20.2 13 15.6 13 8Z`})]}),(0,q.jsxs)(`g`,{fill:`currentColor`,transform:`translate(21 0)`,children:[(0,q.jsx)(`path`,{d:`M9 0a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z`}),(0,q.jsx)(`path`,{d:`M18 7c0 10-4.8 17.2-13.4 20L3 22.4C9.4 20.2 13 15.6 13 8Z`})]})]}),rC=({recipientName:e,recipientEmail:t,buyerName:n,giftMessage:r,deliveryDate:i,isScheduled:a=!1,cadence:o,duration:s,tierName:c,benefits:l=[],siteTitle:u,siteIcon:d})=>{let f=e.trim(),p=t.trim(),m=n.trim(),h=r.trim(),g=ol(new Date),v=ol(dl(i))||g,[y,b]=(0,_.useState)(``);(0,_.useEffect)(()=>{a&&b(v)},[a,v]);let x=a?v:y||g,S=``;S=f&&p?`${f} <${p}>`:p||f;let C={buyerName:(0,q.jsx)(`strong`,{children:m}),duration:s,strong:(0,q.jsx)(`strong`,{}),tierName:(0,q.jsx)(`strong`,{children:c}),siteTitle:u},w=qd({buyerName:m,cadence:o,duration:s,siteTitle:u});return(0,q.jsx)(`div`,{className:`gh-portal-gift-email`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-sheet`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-meta`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-meta-text`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-email-from`,children:u}),(0,q.jsx)(`div`,{"aria-hidden":!S,className:`gh-portal-gift-checkout-reveal`,"data-open":!!S,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-to`,children:[(0,q.jsxs)(`span`,{className:`gh-portal-gift-email-meta-label`,children:[K(`To`),`:`]}),(0,q.jsx)(`span`,{className:`gh-portal-gift-email-to-value`,children:S})]})})})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-date-stack`,children:[(0,q.jsx)(`div`,{"aria-hidden":a,className:`gh-portal-gift-email-date`,"data-active":!a,children:g}),(0,q.jsx)(`div`,{"aria-hidden":!a,className:`gh-portal-gift-email-date`,"data-active":a,children:x})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-body`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-email-lockup`,children:d?(0,q.jsx)(`img`,{alt:u,className:`gh-portal-gift-email-lockup-icon`,src:d}):(0,q.jsx)(`span`,{className:`gh-portal-gift-email-lockup-title`,children:u})}),(0,q.jsx)(`h1`,{className:`gh-portal-gift-email-subject`,children:K(`A gift, just for you`)}),(0,q.jsx)(`div`,{"aria-hidden":!f,className:`gh-portal-gift-checkout-reveal`,"data-open":!!f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsx)(`p`,{className:`gh-portal-gift-email-greeting`,children:K(`Hi {recipientName},`,{recipientName:f})})})}),(0,q.jsx)(`p`,{className:`gh-portal-gift-email-lede`,children:(0,q.jsx)(Bd,{mapping:C,string:w})}),(0,q.jsx)(`div`,{"aria-hidden":!h,className:`gh-portal-gift-checkout-reveal`,"data-open":!!h,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`blockquote`,{className:`gh-portal-gift-email-message`,children:[(0,q.jsx)(nC,{"aria-hidden":`true`,className:`gh-portal-gift-email-message-mark`,focusable:`false`}),(0,q.jsx)(`p`,{className:`gh-portal-gift-email-message-text`,children:h}),m&&(0,q.jsx)(`p`,{className:`gh-portal-gift-email-message-from`,children:m})]})})}),l.length>0&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-benefits`,children:[(0,q.jsx)(`p`,{className:`gh-portal-gift-email-benefits-label`,children:K(`What's included`)}),(0,q.jsx)(`div`,{children:l.map((e,t)=>(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-benefit`,children:[(0,q.jsx)(Ff,{"aria-hidden":`true`,focusable:`false`}),(0,q.jsx)(`span`,{children:e.name})]},e?.id||`benefit-${t}`))})]})]})]})})},iC=Sf,aC=rC;function oC({activeDuration:e,activeProduct:t,buyerName:n,cardRef:r,cardTiltProps:i,effectiveDeliveryDate:a,emailDuration:o,giftMessage:s,giftValue:c,minDeliveryDate:l,recipientEmail:u,recipientName:d,showEmailPreview:f,siteIcon:p,siteTitle:m}){return(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-right`,...i,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-right-panel`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-stage`,children:[(0,q.jsx)(`div`,{"aria-hidden":f,className:`gh-portal-gift-checkout-stage-item card`,"data-active":!f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-stack`,children:(0,q.jsx)(iC,{cardRef:r,duration:Gd({cadence:`month`,duration:e}),fromName:n.trim(),giftValue:c,siteIcon:p,siteTitle:m,tierName:t.name})})}),(0,q.jsx)(`div`,{"aria-hidden":!f,className:`gh-portal-gift-checkout-stage-item email`,"data-active":f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-email-stack`,children:(0,q.jsx)(aC,{...o,benefits:t.benefits||[],buyerName:n,deliveryDate:a,giftMessage:s,isScheduled:a>l,recipientEmail:u,recipientName:d,siteIcon:p,siteTitle:m,tierName:t.name})})})]})})})}var sC=`ghostPortalGiftHistory`;function cC(){let e=window.history.state;return e&&typeof e==`object`?e:{}}function lC(){let e=cC()[sC];if(!e||typeof e!=`object`||!(`depth`in e))return null;let{depth:t}=e;return typeof t==`number`&&t>0?{depth:t}:null}function uC(e){return e===`delivery`?`#/portal/gift/delivery`:`#/portal/gift`}function dC(){window.dispatchEvent(new HashChangeEvent(`hashchange`))}function fC({step:e,replace:t=!1}){let n=uC(e);if(t){window.history.replaceState(window.history.state,``,n),dC();return}let r=lC(),i=r?{...cC(),[sC]:{depth:r.depth+1}}:window.history.state;window.history.pushState(i,``,n),dC()}function pC(){window.location.hash!==`#/portal/gift`&&window.history.pushState({...cC(),[sC]:{depth:1}},``,`#/portal/gift`)}function mC(){let e=lC();return e?(window.history.go(-e.depth),!0):!1}var hC=Nv,gC=365;function _C(e){return e===`signup`?`#/portal/signup`:e===`accountHome`?`#/portal/account`:e===`accountPlan`?`#/portal/account/plans`:null}var vC=()=>{let{site:e,member:t,brandColor:n,action:r,doAction:i,lastPage:a,pageData:o}=(0,_.useContext)(J),s=o?.giftStep===`delivery`?`delivery`:`plan`,[c,l]=(0,_.useState)(s),[u,d]=US({key:JS,initialState:()=>YS({buyerName:t?.name||``}),parse:ZS}),[f,p]=(0,_.useState)({}),{cardRef:m,containerProps:h}=Ex(),g=(0,_.useRef)(null),v=(0,_.useRef)(!1),{plan:y,delivery:b}=u,{selectedDuration:x,selectedProductId:S,buyerEmail:C,buyerName:w}=y,{method:T,emailDraft:E}=b,{recipientEmail:D,recipientName:O,message:k,timing:ee}=E;(0,_.useEffect)(()=>{d(e=>e.plan.buyerName||!t?.name?e:{...e,plan:{...e.plan,buyerName:t.name}})},[t?.name]),(0,_.useEffect)(()=>{if(s===`delivery`&&!y.completed){l(`plan`),fC({step:`plan`,replace:!0});return}g.current!==s&&(g.current=s,l(s))},[y.completed,s]);let te=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=te.current,t=e?.ownerDocument;if(!t)return;let n=t.defaultView;t.querySelectorAll(`.gh-portal-popup-wrapper, .gh-portal-popup-container`).forEach(e=>{e.scrollTop=0});for(let t=e.parentElement;t;t=t.parentElement){let e=n?.getComputedStyle(t).overflowY;(e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight&&(t.scrollTop=0)}});return()=>cancelAnimationFrame(e)},[c]);let ne=()=>{let e=_C(a);!mC()&&e&&window.history.replaceState(window.history.state,``,e),i(`back`)},A=()=>{i(`closePopup`)},re=e?.portal_default_plan??null,ie=kf({site:e}),j=Nf({availableDurations:ie,portalDefaultPlan:re,selectedDuration:x}),M=j?Of({site:e,duration:j}):[],ae=x!==null&&ie.includes(x)&&S!==null&&M.some(e=>e.id===S);if((0,_.useEffect)(()=>{!e||!y.completed||ae||(d(e=>({...e,plan:{...e.plan,completed:!1}})),l(`plan`),fC({step:`plan`,replace:!0}))},[y.completed,ae,e]),!e)return(0,q.jsx)(mx,{});function oe(t,n){return jx(Df(t,n),e?.locale)}let se=e.icon,ce=e.title||``;if(!j||M.length===0)return(0,q.jsxs)(`div`,{className:`gh-portal-content gift`,children:[(0,q.jsx)(vf,{onClick:A}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-left`,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-bg`}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-inner`,children:(0,q.jsxs)(`header`,{className:`gh-portal-gift-checkout-header`,children:[(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Gift a membership`)}),(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-subtitle`,children:K(`Gift subscriptions are not available right now.`)})]})})]}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-right`})]})]});let N=M.find(e=>e.id===S)||M[0];if(!N)return null;let le=M.length===1,ue=j===12?{cadence:`year`,duration:1}:{cadence:`month`,duration:j},de=Kd(ue),fe=r===`checkoutGift:running`,P=c===`plan`?!!(f.email||f.buyerName):!!(f.recipientEmail||f.deliveryDate),pe=xl()||fe||P,me=!!t,he=!(t?.name||``).trim(),ge=!me,F=c===`delivery`&&T===`email`,_e=gl(new Date,e.timezone),I=pl(_e,gC),ve=ee.type===`scheduled`?ee.date:_e,ye={type:`email`,value:C,placeholder:K(`jamie@example.com`),label:K(`Your email`),name:`email`,required:!0,maxLength:191,errorMessage:f.email||``},be={type:`email`,value:D,placeholder:K(`taylor@example.com`),label:K(`Recipient's email`),name:`recipientEmail`,required:!1,maxLength:191,errorMessage:f.recipientEmail||``},xe={type:`text`,value:w,placeholder:K(`Jamie Larson`),label:K(`Your name`),name:`buyerName`,required:!0,maxLength:191,errorMessage:f.buyerName||``},Se={type:`text`,value:O,placeholder:K(`Taylor Reid`),label:K(`Recipient's name`),name:`recipientName`,required:!1,maxLength:191,errorMessage:``},Ce=e=>{p(e=>({...e,email:``})),d(t=>({...t,plan:{...t.plan,buyerEmail:e,completed:!1}}))},we=e=>{p(e=>({...e,buyerName:``})),d(t=>({...t,plan:{...t.plan,buyerName:e,completed:!1}}))},L=e=>{p(e=>({...e,recipientEmail:``,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,recipientEmail:e}}}))},Te=e=>{p(e=>({...e,recipientEmail:``,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,method:e}}))},Ee=e=>{p(e=>({...e,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,timing:e===_e?{type:`immediate`}:{type:`scheduled`,date:e}}}}))},De=e=>{d(t=>({...t,plan:{...t.plan,selectedDuration:e,completed:!1}}))},Oe=e=>{d(t=>({...t,plan:{...t.plan,selectedProductId:e,completed:!1}}))},ke=e=>{d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,recipientName:e}}}))},Ae=e=>{d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,message:e}}}))},je=()=>{let e=[];me||e.push({...ye,value:C.trim()}),e.push({...xe,value:w.trim()});let t=hC({fields:e}),n=Object.values(t).some(e=>!!e);p(t),!n&&(d(e=>({...e,plan:{...e.plan,selectedDuration:j,selectedProductId:N.id,completed:!0}})),pC(),v.current=!0,l(`delivery`),fC({step:`delivery`}))},Me=()=>{p({}),l(`plan`),v.current?(v.current=!1,window.history.back()):fC({step:`plan`,replace:!0})};return(0,q.jsxs)(`div`,{ref:te,className:`gh-portal-content gift`,children:[(0,q.jsx)(vf,{onClick:A}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-left`,"data-step":c,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-bg`}),(c===`delivery`||a)&&(0,q.jsx)(Ev,{onBack:()=>c===`delivery`?Me():ne()}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-inner`,children:[c===`plan`?(0,q.jsx)(tC,{activeDuration:j,activeDurationLabel:de,activeProduct:N,buyerEmailField:ye,buyerNameField:xe,isSingleTier:le,offeredDurations:ie,products:M,showBuyerEmail:ge,showBuyerName:he,siteTitle:ce,tierPriceLabel:oe,onBuyerEmailChange:Ce,onBuyerNameChange:we,onSelectDuration:De,onSelectProduct:Oe}):(0,q.jsx)(qS,{deliveryDateError:f.deliveryDate||``,deliveryMethod:T,effectiveDeliveryDate:ve,giftMessage:k,maxDeliveryDate:I,maxMessageLength:250,minDeliveryDate:_e,recipientEmailField:be,recipientNameField:Se,onChangeDeliveryDate:Ee,onChangeDeliveryMethod:Te,onChangeGiftMessage:Ae,onChangeRecipientEmail:L,onChangeRecipientName:ke}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-cta-wrapper`,children:(0,q.jsx)(df,{brandColor:n,classes:`gh-portal-gift-checkout-cta`,dataTestId:c===`plan`?`gift-continue`:`purchase-gift`,disabled:pe,isRunning:c===`delivery`&&fe,label:K(c===`plan`?`Continue to delivery details`:`Continue to payment`),style:{width:`100%`},onClick:c===`plan`?je:()=>{if(fe)return;let e=C.trim(),t=D.trim(),n=O.trim(),r=w.trim(),a=k.trim(),o=T===`email`,s=o&&ve>_e,c=[];me||c.push({...ye,value:e}),o&&t&&c.push({...be,value:t});let u=hC({fields:c});o&&!t&&(u.recipientEmail=K(`Enter the recipient's email address`)),o&&(ve?ve<_e?u.deliveryDate=K(`Choose a date from today onwards`):ve>I&&(u.deliveryDate=K(`Choose a date within the next year`)):u.deliveryDate=K(`Choose a delivery date`));let f=Object.values(u).some(e=>!!e);if(p(u),f){u.email&&(l(`plan`),d(e=>({...e,plan:{...e.plan,completed:!1}})),fC({step:`plan`,replace:!0}));return}i(`checkoutGift`,{tierId:N.id,duration:j,...me?{}:{email:e},deliveryMethod:T,...o?{recipientEmail:t}:{},...o&&n?{recipientName:n}:{},buyerName:r,...o&&a?{personalMessage:a}:{},...s?{deliveryDate:ve}:{}})}})})]})]}),(0,q.jsx)(oC,{activeDuration:j,activeProduct:N,buyerName:w,cardRef:m,cardTiltProps:h,effectiveDeliveryDate:ve,emailDuration:ue,giftMessage:k,giftValue:oe(N,j),minDeliveryDate:_e,recipientEmail:D,recipientName:O,showEmailPreview:F,siteIcon:se,siteTitle:ce})]})]})},yC=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},bC=(e,t)=>`${e}?${new URLSearchParams(t).toString()}`,xC=({shareTitle:e,shareUrl:t})=>{let n=[e,t].filter(Boolean).join(`
5691
+ `;function eS({site:e}){return il+Zx+_f+ip+vp+Qp+yv+Lf({site:e})+hf+lf+pf+Xc+Pb+hb+Vb({site:e})+Vd+Lb+Qx+$x+hx+Sx+``+wx+Dx+kx+Lx+Mx+Vx+qx+Jx}var tS=class extends _.Component{static contextType=J;constructor(e){super(e),this.state={email:``,token:void 0}}componentDidMount(){let{member:e}=this.context;e&&this.context.doAction(`switchPage`,{page:`accountHome`})}handleSignin(e){e.preventDefault(),this.doSignin()}doSignin(){this.setState(e=>({errors:Nv({fields:this.getInputFields({state:e})})}),async()=>{let{email:e,phonenumber:t,errors:n,token:r}=this.state,{redirect:i}=this.context.pageData??{};n&&Object.values(n).filter(e=>!!e).length>0||this.context.doAction(`signin`,{email:e,phonenumber:t,redirect:i,token:r})})}handleInputChange(e,t){let n=t.name;this.setState({[n]:e.target.value})}onKeyDown(e){e.keyCode===13&&this.handleSignin(e)}getInputFields({state:e}){let t=e.errors||{};return[{type:`email`,value:e.email,placeholder:K(`jamie@example.com`),label:K(`Email`),name:`email`,required:!0,errorMessage:t.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(){let{action:e}=this.context,t=!1,n=e===`signin:running`,r=K(n?`Sending login link...`:`Continue`),i=!!n;return e===`signin:failed`&&(r=K(`Retry`),t=!0),(0,q.jsx)(df,{dataTestId:`signin`,retry:t,style:{width:`100%`},onClick:e=>this.handleSignin(e),disabled:i,brandColor:this.context.brandColor,label:r,isRunning:n})}renderSignupMessage(){let{brandColor:e}=this.context;return(0,q.jsxs)(`div`,{className:`gh-portal-signup-message`,children:[(0,q.jsx)(`div`,{children:K(`Don't have an account?`)}),(0,q.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:(0,q.jsx)(`span`,{children:K(`Sign up`)})})]})}renderForm(){let{site:e}=this.context,t=Jl({site:e})&&Wl({site:e});return ql({site:e})?(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(Pp,{fields:this.getInputFields({state:this.state}),onChange:(e,t)=>this.handleInputChange(e,t),onKeyDown:(e,t)=>this.onKeyDown(e,t)})}),(0,q.jsxs)(`footer`,{className:`gh-portal-signin-footer`,children:[this.renderSubmitButton(),t&&this.renderSignupMessage()]})]}):(0,q.jsx)(`section`,{children:(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-members-disabled-notification`,"data-testid":`members-disabled-notification-text`,children:K(`Memberships unavailable, contact the owner for access.`)})})})}renderSiteIcon(){let e={},{site:t}=this.context,n=t.icon;return n?(e.backgroundImage=`url(${n})`,(0,q.jsx)(`img`,{className:`gh-portal-signup-logo`,src:n,alt:this.context.site.title})):ql({site:t})?null:(0,q.jsx)(Pv,{className:`gh-portal-icon gh-portal-icon-invitation`})}renderSiteTitle(){let{site:e}=this.context,t=e.title;return ql({site:e})?(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Sign in`)}):(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:t})}renderFormHeader(){return(0,q.jsxs)(`header`,{className:`gh-portal-signin-header`,children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-logged-out-form-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-content signin`,children:[this.renderFormHeader(),this.renderForm()]})})]})}},nS=({handleSignout:e,supportAddress:t=``})=>{let n=`mailto:${t}`;return(0,q.jsxs)(`footer`,{className:`gh-portal-account-footer`,children:[(0,q.jsx)(`ul`,{className:`gh-portal-account-footermenu`,children:(0,q.jsx)(`li`,{children:(0,q.jsx)(`button`,{"data-test-button":`footer-signout`,className:`gh-portal-btn`,name:`logout`,"aria-label":`logout`,onClick:t=>e(t),children:K(`Sign out`)})})}),(0,q.jsx)(`div`,{className:`gh-portal-account-footerright`,children:(0,q.jsx)(`ul`,{className:`gh-portal-account-footermenu`,children:(0,q.jsx)(`li`,{children:(0,q.jsx)(`a`,{"data-test-link":`footer-support`,className:`gh-portal-btn gh-portal-btn-branded`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:K(`Contact support`)})})})})]})},rS=()=>{let{member:e,brandColor:t}=(0,_.useContext)(J),n=e.avatar_image;return(0,q.jsxs)(`header`,{className:`gh-portal-account-header`,children:[(0,q.jsx)(Qc,{gravatar:n,style:{userIcon:{color:t,width:`56px`,height:`56px`,padding:`2px`}}}),(0,q.jsx)(`h2`,{className:`gh-portal-main-title`,children:K(`Your account`)})]})},iS=()=>{let{site:e,action:t,brandColor:n,doAction:r}=(0,_.useContext)(J);if(!Jl({site:e})||!Wl({site:e}))return null;let i=[`checkoutPlan:running`].includes(t),a=()=>{r(`switchPage`,{page:`accountPlan`,lastPage:`accountHome`})};return(0,q.jsx)(df,{dataTestId:`view-plans`,isRunning:i,label:K(`View plans`),onClick:()=>a(),brandColor:n,style:{width:`100%`}})},aS=()=>{let{member:e,site:t}=(0,_.useContext)(J),{paid_members_enabled:n}=t;if(!n||zl({site:t}))return null;let r=Cl({member:e}),i=wl({member:e});if(i&&!r)return null;if(r){let t=r?.current_period_end,n=kl({member:e});return El({member:e})?n?(0,q.jsx)(`div`,{className:`gh-portal-section`,style:{marginBottom:24},children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your gift subscription will expire on {expiryDate}`,{expiryDate:n})})}):null:i&&n?(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will expire on {expiryDate}`,{expiryDate:n})})}):r?.cancel_at_period_end||i?null:gu({sub:r})?(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will start on {subscriptionStart}`,{subscriptionStart:ol(r.trial_end_at)})})}):(0,q.jsx)(`div`,{className:`gh-portal-section`,children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`Your subscription will renew on {renewalDate}`,{renewalDate:ol(t)})})})}return(0,q.jsxs)(`div`,{className:`gh-portal-section`,children:[(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-free-ctatext`,children:K(`You currently have a free membership, upgrade to a paid subscription for full access.`)}),(0,q.jsx)(iS,{})]})},oS=()=>{let{member:e,doAction:t,action:n,brandColor:r}=(0,_.useContext)(J),i=Cl({member:e});if(!i||!i.cancel_at_period_end)return null;let a=K(`Resume subscription`),o=[`continueSubscription:running`].includes(n),s=!!o,c=ol(i.current_period_end);return(0,q.jsx)(`div`,{className:`gh-portal-cancelcontinue-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-cancel-banner`,children:[(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`Your subscription has been canceled and will expire on {expiryDate}.`),mapping:{expiryDate:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(df,{onClick:()=>{t(`continueSubscription`,{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:!0,brandColor:r,label:a,style:{width:`100%`}})]})})},sS=()=>{let{member:e,site:t,doAction:n,action:r,brandColor:i}=(0,_.useContext)(J);if(!(El({member:e})&&!Al({member:e,site:t})&&Kl({site:t}))||!kl({member:e}))return null;let a=r===`continueGiftSubscription:running`;return(0,q.jsx)(`div`,{className:`gh-portal-cancelcontinue-container`,children:(0,q.jsxs)(`div`,{className:`gh-portal-cancel-banner`,children:[(0,q.jsx)(`p`,{style:{maxWidth:`none`,margin:`0 0 16px`,textAlign:`center`,textWrap:`pretty`},children:K(`Continue with a paid subscription anytime. Your remaining gift period will be added as a free trial.`)}),(0,q.jsx)(df,{onClick:()=>n(`continueGiftSubscription`),isRunning:a,disabled:a,isPrimary:!0,brandColor:i,label:K(`Continue subscription`),style:{width:`100%`}})]})})},cS=e=>(0,q.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`style`,{children:`.a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}`})}),(0,q.jsx)(`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`}),(0,q.jsx)(`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`})]}),lS=()=>{let{member:e,site:t,doAction:n}=(0,_.useContext)(J),r=()=>{let t=Cl({member:e});n(`manageBilling`,{subscriptionId:t.id})},i=()=>{Kl({site:t})&&n(`switchPage`,{page:`accountPlan`,lastPage:`accountHome`})},a=({price:t,isComplimentary:n,subscription:r})=>{let{next_payment:i}=r||{},a=``;if(t){let{amount:e=0,currency:n,interval:r}=t;a=`${Intl.NumberFormat(`en`,{currency:n,style:`currency`}).format(e/100)}/${K(r)}`}let o=kl({member:e});if(El({member:e})&&o)return(0,q.jsxs)(`p`,{className:`gh-portal-account-discountcontainer`,children:[(0,q.jsx)(yf,{className:`gh-portal-account-tagicon`}),(0,q.jsx)(`span`,{children:K(`Gift subscription`)}),(0,q.jsx)(`span`,{className:`gh-portal-account-expiry-separator`,children:`-`}),(0,q.jsx)(`span`,{className:`gh-portal-account-expiry`,children:K(`Expires {expiryDate}`,{expiryDate:o})})]});n&&(a=o?`${K(`Complimentary`)} - ${K(`Expires {expiryDate}`,{expiryDate:o})}`:K(`Complimentary`));let s=``;if(gu({sub:r}))return s=`gh-portal-account-old-price`,(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:s,children:a}),(0,q.jsx)(uS,{subscription:r})]});let c=dS({nextPayment:i});return c&&(s=`gh-portal-account-old-price`),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:s,children:a}),(0,q.jsx)(()=>c?(0,q.jsxs)(`p`,{className:`gh-portal-account-discountcontainer`,"data-testid":`offer-label`,children:[(0,q.jsx)(cS,{className:`gh-portal-account-tagicon`}),(0,q.jsx)(`span`,{children:c})]}):null,{})]})},o=({isPaid:r})=>{let a=El({member:e});if(a&&!Kl({site:t}))return null;let o=a&&!Al({member:e,site:t});return zl({site:t})&&(!r||a&&!o)?null:o?(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-btn-list`,onClick:e=>{e.stopPropagation(),n(`continueGiftSubscription`)},"data-test-button":`continue-gift-subscription`,children:K(`Continue`)}):(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-btn-list`,onClick:e=>{e.stopPropagation(),i(e)},"data-test-button":`change-plan`,children:K(`Change`)})},s=({defaultCardLast4:e})=>e?(0,q.jsx)(`p`,{children:`**** **** **** ${e}`}):null,c=({defaultCardLast4:e})=>{let{action:t}=(0,_.useContext)(J),n=t===`manageBilling:running`?(0,q.jsx)(cf,{className:`gh-portal-billing-button-loader`}):K(`Update`);return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Billing info & receipts`)}),(0,q.jsx)(s,{defaultCardLast4:e})]}),(0,q.jsx)(`span`,{className:`gh-portal-list-action`,"data-test-button":`manage-billing`,"aria-hidden":`true`,children:n})]})},l=Cl({member:e}),u=wl({member:e}),d=El({member:e}),f=Tl({member:e});if(l||u){let{price:t,default_payment_card_last4:n}=l||{},r=K(`Plan`);return Rl({member:e})&&(r=Rl({member:e})),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsxs)(`h3`,{children:[r,l?.cancel_at_period_end&&(0,q.jsx)(`span`,{className:`gh-portal-canceled-badge`,children:K(`Canceled`)})]}),(0,q.jsx)(a,{price:t,isComplimentary:u,subscription:l})]}),(0,q.jsx)(o,{isPaid:f})]}),!u&&!d&&(0,q.jsx)(c,{defaultCardLast4:n})]})}return null};function uS({subscription:e}){return gu({sub:e})?(0,q.jsx)(`p`,{className:`gh-portal-account-discountcontainer`,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(`span`,{children:K(`Free Trial – Ends {trialEnd}`,{trialEnd:ol(e.trial_end_at)})})})}):null}function dS({nextPayment:e}){if(!e)return``;let t=e.discount;if(!t)return``;let n=t.end?K(`Ends {offerEndDate}`,{offerEndDate:ol(t.end)}):K(`Forever`);return`${`${Intl.NumberFormat(`en`,{currency:e.currency,style:`currency`}).format(e.amount/100)}/${K(e.interval)}`}${n?` — ${n}`:``}`}function fS({site:e,member:t}){return Mf({site:e})&&Tl({member:t??void 0})&&!El({member:t??void 0})}function pS(){let{member:e,site:t,doAction:n}=(0,_.useContext)(J),r=fS({site:t,member:e});if((0,_.useEffect)(()=>{r&&xf(t?.url)},[r,t?.url]),!r)return null;let i=()=>{n(`switchPage`,{page:`gift`,lastPage:`accountHome`})};return(0,q.jsx)(`div`,{className:`gh-portal-list gh-portal-gift-card`,children:(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Gift membership`)}),(0,q.jsx)(`p`,{children:K(`For a friend or colleague`)})]}),(0,q.jsxs)(`span`,{"aria-hidden":`true`,className:`gh-portal-list-action`,"data-test-button":`give-gift-subscription`,children:[(0,q.jsx)(yf,{className:`gh-portal-gift-card-icon`}),K(`Buy`)]})]})})}function mS(){let{member:e,site:t,doAction:n}=(0,_.useContext)(J),{newsletters:r}=e,i=!!r?.length,a=K(i?`Subscribed`:`Unsubscribed`),o=()=>{let r=fu({site:t}),i=e?.newsletters?.length?[]:r;n(`updateNewsletterPreference`,{newsletters:i})};return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,"aria-pressed":i,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail email-newsletter`,children:[(0,q.jsx)(`h3`,{children:K(`Email newsletter`)}),(0,q.jsxs)(`p`,{children:[a,` `,Tu({member:e})&&i&&(0,q.jsx)(`button`,{className:`gh-portal-btn-text gh-email-faq-page-button`,onClick:e=>{e.stopPropagation(),n(`switchPage`,{page:`emailReceivingFAQ`,lastPage:`accountHome`})},children:K(`Not receiving emails?`)})]})]}),(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{dataTestId:`default-newsletter-toggle`,id:`default-newsletter-toggle`,label:K(`Email newsletter`),onToggle:e=>{o(e,i)},checked:i,presentational:!0})})]})}var hS=e=>(0,q.jsxs)(`svg`,{fill:`none`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,...e,children:[(0,q.jsx)(`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`}),(0,q.jsx)(`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 gS(){return(0,q.jsxs)(`p`,{className:`gh-portal-email-notice`,children:[(0,q.jsx)(hS,{className:`gh-portal-email-notice-icon`}),(0,q.jsx)(`span`,{className:`gh-mobile-only`,children:K(`You're not receiving emails`)}),(0,q.jsx)(`span`,{className:`gh-desktop-only`,children:K(`You're currently not receiving emails`)})]})}function _S(){let{doAction:e,member:t,site:n}=(0,_.useContext)(J),r=mu({member:t}),i=Ol({site:n}),a=Ql({site:n}),o=r?`emailSuppressed`:`accountEmail`,s=!i&&!a,c=()=>r||s?(0,q.jsx)(gS,{}):(0,q.jsx)(`p`,{children:K(`Update your preferences`)}),l=()=>{e(`switchPage`,{page:o,lastPage:`accountHome`})};return(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:l,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Emails`)}),c()]}),(0,q.jsx)(`span`,{className:`gh-portal-list-action`,"data-test-button":`manage-newsletters`,"aria-hidden":`true`,children:K(`Manage`)})]})}var vS=()=>{let{member:e,site:t}=(0,_.useContext)(J),n=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},r=n?.enabled===!0,i=e?.uuid,a=Qu(),[o,s]=(0,_.useState)(a&&r);return(0,_.useEffect)(()=>{if(a){s(r);return}if(!r||!i){s(!1);return}s(!1);let e=new AbortController;return(async()=>{try{let t=await fetch(`https://partner.transistor.fm/ghost/member/${i}`,{signal:e.signal});if(t.ok){let n=await t.json();e.signal.aborted||s(n?.member===!0)}}catch(t){if(e.signal.aborted)return;console.warn(`Error in Transistor request`,t)}})(),()=>e.abort()},[r,i,a]),{transistor:{enabled:r,hasPodcasts:o,memberUuid:i,settings:n}}},yS=(e,t)=>pu({site:e})&&Ol({site:e})||Ql({site:e})||mu({member:t}),bS=e=>!pu({site:e})&&Ol({site:e})&&!Ql({site:e}),xS=()=>{let{member:e,doAction:t,site:n}=(0,_.useContext)(J),{name:r,email:i}=e,{transistor:a}=vS(),o=()=>{t(`switchPage`,{page:`accountProfile`,lastPage:`accountHome`})},s=yS(n,e),c=bS(n);return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-list`,children:[(0,q.jsxs)(`section`,{className:`gh-portal-list-clickable`,role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:r&&!Zl({site:n})?r:K(`Account`)}),(0,q.jsx)(`p`,{children:i})]}),(0,q.jsx)(`span`,{"data-test-button":`edit-profile`,className:`gh-portal-list-action`,"aria-hidden":`true`,children:K(`Edit`)})]}),(0,q.jsx)(lS,{}),s&&(0,q.jsx)(_S,{}),c&&(0,q.jsx)(mS,{}),a.enabled&&(0,q.jsx)(Xx,{hasPodcasts:a.hasPodcasts,memberUuid:a.memberUuid,settings:a.settings})]}),(0,q.jsx)(pS,{})]})},SS=()=>(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-account-main`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(rS,{}),(0,q.jsxs)(`section`,{className:`gh-portal-account-data`,children:[(0,q.jsx)(aS,{}),(0,q.jsx)(sS,{}),(0,q.jsx)(oS,{}),(0,q.jsx)(xS,{})]})]}),CS=class extends _.Component{static contextType=J;componentDidMount(){let{member:e,site:t}=this.context;ql({site:t})||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(){let{member:e,site:t}=this.context,n=Ou({site:t});return!e||!ql({site:t})?null:(0,q.jsxs)(`div`,{className:`gh-portal-account-wrapper`,children:[(0,q.jsx)(SS,{}),(0,q.jsx)(nS,{onClose:()=>this.context.doAction(`closePopup`),handleSignout:e=>this.handleSignout(e),supportAddress:n})]})}},wS=class extends _.Component{static contextType=J;constructor(e,t){super(e,t);let{name:n=``,email:r=``,metafields:i}=t.member||{};this.state={name:n,email:r,metafields:i?.custom||{}}}componentDidMount(){let{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(e=>({errors:Nv({fields:this.getInputFields({state:e})})}),()=>{let{email:e,name:t,errors:n}=this.state;if(!(n&&Object.values(n).filter(e=>!!e).length>0)){this.context.doAction(`clearPopupNotification`);let n=Yp(this.customFields(),this.state.metafields,this.context.member.metafields?.custom||{});this.context.doAction(`updateProfile`,{email:e,name:t,...n?{metafields:n}:{}})}})}renderSaveButton(){let e=this.context.action===`updateProfile:running`,t=K(`Save`);return this.context.action===`updateProfile:failed`&&(t=K(`Retry`)),(0,q.jsx)(df,{dataTestId:`save-button`,isRunning:e,onClick:e=>this.onProfileSave(e),disabled:!!e,brandColor:this.context.brandColor,label:t,style:{width:`100%`}})}renderDeleteAccountButton(){return(0,q.jsx)(`div`,{style:{cursor:`pointer`,color:`red`},role:`button`,children:K(`Delete account`)})}renderAccountFooter(){return(0,q.jsx)(`footer`,{className:`gh-portal-action-footer`,children:this.renderSaveButton()})}renderHeader(){return(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:e=>this.onBack(e)}),(0,q.jsx)(`h3`,{className:`gh-portal-main-title`,children:K(`Account settings`)})]})}renderUserAvatar(){return(0,q.jsx)(`div`,{style:{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`},children:(0,q.jsx)(Qc,{gravatar:this.context.member&&this.context.member.avatar_image,style:{userIcon:{color:`black`,width:`56px`,height:`56px`}}})})}handleInputChange(e,t){this.setState({[t.name]:e.target.value})}handleCustomFieldChange(e,t,n){this.setState(({metafields:r})=>({metafields:{...r,[e.key]:Xp(e,r[e.key],t,n)}}))}customFields(){return Gp(this.context.customFields)}getInputFields({state:e,fieldNames:t}){let n=e.errors||{},r=[{type:`text`,value:e.name,placeholder:K(`Jamie Larson`),label:K(`Name`),name:`name`,required:!1,errorMessage:n.name||``},{type:`email`,value:e.email,placeholder:K(`jamie@example.com`),label:K(`Email`),name:`email`,required:!0,errorMessage:n.email||``}];return t&&t.length>0?r.filter(e=>t.includes(e.name)):r}onKeyDown(e){e.keyCode===13&&this.onProfileSave(e)}renderProfileData(){let e=this.customFields();return(0,q.jsxs)(`div`,{className:`gh-portal-section`,children:[(0,q.jsx)(Pp,{fields:this.getInputFields({state:this.state}),onChange:(e,t)=>this.handleInputChange(e,t),onKeyDown:(e,t)=>this.onKeyDown(e,t)}),e.length>0&&(0,q.jsx)(sm,{errors:this.context.fieldErrors||{},fields:e,onChange:(e,t,n)=>this.handleCustomFieldChange(e,t,n),onKeyDown:e=>this.onKeyDown(e),values:this.state.metafields})]})}render(){let{member:e}=this.context;return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-content with-footer`,children:[this.renderHeader(),(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-section`,children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};function TS(){let{brandColor:e,lastPage:t,doAction:n}=(0,_.useContext)(J);return(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,hidden:!t,onClick:()=>{n(`back`)}}),(0,q.jsx)(`h3`,{className:`gh-portal-main-title`,children:K(`Email preferences`)})]})}function ES({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){let r=t.some(t=>t.id===e?.id),i=()=>{let i=[];i=r?t.filter(t=>t.id!==e.id):t.filter(t=>t.id!==e.id).concat(e),n(i)};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`newsletter-toggle`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:e.name}),(0,q.jsx)(`p`,{children:e?.description})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:e.id,label:e.name,onToggle:i,checked:r,dataTestId:`switch-input`,presentational:!0})})]})}function DS({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){let r=!!n,i=(0,_.useRef)(!1);if(!t)return null;let a=async()=>{if(!i.current){i.current=!0;try{await e(!r)}finally{i.current=!1}}};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`comment-toggle`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:a,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Comments`)}),(0,q.jsx)(`p`,{children:K(`Get notified when someone replies to your comment`)})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:`comments`,label:K(`Comments`),onToggle:a,checked:r,dataTestId:`switch-input`,presentational:!0})})]})}function OS({updateUpdatesAndAnnouncements:e,canChangeUpdatesAndAnnouncements:t,enableUpdatesAndAnnouncements:n}){let{site:r}=(0,_.useContext)(J),i=(0,_.useRef)(!1);if(!t)return null;let a=async()=>{if(!i.current){i.current=!0;try{await e(!n)}finally{i.current=!1}}};return(0,q.jsxs)(`section`,{className:`gh-portal-list-toggle-wrapper gh-portal-list-clickable`,"data-testid":`updates-and-announcements-toggle`,role:`button`,tabIndex:0,"aria-pressed":!!n,onClick:a,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:[(0,q.jsxs)(`div`,{className:`gh-portal-list-detail`,children:[(0,q.jsx)(`h3`,{children:K(`Updates & announcements`)}),(0,q.jsx)(`p`,{children:K(`Occasional updates from {siteTitle}`,{siteTitle:r?.title})})]}),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},onClick:e=>e.stopPropagation(),children:(0,q.jsx)(gf,{id:`updates-and-announcements`,label:K(`Updates & announcements`),onToggle:a,checked:n,dataTestId:`switch-input`,presentational:!0})})]})}function kS({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){let{site:r}=(0,_.useContext)(J),i=fu({site:r});return n?i.map(n=>(0,q.jsx)(ES,{newsletter:n,subscribedNewsletters:e,setSubscribedNewsletters:t},n?.id)):null}function AS(){let{doAction:e}=(0,_.useContext)(J);return(0,q.jsxs)(`section`,{className:`gh-portal-list-help`,children:[(0,q.jsx)(`span`,{className:`gh-portal-list-help-label`,children:K(`Not receiving emails?`)}),(0,q.jsxs)(`button`,{className:`gh-portal-btn-text gh-email-faq-page-button`,onClick:()=>e(`switchPage`,{page:`emailReceivingFAQ`,pageData:{direct:!1}}),children:[K(`Get help`),` `,(0,q.jsx)(`span`,{className:`right-arrow`,children:`→`})]})]})}function jS({site:e,isPaid:t}){return t?(0,q.jsx)(`p`,{className:`gh-portal-btn-unsubscribe-note`,children:K(`Unsubscribing from emails will not cancel your paid subscription to {title}`,{title:e?.title})}):null}function MS({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:r,updateCommentNotifications:i,updateUpdatesAndAnnouncements:a,unsubscribeAll:o,isPaidMember:s,isCommentsEnabled:c,enableCommentNotifications:l,canChangeUpdatesAndAnnouncements:u,enableUpdatesAndAnnouncements:d}){let{brandColor:f,member:p,site:m}=(0,_.useContext)(J),h=(0,_.useRef)(!!n?.length).current,g=d!=null,v=g?d:h,y=c&&!l||!c,b=u&&!v||!u,x=!n?.length&&y&&b;return(0,q.jsxs)(`div`,{className:`gh-portal-content with-footer`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-email-preferences-header`,children:[(0,q.jsx)(TS,{}),(0,q.jsx)(t||(()=>null),{})]}),(0,q.jsx)(vf,{brandColor:f}),(0,q.jsx)(`div`,{className:`gh-portal-section flex`,children:(0,q.jsxs)(`div`,{className:`gh-portal-list`,children:[(0,q.jsx)(kS,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:e=>{let t=e.map(e=>({id:e.id}));u&&!g?r(t,v):r(t)}}),(0,q.jsx)(DS,{isCommentsEnabled:c,enableCommentNotifications:l,updateCommentNotifications:i}),(0,q.jsx)(OS,{canChangeUpdatesAndAnnouncements:u,enableUpdatesAndAnnouncements:v,updateUpdatesAndAnnouncements:a}),Tu({member:p})&&!x&&(0,q.jsx)(AS,{})]})}),(0,q.jsxs)(`div`,{className:`gh-portal-btn-unsubscribe`,children:[(0,q.jsx)(df,{isRunning:!1,onClick:()=>{o()},disabled:x,brandColor:f,isPrimary:!1,label:K(`Unsubscribe from all emails`),isDestructive:!0,style:{width:`100%`},dataTestId:`unsubscribe-from-all-emails`}),(0,q.jsx)(jS,{isPaid:s,site:m})]})]})}function NS(){let{member:e,doAction:t,site:n,pageData:r}=(0,_.useContext)(J),i,a;r&&(i=r.newsletterUuid,a=r.action);let[o,s]=(0,_.useState)(!0),c=fu({site:n}),l=Ol({site:n});(0,_.useEffect)(()=>{e||t(`switchPage`,{page:`signin`})},[e,t]),(0,_.useEffect)(()=>{if(i&&a===`unsubscribe`){let n=e?.newsletters.filter(e=>e.uuid!==i);f(n),s(!1),t(`updateNewsletterPreference`,{newsletters:n})}},[]);let u=()=>{if(r.comments&&p)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${o?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive emails when someone replies to your comments.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:e?.email})}})})});let t=c?.find(e=>e.uuid===r.newsletterUuid);return t?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${o?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive {newsletterName} newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:e?.email}),newsletterName:(0,q.jsx)(`strong`,{children:t?.name})}})})}):null},[d,f]=(0,_.useState)([...e?.newsletters||[]]),{comments_enabled:p}=n,m=!!n.labs?.automations,{enable_comment_notifications:h,enable_updates_and_announcements:g}=e||{};return(0,_.useEffect)(()=>{f(e?.newsletters||[])},[e?.newsletters]),(0,q.jsx)(MS,{hasNewslettersEnabled:l,notification:i?u:null,subscribedNewsletters:d,updateSubscribedNewsletters:(e,n)=>{f(e),t(`updateNewsletterPreference`,{newsletters:e,enableUpdatesAndAnnouncements:n}),t(`showPopupNotification`,{action:`updated:success`,message:K(`Email preferences updated.`)})},updateCommentNotifications:e=>t(`updateNewsletterPreference`,{enableCommentNotifications:e,successMessage:K(`Comment preferences updated.`)}),updateUpdatesAndAnnouncements:e=>t(`updateNewsletterPreference`,{enableUpdatesAndAnnouncements:e,successMessage:K(`Email preferences updated.`)}),unsubscribeAll:()=>{f([]),t(`showPopupNotification`,{action:`updated:success`,message:K(`Unsubscribed from all emails.`)});let e={newsletters:[]};p&&(e.enableCommentNotifications=!1),m&&(e.enableUpdatesAndAnnouncements=!1),t(`updateNewsletterPreference`,e)},isPaidMember:Tl({member:e}),isCommentsEnabled:p!==`off`,enableCommentNotifications:h,canChangeUpdatesAndAnnouncements:m,enableUpdatesAndAnnouncements:g})}function PS(){let{site:e}=(0,_.useContext)(J),t=e.icon;return t?(0,q.jsx)(`img`,{className:`gh-portal-unsubscribe-logo`,src:t,alt:e.title}):null}function FS(){let{site:e}=(0,_.useContext)(J),t=e.title||``;return(0,q.jsxs)(`header`,{className:`gh-portal-header`,children:[(0,q.jsx)(PS,{}),(0,q.jsx)(`h2`,{className:`gh-portal-publication-title`,children:t})]})}function IS({message:e}){let{doAction:t}=(0,_.useContext)(J);return(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-feedback with-footer`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-feedback-icon gh-feedback-icon-error`,children:(0,q.jsx)(Wd,{})}),(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`That didn't go to plan`)}),(0,q.jsx)(`div`,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:e})}),(0,q.jsx)(df,{style:{width:`100%`},retry:!1,onClick:()=>t(`closePopup`),disabled:!1,brandColor:`#000000`,label:K(`Close`),isRunning:!1,tabIndex:3,classes:`sticky bottom`})]})}async function LS({api:e,memberUuid:t,key:n,newsletters:r,enableCommentNotifications:i,enableUpdatesAndAnnouncements:a}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:r,enableCommentNotifications:i,enableUpdatesAndAnnouncements:a})}catch{}}function RS(){let{site:e,api:t,pageData:n,member:r,doAction:i}=(0,_.useContext)(J),[a,o]=(0,_.useState)(),s=!!r&&r.uuid!==n.uuid,[c,l]=(0,_.useState)(!0),u=fu({site:e}),d=u.filter(e=>e.subscribe_on_signup),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(d),[g,v]=(0,_.useState)(!1),{comments_enabled:y}=e,b=!!e.labs?.automations,{enable_comment_notifications:x=!1,enable_updates_and_announcements:S}=a||{},C=Ol({site:e}),w=async(e,a)=>{let o={newsletters:e};a!==void 0&&(o.enableUpdatesAndAnnouncements=a),r?i(`updateNewsletterPreference`,o):await LS({api:t,memberUuid:n.uuid,key:n.key,...o}),h(e);let s={action:`updated:success`,message:K(`Email preferences updated.`)};i(`showPopupNotification`,s)},T=async(e,a)=>{let s;r?s=(await i(`updateNewsletterPreference`,{...e,successMessage:a}))?.member:(s=await LS({api:t,memberUuid:n.uuid,key:n.key,...e}),i(`showPopupNotification`,s?{action:`updated:success`,message:a}:{action:`updateNewsletter:failed`,status:`error`,message:K(`Failed to update newsletter settings`)})),s&&o(s)},E=e=>T({enableCommentNotifications:e},K(`Comment preferences updated.`)),D=e=>T({enableUpdatesAndAnnouncements:e},K(`Email preferences updated.`)),O=async()=>{let e;r?(await i(`updateNewsletterPreference`,{newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),e={...r},e.newsletters=[],e.enable_comment_notifications=!1,e.enable_updates_and_announcements=!1):e=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),h([]),o(e),i(`showPopupNotification`,{action:`updated:success`,message:K(`Unsubscribed from all emails.`)})};return(0,_.useEffect)(()=>{(async()=>{if(s)return;let e;try{e=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(e??null),l(!1)}catch(e){console.error(`[PORTAL] Error fetching member newsletters`,e),o(null),l(!1);return}if(e===null)return;let r=e?.newsletters||[];h(r),u?.length===1&&!y&&!n.newsletterUuid?await w([]):n.newsletterUuid?await w(r?.filter(e=>e.uuid!==n.newsletterUuid)):n.comments&&y?await E(!1):n.updatesAndAnnouncements&&b&&await D(!1)})()},[y,b,s,n.uuid,n.newsletterUuid,n.comments,n.updatesAndAnnouncements,e.url,u?.length]),s?(0,q.jsx)(IS,{message:K(`This unsubscribe link belongs to a different email address than the one you are signed in with.`)}):c?(0,q.jsx)(mx,{}):a?u?.length===1&&!y&&!g?(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-unsubscribe with-footer`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(FS,{}),(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Successfully unsubscribed`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive this newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})}),(0,q.jsx)(`p`,{className:`gh-portal-text-center`,children:(0,q.jsx)(Bd,{string:K(`Didn't mean to do this? Manage your preferences <button>here</button>.`),mapping:{button:(0,q.jsx)(`button`,{className:`gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline`,onClick:()=>{v(!0)}})}})})]})]}):(0,q.jsx)(MS,{hasNewslettersEnabled:C,notification:()=>{if(n.comments&&y)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f||x?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive emails when someone replies to your comments.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})})});if(n.updatesAndAnnouncements&&b)return(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f||S!==!1?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive updates & announcements.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email})}})})});let e=u?.find(e=>e.uuid===n.newsletterUuid);return e?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`p`,{className:`gh-portal-text-center gh-portal-header-message ${f?`gh-portal-hide`:``}`,children:(0,q.jsx)(Bd,{string:K(`{memberEmail} will no longer receive {newsletterName} newsletter.`),mapping:{memberEmail:(0,q.jsx)(`strong`,{children:a?.email}),newsletterName:(0,q.jsx)(`strong`,{children:e?.name})}})})}):null},subscribedNewsletters:m,updateSubscribedNewsletters:async(e,t)=>{await w(e,t),p(!0)},updateCommentNotifications:E,updateUpdatesAndAnnouncements:D,unsubscribeAll:async()=>{await O(),p(!0)},isPaidMember:a?.status!==`free`,isCommentsEnabled:y!==`off`,enableCommentNotifications:x,canChangeUpdatesAndAnnouncements:b,enableUpdatesAndAnnouncements:S}):(0,q.jsx)(IS,{message:K(`We couldn't unsubscribe you as the email address was not found. Please contact the site owner.`)})}function zS(){let{brandColor:e,lastPage:t,doAction:n,action:r,site:i}=(0,_.useContext)(J);(0,_.useEffect)(()=>{[`removeEmailFromSuppressionList:success`].includes(r)&&n(`refreshMemberData`),[`removeEmailFromSuppressionList:failed`,`refreshMemberData:failed`].includes(r)&&n(`back`),[`refreshMemberData:success`].includes(r)&&(pu({site:i})||Ql({site:i})?(n(`switchPage`,{page:`accountEmail`,lastPage:`accountHome`}),n(`showPopupNotification`,{message:K(`You have been successfully resubscribed`)})):n(`back`))},[r,n,i,K]);let a=[`removeEmailFromSuppressionList:running`,`refreshMemberData:running`].includes(r);return(0,q.jsxs)(`div`,{className:`gh-email-suppressed-page`,children:[(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,hidden:!t,onClick:()=>{n(`back`)}}),(0,q.jsx)(vf,{})]}),(0,q.jsx)(hS,{className:`gh-email-suppressed-page-icon`}),(0,q.jsxs)(`div`,{className:`gh-email-suppressed-page-text`,children:[(0,q.jsx)(`h3`,{className:`gh-portal-main-title gh-email-suppressed-page-title`,children:K(`Emails disabled`)}),(0,q.jsx)(`p`,{children:K(`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.`)})]}),(0,q.jsx)(df,{dataTestId:`resubscribe-email`,classes:`gh-portal-confirm-button`,onClick:()=>{n(`removeEmailFromSuppressionList`)},disabled:a,brandColor:e,label:K(`Re-enable emails`),isRunning:a})]})}function BS(){let{brandColor:e,doAction:t,site:n,pageData:r}=(0,_.useContext)(J),i=`mailto:${Ou({site:n})}`;return(0,q.jsxs)(`div`,{className:`gh-email-suppression-faq`,children:[!(r&&r.direct)&&(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[(0,q.jsx)(mf,{brandColor:e,onClick:()=>{t(`switchPage`,{page:`emailSuppressed`,lastPage:`accountHome`})}}),(0,q.jsx)(vf,{})]}),(0,q.jsxs)(`div`,{className:`gh-longform`,children:[(0,q.jsx)(`h3`,{children:K(`Why has my email been disabled?`)}),(0,q.jsx)(`p`,{children:K(`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).`)}),(0,q.jsx)(`h4`,{children:K(`Spam complaints`)}),(0,q.jsx)(`p`,{children:K(`If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`h4`,{children:K(`Permanent failure (bounce)`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:K(`In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.`)}),(0,q.jsx)(`p`,{children:K(`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.`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-btn-branded no-margin-right`,href:i,onClick:()=>{i&&window.open(i)},children:K(`Need more help? Contact support`)})})]})]})}function VS(){let{brandColor:e,doAction:t,site:n,lastPage:r,member:i,pageData:a}=(0,_.useContext)(J),o=Ou({site:n}),s=`mailto:${o}`,c=ku({site:n});return(0,q.jsxs)(`div`,{className:`gh-email-receiving-faq`,children:[(0,q.jsxs)(`header`,{className:`gh-portal-detail-header`,children:[!(a&&a.direct)&&(0,q.jsx)(mf,{brandColor:e,onClick:()=>{r?t(`switchPage`,{page:`accountHome`}):t(`switchPage`,{page:`accountEmail`,lastPage:`accountHome`})}}),(0,q.jsx)(vf,{})]}),(0,q.jsxs)(`div`,{className:`gh-longform`,children:[(0,q.jsx)(`h3`,{children:K(`Help! I'm not receiving emails`)}),(0,q.jsx)(`p`,{children:K(`If you're not receiving the email newsletter you've subscribed to, here are a few things to check.`)}),(0,q.jsx)(`h4`,{children:K(`Verify your email address is correct`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:i.email}),button:(0,q.jsx)(`button`,{className:`gh-portal-btn-text`,onClick:()=>t(`switchPage`,{lastPage:`emailReceivingFAQ`,page:`accountProfile`})})}})}),(0,q.jsx)(`h4`,{children:K(`Check spam & promotions folders`)}),(0,q.jsx)(`p`,{children:K(`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".`)}),(0,q.jsx)(`h4`,{children:K(`Create a new contact`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(`h4`,{children:K(`Check with your mail provider`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`strong`,{children:c})}})}),(0,q.jsx)(`h4`,{children:K(`Get in touch for help`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(Bd,{string:K(`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:(0,q.jsx)(`a`,{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}var HS=()=>{let[e,t]=(0,_.useState)(!0),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),{member:o,site:s}=(0,_.useContext)(J);return(0,_.useEffect)(()=>{async function e(){let e=s.url,n=window.location.origin+window.location.pathname,i=o?`${n}?action=support&success=true`:`${n}#/portal/support/success`,c=n,l=px({siteUrl:e});try{let e=await l.member.checkoutDonation({successUrl:i,cancelUrl:c,personalNote:K(`Add a personal note`)});e.url&&window.location.replace(e.url)}catch(e){e.type&&e.type===`DisabledFeatureError`?a(K(`This site is not accepting payments at the moment.`)):r(K(`Something went wrong, please try again later.`)),t(!1)}}s&&s.donations_enabled===!1?(a(K(`This site is not accepting donations at the moment.`)),t(!1)):e()},[]),e?(0,q.jsx)(`div`,{children:(0,q.jsx)(mx,{})}):n?(0,q.jsx)(Rx,{error:n}):i?(0,q.jsx)(Rx,{error:i}):null};function US({initialState:e,key:t,parse:n}){let[r,i]=(0,_.useState)(()=>{let r=typeof e==`function`?e():e;try{let e=window.sessionStorage.getItem(t);return e===null?r:n(JSON.parse(e))??r}catch{return r}});return(0,_.useEffect)(()=>{try{window.sessionStorage.setItem(t,JSON.stringify(r))}catch{}},[t,r]),[r,i]}function WS({key:e}){try{window.sessionStorage.removeItem(e)}catch{}}var GS=Tv,KS=bp;function qS({deliveryDateError:e,deliveryMethod:t,effectiveDeliveryDate:n,giftMessage:r,maxDeliveryDate:i,maxMessageLength:a,minDeliveryDate:o,onChangeDeliveryDate:s,onChangeDeliveryMethod:c,onChangeGiftMessage:l,onChangeRecipientEmail:u,onChangeRecipientName:d,recipientEmailField:f,recipientNameField:p}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-label`,children:K(`How would you like to share this gift?`)}),(0,q.jsxs)(`div`,{"aria-label":K(`Delivery method`),className:`gh-portal-gift-duration-switch`,role:`radiogroup`,children:[(0,q.jsx)(`button`,{"aria-checked":t===`email`,className:`gh-portal-btn`+(t===`email`?` active`:``),"data-test-button":`delivery-method-email`,role:`radio`,type:`button`,onClick:()=>c(`email`),children:K(`Email it to them`)}),(0,q.jsx)(`button`,{"aria-checked":t===`link`,className:`gh-portal-btn`+(t===`link`?` active`:``),"data-test-button":`delivery-method-link`,role:`radio`,type:`button`,onClick:()=>c(`link`),children:K(`I'll share it myself`)})]})]}),(0,q.jsx)(`div`,{"aria-hidden":t!==`email`,className:`gh-portal-gift-checkout-reveal`,"data-open":t===`email`,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(KS,{...p,onChange:e=>d(e.target.value)}),(0,q.jsx)(KS,{...f,onChange:e=>u(e.target.value)}),(0,q.jsx)(`div`,{className:`gh-portal-input-labelcontainer`,children:(0,q.jsx)(`label`,{className:`gh-portal-input-label`,htmlFor:`gift-message`,children:K(`Optional message`)})}),(0,q.jsx)(`textarea`,{className:`gh-portal-input gh-portal-gift-checkout-textarea`,"data-test-input":`gift-message`,id:`gift-message`,maxLength:a,placeholder:K(`Add a short note to go with your gift`),value:r,onChange:e=>l(e.target.value)}),(0,q.jsx)(`div`,{"aria-hidden":r.length===0,className:`gh-portal-gift-checkout-reveal`,"data-open":r.length>0,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`p`,{className:`gh-portal-gift-checkout-message-count`,children:[r.length,`/`,a]})})}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-delivery-date`,children:[(0,q.jsx)(`div`,{className:`gh-portal-input-labelcontainer`,children:(0,q.jsx)(`label`,{className:`gh-portal-input-label`,htmlFor:`gift-delivery-date`,children:K(`Delivery date`)})}),(0,q.jsx)(GS,{ariaLabel:K(`Delivery date`),hasError:!!e,id:`gift-delivery-date`,max:i,min:o,minLabel:K(`Now`),value:n,onChange:s}),e&&(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-delivery-error`,children:e})]})]})})})]})}var JS=`ghost-portal-gift-form-state`;function YS({buyerName:e=``}={}){return{version:1,plan:{selectedDuration:null,selectedProductId:null,buyerEmail:``,buyerName:e,completed:!1},delivery:{method:`email`,emailDraft:{recipientEmail:``,recipientName:``,message:``,timing:{type:`immediate`}}}}}function XS(e,t){return typeof e==`string`&&e.length<=t}function ZS(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.plan,r=t.delivery,i=r?.emailDraft,a=i?.timing,o=n?.selectedDuration===null||Cf.includes(n?.selectedDuration),s=a?.type===`immediate`||a?.type===`scheduled`&&typeof a.date==`string`;return t.version!==1||!n||!r||!i||!o||!(n.selectedProductId===null||typeof n.selectedProductId==`string`)||!XS(n.buyerEmail,191)||!XS(n.buyerName,191)||typeof n.completed!=`boolean`||![`email`,`link`].includes(r.method)||!XS(i.recipientEmail,191)||!XS(i.recipientName,191)||!XS(i.message,250)||!s?null:t}function QS(){WS({key:JS})}var $S=bp;function eC({activeDuration:e,offeredDurations:t,onSelectDuration:n}){return t.length<2?null:(0,q.jsx)(`div`,{"aria-label":K(`Gift duration`),className:`gh-portal-gift-duration-switch`,role:`radiogroup`,children:t.map(t=>{let r=t===e;return(0,q.jsx)(`button`,{"aria-checked":r,className:`gh-portal-btn`+(r?` active`:``),"data-test-button":`switch-duration-${t}`,role:`radio`,type:`button`,onClick:()=>n(t),children:Gd({cadence:`month`,duration:t})},t)})})}function tC({activeDuration:e,activeDurationLabel:t,activeProduct:n,buyerEmailField:r,buyerNameField:i,isSingleTier:a,offeredDurations:o,onBuyerEmailChange:s,onBuyerNameChange:c,onSelectDuration:l,onSelectProduct:u,products:d,showBuyerEmail:f,showBuyerName:p,siteTitle:m,tierPriceLabel:h}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`header`,{className:`gh-portal-gift-checkout-header`,children:[(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Gift a membership`)}),(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-subtitle`,children:K(`Share a full membership to {siteTitle} with a friend or colleague`,{siteTitle:m})})]}),(p||f)&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[p&&(0,q.jsx)($S,{...i,onChange:e=>c(e.target.value)}),f&&(0,q.jsx)($S,{...r,onChange:e=>s(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-section`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-label`,children:K(a?`Membership details`:`Tier`)}),o.length>1?(0,q.jsx)(eC,{activeDuration:e,offeredDurations:o,onSelectDuration:l}):(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-single-duration`,"data-test-single-duration":!0,children:K(`{duration} membership`,{duration:t})})]}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-section`,children:(0,q.jsx)(`div`,{"aria-label":a?void 0:K(`Choose a tier`),className:`gh-portal-gift-checkout-tiers`+(a?` single`:``),role:a?void 0:`radiogroup`,children:d.map(t=>{let r=t.id===n.id,i=t.benefits||[];return(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-item`+(r&&!a?` selected`:``),children:[(0,q.jsxs)(`button`,{"aria-checked":a?void 0:r,className:`gh-portal-gift-checkout-tier`,"data-test-tier":t.name,role:a?void 0:`radio`,type:`button`,onClick:()=>u(t.id),children:[!a&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-tier-radio`}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-content`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-tier-heading`,children:[(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-tier-name`,children:t.name}),(0,q.jsx)(`span`,{className:`gh-portal-gift-checkout-tier-price`,children:h(t,e)})]}),t.description&&(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-tier-description`,children:t.description})]})]}),i.length>0&&(0,q.jsx)(`div`,{"aria-hidden":!r,className:`gh-portal-gift-checkout-tier-benefits`,"data-open":r,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-tier-benefits-inner`,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-benefits`,children:i.map((e,t)=>{let n=e.id||`benefit-${t}`;return(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-benefit`,children:[(0,q.jsx)(Ff,{"aria-hidden":`true`,focusable:`false`}),(0,q.jsx)(`span`,{children:e.name})]},n)})})})})]},t.id)})})})]})}var nC=e=>(0,q.jsxs)(`svg`,{width:39,height:27,viewBox:`0 0 39 27`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsxs)(`g`,{fill:`currentColor`,children:[(0,q.jsx)(`path`,{d:`M9 0a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z`}),(0,q.jsx)(`path`,{d:`M18 7c0 10-4.8 17.2-13.4 20L3 22.4C9.4 20.2 13 15.6 13 8Z`})]}),(0,q.jsxs)(`g`,{fill:`currentColor`,transform:`translate(21 0)`,children:[(0,q.jsx)(`path`,{d:`M9 0a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z`}),(0,q.jsx)(`path`,{d:`M18 7c0 10-4.8 17.2-13.4 20L3 22.4C9.4 20.2 13 15.6 13 8Z`})]})]}),rC=({recipientName:e,recipientEmail:t,buyerName:n,giftMessage:r,deliveryDate:i,isScheduled:a=!1,cadence:o,duration:s,tierName:c,benefits:l=[],siteTitle:u,siteIcon:d})=>{let f=e.trim(),p=t.trim(),m=n.trim(),h=r.trim(),g=ol(new Date),v=ol(dl(i))||g,[y,b]=(0,_.useState)(``);(0,_.useEffect)(()=>{a&&b(v)},[a,v]);let x=a?v:y||g,S=``;S=f&&p?`${f} <${p}>`:p||f;let C={buyerName:(0,q.jsx)(`strong`,{children:m}),duration:s,strong:(0,q.jsx)(`strong`,{}),tierName:(0,q.jsx)(`strong`,{children:c}),siteTitle:u},w=qd({buyerName:m,cadence:o,duration:s,siteTitle:u});return(0,q.jsx)(`div`,{className:`gh-portal-gift-email`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-sheet`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-meta`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-meta-text`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-email-from`,children:u}),(0,q.jsx)(`div`,{"aria-hidden":!S,className:`gh-portal-gift-checkout-reveal`,"data-open":!!S,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-to`,children:[(0,q.jsxs)(`span`,{className:`gh-portal-gift-email-meta-label`,children:[K(`To`),`:`]}),(0,q.jsx)(`span`,{className:`gh-portal-gift-email-to-value`,children:S})]})})})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-date-stack`,children:[(0,q.jsx)(`div`,{"aria-hidden":a,className:`gh-portal-gift-email-date`,"data-active":!a,children:g}),(0,q.jsx)(`div`,{"aria-hidden":!a,className:`gh-portal-gift-email-date`,"data-active":a,children:x})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-body`,children:[(0,q.jsx)(`div`,{className:`gh-portal-gift-email-lockup`,children:d?(0,q.jsx)(`img`,{alt:u,className:`gh-portal-gift-email-lockup-icon`,src:d}):(0,q.jsx)(`span`,{className:`gh-portal-gift-email-lockup-title`,children:u})}),(0,q.jsx)(`h1`,{className:`gh-portal-gift-email-subject`,children:K(`A gift, just for you`)}),(0,q.jsx)(`div`,{"aria-hidden":!f,className:`gh-portal-gift-checkout-reveal`,"data-open":!!f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsx)(`p`,{className:`gh-portal-gift-email-greeting`,children:K(`Hi {recipientName},`,{recipientName:f})})})}),(0,q.jsx)(`p`,{className:`gh-portal-gift-email-lede`,children:(0,q.jsx)(Bd,{mapping:C,string:w})}),(0,q.jsx)(`div`,{"aria-hidden":!h,className:`gh-portal-gift-checkout-reveal`,"data-open":!!h,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-reveal-inner`,children:(0,q.jsxs)(`blockquote`,{className:`gh-portal-gift-email-message`,children:[(0,q.jsx)(nC,{"aria-hidden":`true`,className:`gh-portal-gift-email-message-mark`,focusable:`false`}),(0,q.jsx)(`p`,{className:`gh-portal-gift-email-message-text`,children:h}),m&&(0,q.jsx)(`p`,{className:`gh-portal-gift-email-message-from`,children:m})]})})}),l.length>0&&(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-benefits`,children:[(0,q.jsx)(`p`,{className:`gh-portal-gift-email-benefits-label`,children:K(`What's included`)}),(0,q.jsx)(`div`,{children:l.map((e,t)=>(0,q.jsxs)(`div`,{className:`gh-portal-gift-email-benefit`,children:[(0,q.jsx)(Ff,{"aria-hidden":`true`,focusable:`false`}),(0,q.jsx)(`span`,{children:e.name})]},e?.id||`benefit-${t}`))})]})]})]})})},iC=Sf,aC=rC;function oC({activeDuration:e,activeProduct:t,buyerName:n,cardRef:r,cardTiltProps:i,effectiveDeliveryDate:a,emailDuration:o,giftMessage:s,giftValue:c,minDeliveryDate:l,recipientEmail:u,recipientName:d,showEmailPreview:f,siteIcon:p,siteTitle:m}){return(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-right`,...i,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-right-panel`,children:(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-stage`,children:[(0,q.jsx)(`div`,{"aria-hidden":f,className:`gh-portal-gift-checkout-stage-item card`,"data-active":!f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-card-stack`,children:(0,q.jsx)(iC,{cardRef:r,duration:Gd({cadence:`month`,duration:e}),fromName:n.trim(),giftValue:c,siteIcon:p,siteTitle:m,tierName:t.name})})}),(0,q.jsx)(`div`,{"aria-hidden":!f,className:`gh-portal-gift-checkout-stage-item email`,"data-active":f,children:(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-email-stack`,children:(0,q.jsx)(aC,{...o,benefits:t.benefits||[],buyerName:n,deliveryDate:a,giftMessage:s,isScheduled:a>l,recipientEmail:u,recipientName:d,siteIcon:p,siteTitle:m,tierName:t.name})})})]})})})}var sC=`ghostPortalGiftHistory`;function cC(){let e=window.history.state;return e&&typeof e==`object`?e:{}}function lC(){let e=cC()[sC];if(!e||typeof e!=`object`||!(`depth`in e))return null;let{depth:t}=e;return typeof t==`number`&&t>0?{depth:t}:null}function uC(e){return e===`delivery`?`#/portal/gift/delivery`:`#/portal/gift`}function dC(){window.dispatchEvent(new HashChangeEvent(`hashchange`))}function fC({step:e,replace:t=!1}){let n=uC(e);if(t){window.history.replaceState(window.history.state,``,n),dC();return}let r=lC(),i=r?{...cC(),[sC]:{depth:r.depth+1}}:window.history.state;window.history.pushState(i,``,n),dC()}function pC(){window.location.hash!==`#/portal/gift`&&window.history.pushState({...cC(),[sC]:{depth:1}},``,`#/portal/gift`)}function mC(){let e=lC();return e?(window.history.go(-e.depth),!0):!1}var hC=Nv,gC=365;function _C(e){return e===`signup`?`#/portal/signup`:e===`accountHome`?`#/portal/account`:e===`accountPlan`?`#/portal/account/plans`:null}var vC=()=>{let{site:e,member:t,brandColor:n,action:r,doAction:i,lastPage:a,pageData:o}=(0,_.useContext)(J),s=o?.giftStep===`delivery`?`delivery`:`plan`,[c,l]=(0,_.useState)(s),[u,d]=US({key:JS,initialState:()=>YS({buyerName:t?.name||``}),parse:ZS}),[f,p]=(0,_.useState)({}),{cardRef:m,containerProps:h}=Ex(),g=(0,_.useRef)(null),v=(0,_.useRef)(!1),{plan:y,delivery:b}=u,{selectedDuration:x,selectedProductId:S,buyerEmail:C,buyerName:w}=y,{method:T,emailDraft:E}=b,{recipientEmail:D,recipientName:O,message:k,timing:ee}=E;(0,_.useEffect)(()=>{d(e=>e.plan.buyerName||!t?.name?e:{...e,plan:{...e.plan,buyerName:t.name}})},[t?.name]),(0,_.useEffect)(()=>{if(s===`delivery`&&!y.completed){l(`plan`),fC({step:`plan`,replace:!0});return}g.current!==s&&(g.current=s,l(s))},[y.completed,s]);let te=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=te.current,t=e?.ownerDocument;if(!t)return;let n=t.defaultView;t.querySelectorAll(`.gh-portal-popup-wrapper, .gh-portal-popup-container`).forEach(e=>{e.scrollTop=0});for(let t=e.parentElement;t;t=t.parentElement){let e=n?.getComputedStyle(t).overflowY;(e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight&&(t.scrollTop=0)}});return()=>cancelAnimationFrame(e)},[c]);let ne=()=>{let e=_C(a);!mC()&&e&&window.history.replaceState(window.history.state,``,e),i(`back`)},A=()=>{i(`closePopup`)},re=e?.portal_default_plan??null,ie=kf({site:e}),j=Nf({availableDurations:ie,portalDefaultPlan:re,selectedDuration:x}),M=j?Of({site:e,duration:j}):[],ae=x!==null&&ie.includes(x)&&S!==null&&M.some(e=>e.id===S);if((0,_.useEffect)(()=>{!e||!y.completed||ae||(d(e=>({...e,plan:{...e.plan,completed:!1}})),l(`plan`),fC({step:`plan`,replace:!0}))},[y.completed,ae,e]),!e)return(0,q.jsx)(mx,{});function oe(t,n){return jx(Df(t,n),e?.locale)}let se=e.icon,ce=e.title||``;if(!j||M.length===0)return(0,q.jsxs)(`div`,{className:`gh-portal-content gift`,children:[(0,q.jsx)(vf,{onClick:A}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-left`,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-bg`}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-inner`,children:(0,q.jsxs)(`header`,{className:`gh-portal-gift-checkout-header`,children:[(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Gift a membership`)}),(0,q.jsx)(`p`,{className:`gh-portal-gift-checkout-subtitle`,children:K(`Gift subscriptions are not available right now.`)})]})})]}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-right`})]})]});let N=M.find(e=>e.id===S)||M[0];if(!N)return null;let le=M.length===1,ue=j===12?{cadence:`year`,duration:1}:{cadence:`month`,duration:j},de=Kd(ue),fe=r===`checkoutGift:running`,P=c===`plan`?!!(f.email||f.buyerName):!!(f.recipientEmail||f.deliveryDate),pe=xl()||fe||P,me=!!t,he=!(t?.name||``).trim(),ge=!me,F=c===`delivery`&&T===`email`,_e=gl(new Date,e.timezone),I=pl(_e,gC),ve=ee.type===`scheduled`?ee.date:_e,ye={type:`email`,value:C,placeholder:K(`jamie@example.com`),label:K(`Your email`),name:`email`,required:!0,maxLength:191,errorMessage:f.email||``},be={type:`email`,value:D,placeholder:K(`taylor@example.com`),label:K(`Recipient's email`),name:`recipientEmail`,required:!1,maxLength:191,errorMessage:f.recipientEmail||``},xe={type:`text`,value:w,placeholder:K(`Jamie Larson`),label:K(`Your name`),name:`buyerName`,required:!0,maxLength:191,errorMessage:f.buyerName||``},Se={type:`text`,value:O,placeholder:K(`Taylor Reid`),label:K(`Recipient's name`),name:`recipientName`,required:!1,maxLength:191,errorMessage:``},Ce=e=>{p(e=>({...e,email:``})),d(t=>({...t,plan:{...t.plan,buyerEmail:e,completed:!1}}))},we=e=>{p(e=>({...e,buyerName:``})),d(t=>({...t,plan:{...t.plan,buyerName:e,completed:!1}}))},L=e=>{p(e=>({...e,recipientEmail:``,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,recipientEmail:e}}}))},Te=e=>{p(e=>({...e,recipientEmail:``,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,method:e}}))},Ee=e=>{p(e=>({...e,deliveryDate:``})),d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,timing:e===_e?{type:`immediate`}:{type:`scheduled`,date:e}}}}))},De=e=>{d(t=>({...t,plan:{...t.plan,selectedDuration:e,completed:!1}}))},Oe=e=>{d(t=>({...t,plan:{...t.plan,selectedProductId:e,completed:!1}}))},ke=e=>{d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,recipientName:e}}}))},Ae=e=>{d(t=>({...t,delivery:{...t.delivery,emailDraft:{...t.delivery.emailDraft,message:e}}}))},je=()=>{let e=[];me||e.push({...ye,value:C.trim()}),e.push({...xe,value:w.trim()});let t=hC({fields:e}),n=Object.values(t).some(e=>!!e);p(t),!n&&(d(e=>({...e,plan:{...e.plan,selectedDuration:j,selectedProductId:N.id,completed:!0}})),pC(),v.current=!0,l(`delivery`),fC({step:`delivery`}))},Me=()=>{p({}),l(`plan`),v.current?(v.current=!1,window.history.back()):fC({step:`plan`,replace:!0})};return(0,q.jsxs)(`div`,{ref:te,className:`gh-portal-content gift`,children:[(0,q.jsx)(vf,{onClick:A}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout`,children:[(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-left`,"data-step":c,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`gh-portal-gift-checkout-bg`}),(c===`delivery`||a)&&(0,q.jsx)(Ev,{onBack:()=>c===`delivery`?Me():ne()}),(0,q.jsxs)(`div`,{className:`gh-portal-gift-checkout-inner`,children:[c===`plan`?(0,q.jsx)(tC,{activeDuration:j,activeDurationLabel:de,activeProduct:N,buyerEmailField:ye,buyerNameField:xe,isSingleTier:le,offeredDurations:ie,products:M,showBuyerEmail:ge,showBuyerName:he,siteTitle:ce,tierPriceLabel:oe,onBuyerEmailChange:Ce,onBuyerNameChange:we,onSelectDuration:De,onSelectProduct:Oe}):(0,q.jsx)(qS,{deliveryDateError:f.deliveryDate||``,deliveryMethod:T,effectiveDeliveryDate:ve,giftMessage:k,maxDeliveryDate:I,maxMessageLength:250,minDeliveryDate:_e,recipientEmailField:be,recipientNameField:Se,onChangeDeliveryDate:Ee,onChangeDeliveryMethod:Te,onChangeGiftMessage:Ae,onChangeRecipientEmail:L,onChangeRecipientName:ke}),(0,q.jsx)(`div`,{className:`gh-portal-gift-checkout-cta-wrapper`,children:(0,q.jsx)(df,{brandColor:n,classes:`gh-portal-gift-checkout-cta`,dataTestId:c===`plan`?`gift-continue`:`purchase-gift`,disabled:pe,isRunning:c===`delivery`&&fe,label:K(c===`plan`?`Continue to delivery details`:`Continue to payment`),style:{width:`100%`},onClick:c===`plan`?je:()=>{if(fe)return;let e=C.trim(),t=D.trim(),n=O.trim(),r=w.trim(),a=k.trim(),o=T===`email`,s=o&&ve>_e,c=[];me||c.push({...ye,value:e}),o&&t&&c.push({...be,value:t});let u=hC({fields:c});o&&!t&&(u.recipientEmail=K(`Enter the recipient's email address`)),o&&(ve?ve<_e?u.deliveryDate=K(`Choose a date from today onwards`):ve>I&&(u.deliveryDate=K(`Choose a date within the next year`)):u.deliveryDate=K(`Choose a delivery date`));let f=Object.values(u).some(e=>!!e);if(p(u),f){u.email&&(l(`plan`),d(e=>({...e,plan:{...e.plan,completed:!1}})),fC({step:`plan`,replace:!0}));return}i(`checkoutGift`,{tierId:N.id,duration:j,...me?{}:{email:e},deliveryMethod:T,...o?{recipientEmail:t}:{},...o&&n?{recipientName:n}:{},buyerName:r,...o&&a?{personalMessage:a}:{},...s?{deliveryDate:ve}:{}})}})})]})]}),(0,q.jsx)(oC,{activeDuration:j,activeProduct:N,buyerName:w,cardRef:m,cardTiltProps:h,effectiveDeliveryDate:ve,emailDuration:ue,giftMessage:k,giftValue:oe(N,j),minDeliveryDate:_e,recipientEmail:D,recipientName:O,showEmailPreview:F,siteIcon:se,siteTitle:ce})]})]})},yC=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},bC=(e,t)=>`${e}?${new URLSearchParams(t).toString()}`,xC=({shareTitle:e,shareUrl:t})=>{let n=[e,t].filter(Boolean).join(`
5692
5692
 
5693
- `),r=[];return e&&r.push(`subject=${encodeURIComponent(e)}`),n&&r.push(`body=${encodeURIComponent(n)}`),`mailto:${r.length?`?${r.join(`&`)}`:``}`},SC=({shareTitle:e,shareUrl:t})=>bC(`https://www.linkedin.com/shareArticle`,{mini:`true`,url:t,title:e}),CC=()=>{let e=yC(),t=e.document,n=e.location,r=(e,n=`content`)=>t.querySelector(e)?.[n]||``,i=r(`link[rel="canonical"]`,`href`)||n.origin+n.pathname+n.search,a=r(`meta[property="og:title"]`)||t.title||``,o=r(`meta[property="og:description"]`)||r(`meta[name="description"]`)||``,s=r(`meta[property="og:image"]`)||r(`meta[name="twitter:image"]`)||``,c=r(`link[rel="icon"]`,`href`)||r(`link[rel="shortcut icon"]`,`href`)||r(`link[rel="apple-touch-icon"]`,`href`),l=r(`meta[name="author"]`),u=(l&&!/^https?:\/\//i.test(l)?l:``)||r(`meta[name="twitter:creator"]`)||``,d=r(`meta[property="og:site_name"]`)||r(`meta[name="application-name"]`)||``;if(!d)try{d=new URL(i).hostname.replace(/^www\./,``)}catch{d=``}let f=[a,i].filter(Boolean).join(` `).trim(),p={twitter:bC(`https://twitter.com/intent/tweet`,{url:i,text:a}),facebook:bC(`https://www.facebook.com/sharer/sharer.php`,{u:i}),email:xC({shareTitle:a,shareUrl:i}),threads:bC(`https://www.threads.net/intent/post`,{text:f}),linkedin:SC({shareTitle:a,shareUrl:i}),bluesky:bC(`https://bsky.app/intent/compose`,{text:f})};return{shareUrl:i,shareTitle:a,shareExcerpt:o,shareImage:s,shareFavicon:c,shareSiteName:d,shareAuthor:u,socialLinks:p}},wC=()=>{let[e]=(0,_.useState)(CC);return e},TC=e=>(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 -3.268 64 68.414`,width:2232,height:2500,...e,children:(0,q.jsx)(`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`})}),EC=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`lucide lucide-ellipsis-icon lucide-ellipsis`,...e,children:[(0,q.jsx)(`circle`,{cx:12,cy:12,r:1}),(0,q.jsx)(`circle`,{cx:19,cy:12,r:1}),(0,q.jsx)(`circle`,{cx:5,cy:12,r:1})]}),DC=e=>(0,q.jsxs)(`svg`,{id:`svg9`,width:666.66669,height:666.66718,viewBox:`0 0 666.66668 666.66717`,xmlns:`http://www.w3.org/2000/svg`,"xmlns:svg":`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`defs`,{id:`defs13`,children:(0,q.jsx)(`clipPath`,{clipPathUnits:`userSpaceOnUse`,id:`clipPath25`,children:(0,q.jsx)(`path`,{d:`M 0,700 H 700 V 0 H 0 Z`,id:`path23`})})}),(0,q.jsx)(`g`,{id:`g17`,transform:`matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)`,children:(0,q.jsx)(`g`,{id:`g19`,children:(0,q.jsxs)(`g`,{id:`g21`,clipPath:`url(#clipPath25)`,children:[(0,q.jsx)(`g`,{id:`g27`,transform:`translate(600,350)`,children:(0,q.jsx)(`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`})}),(0,q.jsx)(`g`,{id:`g31`,transform:`translate(447.9175,273.6036)`,children:(0,q.jsx)(`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`})})]})})})]}),OC=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`lucide lucide-link-icon lucide-link`,...e,children:[(0,q.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}),(0,q.jsx)(`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`})]}),kC=e=>(0,q.jsxs)(`svg`,{viewBox:`0 5 2490 2490.0000000000005`,xmlns:`http://www.w3.org/2000/svg`,width:2500,height:2495,...e,children:[(0,q.jsx)(`path`,{d:`M185.2 313.1H2252V2291H185.2z`,fill:`#fff`}),(0,q.jsx)(`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`}),(0,q.jsx)(`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`})]}),AC=e=>(0,q.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`g`,{clipPath:`url(#clip0_351_18008)`,children:(0,q.jsx)(`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`})}),(0,q.jsx)(`defs`,{children:(0,q.jsx)(`clipPath`,{id:`clip0_351_18008`,children:(0,q.jsx)(`rect`,{width:17,height:17,fill:`white`,transform:`translate(0.5 0.5)`})})})]}),jC=e=>(0,q.jsx)(`svg`,{viewBox:`0 0 1200 1226.37`,xmlns:`http://www.w3.org/2000/svg`,width:2446,height:2500,...e,children:(0,q.jsx)(`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`})}),MC={signin:tS,signup:gb,accountHome:CS,accountPlan:_p,accountProfile:wS,accountEmail:NS,signupNewsletter:Av,unsubscribe:RS,magiclink:Ib,loading:mx,offer:Hb,feedback:xx,emailSuppressed:zS,emailSuppressionFAQ:BS,emailReceivingFAQ:VS,support:HS,supportSuccess:Tx,supportError:Rx,recommendations:Kx,gift:vC,giftRedemption:Ox,giftSuccess:Fx,share:()=>{let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(),a=(0,_.useRef)(null),{shareUrl:o,shareTitle:s,shareExcerpt:c,shareImage:l,shareFavicon:u,shareSiteName:d,shareAuthor:f,socialLinks:p}=wC();(0,_.useEffect)(()=>()=>{clearTimeout(i.current)},[]),(0,_.useEffect)(()=>{if(!n)return;let e=a.current?.ownerDocument||document,t=e=>{a.current&&!a.current.contains(e.target)&&(e.stopPropagation(),e.preventDefault(),r(!1))},i=e=>{e.key===`Escape`&&r(!1)};return e.addEventListener(`click`,t,!0),e.addEventListener(`keydown`,i),()=>{e.removeEventListener(`click`,t,!0),e.removeEventListener(`keydown`,i)}},[n]);let m=async()=>{await Ax(o)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},h=()=>{r(e=>!e)},g=()=>{r(!1)};return(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-share`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-share-header`,children:(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Share`)})}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview`,children:[l&&(0,q.jsx)(`img`,{className:`gh-portal-share-preview-image`,src:l,alt:``,"data-testid":`share-preview-image`}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-content`,children:[s&&(0,q.jsx)(`h2`,{className:`gh-portal-share-preview-title`,children:s}),c&&(0,q.jsx)(`p`,{className:`gh-portal-share-preview-excerpt`,children:c}),(u||d||f)&&(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-footer`,children:[u&&(0,q.jsx)(`img`,{className:`gh-portal-share-preview-favicon`,src:u,alt:``,"data-testid":`share-preview-favicon`}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-meta`,children:[d&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-site`,children:d}),d&&f&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-separator`,"aria-hidden":`true`,children:`|`}),f&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-author`,children:f})]})]})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-share-actions`,children:[(0,q.jsxs)(`button`,{className:`gh-portal-btn gh-portal-share-action copy`,type:`button`,onClick:m,"aria-label":K(e?`Copied`:`Copy link`),title:K(e?`Copied`:`Copy link`),children:[e?(0,q.jsx)(`span`,{className:`gh-portal-share-icon copied`,"aria-hidden":`true`,children:(0,q.jsx)(Ff,{})}):(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(OC,{})}),(0,q.jsx)(`span`,{className:`gh-portal-share-label`,children:K(e?`Copied`:`Copy link`)})]}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action twitter`,href:p.twitter,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`X (Twitter)`),title:K(`X (Twitter)`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon x`,"aria-hidden":`true`,children:(0,q.jsx)(jC,{})})}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action linkedin`,href:p.linkedin,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`LinkedIn`),title:K(`LinkedIn`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(kC,{})})}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action email`,href:p.email,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`Email`),title:K(`Email`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(yb,{})})}),(0,q.jsxs)(`div`,{className:`gh-portal-share-more`,ref:a,children:[(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-share-action more`,type:`button`,onClick:h,"aria-label":K(`More options`),title:K(`More options`),"aria-haspopup":`menu`,"aria-expanded":n,children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(EC,{})})}),n&&(0,q.jsxs)(`div`,{className:`gh-portal-share-more-menu`,role:`menu`,"aria-label":K(`More options`),children:[(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.facebook,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(DC,{})}),(0,q.jsx)(`span`,{children:K(`Facebook`)})]}),(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.threads,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(AC,{})}),(0,q.jsx)(`span`,{children:K(`Threads`)})]}),(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.bluesky,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(TC,{})}),(0,q.jsx)(`span`,{children:K(`Bluesky`)})]})]})]})]})]})}},NC=function(){return MC},PC=function({page:e}){return Object.keys(MC).includes(e)?e:`signup`},FC=function({page:e}){return e.includes(`account`)},IC=function({page:e}){return e.includes(`offer`)},LC=e=>(0,q.jsx)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,q.jsx)(`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`})}),RC=class extends _.Component{static contextType=J;render(){return(0,q.jsxs)(`a`,{href:`https://ghost.org`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(LC,{}),`Powered by Ghost`]})}},zC=()=>({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 BC({message:e}){return xl()?(0,q.jsx)(`div`,{className:`gh-portal-cookiebanner`,children:e}):null}var VC=class extends _.Component{static contextType=J;componentDidMount(){this.node&&!nd([`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){let t=e.target&&e.target.tagName;(!(t===`INPUT`||t===`TEXTAREA`)||!e?.target?.value)&&this.context.doAction(`closePopup`)}sendContainerHeightChangeEvent(){this.node&&nd([`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){let{page:t,otcRef:n}=this.context;nd([`preview`])||n&&t===`magiclink`||t===`giftRedemption`||t===`giftSuccess`||e.target===e.currentTarget&&this.context.doAction(`closePopup`)}renderActivePage(){let{page:e,site:t}=this.context;PC({page:e});let n=NC({site:t})[e];return(0,q.jsx)(n,{})}renderPopupNotification(){let{popupNotification:e}=this.context;return!e||!e.type?null:(0,q.jsx)(Bb,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:`portal-preview-ready`,payload:{}},`*`)}render(){let{page:e,pageQuery:t,site:n,customSiteUrl:r,lastPage:i}=this.context,a=ru({site:n,pageQuery:t}).length;PC({page:e});let o={...zC({page:e}).page[e]},s=`regular`,c=``,l=e;switch(e){case`signup`:c=`Cookies must be enabled in your browser to sign up.`;break;case`signin`:c=`Cookies must be enabled in your browser to sign in.`;break;case`accountHome`:l=`account-home`;break;case`accountProfile`:l=`account-profile`;break;case`accountPlan`:l=`account-plan`;break;default:c=`Cookies must be enabled in your browser.`,l=e;break}a>1&&!Ul({site:n})&&Wl({site:n,pageQuery:t})&&e===`signup`&&(l+=` full-size`,s=`full`),(e===`gift`||e===`giftSuccess`||e===`giftRedemption`)&&(l+=` full-size`,s=`full`),e===`magiclink`&&i===`gift`&&(l+=` full-size giftRedemption`,s=`full`);let u=du({site:n});(u&&a>2||!u&&a>1)&&e===`accountPlan`&&(l+=` full-size`,s=`full`),(e===`emailSuppressionFAQ`||e===`emailReceivingFAQ`)&&(l+=` large-size`);let d=`gh-portal-popup-container`;nd([`preview`])&&(l+=` preview`),nd([`preview`],{customSiteUrl:r})&&!n.disableBackground&&(d+=` preview`),nd([`dev`])&&(d+=` dev`);let f=`${d} ${l}`,p=e===`gift`||e===`giftSuccess`||e===`giftRedemption`||e===`magiclink`&&i===`gift`;return this.sendPortalPreviewReadyEvent(),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-popup-wrapper `+l,onClick:e=>this.handlePopupClose(e),children:[this.renderPopupNotification(),(0,q.jsxs)(`div`,{className:f,style:o,ref:e=>this.node=e,tabIndex:-1,children:[(0,q.jsx)(BC,{message:c}),this.renderActivePage(),s===`full`&&!p?(0,q.jsx)(`div`,{className:`gh-portal-powered inside `+(nd([`preview`])?`hidden `:``)+l,children:(0,q.jsx)(RC,{})}):``]})]}),e!==`share`&&!p&&(0,q.jsx)(`div`,{className:`gh-portal-powered outside `+(nd([`preview`])?`hidden `:``)+l,children:(0,q.jsx)(RC,{})})]})}},HC=class extends _.Component{static contextType=J;constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){let t=NC({site:this.context.site})[e];return(0,q.jsx)(t,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();let{page:t}=this.context;t===`giftRedemption`||t===`giftSuccess`||e.target===e.currentTarget&&this.context.doAction(`closePopup`)}renderFrameStyles(){let{site:e,brandColor:t}=this.context,n=eS({site:e});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:t?`:root { --brandcolor: ${t} }`+n:n}}),(0,q.jsx)(`meta`,{name:`viewport`,content:`width=device-width, initial-scale=1, maximum-scale=1`})]})}renderFrameContainer(){let{member:e,site:t,customSiteUrl:n}=this.context,r=zC({member:e}),i=window.innerWidth<480,a={...r.frame.common},o=`gh-portal-popup-background`;return nd([`preview`])&&(r.modalContainer.zIndex=`3999997`),nd([`preview`],{customSiteUrl:n})&&!t.disableBackground&&(o+=` preview`,t.preview_theme===`dark`&&(o+=` preview-dark`)),nd([`dev`])&&(o+=` dev`),(0,q.jsx)(`div`,{style:r.modalContainer,children:(0,q.jsxs)(Jc,{style:a,title:`portal-popup`,head:this.renderFrameStyles(),dataTestId:`portal-popup-frame`,dataDir:this.context.dir,children:[(0,q.jsx)(`div`,{className:o,onClick:e=>this.handlePopupClose(e)}),(0,q.jsx)(VC,{isMobile:i})]})})}render(){let{showPopup:e}=this.context;return e?this.renderFrameContainer():null}};GC({products:XC({numOfProducts:1})});function UC(){return(new Date().getTime()/1e3|0).toString(16)+`xxxxxxxxxxxxxxxx`.replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function WC(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function GC({title:e=`The Blueprint`,description:t=`Thoughts, stories and ideas.`,logo:n=`https://static.ghost.org/v4.0.0/images/ghost-orb-1.png`,icon:r=`https://static.ghost.org/v4.0.0/images/ghost-orb-1.png`,url:i=`https://portal.localhost`,plans:a={monthly:5e3,yearly:15e4,currency:`USD`},products:o=XC({numOfProducts:1}),portalProducts:s=o.map(e=>e.id),accentColor:c=`#45C32E`,portalPlans:l=[`free`,`monthly`,`yearly`],portalDefaultPlan:u=``,membersSignupAccess:d=`all`,freePriceName:f=`Free`,freePriceDescription:p=`Free preview`,paidMembersEnabled:m=!0,portalButton:h=!0,portalName:g=!0,portalButtonIcon:_=`icon-1`,portalButtonSignupText:v=`Subscribe now`,portalButtonStyle:y=`icon-and-text`,membersSupportAddress:b=`support@example.com`,editorDefaultEmailRecipients:x=`visibility`,newsletters:S=[],posts:C=JC(),commentsEnabled:w,recommendations:T=[],recommendationsEnabled:E,labs:D={}}={}){return{title:e,description:t,logo:n,icon:r,accent_color:c,url:i,plans:a,products:o,portal_products:s,members_signup_access:d,free_price_name:f,free_price_description:p,paid_members_enabled:m,portal_button:h,portal_name:g,portal_plans:l,...u?{portal_default_plan:u}:{},portal_button_icon:_,portal_button_signup_text:v,portal_button_style:y,members_support_address:b,comments_enabled:w!==`off`,newsletters:S,recommendations:T,recommendations_enabled:!!E,labs:D,editor_default_email_recipients:x,posts:C}}function KC({name:e=`Black Friday`,code:t=`black-friday`,displayTitle:n=`Black Friday Sale!`,displayDescription:r=`Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.`,type:i=`percent`,cadence:a=`month`,amount:o=50,duration:s=`repeating`,durationInMonths:c=null,currencyRestriction:l=!1,currency:u=null,status:d=`active`,tierId:f=``,tierName:p=`Basic`,redemptionType:m=`signup`}={}){return{id:`offer_${UC()}`,name:e,code:t,display_title:n,display_description:r,type:i,cadence:a,amount:o,duration:s,duration_in_months:c,currency_restriction:l,currency:u,status:d,tier:{id:`${f}`,name:p},redemption_type:m}}function qC({name:e=`Jamie Larson`,email:t=`jamie@example.com`,firstname:n=`Jamie`,subscriptions:r=[],paid:i=!1,status:a,avatarImage:o=``,subscribed:s=!0,email_suppression:c={suppressed:!1,info:null},newsletters:l=[]}={}){let u={uuid:WC(),email:t,name:e,firstname:n,paid:i,subscribed:s,avatar_image:o,subscriptions:r,email_suppression:c,newsletters:l};return a===void 0?i?u.status=`paid`:u.status=`free`:u.status=a,u}function JC({numOfPosts:e=3}={}){let t=[];for(let n=0;n<e;n++)t.push(YC({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function YC({id:e=`post_${UC()}`,title:t=`Post`,excerpt:n=`Post excerpt`,slug:r=`post`,featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:r,featured:i}}function XC({numOfProducts:e=3}={}){let t=[ZC({name:`Bronze`,description:`Access to all members articles`,monthlyPrice:tw({interval:`month`,amount:700}),yearlyPrice:tw({interval:`year`,amount:7e3}),numOfBenefits:2}),ZC({name:`Silver`,description:`Access to all members articles and weekly podcast`,monthlyPrice:tw({interval:`month`,amount:1200}),yearlyPrice:tw({interval:`year`,amount:12e3}),numOfBenefits:3}),ZC({name:`Friends of the Blueprint`,description:`Get access to everything and lock in early adopter pricing for life + listen to my podcast`,monthlyPrice:tw({interval:`month`,amount:18e3}),yearlyPrice:tw({interval:`year`,amount:17e3}),numOfBenefits:4})].slice(0,e),n=QC({});return[...t,n]}function ZC({type:e=`paid`,name:t=`Basic`,description:n=``,id:r=`product_${UC()}`,monthlyPrice:i=tw(),yearlyPrice:a=tw({interval:`year`}),numOfBenefits:o=2,trialDays:s=null}){return{id:r,name:t,description:n,monthlyPrice:e===`free`?null:i,yearlyPrice:e===`free`?null:a,type:e,benefits:$C({numOfBenefits:o}),trial_days:s}}function QC({name:e=`Free tier`,description:t=`Free tier description`,id:n=`product_${UC()}`,numOfBenefits:r=2}){return{id:n,name:e,type:`free`,description:t,benefits:$C({numOfBenefits:r})}}function $C({numOfBenefits:e}){let t=UC();return[ew({name:`Limited early adopter pricing #${t.substring(0,6)}`}),ew({name:`Latest gear reviews #${t.substring(6,12)}`}),ew({name:`Weekly email newsletter #${t.substring(12,18)}`}),ew({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function ew({id:e=`benefit_${UC()}`,name:t=`Benefit`}){return{id:e,name:t}}function tw({interval:e=`month`,amount:t=e===`month`?500:5e3,nickname:n=e===`month`?`Monthly`:`Yearly`,description:r=null,currency:i=`usd`,active:a=!0,id:o=`price_${UC()}`}={}){return{id:o,active:a,nickname:n,currency:i,amount:t,interval:e,description:r,stripe_price_id:`price_${UC()}`,stripe_product_id:`prod_${UC()}`,type:`recurring`}}function nw({id:e=`sub_${UC()}`,status:t=`active`,currency:n=`USD`,interval:r=`year`,amount:i=r===`month`?500:5e3,nickname:a=r===`month`?`Monthly`:`Yearly`,cardLast4:o=`4242`,offer:s=iw,priceId:c=`price_${UC()}`,startDate:l=`2021-10-05T03:18:30.000Z`,currentPeriodEnd:u=`2022-10-05T03:18:30.000Z`,cancelAtPeriodEnd:d=!1,trialEndAt:f=null,nextPayment:p=null,tier:m=null}={}){return{id:e,customer:{id:`cus_${UC()}`,name:`Jamie`,email:`jamie@example.com`},plan:{id:`price_${UC()}`,nickname:a,amount:i,interval:r,currency:n},offer:s,status:t,start_date:l,default_payment_card_last4:o,cancel_at_period_end:d,cancellation_reason:null,current_period_end:u,trial_end_at:f,next_payment:p,tier:m,price:{id:`stripe_price_${UC()}`,price_id:c,nickname:a,amount:i,interval:r,type:`recurring`,currency:n,product:{id:`stripe_prod_${UC()}`,product_id:`prod_${UC()}`}}}}function rw(){let e=XC({numOfProducts:1});return GC({products:e,portalPlans:[`free`,`monthly`,`yearly`],portalProducts:e.map(e=>e.id)})}rw();var iw=KC({tierId:GC({products:[ZC({numOfBenefits:2,type:`free`})]}).products[0]?.id});qC({status:`free`}),qC({status:`paid`,paid:!0,subscriptions:[nw()]}),qC({status:`comped`,paid:!0,subscriptions:[]}),qC({status:`comped`,paid:!0,subscriptions:[nw({amount:0})]}),qC({status:`paid`,paid:!0,subscriptions:[nw({amount:1500,startDate:`2019-05-01T11:42:40.000Z`,currentPeriodEnd:`2021-06-05T11:42:40.000Z`})]}),rw();var aw=[QC({name:`Free`,description:`Free tier description which is actually a pretty long description`,numOfBenefits:2}),ZC({name:`The Blueprint`,description:``,monthlyPrice:tw({interval:`month`,amount:500}),yearlyPrice:tw({interval:`year`,amount:5e3}),numOfBenefits:3}),ZC({name:`Friends of the Blueprint Silver`,description:`Access to all members articles and weekly podcast`,monthlyPrice:tw({interval:`month`,amount:1200}),yearlyPrice:tw({interval:`year`,amount:11e3}),numOfBenefits:4})],ow=GC({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:aw,portalProducts:aw.map(e=>e.id),allowSelfSignup:!0,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}]}),sw=KC({tierId:ow.products[1]?.id}),cw={free:qC({name:`Jamie Larson`,email:`jamie@example.com`,firstname:`Jamie`,subscriptions:[],paid:!1,status:`free`,avatarImage:``,subscribed:!0}),paid:qC({paid:!0,status:`paid`,subscriptions:[nw({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:qC({paid:!0,status:`comped`,subscriptions:[]}),complimentaryWithSubscription:qC({paid:!0,status:`comped`,subscriptions:[nw({amount:0})]}),preview:qC({paid:!0,status:`paid`,subscriptions:[nw({amount:1500,startDate:`2019-05-01T11:42:40.000Z`,currentPeriodEnd:new Date().toISOString()})]})};function lw(){if(!aw||!aw[1])return null;let e=ow?.products?.[1].monthlyPrice;return{site:ow,member:qC({paid:!0,status:`paid`,subscriptions:[nw({offer:null,priceId:e?.id,status:`active`,currency:e?.currency,interval:e?.interval,amount:e?.amount,cardLast4:`4242`,startDate:`2021-10-05T03:18:30.000Z`,currentPeriodEnd:`2022-10-05T03:18:30.000Z`,cancelAtPeriodEnd:!1})]})}}function uw(e){let t=e.getAttribute(`href`),n;try{n=new URL(t,window.location.origin)}catch{return}let r=[`#/portal`,`#/share`],i=r.some(e=>n.hash.startsWith(e)),a=r.some(e=>t.startsWith(e));!n.hash||!i||a||n.origin===window.location.origin&&e.setAttribute(`href`,n.hash)}var dw=`CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION`;function fw({data:e,state:t}){return{page:e.page,popupNotification:null,fieldErrors:{},lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function pw({state:e}){return{showPopup:!e.showPopup}}function mw({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function hw({state:e}){return e.page===`gift`&&QS(),e.lastPage?{page:e.lastPage,fieldErrors:{}}:gw({state:e})}function gw({state:e}){let t=!1;e.page===`gift`&&(QS(),t=mC()),t||vl();let n={...e.pageData||{}};return delete n.redirect,{showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,fieldErrors:{},page:e.page===`magiclink`?``:e.page,pageData:n}}function _w({data:e,state:t}){let{action:n=`openNotification`,status:r=`success`,autoHide:i=!0,closeable:a=!0,duration:o=2600,message:s=``}=e||{},c=Iu({type:n,status:r,autoHide:i,closeable:a,duration:o,state:t,message:s});return{notification:c,notificationSequence:c.count}}function vw(){return{notification:null}}async function yw({api:e,state:t}){try{return await e.member.signout(),{action:`signout:success`}}catch{return{action:`signout:failed`,popupNotification:Y({type:`signout:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to log out, please try again`)})}}}async function bw({data:e,api:t,state:n}){try{let r=await t.member.getIntegrityToken(),i={...e,emailType:`signin`,integrityToken:r,includeOTC:!0},{otc_ref:a,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:`magiclink`,lastPage:`signin`,...a?{otcRef:a}:{},inboxLinks:o,pageData:{...n.pageData||{},email:(e?.email||``).trim()}}}catch(e){return{action:`signin:failed`,popupNotification:Y({type:`signin:failed`,autoHide:!1,closeable:!0,state:n,status:`error`,message:Kc(e,K(`Failed to log in, please try again`))})}}}function xw({data:e,state:t}){let n=(e?.email||``).trim(),r=e?.otcRef,i=e?.inboxLinks;return r?{showPopup:!0,page:`magiclink`,lastPage:`signin`,otcRef:r,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function Sw({data:e,api:t}){let n=K(`Failed to verify code, please try again`);try{let r=await t.member.getIntegrityToken(),i=await t.member.verifyOTC({...e,integrityToken:r});return i.redirectUrl?window.location.assign(i.redirectUrl):{action:`verifyOTC:failed`,actionErrorMessage:Kc(i.errors?.[0],n)}}catch(e){return{action:`verifyOTC:failed`,actionErrorMessage:Kc(e,n)}}}async function Cw({data:e,state:t,api:n}){try{let{plan:r,tierId:i,cadence:a,email:o,name:s,newsletters:c,offerId:l}=e;s=s?.trim();let u;if(r.toLowerCase()===`free`){let t=await n.member.getIntegrityToken();({inboxLinks:u}=await n.member.sendMagicLink({emailType:`signup`,integrityToken:t,...e,name:s}))}else{let e=t.member?{checkoutType:`upgrade`}:void 0;return(!i||!a)&&({tierId:i,cadence:a}=bu({site:t?.site,priceId:r})),await n.member.checkoutPlan({plan:r,tierId:i,cadence:a,email:o,name:s,newsletters:c,offerId:l,metadata:e}),{page:`loading`}}return{page:`magiclink`,lastPage:`signup`,inboxLinks:u,pageData:{...t.pageData||{},email:(o||``).trim()}}}catch(n){return n.code===dw?t.member?{action:`signup:failed`,popupNotification:Y({type:`signup:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`You already have an active subscription.`)})}:{page:`magiclink`,lastPage:`signin`,pageData:{...t.pageData||{},email:(e?.email||``).trim()},popupNotification:null}:{action:`signup:failed`,popupNotification:Y({type:`signup:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:Kc(n,K(`Failed to sign up, please try again`))})}}}async function ww({data:e,state:t,api:n}){try{let{email:r,name:i,giftToken:a}=e;if(i=i?.trim(),t.member){await n.gift.redeem({token:a});let e=await n.member.sessionData(),r=Iu({type:`giftRedeem`,status:`success`,autoHide:!0,closeable:!0,state:t,message:Jd({member:e})});return vl(),{action:`redeemGift:success`,member:e,showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,notification:r,notificationSequence:r.count}}let o=await n.member.getIntegrityToken(),s=new URL(t?.site?.url||window.location.href);s.search=new URLSearchParams({giftRedemption:`true`}).toString(),s.hash=``;let{otc_ref:c,inboxLinks:l}=await n.member.sendMagicLink({email:(r||``).trim(),emailType:`subscribe`,integrityToken:o,includeOTC:!0,redirect:s.href,giftToken:a,...i?{name:i}:{}});return{page:`magiclink`,lastPage:`gift`,...c?{otcRef:c}:{},inboxLinks:l,pageData:{...t.pageData||{},email:(r||``).trim(),...i?{name:i}:{},redirect:s.href}}}catch(e){let n=Iu({type:`giftRedeem`,status:`error`,autoHide:!1,closeable:!0,state:t,message:Yd(e)});return vl(),{action:`redeemGift:failed`,showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,notification:n,notificationSequence:n.count}}}async function Tw({data:e,state:t,api:n}){try{let{plan:r,offerId:i,tierId:a,cadence:o}=e;(!a||!o)&&({tierId:a,cadence:o}=bu({site:t?.site,priceId:r})),await n.member.checkoutPlan({plan:r,tierId:a,cadence:o,offerId:i,metadata:{checkoutType:`upgrade`}})}catch{return{action:`checkoutPlan:failed`,popupNotification:Y({type:`checkoutPlan:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Ew({state:e,api:t}){try{await t.member.continueGiftCheckout()}catch{return{action:`continueGiftSubscription:failed`,popupNotification:Y({type:`continueGiftSubscription:failed`,autoHide:!1,closeable:!0,state:e,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Dw({data:e,state:t,api:n}){try{let{tierId:t,cadence:r,duration:i,email:a,deliveryMethod:o,recipientEmail:s,recipientName:c,buyerName:l,personalMessage:u,deliveryDate:d}=e;return await n.member.checkoutGift({tierId:t,...i===void 0?{cadence:r}:{duration:i},...a?{email:a}:{},...o===void 0?{}:{deliveryMethod:o},...s?{recipientEmail:s}:{},...c?{recipientName:c}:{},...l?{buyerName:l}:{},...u?{personalMessage:u}:{},...d?{deliveryDate:d}:{}}),{action:`checkoutGift:success`}}catch{return{action:`checkoutGift:failed`,popupNotification:Y({type:`checkoutGift:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Ow({data:e,state:t,api:n}){try{let{plan:r,planId:i,subscriptionId:a,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:c}=bu({site:t?.site,priceId:i});await n.member.updateSubscription({planName:r,tierId:s,cadence:c,subscriptionId:a,cancelAtPeriodEnd:o,planId:i});let l=await n.member.sessionData(),u=`updateSubscription:success`;return{action:u,popupNotification:Y({type:u,autoHide:!0,closeable:!0,state:t,status:`success`,message:K(`Subscription plan updated successfully`)}),page:`accountHome`,member:l}}catch{return{action:`updateSubscription:failed`,popupNotification:Y({type:`updateSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to update subscription, please try again`)})}}}async function kw({data:e,state:t,api:n}){try{let{subscriptionId:t,cancellationReason:r}=e;return await n.member.updateSubscription({subscriptionId:t,smartCancel:!0,cancellationReason:r}),{action:`cancelSubscription:success`,page:`accountHome`,member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:`cancelSubscription:failed`,popupNotification:Y({type:`cancelSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to cancel subscription, please try again`)})}}}async function Aw({data:e,state:t,api:n}){try{let{subscriptionId:t}=e;return await n.member.updateSubscription({subscriptionId:t,cancelAtPeriodEnd:!1}),{action:`continueSubscription:success`,page:`accountHome`,member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:`continueSubscription:failed`,popupNotification:Y({type:`continueSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to cancel subscription, please try again`)})}}}async function jw({data:e,state:t,api:n}){try{let{offerId:r,subscriptionId:i}=e;return await n.member.applyOffer({offerId:r,subscriptionId:i}),{action:`applyOffer:success`,page:`accountHome`,member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:Y({type:`applyOffer:success`,autoHide:!0,closeable:!0,state:t,status:`success`,message:`Offer applied successfully!`})}}catch{return{action:`applyOffer:failed`,popupNotification:Y({type:`applyOffer:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:`Failed to apply offer, please try again`})}}}async function Mw({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:`editBilling:failed`,popupNotification:Y({type:`editBilling:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to update billing information, please try again`)})}}}async function Nw({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:`manageBilling:failed`,popupNotification:Y({type:`manageBilling:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to open billing portal, please try again`)})}}}async function Pw(){return{popupNotification:null}}async function Fw({data:e,state:t}){let{action:n,message:r=``}=e;return n||=`showPopupNotification:success`,{popupNotification:Y({type:n,autoHide:!0,closeable:!0,state:t,status:`success`,message:r})}}async function Iw({data:e,state:t,api:n}){try{let{newsletters:t,enableCommentNotifications:r,enableUpdatesAndAnnouncements:i}=e;if(!t&&r===void 0&&i===void 0)return{};let a={};return t&&(a.newsletters=t),r!==void 0&&(a.enableCommentNotifications=r),i!==void 0&&(a.enableUpdatesAndAnnouncements=i),{action:`updateNewsletterPref:success`,member:await n.member.update(a)}}catch{return{action:`updateNewsletterPref:failed`,popupNotification:Y({type:`updateNewsletter:failed`,autoHide:!0,closeable:!0,state:t,status:`error`,message:K(`Failed to update newsletter settings`)})}}}async function Lw({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:`removeEmailFromSuppressionList:success`,popupNotification:Y({type:`removeEmailFromSuppressionList:success`,autoHide:!0,closeable:!0,state:e,status:`success`,message:K(`You have been successfully resubscribed`)})}}catch{return{action:`removeEmailFromSuppressionList:failed`,popupNotification:Y({type:`removeEmailFromSuppressionList:failed`,autoHide:!0,closeable:!0,state:e,status:`error`,message:K(`Your email has failed to resubscribe, please try again`)})}}}async function Rw({data:e,state:t,api:n}){try{let{subscribed:r}=e,i=await n.member.update({subscribed:r});if(!i)throw Error(`Failed to update newsletter`);let a=`updateNewsletter:success`;return{action:a,member:i,popupNotification:Y({type:a,autoHide:!0,closeable:!0,state:t,status:`success`,message:K(`Email newsletter settings updated`)})}}catch{return{action:`updateNewsletter:failed`,popupNotification:Y({type:`updateNewsletter:failed`,autoHide:!0,closeable:!0,state:t,status:`error`,message:K(`Failed to update newsletter settings`)})}}}async function zw({data:e,state:t,api:n}){let{email:r}=e;if(r!==wu({member:t.member}))try{return await n.member.updateEmailAddress({email:r}),{success:!0}}catch(e){return{success:!1,error:e}}return null}async function Bw({data:e,state:t,api:n}){let r=e?.name?.trim(),i=e?.metafields;if(Du({member:t.member})!==r||i)try{let e=await n.member.update({name:r,metafields:i});if(!e)throw Error(`Failed to update member`);return{member:e,success:!0}}catch(e){return{success:!1,error:e}}return null}async function Vw({state:e,api:t}){if(e.member)try{let e=await t.member.sessionData();return e?{member:e,success:!0,action:`refreshMemberData:success`}:null}catch(e){return{success:!1,error:e,action:`refreshMemberData:failed`}}return null}function Hw(e,t,n){let r=e?.details?.length?e.details:[{property:e?.property,message:e?.message}],i={},a=null;for(let e of r){let n=Uw(e,t);n.input?i[n.input]=n.message:n.sentence&&!a&&(a=n.sentence)}return{fieldErrors:i,message:a??n}}function Uw({property:e,message:t},n){let[r,,i,...a]=(typeof e==`string`?e:``).split(`.`);if(r!==`metafields`)return{};let o=Kc({message:t}),s=n.customFields?.find(e=>e.key===i);if(!s)return{sentence:o};let c=Zp(s,a.join(`.`));return c?{input:c,message:o}:{sentence:K(`{field}: {message}`,{field:s.name,message:o})}}function Ww({fieldErrors:e,message:t,state:n}){return Object.keys(e).length>0?null:Y({type:`updateProfile:failed`,autoHide:!0,closeable:!0,status:`error`,message:t,state:n})}async function Gw({data:e,state:t,api:n}){let[r,i]=await Promise.all([Bw({data:e,state:t,api:n}),zw({data:e,state:t,api:n})]);if(r&&i){if(i.success&&r.success)return{action:`updateProfile:success`,...r.success?{member:r.member}:{},page:`accountHome`,popupNotification:Y({type:`updateProfile:success`,autoHide:!0,closeable:!0,status:`success`,state:t,message:K(`Check your inbox to verify email update`)})};let e=r.success?{fieldErrors:{},message:K(`Failed to send verification email`)}:Hw(r.error,t,K(`Failed to update account data`));return{action:`updateProfile:failed`,fieldErrors:e.fieldErrors,...r.success?{member:r.member}:{},popupNotification:Ww({...e,state:t})}}else if(r){let e=r.success?`updateProfile:success`:`updateProfile:failed`,n=r.success?`success`:`error`,i=r.success?{fieldErrors:{},message:K(`Account details updated successfully`)}:Hw(r.error,t,K(`Failed to update account details`));return{action:e,fieldErrors:i.fieldErrors,...r.success?{member:r.member}:{},...r.success?{page:`accountHome`}:{},popupNotification:r.success?Y({type:e,autoHide:!0,closeable:!0,status:n,state:t,message:i.message}):Ww({...i,state:t})}}else if(i){let e=i.success?`updateProfile:success`:`updateProfile:failed`,n=i.success?`success`:`error`,r=``;return r=i.error?Kc(i.error,K(`Failed to send verification email`)):K(`Check your inbox to verify email update`),{action:e,fieldErrors:{},...i.success?{page:`accountHome`}:{},popupNotification:Y({type:e,autoHide:i.success,closeable:!0,status:n,state:t,message:r})}}return{action:`updateProfile:success`,page:`accountHome`,popupNotification:Y({type:`updateProfile:success`,autoHide:!0,closeable:!0,status:`success`,state:t,message:K(`Account details updated successfully`)})}}async function Kw({data:{siteUrl:e},state:t}){let n=px({siteUrl:e,apiUrl:`not-defined`,contentApiKey:`not-defined`}),{member:r}=t,i=window.location.href,a=Xl(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:`signup`,name:r.name,email:r.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:a,referrerMedium:`Ghost Recommendations`,referrerUrl:i}]:[]}),{}}function qw({data:{recommendationId:e},api:t}){try{let t=localStorage.getItem(`ghost-recommendations-clicked`),n=t?JSON.parse(t):[];if(n.includes(e))return;n.push(e),localStorage.setItem(`ghost-recommendations-clicked`,JSON.stringify(n))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function Jw({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}var Yw={togglePopup:pw,openPopup:mw,closePopup:gw,switchPage:fw,openNotification:_w,closeNotification:vw,back:hw,signout:yw,signin:bw,startSigninOTCFromCustomForm:xw,verifyOTC:Sw,signup:Cw,redeemGift:ww,updateSubscription:Ow,cancelSubscription:kw,continueSubscription:Aw,applyOffer:jw,updateNewsletter:Rw,updateProfile:Gw,refreshMemberData:Vw,clearPopupNotification:Pw,editBilling:Mw,manageBilling:Nw,checkoutPlan:Tw,continueGiftSubscription:Ew,checkoutGift:Dw,updateNewsletterPreference:Iw,showPopupNotification:Fw,removeEmailFromSuppressionList:Lw,oneClickSubscribe:Kw,trackRecommendationClicked:qw,trackRecommendationSubscribed:Jw};async function Xw({action:e,data:t,state:n,api:r}){let i=Yw[e];return i&&await i({data:t,state:n,api:r})||{}}function Zw(e,t){e&&(e.innerText=t)}function Qw(e,t,n){t.classList.add(`error`),Zw(n,Kc(e,K(`There was an error sending the email, please try again`)))}async function $w({event:e,form:t,errorEl:n,siteUrl:r,submitHandler:i,doAction:a,captureException:o}){t.removeEventListener(`submit`,i),e.preventDefault(),n&&(n.innerText=``),t.classList.remove(`success`,`invalid`,`error`);let s=e.target.querySelector(`input[data-members-email]`),c=e.target.querySelector(`input[data-members-name]`),l=t?.dataset?.membersAutoredirect||`true`,u=s?.value,d=(c?.value||``).trim()||void 0,f,p=[],m=[],h=e.target.querySelectorAll(`input[data-members-label]`)||[];for(let e=0;e<h.length;++e)p.push(h[e].value);let g=e.target.querySelectorAll(`input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked`)||[];for(let e=0;e<g.length;++e)m.push({name:g[e].value});t.dataset.membersForm&&(f=t.dataset.membersForm);let _=f===`signin`&&t?.dataset?.membersOtc===`true`;t.classList.add(`loading`);let v=qu(),y={email:u,emailType:f,labels:p,name:d,autoRedirect:l===`true`};_&&(y.includeOTC=!0),v&&(y.urlHistory=v),g.length>0?y.newsletters=m:(e.target.querySelectorAll(`input[type=checkbox][data-members-newsletter]`)||[]).length>0&&(y.newsletters=[]);try{let e=await(await fx(`${r}/members/api/integrity-token/`,{method:`GET`})).text(),i=await fx(`${r}/members/api/send-magic-link/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...y,integrityToken:e})});if(i.ok){t.classList.add(`success`);let e;if(_)try{e=await i.clone().json()}catch{e=void 0}let n=e?.otc_ref;if(n&&typeof a==`function`)try{a(`startSigninOTCFromCustomForm`,{email:(u||``).trim(),otcRef:n,inboxLinks:e?.inboxLinks})}catch(e){console.error(e),o?.(e)}}else Zw(n,Kc(await Uc.fromApiResponse(i),K(`Failed to send magic link email`))),t.classList.add(`error`)}catch(e){Qw(e,t,n)}finally{t.addEventListener(`submit`,i),t.classList.remove(`loading`)}}function eT({event:e,el:t,errorEl:n,siteUrl:r,site:i,member:a,clickHandler:o}){t.removeEventListener(`click`,o),e.preventDefault();let s=t.dataset.membersPlan,c=Bl(i,s.toLowerCase()),l=t.dataset.membersSuccess,u=t.dataset.membersCancel,d,f;l&&(d=new URL(l,window.location.href).href),u&&(f=new URL(u,window.location.href).href),n&&(n.innerText=``),t.classList.add(`loading`);let p=a?{checkoutType:`upgrade`}:{},m=qu();return m&&(p.urlHistory=m),fetch(`${r}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(e){return fetch(`${r}/members/api/create-stripe-checkout-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...c,identity:e,successUrl:d,cancelUrl:f,metadata:p})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe checkout session`));return e.json()})}).then(function(e){return e.url?window.location.assign(e.url):window.Stripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId}).then(function(e){if(e.error)throw Error(e.error.message)})}).catch(function(e){console.error(e),t.addEventListener(`click`,o),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}function tT({siteUrl:e,site:t={},member:n,offers:r=[],doAction:i,captureException:a}={}){if(!e)return;e=e.replace(/\/$/,``),Array.prototype.forEach.call(document.querySelectorAll(`form[data-members-form]`),function(t){let n=t.querySelector(`[data-members-error]`);function r(o){$w({event:o,errorEl:n,form:t,siteUrl:e,submitHandler:r,doAction:i,captureException:a})}t.addEventListener(`submit`,r)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-plan]`),function(r){let i=r.querySelector(`[data-members-error]`);function a(o){eT({el:r,event:o,errorEl:i,member:n,site:t,siteUrl:e,clickHandler:a})}r.addEventListener(`click`,a)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-edit-billing]`),function(t){let n=t.querySelector(`[data-members-error]`),r=t.dataset.membersSuccess,i=t.dataset.membersCancel,a,o;r&&(a=new URL(r,window.location.href).href),i&&(o=new URL(i,window.location.href).href);function s(r){t.removeEventListener(`click`,s),r.preventDefault(),n&&(n.innerText=``),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,successUrl:a,cancelUrl:o})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe checkout session`));return e.json()})}).then(function(e){return window.Stripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)throw Error(K(e.error.message))}).catch(function(e){console.error(e),t.addEventListener(`click`,s),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}t.addEventListener(`click`,s)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-manage-billing]`),function(t){let n=t.querySelector(`[data-members-error]`),r=t.dataset.membersReturn,i;r&&(i=new URL(r,window.location.href).href);function a(r){t.removeEventListener(`click`,a),r.preventDefault(),n&&(n.innerText=``),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,returnUrl:i})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe billing portal session`));return e.json()})}).then(function(e){return window.location.assign(e.url)}).catch(function(e){console.error(e),t.addEventListener(`click`,a),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}t.addEventListener(`click`,a)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-signout]`),function(t){function n(r){t.removeEventListener(`click`,n),r.preventDefault(),t.classList.remove(`error`),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{method:`DELETE`}).then(function(r){r.ok?window.location.replace(e):(t.addEventListener(`click`,n),t.classList.remove(`loading`),t.classList.add(`error`))})}t.addEventListener(`click`,n)});let o=(r||[]).some(e=>e.redemption_type===`retention`);Array.prototype.forEach.call(document.querySelectorAll(`[data-members-cancel-subscription]`),function(t){let n=t.parentElement.querySelector(`[data-members-error]`);function r(a){a.preventDefault();let s=t.dataset.membersCancelSubscription;if(o){i(`openPopup`,{page:`accountPlan`,pageData:{subscriptionId:s,action:`cancel`}});return}return t.removeEventListener(`click`,r),t.classList.remove(`error`),t.classList.add(`loading`),n&&(n.innerText=``),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/subscriptions/${s}/`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,smart_cancel:!0})})}).then(function(e){e.ok?window.location.reload():(t.addEventListener(`click`,r),t.classList.remove(`loading`),t.classList.add(`error`),n&&(n.innerText=K(`There was an error cancelling your subscription, please try again.`)))})}t.addEventListener(`click`,r)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-continue-subscription]`),function(t){let n=t.parentElement.querySelector(`[data-members-error]`);function r(i){t.removeEventListener(`click`,r),i.preventDefault(),t.classList.remove(`error`),t.classList.add(`loading`);let a=t.dataset.membersContinueSubscription;return n&&(n.innerText=``),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/subscriptions/${a}/`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,cancel_at_period_end:!1})})}).then(function(e){e.ok?window.location.reload():(t.addEventListener(`click`,r),t.classList.remove(`loading`),t.classList.add(`error`),n&&(n.innerText=K(`There was an error continuing your subscription, please try again.`)))})}t.addEventListener(`click`,r)})}var nT=e=>{try{return decodeURIComponent(e)}catch{return null}},rT=e=>{if(e===`true`)return!0;if(e===`false`)return!1},iT={staleGiftRedemptionRequest:!0},aT={showPopup:!0,site:ow,member:cw.free,page:`accountEmail`,...lw(),pageData:sw};function oT({site:e,children:t}){let{portal_sentry:n}=e||{};return n&&n.dsn?(0,q.jsx)(Eo,{children:t}):(0,q.jsx)(q.Fragment,{children:t})}var sT=class extends _.Component{constructor(e){super(e),this.setupCustomTriggerButton(),this.state={site:null,member:null,customFields:[],offers:[],page:`loading`,showPopup:!1,action:`init:running`,actionErrorMessage:null,fieldErrors:{},initStatus:`running`,lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){let e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,t){if(t.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`&&t.initStatus!==this.state.initStatus){let{siteUrl:e}=this.props,t=this.getContextFromState();this.sendPortalReadyEvent(),tT({siteUrl:e,site:t.site,member:t.member,offers:t.offers,doAction:t.doAction,captureException:rr})}}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(){let e=document.createElement(`div`);e.style.visibility=`hidden`,e.style.overflow=`scroll`,document.body.appendChild(e),document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t}setupCustomTriggerButton(){this.clickHandler=async e=>{e.preventDefault();let t=e.currentTarget,n=t&&t.dataset.portal,r=this.getPageFromLinkPath(n,this.state.site);if(!r)return;let{page:i,pageQuery:a,pageData:o}=r;if(this.state.initStatus===`success`){if(i===`gift`&&!Kl({site:this.state.site})){this.invalidateGiftRedemptionRequest(),vl();return}if(i===`giftRedemption`&&o?.token){let e=this.startGiftRedemptionRequest(o.token),t=await this.fetchGiftRedemptionData({token:o.token});if(!this.isCurrentGiftRedemptionRequest(e))return;this.setState(t);return}this.invalidateGiftRedemptionRequest(),a&&a!==`free`?this.handleSignupQuery({site:this.state.site,pageQuery:a}):this.dispatchAction(`openPopup`,{page:i,pageQuery:a,pageData:o})}},this.customTriggerButtons=document.querySelectorAll(`[data-portal]`)||[],this.customTriggerButtons.forEach(e=>{e.classList.add(`gh-portal-close`),e.removeEventListener(`click`,this.clickHandler),e.addEventListener(`click`,this.clickHandler)})}handleCustomTriggerClassUpdate(){let e=`gh-portal-open`,t=`gh-portal-close`;this.customTriggerButtons?.forEach(n=>{let r=this.state.showPopup?e:t,i=this.state.showPopup?t:e;n.classList.add(r),n.classList.remove(i)})}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:t}){return this._redemptionRequestId===e&&this.currentRedemptionToken===t}async initSetup(){try{let{site:e,member:t,offers:n,customFields:r,page:i,showPopup:a,popupNotification:o,notification:s,notificationSequence:c,lastPage:l,pageQuery:u,pageData:d}=await this.fetchData(),f=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||`en`;Hc.changeLanguage(f);let p={site:e,member:t,offers:n,customFields:r,page:i,lastPage:l,pageQuery:u,showPopup:a,pageData:d,popupNotification:o,notification:s,notificationSequence:c,dir:Hc.dir()||`ltr`,action:`init:success`,initStatus:`success`,locale:f};if(this.setState(p,()=>{this.handleSignupQuery({site:e,pageQuery:u,member:t})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener(`hashchange`,this.hashHandler,!1),!t){let e=document.querySelectorAll(`[data-lexical-signup-form]`);e.length>0&&e.forEach(e=>{e.style.display=``})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error(`[Portal] Failed to initialize:`,e),this.setState({action:`init:failed`,initStatus:`failed`})}}async fetchData(){let{site:e,member:t,offers:n}=await this.fetchApiData(),{site:r,...i}=this.fetchDevData(),[a,o]=await Promise.all([this.fetchLinkData(e,t),Up({api:this.GhostApi,site:e,member:t})]),{site:s,...c}=a?.staleGiftRedemptionRequest?{}:a,{site:l,...u}=this.fetchPreviewData(),{site:d,...f}=this.fetchNotificationData();return{member:t,offers:n,customFields:o,page:``,site:{...e,...s,...l,...d,...r,plans:{...(r||{}).plans,...(e||{}).plans,...(l||{}).plans}},...i,...c,...f,...u}}fetchDevData(){return nd([`dev`])&&!this.state.customSiteUrl?aT:nd([`test`])?{showPopup:this.props.showPopup===void 0?!0:this.props.showPopup}:{}}fetchOfferQueryStrData(e=``){let t=new URLSearchParams(e),n={};for(let e of t.entries()){let t=e[0],r=decodeURIComponent(e[1]);t===`name`?n.name=r||``:t===`code`?n.code=r||``:t===`display_title`?n.display_title=r||``:t===`display_description`?n.display_description=r||``:t===`type`?n.type=r||``:t===`cadence`?n.cadence=r||``:t===`duration`?n.duration=r||``:t===`duration_in_months`&&!isNaN(Number(r))?n.duration_in_months=Number(r):t===`amount`&&!isNaN(Number(r))?n.amount=Number(r):t===`currency`?n.currency=r||``:t===`status`?n.status=r||``:t===`tier_id`?n.tier={id:r||sw.tier.id}:t===`redemption_type`&&(n.redemption_type=r||`signup`)}if(n.redemption_type===`retention`){let e=cw.preview?.subscriptions?.[0]?.id;return{page:`accountPlan`,offers:[n],pageData:{action:`cancel`,subscriptionId:e}}}return{page:`offer`,pageData:n}}fetchQueryStrData(e=``){let t=new URLSearchParams(e),n={site:{plans:{}}},r=[],i,a=null,o,s,c;for(let e of t.entries()){let t=e[0],l=decodeURIComponent(e[1]);if(t===`button`)n.site.portal_button=JSON.parse(l);else if(t===`name`)n.site.portal_name=JSON.parse(l);else if(t===`signupGiftPromotion`){let e=rT(l);e!==void 0&&(n.site.portal_signup_gift_promotion=e)}else if(t===`accountGiftPromotion`){let e=rT(l);e!==void 0&&(n.site.portal_account_gift_promotion=e)}else if(t===`isFree`&&JSON.parse(l))r.push(`free`);else if(t===`isMonthly`&&JSON.parse(l))r.push(`monthly`);else if(t===`isYearly`&&JSON.parse(l))r.push(`yearly`);else if(t===`portalPrices`)i=l?l.split(`,`):[];else if(t===`portalProducts`)a=l?l.split(`,`):[];else if(t===`page`&&l)n.page=l;else if(t===`accentColor`&&(l===``||l))n.site.accent_color=l;else if(t===`buttonIcon`&&l)n.site.portal_button_icon=l;else if(t===`signupButtonText`)n.site.portal_button_signup_text=l||``;else if(t===`signupTermsHtml`)n.site.portal_signup_terms_html=l||``;else if(t===`signupCheckboxRequired`)n.site.portal_signup_checkbox_required=JSON.parse(l);else if(t===`buttonStyle`&&l)n.site.portal_button_style=l;else if(t===`monthlyPrice`&&!isNaN(Number(l)))n.site.plans.monthly=Number(l),o=Number(l);else if(t===`yearlyPrice`&&!isNaN(Number(l)))n.site.plans.yearly=Number(l),s=Number(l);else if(t===`currency`&&l){let e=l.toUpperCase();n.site.plans.currency=e,n.site.plans.currency_symbol=ju(e),c=e}else t===`disableBackground`?n.site.disableBackground=JSON.parse(l):t===`previewTheme`?n.site.preview_theme=l:t===`membersSignupAccess`&&l?n.site.members_signup_access=l:t===`portalDefaultPlan`&&l?n.site.portal_default_plan=l:t===`transistorPortalSettings`&&l&&(n.site.transistor_portal_settings=JSON.parse(l))}return n.site.portal_plans=r,n.site.portal_products=a,i?n.site.portal_plans=i:o&&s&&c&&(n.site.prices=[{id:`monthly`,stripe_price_id:`dummy_stripe_monthly`,stripe_product_id:`dummy_stripe_product`,active:1,nickname:`Monthly`,currency:c,amount:o,type:`recurring`,interval:`month`},{id:`yearly`,stripe_price_id:`dummy_stripe_yearly`,stripe_product_id:`dummy_stripe_product`,active:1,nickname:`Yearly`,currency:c,amount:s,type:`recurring`,interval:`year`}]),n}fetchNotificationData(){let{type:e,status:t,duration:n,autoHide:r,closeable:i}=nf({billingOnly:!0})||{};return[`stripe:billing-update`].includes(e)?t===`success`?{showPopup:!0,popupNotification:Y({type:e,status:t,duration:n,closeable:i,autoHide:r,state:this.state,message:t===`success`?`Billing info updated successfully`:``})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{return{showPopup:!0,notification:null,page:`giftRedemption`,pageData:{token:e,gift:(await this.GhostApi.gift.fetchRedemptionData({token:e}))?.gifts?.[0]||null}}}catch(e){vl();let t=Iu({type:`giftRedemption:failed`,status:`error`,autoHide:!1,closeable:!0,state:this.state,message:Yd(e)});return{showPopup:!1,pageData:null,notification:t,notificationSequence:t.count}}}async fetchLinkData(e,t){this.invalidateGiftRedemptionRequest();let n=new URLSearchParams(window.location.search);if(n.get(`stripe`)===`gift-purchase-success`){let e=n.get(`gift_token`),t=n.get(`gift_tier`),r=n.get(`gift_cadence`),i=Number(n.get(`gift_duration`)),a=n.get(`gift_delivery`),o=n.get(`gift_delivery_date`),s=/^\d{4}-\d{2}-\d{2}$/.test(o||``)?o:null,c=Number(n.get(`gift_scheduled_at`)),l=Number.isFinite(c)&&c>0?c:null;if(tf([`stripe`,`gift_token`,`gift_tier`,`gift_cadence`,`gift_duration`,`gift_delivery`,`gift_delivery_date`,`gift_scheduled_at`]),e)return QS(),{showPopup:!0,page:`giftSuccess`,pageData:{token:e,tierId:t,cadence:r,duration:Cf.includes(i)?i:null,deliveryMethod:a===`email`?`email`:`link`,deliveryDate:s,scheduledAt:l}}}if(n.get(`action`)===`unsubscribe`)return n.get(`key`)&&n.get(`uuid`)?{showPopup:!0,page:`unsubscribe`,pageData:{uuid:n.get(`uuid`),key:n.get(`key`),newsletterUuid:n.get(`newsletter`),comments:n.get(`comments`),updatesAndAnnouncements:n.get(`updatesandannouncements`)}}:{showPopup:!0,page:`accountEmail`,pageData:{newsletterUuid:n.get(`newsletter`),action:`unsubscribe`,redirect:e.url+`#/portal/account/newsletters`}};if(Gl({site:e})&&n.get(`action`)===`signup`&&n.get(`success`)===`true`)return{showPopup:!0,page:`recommendations`,pageData:{signup:!0}};let[r,i]=window.location.hash.substr(1).split(`?`),a=new URLSearchParams(i??``),o=/^(?:(\w+?))?\/monthly$/,s=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,l=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,u=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,d=/^\/share\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(r&&f.test(r)){let[,n,i]=r.match(f),o=parseInt(i);if(o===1||o===0)return t||a.get(`uuid`)&&a.get(`key`)?{showPopup:!0,page:`feedback`,pageData:{uuid:a.get(`uuid`),key:a.get(`key`),postId:n,score:o}}:{showPopup:!0,page:`signin`,pageData:{redirect:e.url+`#/feedback/${n}/${o}/`}}}if(r&&l.test(r)){let[,t]=r.match(l),n=nT(t);if(!n)return{};xf(e.url);let i=this.startGiftRedemptionRequest(n),a=await this.fetchGiftRedemptionData({token:n});return this.isCurrentGiftRedemptionRequest(i)?a:iT}if(r&&d.test(r))return{showPopup:!0,page:`share`};if(r&&u.test(r)){let[,n]=r.match(u),{page:i,pageQuery:l,pageData:d}=this.getPageFromLinkPath(n,e)||{};if(!t&&i&&FC({page:i}))return{showPopup:!0,page:`signin`,pageData:{redirect:e.url+`#/portal/${n}/`}};if(i===`gift`&&!Kl({site:e}))return vl(),{};i===`gift`&&xf(e.url);let f=[`accountPlan`,`accountProfile`].includes(i)?`accountHome`:null,p=!([`monthly`,`yearly`].includes(l)||o.test(l)||s.test(l)||c.test(l)),m=a.get(`redirect`),h=i===`signin`&&m?{...d||{},redirect:m}:d;return{showPopup:p,...i?{page:i}:{},...l?{pageQuery:l}:{},...h?{pageData:h}:{},...f?{lastPage:f}:{}}}return{}}fetchPreviewData(){let[,e]=window.location.hash.substr(1).split(`?`);if(nd([`preview`])){let t={};try{t=nd([`offerPreview`])?this.fetchOfferQueryStrData(e):this.fetchQueryStrData(e)}catch(e){return rr(e),{}}return{...t,showPopup:!0}}return{}}getColorOverride(){let e=document.querySelector(`script[data-ghost]`);return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){let{siteUrl:e,customSiteUrl:t,apiUrl:n,apiKey:r}=this.props;try{this.GhostApi=this.props.api||px({siteUrl:e,apiUrl:n,apiKey:r});let{site:t,member:i,offers:a}=await this.GhostApi.init(),o=this.getColorOverride();return o&&(t.accent_color=o),this.setupFirstPromoter({site:t,member:i}),this.setupSentry({site:t}),{site:t,member:i,offers:a}}catch(e){if(nd([`dev`,`test`],{customSiteUrl:t}))return{};throw e}}setupSentry({site:e}){if(nd([`test`]))return null;let{portal_sentry:t,portal_version:n,version:r}=e,i=`portal@2.72.11|ghost@${r}`;t&&t.dsn&&vo({dsn:t.dsn,environment:t.env||`development`,release:i,beforeSend:e=>Sl({event:e})?e:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:t}){if(nd([`test`]))return null;let n=Eu({site:e}),r=Au({site:e});if(r=r?.replace(/^(\S*\.)?(\S*\.\S*)$/i,`.$2`),n&&r){let e=document.createElement(`script`);e.type=`text/javascript`,e.async=!0,e.src=`https://cdn.firstpromoter.com/fprom.js`,e.onload=e.onreadystatechange=function(){let e=this.readyState;if(!e||e===`complete`||e===`loaded`)try{if(window.$FPROM.init(n,r),Yu({member:t})){let e=t.email,n=t.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:e,uid:n});else{let t=window._fprom||[];window._fprom=t,t.push([`event`,`signup`]),t.push([`email`,e]),t.push([`uid`,n])}}}catch{}};let i=document.getElementsByTagName(`script`)[0];i.parentNode.insertBefore(e,i)}}async dispatchAction(e,t){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{let n=await Xw({action:e,data:t,state:this.state,api:this.GhostApi});this.setState(n),n&&n.action&&!n.action.includes(`:failed`)&&(this.timeoutId=setTimeout(()=>{this.setState({action:``})},2e3))}catch(n){if(console.error(`[Portal] Failed to dispatch action: ${e}`,n),t&&t.throwErrors)throw n;let r=Y({type:`${e}:failed`,autoHide:!0,closeable:!0,status:`error`,state:this.state,meta:{error:n}});this.setState({action:`${e}:failed`,actionErrorMessage:Kc(n,K(`An unexpected error occured. Please try again or <a>contact support</a> if the error persists.`)),popupNotification:r})}}async updateStateForPreviewLinks(){let{site:e,...t}=this.fetchPreviewData(),n=await this.fetchLinkData(this.state.site,this.state.member);if(n?.staleGiftRedemptionRequest)return;let{site:r,...i}=n,a=this.state.page===`gift`&&i.page!==`gift`;a&&QS();let o=a&&!i.page,s={site:{...this.state.site,...r||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(r||{}).plans,...(e||{}).plans}},...i,...t,...o?{showPopup:!1,lastPage:null}:{}};this.handleSignupQuery({site:s.site,pageQuery:s.pageQuery}),this.setState(s)}async handleOfferQuery({site:e,offerId:t,member:n=this.state.member}){if(vl(),!(!Tl({member:n})||wl({member:n}))){let e=Iu({type:`offer:failed`,status:`error`,autoHide:!1,closeable:!0,state:this.state,message:K(`You already have an active subscription.`)});await this.dispatchAction(`closePopup`),this.setState({notification:e,notificationSequence:e.count});return}try{let n=(await this.GhostApi.site.offer({offerId:t}))?.offers[0];if(!n||!n.tier||Vu({offer:n})||!Hu({site:e,offer:n}))return;this.dispatchAction(`openPopup`,{page:`offer`,pageData:n})}catch{}}handleSignupQuery({site:e,pageQuery:t,member:n}){let r=/^offers\/(\w+?)\/?$/,i=t;if(r.test(t||``)){let[,i]=t.match(r);this.handleOfferQuery({site:e,offerId:i,member:n});return}Ru({site:e,pageQuery:t})&&(i=Ru({site:e,pageQuery:t}));let a=Vl({site:e,priceId:i});if(t&&t!==`free`){vl();let t=a?.id||i;t!==`free`&&this.dispatchAction(`openPopup`,{page:`loading`});let{tierId:n,cadence:r}=bu({site:e,priceId:t});this.dispatchAction(`signup`,{plan:t,tierId:n,cadence:r})}}getPageFromLinkPath(e){let t=/^signup\/?(?:\/(\w+?))?\/?$/,n=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,r=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,i=/^offers\/(\w+?)\/?$/,a=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e===``)return{page:`default`};if(a.test(e)){let[,t]=e.match(a),n=nT(t);return n?{page:`giftRedemption`,pageData:{token:n}}:null}else if(i.test(e))return{pageQuery:e};else if(e===`signup`)return{page:`signup`};else if(n.test(e)){let[,t]=e.match(n);return{page:`signup`,pageQuery:`${t}/monthly`}}else if(r.test(e)){let[,t]=e.match(r);return{page:`signup`,pageQuery:`${t}/yearly`}}else if(t.test(e)){let[,n]=e.match(t);return{page:`signup`,pageQuery:n}}else if(e===`signup/free`)return{page:`signup`,pageQuery:`free`};else if(e===`signup/monthly`)return{page:`signup`,pageQuery:`monthly`};else if(e===`signup/yearly`)return{page:`signup`,pageQuery:`yearly`};else if(e===`signin`)return{page:`signin`};else if(e===`account`)return{page:`accountHome`};else if(e===`account/plans`)return{page:`accountPlan`};else if(e===`account/profile`)return{page:`accountProfile`};else if(e===`account/newsletters`)return{page:`accountEmail`};else if(e===`support`)return{page:`support`};else if(e===`support/success`)return{page:`supportSuccess`};else if(e===`support/error`)return{page:`supportError`};else if(e===`recommendations`)return{page:`recommendations`,pageData:{signup:!1}};else if(e===`gift`)return{page:`gift`,pageData:{giftStep:`plan`}};else if(e===`gift/delivery`)return{page:`gift`,pageData:{giftStep:`delivery`}};else if(e===`share`)return{page:`share`};else if(e===`account/newsletters/help`)return{page:`emailReceivingFAQ`,pageData:{direct:!0}};else if(e===`account/newsletters/disabled`)return{page:`emailSuppressionFAQ`,pageData:{direct:!0}};return{page:`default`}}getAccentColor(){let{accent_color:e}=this.state.site||{};return mb(e)}getRetentionPreviewMember({site:e,offers:t}){let n=(t||[]).find(e=>Vu({offer:e})),r=n?.tier?.id,i=r?lu({site:e,productId:r}):null,a=i?n.cadence===`year`?i.yearlyPrice:i.monthlyPrice:null,o=cw.preview,s=o?.subscriptions?.[0];return!s||!i||!a?o:{...o,subscriptions:[{...s,plan:{...s.plan,amount:a.amount,interval:a.interval,currency:a.currency.toUpperCase()},price:{...s.price,price_id:a.id,amount:a.amount,interval:a.interval,currency:a.currency,product:{...s.price?.product,product_id:i.id}},tier:{id:i.id,name:i.name}}]}}getContextPage({site:e,page:t,member:n}){if(!t||t==="default"){let r=Ul({site:e})||!Wl({site:e})?`signin`:`signup`;t=n?`accountHome`:r}return PC({page:t})}getContextMember({site:e,page:t,member:n,offers:r,pageData:i,customSiteUrl:a}){return nd([`dev`,`preview`],{customSiteUrl:a})?FC({page:t})||IC({page:t})?nd([`dev`],{customSiteUrl:a})?n||cw.free:nd([`preview`])?t===`accountPlan`&&i?.action===`cancel`?this.getRetentionPreviewMember({site:e,offers:r}):cw.preview:cw.paid:null:n}getContextFromState(){let{site:e,member:t,offers:n,action:r,actionErrorMessage:i,page:a,lastPage:o,showPopup:s,pageQuery:c,pageData:l,popupNotification:u,notification:d,customSiteUrl:f,dir:p,scrollbarWidth:m,otcRef:h,inboxLinks:g,customFields:_,fieldErrors:v}=this.state,y=this.getContextPage({site:e,page:a,member:t}),b=this.getContextMember({site:e,page:y,member:t,offers:n,pageData:l,customSiteUrl:f});return{api:this.GhostApi,site:e,offers:n,action:r,actionErrorMessage:i,brandColor:this.getAccentColor(),page:y,pageQuery:c,pageData:l,member:b,customFields:_,fieldErrors:v,lastPage:o,showPopup:s,popupNotification:u,notification:d,customSiteUrl:f,dir:p,scrollbarWidth:m,otcRef:h,inboxLinks:g,doAction:(e,t)=>this.dispatchAction(e,t)}}getRecommendationButtons(){return document.querySelectorAll(`[data-recommendation]`)||[]}setupRecommendationButtons(){let e=e=>{let t=e.currentTarget.dataset.recommendation;t?this.dispatchAction(`trackRecommendationClicked`,{recommendationId:t}).catch(console.error):console.warn(`[Portal] Invalid usage of data-recommendation attribute`)},t=this.getRecommendationButtons();for(let n of t)n.addEventListener(`click`,e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll(`a[href*="#/portal"], a[href*="#/share"]`).forEach(uw)}render(){return this.state.initStatus===`success`?(0,q.jsx)(oT,{site:this.state.site,children:(0,q.jsxs)(J.Provider,{value:this.getContextFromState(),children:[(0,q.jsx)(HC,{}),(0,q.jsx)(od,{}),(0,q.jsx)(sf,{})]})}):null}},cT=`ghost-portal-root`;function lT(){let e=document.createElement(`div`);e.id=cT,e.setAttribute(`data-testid`,`portal-root`),document.body.appendChild(e)}function uT(){let e=document.querySelector(`script[data-ghost]`);if(e){let t=e.dataset.i18n===`true`;return{siteUrl:e.dataset.ghost,apiKey:e.dataset.key,apiUrl:e.dataset.api,siteI18nEnabled:t,locale:e.dataset.locale}}return{}}function dT(){let e=new URL(window.location.href);e.searchParams.get(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState({},document.title,e.href))}function fT(){let[,e]=window.location.hash.substring(1).split(`?`);new URLSearchParams(e).get(`previewTheme`)===`dark`&&(document.documentElement.dataset.portalPreviewTheme=`dark`)}function pT(){let{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:r,locale:i}=uT(),a=e||window.location.origin;fT(),lT(),dT(),v.render((0,q.jsx)(_.default.StrictMode,{children:(0,q.jsx)(sT,{siteUrl:a,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:r,locale:i})}),document.getElementById(cT))}pT()});
5693
+ `),r=[];return e&&r.push(`subject=${encodeURIComponent(e)}`),n&&r.push(`body=${encodeURIComponent(n)}`),`mailto:${r.length?`?${r.join(`&`)}`:``}`},SC=({shareTitle:e,shareUrl:t})=>bC(`https://www.linkedin.com/shareArticle`,{mini:`true`,url:t,title:e}),CC=()=>{let e=yC(),t=e.document,n=e.location,r=(e,n=`content`)=>t.querySelector(e)?.[n]||``,i=r(`link[rel="canonical"]`,`href`)||n.origin+n.pathname+n.search,a=r(`meta[property="og:title"]`)||t.title||``,o=r(`meta[property="og:description"]`)||r(`meta[name="description"]`)||``,s=r(`meta[property="og:image"]`)||r(`meta[name="twitter:image"]`)||``,c=r(`link[rel="icon"]`,`href`)||r(`link[rel="shortcut icon"]`,`href`)||r(`link[rel="apple-touch-icon"]`,`href`),l=r(`meta[name="author"]`),u=(l&&!/^https?:\/\//i.test(l)?l:``)||r(`meta[name="twitter:creator"]`)||``,d=r(`meta[property="og:site_name"]`)||r(`meta[name="application-name"]`)||``;if(!d)try{d=new URL(i).hostname.replace(/^www\./,``)}catch{d=``}let f=[a,i].filter(Boolean).join(` `).trim(),p={twitter:bC(`https://twitter.com/intent/tweet`,{url:i,text:a}),facebook:bC(`https://www.facebook.com/sharer/sharer.php`,{u:i}),email:xC({shareTitle:a,shareUrl:i}),threads:bC(`https://www.threads.net/intent/post`,{text:f}),linkedin:SC({shareTitle:a,shareUrl:i}),bluesky:bC(`https://bsky.app/intent/compose`,{text:f})};return{shareUrl:i,shareTitle:a,shareExcerpt:o,shareImage:s,shareFavicon:c,shareSiteName:d,shareAuthor:u,socialLinks:p}},wC=()=>{let[e]=(0,_.useState)(CC);return e},TC=e=>(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 -3.268 64 68.414`,width:2232,height:2500,...e,children:(0,q.jsx)(`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`})}),EC=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`lucide lucide-ellipsis-icon lucide-ellipsis`,...e,children:[(0,q.jsx)(`circle`,{cx:12,cy:12,r:1}),(0,q.jsx)(`circle`,{cx:19,cy:12,r:1}),(0,q.jsx)(`circle`,{cx:5,cy:12,r:1})]}),DC=e=>(0,q.jsxs)(`svg`,{id:`svg9`,width:666.66669,height:666.66718,viewBox:`0 0 666.66668 666.66717`,xmlns:`http://www.w3.org/2000/svg`,"xmlns:svg":`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`defs`,{id:`defs13`,children:(0,q.jsx)(`clipPath`,{clipPathUnits:`userSpaceOnUse`,id:`clipPath25`,children:(0,q.jsx)(`path`,{d:`M 0,700 H 700 V 0 H 0 Z`,id:`path23`})})}),(0,q.jsx)(`g`,{id:`g17`,transform:`matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)`,children:(0,q.jsx)(`g`,{id:`g19`,children:(0,q.jsxs)(`g`,{id:`g21`,clipPath:`url(#clipPath25)`,children:[(0,q.jsx)(`g`,{id:`g27`,transform:`translate(600,350)`,children:(0,q.jsx)(`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`})}),(0,q.jsx)(`g`,{id:`g31`,transform:`translate(447.9175,273.6036)`,children:(0,q.jsx)(`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`})})]})})})]}),OC=e=>(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`lucide lucide-link-icon lucide-link`,...e,children:[(0,q.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}),(0,q.jsx)(`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`})]}),kC=e=>(0,q.jsxs)(`svg`,{viewBox:`0 5 2490 2490.0000000000005`,xmlns:`http://www.w3.org/2000/svg`,width:2500,height:2495,...e,children:[(0,q.jsx)(`path`,{d:`M185.2 313.1H2252V2291H185.2z`,fill:`#fff`}),(0,q.jsx)(`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`}),(0,q.jsx)(`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`})]}),AC=e=>(0,q.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,q.jsx)(`g`,{clipPath:`url(#clip0_351_18008)`,children:(0,q.jsx)(`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`})}),(0,q.jsx)(`defs`,{children:(0,q.jsx)(`clipPath`,{id:`clip0_351_18008`,children:(0,q.jsx)(`rect`,{width:17,height:17,fill:`white`,transform:`translate(0.5 0.5)`})})})]}),jC=e=>(0,q.jsx)(`svg`,{viewBox:`0 0 1200 1226.37`,xmlns:`http://www.w3.org/2000/svg`,width:2446,height:2500,...e,children:(0,q.jsx)(`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`})}),MC={signin:tS,signup:gb,accountHome:CS,accountPlan:_p,accountProfile:wS,accountEmail:NS,signupNewsletter:Av,unsubscribe:RS,magiclink:Ib,loading:mx,offer:Hb,feedback:xx,emailSuppressed:zS,emailSuppressionFAQ:BS,emailReceivingFAQ:VS,support:HS,supportSuccess:Tx,supportError:Rx,recommendations:Kx,gift:vC,giftRedemption:Ox,giftSuccess:Fx,share:()=>{let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(),a=(0,_.useRef)(null),{shareUrl:o,shareTitle:s,shareExcerpt:c,shareImage:l,shareFavicon:u,shareSiteName:d,shareAuthor:f,socialLinks:p}=wC();(0,_.useEffect)(()=>()=>{clearTimeout(i.current)},[]),(0,_.useEffect)(()=>{if(!n)return;let e=a.current?.ownerDocument||document,t=e=>{a.current&&!a.current.contains(e.target)&&(e.stopPropagation(),e.preventDefault(),r(!1))},i=e=>{e.key===`Escape`&&r(!1)};return e.addEventListener(`click`,t,!0),e.addEventListener(`keydown`,i),()=>{e.removeEventListener(`click`,t,!0),e.removeEventListener(`keydown`,i)}},[n]);let m=async()=>{await Ax(o)&&(t(!0),clearTimeout(i.current),i.current=setTimeout(()=>{t(!1)},2e3))},h=()=>{r(e=>!e)},g=()=>{r(!1)};return(0,q.jsxs)(`div`,{className:`gh-portal-content gh-portal-share`,children:[(0,q.jsx)(vf,{}),(0,q.jsx)(`div`,{className:`gh-portal-share-header`,children:(0,q.jsx)(`h1`,{className:`gh-portal-main-title`,children:K(`Share`)})}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview`,children:[l&&(0,q.jsx)(`img`,{className:`gh-portal-share-preview-image`,src:l,alt:``,"data-testid":`share-preview-image`}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-content`,children:[s&&(0,q.jsx)(`h2`,{className:`gh-portal-share-preview-title`,children:s}),c&&(0,q.jsx)(`p`,{className:`gh-portal-share-preview-excerpt`,children:c}),(u||d||f)&&(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-footer`,children:[u&&(0,q.jsx)(`img`,{className:`gh-portal-share-preview-favicon`,src:u,alt:``,"data-testid":`share-preview-favicon`}),(0,q.jsxs)(`div`,{className:`gh-portal-share-preview-meta`,children:[d&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-site`,children:d}),d&&f&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-separator`,"aria-hidden":`true`,children:`|`}),f&&(0,q.jsx)(`span`,{className:`gh-portal-share-preview-author`,children:f})]})]})]})]}),(0,q.jsxs)(`div`,{className:`gh-portal-share-actions`,children:[(0,q.jsxs)(`button`,{className:`gh-portal-btn gh-portal-share-action copy`,type:`button`,onClick:m,"aria-label":K(e?`Copied`:`Copy link`),title:K(e?`Copied`:`Copy link`),children:[e?(0,q.jsx)(`span`,{className:`gh-portal-share-icon copied`,"aria-hidden":`true`,children:(0,q.jsx)(Ff,{})}):(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(OC,{})}),(0,q.jsx)(`span`,{className:`gh-portal-share-label`,children:K(e?`Copied`:`Copy link`)})]}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action twitter`,href:p.twitter,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`X (Twitter)`),title:K(`X (Twitter)`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon x`,"aria-hidden":`true`,children:(0,q.jsx)(jC,{})})}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action linkedin`,href:p.linkedin,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`LinkedIn`),title:K(`LinkedIn`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(kC,{})})}),(0,q.jsx)(`a`,{className:`gh-portal-btn gh-portal-share-action email`,href:p.email,target:`_blank`,rel:`noopener noreferrer`,"aria-label":K(`Email`),title:K(`Email`),children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(yb,{})})}),(0,q.jsxs)(`div`,{className:`gh-portal-share-more`,ref:a,children:[(0,q.jsx)(`button`,{className:`gh-portal-btn gh-portal-share-action more`,type:`button`,onClick:h,"aria-label":K(`More options`),title:K(`More options`),"aria-haspopup":`menu`,"aria-expanded":n,children:(0,q.jsx)(`span`,{className:`gh-portal-share-icon`,"aria-hidden":`true`,children:(0,q.jsx)(EC,{})})}),n&&(0,q.jsxs)(`div`,{className:`gh-portal-share-more-menu`,role:`menu`,"aria-label":K(`More options`),children:[(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.facebook,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(DC,{})}),(0,q.jsx)(`span`,{children:K(`Facebook`)})]}),(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.threads,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(AC,{})}),(0,q.jsx)(`span`,{children:K(`Threads`)})]}),(0,q.jsxs)(`a`,{className:`gh-portal-share-more-item`,href:p.bluesky,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,onClick:g,children:[(0,q.jsx)(`span`,{className:`gh-portal-share-more-item-icon`,"aria-hidden":`true`,children:(0,q.jsx)(TC,{})}),(0,q.jsx)(`span`,{children:K(`Bluesky`)})]})]})]})]})]})}},NC=function(){return MC},PC=function({page:e}){return Object.keys(MC).includes(e)?e:`signup`},FC=function({page:e}){return e.includes(`account`)},IC=function({page:e}){return e.includes(`offer`)},LC=e=>(0,q.jsx)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,q.jsx)(`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`})}),RC=class extends _.Component{static contextType=J;render(){return(0,q.jsxs)(`a`,{href:`https://ghost.org`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(LC,{}),`Powered by Ghost`]})}},zC=()=>({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 BC({message:e}){return xl()?(0,q.jsx)(`div`,{className:`gh-portal-cookiebanner`,children:e}):null}var VC=class extends _.Component{static contextType=J;componentDidMount(){this.node&&!nd([`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){let t=e.target&&e.target.tagName;(!(t===`INPUT`||t===`TEXTAREA`)||!e?.target?.value)&&this.context.doAction(`closePopup`)}sendContainerHeightChangeEvent(){this.node&&nd([`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){let{page:t,otcRef:n}=this.context;nd([`preview`])||n&&t===`magiclink`||t===`giftRedemption`||t===`giftSuccess`||e.target===e.currentTarget&&this.context.doAction(`closePopup`)}renderActivePage(){let{page:e,site:t}=this.context;PC({page:e});let n=NC({site:t})[e];return(0,q.jsx)(n,{})}renderPopupNotification(){let{popupNotification:e}=this.context;return!e||!e.type?null:(0,q.jsx)(Bb,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:`portal-preview-ready`,payload:{}},`*`)}render(){let{page:e,pageQuery:t,site:n,customSiteUrl:r,lastPage:i}=this.context,a=ru({site:n,pageQuery:t}).length;PC({page:e});let o={...zC({page:e}).page[e]},s=`regular`,c=``,l=e;switch(e){case`signup`:c=`Cookies must be enabled in your browser to sign up.`;break;case`signin`:c=`Cookies must be enabled in your browser to sign in.`;break;case`accountHome`:l=`account-home`;break;case`accountProfile`:l=`account-profile`;break;case`accountPlan`:l=`account-plan`;break;default:c=`Cookies must be enabled in your browser.`,l=e;break}a>1&&!Ul({site:n})&&Wl({site:n,pageQuery:t})&&e===`signup`&&(l+=` full-size`,s=`full`),(e===`gift`||e===`giftSuccess`||e===`giftRedemption`)&&(l+=` full-size`,s=`full`),e===`magiclink`&&i===`gift`&&(l+=` full-size giftRedemption`,s=`full`);let u=du({site:n});(u&&a>2||!u&&a>1)&&e===`accountPlan`&&(l+=` full-size`,s=`full`),(e===`emailSuppressionFAQ`||e===`emailReceivingFAQ`)&&(l+=` large-size`);let d=`gh-portal-popup-container`;nd([`preview`])&&(l+=` preview`),nd([`preview`],{customSiteUrl:r})&&!n.disableBackground&&(d+=` preview`),nd([`dev`])&&(d+=` dev`);let f=`${d} ${l}`,p=e===`gift`||e===`giftSuccess`||e===`giftRedemption`||e===`magiclink`&&i===`gift`;return this.sendPortalPreviewReadyEvent(),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`gh-portal-popup-wrapper `+l,onClick:e=>this.handlePopupClose(e),children:[this.renderPopupNotification(),(0,q.jsxs)(`div`,{className:f,style:o,ref:e=>this.node=e,tabIndex:-1,children:[(0,q.jsx)(BC,{message:c}),this.renderActivePage(),s===`full`&&!p?(0,q.jsx)(`div`,{className:`gh-portal-powered inside `+(nd([`preview`])?`hidden `:``)+l,children:(0,q.jsx)(RC,{})}):``]})]}),e!==`share`&&!p&&(0,q.jsx)(`div`,{className:`gh-portal-powered outside `+(nd([`preview`])?`hidden `:``)+l,children:(0,q.jsx)(RC,{})})]})}},HC=class extends _.Component{static contextType=J;constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){let t=NC({site:this.context.site})[e];return(0,q.jsx)(t,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();let{page:t}=this.context;t===`giftRedemption`||t===`giftSuccess`||e.target===e.currentTarget&&this.context.doAction(`closePopup`)}renderFrameStyles(){let{site:e,brandColor:t}=this.context,n=eS({site:e});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:t?`:root { --brandcolor: ${t} }`+n:n}}),(0,q.jsx)(`meta`,{name:`viewport`,content:`width=device-width, initial-scale=1, maximum-scale=1`})]})}renderFrameContainer(){let{member:e,site:t,customSiteUrl:n}=this.context,r=zC({member:e}),i=window.innerWidth<480,a={...r.frame.common},o=`gh-portal-popup-background`;return nd([`preview`])&&(r.modalContainer.zIndex=`3999997`),nd([`preview`],{customSiteUrl:n})&&!t.disableBackground&&(o+=` preview`,t.preview_theme===`dark`&&(o+=` preview-dark`)),nd([`dev`])&&(o+=` dev`),(0,q.jsx)(`div`,{style:r.modalContainer,children:(0,q.jsxs)(Jc,{style:a,title:`portal-popup`,head:this.renderFrameStyles(),dataTestId:`portal-popup-frame`,dataDir:this.context.dir,children:[(0,q.jsx)(`div`,{className:o,onClick:e=>this.handlePopupClose(e)}),(0,q.jsx)(VC,{isMobile:i})]})})}render(){let{showPopup:e}=this.context;return e?this.renderFrameContainer():null}};GC({products:XC({numOfProducts:1})});function UC(){return(new Date().getTime()/1e3|0).toString(16)+`xxxxxxxxxxxxxxxx`.replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function WC(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function GC({title:e=`The Blueprint`,description:t=`Thoughts, stories and ideas.`,logo:n=`https://static.ghost.org/v4.0.0/images/ghost-orb-1.png`,icon:r=`https://static.ghost.org/v4.0.0/images/ghost-orb-1.png`,url:i=`https://portal.localhost`,plans:a={monthly:5e3,yearly:15e4,currency:`USD`},products:o=XC({numOfProducts:1}),portalProducts:s=o.map(e=>e.id),accentColor:c=`#45C32E`,portalPlans:l=[`free`,`monthly`,`yearly`],portalDefaultPlan:u=``,membersSignupAccess:d=`all`,freePriceName:f=`Free`,freePriceDescription:p=`Free preview`,paidMembersEnabled:m=!0,portalButton:h=!0,portalName:g=!0,portalButtonIcon:_=`icon-1`,portalButtonSignupText:v=`Subscribe now`,portalButtonStyle:y=`icon-and-text`,membersSupportAddress:b=`support@example.com`,editorDefaultEmailRecipients:x=`visibility`,newsletters:S=[],posts:C=JC(),commentsEnabled:w,recommendations:T=[],recommendationsEnabled:E,labs:D={}}={}){return{title:e,description:t,logo:n,icon:r,accent_color:c,url:i,plans:a,products:o,portal_products:s,members_signup_access:d,free_price_name:f,free_price_description:p,paid_members_enabled:m,portal_button:h,portal_name:g,portal_plans:l,...u?{portal_default_plan:u}:{},portal_button_icon:_,portal_button_signup_text:v,portal_button_style:y,members_support_address:b,comments_enabled:w!==`off`,newsletters:S,recommendations:T,recommendations_enabled:!!E,labs:D,editor_default_email_recipients:x,posts:C}}function KC({name:e=`Black Friday`,code:t=`black-friday`,displayTitle:n=`Black Friday Sale!`,displayDescription:r=`Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.`,type:i=`percent`,cadence:a=`month`,amount:o=50,duration:s=`repeating`,durationInMonths:c=null,currencyRestriction:l=!1,currency:u=null,status:d=`active`,tierId:f=``,tierName:p=`Basic`,redemptionType:m=`signup`}={}){return{id:`offer_${UC()}`,name:e,code:t,display_title:n,display_description:r,type:i,cadence:a,amount:o,duration:s,duration_in_months:c,currency_restriction:l,currency:u,status:d,tier:{id:`${f}`,name:p},redemption_type:m}}function qC({name:e=`Jamie Larson`,email:t=`jamie@example.com`,firstname:n=`Jamie`,subscriptions:r=[],paid:i=!1,status:a,avatarImage:o=``,subscribed:s=!0,email_suppression:c={suppressed:!1,info:null},newsletters:l=[]}={}){let u={uuid:WC(),email:t,name:e,firstname:n,paid:i,subscribed:s,avatar_image:o,subscriptions:r,email_suppression:c,newsletters:l};return a===void 0?i?u.status=`paid`:u.status=`free`:u.status=a,u}function JC({numOfPosts:e=3}={}){let t=[];for(let n=0;n<e;n++)t.push(YC({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function YC({id:e=`post_${UC()}`,title:t=`Post`,excerpt:n=`Post excerpt`,slug:r=`post`,featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:r,featured:i}}function XC({numOfProducts:e=3}={}){let t=[ZC({name:`Bronze`,description:`Access to all members articles`,monthlyPrice:tw({interval:`month`,amount:700}),yearlyPrice:tw({interval:`year`,amount:7e3}),numOfBenefits:2}),ZC({name:`Silver`,description:`Access to all members articles and weekly podcast`,monthlyPrice:tw({interval:`month`,amount:1200}),yearlyPrice:tw({interval:`year`,amount:12e3}),numOfBenefits:3}),ZC({name:`Friends of the Blueprint`,description:`Get access to everything and lock in early adopter pricing for life + listen to my podcast`,monthlyPrice:tw({interval:`month`,amount:18e3}),yearlyPrice:tw({interval:`year`,amount:17e3}),numOfBenefits:4})].slice(0,e),n=QC({});return[...t,n]}function ZC({type:e=`paid`,name:t=`Basic`,description:n=``,id:r=`product_${UC()}`,monthlyPrice:i=tw(),yearlyPrice:a=tw({interval:`year`}),numOfBenefits:o=2,trialDays:s=null}){return{id:r,name:t,description:n,monthlyPrice:e===`free`?null:i,yearlyPrice:e===`free`?null:a,type:e,benefits:$C({numOfBenefits:o}),trial_days:s}}function QC({name:e=`Free tier`,description:t=`Free tier description`,id:n=`product_${UC()}`,numOfBenefits:r=2}){return{id:n,name:e,type:`free`,description:t,benefits:$C({numOfBenefits:r})}}function $C({numOfBenefits:e}){let t=UC();return[ew({name:`Limited early adopter pricing #${t.substring(0,6)}`}),ew({name:`Latest gear reviews #${t.substring(6,12)}`}),ew({name:`Weekly email newsletter #${t.substring(12,18)}`}),ew({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function ew({id:e=`benefit_${UC()}`,name:t=`Benefit`}){return{id:e,name:t}}function tw({interval:e=`month`,amount:t=e===`month`?500:5e3,nickname:n=e===`month`?`Monthly`:`Yearly`,description:r=null,currency:i=`usd`,active:a=!0,id:o=`price_${UC()}`}={}){return{id:o,active:a,nickname:n,currency:i,amount:t,interval:e,description:r,stripe_price_id:`price_${UC()}`,stripe_product_id:`prod_${UC()}`,type:`recurring`}}function nw({id:e=`sub_${UC()}`,status:t=`active`,currency:n=`USD`,interval:r=`year`,amount:i=r===`month`?500:5e3,nickname:a=r===`month`?`Monthly`:`Yearly`,cardLast4:o=`4242`,offer:s=iw,priceId:c=`price_${UC()}`,startDate:l=`2021-10-05T03:18:30.000Z`,currentPeriodEnd:u=`2022-10-05T03:18:30.000Z`,cancelAtPeriodEnd:d=!1,trialEndAt:f=null,nextPayment:p=null,tier:m=null}={}){return{id:e,customer:{id:`cus_${UC()}`,name:`Jamie`,email:`jamie@example.com`},plan:{id:`price_${UC()}`,nickname:a,amount:i,interval:r,currency:n},offer:s,status:t,start_date:l,default_payment_card_last4:o,cancel_at_period_end:d,cancellation_reason:null,current_period_end:u,trial_end_at:f,next_payment:p,tier:m,price:{id:`stripe_price_${UC()}`,price_id:c,nickname:a,amount:i,interval:r,type:`recurring`,currency:n,product:{id:`stripe_prod_${UC()}`,product_id:`prod_${UC()}`}}}}function rw(){let e=XC({numOfProducts:1});return GC({products:e,portalPlans:[`free`,`monthly`,`yearly`],portalProducts:e.map(e=>e.id)})}rw();var iw=KC({tierId:GC({products:[ZC({numOfBenefits:2,type:`free`})]}).products[0]?.id});qC({status:`free`}),qC({status:`paid`,paid:!0,subscriptions:[nw()]}),qC({status:`comped`,paid:!0,subscriptions:[]}),qC({status:`comped`,paid:!0,subscriptions:[nw({amount:0})]}),qC({status:`paid`,paid:!0,subscriptions:[nw({amount:1500,startDate:`2019-05-01T11:42:40.000Z`,currentPeriodEnd:`2021-06-05T11:42:40.000Z`})]}),rw();var aw=[QC({name:`Free`,description:`Free tier description which is actually a pretty long description`,numOfBenefits:2}),ZC({name:`The Blueprint`,description:``,monthlyPrice:tw({interval:`month`,amount:500}),yearlyPrice:tw({interval:`year`,amount:5e3}),numOfBenefits:3}),ZC({name:`Friends of the Blueprint Silver`,description:`Access to all members articles and weekly podcast`,monthlyPrice:tw({interval:`month`,amount:1200}),yearlyPrice:tw({interval:`year`,amount:11e3}),numOfBenefits:4})],ow=GC({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:aw,portalProducts:aw.map(e=>e.id),allowSelfSignup:!0,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}]}),sw=KC({tierId:ow.products[1]?.id}),cw={free:qC({name:`Jamie Larson`,email:`jamie@example.com`,firstname:`Jamie`,subscriptions:[],paid:!1,status:`free`,avatarImage:``,subscribed:!0}),paid:qC({paid:!0,status:`paid`,subscriptions:[nw({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:qC({paid:!0,status:`comped`,subscriptions:[]}),complimentaryWithSubscription:qC({paid:!0,status:`comped`,subscriptions:[nw({amount:0})]}),preview:qC({paid:!0,status:`paid`,subscriptions:[nw({amount:1500,startDate:`2019-05-01T11:42:40.000Z`,currentPeriodEnd:new Date().toISOString()})]})};function lw(){if(!aw||!aw[1])return null;let e=ow?.products?.[1].monthlyPrice;return{site:ow,member:qC({paid:!0,status:`paid`,subscriptions:[nw({offer:null,priceId:e?.id,status:`active`,currency:e?.currency,interval:e?.interval,amount:e?.amount,cardLast4:`4242`,startDate:`2021-10-05T03:18:30.000Z`,currentPeriodEnd:`2022-10-05T03:18:30.000Z`,cancelAtPeriodEnd:!1})]})}}function uw(e){let t=e.getAttribute(`href`),n;try{n=new URL(t,window.location.origin)}catch{return}let r=[`#/portal`,`#/share`],i=r.some(e=>n.hash.startsWith(e)),a=r.some(e=>t.startsWith(e));!n.hash||!i||a||n.origin===window.location.origin&&e.setAttribute(`href`,n.hash)}var dw=`CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION`;function fw({data:e,state:t}){return{page:e.page,popupNotification:null,fieldErrors:{},lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function pw({state:e}){return{showPopup:!e.showPopup}}function mw({data:e}){return{showPopup:!0,reloadOnPopupClose:!1,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function hw({state:e}){return e.page===`gift`&&QS(),e.lastPage?{page:e.lastPage,fieldErrors:{}}:gw({state:e})}function gw({state:e}){let t=!1;e.page===`gift`&&(QS(),t=mC()),t||vl();let n={...e.pageData||{}};return delete n.redirect,{showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,fieldErrors:{},page:e.page===`magiclink`?``:e.page,pageData:n}}function _w({data:e,state:t}){let{action:n=`openNotification`,status:r=`success`,autoHide:i=!0,closeable:a=!0,duration:o=2600,message:s=``}=e||{},c=Iu({type:n,status:r,autoHide:i,closeable:a,duration:o,state:t,message:s});return{notification:c,notificationSequence:c.count}}function vw(){return{notification:null}}async function yw({api:e,state:t}){try{return await e.member.signout(),{action:`signout:success`}}catch{return{action:`signout:failed`,popupNotification:Y({type:`signout:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to log out, please try again`)})}}}async function bw({data:e,api:t,state:n}){try{let r=await t.member.getIntegrityToken(),i={...e,emailType:`signin`,integrityToken:r,includeOTC:!0},{otc_ref:a,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:`magiclink`,lastPage:`signin`,...a?{otcRef:a}:{},inboxLinks:o,pageData:{...n.pageData||{},email:(e?.email||``).trim()}}}catch(e){return{action:`signin:failed`,popupNotification:Y({type:`signin:failed`,autoHide:!1,closeable:!0,state:n,status:`error`,message:Kc(e,K(`Failed to log in, please try again`))})}}}function xw({data:e,state:t}){let n=(e?.email||``).trim(),r=e?.otcRef,i=e?.inboxLinks;return r?{showPopup:!0,page:`magiclink`,lastPage:`signin`,otcRef:r,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function Sw({data:e,api:t}){let n=K(`Failed to verify code, please try again`);try{let r=await t.member.getIntegrityToken(),i=await t.member.verifyOTC({...e,integrityToken:r});return i.redirectUrl?window.location.assign(i.redirectUrl):{action:`verifyOTC:failed`,actionErrorMessage:Kc(i.errors?.[0],n)}}catch(e){return{action:`verifyOTC:failed`,actionErrorMessage:Kc(e,n)}}}async function Cw({data:e,state:t,api:n}){try{let{plan:r,tierId:i,cadence:a,email:o,name:s,newsletters:c,offerId:l}=e;s=s?.trim();let u;if(r.toLowerCase()===`free`){let t=await n.member.getIntegrityToken();({inboxLinks:u}=await n.member.sendMagicLink({emailType:`signup`,integrityToken:t,...e,name:s}))}else{let e=t.member?{checkoutType:`upgrade`}:void 0;return(!i||!a)&&({tierId:i,cadence:a}=bu({site:t?.site,priceId:r})),await n.member.checkoutPlan({plan:r,tierId:i,cadence:a,email:o,name:s,newsletters:c,offerId:l,metadata:e}),{page:`loading`}}return{page:`magiclink`,lastPage:`signup`,inboxLinks:u,pageData:{...t.pageData||{},email:(o||``).trim()}}}catch(n){return n.code===dw?t.member?{action:`signup:failed`,popupNotification:Y({type:`signup:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`You already have an active subscription.`)})}:{page:`magiclink`,lastPage:`signin`,pageData:{...t.pageData||{},email:(e?.email||``).trim()},popupNotification:null}:{action:`signup:failed`,popupNotification:Y({type:`signup:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:Kc(n,K(`Failed to sign up, please try again`))})}}}async function ww({data:e,state:t,api:n}){try{let{email:r,name:i,giftToken:a}=e;if(i=i?.trim(),t.member){await n.gift.redeem({token:a});let e=await n.member.sessionData(),r=Iu({type:`giftRedeem`,status:`success`,autoHide:!0,closeable:!0,state:t,message:Jd({member:e})});return vl(),{action:`redeemGift:success`,member:e,showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,notification:r,notificationSequence:r.count}}let o=await n.member.getIntegrityToken(),s=new URL(t?.site?.url||window.location.href);s.search=new URLSearchParams({giftRedemption:`true`}).toString(),s.hash=``;let{otc_ref:c,inboxLinks:l}=await n.member.sendMagicLink({email:(r||``).trim(),emailType:`subscribe`,integrityToken:o,includeOTC:!0,redirect:s.href,giftToken:a,...i?{name:i}:{}});return{page:`magiclink`,lastPage:`gift`,...c?{otcRef:c}:{},inboxLinks:l,pageData:{...t.pageData||{},email:(r||``).trim(),...i?{name:i}:{},redirect:s.href}}}catch(e){let n=Iu({type:`giftRedeem`,status:`error`,autoHide:!1,closeable:!0,state:t,message:Yd(e)});return vl(),{action:`redeemGift:failed`,showPopup:!1,lastPage:null,pageQuery:``,popupNotification:null,notification:n,notificationSequence:n.count}}}async function Tw({data:e,state:t,api:n}){try{let{plan:r,offerId:i,tierId:a,cadence:o}=e;(!a||!o)&&({tierId:a,cadence:o}=bu({site:t?.site,priceId:r})),await n.member.checkoutPlan({plan:r,tierId:a,cadence:o,offerId:i,metadata:{checkoutType:`upgrade`}})}catch{return{action:`checkoutPlan:failed`,popupNotification:Y({type:`checkoutPlan:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Ew({state:e,api:t}){try{await t.member.continueGiftCheckout()}catch{return{action:`continueGiftSubscription:failed`,popupNotification:Y({type:`continueGiftSubscription:failed`,autoHide:!1,closeable:!0,state:e,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Dw({data:e,state:t,api:n}){try{let{tierId:t,cadence:r,duration:i,email:a,deliveryMethod:o,recipientEmail:s,recipientName:c,buyerName:l,personalMessage:u,deliveryDate:d}=e;return await n.member.checkoutGift({tierId:t,...i===void 0?{cadence:r}:{duration:i},...a?{email:a}:{},...o===void 0?{}:{deliveryMethod:o},...s?{recipientEmail:s}:{},...c?{recipientName:c}:{},...l?{buyerName:l}:{},...u?{personalMessage:u}:{},...d?{deliveryDate:d}:{}}),{action:`checkoutGift:success`}}catch{return{action:`checkoutGift:failed`,popupNotification:Y({type:`checkoutGift:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to process checkout, please try again`)})}}}async function Ow({data:e,state:t,api:n}){try{let{plan:r,planId:i,subscriptionId:a,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:c}=bu({site:t?.site,priceId:i});await n.member.updateSubscription({planName:r,tierId:s,cadence:c,subscriptionId:a,cancelAtPeriodEnd:o,planId:i});let l=await n.member.sessionData(),u=`updateSubscription:success`;return{action:u,popupNotification:Y({type:u,autoHide:!0,closeable:!0,state:t,status:`success`,message:K(`Subscription plan updated successfully`)}),page:`accountHome`,member:l}}catch{return{action:`updateSubscription:failed`,popupNotification:Y({type:`updateSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to update subscription, please try again`)})}}}async function kw({data:e,state:t,api:n}){try{let{subscriptionId:t,cancellationReason:r}=e;return await n.member.updateSubscription({subscriptionId:t,smartCancel:!0,cancellationReason:r}),{action:`cancelSubscription:success`,page:`accountHome`,member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:`cancelSubscription:failed`,popupNotification:Y({type:`cancelSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to cancel subscription, please try again`)})}}}async function Aw({data:e,state:t,api:n}){try{let{subscriptionId:t}=e;return await n.member.updateSubscription({subscriptionId:t,cancelAtPeriodEnd:!1}),{action:`continueSubscription:success`,page:`accountHome`,member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:`continueSubscription:failed`,popupNotification:Y({type:`continueSubscription:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to cancel subscription, please try again`)})}}}async function jw({data:e,state:t,api:n}){try{let{offerId:r,subscriptionId:i}=e;return await n.member.applyOffer({offerId:r,subscriptionId:i}),{action:`applyOffer:success`,page:`accountHome`,member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:Y({type:`applyOffer:success`,autoHide:!0,closeable:!0,state:t,status:`success`,message:`Offer applied successfully!`})}}catch{return{action:`applyOffer:failed`,popupNotification:Y({type:`applyOffer:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:`Failed to apply offer, please try again`})}}}async function Mw({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:`editBilling:failed`,popupNotification:Y({type:`editBilling:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to update billing information, please try again`)})}}}async function Nw({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:`manageBilling:failed`,popupNotification:Y({type:`manageBilling:failed`,autoHide:!1,closeable:!0,state:t,status:`error`,message:K(`Failed to open billing portal, please try again`)})}}}async function Pw(){return{popupNotification:null}}async function Fw({data:e,state:t}){let{action:n,message:r=``,status:i=`success`}=e;return n||=`showPopupNotification:success`,{popupNotification:Y({type:n,autoHide:!0,closeable:!0,state:t,status:i,message:r})}}async function Iw({data:e,state:t,api:n}){try{let{newsletters:r,enableCommentNotifications:i,enableUpdatesAndAnnouncements:a,successMessage:o}=e;if(!r&&i===void 0&&a===void 0)return{};let s={};r&&(s.newsletters=r),i!==void 0&&(s.enableCommentNotifications=i),a!==void 0&&(s.enableUpdatesAndAnnouncements=a);let c=await n.member.update(s),l=`updateNewsletterPref:success`;return{action:l,member:c,...o&&{popupNotification:Y({type:l,autoHide:!0,closeable:!0,state:t,status:`success`,message:o})}}}catch{return{action:`updateNewsletterPref:failed`,popupNotification:Y({type:`updateNewsletter:failed`,autoHide:!0,closeable:!0,state:t,status:`error`,message:K(`Failed to update newsletter settings`)})}}}async function Lw({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:`removeEmailFromSuppressionList:success`,popupNotification:Y({type:`removeEmailFromSuppressionList:success`,autoHide:!0,closeable:!0,state:e,status:`success`,message:K(`You have been successfully resubscribed`)})}}catch{return{action:`removeEmailFromSuppressionList:failed`,popupNotification:Y({type:`removeEmailFromSuppressionList:failed`,autoHide:!0,closeable:!0,state:e,status:`error`,message:K(`Your email has failed to resubscribe, please try again`)})}}}async function Rw({data:e,state:t,api:n}){try{let{subscribed:r}=e,i=await n.member.update({subscribed:r});if(!i)throw Error(`Failed to update newsletter`);let a=`updateNewsletter:success`;return{action:a,member:i,popupNotification:Y({type:a,autoHide:!0,closeable:!0,state:t,status:`success`,message:K(`Email newsletter settings updated`)})}}catch{return{action:`updateNewsletter:failed`,popupNotification:Y({type:`updateNewsletter:failed`,autoHide:!0,closeable:!0,state:t,status:`error`,message:K(`Failed to update newsletter settings`)})}}}async function zw({data:e,state:t,api:n}){let{email:r}=e;if(r!==wu({member:t.member}))try{return await n.member.updateEmailAddress({email:r}),{success:!0}}catch(e){return{success:!1,error:e}}return null}async function Bw({data:e,state:t,api:n}){let r=e?.name?.trim(),i=e?.metafields;if(Du({member:t.member})!==r||i)try{let e=await n.member.update({name:r,metafields:i});if(!e)throw Error(`Failed to update member`);return{member:e,success:!0}}catch(e){return{success:!1,error:e}}return null}async function Vw({state:e,api:t}){if(e.member)try{let e=await t.member.sessionData();return e?{member:e,success:!0,action:`refreshMemberData:success`}:null}catch(e){return{success:!1,error:e,action:`refreshMemberData:failed`}}return null}function Hw(e,t,n){let r=e?.details?.length?e.details:[{property:e?.property,message:e?.message}],i={},a=null;for(let e of r){let n=Uw(e,t);n.input?i[n.input]=n.message:n.sentence&&!a&&(a=n.sentence)}return{fieldErrors:i,message:a??n}}function Uw({property:e,message:t},n){let[r,,i,...a]=(typeof e==`string`?e:``).split(`.`);if(r!==`metafields`)return{};let o=Kc({message:t}),s=n.customFields?.find(e=>e.key===i);if(!s)return{sentence:o};let c=Zp(s,a.join(`.`));return c?{input:c,message:o}:{sentence:K(`{field}: {message}`,{field:s.name,message:o})}}function Ww({fieldErrors:e,message:t,state:n}){return Object.keys(e).length>0?null:Y({type:`updateProfile:failed`,autoHide:!0,closeable:!0,status:`error`,message:t,state:n})}async function Gw({data:e,state:t,api:n}){let[r,i]=await Promise.all([Bw({data:e,state:t,api:n}),zw({data:e,state:t,api:n})]);if(r&&i){if(i.success&&r.success)return{action:`updateProfile:success`,...r.success?{member:r.member}:{},page:`accountHome`,popupNotification:Y({type:`updateProfile:success`,autoHide:!0,closeable:!0,status:`success`,state:t,message:K(`Check your inbox to verify email update`)})};let e=r.success?{fieldErrors:{},message:K(`Failed to send verification email`)}:Hw(r.error,t,K(`Failed to update account data`));return{action:`updateProfile:failed`,fieldErrors:e.fieldErrors,...r.success?{member:r.member}:{},popupNotification:Ww({...e,state:t})}}else if(r){let e=r.success?`updateProfile:success`:`updateProfile:failed`,n=r.success?`success`:`error`,i=r.success?{fieldErrors:{},message:K(`Account details updated successfully`)}:Hw(r.error,t,K(`Failed to update account details`));return{action:e,fieldErrors:i.fieldErrors,...r.success?{member:r.member}:{},...r.success?{page:`accountHome`}:{},popupNotification:r.success?Y({type:e,autoHide:!0,closeable:!0,status:n,state:t,message:i.message}):Ww({...i,state:t})}}else if(i){let e=i.success?`updateProfile:success`:`updateProfile:failed`,n=i.success?`success`:`error`,r=``;return r=i.error?Kc(i.error,K(`Failed to send verification email`)):K(`Check your inbox to verify email update`),{action:e,fieldErrors:{},...i.success?{page:`accountHome`}:{},popupNotification:Y({type:e,autoHide:i.success,closeable:!0,status:n,state:t,message:r})}}return{action:`updateProfile:success`,page:`accountHome`,popupNotification:Y({type:`updateProfile:success`,autoHide:!0,closeable:!0,status:`success`,state:t,message:K(`Account details updated successfully`)})}}async function Kw({data:{siteUrl:e},state:t}){let n=px({siteUrl:e,apiUrl:`not-defined`,contentApiKey:`not-defined`}),{member:r}=t,i=window.location.href,a=Xl(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:`signup`,name:r.name,email:r.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:a,referrerMedium:`Ghost Recommendations`,referrerUrl:i}]:[]}),{}}function qw({data:{recommendationId:e},api:t}){try{let t=localStorage.getItem(`ghost-recommendations-clicked`),n=t?JSON.parse(t):[];if(n.includes(e))return;n.push(e),localStorage.setItem(`ghost-recommendations-clicked`,JSON.stringify(n))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function Jw({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}var Yw={togglePopup:pw,openPopup:mw,closePopup:gw,switchPage:fw,openNotification:_w,closeNotification:vw,back:hw,signout:yw,signin:bw,startSigninOTCFromCustomForm:xw,verifyOTC:Sw,signup:Cw,redeemGift:ww,updateSubscription:Ow,cancelSubscription:kw,continueSubscription:Aw,applyOffer:jw,updateNewsletter:Rw,updateProfile:Gw,refreshMemberData:Vw,clearPopupNotification:Pw,editBilling:Mw,manageBilling:Nw,checkoutPlan:Tw,continueGiftSubscription:Ew,checkoutGift:Dw,updateNewsletterPreference:Iw,showPopupNotification:Fw,removeEmailFromSuppressionList:Lw,oneClickSubscribe:Kw,trackRecommendationClicked:qw,trackRecommendationSubscribed:Jw};async function Xw({action:e,data:t,state:n,api:r}){let i=Yw[e];return i&&await i({data:t,state:n,api:r})||{}}function Zw(e,t){e&&(e.innerText=t)}function Qw(e,t,n){t.classList.add(`error`),Zw(n,Kc(e,K(`There was an error sending the email, please try again`)))}async function $w({event:e,form:t,errorEl:n,siteUrl:r,submitHandler:i,doAction:a,captureException:o}){t.removeEventListener(`submit`,i),e.preventDefault(),n&&(n.innerText=``),t.classList.remove(`success`,`invalid`,`error`);let s=e.target.querySelector(`input[data-members-email]`),c=e.target.querySelector(`input[data-members-name]`),l=t?.dataset?.membersAutoredirect||`true`,u=s?.value,d=(c?.value||``).trim()||void 0,f,p=[],m=[],h=e.target.querySelectorAll(`input[data-members-label]`)||[];for(let e=0;e<h.length;++e)p.push(h[e].value);let g=e.target.querySelectorAll(`input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked`)||[];for(let e=0;e<g.length;++e)m.push({name:g[e].value});t.dataset.membersForm&&(f=t.dataset.membersForm);let _=f===`signin`&&t?.dataset?.membersOtc===`true`;t.classList.add(`loading`);let v=qu(),y={email:u,emailType:f,labels:p,name:d,autoRedirect:l===`true`};_&&(y.includeOTC=!0),v&&(y.urlHistory=v),g.length>0?y.newsletters=m:(e.target.querySelectorAll(`input[type=checkbox][data-members-newsletter]`)||[]).length>0&&(y.newsletters=[]);try{let e=await(await fx(`${r}/members/api/integrity-token/`,{method:`GET`})).text(),i=await fx(`${r}/members/api/send-magic-link/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...y,integrityToken:e})});if(i.ok){t.classList.add(`success`);let e;if(_)try{e=await i.clone().json()}catch{e=void 0}let n=e?.otc_ref;if(n&&typeof a==`function`)try{a(`startSigninOTCFromCustomForm`,{email:(u||``).trim(),otcRef:n,inboxLinks:e?.inboxLinks})}catch(e){console.error(e),o?.(e)}}else Zw(n,Kc(await Uc.fromApiResponse(i),K(`Failed to send magic link email`))),t.classList.add(`error`)}catch(e){Qw(e,t,n)}finally{t.addEventListener(`submit`,i),t.classList.remove(`loading`)}}function eT({event:e,el:t,errorEl:n,siteUrl:r,site:i,member:a,clickHandler:o}){t.removeEventListener(`click`,o),e.preventDefault();let s=t.dataset.membersPlan,c=Bl(i,s.toLowerCase()),l=t.dataset.membersSuccess,u=t.dataset.membersCancel,d,f;l&&(d=new URL(l,window.location.href).href),u&&(f=new URL(u,window.location.href).href),n&&(n.innerText=``),t.classList.add(`loading`);let p=a?{checkoutType:`upgrade`}:{},m=qu();return m&&(p.urlHistory=m),fetch(`${r}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(e){return fetch(`${r}/members/api/create-stripe-checkout-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...c,identity:e,successUrl:d,cancelUrl:f,metadata:p})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe checkout session`));return e.json()})}).then(function(e){return e.url?window.location.assign(e.url):window.Stripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId}).then(function(e){if(e.error)throw Error(e.error.message)})}).catch(function(e){console.error(e),t.addEventListener(`click`,o),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}function tT({siteUrl:e,site:t={},member:n,offers:r=[],doAction:i,captureException:a}={}){if(!e)return;e=e.replace(/\/$/,``),Array.prototype.forEach.call(document.querySelectorAll(`form[data-members-form]`),function(t){let n=t.querySelector(`[data-members-error]`);function r(o){$w({event:o,errorEl:n,form:t,siteUrl:e,submitHandler:r,doAction:i,captureException:a})}t.addEventListener(`submit`,r)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-plan]`),function(r){let i=r.querySelector(`[data-members-error]`);function a(o){eT({el:r,event:o,errorEl:i,member:n,site:t,siteUrl:e,clickHandler:a})}r.addEventListener(`click`,a)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-edit-billing]`),function(t){let n=t.querySelector(`[data-members-error]`),r=t.dataset.membersSuccess,i=t.dataset.membersCancel,a,o;r&&(a=new URL(r,window.location.href).href),i&&(o=new URL(i,window.location.href).href);function s(r){t.removeEventListener(`click`,s),r.preventDefault(),n&&(n.innerText=``),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,successUrl:a,cancelUrl:o})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe checkout session`));return e.json()})}).then(function(e){return window.Stripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)throw Error(K(e.error.message))}).catch(function(e){console.error(e),t.addEventListener(`click`,s),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}t.addEventListener(`click`,s)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-manage-billing]`),function(t){let n=t.querySelector(`[data-members-error]`),r=t.dataset.membersReturn,i;r&&(i=new URL(r,window.location.href).href);function a(r){t.removeEventListener(`click`,a),r.preventDefault(),n&&(n.innerText=``),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,returnUrl:i})}).then(function(e){if(!e.ok)throw Error(K(`Could not create Stripe billing portal session`));return e.json()})}).then(function(e){return window.location.assign(e.url)}).catch(function(e){console.error(e),t.addEventListener(`click`,a),t.classList.remove(`loading`),n&&(n.innerText=e.message),t.classList.add(`error`)})}t.addEventListener(`click`,a)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-signout]`),function(t){function n(r){t.removeEventListener(`click`,n),r.preventDefault(),t.classList.remove(`error`),t.classList.add(`loading`),fetch(`${e}/members/api/session`,{method:`DELETE`}).then(function(r){r.ok?window.location.replace(e):(t.addEventListener(`click`,n),t.classList.remove(`loading`),t.classList.add(`error`))})}t.addEventListener(`click`,n)});let o=(r||[]).some(e=>e.redemption_type===`retention`);Array.prototype.forEach.call(document.querySelectorAll(`[data-members-cancel-subscription]`),function(t){let n=t.parentElement.querySelector(`[data-members-error]`);function r(a){a.preventDefault();let s=t.dataset.membersCancelSubscription;if(o){i(`openPopup`,{page:`accountPlan`,pageData:{subscriptionId:s,action:`cancel`}});return}return t.removeEventListener(`click`,r),t.classList.remove(`error`),t.classList.add(`loading`),n&&(n.innerText=``),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/subscriptions/${s}/`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,smart_cancel:!0})})}).then(function(e){e.ok?window.location.reload():(t.addEventListener(`click`,r),t.classList.remove(`loading`),t.classList.add(`error`),n&&(n.innerText=K(`There was an error cancelling your subscription, please try again.`)))})}t.addEventListener(`click`,r)}),Array.prototype.forEach.call(document.querySelectorAll(`[data-members-continue-subscription]`),function(t){let n=t.parentElement.querySelector(`[data-members-error]`);function r(i){t.removeEventListener(`click`,r),i.preventDefault(),t.classList.remove(`error`),t.classList.add(`loading`);let a=t.dataset.membersContinueSubscription;return n&&(n.innerText=``),fetch(`${e}/members/api/session`,{credentials:`same-origin`}).then(function(e){return e.ok?e.text():null}).then(function(t){return fetch(`${e}/members/api/subscriptions/${a}/`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({identity:t,cancel_at_period_end:!1})})}).then(function(e){e.ok?window.location.reload():(t.addEventListener(`click`,r),t.classList.remove(`loading`),t.classList.add(`error`),n&&(n.innerText=K(`There was an error continuing your subscription, please try again.`)))})}t.addEventListener(`click`,r)})}var nT=e=>{try{return decodeURIComponent(e)}catch{return null}},rT=e=>{if(e===`true`)return!0;if(e===`false`)return!1},iT={staleGiftRedemptionRequest:!0},aT={showPopup:!0,site:ow,member:cw.free,page:`accountEmail`,...lw(),pageData:sw};function oT({site:e,children:t}){let{portal_sentry:n}=e||{};return n&&n.dsn?(0,q.jsx)(Eo,{children:t}):(0,q.jsx)(q.Fragment,{children:t})}var sT=class extends _.Component{constructor(e){super(e),this.setupCustomTriggerButton(),this.state={site:null,member:null,customFields:[],offers:[],page:`loading`,showPopup:!1,action:`init:running`,actionErrorMessage:null,fieldErrors:{},initStatus:`running`,lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){let e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,t){if(t.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`&&t.initStatus!==this.state.initStatus){let{siteUrl:e}=this.props,t=this.getContextFromState();this.sendPortalReadyEvent(),tT({siteUrl:e,site:t.site,member:t.member,offers:t.offers,doAction:t.doAction,captureException:rr})}}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(){let e=document.createElement(`div`);e.style.visibility=`hidden`,e.style.overflow=`scroll`,document.body.appendChild(e),document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t}setupCustomTriggerButton(){this.clickHandler=async e=>{e.preventDefault();let t=e.currentTarget,n=t&&t.dataset.portal,r=this.getPageFromLinkPath(n,this.state.site);if(!r)return;let{page:i,pageQuery:a,pageData:o}=r;if(this.state.initStatus===`success`){if(i===`gift`&&!Kl({site:this.state.site})){this.invalidateGiftRedemptionRequest(),vl();return}if(i===`giftRedemption`&&o?.token){let e=this.startGiftRedemptionRequest(o.token),t=await this.fetchGiftRedemptionData({token:o.token});if(!this.isCurrentGiftRedemptionRequest(e))return;this.setState(t);return}this.invalidateGiftRedemptionRequest(),a&&a!==`free`?this.handleSignupQuery({site:this.state.site,pageQuery:a}):this.dispatchAction(`openPopup`,{page:i,pageQuery:a,pageData:o})}},this.customTriggerButtons=document.querySelectorAll(`[data-portal]`)||[],this.customTriggerButtons.forEach(e=>{e.classList.add(`gh-portal-close`),e.removeEventListener(`click`,this.clickHandler),e.addEventListener(`click`,this.clickHandler)})}handleCustomTriggerClassUpdate(){let e=`gh-portal-open`,t=`gh-portal-close`;this.customTriggerButtons?.forEach(n=>{let r=this.state.showPopup?e:t,i=this.state.showPopup?t:e;n.classList.add(r),n.classList.remove(i)})}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:t}){return this._redemptionRequestId===e&&this.currentRedemptionToken===t}async initSetup(){try{let{site:e,member:t,offers:n,customFields:r,page:i,showPopup:a,popupNotification:o,notification:s,notificationSequence:c,lastPage:l,pageQuery:u,pageData:d}=await this.fetchData(),f=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||`en`;Hc.changeLanguage(f);let p={site:e,member:t,offers:n,customFields:r,page:i,lastPage:l,pageQuery:u,showPopup:a,pageData:d,popupNotification:o,notification:s,notificationSequence:c,dir:Hc.dir()||`ltr`,action:`init:success`,initStatus:`success`,locale:f};if(this.setState(p,()=>{this.handleSignupQuery({site:e,pageQuery:u,member:t})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener(`hashchange`,this.hashHandler,!1),!t){let e=document.querySelectorAll(`[data-lexical-signup-form]`);e.length>0&&e.forEach(e=>{e.style.display=``})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error(`[Portal] Failed to initialize:`,e),this.setState({action:`init:failed`,initStatus:`failed`})}}async fetchData(){let{site:e,member:t,offers:n}=await this.fetchApiData(),{site:r,...i}=this.fetchDevData(),[a,o]=await Promise.all([this.fetchLinkData(e,t),Up({api:this.GhostApi,site:e,member:t})]),{site:s,...c}=a?.staleGiftRedemptionRequest?{}:a,{site:l,...u}=this.fetchPreviewData(),{site:d,...f}=this.fetchNotificationData();return{member:t,offers:n,customFields:o,page:``,site:{...e,...s,...l,...d,...r,plans:{...(r||{}).plans,...(e||{}).plans,...(l||{}).plans}},...i,...c,...f,...u}}fetchDevData(){return nd([`dev`])&&!this.state.customSiteUrl?aT:nd([`test`])?{showPopup:this.props.showPopup===void 0?!0:this.props.showPopup}:{}}fetchOfferQueryStrData(e=``){let t=new URLSearchParams(e),n={};for(let e of t.entries()){let t=e[0],r=decodeURIComponent(e[1]);t===`name`?n.name=r||``:t===`code`?n.code=r||``:t===`display_title`?n.display_title=r||``:t===`display_description`?n.display_description=r||``:t===`type`?n.type=r||``:t===`cadence`?n.cadence=r||``:t===`duration`?n.duration=r||``:t===`duration_in_months`&&!isNaN(Number(r))?n.duration_in_months=Number(r):t===`amount`&&!isNaN(Number(r))?n.amount=Number(r):t===`currency`?n.currency=r||``:t===`status`?n.status=r||``:t===`tier_id`?n.tier={id:r||sw.tier.id}:t===`redemption_type`&&(n.redemption_type=r||`signup`)}if(n.redemption_type===`retention`){let e=cw.preview?.subscriptions?.[0]?.id;return{page:`accountPlan`,offers:[n],pageData:{action:`cancel`,subscriptionId:e}}}return{page:`offer`,pageData:n}}fetchQueryStrData(e=``){let t=new URLSearchParams(e),n={site:{plans:{}}},r=[],i,a=null,o,s,c;for(let e of t.entries()){let t=e[0],l=decodeURIComponent(e[1]);if(t===`button`)n.site.portal_button=JSON.parse(l);else if(t===`name`)n.site.portal_name=JSON.parse(l);else if(t===`signupGiftPromotion`){let e=rT(l);e!==void 0&&(n.site.portal_signup_gift_promotion=e)}else if(t===`accountGiftPromotion`){let e=rT(l);e!==void 0&&(n.site.portal_account_gift_promotion=e)}else if(t===`isFree`&&JSON.parse(l))r.push(`free`);else if(t===`isMonthly`&&JSON.parse(l))r.push(`monthly`);else if(t===`isYearly`&&JSON.parse(l))r.push(`yearly`);else if(t===`portalPrices`)i=l?l.split(`,`):[];else if(t===`portalProducts`)a=l?l.split(`,`):[];else if(t===`page`&&l)n.page=l;else if(t===`accentColor`&&(l===``||l))n.site.accent_color=l;else if(t===`buttonIcon`&&l)n.site.portal_button_icon=l;else if(t===`signupButtonText`)n.site.portal_button_signup_text=l||``;else if(t===`signupTermsHtml`)n.site.portal_signup_terms_html=l||``;else if(t===`signupCheckboxRequired`)n.site.portal_signup_checkbox_required=JSON.parse(l);else if(t===`buttonStyle`&&l)n.site.portal_button_style=l;else if(t===`monthlyPrice`&&!isNaN(Number(l)))n.site.plans.monthly=Number(l),o=Number(l);else if(t===`yearlyPrice`&&!isNaN(Number(l)))n.site.plans.yearly=Number(l),s=Number(l);else if(t===`currency`&&l){let e=l.toUpperCase();n.site.plans.currency=e,n.site.plans.currency_symbol=ju(e),c=e}else t===`disableBackground`?n.site.disableBackground=JSON.parse(l):t===`previewTheme`?n.site.preview_theme=l:t===`membersSignupAccess`&&l?n.site.members_signup_access=l:t===`portalDefaultPlan`&&l?n.site.portal_default_plan=l:t===`transistorPortalSettings`&&l&&(n.site.transistor_portal_settings=JSON.parse(l))}return n.site.portal_plans=r,n.site.portal_products=a,i?n.site.portal_plans=i:o&&s&&c&&(n.site.prices=[{id:`monthly`,stripe_price_id:`dummy_stripe_monthly`,stripe_product_id:`dummy_stripe_product`,active:1,nickname:`Monthly`,currency:c,amount:o,type:`recurring`,interval:`month`},{id:`yearly`,stripe_price_id:`dummy_stripe_yearly`,stripe_product_id:`dummy_stripe_product`,active:1,nickname:`Yearly`,currency:c,amount:s,type:`recurring`,interval:`year`}]),n}fetchNotificationData(){let{type:e,status:t,duration:n,autoHide:r,closeable:i}=nf({billingOnly:!0})||{};return[`stripe:billing-update`].includes(e)?t===`success`?{showPopup:!0,popupNotification:Y({type:e,status:t,duration:n,closeable:i,autoHide:r,state:this.state,message:t===`success`?`Billing info updated successfully`:``})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{return{showPopup:!0,notification:null,page:`giftRedemption`,pageData:{token:e,gift:(await this.GhostApi.gift.fetchRedemptionData({token:e}))?.gifts?.[0]||null}}}catch(e){vl();let t=Iu({type:`giftRedemption:failed`,status:`error`,autoHide:!1,closeable:!0,state:this.state,message:Yd(e)});return{showPopup:!1,pageData:null,notification:t,notificationSequence:t.count}}}async fetchLinkData(e,t){this.invalidateGiftRedemptionRequest();let n=new URLSearchParams(window.location.search);if(n.get(`stripe`)===`gift-purchase-success`){let e=n.get(`gift_token`),t=n.get(`gift_tier`),r=n.get(`gift_cadence`),i=Number(n.get(`gift_duration`)),a=n.get(`gift_delivery`),o=n.get(`gift_delivery_date`),s=/^\d{4}-\d{2}-\d{2}$/.test(o||``)?o:null,c=Number(n.get(`gift_scheduled_at`)),l=Number.isFinite(c)&&c>0?c:null;if(tf([`stripe`,`gift_token`,`gift_tier`,`gift_cadence`,`gift_duration`,`gift_delivery`,`gift_delivery_date`,`gift_scheduled_at`]),e)return QS(),{showPopup:!0,page:`giftSuccess`,pageData:{token:e,tierId:t,cadence:r,duration:Cf.includes(i)?i:null,deliveryMethod:a===`email`?`email`:`link`,deliveryDate:s,scheduledAt:l}}}if(n.get(`action`)===`unsubscribe`)return n.get(`key`)&&n.get(`uuid`)?{showPopup:!0,page:`unsubscribe`,pageData:{uuid:n.get(`uuid`),key:n.get(`key`),newsletterUuid:n.get(`newsletter`),comments:n.get(`comments`),updatesAndAnnouncements:n.get(`updatesandannouncements`)}}:{showPopup:!0,page:`accountEmail`,pageData:{newsletterUuid:n.get(`newsletter`),action:`unsubscribe`,redirect:e.url+`#/portal/account/newsletters`}};if(Gl({site:e})&&n.get(`action`)===`signup`&&n.get(`success`)===`true`)return{showPopup:!0,page:`recommendations`,pageData:{signup:!0}};let[r,i]=window.location.hash.substr(1).split(`?`),a=new URLSearchParams(i??``),o=/^(?:(\w+?))?\/monthly$/,s=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,l=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,u=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,d=/^\/share\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(r&&f.test(r)){let[,n,i]=r.match(f),o=parseInt(i);if(o===1||o===0)return t||a.get(`uuid`)&&a.get(`key`)?{showPopup:!0,page:`feedback`,pageData:{uuid:a.get(`uuid`),key:a.get(`key`),postId:n,score:o}}:{showPopup:!0,page:`signin`,pageData:{redirect:e.url+`#/feedback/${n}/${o}/`}}}if(r&&l.test(r)){let[,t]=r.match(l),n=nT(t);if(!n)return{};xf(e.url);let i=this.startGiftRedemptionRequest(n),a=await this.fetchGiftRedemptionData({token:n});return this.isCurrentGiftRedemptionRequest(i)?a:iT}if(r&&d.test(r))return{showPopup:!0,page:`share`};if(r&&u.test(r)){let[,n]=r.match(u),{page:i,pageQuery:l,pageData:d}=this.getPageFromLinkPath(n,e)||{};if(!t&&i&&FC({page:i}))return{showPopup:!0,page:`signin`,pageData:{redirect:e.url+`#/portal/${n}/`}};if(i===`gift`&&!Kl({site:e}))return vl(),{};i===`gift`&&xf(e.url);let f=[`accountPlan`,`accountProfile`].includes(i)?`accountHome`:null,p=!([`monthly`,`yearly`].includes(l)||o.test(l)||s.test(l)||c.test(l)),m=a.get(`redirect`),h=i===`signin`&&m?{...d||{},redirect:m}:d;return{showPopup:p,...i?{page:i}:{},...l?{pageQuery:l}:{},...h?{pageData:h}:{},...f?{lastPage:f}:{}}}return{}}fetchPreviewData(){let[,e]=window.location.hash.substr(1).split(`?`);if(nd([`preview`])){let t={};try{t=nd([`offerPreview`])?this.fetchOfferQueryStrData(e):this.fetchQueryStrData(e)}catch(e){return rr(e),{}}return{...t,showPopup:!0}}return{}}getColorOverride(){let e=document.querySelector(`script[data-ghost]`);return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){let{siteUrl:e,customSiteUrl:t,apiUrl:n,apiKey:r}=this.props;try{this.GhostApi=this.props.api||px({siteUrl:e,apiUrl:n,apiKey:r});let{site:t,member:i,offers:a}=await this.GhostApi.init(),o=this.getColorOverride();return o&&(t.accent_color=o),this.setupFirstPromoter({site:t,member:i}),this.setupSentry({site:t}),{site:t,member:i,offers:a}}catch(e){if(nd([`dev`,`test`],{customSiteUrl:t}))return{};throw e}}setupSentry({site:e}){if(nd([`test`]))return null;let{portal_sentry:t,portal_version:n,version:r}=e,i=`portal@2.72.12|ghost@${r}`;t&&t.dsn&&vo({dsn:t.dsn,environment:t.env||`development`,release:i,beforeSend:e=>Sl({event:e})?e:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:t}){if(nd([`test`]))return null;let n=Eu({site:e}),r=Au({site:e});if(r=r?.replace(/^(\S*\.)?(\S*\.\S*)$/i,`.$2`),n&&r){let e=document.createElement(`script`);e.type=`text/javascript`,e.async=!0,e.src=`https://cdn.firstpromoter.com/fprom.js`,e.onload=e.onreadystatechange=function(){let e=this.readyState;if(!e||e===`complete`||e===`loaded`)try{if(window.$FPROM.init(n,r),Yu({member:t})){let e=t.email,n=t.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:e,uid:n});else{let t=window._fprom||[];window._fprom=t,t.push([`event`,`signup`]),t.push([`email`,e]),t.push([`uid`,n])}}}catch{}};let i=document.getElementsByTagName(`script`)[0];i.parentNode.insertBefore(e,i)}}async dispatchAction(e,t){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{let n=await Xw({action:e,data:t,state:this.state,api:this.GhostApi});return this.setState(n),n&&n.action&&!n.action.includes(`:failed`)&&(this.timeoutId=setTimeout(()=>{this.setState({action:``})},2e3)),n}catch(n){if(console.error(`[Portal] Failed to dispatch action: ${e}`,n),t&&t.throwErrors)throw n;let r=Y({type:`${e}:failed`,autoHide:!0,closeable:!0,status:`error`,state:this.state,meta:{error:n}});this.setState({action:`${e}:failed`,actionErrorMessage:Kc(n,K(`An unexpected error occured. Please try again or <a>contact support</a> if the error persists.`)),popupNotification:r})}}async updateStateForPreviewLinks(){let{site:e,...t}=this.fetchPreviewData(),n=await this.fetchLinkData(this.state.site,this.state.member);if(n?.staleGiftRedemptionRequest)return;let{site:r,...i}=n,a=this.state.page===`gift`&&i.page!==`gift`;a&&QS();let o=a&&!i.page,s={site:{...this.state.site,...r||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(r||{}).plans,...(e||{}).plans}},...i,...t,...o?{showPopup:!1,lastPage:null}:{}};this.handleSignupQuery({site:s.site,pageQuery:s.pageQuery}),this.setState(s)}async handleOfferQuery({site:e,offerId:t,member:n=this.state.member}){if(vl(),!(!Tl({member:n})||wl({member:n}))){let e=Iu({type:`offer:failed`,status:`error`,autoHide:!1,closeable:!0,state:this.state,message:K(`You already have an active subscription.`)});await this.dispatchAction(`closePopup`),this.setState({notification:e,notificationSequence:e.count});return}try{let n=(await this.GhostApi.site.offer({offerId:t}))?.offers[0];if(!n||!n.tier||Vu({offer:n})||!Hu({site:e,offer:n}))return;this.dispatchAction(`openPopup`,{page:`offer`,pageData:n})}catch{}}handleSignupQuery({site:e,pageQuery:t,member:n}){let r=/^offers\/(\w+?)\/?$/,i=t;if(r.test(t||``)){let[,i]=t.match(r);this.handleOfferQuery({site:e,offerId:i,member:n});return}Ru({site:e,pageQuery:t})&&(i=Ru({site:e,pageQuery:t}));let a=Vl({site:e,priceId:i});if(t&&t!==`free`){vl();let t=a?.id||i;t!==`free`&&this.dispatchAction(`openPopup`,{page:`loading`});let{tierId:n,cadence:r}=bu({site:e,priceId:t});this.dispatchAction(`signup`,{plan:t,tierId:n,cadence:r})}}getPageFromLinkPath(e){let t=/^signup\/?(?:\/(\w+?))?\/?$/,n=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,r=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,i=/^offers\/(\w+?)\/?$/,a=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e===``)return{page:`default`};if(a.test(e)){let[,t]=e.match(a),n=nT(t);return n?{page:`giftRedemption`,pageData:{token:n}}:null}else if(i.test(e))return{pageQuery:e};else if(e===`signup`)return{page:`signup`};else if(n.test(e)){let[,t]=e.match(n);return{page:`signup`,pageQuery:`${t}/monthly`}}else if(r.test(e)){let[,t]=e.match(r);return{page:`signup`,pageQuery:`${t}/yearly`}}else if(t.test(e)){let[,n]=e.match(t);return{page:`signup`,pageQuery:n}}else if(e===`signup/free`)return{page:`signup`,pageQuery:`free`};else if(e===`signup/monthly`)return{page:`signup`,pageQuery:`monthly`};else if(e===`signup/yearly`)return{page:`signup`,pageQuery:`yearly`};else if(e===`signin`)return{page:`signin`};else if(e===`account`)return{page:`accountHome`};else if(e===`account/plans`)return{page:`accountPlan`};else if(e===`account/profile`)return{page:`accountProfile`};else if(e===`account/newsletters`)return{page:`accountEmail`};else if(e===`support`)return{page:`support`};else if(e===`support/success`)return{page:`supportSuccess`};else if(e===`support/error`)return{page:`supportError`};else if(e===`recommendations`)return{page:`recommendations`,pageData:{signup:!1}};else if(e===`gift`)return{page:`gift`,pageData:{giftStep:`plan`}};else if(e===`gift/delivery`)return{page:`gift`,pageData:{giftStep:`delivery`}};else if(e===`share`)return{page:`share`};else if(e===`account/newsletters/help`)return{page:`emailReceivingFAQ`,pageData:{direct:!0}};else if(e===`account/newsletters/disabled`)return{page:`emailSuppressionFAQ`,pageData:{direct:!0}};return{page:`default`}}getAccentColor(){let{accent_color:e}=this.state.site||{};return mb(e)}getRetentionPreviewMember({site:e,offers:t}){let n=(t||[]).find(e=>Vu({offer:e})),r=n?.tier?.id,i=r?lu({site:e,productId:r}):null,a=i?n.cadence===`year`?i.yearlyPrice:i.monthlyPrice:null,o=cw.preview,s=o?.subscriptions?.[0];return!s||!i||!a?o:{...o,subscriptions:[{...s,plan:{...s.plan,amount:a.amount,interval:a.interval,currency:a.currency.toUpperCase()},price:{...s.price,price_id:a.id,amount:a.amount,interval:a.interval,currency:a.currency,product:{...s.price?.product,product_id:i.id}},tier:{id:i.id,name:i.name}}]}}getContextPage({site:e,page:t,member:n}){if(!t||t==="default"){let r=Ul({site:e})||!Wl({site:e})?`signin`:`signup`;t=n?`accountHome`:r}return PC({page:t})}getContextMember({site:e,page:t,member:n,offers:r,pageData:i,customSiteUrl:a}){return nd([`dev`,`preview`],{customSiteUrl:a})?FC({page:t})||IC({page:t})?nd([`dev`],{customSiteUrl:a})?n||cw.free:nd([`preview`])?t===`accountPlan`&&i?.action===`cancel`?this.getRetentionPreviewMember({site:e,offers:r}):cw.preview:cw.paid:null:n}getContextFromState(){let{site:e,member:t,offers:n,action:r,actionErrorMessage:i,page:a,lastPage:o,showPopup:s,pageQuery:c,pageData:l,popupNotification:u,notification:d,customSiteUrl:f,dir:p,scrollbarWidth:m,otcRef:h,inboxLinks:g,customFields:_,fieldErrors:v}=this.state,y=this.getContextPage({site:e,page:a,member:t}),b=this.getContextMember({site:e,page:y,member:t,offers:n,pageData:l,customSiteUrl:f});return{api:this.GhostApi,site:e,offers:n,action:r,actionErrorMessage:i,brandColor:this.getAccentColor(),page:y,pageQuery:c,pageData:l,member:b,customFields:_,fieldErrors:v,lastPage:o,showPopup:s,popupNotification:u,notification:d,customSiteUrl:f,dir:p,scrollbarWidth:m,otcRef:h,inboxLinks:g,doAction:(e,t)=>this.dispatchAction(e,t)}}getRecommendationButtons(){return document.querySelectorAll(`[data-recommendation]`)||[]}setupRecommendationButtons(){let e=e=>{let t=e.currentTarget.dataset.recommendation;t?this.dispatchAction(`trackRecommendationClicked`,{recommendationId:t}).catch(console.error):console.warn(`[Portal] Invalid usage of data-recommendation attribute`)},t=this.getRecommendationButtons();for(let n of t)n.addEventListener(`click`,e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll(`a[href*="#/portal"], a[href*="#/share"]`).forEach(uw)}render(){return this.state.initStatus===`success`?(0,q.jsx)(oT,{site:this.state.site,children:(0,q.jsxs)(J.Provider,{value:this.getContextFromState(),children:[(0,q.jsx)(HC,{}),(0,q.jsx)(od,{}),(0,q.jsx)(sf,{})]})}):null}},cT=`ghost-portal-root`;function lT(){let e=document.createElement(`div`);e.id=cT,e.setAttribute(`data-testid`,`portal-root`),document.body.appendChild(e)}function uT(){let e=document.querySelector(`script[data-ghost]`);if(e){let t=e.dataset.i18n===`true`;return{siteUrl:e.dataset.ghost,apiKey:e.dataset.key,apiUrl:e.dataset.api,siteI18nEnabled:t,locale:e.dataset.locale}}return{}}function dT(){let e=new URL(window.location.href);e.searchParams.get(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState({},document.title,e.href))}function fT(){let[,e]=window.location.hash.substring(1).split(`?`);new URLSearchParams(e).get(`previewTheme`)===`dark`&&(document.documentElement.dataset.portalPreviewTheme=`dark`)}function pT(){let{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:r,locale:i}=uT(),a=e||window.location.origin;fT(),lT(),dT(),v.render((0,q.jsx)(_.default.StrictMode,{children:(0,q.jsx)(sT,{siteUrl:a,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:r,locale:i})}),document.getElementById(cT))}pT()});
5694
5694
  //# sourceMappingURL=portal.min.js.map