@tryghost/portal 2.69.68 → 2.69.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/umd/portal.min.js +1 -1
package/package.json
CHANGED
package/umd/portal.min.js
CHANGED
|
@@ -4567,5 +4567,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
|
|
|
4567
4567
|
}
|
|
4568
4568
|
`;function P1({site:t}){return Cc+E1+iC+yC+IC+oC()+aC+_S+nC+Np+$E+wE+HE()+Uc+BE+j1+T1+JE+n1+a1+i1+r1+l1+FE+f1+u1+y1+x1+S1}class z1 extends Pe.Component{static contextType=Q;constructor(e){super(e),this.state={email:"",token:void 0}}componentDidMount(){const{member:e}=this.context;e&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(e){e.preventDefault(),this.doSignin()}doSignin(){this.setState(e=>({errors:xi({fields:this.getInputFields({state:e})})}),async()=>{const{email:e,phonenumber:n,errors:i,token:r}=this.state,{redirect:l}=this.context.pageData??{};i&&Object.values(i).filter(m=>!!m).length>0||this.context.doAction("signin",{email:e,phonenumber:n,redirect:l,token:r})})}handleInputChange(e,n){const i=n.name;this.setState({[i]:e.target.value})}onKeyDown(e){e.keyCode===13&&this.handleSignin(e)}getInputFields({state:e}){const n=e.errors||{};return[{type:"email",value:e.email,placeholder:y("jamie@example.com"),label:y("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:e.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:e}=this.context;let n=!1;const i=e==="signin:running";let r=y(i?"Sending login link...":"Continue");const l=!!i;return e==="signin:failed"&&(r=y("Retry"),n=!0),c.jsx(Be,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:u=>this.handleSignin(u),disabled:l,brandColor:this.context.brandColor,label:r,isRunning:i})}renderSignupMessage(){const{brandColor:e}=this.context;return c.jsxs("div",{className:"gh-portal-signup-message",children:[c.jsx("div",{children:y("Don't have an account?")}),c.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:c.jsx("span",{children:y("Sign up")})})]})}renderForm(){const{site:e}=this.context,n=ss({site:e})&&Pn({site:e});return qn({site:e})?c.jsxs("section",{children:[c.jsx("div",{className:"gh-portal-section",children:c.jsx(Lo,{fields:this.getInputFields({state:this.state}),onChange:(i,r)=>this.handleInputChange(i,r),onKeyDown:(i,r)=>this.onKeyDown(i,r)})}),c.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):c.jsx("section",{children:c.jsx("div",{className:"gh-portal-section",children:c.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:y("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:e}=this.context,n=e.icon;return n?c.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):qn({site:e})?null:c.jsx(hh,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:e}=this.context,n=e.title;return qn({site:e})?c.jsx("h1",{className:"gh-portal-main-title",children:y("Sign in")}):c.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return c.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return c.jsxs(c.Fragment,{children:[c.jsx(We,{}),c.jsx("div",{className:"gh-portal-logged-out-form-container",children:c.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}}const N1=({handleSignout:t,supportAddress:e=""})=>{const n=`mailto:${e}`;return c.jsxs("footer",{className:"gh-portal-account-footer",children:[c.jsx("ul",{className:"gh-portal-account-footermenu",children:c.jsx("li",{children:c.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:i=>t(i),children:y("Sign out")})})}),c.jsx("div",{className:"gh-portal-account-footerright",children:c.jsx("ul",{className:"gh-portal-account-footermenu",children:c.jsx("li",{children:c.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,target:"_blank",rel:"noopener noreferrer",children:y("Contact support")})})})})]})},I1=()=>{const{member:t,brandColor:e}=C.useContext(Q),n=t.avatar_image;return c.jsxs("header",{className:"gh-portal-account-header",children:[c.jsx(Sc,{gravatar:n,style:{userIcon:{color:e,width:"56px",height:"56px",padding:"2px"}}}),c.jsx("h2",{className:"gh-portal-main-title",children:y("Your account")})]})},M1=()=>{const{site:t,action:e,brandColor:n,doAction:i}=C.useContext(Q);if(!ss({site:t})||!Pn({site:t}))return null;const r=["checkoutPlan:running"].includes(e),l=()=>{i("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return c.jsx(Be,{dataTestId:"view-plans",isRunning:r,label:y("View plans"),onClick:()=>l(),brandColor:n,style:{width:"100%"}})},O1=()=>{const{member:t,site:e}=C.useContext(Q),{paid_members_enabled:n}=e;if(!n||hi({site:e}))return null;const i=jt({member:t}),r=Hn({member:t});if(r&&!i)return null;if(i){const l=i?.current_period_end,u=os({member:t});if(mn({member:t}))return u?c.jsx("div",{className:"gh-portal-section",style:{marginBottom:24},children:c.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:y("Your gift subscription will expire on {expiryDate}",{expiryDate:u})})}):null;if(r&&u)return c.jsx("div",{className:"gh-portal-section",children:c.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:y("Your subscription will expire on {expiryDate}",{expiryDate:u})})});if(i?.cancel_at_period_end||r)return null;if(Pc({sub:i})){const m=Gn(i.trial_end_at);return c.jsx("div",{className:"gh-portal-section",children:c.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:y("Your subscription will start on {subscriptionStart}",{subscriptionStart:m})})})}return c.jsx("div",{className:"gh-portal-section",children:c.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:y("Your subscription will renew on {renewalDate}",{renewalDate:Gn(l)})})})}return c.jsxs("div",{className:"gh-portal-section",children:[c.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:y("You currently have a free membership, upgrade to a paid subscription for full access.")}),c.jsx(M1,{})]})},A1=()=>{const{member:t,doAction:e,action:n,brandColor:i}=C.useContext(Q),r=jt({member:t});if(!r||!r.cancel_at_period_end)return null;const l=y("Resume subscription"),u=["continueSubscription:running"].includes(n),m=!!u,p=Gn(r.current_period_end);return c.jsx("div",{className:"gh-portal-cancelcontinue-container",children:c.jsxs("div",{className:"gh-portal-cancel-banner",children:[c.jsx("p",{children:c.jsx(tt,{string:y("Your subscription has been canceled and will expire on {expiryDate}."),mapping:{expiryDate:c.jsx("strong",{children:p})}})}),c.jsx(Be,{onClick:()=>{e("continueSubscription",{subscriptionId:r.id})},isRunning:u,disabled:m,isPrimary:!0,brandColor:i,label:l,style:{width:"100%"}})]})})},D1=()=>{const{member:t,site:e,doAction:n,action:i,brandColor:r}=C.useContext(Q);if(!(mn({member:t})&&!Ec({member:t,site:e})&&fi({site:e}))||!os({member:t}))return null;const m=i==="continueGiftSubscription:running";return c.jsx("div",{className:"gh-portal-cancelcontinue-container",children:c.jsxs("div",{className:"gh-portal-cancel-banner",children:[c.jsx("p",{style:{maxWidth:"none",margin:"0 0 16px",textAlign:"center",textWrap:"pretty"},children:y("Continue with a paid subscription anytime. Your remaining gift period will be added as a free trial.")}),c.jsx(Be,{onClick:()=>n("continueGiftSubscription"),isRunning:m,disabled:m,isPrimary:!0,brandColor:r,label:y("Continue subscription"),style:{width:"100%"}})]})})},Y1=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...t},C.createElement("rect",{x:3,y:8,width:18,height:4,rx:1}),C.createElement("path",{d:"M12 8v13"}),C.createElement("path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}),C.createElement("path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5C9 3 12 8 12 8"}),C.createElement("path",{d:"M16.5 8a2.5 2.5 0 0 0 0-5C15 3 12 8 12 8"})),F1=t=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),C.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),C.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),R1=()=>{const{member:t,site:e,doAction:n}=C.useContext(Q),i=()=>{const x=jt({member:t});n("manageBilling",{subscriptionId:x.id})},r=()=>{fi({site:e})&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},l=({price:x,isComplimentary:j,subscription:T})=>{const{next_payment:z}=T||{};let D="";if(x){const{amount:K=0,currency:_,interval:le}=x;D=`${Intl.NumberFormat("en",{currency:_,style:"currency"}).format(K/100)}/${y(le)}`}const R=os({member:t});if(mn({member:t})&&R)return c.jsxs("p",{className:"gh-portal-account-discountcontainer",children:[c.jsx(Y1,{className:"gh-portal-account-tagicon"}),c.jsx("span",{children:y("Gift subscription")}),c.jsx("span",{className:"gh-portal-account-expiry-separator",children:"-"}),c.jsx("span",{className:"gh-portal-account-expiry",children:y("Expires {expiryDate}",{expiryDate:R})})]});j&&(R?D=`${y("Complimentary")} - ${y("Expires {expiryDate}",{expiryDate:R})}`:D=y("Complimentary"));let G="";if(Pc({sub:T}))return G="gh-portal-account-old-price",c.jsxs(c.Fragment,{children:[c.jsx("p",{className:G,children:D}),c.jsx(L1,{subscription:T})]});let Y=$1({nextPayment:z});Y&&(G="gh-portal-account-old-price");const V=()=>Y?c.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[c.jsx(F1,{className:"gh-portal-account-tagicon"}),c.jsx("span",{children:Y})]}):null;return c.jsxs(c.Fragment,{children:[c.jsx("p",{className:G,children:D}),c.jsx(V,{})]})},u=({isPaid:x})=>{const j=mn({member:t});if(j&&!fi({site:e}))return null;const T=j&&!Ec({member:t,site:e});return hi({site:e})&&(!x||j&&!T)?null:T?c.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:z=>{z.stopPropagation(),n("continueGiftSubscription")},"data-test-button":"continue-gift-subscription",children:y("Continue")}):c.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:z=>{z.stopPropagation(),r()},"data-test-button":"change-plan",children:y("Change")})},m=({defaultCardLast4:x})=>{if(x){const j=`**** **** **** ${x}`;return c.jsx("p",{children:j})}return null},p=({defaultCardLast4:x})=>{const{action:j}=C.useContext(Q),T=j==="manageBilling:running"?c.jsx(ki,{className:"gh-portal-billing-button-loader"}):y("Update");return c.jsxs("section",{className:"gh-portal-list-clickable",role:"button",tabIndex:0,onClick:i,onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),i())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:y("Billing info & receipts")}),c.jsx(m,{defaultCardLast4:x})]}),c.jsx("span",{className:"gh-portal-list-action","data-test-button":"manage-billing","aria-hidden":"true",children:T})]})},f=jt({member:t}),g=Hn({member:t}),v=mn({member:t}),k=dn({member:t});if(f||g){const{price:x,default_payment_card_last4:j}=f||{};let T=y("Plan");return jc({member:t})&&(T=jc({member:t})),c.jsxs(c.Fragment,{children:[c.jsxs("section",{children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsxs("h3",{children:[T,f?.cancel_at_period_end&&c.jsx("span",{className:"gh-portal-canceled-badge",children:y("Canceled")})]}),c.jsx(l,{price:x,isComplimentary:g,subscription:f})]}),c.jsx(u,{isPaid:k})]}),!g&&!v&&c.jsx(p,{defaultCardLast4:j})]})}return null};function L1({subscription:t}){if(Pc({sub:t})){const e=Gn(t.trial_end_at);return c.jsx("p",{className:"gh-portal-account-discountcontainer",children:c.jsx("div",{children:c.jsx("span",{children:y("Free Trial – Ends {trialEnd}",{trialEnd:e})})})})}return null}function $1({nextPayment:t}){if(!t)return"";const e=t.discount;if(!e)return"";const n=e.end?y("Ends {offerEndDate}",{offerEndDate:Gn(e.end)}):y("Forever");return`${`${Intl.NumberFormat("en",{currency:t.currency,style:"currency"}).format(t.amount/100)}/${y(t.interval)}`}${n?` — ${n}`:""}`}function U1(){const{member:t,site:e,doAction:n}=C.useContext(Q);let{newsletters:i}=t;const r=!!i?.length;let l=y(r?"Subscribed":"Unsubscribed");const u=()=>{const m=Ia({site:e}),p=t?.newsletters?.length?[]:m;n("updateNewsletterPreference",{newsletters:p})};return c.jsxs("section",{className:"gh-portal-list-clickable",role:"button",tabIndex:0,"aria-pressed":r,onClick:u,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),u())},children:[c.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[c.jsx("h3",{children:y("Email newsletter")}),c.jsxs("p",{children:[l," ",zc({member:t})&&r&&c.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:m=>{m.stopPropagation(),n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"})},children:y("Not receiving emails?")})]})]}),c.jsx("div",{onClick:m=>m.stopPropagation(),children:c.jsx(Fo,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",label:y("Email newsletter"),onToggle:m=>{u()},checked:r,presentational:!0})})]})}const Wh=t=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...t},C.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),C.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function B1(){return c.jsxs("p",{className:"gh-portal-email-notice",children:[c.jsx(Wh,{className:"gh-portal-email-notice-icon"}),c.jsx("span",{className:"gh-mobile-only",children:y("You're not receiving emails")}),c.jsx("span",{className:"gh-desktop-only",children:y("You're currently not receiving emails")})]})}function W1(){const{doAction:t,member:e,site:n}=C.useContext(Q),i=Dp({member:e}),r=Po({site:n}),l=ls({site:n}),u=i?"emailSuppressed":"accountEmail",m=!r&&!l,p=()=>i||m?c.jsx(B1,{}):c.jsx("p",{children:y("Update your preferences")}),f=()=>{t("switchPage",{page:u,lastPage:"accountHome"})};return c.jsxs("section",{className:"gh-portal-list-clickable",role:"button",tabIndex:0,onClick:f,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:y("Emails")}),p()]}),c.jsx("span",{className:"gh-portal-list-action","data-test-button":"manage-newsletters","aria-hidden":"true",children:y("Manage")})]})}const G1=()=>{const{member:t,site:e}=C.useContext(Q),i=e.transistor_portal_settings||{enabled:e.transistor_portal_enabled===!0,heading:e.transistor_portal_heading,description:e.transistor_portal_description,button_text:e.transistor_portal_button_text,url_template:e.transistor_portal_url_template},r=i?.enabled===!0,l=t?.uuid,u=$p(),[m,p]=C.useState(u&&r);return C.useEffect(()=>{if(u){p(r);return}if(!r||!l){p(!1);return}p(!1);const f=new AbortController;return(async()=>{try{const v=await fetch(`https://partner.transistor.fm/ghost/member/${l}`,{signal:f.signal});if(v.ok){const k=await v.json();f.signal.aborted||p(k?.member===!0)}}catch(v){if(f.signal.aborted)return;console.warn("Error in Transistor request",v)}})(),()=>f.abort()},[r,l,u]),{transistor:{enabled:r,hasPodcasts:m,memberUuid:l,settings:i}}},V1=(t,e)=>No({site:t})&&Po({site:t})||ls({site:t})||Dp({member:e}),H1=t=>!No({site:t})&&Po({site:t})&&!ls({site:t}),q1=()=>{const{member:t,doAction:e,site:n}=C.useContext(Q),{name:i,email:r}=t,{transistor:l}=G1(),u=()=>{e("switchPage",{page:"accountProfile",lastPage:"accountHome"})},m=V1(n,t),p=H1(n);return c.jsx("div",{children:c.jsxs("div",{className:"gh-portal-list",children:[c.jsxs("section",{className:"gh-portal-list-clickable",role:"button",tabIndex:0,onClick:u,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:i||y("Account")}),c.jsx("p",{children:r})]}),c.jsx("span",{"data-test-button":"edit-profile",className:"gh-portal-list-action","aria-hidden":"true",children:y("Edit")})]}),c.jsx(R1,{}),m&&c.jsx(W1,{}),p&&c.jsx(U1,{}),l.enabled&&c.jsx(C1,{hasPodcasts:l.hasPodcasts,memberUuid:l.memberUuid,settings:l.settings})]})})},Z1=()=>c.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[c.jsx(We,{}),c.jsx(I1,{}),c.jsxs("section",{className:"gh-portal-account-data",children:[c.jsx(O1,{}),c.jsx(D1,{}),c.jsx(A1,{}),c.jsx(q1,{})]})]});class J1 extends Pe.Component{static contextType=Q;componentDidMount(){const{member:e,site:n}=this.context;qn({site:n})||this.context.doAction("signout"),e||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(e){e.preventDefault(),this.context.doAction("signout")}render(){const{member:e,site:n}=this.context,i=Mo({site:n});return!e||!qn({site:n})?null:c.jsxs("div",{className:"gh-portal-account-wrapper",children:[c.jsx(Z1,{}),c.jsx(N1,{onClose:()=>this.context.doAction("closePopup"),handleSignout:r=>this.handleSignout(r),supportAddress:i})]})}}class K1 extends Pe.Component{static contextType=Q;constructor(e,n){super(e,n);const{name:i="",email:r=""}=n.member||{};this.state={name:i,email:r}}componentDidMount(){const{member:e}=this.context;e||this.context.doAction("switchPage",{page:"signin"})}handleSignout(e){e.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(e){e.preventDefault(),this.setState(n=>({errors:xi({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:i,errors:r}=this.state;r&&Object.values(r).filter(u=>!!u).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:i}))})}renderSaveButton(){const e=this.context.action==="updateProfile:running";let n=y("Save");this.context.action==="updateProfile:failed"&&(n=y("Retry"));const i=!!e;return c.jsx(Be,{dataTestId:"save-button",isRunning:e,onClick:r=>this.onProfileSave(r),disabled:i,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return c.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:y("Delete account")})}renderAccountFooter(){return c.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return c.jsxs("header",{className:"gh-portal-detail-header",children:[c.jsx(vi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:e=>this.onBack(e)}),c.jsx("h3",{className:"gh-portal-main-title",children:y("Account settings")})]})}renderUserAvatar(){const e=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return c.jsx("div",{style:n,children:c.jsx(Sc,{gravatar:e,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(e,n){const i=n.name;this.setState({[i]:e.target.value})}getInputFields({state:e,fieldNames:n}){const i=e.errors||{},r=[{type:"text",value:e.name,placeholder:y("Jamie Larson"),label:y("Name"),name:"name",required:!1,errorMessage:i.name||""},{type:"email",value:e.email,placeholder:y("jamie@example.com"),label:y("Email"),name:"email",required:!0,errorMessage:i.email||""}];return n&&n.length>0?r.filter(l=>n.includes(l.name)):r}onKeyDown(e){e.keyCode===13&&this.onProfileSave(e)}renderProfileData(){return c.jsx("div",{className:"gh-portal-section",children:c.jsx(Lo,{fields:this.getInputFields({state:this.state}),onChange:(e,n)=>this.handleInputChange(e,n),onKeyDown:(e,n)=>this.onKeyDown(e,n)})})}render(){const{member:e}=this.context;return e?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"gh-portal-content with-footer",children:[this.renderHeader(),c.jsx(We,{}),c.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}}function X1(){const{brandColor:t,lastPage:e,doAction:n}=C.useContext(Q);return c.jsxs("header",{className:"gh-portal-detail-header",children:[c.jsx(vi,{brandColor:t,hidden:!e,onClick:()=>{n("back")}}),c.jsx("h3",{className:"gh-portal-main-title",children:y("Email preferences")})]})}function Q1({newsletter:t,subscribedNewsletters:e,setSubscribedNewsletters:n}){const i=e.some(l=>l.id===t?.id),r=()=>{let l=[];i?l=e.filter(u=>u.id!==t.id):l=e.filter(u=>u.id!==t.id).concat(t),n(l)};return c.jsxs("section",{className:"gh-portal-list-toggle-wrapper gh-portal-list-clickable","data-testid":"newsletter-toggle",role:"button",tabIndex:0,"aria-pressed":i,onClick:r,onKeyDown:l=>{l.target===l.currentTarget&&(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),r())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:t.name}),c.jsx("p",{children:t?.description})]}),c.jsx("div",{style:{display:"flex",alignItems:"center"},onClick:l=>l.stopPropagation(),children:c.jsx(Fo,{id:t.id,label:t.name,onToggle:r,checked:i,dataTestId:"switch-input",presentational:!0})})]})}function _1({updateCommentNotifications:t,isCommentsEnabled:e,enableCommentNotifications:n}){const{doAction:i}=C.useContext(Q),r=!!n,l=C.useRef(!1);if(!e)return null;const u=async()=>{if(!l.current){l.current=!0;try{await t(!r),i("showPopupNotification",{action:"updated:success",message:y("Comment preferences updated.")})}finally{l.current=!1}}};return c.jsxs("section",{className:"gh-portal-list-toggle-wrapper gh-portal-list-clickable","data-testid":"comment-toggle",role:"button",tabIndex:0,"aria-pressed":r,onClick:u,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),u())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:y("Comments")}),c.jsx("p",{children:y("Get notified when someone replies to your comment")})]}),c.jsx("div",{style:{display:"flex",alignItems:"center"},onClick:m=>m.stopPropagation(),children:c.jsx(Fo,{id:"comments",label:y("Comments"),onToggle:u,checked:r,dataTestId:"switch-input",presentational:!0})})]})}function ej({updateUpdatesAndAnnouncements:t,canChangeUpdatesAndAnnouncements:e,enableUpdatesAndAnnouncements:n}){const{doAction:i,site:r}=C.useContext(Q),l=C.useRef(!1);if(!e)return null;const u=async()=>{if(!l.current){l.current=!0;try{await t(!n),i("showPopupNotification",{action:"updated:success",message:y("Email preferences updated.")})}finally{l.current=!1}}};return c.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:u,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),u())},children:[c.jsxs("div",{className:"gh-portal-list-detail",children:[c.jsx("h3",{children:y("Updates & announcements")}),c.jsx("p",{children:y("Occasional updates from {siteTitle}",{siteTitle:r?.title})})]}),c.jsx("div",{style:{display:"flex",alignItems:"center"},onClick:m=>m.stopPropagation(),children:c.jsx(Fo,{id:"updates-and-announcements",label:y("Updates & announcements"),onToggle:u,checked:n,dataTestId:"switch-input",presentational:!0})})]})}function tj({subscribedNewsletters:t,setSubscribedNewsletters:e,hasNewslettersEnabled:n}){const{site:i}=C.useContext(Q),r=Ia({site:i});return n?r.map(l=>c.jsx(Q1,{newsletter:l,subscribedNewsletters:t,setSubscribedNewsletters:e},l?.id)):null}function nj({site:t,isPaid:e}){return e?c.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:y("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:t?.title})}):null}function Gh({hasNewslettersEnabled:t,notification:e,subscribedNewsletters:n,updateSubscribedNewsletters:i,updateCommentNotifications:r,updateUpdatesAndAnnouncements:l,unsubscribeAll:u,isPaidMember:m,isCommentsEnabled:p,enableCommentNotifications:f,canChangeUpdatesAndAnnouncements:g,enableUpdatesAndAnnouncements:v}){const{brandColor:k,doAction:x,member:j,site:T}=C.useContext(Q),z=C.useRef(!!n?.length).current,D=v!=null,R=D?v:z,G=p&&!f||!p,$=g&&!R||!g,Y=!n?.length&&G&&$,K=e||(()=>null);return c.jsxs("div",{className:"gh-portal-content with-footer",children:[c.jsx(X1,{}),c.jsx(We,{brandColor:k}),c.jsx(K,{}),c.jsx("div",{className:"gh-portal-section flex",children:c.jsxs("div",{className:"gh-portal-list",children:[c.jsx(tj,{hasNewslettersEnabled:t,subscribedNewsletters:n,setSubscribedNewsletters:_=>{let le=_.map(fe=>({id:fe.id}));g&&!D?i(le,R):i(le)}}),c.jsx(_1,{isCommentsEnabled:p,enableCommentNotifications:f,updateCommentNotifications:r}),c.jsx(ej,{canChangeUpdatesAndAnnouncements:g,enableUpdatesAndAnnouncements:R,updateUpdatesAndAnnouncements:l})]})}),c.jsx("div",{className:"gh-portal-btn-unsubscribe",children:c.jsx(Be,{isRunning:!1,onClick:()=>{u()},disabled:Y,brandColor:k,isPrimary:!1,label:y("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%"},dataTestId:"unsubscribe-from-all-emails"})}),c.jsxs("footer",{className:"gh-portal-action-footer"+(zc({member:j})?" gh-feature-suppressions":""),children:[c.jsx("div",{style:{width:"100%"},children:c.jsx(nj,{isPaid:m,site:T,subscribedNewsletters:n})}),zc({member:j})&&!Y&&c.jsxs("div",{className:"gh-portal-footer-secondary",children:[c.jsx("span",{className:"gh-portal-footer-secondary-light",children:y("Not receiving emails?")}),c.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>x("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[y("Get help")," ",c.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function aj(){const{member:t,doAction:e,site:n,pageData:i}=C.useContext(Q);let r,l;i&&(r=i.newsletterUuid,l=i.action);const[u,m]=C.useState(!0),p=Ia({site:n}),f=Po({site:n});C.useEffect(()=>{t||e("switchPage",{page:"signin"})},[t,e]),C.useEffect(()=>{if(r&&l==="unsubscribe"){const R=t?.newsletters.filter(G=>G.uuid!==r);x(R),m(!1),e("updateNewsletterPreference",{newsletters:R})}},[]);const g=()=>{if(i.comments&&j){const $=u?"gh-portal-hide":"";return c.jsx(c.Fragment,{children:c.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${$}`,children:c.jsx(tt,{string:y("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:c.jsx("strong",{children:t?.email})}})})})}const R=p?.find($=>$.uuid===i.newsletterUuid);if(!R)return null;const G=u?"gh-portal-hide":"";return c.jsx(c.Fragment,{children:c.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${G}`,children:c.jsx(tt,{string:y("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:c.jsx("strong",{children:t?.email}),newsletterName:c.jsx("strong",{children:R?.name})}})})})},v=[...t?.newsletters||[]],[k,x]=C.useState(v),{comments_enabled:j}=n,T=!!n.labs?.automations,{enable_comment_notifications:z,enable_updates_and_announcements:D}=t||{};return C.useEffect(()=>{x(t?.newsletters||[])},[t?.newsletters]),c.jsx(Gh,{hasNewslettersEnabled:f,notification:r?g:null,subscribedNewsletters:k,updateSubscribedNewsletters:(R,G)=>{x(R),e("updateNewsletterPreference",{newsletters:R,enableUpdatesAndAnnouncements:G}),e("showPopupNotification",{action:"updated:success",message:y("Email preferences updated.")})},updateCommentNotifications:async R=>{e("updateNewsletterPreference",{enableCommentNotifications:R})},updateUpdatesAndAnnouncements:async R=>{e("updateNewsletterPreference",{enableUpdatesAndAnnouncements:R})},unsubscribeAll:()=>{x([]),e("showPopupNotification",{action:"updated:success",message:y("Unsubscribed from all emails.")});const R={newsletters:[]};j&&(R.enableCommentNotifications=!1),T&&(R.enableUpdatesAndAnnouncements=!1),e("updateNewsletterPreference",R)},isPaidMember:dn({member:t}),isCommentsEnabled:j!=="off",enableCommentNotifications:z,canChangeUpdatesAndAnnouncements:T,enableUpdatesAndAnnouncements:D})}function ij(){const{site:t}=C.useContext(Q),e=t.icon;return e?c.jsx("img",{className:"gh-portal-unsubscribe-logo",src:e,alt:t.title}):null}function oj(){const{site:t}=C.useContext(Q),e=t.title||"";return c.jsxs("header",{className:"gh-portal-header",children:[c.jsx(ij,{}),c.jsx("h2",{className:"gh-portal-publication-title",children:e})]})}async function iu({api:t,memberUuid:e,key:n,newsletters:i,enableCommentNotifications:r,enableUpdatesAndAnnouncements:l}){try{return await t.member.updateNewsletters({uuid:e,key:n,newsletters:i,enableCommentNotifications:r,enableUpdatesAndAnnouncements:l})}catch{}}function rj(){const{site:t,api:e,pageData:n,member:i,doAction:r}=C.useContext(Q),[l,u]=C.useState(),[m,p]=C.useState(!0),f=Ia({site:t}),g=f.filter(oe=>oe.subscribe_on_signup),[v,k]=C.useState(!1),[x,j]=C.useState(g),[T,z]=C.useState(!1),{comments_enabled:D}=t,R=!!t.labs?.automations,{enable_comment_notifications:G=!1,enable_updates_and_announcements:$}=l||{},Y=Po({site:t}),V=async(oe,se)=>{const ce={newsletters:oe};se!==void 0&&(ce.enableUpdatesAndAnnouncements=se),i?r("updateNewsletterPreference",ce):await iu({api:e,memberUuid:n.uuid,key:n.key,...ce}),j(oe);const Ie={action:"updated:success",message:y("Email preferences updated.")};r("showPopupNotification",Ie)},K=async oe=>{let se;i?(await r("updateNewsletterPreference",{enableCommentNotifications:oe}),se={...i,enable_comment_notifications:oe}):se=await iu({api:e,memberUuid:n.uuid,key:n.key,enableCommentNotifications:oe}),u(se),r("showPopupNotification",{action:"updated:success",message:y("Comment preferences updated.")})},_=async oe=>{let se;i?(await r("updateNewsletterPreference",{enableUpdatesAndAnnouncements:oe}),se={...i,enable_updates_and_announcements:oe}):se=await iu({api:e,memberUuid:n.uuid,key:n.key,enableUpdatesAndAnnouncements:oe}),u(se),r("showPopupNotification",{action:"updated:success",message:y("Email preferences updated.")})},le=async()=>{let oe;i?(await r("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),oe={...i},oe.newsletters=[],oe.enable_comment_notifications=!1,oe.enable_updates_and_announcements=!1):oe=await e.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1,enableUpdatesAndAnnouncements:!1}),j([]),u(oe),r("showPopupNotification",{action:"updated:success",message:y("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let oe;try{oe=await e.member.newsletters({uuid:n.uuid,key:n.key}),u(oe??null),p(!1)}catch(ce){console.error("[PORTAL] Error fetching member newsletters",ce),u(null),p(!1);return}if(oe===null)return;const se=oe?.newsletters||[];j(se),f?.length===1&&!D&&!n.newsletterUuid?await V([]):n.newsletterUuid?await V(se?.filter(ce=>ce.uuid!==n.newsletterUuid)):n.comments&&D?await K(!1):n.updatesAndAnnouncements&&R&&await _(!1)})()},[D,R,n.uuid,n.newsletterUuid,n.comments,n.updatesAndAnnouncements,t.url,f?.length]),m)return c.jsx(Ei,{});if(!l)return c.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[c.jsx(We,{}),c.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:c.jsx(Wc,{})}),c.jsx("h1",{className:"gh-portal-main-title",children:y("That didn't go to plan")}),c.jsx("div",{children:c.jsx("p",{className:"gh-portal-text-center",children:y("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),c.jsx(Be,{style:{width:"100%"},retry:!1,onClick:()=>r("closePopup"),disabled:!1,brandColor:"#000000",label:y("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if(f?.length===1&&!D&&!T)return c.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[c.jsx(We,{}),c.jsx(oj,{}),c.jsx("h1",{className:"gh-portal-main-title",children:y("Successfully unsubscribed")}),c.jsxs("div",{children:[c.jsx("p",{className:"gh-portal-text-center",children:c.jsx(tt,{string:y("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:c.jsx("strong",{children:l?.email})}})}),c.jsx("p",{className:"gh-portal-text-center",children:c.jsx(tt,{string:y("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:c.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{z(!0)}})}})})]})]});const fe=()=>{if(n.comments&&D){const ce=v?"gh-portal-hide":"";return c.jsx(c.Fragment,{children:c.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ce}`,children:c.jsx(tt,{string:y("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:c.jsx("strong",{children:l?.email})}})})})}if(n.updatesAndAnnouncements&&R){const ce=v?"gh-portal-hide":"";return c.jsx(c.Fragment,{children:c.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${ce}`,children:c.jsx(tt,{string:y("{memberEmail} will no longer receive updates & announcements."),mapping:{memberEmail:c.jsx("strong",{children:l?.email})}})})})}const oe=f?.find(ce=>ce.uuid===n.newsletterUuid);if(!oe)return null;const se=v?"gh-portal-hide":"";return c.jsx(c.Fragment,{children:c.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${se}`,children:c.jsx(tt,{string:y("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:c.jsx("strong",{children:l?.email}),newsletterName:c.jsx("strong",{children:oe?.name})}})})})};return c.jsx(Gh,{hasNewslettersEnabled:Y,notification:fe,subscribedNewsletters:x,updateSubscribedNewsletters:async(oe,se)=>{await V(oe,se),k(!0)},updateCommentNotifications:K,updateUpdatesAndAnnouncements:_,unsubscribeAll:async()=>{await le(),k(!0)},isPaidMember:l?.status!=="free",isCommentsEnabled:D!=="off",enableCommentNotifications:G,canChangeUpdatesAndAnnouncements:R,enableUpdatesAndAnnouncements:$})}function sj(){const{brandColor:t,lastPage:e,doAction:n,action:i,site:r}=C.useContext(Q);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(i)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(i)&&n("back"),["refreshMemberData:success"].includes(i)&&(No({site:r})||ls({site:r})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:y("You have been successfully resubscribed")})):n("back"))},[i,n,r,y]);const l=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(i),u=()=>{n("removeEmailFromSuppressionList")};return c.jsxs("div",{className:"gh-email-suppressed-page",children:[c.jsxs("header",{className:"gh-portal-detail-header",children:[c.jsx(vi,{brandColor:t,hidden:!e,onClick:()=>{n("back")}}),c.jsx(We,{})]}),c.jsx(Wh,{className:"gh-email-suppressed-page-icon"}),c.jsxs("div",{className:"gh-email-suppressed-page-text",children:[c.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:y("Emails disabled")}),c.jsx("p",{children:y("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.")})]}),c.jsx(Be,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:u,disabled:l,brandColor:t,label:y("Re-enable emails"),isRunning:l})]})}function lj(){const{brandColor:t,doAction:e,site:n,pageData:i}=C.useContext(Q),r=`mailto:${Mo({site:n})}`,l=i&&i.direct||!1;return c.jsxs("div",{className:"gh-email-suppression-faq",children:[!l&&c.jsxs("header",{className:"gh-portal-detail-header",children:[c.jsx(vi,{brandColor:t,onClick:()=>{e("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),c.jsx(We,{})]}),c.jsxs("div",{className:"gh-longform",children:[c.jsx("h3",{children:y("Why has my email been disabled?")}),c.jsx("p",{children:y("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).")}),c.jsx("h4",{children:y("Spam complaints")}),c.jsx("p",{children:y("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),c.jsx("p",{children:y("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.")}),c.jsx("p",{children:y("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.")}),c.jsx("h4",{children:y("Permanent failure (bounce)")}),c.jsx("p",{children:y("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.")}),c.jsx("p",{children:y("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),c.jsx("p",{children:y("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.")}),c.jsx("p",{children:c.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:r,onClick:()=>{r&&window.open(r)},children:y("Need more help? Contact support")})})]})]})}function cj(){const{brandColor:t,doAction:e,site:n,lastPage:i,member:r,pageData:l}=C.useContext(Q),u=Mo({site:n}),m=`mailto:${u}`,p=fS({site:n}),f=l&&l.direct||!1;return c.jsxs("div",{className:"gh-email-receiving-faq",children:[c.jsxs("header",{className:"gh-portal-detail-header",children:[!f&&c.jsx(vi,{brandColor:t,onClick:()=>{i?e("switchPage",{page:"accountHome"}):e("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),c.jsx(We,{})]}),c.jsxs("div",{className:"gh-longform",children:[c.jsx("h3",{children:y("Help! I'm not receiving emails")}),c.jsx("p",{children:y("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),c.jsx("h4",{children:y("Verify your email address is correct")}),c.jsx("p",{children:c.jsx(tt,{string:y("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:c.jsx("strong",{children:r.email}),button:c.jsx("button",{className:"gh-portal-btn-text",onClick:()=>e("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),c.jsx("h4",{children:y("Check spam & promotions folders")}),c.jsx("p",{children:y(`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".`)}),c.jsx("h4",{children:y("Create a new contact")}),c.jsx("p",{children:c.jsx(tt,{string:y("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:c.jsx("strong",{children:p})}})}),c.jsx("h4",{children:y("Send an email and say hi!")}),c.jsx("p",{children:c.jsx(tt,{string:y("Send an email to {senderEmail} and say hello. This can also help signal to your mail provider that emails to and from this address should be trusted."),mapping:{senderEmail:c.jsx("strong",{children:p})}})}),c.jsx("h4",{children:y("Check with your mail provider")}),c.jsx("p",{children:c.jsx(tt,{string:y("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:c.jsx("strong",{children:p})}})}),c.jsx("h4",{children:y("Get in touch for help")}),c.jsx("p",{children:c.jsx(tt,{string:y("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:c.jsx("a",{href:m,onClick:()=>{m&&window.open(m)},children:u})}})})]})]})}const uj=()=>{const[t,e]=C.useState(!0),[n,i]=C.useState(null),[r,l]=C.useState(null),{member:u,site:m}=C.useContext(Q);return C.useEffect(()=>{async function p(){const f=m.url,g=window.location.origin+window.location.pathname,v=u?`${g}?action=support&success=true`:`${g}#/portal/support/success`,k=g,x=Es({siteUrl:f});try{const j=await x.member.checkoutDonation({successUrl:v,cancelUrl:k,personalNote:y("Add a personal note")});j.url&&window.location.replace(j.url)}catch(j){j.type&&j.type==="DisabledFeatureError"?l(y("This site is not accepting payments at the moment.")):i(y("Something went wrong, please try again later.")),e(!1)}}m&&m.donations_enabled===!1?(l(y("This site is not accepting donations at the moment.")),e(!1)):p()},[]),t?c.jsx("div",{children:c.jsx(Ei,{})}):n?c.jsx(au,{error:n}):r?c.jsx(au,{error:r}):null},dj=()=>{try{if(window.parent&&window.parent!==window&&window.parent.location.href)return window.parent}catch{}return window},Vo=(t,e)=>{const n=new URLSearchParams(e);return`${t}?${n.toString()}`},mj=({shareTitle:t,shareUrl:e})=>{const n=[t,e].filter(Boolean).join(`
|
|
4569
4569
|
|
|
4570
|
-
`),i=[];return t&&i.push(`subject=${encodeURIComponent(t)}`),n&&i.push(`body=${encodeURIComponent(n)}`),`mailto:${i.length?`?${i.join("&")}`:""}`},pj=({shareTitle:t,shareUrl:e})=>Vo("https://www.linkedin.com/shareArticle",{mini:"true",url:e,title:t}),hj=()=>{const t=dj(),e=t.document,n=t.location,i=(j,T="content")=>e.querySelector(j)?.[T]||"",r=i('link[rel="canonical"]',"href")||n.origin+n.pathname+n.search,l=i('meta[property="og:title"]')||e.title||"",u=i('meta[property="og:description"]')||i('meta[name="description"]')||"",m=i('meta[property="og:image"]')||i('meta[name="twitter:image"]')||"",p=i('link[rel="icon"]',"href")||i('link[rel="shortcut icon"]',"href")||i('link[rel="apple-touch-icon"]',"href"),f=i('meta[name="author"]'),g=(f&&!/^https?:\/\//i.test(f)?f:"")||i('meta[name="twitter:creator"]')||"";let v=i('meta[property="og:site_name"]')||i('meta[name="application-name"]')||"";if(!v)try{v=new URL(r).hostname.replace(/^www\./,"")}catch{v=""}const k=[l,r].filter(Boolean).join(" ").trim(),x={twitter:Vo("https://twitter.com/intent/tweet",{url:r,text:l}),facebook:Vo("https://www.facebook.com/sharer/sharer.php",{u:r}),email:mj({shareTitle:l,shareUrl:r}),threads:Vo("https://www.threads.net/intent/post",{text:k}),linkedin:pj({shareTitle:l,shareUrl:r}),bluesky:Vo("https://bsky.app/intent/compose",{text:k})};return{shareUrl:r,shareTitle:l,shareExcerpt:u,shareImage:m,shareFavicon:p,shareSiteName:v,shareAuthor:g,socialLinks:x}},fj=()=>{const[t]=C.useState(hj);return t},gj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...t},C.createElement("path",{fill:"#0085ff",d:"M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805zm36.254 0C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745z"})),bj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-ellipsis-icon lucide-ellipsis",...t},C.createElement("circle",{cx:12,cy:12,r:1}),C.createElement("circle",{cx:19,cy:12,r:1}),C.createElement("circle",{cx:5,cy:12,r:1})),yj=t=>C.createElement("svg",{id:"svg9",width:666.66669,height:666.66718,viewBox:"0 0 666.66668 666.66717",xmlns:"http://www.w3.org/2000/svg","xmlns:svg":"http://www.w3.org/2000/svg",...t},C.createElement("defs",{id:"defs13"},C.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},C.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),C.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},C.createElement("g",{id:"g19"},C.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},C.createElement("g",{id:"g27",transform:"translate(600,350)"},C.createElement("path",{d:"m 0,0 c 0,138.071 -111.929,250 -250,250 -138.071,0 -250,-111.929 -250,-250 0,-117.245 80.715,-215.622 189.606,-242.638 v 166.242 h -51.552 V 0 h 51.552 v 32.919 c 0,85.092 38.508,124.532 122.048,124.532 15.838,0 43.167,-3.105 54.347,-6.211 V 81.986 c -5.901,0.621 -16.149,0.932 -28.882,0.932 -40.993,0 -56.832,-15.528 -56.832,-55.9 V 0 h 81.659 l -14.028,-76.396 h -67.631 V -248.169 C -95.927,-233.218 0,-127.818 0,0",style:{fill:"#0866ff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path29"})),C.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},C.createElement("path",{d:"M 0,0 14.029,76.396 H -67.63 v 27.019 c 0,40.372 15.838,55.899 56.831,55.899 12.733,0 22.981,-0.31 28.882,-0.931 v 69.253 c -11.18,3.106 -38.509,6.212 -54.347,6.212 -83.539,0 -122.048,-39.441 -122.048,-124.533 V 76.396 h -51.552 V 0 h 51.552 v -166.242 c 19.343,-4.798 39.568,-7.362 60.394,-7.362 10.254,0 20.358,0.632 30.288,1.831 L -67.63,0 Z",style:{fill:"#ffffff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path33"})))))),kj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-link-icon lucide-link",...t},C.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),vj=t=>C.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...t},C.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),C.createElement("path",{d:"M0 183.4C0 84.9 82.4 5 184 5h2122c101.6 0 184 79.9 184 178.4v2133.3c0 98.5-82.4 178.3-184 178.3H184c-101.6 0-184-79.8-184-178.3z",fill:"#0a66c2"}),C.createElement("path",{d:"M756.7 2088.8v-1121H384.1v1121zm-186.2-1274c129.9 0 210.8-86.1 210.8-193.7-2.4-110-80.9-193.7-208.3-193.7-127.5 0-210.8 83.7-210.8 193.7 0 107.6 80.8 193.7 205.9 193.7zm392.4 1274h372.6v-626c0-33.5 2.4-67 12.3-90.9 26.9-67 88.2-136.3 191.2-136.3 134.8 0 188.7 102.8 188.7 253.5v599.6h372.6V1446c0-344.3-183.8-504.5-428.9-504.5-201 0-289.2 112.3-338.3 188.8h2.5V967.8H962.9c4.9 105.2 0 1121 0 1121z",fill:"#fff"})),wj=t=>C.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},C.createElement("g",{clipPath:"url(#clip0_351_18008)"},C.createElement("path",{d:"M13.0332 8.37917C12.96 8.34407 12.8856 8.3103 12.8103 8.27795C12.6791 5.86015 11.3579 4.47596 9.1396 4.4618C9.12955 4.46173 9.11955 4.46173 9.1095 4.46173C7.78265 4.46173 6.67913 5.0281 5.99992 6.05871L7.21993 6.89561C7.72733 6.12579 8.52364 5.96167 9.11008 5.96167C9.11686 5.96167 9.12366 5.96168 9.13036 5.96174C9.86078 5.96639 10.4119 6.17876 10.7687 6.59291C11.0283 6.89442 11.2019 7.31107 11.2879 7.8369C10.6403 7.72683 9.93993 7.69299 9.19122 7.73592C7.08214 7.8574 5.72624 9.08747 5.81731 10.7967C5.86352 11.6637 6.29544 12.4096 7.03346 12.8968C7.65745 13.3087 8.46111 13.5101 9.29635 13.4645C10.3994 13.4041 11.2647 12.9832 11.8684 12.2137C12.3268 11.6293 12.6168 10.872 12.7448 9.91782C13.2705 10.2351 13.6601 10.6525 13.8753 11.1544C14.2411 12.0075 14.2624 13.4094 13.1186 14.5523C12.1164 15.5535 10.9117 15.9866 9.09104 16C7.07147 15.9851 5.54409 15.3374 4.55103 14.0749C3.62111 12.8928 3.14053 11.1854 3.1226 9C3.14053 6.8146 3.62111 5.10714 4.55103 3.92503C5.54409 2.66262 7.07144 2.01495 9.09101 1.99994C11.1252 2.01506 12.6792 2.66585 13.7103 3.93435C14.2159 4.55641 14.597 5.3387 14.8483 6.25081L16.278 5.86936C15.9734 4.74665 15.4942 3.7792 14.842 2.97686C13.5201 1.35059 11.5869 0.517279 9.096 0.5H9.08603C6.60019 0.517219 4.68862 1.3537 3.40443 2.98619C2.26168 4.4389 1.67221 6.46024 1.65241 8.99402L1.65234 9L1.65241 9.00598C1.67221 11.5397 2.26168 13.5611 3.40443 15.0138C4.68862 16.6463 6.60019 17.4828 9.08603 17.5H9.096C11.306 17.4847 12.8638 16.9061 14.1472 15.6239C15.8262 13.9465 15.7756 11.8439 15.2222 10.5531C14.8252 9.62749 14.0683 8.8757 13.0332 8.37917ZM9.21739 11.9668C8.29301 12.0188 7.33268 11.6039 7.28533 10.7152C7.25023 10.0563 7.75426 9.32105 9.27412 9.23347C9.44817 9.22343 9.61897 9.21852 9.78676 9.21852C10.3388 9.21852 10.8553 9.27215 11.3248 9.3748C11.1497 11.562 10.1224 11.9171 9.21739 11.9668Z",fill:"black"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_351_18008"},C.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),xj=t=>C.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...t},C.createElement("path",{d:"M714.163 519.284L1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284zM569.165 687.828l-47.468-67.894-377.686-540.24h162.604l304.797 435.991 47.468 67.894 396.2 566.721H892.476L569.165 687.854z"})),ou={signin:z1,signup:xE,accountHome:J1,accountPlan:NC,accountProfile:K1,accountEmail:aj,signupNewsletter:Hc,unsubscribe:rj,magiclink:UE,loading:Ei,offer:qE,feedback:t1,emailSuppressed:sj,emailSuppressionFAQ:lj,emailReceivingFAQ:cj,support:uj,supportSuccess:s1,supportError:au,recommendations:w1,gift:LE,giftRedemption:c1,giftSuccess:p1,share:()=>{const[t,e]=C.useState(!1),[n,i]=C.useState(!1),r=C.useRef(),l=C.useRef(null),{shareUrl:u,shareTitle:m,shareExcerpt:p,shareImage:f,shareFavicon:g,shareSiteName:v,shareAuthor:k,socialLinks:x}=fj();C.useEffect(()=>()=>{clearTimeout(r.current)},[]),C.useEffect(()=>{if(!n)return;const D=l.current?.ownerDocument||document,R=$=>{l.current&&!l.current.contains($.target)&&($.stopPropagation(),$.preventDefault(),i(!1))},G=$=>{$.key==="Escape"&&i(!1)};return D.addEventListener("click",R,!0),D.addEventListener("keydown",G),()=>{D.removeEventListener("click",R,!0),D.removeEventListener("keydown",G)}},[n]);const j=async()=>{await Lh(u)&&(e(!0),clearTimeout(r.current),r.current=setTimeout(()=>{e(!1)},2e3))},T=()=>{i(D=>!D)},z=()=>{i(!1)};return c.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[c.jsx(We,{}),c.jsx("div",{className:"gh-portal-share-header",children:c.jsx("h1",{className:"gh-portal-main-title",children:y("Share")})}),c.jsxs("div",{className:"gh-portal-share-preview",children:[f&&c.jsx("img",{className:"gh-portal-share-preview-image",src:f,alt:"","data-testid":"share-preview-image"}),c.jsxs("div",{className:"gh-portal-share-preview-content",children:[m&&c.jsx("h2",{className:"gh-portal-share-preview-title",children:m}),p&&c.jsx("p",{className:"gh-portal-share-preview-excerpt",children:p}),(g||v||k)&&c.jsxs("div",{className:"gh-portal-share-preview-footer",children:[g&&c.jsx("img",{className:"gh-portal-share-preview-favicon",src:g,alt:"","data-testid":"share-preview-favicon"}),c.jsxs("div",{className:"gh-portal-share-preview-meta",children:[v&&c.jsx("span",{className:"gh-portal-share-preview-site",children:v}),v&&k&&c.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),k&&c.jsx("span",{className:"gh-portal-share-preview-author",children:k})]})]})]})]}),c.jsxs("div",{className:"gh-portal-share-actions",children:[c.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:j,"aria-label":y(t?"Copied":"Copy link"),title:y(t?"Copied":"Copy link"),children:[t?c.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:c.jsx(Ro,{})}):c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(kj,{})}),c.jsx("span",{className:"gh-portal-share-label",children:y(t?"Copied":"Copy link")})]}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:x.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":y("X (Twitter)"),title:y("X (Twitter)"),children:c.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:c.jsx(xj,{})})}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:x.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":y("LinkedIn"),title:y("LinkedIn"),children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(vj,{})})}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:x.email,target:"_blank",rel:"noopener noreferrer","aria-label":y("Email"),title:y("Email"),children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(tu,{})})}),c.jsxs("div",{className:"gh-portal-share-more",ref:l,children:[c.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:T,"aria-label":y("More options"),title:y("More options"),"aria-haspopup":"menu","aria-expanded":n,children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(bj,{})})}),n&&c.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":y("More options"),children:[c.jsxs("a",{className:"gh-portal-share-more-item",href:x.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(yj,{})}),c.jsx("span",{children:y("Facebook")})]}),c.jsxs("a",{className:"gh-portal-share-more-item",href:x.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(wj,{})}),c.jsx("span",{children:y("Threads")})]}),c.jsxs("a",{className:"gh-portal-share-more-item",href:x.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(gj,{})}),c.jsx("span",{children:y("Bluesky")})]})]})]})]})]})}},ru=function({page:t}){return Object.keys(ou).includes(t)?t:"signup"},Vh=function({page:t}){return t.includes("account")},Sj=function({page:t}){return t.includes("offer")},Cj=t=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},C.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"}));class Hh extends Pe.Component{static contextType=Q;render(){return c.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",children:[c.jsx(Cj,{}),"Powered by Ghost"]})}}const qh=()=>({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 Ej({message:t}){return Ta()?c.jsx("div",{className:"gh-portal-cookiebanner",children:t}):null}class jj extends Pe.Component{static contextType=Q;componentDidMount(){this.node&&!Ze(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=e=>{e.key==="Escape"&&this.dismissPopup(e)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(e){const n=e.target&&e.target.tagName;(n!=="INPUT"||n==="INPUT"&&!e?.target?.value)&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){this.node&&Ze(["preview"])&&this.node?.clientHeight!==this.lastContainerHeight&&(this.lastContainerHeight=this.node?.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(e){const{page:n,otcRef:i}=this.context;Ze(["preview"])||i&&n==="magiclink"||n==="giftRedemption"||n==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:e}=this.context;ru({page:e});const n=ou[e];return c.jsx(n,{})}renderPopupNotification(){const{popupNotification:e}=this.context;return!e||!e.type?null:c.jsx(VE,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:e,pageQuery:n,site:i,customSiteUrl:r,lastPage:l}=this.context,m=us({site:i,pageQuery:n}).length;ru({page:e});const f={...qh().page[e]};let g="",v="regular",k="",x=e;switch(e){case"signup":k="Cookies must be enabled in your browser to sign up.";break;case"signin":k="Cookies must be enabled in your browser to sign in.";break;case"accountHome":x="account-home";break;case"accountProfile":x="account-profile";break;case"accountPlan":x="account-plan";break;default:k="Cookies must be enabled in your browser.",x=e;break}m>1&&!pn({site:i})&&Pn({site:i,pageQuery:n})&&e==="signup"&&(x+=" full-size",v="full"),(e==="gift"||e==="giftSuccess"||e==="giftRedemption")&&(x+=" full-size",v="full"),e==="magiclink"&&l==="gift"&&(x+=" full-size giftRedemption",v="full");const j=zo({site:i});(j&&m>2||!j&&m>1)&&e==="accountPlan"&&(x+=" full-size",v="full"),(e==="emailSuppressionFAQ"||e==="emailReceivingFAQ")&&(x+=" large-size");let T="gh-portal-popup-container";Ze(["preview"])&&(x+=" preview"),Ze(["preview"],{customSiteUrl:r})&&!i.disableBackground&&(T+=" preview"),Ze(["dev"])&&(T+=" dev");const z=`${T} ${g} ${x}`,D=e==="gift"||e==="giftSuccess"||e==="giftRedemption"||e==="magiclink"&&l==="gift";return this.sendPortalPreviewReadyEvent(),c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"gh-portal-popup-wrapper "+x,onClick:R=>this.handlePopupClose(R),children:[this.renderPopupNotification(),c.jsxs("div",{className:z,style:f,ref:R=>this.node=R,tabIndex:-1,children:[c.jsx(Ej,{message:k}),this.renderActivePage(),v==="full"&&!D?c.jsx("div",{className:"gh-portal-powered inside "+(Ze(["preview"])?"hidden ":"")+x,children:c.jsx(Hh,{})}):""]})]}),e!=="share"&&!D&&c.jsx("div",{className:"gh-portal-powered outside "+(Ze(["preview"])?"hidden ":"")+x,children:c.jsx(Hh,{})})]})}}class Tj extends Pe.Component{static contextType=Q;constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){const n=ou[e];return c.jsx(n,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();const{page:n}=this.context;n==="giftRedemption"||n==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:e,brandColor:n}=this.context,i=P1({site:e}),r=n?`:root { --brandcolor: ${n} }`+i:i;return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:r}}),c.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:e,site:n,customSiteUrl:i}=this.context,r=qh(),l=window.innerWidth<480,u={...r.frame.common};let m="gh-portal-popup-background";return Ze(["preview"])&&(r.modalContainer.zIndex="3999997"),Ze(["preview"],{customSiteUrl:i})&&!n.disableBackground&&(m+=" preview"),Ze(["dev"])&&(m+=" dev"),c.jsx("div",{style:r.modalContainer,children:c.jsxs(wc,{style:u,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[c.jsx("div",{className:m,onClick:p=>this.handlePopupClose(p)}),c.jsx(jj,{isMobile:l})]})})}render(){const{showPopup:e}=this.context;return e?this.renderFrameContainer():null}}js({products:su({numOfProducts:1})});function gt(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function Pj(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function js({title:t="The Blueprint",description:e="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:i="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:r="https://portal.localhost",plans:l={monthly:5e3,yearly:15e4,currency:"USD"},products:u=su({numOfProducts:1}),portalProducts:m=u.map(fe=>fe.id),accentColor:p="#45C32E",portalPlans:f=["free","monthly","yearly"],membersSignupAccess:g="all",freePriceName:v="Free",freePriceDescription:k="Free preview",paidMembersEnabled:x=!0,portalButton:j=!0,portalName:T=!0,portalButtonIcon:z="icon-1",portalButtonSignupText:D="Subscribe now",portalButtonStyle:R="icon-and-text",membersSupportAddress:G="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:Y=[],posts:V=zj(),commentsEnabled:K,recommendations:_=[],recommendationsEnabled:le}={}){return{title:t,description:e,logo:n,icon:i,accent_color:p,url:r,plans:l,products:u,portal_products:m,members_signup_access:g,free_price_name:v,free_price_description:k,paid_members_enabled:x,portal_button:j,portal_name:T,portal_plans:f,portal_button_icon:z,portal_button_signup_text:D,portal_button_style:R,members_support_address:G,comments_enabled:K!=="off",newsletters:Y,recommendations:_,recommendations_enabled:!!le,editor_default_email_recipients:$,posts:V}}function Zh({name:t="Black Friday",code:e="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:i="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:r="percent",cadence:l="month",amount:u=50,duration:m="repeating",durationInMonths:p=null,currencyRestriction:f=!1,currency:g=null,status:v="active",tierId:k="",tierName:x="Basic",redemptionType:j="signup"}={}){return{id:`offer_${gt()}`,name:t,code:e,display_title:n,display_description:i,type:r,cadence:l,amount:u,duration:m,duration_in_months:p,currency_restriction:f,currency:g,status:v,tier:{id:`${k}`,name:x},redemption_type:j}}function _t({name:t="Jamie Larson",email:e="jamie@example.com",firstname:n="Jamie",subscriptions:i=[],paid:r=!1,status:l,avatarImage:u="",subscribed:m=!0,email_suppression:p={suppressed:!1,info:null},newsletters:f=[]}={}){const g={uuid:Pj(),email:e,name:t,firstname:n,paid:r,subscribed:m,avatar_image:u,subscriptions:i,email_suppression:p,newsletters:f};return l!==void 0?g.status=l:r?g.status="paid":g.status="free",g}function zj({numOfPosts:t=3}={}){const e=[];for(let n=0;n<t;n++)e.push(Nj({title:`Post ${n+1}`,slug:`post-${n+1}`}));return e.slice(0,t)}function Nj({id:t=`post_${gt()}`,title:e="Post",excerpt:n="Post excerpt",slug:i="post",featured:r=!1}={}){return{id:t,title:e,excerpt:n,slug:i,featured:r}}function su({numOfProducts:t=3}={}){const n=[Ti({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ut({interval:"month",amount:700}),yearlyPrice:Ut({interval:"year",amount:7e3}),numOfBenefits:2}),Ti({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ut({interval:"month",amount:1200}),yearlyPrice:Ut({interval:"year",amount:12e3}),numOfBenefits:3}),Ti({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ut({interval:"month",amount:18e3}),yearlyPrice:Ut({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,t),i=Jh({});return[...n,i]}function Ti({type:t="paid",name:e="Basic",description:n="",id:i=`product_${gt()}`,monthlyPrice:r=Ut(),yearlyPrice:l=Ut({interval:"year"}),numOfBenefits:u=2,trialDays:m=null}){return{id:i,name:e,description:n,monthlyPrice:t==="free"?null:r,yearlyPrice:t==="free"?null:l,type:t,benefits:Kh({numOfBenefits:u}),trial_days:m}}function Jh({name:t="Free tier",description:e="Free tier description",id:n=`product_${gt()}`,numOfBenefits:i=2}){return{id:n,name:t,type:"free",description:e,benefits:Kh({numOfBenefits:i})}}function Kh({numOfBenefits:t}){const e=gt();return[Ts({name:`Limited early adopter pricing #${e.substring(0,6)}`}),Ts({name:`Latest gear reviews #${e.substring(6,12)}`}),Ts({name:`Weekly email newsletter #${e.substring(12,18)}`}),Ts({name:`Listen to my podcast #${e.substring(18)}`})].slice(0,t)}function Ts({id:t=`benefit_${gt()}`,name:e="Benefit"}){return{id:t,name:e}}function Ut({interval:t="month",amount:e=t==="month"?500:5e3,nickname:n=t==="month"?"Monthly":"Yearly",description:i=null,currency:r="usd",active:l=!0,id:u=`price_${gt()}`}={}){return{id:u,active:l,nickname:n,currency:r,amount:e,interval:t,description:i,stripe_price_id:`price_${gt()}`,stripe_product_id:`prod_${gt()}`,type:"recurring"}}function Aa({id:t=`sub_${gt()}`,status:e="active",currency:n="USD",interval:i="year",amount:r=i==="month"?500:5e3,nickname:l=i==="month"?"Monthly":"Yearly",cardLast4:u="4242",offer:m=Mj,priceId:p=`price_${gt()}`,startDate:f="2021-10-05T03:18:30.000Z",currentPeriodEnd:g="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:v=!1,trialEndAt:k=null,nextPayment:x=null,tier:j=null}={}){return{id:t,customer:{id:`cus_${gt()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${gt()}`,nickname:l,amount:r,interval:i,currency:n},offer:m,status:e,start_date:f,default_payment_card_last4:u,cancel_at_period_end:v,cancellation_reason:null,current_period_end:g,trial_end_at:k,next_payment:x,tier:j,price:{id:`stripe_price_${gt()}`,price_id:p,nickname:l,amount:r,interval:i,type:"recurring",currency:n,product:{id:`stripe_prod_${gt()}`,product_id:`prod_${gt()}`}}}}function Xh(){const t=su({numOfProducts:1}),e=t.map(i=>i.id);return js({products:t,portalPlans:["free","monthly","yearly"],portalProducts:e})}Xh();const Ij=js({products:[Ti({numOfBenefits:2,type:"free"})]}),Mj=Zh({tierId:Ij.products[0]?.id});_t({status:"free"}),_t({status:"paid",paid:!0,subscriptions:[Aa()]}),_t({status:"comped",paid:!0,subscriptions:[]}),_t({status:"comped",paid:!0,subscriptions:[Aa({amount:0})]}),_t({status:"paid",paid:!0,subscriptions:[Aa({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Xh();const Ps=[Jh({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Ti({name:"The Blueprint",description:"",monthlyPrice:Ut({interval:"month",amount:500}),yearlyPrice:Ut({interval:"year",amount:5e3}),numOfBenefits:3}),Ti({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ut({interval:"month",amount:1200}),yearlyPrice:Ut({interval:"year",amount:11e3}),numOfBenefits:4})],zs=js({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:Ps,portalProducts:Ps.map(t=>t.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",paidMembersEnabled:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),Qh=Zh({tierId:zs.products[1]?.id}),Pi={free:_t({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:_t({paid:!0,status:"paid",subscriptions:[Aa({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:_t({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:_t({paid:!0,status:"comped",subscriptions:[Aa({amount:0})]}),preview:_t({paid:!0,status:"paid",subscriptions:[Aa({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function Oj(){if(!Ps||!Ps[1])return null;let t=zs?.products?.[1].monthlyPrice,e=_t({paid:!0,status:"paid",subscriptions:[Aa({offer:null,priceId:t?.id,status:"active",currency:t?.currency,interval:t?.interval,amount:t?.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:zs,member:e}}function Aj(t){const e=t.getAttribute("href"),n=new URL(e,window.location.origin),i=["#/portal","#/share"],r=i.some(u=>n.hash.startsWith(u)),l=i.some(u=>e.startsWith(u));!n.hash||!r||l||n.origin===window.location.origin&&t.setAttribute("href",n.hash)}const Dj="CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION";function Yj({data:t,state:e}){return{page:t.page,popupNotification:null,lastPage:t.lastPage||null,pageData:t.pageData||e.pageData}}function Fj({state:t}){return{showPopup:!t.showPopup}}function Rj({data:t}){return{showPopup:!0,reloadOnPopupClose:!1,page:t.page,...t.pageQuery?{pageQuery:t.pageQuery}:{},...t.pageData?{pageData:t.pageData}:{}}}function Lj({state:t}){return t.lastPage?{page:t.lastPage}:_h({state:t})}function _h({state:t}){Vn();const e={...t.pageData||{}};return delete e.redirect,{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:t.page==="magiclink"?"":t.page,pageData:e}}function $j({data:t,state:e}){const{action:n="openNotification",status:i="success",autoHide:r=!0,closeable:l=!0,duration:u=2600,message:m=""}=t||{},p=Oo({type:n,status:i,autoHide:r,closeable:l,duration:u,state:e,message:m});return{notification:p,notificationSequence:p.count}}function Uj(){return{notification:null}}async function Bj({api:t,state:e}){try{return await t.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:De({type:"signout:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to log out, please try again")})}}}async function Wj({data:t,api:e,state:n}){try{const i=await e.member.getIntegrityToken(),r={...t,emailType:"signin",integrityToken:i,includeOTC:!0},{otc_ref:l,inboxLinks:u}=await e.member.sendMagicLink(r);return{page:"magiclink",lastPage:"signin",...l?{otcRef:l}:{},inboxLinks:u,pageData:{...n.pageData||{},email:(t?.email||"").trim()}}}catch(i){return{action:"signin:failed",popupNotification:De({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Tn(i,y("Failed to log in, please try again"))})}}}function Gj({data:t,state:e}){const n=(t?.email||"").trim(),i=t?.otcRef,r=t?.inboxLinks;return i?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:i,inboxLinks:r,pageData:{...e.pageData||{},email:n},popupNotification:null}:{}}async function Vj({data:t,api:e}){const n=y("Failed to verify code, please try again");try{const i=await e.member.getIntegrityToken(),r=await e.member.verifyOTC({...t,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Tn(r.errors?.[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Tn(i,n)}}}async function Hj({data:t,state:e,api:n}){try{let{plan:i,tierId:r,cadence:l,email:u,name:m,newsletters:p,offerId:f}=t;m=m?.trim();let g;if(i.toLowerCase()==="free"){const v=await n.member.getIntegrityToken();({inboxLinks:g}=await n.member.sendMagicLink({emailType:"signup",integrityToken:v,...t,name:m}))}else{const v=e.member?{checkoutType:"upgrade"}:void 0;return(!r||!l)&&({tierId:r,cadence:l}=Io({site:e?.site,priceId:i})),await n.member.checkoutPlan({plan:i,tierId:r,cadence:l,email:u,name:m,newsletters:p,offerId:f,metadata:v}),{page:"loading"}}return{page:"magiclink",lastPage:"signup",inboxLinks:g,pageData:{...e.pageData||{},email:(u||"").trim()}}}catch(i){if(i.code===Dj)return e.member?{action:"signup:failed",popupNotification:De({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("You already have an active subscription.")})}:{page:"magiclink",lastPage:"signin",pageData:{...e.pageData||{},email:(t?.email||"").trim()},popupNotification:null};const r=Tn(i,y("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:De({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:r})}}}async function qj({data:t,state:e,api:n}){try{let{email:i,name:r,giftToken:l}=t;if(r=r?.trim(),e.member){await n.gift.redeem({token:l});const g=await n.member.sessionData(),v=Oo({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:e,message:ah({member:g})});return Vn(),{action:"redeemGift:success",member:g,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:v,notificationSequence:v.count}}const u=await n.member.getIntegrityToken(),m=new URL(e?.site?.url||window.location.href);m.search=new URLSearchParams({giftRedemption:"true"}).toString(),m.hash="";const{otc_ref:p,inboxLinks:f}=await n.member.sendMagicLink({email:(i||"").trim(),emailType:"subscribe",integrityToken:u,includeOTC:!0,redirect:m.href,giftToken:l,...r?{name:r}:{}});return{page:"magiclink",lastPage:"gift",...p?{otcRef:p}:{},inboxLinks:f,pageData:{...e.pageData||{},email:(i||"").trim(),redirect:m.href}}}catch(i){const r=Oo({type:"giftRedeem",status:"error",autoHide:!1,closeable:!0,state:e,message:vs(i)});return Vn(),{action:"redeemGift:failed",showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:r,notificationSequence:r.count}}}async function Zj({data:t,state:e,api:n}){try{let{plan:i,offerId:r,tierId:l,cadence:u}=t;(!l||!u)&&({tierId:l,cadence:u}=Io({site:e?.site,priceId:i})),await n.member.checkoutPlan({plan:i,tierId:l,cadence:u,offerId:r,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:De({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Jj({state:t,api:e}){try{await e.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:De({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Kj({data:t,state:e,api:n}){try{const{tierId:i,cadence:r,email:l}=t;return await n.member.checkoutGift({tierId:i,cadence:r,...l?{email:l}:{}}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:De({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Xj({data:t,state:e,api:n}){try{const{plan:i,planId:r,subscriptionId:l,cancelAtPeriodEnd:u}=t,{tierId:m,cadence:p}=Io({site:e?.site,priceId:r});await n.member.updateSubscription({planName:i,tierId:m,cadence:p,subscriptionId:l,cancelAtPeriodEnd:u,planId:r});const f=await n.member.sessionData(),g="updateSubscription:success";return{action:g,popupNotification:De({type:g,autoHide:!0,closeable:!0,state:e,status:"success",message:y("Subscription plan updated successfully")}),page:"accountHome",member:f}}catch{return{action:"updateSubscription:failed",popupNotification:De({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to update subscription, please try again")})}}}async function Qj({data:t,state:e,api:n}){try{const{subscriptionId:i,cancellationReason:r}=t;return await n.member.updateSubscription({subscriptionId:i,smartCancel:!0,cancellationReason:r}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:De({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to cancel subscription, please try again")})}}}async function _j({data:t,state:e,api:n}){try{const{subscriptionId:i}=t;return await n.member.updateSubscription({subscriptionId:i,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:De({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to cancel subscription, please try again")})}}}async function eT({data:t,state:e,api:n}){try{const{offerId:i,subscriptionId:r}=t;return await n.member.applyOffer({offerId:i,subscriptionId:r}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:De({type:"applyOffer:success",autoHide:!0,closeable:!0,state:e,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:De({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:"Failed to apply offer, please try again"})}}}async function tT({data:t,state:e,api:n}){try{await n.member.editBilling(t)}catch{return{action:"editBilling:failed",popupNotification:De({type:"editBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to update billing information, please try again")})}}}async function nT({data:t,state:e,api:n}){try{await n.member.manageBilling(t)}catch{return{action:"manageBilling:failed",popupNotification:De({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to open billing portal, please try again")})}}}async function aT(){return{popupNotification:null}}async function iT({data:t,state:e}){let{action:n,message:i=""}=t;return n=n||"showPopupNotification:success",{popupNotification:De({type:n,autoHide:!0,closeable:!0,state:e,status:"success",message:i})}}async function oT({data:t,state:e,api:n}){try{const{newsletters:i,enableCommentNotifications:r,enableUpdatesAndAnnouncements:l}=t;if(!i&&r===void 0&&l===void 0)return{};const u={};return i&&(u.newsletters=i),r!==void 0&&(u.enableCommentNotifications=r),l!==void 0&&(u.enableUpdatesAndAnnouncements=l),{action:"updateNewsletterPref:success",member:await n.member.update(u)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:De({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:y("Failed to update newsletter settings")})}}}async function rT({state:t,api:e}){try{return await e.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:De({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:t,status:"success",message:y("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:De({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:y("Your email has failed to resubscribe, please try again")})}}}async function sT({data:t,state:e,api:n}){try{const{subscribed:i}=t,r=await n.member.update({subscribed:i});if(!r)throw new Error("Failed to update newsletter");const l="updateNewsletter:success";return{action:l,member:r,popupNotification:De({type:l,autoHide:!0,closeable:!0,state:e,status:"success",message:y("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:De({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:y("Failed to update newsletter settings")})}}}async function lT({data:t,state:e,api:n}){const{email:i}=t,r=mS({member:e.member});if(i!==r)try{return await n.member.updateEmailAddress({email:i}),{success:!0}}catch(l){return{success:!1,error:l}}return null}async function cT({data:t,state:e,api:n}){const i=t?.name?.trim();if(hS({member:e.member})!==i)try{const l=await n.member.update({name:i});if(!l)throw new Error("Failed to update member");return{member:l,success:!0}}catch(l){return{success:!1,error:l}}return null}async function uT({state:t,api:e}){if(t.member)try{const n=await e.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function dT({data:t,state:e,api:n}){const[i,r]=await Promise.all([cT({data:t,state:e,api:n}),lT({data:t,state:e,api:n})]);if(i&&r){if(r.success)return{action:"updateProfile:success",...i.success?{member:i.member}:{},page:"accountHome",popupNotification:De({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:y("Check your inbox to verify email update")})};const l=i.success?y("Failed to send verification email"):y("Failed to update account data");return{action:"updateProfile:failed",...i.success?{member:i.member}:{},popupNotification:De({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:l,state:e})}}else if(i){const l=i.success?"updateProfile:success":"updateProfile:failed",u=i.success?"success":"error",m=i.success?y("Account details updated successfully"):y("Failed to update account details");return{action:l,...i.success?{member:i.member}:{},...i.success?{page:"accountHome"}:{},popupNotification:De({type:l,autoHide:i.success,closeable:!0,status:u,state:e,message:m})}}else if(r){const l=r.success?"updateProfile:success":"updateProfile:failed",u=r.success?"success":"error";let m="";return r.error?m=Tn(r.error,y("Failed to send verification email")):m=y("Check your inbox to verify email update"),{action:l,...r.success?{page:"accountHome"}:{},popupNotification:De({type:l,autoHide:r.success,closeable:!0,status:u,state:e,message:m})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:De({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:y("Account details updated successfully")})}}async function mT({data:{siteUrl:t},state:e}){const n=Es({siteUrl:t,apiUrl:"not-defined"}),{member:i}=e,r=window.location.href,l=Op(),u=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:i.name,email:i.email,autoRedirect:!1,integrityToken:u,customUrlHistory:e.site.outbound_link_tagging?[{time:Date.now(),referrerSource:l,referrerMedium:"Ghost Recommendations",referrerUrl:r}]:[]}),{}}function pT({data:{recommendationId:t},api:e}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),i=n?JSON.parse(n):[];if(i.includes(t))return;i.push(t),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(i))}catch{}return e.recommendations.trackClicked({recommendationId:t}),{}}async function hT({data:{recommendationId:t},api:e}){return e.recommendations.trackSubscribed({recommendationId:t}),{}}const fT={togglePopup:Fj,openPopup:Rj,closePopup:_h,switchPage:Yj,openNotification:$j,closeNotification:Uj,back:Lj,signout:Bj,signin:Wj,startSigninOTCFromCustomForm:Gj,verifyOTC:Vj,signup:Hj,redeemGift:qj,updateSubscription:Xj,cancelSubscription:Qj,continueSubscription:_j,applyOffer:eT,updateNewsletter:sT,updateProfile:dT,refreshMemberData:uT,clearPopupNotification:aT,editBilling:tT,manageBilling:nT,checkoutPlan:Zj,continueGiftSubscription:Jj,checkoutGift:Kj,updateNewsletterPreference:oT,showPopupNotification:iT,removeEmailFromSuppressionList:rT,oneClickSubscribe:mT,trackRecommendationClicked:pT,trackRecommendationSubscribed:hT};async function gT({action:t,data:e,state:n,api:i}){const r=fT[t];return r?await r({data:e,state:n,api:i})||{}:{}}function ef(t,e){t&&(t.innerText=e)}function bT(t,e,n){e.classList.add("error");const i=y("There was an error sending the email, please try again");ef(n,Tn(t,i))}async function yT({event:t,form:e,errorEl:n,siteUrl:i,submitHandler:r,doAction:l,captureException:u}){e.removeEventListener("submit",r),t.preventDefault(),n&&(n.innerText=""),e.classList.remove("success","invalid","error");let m=t.target.querySelector("input[data-members-email]"),p=t.target.querySelector("input[data-members-name]"),f=e?.dataset?.membersAutoredirect||"true",g=m?.value,v=(p?.value||"").trim()||void 0,k,x=[],j=[],T=t.target.querySelectorAll("input[data-members-label]")||[];for(let $=0;$<T.length;++$)x.push(T[$].value);let z=t.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let $=0;$<z.length;++$)j.push({name:z[$].value});e.dataset.membersForm&&(k=e.dataset.membersForm);const D=k==="signin"&&e?.dataset?.membersOtc==="true";e.classList.add("loading");const R=bi(),G={email:g,emailType:k,labels:x,name:v,autoRedirect:f==="true"};D&&(G.includeOTC=!0),R&&(G.urlHistory=R),z.length>0?G.newsletters=j:(t.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(G.newsletters=[]);try{const Y=await(await fetch(`${i}/members/api/integrity-token/`,{method:"GET"})).text(),V=await fetch(`${i}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...G,integrityToken:Y})});if(e.addEventListener("submit",r),e.classList.remove("loading"),V.ok){e.classList.add("success");let K;if(D)try{K=await V.clone().json()}catch{K=void 0}const _=K?.otc_ref;if(_&&typeof l=="function")try{l("startSigninOTCFromCustomForm",{email:(g||"").trim(),otcRef:_,inboxLinks:K?.inboxLinks})}catch(le){console.error(le),u?.(le)}}else{const K=await Qt.fromApiResponse(V),_=Tn(K,y("Failed to send magic link email"));ef(n,_),e.classList.add("error")}}catch($){bT($,e,n)}}function kT({event:t,el:e,errorEl:n,siteUrl:i,site:r,member:l,clickHandler:u}){e.removeEventListener("click",u),t.preventDefault();let m=e.dataset.membersPlan,p=tS(r,m.toLowerCase()),f=e.dataset.membersSuccess,g=e.dataset.membersCancel,v,k;f&&(v=new URL(f,window.location.href).href),g&&(k=new URL(g,window.location.href).href),n&&(n.innerText=""),e.classList.add("loading");const x=l?{checkoutType:"upgrade"}:{},j=bi();return j&&(x.urlHistory=j),fetch(`${i}/members/api/session`,{credentials:"same-origin"}).then(function(T){return T.ok?T.text():null}).then(function(T){return fetch(`${i}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,identity:T,successUrl:v,cancelUrl:k,metadata:x})}).then(function(z){if(!z.ok)throw new Error(y("Could not create Stripe checkout session"));return z.json()})}).then(function(T){return T.url?window.location.assign(T.url):window.Stripe(T.publicKey).redirectToCheckout({sessionId:T.sessionId}).then(function(D){if(D.error)throw new Error(D.error.message)})}).catch(function(T){console.error(T),e.addEventListener("click",u),e.classList.remove("loading"),n&&(n.innerText=T.message),e.classList.add("error")})}function vT({siteUrl:t,site:e={},member:n,offers:i=[],doAction:r,captureException:l}={}){if(!t)return;t=t.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(m){let p=m.querySelector("[data-members-error]");function f(g){yT({event:g,errorEl:p,form:m,siteUrl:t,submitHandler:f,doAction:r,captureException:l})}m.addEventListener("submit",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(m){let p=m.querySelector("[data-members-error]");function f(g){kT({el:m,event:g,errorEl:p,member:n,site:e,siteUrl:t,clickHandler:f})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(m){let p=m.querySelector("[data-members-error]"),f=m.dataset.membersSuccess,g=m.dataset.membersCancel,v,k;f&&(v=new URL(f,window.location.href).href),g&&(k=new URL(g,window.location.href).href);function x(j){m.removeEventListener("click",x),j.preventDefault(),p&&(p.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(T){return T.ok?T.text():null}).then(function(T){return fetch(`${t}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:T,successUrl:v,cancelUrl:k})}).then(function(z){if(!z.ok)throw new Error(y("Could not create Stripe checkout session"));return z.json()})}).then(function(T){return window.Stripe(T.publicKey).redirectToCheckout({sessionId:T.sessionId})}).then(function(T){if(T.error)throw new Error(y(T.error.message))}).catch(function(T){console.error(T),m.addEventListener("click",x),m.classList.remove("loading"),p&&(p.innerText=T.message),m.classList.add("error")})}m.addEventListener("click",x)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(m){let p=m.querySelector("[data-members-error]"),f=m.dataset.membersReturn,g;f&&(g=new URL(f,window.location.href).href);function v(k){m.removeEventListener("click",v),k.preventDefault(),p&&(p.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,returnUrl:g})}).then(function(j){if(!j.ok)throw new Error(y("Could not create Stripe billing portal session"));return j.json()})}).then(function(x){return window.location.assign(x.url)}).catch(function(x){console.error(x),m.addEventListener("click",v),m.classList.remove("loading"),p&&(p.innerText=x.message),m.classList.add("error")})}m.addEventListener("click",v)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(m){function p(f){m.removeEventListener("click",p),f.preventDefault(),m.classList.remove("error"),m.classList.add("loading"),fetch(`${t}/members/api/session`,{method:"DELETE"}).then(function(g){g.ok?window.location.replace(t):(m.addEventListener("click",p),m.classList.remove("loading"),m.classList.add("error"))})}m.addEventListener("click",p)});const u=(i||[]).some(m=>m.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(m){let p=m.parentElement.querySelector("[data-members-error]");function f(g){g.preventDefault();let v=m.dataset.membersCancelSubscription;if(u){r("openPopup",{page:"accountPlan",pageData:{subscriptionId:v,action:"cancel"}});return}return m.removeEventListener("click",f),m.classList.remove("error"),m.classList.add("loading"),p&&(p.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(k){return k.ok?k.text():null}).then(function(k){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:k,smart_cancel:!0})})}).then(function(k){k.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),p&&(p.innerText=y("There was an error cancelling your subscription, please try again.")))})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(m){let p=m.parentElement.querySelector("[data-members-error]");function f(g){m.removeEventListener("click",f),g.preventDefault(),m.classList.remove("error"),m.classList.add("loading");let v=m.dataset.membersContinueSubscription;return p&&(p.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(k){return k.ok?k.text():null}).then(function(k){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:k,cancel_at_period_end:!1})})}).then(function(k){k.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),p&&(p.innerText=y("There was an error continuing your subscription, please try again.")))})}m.addEventListener("click",f)})}const tf=t=>{try{return decodeURIComponent(t)}catch{return null}},wT={staleGiftRedemptionRequest:!0},xT={showPopup:!0,site:zs,member:Pi.free,page:"accountEmail",...Oj(),pageData:Qh};function ST({site:t,children:e}){const{portal_sentry:n}=t||{};return n&&n.dsn?c.jsx(bc,{children:e}):c.jsx(c.Fragment,{children:e})}class CT extends Pe.Component{constructor(e){super(e),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,n){if(n.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"&&n.initStatus!==this.state.initStatus){const{siteUrl:i}=this.props,r=this.getContextFromState();this.sendPortalReadyEvent(),vT({siteUrl:i,site:r.site,member:r.member,offers:r.offers,doAction:r.doAction,captureException:wo})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(e=>{e.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e),document.body.appendChild(e);const n=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),n}setupCustomTriggerButton(){this.clickHandler=async i=>{i.preventDefault();const r=i.currentTarget,l=r&&r.dataset.portal,u=this.getPageFromLinkPath(l);if(!u)return;const{page:m,pageQuery:p,pageData:f}=u;if(this.state.initStatus==="success"){if(m==="gift"&&!fi({site:this.state.site})){this.invalidateGiftRedemptionRequest(),Vn();return}if(m==="giftRedemption"&&f?.token){const g=this.startGiftRedemptionRequest(f.token),v=await this.fetchGiftRedemptionData({token:f.token});if(!this.isCurrentGiftRedemptionRequest(g))return;this.setState(v);return}this.invalidateGiftRedemptionRequest(),p&&p!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:p}):this.dispatchAction("openPopup",{page:m,pageQuery:p,pageData:f})}};const e="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(e)||[],this.customTriggerButtons.forEach(i=>{i.classList.add(n),i.removeEventListener("click",this.clickHandler),i.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){const e="gh-portal-open",n="gh-portal-close";this.customTriggerButtons?.forEach(i=>{const r=this.state.showPopup?e:n,l=this.state.showPopup?n:e;i.classList.add(r),i.classList.remove(l)})}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:n}){return this._redemptionRequestId===e&&this.currentRedemptionToken===n}async initSetup(){try{const{site:e,member:n,offers:i,page:r,showPopup:l,popupNotification:u,notification:m,notificationSequence:p,lastPage:f,pageQuery:g,pageData:v}=await this.fetchData(),k=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||"en";as.changeLanguage(k);const x={site:e,member:n,offers:i,page:r,lastPage:f,pageQuery:g,showPopup:l,pageData:v,popupNotification:u,notification:m,notificationSequence:p,dir:as.dir()||"ltr",action:"init:success",initStatus:"success",locale:k};if(this.setState(x,()=>{this.handleSignupQuery({site:e,pageQuery:g,member:n})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const j=document.querySelectorAll("[data-lexical-signup-form]");j.length>0&&j.forEach(T=>{T.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error("[Portal] Failed to initialize:",e),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:e,member:n,offers:i}=await this.fetchApiData(),{site:r,...l}=this.fetchDevData(),u=await this.fetchLinkData(e,n),{site:m,...p}=u?.staleGiftRedemptionRequest?{}:u,{site:f,...g}=this.fetchPreviewData(),{site:v,...k}=this.fetchNotificationData();return{member:n,offers:i,page:"",site:{...e,...m,...f,...v,...r,plans:{...(r||{}).plans,...(e||{}).plans,...(f||{}).plans}},...l,...p,...k,...g}}fetchDevData(){return Ze(["dev"])&&!this.state.customSiteUrl?xT:Ze(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(e=""){const n=new URLSearchParams(e),i={};for(let r of n.entries()){const l=r[0],u=decodeURIComponent(r[1]);l==="name"?i.name=u||"":l==="code"?i.code=u||"":l==="display_title"?i.display_title=u||"":l==="display_description"?i.display_description=u||"":l==="type"?i.type=u||"":l==="cadence"?i.cadence=u||"":l==="duration"?i.duration=u||"":l==="duration_in_months"&&!isNaN(Number(u))?i.duration_in_months=Number(u):l==="amount"&&!isNaN(Number(u))?i.amount=Number(u):l==="currency"?i.currency=u||"":l==="status"?i.status=u||"":l==="tier_id"?i.tier={id:u||Qh.tier.id}:l==="redemption_type"&&(i.redemption_type=u||"signup")}if(i.redemption_type==="retention"){const r=Pi.preview?.subscriptions?.[0]?.id;return{page:"accountPlan",offers:[i],pageData:{action:"cancel",subscriptionId:r}}}return{page:"offer",pageData:i}}fetchQueryStrData(e=""){const n=new URLSearchParams(e),i={site:{plans:{}}},r=[];let l,u=null,m,p,f;for(let g of n.entries()){const v=g[0],k=decodeURIComponent(g[1]);if(v==="button")i.site.portal_button=JSON.parse(k);else if(v==="name")i.site.portal_name=JSON.parse(k);else if(v==="isFree"&&JSON.parse(k))r.push("free");else if(v==="isMonthly"&&JSON.parse(k))r.push("monthly");else if(v==="isYearly"&&JSON.parse(k))r.push("yearly");else if(v==="portalPrices")l=k?k.split(","):[];else if(v==="portalProducts")u=k?k.split(","):[];else if(v==="page"&&k)i.page=k;else if(v==="accentColor"&&(k===""||k))i.site.accent_color=k;else if(v==="buttonIcon"&&k)i.site.portal_button_icon=k;else if(v==="signupButtonText")i.site.portal_button_signup_text=k||"";else if(v==="signupTermsHtml")i.site.portal_signup_terms_html=k||"";else if(v==="signupCheckboxRequired")i.site.portal_signup_checkbox_required=JSON.parse(k);else if(v==="buttonStyle"&&k)i.site.portal_button_style=k;else if(v==="monthlyPrice"&&!isNaN(Number(k)))i.site.plans.monthly=Number(k),m=Number(k);else if(v==="yearlyPrice"&&!isNaN(Number(k)))i.site.plans.yearly=Number(k),p=Number(k);else if(v==="currency"&&k){const x=k.toUpperCase();i.site.plans.currency=x,i.site.plans.currency_symbol=_e(x),f=x}else v==="disableBackground"?i.site.disableBackground=JSON.parse(k):v==="membersSignupAccess"&&k?i.site.members_signup_access=k:v==="portalDefaultPlan"&&k?i.site.portal_default_plan=k:v==="transistorPortalSettings"&&k&&(i.site.transistor_portal_settings=JSON.parse(k))}return i.site.portal_plans=r,i.site.portal_products=u,l?i.site.portal_plans=l:m&&p&&f&&(i.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:f,amount:m,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:f,amount:p,type:"recurring",interval:"year"}]),i}fetchNotificationData(){const{type:e,status:n,duration:i,autoHide:r,closeable:l}=oh({billingOnly:!0})||{};return["stripe:billing-update"].includes(e)?n==="success"?{showPopup:!0,popupNotification:De({type:e,status:n,duration:i,closeable:l,autoHide:r,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{const n=await this.GhostApi.gift.fetchRedemptionData({token:e});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:e,gift:n?.gifts?.[0]||null}}}catch(n){Vn();const i=Oo({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:vs(n)});return{showPopup:!1,pageData:null,notification:i,notificationSequence:i.count}}}async fetchLinkData(e,n){this.invalidateGiftRedemptionRequest();const i=new URLSearchParams(window.location.search);if(i.get("stripe")==="gift-purchase-success"){const j=i.get("gift_token"),T=i.get("gift_tier"),z=i.get("gift_cadence");if(ws(["stripe","gift_token","gift_tier","gift_cadence"]),j)return{showPopup:!0,page:"giftSuccess",pageData:{token:j,tierId:T,cadence:z}}}if(i.get("action")==="unsubscribe")return i.get("key")&&i.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:i.get("uuid"),key:i.get("key"),newsletterUuid:i.get("newsletter"),comments:i.get("comments"),updatesAndAnnouncements:i.get("updatesandannouncements")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:i.get("newsletter"),action:"unsubscribe",redirect:e.url+"#/portal/account/newsletters"}};if(iS({site:e})&&i.get("action")==="signup"&&i.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[r,l]=window.location.hash.substr(1).split("?"),u=new URLSearchParams(l??""),m=/^(?:(\w+?))?\/monthly$/,p=/^(?:(\w+?))?\/yearly$/,f=/^offers\/(\w+?)\/?$/,g=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,v=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,k=/^\/share\/?$/,x=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(r&&x.test(r)){const[,j,T]=r.match(x),z=parseInt(T);if(z===1||z===0)return n||u.get("uuid")&&u.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:u.get("uuid"),key:n?null:u.get("key"),postId:j,score:z}}:{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/feedback/${j}/${z}/`}}}if(r&&g.test(r)){const[,j]=r.match(g),T=tf(j);if(!T)return{};const z=this.startGiftRedemptionRequest(T),D=await this.fetchGiftRedemptionData({token:T});return this.isCurrentGiftRedemptionRequest(z)?D:wT}if(r&&k.test(r))return{showPopup:!0,page:"share"};if(r&&v.test(r)){const[,j]=r.match(v),{page:T,pageQuery:z,pageData:D}=this.getPageFromLinkPath(j,e)||{};if(!n&&T&&Vh({page:T}))return{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/portal/${j}/`}};if(T==="gift"&&!fi({site:e}))return Vn(),{};const R=["accountPlan","accountProfile"].includes(T)?"accountHome":null,G=!(["monthly","yearly"].includes(z)||m.test(z)||p.test(z)||f.test(z)),$=u.get("redirect"),Y=T==="signin"&&$?{...D||{},redirect:$}:D;return{showPopup:G,...T?{page:T}:{},...z?{pageQuery:z}:{},...Y?{pageData:Y}:{},...R?{lastPage:R}:{}}}return{}}fetchPreviewData(){const[,e]=window.location.hash.substr(1).split("?");if(Ze(["preview"])){let n={};try{Ze(["offerPreview"])?n=this.fetchOfferQueryStrData(e):n=this.fetchQueryStrData(e)}catch(i){return wo(i),{}}return{...n,showPopup:!0}}return{}}getColorOverride(){const e=document.querySelector("script[data-ghost]");return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:e,customSiteUrl:n,apiUrl:i,apiKey:r}=this.props;try{this.GhostApi=this.props.api||Es({siteUrl:e,apiUrl:i,apiKey:r});const{site:l,member:u,offers:m}=await this.GhostApi.init(),p=this.getColorOverride();return p&&(l.accent_color=p),this.setupFirstPromoter({site:l,member:u}),this.setupSentry({site:l}),{site:l,member:u,offers:m}}catch(l){if(Ze(["dev","test"],{customSiteUrl:n}))return{};throw l}}setupSentry({site:e}){if(Ze(["test"]))return null;const{portal_sentry:n,portal_version:i,version:r}=e,u=`portal@2.69.68|ghost@${r}`;n&&n.dsn&&Zv({dsn:n.dsn,environment:n.env||"development",release:u,beforeSend:m=>Zx({event:m})?m:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:n}){if(Ze(["test"]))return null;const i=pS({site:e});let r=Nc({site:e});if(r=r?.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),i&&r){const l=document.createElement("script");l.type="text/javascript",l.async=!0,l.src="https://cdn.firstpromoter.com/fprom.js",l.onload=l.onreadystatechange=function(){let m=this.readyState;if(!m||m==="complete"||m==="loaded")try{if(window.$FPROM.init(i,r),CS({member:n})){const p=n.email,f=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:p,uid:f});else{const g=window._fprom||[];window._fprom=g,g.push(["event","signup"]),g.push(["email",p]),g.push(["uid",f])}}}catch{}};const u=document.getElementsByTagName("script")[0];u.parentNode.insertBefore(l,u)}}async dispatchAction(e,n){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{const i=await gT({action:e,data:n,state:this.state,api:this.GhostApi});this.setState(i),i&&i.action&&!i.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(i){if(console.error(`[Portal] Failed to dispatch action: ${e}`,i),n&&n.throwErrors)throw i;const r=De({type:`${e}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:i}});this.setState({action:`${e}:failed`,actionErrorMessage:Tn(i,y("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:r})}}async updateStateForPreviewLinks(){const{site:e,...n}=this.fetchPreviewData(),i=await this.fetchLinkData(this.state.site,this.state.member);if(i?.staleGiftRedemptionRequest)return;const{site:r,...l}=i,u={site:{...this.state.site,...r||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(r||{}).plans,...(e||{}).plans}},...l,...n};this.handleSignupQuery({site:u.site,pageQuery:u.pageQuery}),this.setState(u)}async handleOfferQuery({site:e,offerId:n,member:i=this.state.member}){if(Vn(),!(!dn({member:i})||Hn({member:i}))){const l=Oo({type:"offer:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:y("You already have an active subscription.")});await this.dispatchAction("closePopup"),this.setState({notification:l,notificationSequence:l.count});return}try{const u=(await this.GhostApi.site.offer({offerId:n}))?.offers[0];if(!u||!u.tier||Oc({offer:u})||!yS({site:e,offer:u}))return;this.dispatchAction("openPopup",{page:"offer",pageData:u})}catch{}}handleSignupQuery({site:e,pageQuery:n,member:i}){const r=/^offers\/(\w+?)\/?$/;let l=n;if(r.test(n||"")){const[,m]=n.match(r);this.handleOfferQuery({site:e,offerId:m,member:i});return}Rp({site:e,pageQuery:n})&&(l=Rp({site:e,pageQuery:n}));const u=nS({site:e,priceId:l});if(n&&n!=="free"){Vn();const m=u?.id||l;m!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:p,cadence:f}=Io({site:e,priceId:m});this.dispatchAction("signup",{plan:m,tierId:p,cadence:f})}}getPageFromLinkPath(e){const n=/^signup\/?(?:\/(\w+?))?\/?$/,i=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,r=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,l=/^offers\/(\w+?)\/?$/,u=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e==="")return{page:"default"};if(u.test(e)){const[,m]=e.match(u),p=tf(m);return p?{page:"giftRedemption",pageData:{token:p}}:null}else{if(l.test(e))return{pageQuery:e};if(e==="signup")return{page:"signup"};if(i.test(e)){const[,m]=e.match(i);return{page:"signup",pageQuery:`${m}/monthly`}}else if(r.test(e)){const[,m]=e.match(r);return{page:"signup",pageQuery:`${m}/yearly`}}else if(n.test(e)){const[,m]=e.match(n);return{page:"signup",pageQuery:m}}else{if(e==="signup/free")return{page:"signup",pageQuery:"free"};if(e==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(e==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(e==="signin")return{page:"signin"};if(e==="account")return{page:"accountHome"};if(e==="account/plans")return{page:"accountPlan"};if(e==="account/profile")return{page:"accountProfile"};if(e==="account/newsletters")return{page:"accountEmail"};if(e==="support")return{page:"support"};if(e==="support/success")return{page:"supportSuccess"};if(e==="support/error")return{page:"supportError"};if(e==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(e==="gift")return{page:"gift"};if(e==="share")return{page:"share"};if(e==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(e==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}}return{page:"default"}}getAccentColor(){const{accent_color:e}=this.state.site||{};return vE(e)}getRetentionPreviewMember({site:e,offers:n}){const i=(n||[]).find(f=>Oc({offer:f})),r=i?.tier?.id,l=r?Na({site:e,productId:r}):null,u=l?i.cadence==="year"?l.yearlyPrice:l.monthlyPrice:null,m=Pi.preview,p=m?.subscriptions?.[0];return!p||!l||!u?m:{...m,subscriptions:[{...p,plan:{...p.plan,amount:u.amount,interval:u.interval,currency:u.currency.toUpperCase()},price:{...p.price,price_id:u.id,amount:u.amount,interval:u.interval,currency:u.currency,product:{...p.price?.product,product_id:l.id}},tier:{id:l.id,name:l.name}}]}}getContextPage({site:e,page:n,member:i}){if(!n||n==="default"){const r=pn({site:e})||!Pn({site:e})?"signin":"signup";n=i?"accountHome":r}return ru({page:n})}getContextMember({site:e,page:n,member:i,offers:r,pageData:l,customSiteUrl:u}){return Ze(["dev","preview"],{customSiteUrl:u})?Vh({page:n})||Sj({page:n})?Ze(["dev"],{customSiteUrl:u})?i||Pi.free:Ze(["preview"])?n==="accountPlan"&&l?.action==="cancel"?this.getRetentionPreviewMember({site:e,offers:r}):Pi.preview:Pi.paid:null:i}getContextFromState(){const{site:e,member:n,offers:i,action:r,actionErrorMessage:l,page:u,lastPage:m,showPopup:p,pageQuery:f,pageData:g,popupNotification:v,notification:k,customSiteUrl:x,dir:j,scrollbarWidth:T,otcRef:z,inboxLinks:D}=this.state,R=this.getContextPage({site:e,page:u,member:n}),G=this.getContextMember({site:e,page:R,member:n,offers:i,pageData:g,customSiteUrl:x});return{api:this.GhostApi,site:e,offers:i,action:r,actionErrorMessage:l,brandColor:this.getAccentColor(),page:R,pageQuery:f,pageData:g,member:G,lastPage:m,showPopup:p,popupNotification:v,notification:k,customSiteUrl:x,dir:j,scrollbarWidth:T,otcRef:z,inboxLinks:D,doAction:($,Y)=>this.dispatchAction($,Y)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const e=i=>{const r=i.currentTarget.dataset.recommendation;r?this.dispatchAction("trackRecommendationClicked",{recommendationId:r}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const i of n)i.addEventListener("click",e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"], a[href*="#/share"]').forEach(Aj)}render(){return this.state.initStatus==="success"?c.jsx(ST,{site:this.state.site,children:c.jsxs(Q.Provider,{value:this.getContextFromState(),children:[c.jsx(Tj,{}),c.jsx(PS,{}),c.jsx(QS,{})]})}):null}}const nf="ghost-portal-root";function ET(){const t=document.createElement("div");t.id=nf,t.setAttribute("data-testid","portal-root"),document.body.appendChild(t)}function jT(){const t=document.querySelector("script[data-ghost]");if(t){const e=t.dataset.i18n==="true",n=t.dataset.ghost,i=t.dataset.key,r=t.dataset.api,l=t.dataset.locale;return{siteUrl:n,apiKey:i,apiUrl:r,siteI18nEnabled:e,locale:l}}return{}}function TT(){const t=new URL(window.location.href);t.searchParams.get("token")&&(t.searchParams.delete("token"),window.history.replaceState({},document.title,t.href))}function PT(){const{siteUrl:t,apiKey:e,apiUrl:n,siteI18nEnabled:i,locale:r}=jT(),l=t||window.location.origin;ET(),TT(),mb.render(c.jsx(Pe.StrictMode,{children:c.jsx(CT,{siteUrl:l,customSiteUrl:t,apiKey:e,apiUrl:n,siteI18nEnabled:i,locale:r})}),document.getElementById(nf))}PT()}));
|
|
4570
|
+
`),i=[];return t&&i.push(`subject=${encodeURIComponent(t)}`),n&&i.push(`body=${encodeURIComponent(n)}`),`mailto:${i.length?`?${i.join("&")}`:""}`},pj=({shareTitle:t,shareUrl:e})=>Vo("https://www.linkedin.com/shareArticle",{mini:"true",url:e,title:t}),hj=()=>{const t=dj(),e=t.document,n=t.location,i=(j,T="content")=>e.querySelector(j)?.[T]||"",r=i('link[rel="canonical"]',"href")||n.origin+n.pathname+n.search,l=i('meta[property="og:title"]')||e.title||"",u=i('meta[property="og:description"]')||i('meta[name="description"]')||"",m=i('meta[property="og:image"]')||i('meta[name="twitter:image"]')||"",p=i('link[rel="icon"]',"href")||i('link[rel="shortcut icon"]',"href")||i('link[rel="apple-touch-icon"]',"href"),f=i('meta[name="author"]'),g=(f&&!/^https?:\/\//i.test(f)?f:"")||i('meta[name="twitter:creator"]')||"";let v=i('meta[property="og:site_name"]')||i('meta[name="application-name"]')||"";if(!v)try{v=new URL(r).hostname.replace(/^www\./,"")}catch{v=""}const k=[l,r].filter(Boolean).join(" ").trim(),x={twitter:Vo("https://twitter.com/intent/tweet",{url:r,text:l}),facebook:Vo("https://www.facebook.com/sharer/sharer.php",{u:r}),email:mj({shareTitle:l,shareUrl:r}),threads:Vo("https://www.threads.net/intent/post",{text:k}),linkedin:pj({shareTitle:l,shareUrl:r}),bluesky:Vo("https://bsky.app/intent/compose",{text:k})};return{shareUrl:r,shareTitle:l,shareExcerpt:u,shareImage:m,shareFavicon:p,shareSiteName:v,shareAuthor:g,socialLinks:x}},fj=()=>{const[t]=C.useState(hj);return t},gj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -3.268 64 68.414",width:2232,height:2500,...t},C.createElement("path",{fill:"#0085ff",d:"M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805zm36.254 0C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745z"})),bj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-ellipsis-icon lucide-ellipsis",...t},C.createElement("circle",{cx:12,cy:12,r:1}),C.createElement("circle",{cx:19,cy:12,r:1}),C.createElement("circle",{cx:5,cy:12,r:1})),yj=t=>C.createElement("svg",{id:"svg9",width:666.66669,height:666.66718,viewBox:"0 0 666.66668 666.66717",xmlns:"http://www.w3.org/2000/svg","xmlns:svg":"http://www.w3.org/2000/svg",...t},C.createElement("defs",{id:"defs13"},C.createElement("clipPath",{clipPathUnits:"userSpaceOnUse",id:"clipPath25"},C.createElement("path",{d:"M 0,700 H 700 V 0 H 0 Z",id:"path23"}))),C.createElement("g",{id:"g17",transform:"matrix(1.3333333,0,0,-1.3333333,-133.33333,799.99999)"},C.createElement("g",{id:"g19"},C.createElement("g",{id:"g21",clipPath:"url(#clipPath25)"},C.createElement("g",{id:"g27",transform:"translate(600,350)"},C.createElement("path",{d:"m 0,0 c 0,138.071 -111.929,250 -250,250 -138.071,0 -250,-111.929 -250,-250 0,-117.245 80.715,-215.622 189.606,-242.638 v 166.242 h -51.552 V 0 h 51.552 v 32.919 c 0,85.092 38.508,124.532 122.048,124.532 15.838,0 43.167,-3.105 54.347,-6.211 V 81.986 c -5.901,0.621 -16.149,0.932 -28.882,0.932 -40.993,0 -56.832,-15.528 -56.832,-55.9 V 0 h 81.659 l -14.028,-76.396 h -67.631 V -248.169 C -95.927,-233.218 0,-127.818 0,0",style:{fill:"#0866ff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path29"})),C.createElement("g",{id:"g31",transform:"translate(447.9175,273.6036)"},C.createElement("path",{d:"M 0,0 14.029,76.396 H -67.63 v 27.019 c 0,40.372 15.838,55.899 56.831,55.899 12.733,0 22.981,-0.31 28.882,-0.931 v 69.253 c -11.18,3.106 -38.509,6.212 -54.347,6.212 -83.539,0 -122.048,-39.441 -122.048,-124.533 V 76.396 h -51.552 V 0 h 51.552 v -166.242 c 19.343,-4.798 39.568,-7.362 60.394,-7.362 10.254,0 20.358,0.632 30.288,1.831 L -67.63,0 Z",style:{fill:"#ffffff",fillOpacity:1,fillRule:"nonzero",stroke:"none"},id:"path33"})))))),kj=t=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-link-icon lucide-link",...t},C.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),vj=t=>C.createElement("svg",{viewBox:"0 5 2490 2490.0000000000005",xmlns:"http://www.w3.org/2000/svg",width:2500,height:2495,...t},C.createElement("path",{d:"M185.2 313.1H2252V2291H185.2z",fill:"#fff"}),C.createElement("path",{d:"M0 183.4C0 84.9 82.4 5 184 5h2122c101.6 0 184 79.9 184 178.4v2133.3c0 98.5-82.4 178.3-184 178.3H184c-101.6 0-184-79.8-184-178.3z",fill:"#0a66c2"}),C.createElement("path",{d:"M756.7 2088.8v-1121H384.1v1121zm-186.2-1274c129.9 0 210.8-86.1 210.8-193.7-2.4-110-80.9-193.7-208.3-193.7-127.5 0-210.8 83.7-210.8 193.7 0 107.6 80.8 193.7 205.9 193.7zm392.4 1274h372.6v-626c0-33.5 2.4-67 12.3-90.9 26.9-67 88.2-136.3 191.2-136.3 134.8 0 188.7 102.8 188.7 253.5v599.6h372.6V1446c0-344.3-183.8-504.5-428.9-504.5-201 0-289.2 112.3-338.3 188.8h2.5V967.8H962.9c4.9 105.2 0 1121 0 1121z",fill:"#fff"})),wj=t=>C.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},C.createElement("g",{clipPath:"url(#clip0_351_18008)"},C.createElement("path",{d:"M13.0332 8.37917C12.96 8.34407 12.8856 8.3103 12.8103 8.27795C12.6791 5.86015 11.3579 4.47596 9.1396 4.4618C9.12955 4.46173 9.11955 4.46173 9.1095 4.46173C7.78265 4.46173 6.67913 5.0281 5.99992 6.05871L7.21993 6.89561C7.72733 6.12579 8.52364 5.96167 9.11008 5.96167C9.11686 5.96167 9.12366 5.96168 9.13036 5.96174C9.86078 5.96639 10.4119 6.17876 10.7687 6.59291C11.0283 6.89442 11.2019 7.31107 11.2879 7.8369C10.6403 7.72683 9.93993 7.69299 9.19122 7.73592C7.08214 7.8574 5.72624 9.08747 5.81731 10.7967C5.86352 11.6637 6.29544 12.4096 7.03346 12.8968C7.65745 13.3087 8.46111 13.5101 9.29635 13.4645C10.3994 13.4041 11.2647 12.9832 11.8684 12.2137C12.3268 11.6293 12.6168 10.872 12.7448 9.91782C13.2705 10.2351 13.6601 10.6525 13.8753 11.1544C14.2411 12.0075 14.2624 13.4094 13.1186 14.5523C12.1164 15.5535 10.9117 15.9866 9.09104 16C7.07147 15.9851 5.54409 15.3374 4.55103 14.0749C3.62111 12.8928 3.14053 11.1854 3.1226 9C3.14053 6.8146 3.62111 5.10714 4.55103 3.92503C5.54409 2.66262 7.07144 2.01495 9.09101 1.99994C11.1252 2.01506 12.6792 2.66585 13.7103 3.93435C14.2159 4.55641 14.597 5.3387 14.8483 6.25081L16.278 5.86936C15.9734 4.74665 15.4942 3.7792 14.842 2.97686C13.5201 1.35059 11.5869 0.517279 9.096 0.5H9.08603C6.60019 0.517219 4.68862 1.3537 3.40443 2.98619C2.26168 4.4389 1.67221 6.46024 1.65241 8.99402L1.65234 9L1.65241 9.00598C1.67221 11.5397 2.26168 13.5611 3.40443 15.0138C4.68862 16.6463 6.60019 17.4828 9.08603 17.5H9.096C11.306 17.4847 12.8638 16.9061 14.1472 15.6239C15.8262 13.9465 15.7756 11.8439 15.2222 10.5531C14.8252 9.62749 14.0683 8.8757 13.0332 8.37917ZM9.21739 11.9668C8.29301 12.0188 7.33268 11.6039 7.28533 10.7152C7.25023 10.0563 7.75426 9.32105 9.27412 9.23347C9.44817 9.22343 9.61897 9.21852 9.78676 9.21852C10.3388 9.21852 10.8553 9.27215 11.3248 9.3748C11.1497 11.562 10.1224 11.9171 9.21739 11.9668Z",fill:"black"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_351_18008"},C.createElement("rect",{width:17,height:17,fill:"white",transform:"translate(0.5 0.5)"})))),xj=t=>C.createElement("svg",{viewBox:"0 0 1200 1226.37",xmlns:"http://www.w3.org/2000/svg",width:2446,height:2500,...t},C.createElement("path",{d:"M714.163 519.284L1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284zM569.165 687.828l-47.468-67.894-377.686-540.24h162.604l304.797 435.991 47.468 67.894 396.2 566.721H892.476L569.165 687.854z"})),ou={signin:z1,signup:xE,accountHome:J1,accountPlan:NC,accountProfile:K1,accountEmail:aj,signupNewsletter:Hc,unsubscribe:rj,magiclink:UE,loading:Ei,offer:qE,feedback:t1,emailSuppressed:sj,emailSuppressionFAQ:lj,emailReceivingFAQ:cj,support:uj,supportSuccess:s1,supportError:au,recommendations:w1,gift:LE,giftRedemption:c1,giftSuccess:p1,share:()=>{const[t,e]=C.useState(!1),[n,i]=C.useState(!1),r=C.useRef(),l=C.useRef(null),{shareUrl:u,shareTitle:m,shareExcerpt:p,shareImage:f,shareFavicon:g,shareSiteName:v,shareAuthor:k,socialLinks:x}=fj();C.useEffect(()=>()=>{clearTimeout(r.current)},[]),C.useEffect(()=>{if(!n)return;const D=l.current?.ownerDocument||document,R=$=>{l.current&&!l.current.contains($.target)&&($.stopPropagation(),$.preventDefault(),i(!1))},G=$=>{$.key==="Escape"&&i(!1)};return D.addEventListener("click",R,!0),D.addEventListener("keydown",G),()=>{D.removeEventListener("click",R,!0),D.removeEventListener("keydown",G)}},[n]);const j=async()=>{await Lh(u)&&(e(!0),clearTimeout(r.current),r.current=setTimeout(()=>{e(!1)},2e3))},T=()=>{i(D=>!D)},z=()=>{i(!1)};return c.jsxs("div",{className:"gh-portal-content gh-portal-share",children:[c.jsx(We,{}),c.jsx("div",{className:"gh-portal-share-header",children:c.jsx("h1",{className:"gh-portal-main-title",children:y("Share")})}),c.jsxs("div",{className:"gh-portal-share-preview",children:[f&&c.jsx("img",{className:"gh-portal-share-preview-image",src:f,alt:"","data-testid":"share-preview-image"}),c.jsxs("div",{className:"gh-portal-share-preview-content",children:[m&&c.jsx("h2",{className:"gh-portal-share-preview-title",children:m}),p&&c.jsx("p",{className:"gh-portal-share-preview-excerpt",children:p}),(g||v||k)&&c.jsxs("div",{className:"gh-portal-share-preview-footer",children:[g&&c.jsx("img",{className:"gh-portal-share-preview-favicon",src:g,alt:"","data-testid":"share-preview-favicon"}),c.jsxs("div",{className:"gh-portal-share-preview-meta",children:[v&&c.jsx("span",{className:"gh-portal-share-preview-site",children:v}),v&&k&&c.jsx("span",{className:"gh-portal-share-preview-separator","aria-hidden":"true",children:"|"}),k&&c.jsx("span",{className:"gh-portal-share-preview-author",children:k})]})]})]})]}),c.jsxs("div",{className:"gh-portal-share-actions",children:[c.jsxs("button",{className:"gh-portal-btn gh-portal-share-action copy",type:"button",onClick:j,"aria-label":y(t?"Copied":"Copy link"),title:y(t?"Copied":"Copy link"),children:[t?c.jsx("span",{className:"gh-portal-share-icon copied","aria-hidden":"true",children:c.jsx(Ro,{})}):c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(kj,{})}),c.jsx("span",{className:"gh-portal-share-label",children:y(t?"Copied":"Copy link")})]}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action twitter",href:x.twitter,target:"_blank",rel:"noopener noreferrer","aria-label":y("X (Twitter)"),title:y("X (Twitter)"),children:c.jsx("span",{className:"gh-portal-share-icon x","aria-hidden":"true",children:c.jsx(xj,{})})}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action linkedin",href:x.linkedin,target:"_blank",rel:"noopener noreferrer","aria-label":y("LinkedIn"),title:y("LinkedIn"),children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(vj,{})})}),c.jsx("a",{className:"gh-portal-btn gh-portal-share-action email",href:x.email,target:"_blank",rel:"noopener noreferrer","aria-label":y("Email"),title:y("Email"),children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(tu,{})})}),c.jsxs("div",{className:"gh-portal-share-more",ref:l,children:[c.jsx("button",{className:"gh-portal-btn gh-portal-share-action more",type:"button",onClick:T,"aria-label":y("More options"),title:y("More options"),"aria-haspopup":"menu","aria-expanded":n,children:c.jsx("span",{className:"gh-portal-share-icon","aria-hidden":"true",children:c.jsx(bj,{})})}),n&&c.jsxs("div",{className:"gh-portal-share-more-menu",role:"menu","aria-label":y("More options"),children:[c.jsxs("a",{className:"gh-portal-share-more-item",href:x.facebook,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(yj,{})}),c.jsx("span",{children:y("Facebook")})]}),c.jsxs("a",{className:"gh-portal-share-more-item",href:x.threads,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(wj,{})}),c.jsx("span",{children:y("Threads")})]}),c.jsxs("a",{className:"gh-portal-share-more-item",href:x.bluesky,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:z,children:[c.jsx("span",{className:"gh-portal-share-more-item-icon","aria-hidden":"true",children:c.jsx(gj,{})}),c.jsx("span",{children:y("Bluesky")})]})]})]})]})]})}},ru=function({page:t}){return Object.keys(ou).includes(t)?t:"signup"},Vh=function({page:t}){return t.includes("account")},Sj=function({page:t}){return t.includes("offer")},Cj=t=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},C.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"}));class Hh extends Pe.Component{static contextType=Q;render(){return c.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",children:[c.jsx(Cj,{}),"Powered by Ghost"]})}}const qh=()=>({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 Ej({message:t}){return Ta()?c.jsx("div",{className:"gh-portal-cookiebanner",children:t}):null}class jj extends Pe.Component{static contextType=Q;componentDidMount(){this.node&&!Ze(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=e=>{e.key==="Escape"&&this.dismissPopup(e)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(e){const n=e.target&&e.target.tagName;(n!=="INPUT"||n==="INPUT"&&!e?.target?.value)&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){this.node&&Ze(["preview"])&&this.node?.clientHeight!==this.lastContainerHeight&&(this.lastContainerHeight=this.node?.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(e){const{page:n,otcRef:i}=this.context;Ze(["preview"])||i&&n==="magiclink"||n==="giftRedemption"||n==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:e}=this.context;ru({page:e});const n=ou[e];return c.jsx(n,{})}renderPopupNotification(){const{popupNotification:e}=this.context;return!e||!e.type?null:c.jsx(VE,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:e,pageQuery:n,site:i,customSiteUrl:r,lastPage:l}=this.context,m=us({site:i,pageQuery:n}).length;ru({page:e});const f={...qh().page[e]};let g="",v="regular",k="",x=e;switch(e){case"signup":k="Cookies must be enabled in your browser to sign up.";break;case"signin":k="Cookies must be enabled in your browser to sign in.";break;case"accountHome":x="account-home";break;case"accountProfile":x="account-profile";break;case"accountPlan":x="account-plan";break;default:k="Cookies must be enabled in your browser.",x=e;break}m>1&&!pn({site:i})&&Pn({site:i,pageQuery:n})&&e==="signup"&&(x+=" full-size",v="full"),(e==="gift"||e==="giftSuccess"||e==="giftRedemption")&&(x+=" full-size",v="full"),e==="magiclink"&&l==="gift"&&(x+=" full-size giftRedemption",v="full");const j=zo({site:i});(j&&m>2||!j&&m>1)&&e==="accountPlan"&&(x+=" full-size",v="full"),(e==="emailSuppressionFAQ"||e==="emailReceivingFAQ")&&(x+=" large-size");let T="gh-portal-popup-container";Ze(["preview"])&&(x+=" preview"),Ze(["preview"],{customSiteUrl:r})&&!i.disableBackground&&(T+=" preview"),Ze(["dev"])&&(T+=" dev");const z=`${T} ${g} ${x}`,D=e==="gift"||e==="giftSuccess"||e==="giftRedemption"||e==="magiclink"&&l==="gift";return this.sendPortalPreviewReadyEvent(),c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"gh-portal-popup-wrapper "+x,onClick:R=>this.handlePopupClose(R),children:[this.renderPopupNotification(),c.jsxs("div",{className:z,style:f,ref:R=>this.node=R,tabIndex:-1,children:[c.jsx(Ej,{message:k}),this.renderActivePage(),v==="full"&&!D?c.jsx("div",{className:"gh-portal-powered inside "+(Ze(["preview"])?"hidden ":"")+x,children:c.jsx(Hh,{})}):""]})]}),e!=="share"&&!D&&c.jsx("div",{className:"gh-portal-powered outside "+(Ze(["preview"])?"hidden ":"")+x,children:c.jsx(Hh,{})})]})}}class Tj extends Pe.Component{static contextType=Q;constructor(e){super(e),this.state={height:null}}renderCurrentPage(e){const n=ou[e];return c.jsx(n,{})}onHeightChange(e){this.setState({height:e})}handlePopupClose(e){e.preventDefault();const{page:n}=this.context;n==="giftRedemption"||n==="giftSuccess"||e.target===e.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:e,brandColor:n}=this.context,i=P1({site:e}),r=n?`:root { --brandcolor: ${n} }`+i:i;return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:r}}),c.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:e,site:n,customSiteUrl:i}=this.context,r=qh(),l=window.innerWidth<480,u={...r.frame.common};let m="gh-portal-popup-background";return Ze(["preview"])&&(r.modalContainer.zIndex="3999997"),Ze(["preview"],{customSiteUrl:i})&&!n.disableBackground&&(m+=" preview"),Ze(["dev"])&&(m+=" dev"),c.jsx("div",{style:r.modalContainer,children:c.jsxs(wc,{style:u,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[c.jsx("div",{className:m,onClick:p=>this.handlePopupClose(p)}),c.jsx(jj,{isMobile:l})]})})}render(){const{showPopup:e}=this.context;return e?this.renderFrameContainer():null}}js({products:su({numOfProducts:1})});function gt(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function Pj(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function js({title:t="The Blueprint",description:e="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:i="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:r="https://portal.localhost",plans:l={monthly:5e3,yearly:15e4,currency:"USD"},products:u=su({numOfProducts:1}),portalProducts:m=u.map(fe=>fe.id),accentColor:p="#45C32E",portalPlans:f=["free","monthly","yearly"],membersSignupAccess:g="all",freePriceName:v="Free",freePriceDescription:k="Free preview",paidMembersEnabled:x=!0,portalButton:j=!0,portalName:T=!0,portalButtonIcon:z="icon-1",portalButtonSignupText:D="Subscribe now",portalButtonStyle:R="icon-and-text",membersSupportAddress:G="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:Y=[],posts:V=zj(),commentsEnabled:K,recommendations:_=[],recommendationsEnabled:le}={}){return{title:t,description:e,logo:n,icon:i,accent_color:p,url:r,plans:l,products:u,portal_products:m,members_signup_access:g,free_price_name:v,free_price_description:k,paid_members_enabled:x,portal_button:j,portal_name:T,portal_plans:f,portal_button_icon:z,portal_button_signup_text:D,portal_button_style:R,members_support_address:G,comments_enabled:K!=="off",newsletters:Y,recommendations:_,recommendations_enabled:!!le,editor_default_email_recipients:$,posts:V}}function Zh({name:t="Black Friday",code:e="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:i="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:r="percent",cadence:l="month",amount:u=50,duration:m="repeating",durationInMonths:p=null,currencyRestriction:f=!1,currency:g=null,status:v="active",tierId:k="",tierName:x="Basic",redemptionType:j="signup"}={}){return{id:`offer_${gt()}`,name:t,code:e,display_title:n,display_description:i,type:r,cadence:l,amount:u,duration:m,duration_in_months:p,currency_restriction:f,currency:g,status:v,tier:{id:`${k}`,name:x},redemption_type:j}}function _t({name:t="Jamie Larson",email:e="jamie@example.com",firstname:n="Jamie",subscriptions:i=[],paid:r=!1,status:l,avatarImage:u="",subscribed:m=!0,email_suppression:p={suppressed:!1,info:null},newsletters:f=[]}={}){const g={uuid:Pj(),email:e,name:t,firstname:n,paid:r,subscribed:m,avatar_image:u,subscriptions:i,email_suppression:p,newsletters:f};return l!==void 0?g.status=l:r?g.status="paid":g.status="free",g}function zj({numOfPosts:t=3}={}){const e=[];for(let n=0;n<t;n++)e.push(Nj({title:`Post ${n+1}`,slug:`post-${n+1}`}));return e.slice(0,t)}function Nj({id:t=`post_${gt()}`,title:e="Post",excerpt:n="Post excerpt",slug:i="post",featured:r=!1}={}){return{id:t,title:e,excerpt:n,slug:i,featured:r}}function su({numOfProducts:t=3}={}){const n=[Ti({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ut({interval:"month",amount:700}),yearlyPrice:Ut({interval:"year",amount:7e3}),numOfBenefits:2}),Ti({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ut({interval:"month",amount:1200}),yearlyPrice:Ut({interval:"year",amount:12e3}),numOfBenefits:3}),Ti({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ut({interval:"month",amount:18e3}),yearlyPrice:Ut({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,t),i=Jh({});return[...n,i]}function Ti({type:t="paid",name:e="Basic",description:n="",id:i=`product_${gt()}`,monthlyPrice:r=Ut(),yearlyPrice:l=Ut({interval:"year"}),numOfBenefits:u=2,trialDays:m=null}){return{id:i,name:e,description:n,monthlyPrice:t==="free"?null:r,yearlyPrice:t==="free"?null:l,type:t,benefits:Kh({numOfBenefits:u}),trial_days:m}}function Jh({name:t="Free tier",description:e="Free tier description",id:n=`product_${gt()}`,numOfBenefits:i=2}){return{id:n,name:t,type:"free",description:e,benefits:Kh({numOfBenefits:i})}}function Kh({numOfBenefits:t}){const e=gt();return[Ts({name:`Limited early adopter pricing #${e.substring(0,6)}`}),Ts({name:`Latest gear reviews #${e.substring(6,12)}`}),Ts({name:`Weekly email newsletter #${e.substring(12,18)}`}),Ts({name:`Listen to my podcast #${e.substring(18)}`})].slice(0,t)}function Ts({id:t=`benefit_${gt()}`,name:e="Benefit"}){return{id:t,name:e}}function Ut({interval:t="month",amount:e=t==="month"?500:5e3,nickname:n=t==="month"?"Monthly":"Yearly",description:i=null,currency:r="usd",active:l=!0,id:u=`price_${gt()}`}={}){return{id:u,active:l,nickname:n,currency:r,amount:e,interval:t,description:i,stripe_price_id:`price_${gt()}`,stripe_product_id:`prod_${gt()}`,type:"recurring"}}function Aa({id:t=`sub_${gt()}`,status:e="active",currency:n="USD",interval:i="year",amount:r=i==="month"?500:5e3,nickname:l=i==="month"?"Monthly":"Yearly",cardLast4:u="4242",offer:m=Mj,priceId:p=`price_${gt()}`,startDate:f="2021-10-05T03:18:30.000Z",currentPeriodEnd:g="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:v=!1,trialEndAt:k=null,nextPayment:x=null,tier:j=null}={}){return{id:t,customer:{id:`cus_${gt()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${gt()}`,nickname:l,amount:r,interval:i,currency:n},offer:m,status:e,start_date:f,default_payment_card_last4:u,cancel_at_period_end:v,cancellation_reason:null,current_period_end:g,trial_end_at:k,next_payment:x,tier:j,price:{id:`stripe_price_${gt()}`,price_id:p,nickname:l,amount:r,interval:i,type:"recurring",currency:n,product:{id:`stripe_prod_${gt()}`,product_id:`prod_${gt()}`}}}}function Xh(){const t=su({numOfProducts:1}),e=t.map(i=>i.id);return js({products:t,portalPlans:["free","monthly","yearly"],portalProducts:e})}Xh();const Ij=js({products:[Ti({numOfBenefits:2,type:"free"})]}),Mj=Zh({tierId:Ij.products[0]?.id});_t({status:"free"}),_t({status:"paid",paid:!0,subscriptions:[Aa()]}),_t({status:"comped",paid:!0,subscriptions:[]}),_t({status:"comped",paid:!0,subscriptions:[Aa({amount:0})]}),_t({status:"paid",paid:!0,subscriptions:[Aa({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Xh();const Ps=[Jh({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Ti({name:"The Blueprint",description:"",monthlyPrice:Ut({interval:"month",amount:500}),yearlyPrice:Ut({interval:"year",amount:5e3}),numOfBenefits:3}),Ti({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ut({interval:"month",amount:1200}),yearlyPrice:Ut({interval:"year",amount:11e3}),numOfBenefits:4})],zs=js({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:Ps,portalProducts:Ps.map(t=>t.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",paidMembersEnabled:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),Qh=Zh({tierId:zs.products[1]?.id}),Pi={free:_t({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,status:"free",avatarImage:"",subscribed:!0}),paid:_t({paid:!0,status:"paid",subscriptions:[Aa({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:_t({paid:!0,status:"comped",subscriptions:[]}),complimentaryWithSubscription:_t({paid:!0,status:"comped",subscriptions:[Aa({amount:0})]}),preview:_t({paid:!0,status:"paid",subscriptions:[Aa({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:new Date().toISOString()})]})};function Oj(){if(!Ps||!Ps[1])return null;let t=zs?.products?.[1].monthlyPrice,e=_t({paid:!0,status:"paid",subscriptions:[Aa({offer:null,priceId:t?.id,status:"active",currency:t?.currency,interval:t?.interval,amount:t?.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:zs,member:e}}function Aj(t){const e=t.getAttribute("href"),n=new URL(e,window.location.origin),i=["#/portal","#/share"],r=i.some(u=>n.hash.startsWith(u)),l=i.some(u=>e.startsWith(u));!n.hash||!r||l||n.origin===window.location.origin&&t.setAttribute("href",n.hash)}const Dj="CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION";function Yj({data:t,state:e}){return{page:t.page,popupNotification:null,lastPage:t.lastPage||null,pageData:t.pageData||e.pageData}}function Fj({state:t}){return{showPopup:!t.showPopup}}function Rj({data:t}){return{showPopup:!0,reloadOnPopupClose:!1,page:t.page,...t.pageQuery?{pageQuery:t.pageQuery}:{},...t.pageData?{pageData:t.pageData}:{}}}function Lj({state:t}){return t.lastPage?{page:t.lastPage}:_h({state:t})}function _h({state:t}){Vn();const e={...t.pageData||{}};return delete e.redirect,{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:t.page==="magiclink"?"":t.page,pageData:e}}function $j({data:t,state:e}){const{action:n="openNotification",status:i="success",autoHide:r=!0,closeable:l=!0,duration:u=2600,message:m=""}=t||{},p=Oo({type:n,status:i,autoHide:r,closeable:l,duration:u,state:e,message:m});return{notification:p,notificationSequence:p.count}}function Uj(){return{notification:null}}async function Bj({api:t,state:e}){try{return await t.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:De({type:"signout:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to log out, please try again")})}}}async function Wj({data:t,api:e,state:n}){try{const i=await e.member.getIntegrityToken(),r={...t,emailType:"signin",integrityToken:i,includeOTC:!0},{otc_ref:l,inboxLinks:u}=await e.member.sendMagicLink(r);return{page:"magiclink",lastPage:"signin",...l?{otcRef:l}:{},inboxLinks:u,pageData:{...n.pageData||{},email:(t?.email||"").trim()}}}catch(i){return{action:"signin:failed",popupNotification:De({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:Tn(i,y("Failed to log in, please try again"))})}}}function Gj({data:t,state:e}){const n=(t?.email||"").trim(),i=t?.otcRef,r=t?.inboxLinks;return i?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:i,inboxLinks:r,pageData:{...e.pageData||{},email:n},popupNotification:null}:{}}async function Vj({data:t,api:e}){const n=y("Failed to verify code, please try again");try{const i=await e.member.getIntegrityToken(),r=await e.member.verifyOTC({...t,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:Tn(r.errors?.[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:Tn(i,n)}}}async function Hj({data:t,state:e,api:n}){try{let{plan:i,tierId:r,cadence:l,email:u,name:m,newsletters:p,offerId:f}=t;m=m?.trim();let g;if(i.toLowerCase()==="free"){const v=await n.member.getIntegrityToken();({inboxLinks:g}=await n.member.sendMagicLink({emailType:"signup",integrityToken:v,...t,name:m}))}else{const v=e.member?{checkoutType:"upgrade"}:void 0;return(!r||!l)&&({tierId:r,cadence:l}=Io({site:e?.site,priceId:i})),await n.member.checkoutPlan({plan:i,tierId:r,cadence:l,email:u,name:m,newsletters:p,offerId:f,metadata:v}),{page:"loading"}}return{page:"magiclink",lastPage:"signup",inboxLinks:g,pageData:{...e.pageData||{},email:(u||"").trim()}}}catch(i){if(i.code===Dj)return e.member?{action:"signup:failed",popupNotification:De({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("You already have an active subscription.")})}:{page:"magiclink",lastPage:"signin",pageData:{...e.pageData||{},email:(t?.email||"").trim()},popupNotification:null};const r=Tn(i,y("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:De({type:"signup:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:r})}}}async function qj({data:t,state:e,api:n}){try{let{email:i,name:r,giftToken:l}=t;if(r=r?.trim(),e.member){await n.gift.redeem({token:l});const g=await n.member.sessionData(),v=Oo({type:"giftRedeem",status:"success",autoHide:!0,closeable:!0,state:e,message:ah({member:g})});return Vn(),{action:"redeemGift:success",member:g,showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:v,notificationSequence:v.count}}const u=await n.member.getIntegrityToken(),m=new URL(e?.site?.url||window.location.href);m.search=new URLSearchParams({giftRedemption:"true"}).toString(),m.hash="";const{otc_ref:p,inboxLinks:f}=await n.member.sendMagicLink({email:(i||"").trim(),emailType:"subscribe",integrityToken:u,includeOTC:!0,redirect:m.href,giftToken:l,...r?{name:r}:{}});return{page:"magiclink",lastPage:"gift",...p?{otcRef:p}:{},inboxLinks:f,pageData:{...e.pageData||{},email:(i||"").trim(),redirect:m.href}}}catch(i){const r=Oo({type:"giftRedeem",status:"error",autoHide:!1,closeable:!0,state:e,message:vs(i)});return Vn(),{action:"redeemGift:failed",showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,notification:r,notificationSequence:r.count}}}async function Zj({data:t,state:e,api:n}){try{let{plan:i,offerId:r,tierId:l,cadence:u}=t;(!l||!u)&&({tierId:l,cadence:u}=Io({site:e?.site,priceId:i})),await n.member.checkoutPlan({plan:i,tierId:l,cadence:u,offerId:r,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:De({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Jj({state:t,api:e}){try{await e.member.continueGiftCheckout()}catch{return{action:"continueGiftSubscription:failed",popupNotification:De({type:"continueGiftSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Kj({data:t,state:e,api:n}){try{const{tierId:i,cadence:r,email:l}=t;return await n.member.checkoutGift({tierId:i,cadence:r,...l?{email:l}:{}}),{action:"checkoutGift:success"}}catch{return{action:"checkoutGift:failed",popupNotification:De({type:"checkoutGift:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to process checkout, please try again")})}}}async function Xj({data:t,state:e,api:n}){try{const{plan:i,planId:r,subscriptionId:l,cancelAtPeriodEnd:u}=t,{tierId:m,cadence:p}=Io({site:e?.site,priceId:r});await n.member.updateSubscription({planName:i,tierId:m,cadence:p,subscriptionId:l,cancelAtPeriodEnd:u,planId:r});const f=await n.member.sessionData(),g="updateSubscription:success";return{action:g,popupNotification:De({type:g,autoHide:!0,closeable:!0,state:e,status:"success",message:y("Subscription plan updated successfully")}),page:"accountHome",member:f}}catch{return{action:"updateSubscription:failed",popupNotification:De({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to update subscription, please try again")})}}}async function Qj({data:t,state:e,api:n}){try{const{subscriptionId:i,cancellationReason:r}=t;return await n.member.updateSubscription({subscriptionId:i,smartCancel:!0,cancellationReason:r}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"cancelSubscription:failed",popupNotification:De({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to cancel subscription, please try again")})}}}async function _j({data:t,state:e,api:n}){try{const{subscriptionId:i}=t;return await n.member.updateSubscription({subscriptionId:i,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData(),reloadOnPopupClose:!0}}catch{return{action:"continueSubscription:failed",popupNotification:De({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to cancel subscription, please try again")})}}}async function eT({data:t,state:e,api:n}){try{const{offerId:i,subscriptionId:r}=t;return await n.member.applyOffer({offerId:i,subscriptionId:r}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],reloadOnPopupClose:!0,popupNotification:De({type:"applyOffer:success",autoHide:!0,closeable:!0,state:e,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:De({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:"Failed to apply offer, please try again"})}}}async function tT({data:t,state:e,api:n}){try{await n.member.editBilling(t)}catch{return{action:"editBilling:failed",popupNotification:De({type:"editBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to update billing information, please try again")})}}}async function nT({data:t,state:e,api:n}){try{await n.member.manageBilling(t)}catch{return{action:"manageBilling:failed",popupNotification:De({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:e,status:"error",message:y("Failed to open billing portal, please try again")})}}}async function aT(){return{popupNotification:null}}async function iT({data:t,state:e}){let{action:n,message:i=""}=t;return n=n||"showPopupNotification:success",{popupNotification:De({type:n,autoHide:!0,closeable:!0,state:e,status:"success",message:i})}}async function oT({data:t,state:e,api:n}){try{const{newsletters:i,enableCommentNotifications:r,enableUpdatesAndAnnouncements:l}=t;if(!i&&r===void 0&&l===void 0)return{};const u={};return i&&(u.newsletters=i),r!==void 0&&(u.enableCommentNotifications=r),l!==void 0&&(u.enableUpdatesAndAnnouncements=l),{action:"updateNewsletterPref:success",member:await n.member.update(u)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:De({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:y("Failed to update newsletter settings")})}}}async function rT({state:t,api:e}){try{return await e.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:De({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:t,status:"success",message:y("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:De({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:y("Your email has failed to resubscribe, please try again")})}}}async function sT({data:t,state:e,api:n}){try{const{subscribed:i}=t,r=await n.member.update({subscribed:i});if(!r)throw new Error("Failed to update newsletter");const l="updateNewsletter:success";return{action:l,member:r,popupNotification:De({type:l,autoHide:!0,closeable:!0,state:e,status:"success",message:y("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:De({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:y("Failed to update newsletter settings")})}}}async function lT({data:t,state:e,api:n}){const{email:i}=t,r=mS({member:e.member});if(i!==r)try{return await n.member.updateEmailAddress({email:i}),{success:!0}}catch(l){return{success:!1,error:l}}return null}async function cT({data:t,state:e,api:n}){const i=t?.name?.trim();if(hS({member:e.member})!==i)try{const l=await n.member.update({name:i});if(!l)throw new Error("Failed to update member");return{member:l,success:!0}}catch(l){return{success:!1,error:l}}return null}async function uT({state:t,api:e}){if(t.member)try{const n=await e.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function dT({data:t,state:e,api:n}){const[i,r]=await Promise.all([cT({data:t,state:e,api:n}),lT({data:t,state:e,api:n})]);if(i&&r){if(r.success)return{action:"updateProfile:success",...i.success?{member:i.member}:{},page:"accountHome",popupNotification:De({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:y("Check your inbox to verify email update")})};const l=i.success?y("Failed to send verification email"):y("Failed to update account data");return{action:"updateProfile:failed",...i.success?{member:i.member}:{},popupNotification:De({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:l,state:e})}}else if(i){const l=i.success?"updateProfile:success":"updateProfile:failed",u=i.success?"success":"error",m=i.success?y("Account details updated successfully"):y("Failed to update account details");return{action:l,...i.success?{member:i.member}:{},...i.success?{page:"accountHome"}:{},popupNotification:De({type:l,autoHide:i.success,closeable:!0,status:u,state:e,message:m})}}else if(r){const l=r.success?"updateProfile:success":"updateProfile:failed",u=r.success?"success":"error";let m="";return r.error?m=Tn(r.error,y("Failed to send verification email")):m=y("Check your inbox to verify email update"),{action:l,...r.success?{page:"accountHome"}:{},popupNotification:De({type:l,autoHide:r.success,closeable:!0,status:u,state:e,message:m})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:De({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:e,message:y("Account details updated successfully")})}}async function mT({data:{siteUrl:t},state:e}){const n=Es({siteUrl:t,apiUrl:"not-defined"}),{member:i}=e,r=window.location.href,l=Op(),u=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:i.name,email:i.email,autoRedirect:!1,integrityToken:u,customUrlHistory:e.site.outbound_link_tagging?[{time:Date.now(),referrerSource:l,referrerMedium:"Ghost Recommendations",referrerUrl:r}]:[]}),{}}function pT({data:{recommendationId:t},api:e}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),i=n?JSON.parse(n):[];if(i.includes(t))return;i.push(t),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(i))}catch{}return e.recommendations.trackClicked({recommendationId:t}),{}}async function hT({data:{recommendationId:t},api:e}){return e.recommendations.trackSubscribed({recommendationId:t}),{}}const fT={togglePopup:Fj,openPopup:Rj,closePopup:_h,switchPage:Yj,openNotification:$j,closeNotification:Uj,back:Lj,signout:Bj,signin:Wj,startSigninOTCFromCustomForm:Gj,verifyOTC:Vj,signup:Hj,redeemGift:qj,updateSubscription:Xj,cancelSubscription:Qj,continueSubscription:_j,applyOffer:eT,updateNewsletter:sT,updateProfile:dT,refreshMemberData:uT,clearPopupNotification:aT,editBilling:tT,manageBilling:nT,checkoutPlan:Zj,continueGiftSubscription:Jj,checkoutGift:Kj,updateNewsletterPreference:oT,showPopupNotification:iT,removeEmailFromSuppressionList:rT,oneClickSubscribe:mT,trackRecommendationClicked:pT,trackRecommendationSubscribed:hT};async function gT({action:t,data:e,state:n,api:i}){const r=fT[t];return r?await r({data:e,state:n,api:i})||{}:{}}function ef(t,e){t&&(t.innerText=e)}function bT(t,e,n){e.classList.add("error");const i=y("There was an error sending the email, please try again");ef(n,Tn(t,i))}async function yT({event:t,form:e,errorEl:n,siteUrl:i,submitHandler:r,doAction:l,captureException:u}){e.removeEventListener("submit",r),t.preventDefault(),n&&(n.innerText=""),e.classList.remove("success","invalid","error");let m=t.target.querySelector("input[data-members-email]"),p=t.target.querySelector("input[data-members-name]"),f=e?.dataset?.membersAutoredirect||"true",g=m?.value,v=(p?.value||"").trim()||void 0,k,x=[],j=[],T=t.target.querySelectorAll("input[data-members-label]")||[];for(let $=0;$<T.length;++$)x.push(T[$].value);let z=t.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let $=0;$<z.length;++$)j.push({name:z[$].value});e.dataset.membersForm&&(k=e.dataset.membersForm);const D=k==="signin"&&e?.dataset?.membersOtc==="true";e.classList.add("loading");const R=bi(),G={email:g,emailType:k,labels:x,name:v,autoRedirect:f==="true"};D&&(G.includeOTC=!0),R&&(G.urlHistory=R),z.length>0?G.newsletters=j:(t.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(G.newsletters=[]);try{const Y=await(await fetch(`${i}/members/api/integrity-token/`,{method:"GET"})).text(),V=await fetch(`${i}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...G,integrityToken:Y})});if(e.addEventListener("submit",r),e.classList.remove("loading"),V.ok){e.classList.add("success");let K;if(D)try{K=await V.clone().json()}catch{K=void 0}const _=K?.otc_ref;if(_&&typeof l=="function")try{l("startSigninOTCFromCustomForm",{email:(g||"").trim(),otcRef:_,inboxLinks:K?.inboxLinks})}catch(le){console.error(le),u?.(le)}}else{const K=await Qt.fromApiResponse(V),_=Tn(K,y("Failed to send magic link email"));ef(n,_),e.classList.add("error")}}catch($){bT($,e,n)}}function kT({event:t,el:e,errorEl:n,siteUrl:i,site:r,member:l,clickHandler:u}){e.removeEventListener("click",u),t.preventDefault();let m=e.dataset.membersPlan,p=tS(r,m.toLowerCase()),f=e.dataset.membersSuccess,g=e.dataset.membersCancel,v,k;f&&(v=new URL(f,window.location.href).href),g&&(k=new URL(g,window.location.href).href),n&&(n.innerText=""),e.classList.add("loading");const x=l?{checkoutType:"upgrade"}:{},j=bi();return j&&(x.urlHistory=j),fetch(`${i}/members/api/session`,{credentials:"same-origin"}).then(function(T){return T.ok?T.text():null}).then(function(T){return fetch(`${i}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,identity:T,successUrl:v,cancelUrl:k,metadata:x})}).then(function(z){if(!z.ok)throw new Error(y("Could not create Stripe checkout session"));return z.json()})}).then(function(T){return T.url?window.location.assign(T.url):window.Stripe(T.publicKey).redirectToCheckout({sessionId:T.sessionId}).then(function(D){if(D.error)throw new Error(D.error.message)})}).catch(function(T){console.error(T),e.addEventListener("click",u),e.classList.remove("loading"),n&&(n.innerText=T.message),e.classList.add("error")})}function vT({siteUrl:t,site:e={},member:n,offers:i=[],doAction:r,captureException:l}={}){if(!t)return;t=t.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(m){let p=m.querySelector("[data-members-error]");function f(g){yT({event:g,errorEl:p,form:m,siteUrl:t,submitHandler:f,doAction:r,captureException:l})}m.addEventListener("submit",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(m){let p=m.querySelector("[data-members-error]");function f(g){kT({el:m,event:g,errorEl:p,member:n,site:e,siteUrl:t,clickHandler:f})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(m){let p=m.querySelector("[data-members-error]"),f=m.dataset.membersSuccess,g=m.dataset.membersCancel,v,k;f&&(v=new URL(f,window.location.href).href),g&&(k=new URL(g,window.location.href).href);function x(j){m.removeEventListener("click",x),j.preventDefault(),p&&(p.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(T){return T.ok?T.text():null}).then(function(T){return fetch(`${t}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:T,successUrl:v,cancelUrl:k})}).then(function(z){if(!z.ok)throw new Error(y("Could not create Stripe checkout session"));return z.json()})}).then(function(T){return window.Stripe(T.publicKey).redirectToCheckout({sessionId:T.sessionId})}).then(function(T){if(T.error)throw new Error(y(T.error.message))}).catch(function(T){console.error(T),m.addEventListener("click",x),m.classList.remove("loading"),p&&(p.innerText=T.message),m.classList.add("error")})}m.addEventListener("click",x)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(m){let p=m.querySelector("[data-members-error]"),f=m.dataset.membersReturn,g;f&&(g=new URL(f,window.location.href).href);function v(k){m.removeEventListener("click",v),k.preventDefault(),p&&(p.innerText=""),m.classList.add("loading"),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(x){return x.ok?x.text():null}).then(function(x){return fetch(`${t}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:x,returnUrl:g})}).then(function(j){if(!j.ok)throw new Error(y("Could not create Stripe billing portal session"));return j.json()})}).then(function(x){return window.location.assign(x.url)}).catch(function(x){console.error(x),m.addEventListener("click",v),m.classList.remove("loading"),p&&(p.innerText=x.message),m.classList.add("error")})}m.addEventListener("click",v)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(m){function p(f){m.removeEventListener("click",p),f.preventDefault(),m.classList.remove("error"),m.classList.add("loading"),fetch(`${t}/members/api/session`,{method:"DELETE"}).then(function(g){g.ok?window.location.replace(t):(m.addEventListener("click",p),m.classList.remove("loading"),m.classList.add("error"))})}m.addEventListener("click",p)});const u=(i||[]).some(m=>m.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(m){let p=m.parentElement.querySelector("[data-members-error]");function f(g){g.preventDefault();let v=m.dataset.membersCancelSubscription;if(u){r("openPopup",{page:"accountPlan",pageData:{subscriptionId:v,action:"cancel"}});return}return m.removeEventListener("click",f),m.classList.remove("error"),m.classList.add("loading"),p&&(p.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(k){return k.ok?k.text():null}).then(function(k){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:k,smart_cancel:!0})})}).then(function(k){k.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),p&&(p.innerText=y("There was an error cancelling your subscription, please try again.")))})}m.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(m){let p=m.parentElement.querySelector("[data-members-error]");function f(g){m.removeEventListener("click",f),g.preventDefault(),m.classList.remove("error"),m.classList.add("loading");let v=m.dataset.membersContinueSubscription;return p&&(p.innerText=""),fetch(`${t}/members/api/session`,{credentials:"same-origin"}).then(function(k){return k.ok?k.text():null}).then(function(k){return fetch(`${t}/members/api/subscriptions/${v}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:k,cancel_at_period_end:!1})})}).then(function(k){k.ok?window.location.reload():(m.addEventListener("click",f),m.classList.remove("loading"),m.classList.add("error"),p&&(p.innerText=y("There was an error continuing your subscription, please try again.")))})}m.addEventListener("click",f)})}const tf=t=>{try{return decodeURIComponent(t)}catch{return null}},wT={staleGiftRedemptionRequest:!0},xT={showPopup:!0,site:zs,member:Pi.free,page:"accountEmail",...Oj(),pageData:Qh};function ST({site:t,children:e}){const{portal_sentry:n}=t||{};return n&&n.dsn?c.jsx(bc,{children:e}):c.jsx(c.Fragment,{children:e})}class CT extends Pe.Component{constructor(e){super(e),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,notification:null,notificationSequence:-1,customSiteUrl:e.customSiteUrl,locale:e.locale,scrollbarWidth:0},this._redemptionRequestId=0,this.currentRedemptionToken=null}componentDidMount(){const e=this.getScrollbarWidth();this.setState({scrollbarWidth:e}),this.initSetup()}componentDidUpdate(e,n){if(n.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"&&n.initStatus!==this.state.initStatus){const{siteUrl:i}=this.props,r=this.getContextFromState();this.sendPortalReadyEvent(),vT({siteUrl:i,site:r.site,member:r.member,offers:r.offers,doAction:r.doAction,captureException:wo})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(e=>{e.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e),document.body.appendChild(e);const n=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),n}setupCustomTriggerButton(){this.clickHandler=async i=>{i.preventDefault();const r=i.currentTarget,l=r&&r.dataset.portal,u=this.getPageFromLinkPath(l);if(!u)return;const{page:m,pageQuery:p,pageData:f}=u;if(this.state.initStatus==="success"){if(m==="gift"&&!fi({site:this.state.site})){this.invalidateGiftRedemptionRequest(),Vn();return}if(m==="giftRedemption"&&f?.token){const g=this.startGiftRedemptionRequest(f.token),v=await this.fetchGiftRedemptionData({token:f.token});if(!this.isCurrentGiftRedemptionRequest(g))return;this.setState(v);return}this.invalidateGiftRedemptionRequest(),p&&p!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:p}):this.dispatchAction("openPopup",{page:m,pageQuery:p,pageData:f})}};const e="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(e)||[],this.customTriggerButtons.forEach(i=>{i.classList.add(n),i.removeEventListener("click",this.clickHandler),i.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){const e="gh-portal-open",n="gh-portal-close";this.customTriggerButtons?.forEach(i=>{const r=this.state.showPopup?e:n,l=this.state.showPopup?n:e;i.classList.add(r),i.classList.remove(l)})}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:n}){return this._redemptionRequestId===e&&this.currentRedemptionToken===n}async initSetup(){try{const{site:e,member:n,offers:i,page:r,showPopup:l,popupNotification:u,notification:m,notificationSequence:p,lastPage:f,pageQuery:g,pageData:v}=await this.fetchData(),k=this.props.siteI18nEnabled&&(this.props.locale||e.locale)||"en";as.changeLanguage(k);const x={site:e,member:n,offers:i,page:r,lastPage:f,pageQuery:g,showPopup:l,pageData:v,popupNotification:u,notification:m,notificationSequence:p,dir:as.dir()||"ltr",action:"init:success",initStatus:"success",locale:k};if(this.setState(x,()=>{this.handleSignupQuery({site:e,pageQuery:g,member:n})}),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const j=document.querySelectorAll("[data-lexical-signup-form]");j.length>0&&j.forEach(T=>{T.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(e){console.error("[Portal] Failed to initialize:",e),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:e,member:n,offers:i}=await this.fetchApiData(),{site:r,...l}=this.fetchDevData(),u=await this.fetchLinkData(e,n),{site:m,...p}=u?.staleGiftRedemptionRequest?{}:u,{site:f,...g}=this.fetchPreviewData(),{site:v,...k}=this.fetchNotificationData();return{member:n,offers:i,page:"",site:{...e,...m,...f,...v,...r,plans:{...(r||{}).plans,...(e||{}).plans,...(f||{}).plans}},...l,...p,...k,...g}}fetchDevData(){return Ze(["dev"])&&!this.state.customSiteUrl?xT:Ze(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(e=""){const n=new URLSearchParams(e),i={};for(let r of n.entries()){const l=r[0],u=decodeURIComponent(r[1]);l==="name"?i.name=u||"":l==="code"?i.code=u||"":l==="display_title"?i.display_title=u||"":l==="display_description"?i.display_description=u||"":l==="type"?i.type=u||"":l==="cadence"?i.cadence=u||"":l==="duration"?i.duration=u||"":l==="duration_in_months"&&!isNaN(Number(u))?i.duration_in_months=Number(u):l==="amount"&&!isNaN(Number(u))?i.amount=Number(u):l==="currency"?i.currency=u||"":l==="status"?i.status=u||"":l==="tier_id"?i.tier={id:u||Qh.tier.id}:l==="redemption_type"&&(i.redemption_type=u||"signup")}if(i.redemption_type==="retention"){const r=Pi.preview?.subscriptions?.[0]?.id;return{page:"accountPlan",offers:[i],pageData:{action:"cancel",subscriptionId:r}}}return{page:"offer",pageData:i}}fetchQueryStrData(e=""){const n=new URLSearchParams(e),i={site:{plans:{}}},r=[];let l,u=null,m,p,f;for(let g of n.entries()){const v=g[0],k=decodeURIComponent(g[1]);if(v==="button")i.site.portal_button=JSON.parse(k);else if(v==="name")i.site.portal_name=JSON.parse(k);else if(v==="isFree"&&JSON.parse(k))r.push("free");else if(v==="isMonthly"&&JSON.parse(k))r.push("monthly");else if(v==="isYearly"&&JSON.parse(k))r.push("yearly");else if(v==="portalPrices")l=k?k.split(","):[];else if(v==="portalProducts")u=k?k.split(","):[];else if(v==="page"&&k)i.page=k;else if(v==="accentColor"&&(k===""||k))i.site.accent_color=k;else if(v==="buttonIcon"&&k)i.site.portal_button_icon=k;else if(v==="signupButtonText")i.site.portal_button_signup_text=k||"";else if(v==="signupTermsHtml")i.site.portal_signup_terms_html=k||"";else if(v==="signupCheckboxRequired")i.site.portal_signup_checkbox_required=JSON.parse(k);else if(v==="buttonStyle"&&k)i.site.portal_button_style=k;else if(v==="monthlyPrice"&&!isNaN(Number(k)))i.site.plans.monthly=Number(k),m=Number(k);else if(v==="yearlyPrice"&&!isNaN(Number(k)))i.site.plans.yearly=Number(k),p=Number(k);else if(v==="currency"&&k){const x=k.toUpperCase();i.site.plans.currency=x,i.site.plans.currency_symbol=_e(x),f=x}else v==="disableBackground"?i.site.disableBackground=JSON.parse(k):v==="membersSignupAccess"&&k?i.site.members_signup_access=k:v==="portalDefaultPlan"&&k?i.site.portal_default_plan=k:v==="transistorPortalSettings"&&k&&(i.site.transistor_portal_settings=JSON.parse(k))}return i.site.portal_plans=r,i.site.portal_products=u,l?i.site.portal_plans=l:m&&p&&f&&(i.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:f,amount:m,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:f,amount:p,type:"recurring",interval:"year"}]),i}fetchNotificationData(){const{type:e,status:n,duration:i,autoHide:r,closeable:l}=oh({billingOnly:!0})||{};return["stripe:billing-update"].includes(e)?n==="success"?{showPopup:!0,popupNotification:De({type:e,status:n,duration:i,closeable:l,autoHide:r,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}async fetchGiftRedemptionData({token:e}){try{const n=await this.GhostApi.gift.fetchRedemptionData({token:e});return{showPopup:!0,notification:null,page:"giftRedemption",pageData:{token:e,gift:n?.gifts?.[0]||null}}}catch(n){Vn();const i=Oo({type:"giftRedemption:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:vs(n)});return{showPopup:!1,pageData:null,notification:i,notificationSequence:i.count}}}async fetchLinkData(e,n){this.invalidateGiftRedemptionRequest();const i=new URLSearchParams(window.location.search);if(i.get("stripe")==="gift-purchase-success"){const j=i.get("gift_token"),T=i.get("gift_tier"),z=i.get("gift_cadence");if(ws(["stripe","gift_token","gift_tier","gift_cadence"]),j)return{showPopup:!0,page:"giftSuccess",pageData:{token:j,tierId:T,cadence:z}}}if(i.get("action")==="unsubscribe")return i.get("key")&&i.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:i.get("uuid"),key:i.get("key"),newsletterUuid:i.get("newsletter"),comments:i.get("comments"),updatesAndAnnouncements:i.get("updatesandannouncements")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:i.get("newsletter"),action:"unsubscribe",redirect:e.url+"#/portal/account/newsletters"}};if(iS({site:e})&&i.get("action")==="signup"&&i.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[r,l]=window.location.hash.substr(1).split("?"),u=new URLSearchParams(l??""),m=/^(?:(\w+?))?\/monthly$/,p=/^(?:(\w+?))?\/yearly$/,f=/^offers\/(\w+?)\/?$/,g=/^\/portal\/gift\/redeem\/([^/?#]+)\/?$/,v=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,k=/^\/share\/?$/,x=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(r&&x.test(r)){const[,j,T]=r.match(x),z=parseInt(T);if(z===1||z===0)return n||u.get("uuid")&&u.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:u.get("uuid"),key:n?null:u.get("key"),postId:j,score:z}}:{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/feedback/${j}/${z}/`}}}if(r&&g.test(r)){const[,j]=r.match(g),T=tf(j);if(!T)return{};const z=this.startGiftRedemptionRequest(T),D=await this.fetchGiftRedemptionData({token:T});return this.isCurrentGiftRedemptionRequest(z)?D:wT}if(r&&k.test(r))return{showPopup:!0,page:"share"};if(r&&v.test(r)){const[,j]=r.match(v),{page:T,pageQuery:z,pageData:D}=this.getPageFromLinkPath(j,e)||{};if(!n&&T&&Vh({page:T}))return{showPopup:!0,page:"signin",pageData:{redirect:e.url+`#/portal/${j}/`}};if(T==="gift"&&!fi({site:e}))return Vn(),{};const R=["accountPlan","accountProfile"].includes(T)?"accountHome":null,G=!(["monthly","yearly"].includes(z)||m.test(z)||p.test(z)||f.test(z)),$=u.get("redirect"),Y=T==="signin"&&$?{...D||{},redirect:$}:D;return{showPopup:G,...T?{page:T}:{},...z?{pageQuery:z}:{},...Y?{pageData:Y}:{},...R?{lastPage:R}:{}}}return{}}fetchPreviewData(){const[,e]=window.location.hash.substr(1).split("?");if(Ze(["preview"])){let n={};try{Ze(["offerPreview"])?n=this.fetchOfferQueryStrData(e):n=this.fetchQueryStrData(e)}catch(i){return wo(i),{}}return{...n,showPopup:!0}}return{}}getColorOverride(){const e=document.querySelector("script[data-ghost]");return e&&e.dataset.accentColor?e.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:e,customSiteUrl:n,apiUrl:i,apiKey:r}=this.props;try{this.GhostApi=this.props.api||Es({siteUrl:e,apiUrl:i,apiKey:r});const{site:l,member:u,offers:m}=await this.GhostApi.init(),p=this.getColorOverride();return p&&(l.accent_color=p),this.setupFirstPromoter({site:l,member:u}),this.setupSentry({site:l}),{site:l,member:u,offers:m}}catch(l){if(Ze(["dev","test"],{customSiteUrl:n}))return{};throw l}}setupSentry({site:e}){if(Ze(["test"]))return null;const{portal_sentry:n,portal_version:i,version:r}=e,u=`portal@2.69.70|ghost@${r}`;n&&n.dsn&&Zv({dsn:n.dsn,environment:n.env||"development",release:u,beforeSend:m=>Zx({event:m})?m:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:e,member:n}){if(Ze(["test"]))return null;const i=pS({site:e});let r=Nc({site:e});if(r=r?.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),i&&r){const l=document.createElement("script");l.type="text/javascript",l.async=!0,l.src="https://cdn.firstpromoter.com/fprom.js",l.onload=l.onreadystatechange=function(){let m=this.readyState;if(!m||m==="complete"||m==="loaded")try{if(window.$FPROM.init(i,r),CS({member:n})){const p=n.email,f=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:p,uid:f});else{const g=window._fprom||[];window._fprom=g,g.push(["event","signup"]),g.push(["email",p]),g.push(["uid",f])}}}catch{}};const u=document.getElementsByTagName("script")[0];u.parentNode.insertBefore(l,u)}}async dispatchAction(e,n){clearTimeout(this.timeoutId),this.setState({action:`${e}:running`,actionErrorMessage:null});try{const i=await gT({action:e,data:n,state:this.state,api:this.GhostApi});this.setState(i),i&&i.action&&!i.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(i){if(console.error(`[Portal] Failed to dispatch action: ${e}`,i),n&&n.throwErrors)throw i;const r=De({type:`${e}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:i}});this.setState({action:`${e}:failed`,actionErrorMessage:Tn(i,y("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:r})}}async updateStateForPreviewLinks(){const{site:e,...n}=this.fetchPreviewData(),i=await this.fetchLinkData(this.state.site,this.state.member);if(i?.staleGiftRedemptionRequest)return;const{site:r,...l}=i,u={site:{...this.state.site,...r||{},...e||{},plans:{...this.state.site&&this.state.site.plans,...(r||{}).plans,...(e||{}).plans}},...l,...n};this.handleSignupQuery({site:u.site,pageQuery:u.pageQuery}),this.setState(u)}async handleOfferQuery({site:e,offerId:n,member:i=this.state.member}){if(Vn(),!(!dn({member:i})||Hn({member:i}))){const l=Oo({type:"offer:failed",status:"error",autoHide:!1,closeable:!0,state:this.state,message:y("You already have an active subscription.")});await this.dispatchAction("closePopup"),this.setState({notification:l,notificationSequence:l.count});return}try{const u=(await this.GhostApi.site.offer({offerId:n}))?.offers[0];if(!u||!u.tier||Oc({offer:u})||!yS({site:e,offer:u}))return;this.dispatchAction("openPopup",{page:"offer",pageData:u})}catch{}}handleSignupQuery({site:e,pageQuery:n,member:i}){const r=/^offers\/(\w+?)\/?$/;let l=n;if(r.test(n||"")){const[,m]=n.match(r);this.handleOfferQuery({site:e,offerId:m,member:i});return}Rp({site:e,pageQuery:n})&&(l=Rp({site:e,pageQuery:n}));const u=nS({site:e,priceId:l});if(n&&n!=="free"){Vn();const m=u?.id||l;m!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:p,cadence:f}=Io({site:e,priceId:m});this.dispatchAction("signup",{plan:m,tierId:p,cadence:f})}}getPageFromLinkPath(e){const n=/^signup\/?(?:\/(\w+?))?\/?$/,i=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,r=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,l=/^offers\/(\w+?)\/?$/,u=/^gift\/redeem\/([^/?#]+)\/?$/;if(e===void 0||e==="")return{page:"default"};if(u.test(e)){const[,m]=e.match(u),p=tf(m);return p?{page:"giftRedemption",pageData:{token:p}}:null}else{if(l.test(e))return{pageQuery:e};if(e==="signup")return{page:"signup"};if(i.test(e)){const[,m]=e.match(i);return{page:"signup",pageQuery:`${m}/monthly`}}else if(r.test(e)){const[,m]=e.match(r);return{page:"signup",pageQuery:`${m}/yearly`}}else if(n.test(e)){const[,m]=e.match(n);return{page:"signup",pageQuery:m}}else{if(e==="signup/free")return{page:"signup",pageQuery:"free"};if(e==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(e==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(e==="signin")return{page:"signin"};if(e==="account")return{page:"accountHome"};if(e==="account/plans")return{page:"accountPlan"};if(e==="account/profile")return{page:"accountProfile"};if(e==="account/newsletters")return{page:"accountEmail"};if(e==="support")return{page:"support"};if(e==="support/success")return{page:"supportSuccess"};if(e==="support/error")return{page:"supportError"};if(e==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(e==="gift")return{page:"gift"};if(e==="share")return{page:"share"};if(e==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(e==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}}return{page:"default"}}getAccentColor(){const{accent_color:e}=this.state.site||{};return vE(e)}getRetentionPreviewMember({site:e,offers:n}){const i=(n||[]).find(f=>Oc({offer:f})),r=i?.tier?.id,l=r?Na({site:e,productId:r}):null,u=l?i.cadence==="year"?l.yearlyPrice:l.monthlyPrice:null,m=Pi.preview,p=m?.subscriptions?.[0];return!p||!l||!u?m:{...m,subscriptions:[{...p,plan:{...p.plan,amount:u.amount,interval:u.interval,currency:u.currency.toUpperCase()},price:{...p.price,price_id:u.id,amount:u.amount,interval:u.interval,currency:u.currency,product:{...p.price?.product,product_id:l.id}},tier:{id:l.id,name:l.name}}]}}getContextPage({site:e,page:n,member:i}){if(!n||n==="default"){const r=pn({site:e})||!Pn({site:e})?"signin":"signup";n=i?"accountHome":r}return ru({page:n})}getContextMember({site:e,page:n,member:i,offers:r,pageData:l,customSiteUrl:u}){return Ze(["dev","preview"],{customSiteUrl:u})?Vh({page:n})||Sj({page:n})?Ze(["dev"],{customSiteUrl:u})?i||Pi.free:Ze(["preview"])?n==="accountPlan"&&l?.action==="cancel"?this.getRetentionPreviewMember({site:e,offers:r}):Pi.preview:Pi.paid:null:i}getContextFromState(){const{site:e,member:n,offers:i,action:r,actionErrorMessage:l,page:u,lastPage:m,showPopup:p,pageQuery:f,pageData:g,popupNotification:v,notification:k,customSiteUrl:x,dir:j,scrollbarWidth:T,otcRef:z,inboxLinks:D}=this.state,R=this.getContextPage({site:e,page:u,member:n}),G=this.getContextMember({site:e,page:R,member:n,offers:i,pageData:g,customSiteUrl:x});return{api:this.GhostApi,site:e,offers:i,action:r,actionErrorMessage:l,brandColor:this.getAccentColor(),page:R,pageQuery:f,pageData:g,member:G,lastPage:m,showPopup:p,popupNotification:v,notification:k,customSiteUrl:x,dir:j,scrollbarWidth:T,otcRef:z,inboxLinks:D,doAction:($,Y)=>this.dispatchAction($,Y)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const e=i=>{const r=i.currentTarget.dataset.recommendation;r?this.dispatchAction("trackRecommendationClicked",{recommendationId:r}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const i of n)i.addEventListener("click",e,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"], a[href*="#/share"]').forEach(Aj)}render(){return this.state.initStatus==="success"?c.jsx(ST,{site:this.state.site,children:c.jsxs(Q.Provider,{value:this.getContextFromState(),children:[c.jsx(Tj,{}),c.jsx(PS,{}),c.jsx(QS,{})]})}):null}}const nf="ghost-portal-root";function ET(){const t=document.createElement("div");t.id=nf,t.setAttribute("data-testid","portal-root"),document.body.appendChild(t)}function jT(){const t=document.querySelector("script[data-ghost]");if(t){const e=t.dataset.i18n==="true",n=t.dataset.ghost,i=t.dataset.key,r=t.dataset.api,l=t.dataset.locale;return{siteUrl:n,apiKey:i,apiUrl:r,siteI18nEnabled:e,locale:l}}return{}}function TT(){const t=new URL(window.location.href);t.searchParams.get("token")&&(t.searchParams.delete("token"),window.history.replaceState({},document.title,t.href))}function PT(){const{siteUrl:t,apiKey:e,apiUrl:n,siteI18nEnabled:i,locale:r}=jT(),l=t||window.location.origin;ET(),TT(),mb.render(c.jsx(Pe.StrictMode,{children:c.jsx(CT,{siteUrl:l,customSiteUrl:t,apiKey:e,apiUrl:n,siteI18nEnabled:i,locale:r})}),document.getElementById(nf))}PT()}));
|
|
4571
4571
|
//# sourceMappingURL=portal.min.js.map
|