@tryghost/portal 2.60.0 → 2.61.0
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 +5 -5
- package/umd/portal.min.js.map +1 -1
package/umd/portal.min.js
CHANGED
|
@@ -5723,7 +5723,7 @@ html[dir=rtl] .gh-portal-signup-terms .checkbox:before {
|
|
|
5723
5723
|
transform: translateX(-50%);
|
|
5724
5724
|
}
|
|
5725
5725
|
}
|
|
5726
|
-
`,Xp=class Xp extends re.Component{constructor(t){super(t),this.handleSelectPlan=(n,a)=>{n&&n.preventDefault(),this.timeoutId=setTimeout(()=>{this.setState(()=>({plan:a}))},5)},this.state={name:"",email:"",plan:"free",showNewsletterSelection:!1,termsCheckboxChecked:!1},this.termsRef=re.createRef()}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"}),this.handleSelectedPlan()}componentDidUpdate(){this.handleSelectedPlan()}handleSelectedPlan(){const{site:t,pageQuery:n}=this.context,a=Ml({site:t,pageQuery:n}),i=this.getSelectedPriceId(a,this.state.plan);i!==this.state.plan&&this.setState({plan:i})}componentWillUnmount(){clearTimeout(this.timeoutId)}getFormErrors(t){const a=this.context.site.portal_signup_checkbox_required&&this.context.site.portal_signup_terms_html&&!t.termsCheckboxChecked;return{...Ul({fields:this.getInputFields({state:t})}),checkbox:a}}doSignup(){this.setState(t=>({errors:this.getFormErrors(t)}),()=>{const{site:t,doAction:n}=this.context,{name:a,email:i,plan:r,phonenumber:o,token:s,errors:l}=this.state,c=l&&Object.values(l).filter(p=>!!p).length>0,m={...l};delete m.checkbox,(l==null?void 0:l.checkbox)&&Object.values(m).every(p=>!p)&&this.termsRef.current&&this.termsRef.current.scrollIntoView({behavior:"smooth",block:"center"}),c||(lo({site:t})?this.setState({showNewsletterSelection:!0,pageData:{name:a,email:i,plan:r,phonenumber:o,token:s},errors:{}}):(this.setState({errors:{}}),n("signup",{name:a,email:i,phonenumber:o,plan:r,token:s})))})}handleSignup(t){t.preventDefault(),this.doSignup()}handleChooseSignup(t,n){t.preventDefault(),this.setState({plan:n},()=>{this.doSignup()})}handleInputChange(t,n){const a=n.name,i=t.target.value;this.setState({[a]:i})}onKeyDown(t){t.keyCode===13&&this.handleSignup(t)}getSelectedPriceId(t=[],n){return!t||t.length===0||n==="free"?"free":t.some(i=>i.id===n)?n:t[0].id||"free"}getInputFields({state:t,fieldNames:n}){const{site:{portal_name:a}}=this.context,i=t.errors||{},r=[{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,tabIndex:2,errorMessage:i.email||""},{type:"text",value:t.phonenumber,placeholder:v("+1 (123) 456-7890"),label:v("Phone number"),name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}];return a&&r.unshift({type:"text",value:t.name,placeholder:v("Jamie Larson"),label:v("Name"),name:"name",required:!0,tabIndex:1,errorMessage:i.name||""}),r[0].autoFocus=!0,n&&n.length>0?r.filter(o=>n.includes(o.name)):r}renderSignupTerms(){var s;const{site:t}=this.context;if(t.portal_signup_terms_html===null||t.portal_signup_terms_html==="")return null;const n=l=>{this.setState({termsCheckboxChecked:l.target.checked})},a=u.jsx("div",{className:"gh-portal-signup-terms-content",dangerouslySetInnerHTML:{__html:Nx(t.portal_signup_terms_html)}}),i=t.portal_signup_checkbox_required?u.jsxs("label",{children:[u.jsx("input",{type:"checkbox",checked:!!this.state.termsCheckboxChecked,required:!0,onChange:n}),u.jsx("span",{className:"checkbox"}),a]}):a,o=`gh-portal-signup-terms ${(s=this.state.errors)!=null&&s.checkbox?"gh-portal-error":""}`;return u.jsx("div",{className:o,onClick:kx,ref:this.termsRef,children:i})}renderSubmitButton(){const{action:t,site:n,brandColor:a,pageQuery:i}=this.context;if(Ht({site:n})||!Sn({site:n,pageQuery:i}))return null;let r=v("Continue");const o=i==="free"&&tp({site:n});if(Ni({site:n})||o)r=v("Sign up");else return null;let s=!1;t==="signup:running"&&(r=v("Sending..."),s=!0);let l=!1;t==="signup:failed"&&(r=v("Retry"),l=!0);const c=t==="signup:running";return u.jsx(ze,{style:{width:"100%"},retry:l,onClick:m=>this.handleSignup(m),disabled:c,brandColor:a,label:r,isRunning:s,tabIndex:3})}renderProducts(){const{site:t,pageQuery:n}=this.context,a=Al({site:t,pageQuery:n}),i=this.state.errors||{},r={};return Object.keys(i).length>0&&this.state.plan&&(r[this.state.plan]=v("Please fill in required fields")),u.jsx(u.Fragment,{children:u.jsx(gx,{handleChooseSignup:(...o)=>this.handleChooseSignup(...o),products:a,onPlanSelect:this.handleSelectPlan,errors:r})})}renderFreeTrialMessage(){const{site:t,pageQuery:n}=this.context;return Nl({site:t,pageQuery:n})&&!Ht({site:t})&&Sn({site:t,pageQuery:n})?u.jsx("p",{className:"gh-portal-free-trial-notification","data-testid":"free-trial-notification-text",children:v("After a free trial ends, you will be charged the regular price for the tier you've chosen. You can always cancel before then.")}):null}renderLoginMessage(){const{brandColor:t,doAction:n}=this.context;return u.jsxs("div",{children:[this.renderFreeTrialMessage(),u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:v("Already a member?")}),u.jsx("button",{"data-test-button":"signin-switch","data-testid":"signin-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>n("switchPage",{page:"signin"}),children:u.jsx("span",{children:v("Sign in")})})]})]})}renderForm(){const t=this.getInputFields({state:this.state}),{site:n,pageQuery:a}=this.context;if(this.state.showNewsletterSelection)return u.jsx(Ep,{pageData:this.state.pageData,onBack:()=>{this.setState({showNewsletterSelection:!1})}});if(Ht({site:n}))return this.renderInviteOnlyMessage();if(PU({site:n})&&a==="free")return this.renderPaidMembersOnlyMessage();if(!$l({site:n})||!Sn({site:n,pageQuery:a}))return ea({site:n})?this.renderInviteOnlyMessage():this.renderMembersDisabledMessage();const i=a==="free"&&tp({site:n}),r=Ni({site:n})||i,o=this.renderSignupTerms();return u.jsx("section",{className:"gh-portal-signup",children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsx(Rl,{fields:t,onChange:(s,l)=>this.handleInputChange(s,l),onKeyDown:s=>this.onKeyDown(s)})}),u.jsxs("div",{children:[r?u.jsxs(u.Fragment,{children:[this.renderProducts(),o&&u.jsx("div",{className:"gh-portal-signup-terms-wrapper free-only",children:o})]}):u.jsxs(u.Fragment,{children:[o&&u.jsx("div",{className:"gh-portal-signup-terms-wrapper",children:o}),this.renderProducts()]}),r?u.jsx("div",{className:"gh-portal-btn-container",children:u.jsxs("div",{className:"gh-portal-logged-out-form-container",children:[this.renderSubmitButton(),this.renderLoginMessage()]})}):this.renderLoginMessage()]})]})})}renderPaidMembersOnlyMessage(){return u.jsx("section",{children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-paid-members-only-notification","data-testid":"paid-members-only-notification-text",children:v("This site only accepts paid members.")}),this.renderLoginMessage()]})})}renderInviteOnlyMessage(){return u.jsx("section",{children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-invite-only-notification","data-testid":"invite-only-notification-text",children:v("This site is invite-only, contact the owner for access.")}),this.renderLoginMessage()]})})}renderMembersDisabledMessage(){return u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:v("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t,pageQuery:n}=this.context,a=t.icon;return a?u.jsx("img",{className:"gh-portal-signup-logo",src:a,alt:t.title}):!Sn({site:t,pageQuery:n})||Ht({site:t})||!$l({site:t})?u.jsx(bx,{className:"gh-portal-icon gh-portal-icon-invitation"}):null}renderFormHeader(){const{site:t}=this.context,n=t.title||"";return u.jsxs("header",{className:"gh-portal-signup-header",children:[this.renderSiteIcon(),u.jsx("h1",{className:"gh-portal-main-title","data-testid":"site-title-text",children:n})]})}getClassNames(){const{site:t,pageQuery:n}=this.context,a=Ml({site:t,pageQuery:n}),i=this.getInputFields({state:this.state});let r="",o="";return(a.length<=1||Ht({site:t}))&&(a.length===1&&a[0].type==="free"||Ht({site:t})?(r=MU({site:t})?"singleplan":"noplan",i.length===1&&(r="single-field"),Ht({site:t})&&(o="invite-only",r="invite-only")):r="singleplan"),{sectionClass:r,footerClass:o}}render(){let{sectionClass:t}=this.getClassNames();return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"gh-portal-back-sitetitle",children:u.jsx(xp,{onBack:()=>{this.state.showNewsletterSelection?this.setState({showNewsletterSelection:!1}):this.context.doAction("closePopup")}})}),u.jsx(Oe,{}),u.jsxs("div",{className:"gh-portal-content signup "+t,children:[this.renderFormHeader(),this.renderForm()]})]})}};Xp.contextType=V;let Ip=Xp;const Ix=e=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1px;}")),C.createElement("rect",{className:"a",x:.75,y:4.5,width:22.5,height:15,rx:1.5,ry:1.5}),C.createElement("line",{className:"a",x1:15.687,y1:9.975,x2:19.5,y2:13.5}),C.createElement("line",{className:"a",x1:8.313,y1:9.975,x2:4.5,y2:13.5}),C.createElement("path",{className:"a",d:"M22.88,5.014l-9.513,6.56a2.406,2.406,0,0,1-2.734,0L1.12,5.014"})),A6=e=>{var t;return typeof((t=e.userAgentData)==null?void 0:t.platform)=="string"?e.userAgentData.platform==="Android":/android/i.test(e.userAgent)},N6=e=>/chrome/i.test(e.userAgent),I6=e=>A6(e)&&N6(e),Mx=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,M6=u.jsx("svg",{height:"24",width:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 49.4 512 399.4200000000001",children:u.jsxs("g",{fill:"none",fillRule:"evenodd",children:[u.jsxs("g",{fillRule:"nonzero",children:[u.jsx("path",{d:"M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z",fill:"#4285f4"}),u.jsx("path",{d:"M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z",fill:"#34a853"}),u.jsx("path",{d:"M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z",fill:"#fbbc04"})]}),u.jsx("path",{d:"M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z",fill:"#ea4335"}),u.jsx("path",{d:"M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z",fill:"#c5221f",fillRule:"nonzero"})]})}),F6=u.jsx("svg",{clipRule:"evenodd",fillRule:"evenodd",height:"2500",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 6876 6994",width:"2457",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M0 779L4033 0l-14 6994L0 6160zm1430 3632c-305-357-390-918-244-1384 203-648 718-867 1149-717 246 86 465 293 582 610 56 152 86 326 88 503 4 318-106 692-324 953-335 400-903 441-1250 35zm314-339c-150-223-191-573-120-864 99-404 352-541 563-447 121 54 228 183 285 381 27 95 42 203 43 314 2 198-52 432-159 595-164 250-442 275-612 22zm2552-2598h2341c131 0 238 107 238 238v86L5035 3039c-24 16-83 62-132 93-72 47-77 38-153-5-117-65-319-203-455-297V1474zm2580 875v2504c0 200-164 365-365 365H4296V3366c133 88 310 204 419 271 88 54 104 79 202 22 45-26 89-60 119-80l1840-1229z",fill:"#0072c6"})}),D6=u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 3386.34 3010.5",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",imageRendering:"optimizeQuality",fillRule:"evenodd",clipRule:"evenodd",children:u.jsx("path",{d:"M0 732.88h645.84l376.07 962.1 380.96-962.1h628.76l-946.8 2277.62H451.98l259.19-603.53L.02 732.88zm2763.84 768.75h-704.26L2684.65 0l701.69.03-622.5 1501.6zm-519.78 143.72c216.09 0 391.25 175.17 391.25 391.22 0 216.06-175.16 391.23-391.25 391.23-216.06 0-391.19-175.17-391.19-391.23 0-216.05 175.16-391.22 391.19-391.22z",fill:"#5f01d1",fillRule:"nonzero"})}),O6=u.jsxs("svg",{viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:"2",children:[u.jsx("path",{d:"M22.86 13.464l.002.002-10.005 11.105L0 10.419V4.315a.827.827 0 011.356-.637l14.265 11.846a3.722 3.722 0 004.758 0l2.481-2.06z",fill:"url(#prefix___Linear1)",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsx("path",{d:"M28.286 8.958l-5.426 4.506.002.002-7.184 6.345a3.31 3.31 0 01-4.308.065L0 10.42v18.142a3.724 3.724 0 003.724 3.724h24.562l2.571-11.664-2.571-11.664z",fill:"url(#prefix___Radial2)",fillRule:"nonzero",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsx("path",{d:"M28.286 8.963v23.323h3.99A3.724 3.724 0 0036 28.562V4.315a.827.827 0 00-1.356-.637l-6.358 5.285z",fill:"url(#prefix___Linear3)",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsxs("defs",{children:[u.jsxs("linearGradient",{id:"prefix___Linear1",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"scale(-43.6455) rotate(73.941 .222 -.49)",children:[u.jsx("stop",{offset:"0",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:"1",stopColor:"#7341ff"})]}),u.jsxs("linearGradient",{id:"prefix___Linear3",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"scale(-66.0342) rotate(65.129 .243 -.95)",children:[u.jsx("stop",{offset:"0",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:".27",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:"1",stopColor:"#7341ff"})]}),u.jsxs("radialGradient",{id:"prefix___Radial2",cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(35.9848 0 0 33.9185 30.723 11.814)",children:[u.jsx("stop",{offset:"0",stopColor:"#6d4aff"}),u.jsx("stop",{offset:".56",stopColor:"#6d4aff"}),u.jsx("stop",{offset:".99",stopColor:"#aa8eff"}),u.jsx("stop",{offset:"1",stopColor:"#aa8eff"})]})]})]}),_6=u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"2500",height:"2432",viewBox:"85.04 232.402 412.912 401.703",children:[u.jsx("path",{d:"M391.631 424.861l-4.477-1.119v-4.477c0-40.281-32.449-72.73-71.611-72.73-29.094 0-55.947 17.904-67.138 44.758l-3.355 7.834-5.595-5.596c-5.597-5.594-13.429-8.951-21.262-8.951a30.086 30.086 0 0 0-30.211 30.211l1.118 6.715-4.476 1.117c-21.26 6.715-35.807 25.736-35.807 46.996 0 26.854 22.38 49.234 49.234 49.234h185.745c25.734 0 48.113-21.262 48.113-48.115-1.114-22.379-16.78-41.401-40.278-45.877z",fill:"#333"}),u.jsx("path",{d:"M394.989 232.402H189.102c-58.185 0-104.062 46.996-104.062 104.062v193.578c0 58.186 46.995 104.062 104.062 104.062H393.87c58.187 0 104.062-46.996 104.062-104.062V337.583c1.118-58.185-45.877-105.181-102.943-105.181zm-11.19 298.76H198.054c-33.568 0-60.424-26.855-60.424-60.424 0-25.734 15.666-46.996 39.164-55.947 1.118-22.379 19.021-40.281 41.4-40.281 7.833 0 15.666 2.238 22.379 6.713 14.547-27.973 42.521-44.758 73.852-44.758 44.758 0 81.684 35.809 82.802 79.447 25.736 6.713 44.759 30.211 44.759 57.066-.001 31.328-25.737 58.184-58.187 58.184z",fill:"#333"}),u.jsx("path",{d:"M398.345 414.791c-2.237-44.758-38.044-79.445-82.802-79.445-31.33 0-60.424 17.904-73.852 44.76-6.714-4.477-14.546-6.715-22.379-6.715-22.379 0-40.282 17.902-41.401 40.281-23.498 8.951-39.163 31.33-39.163 55.947 0 33.568 26.855 60.424 60.424 60.424h185.746c32.448 0 59.304-26.854 59.304-59.305-2.237-25.737-20.14-49.233-45.877-55.947zm-14.546 105.181H198.054c-26.854 0-49.233-22.379-49.233-49.232 0-22.379 14.546-40.283 35.806-46.996l4.476-1.119-1.118-6.713c0-16.785 13.427-30.213 30.211-30.213 7.833 0 15.666 3.357 21.262 8.953l5.595 5.594 3.355-7.832c11.189-26.855 36.925-44.758 67.138-44.758 40.281 0 71.611 32.449 71.611 72.73v4.477l4.477 1.119c23.498 3.355 39.164 23.498 39.164 46.996-.003 25.734-21.264 46.994-46.999 46.994z",fill:"#e4e4e4"})]}),Hl=u.jsx(Ix,{className:"gh-portal-sniper-link-icon"}),R6={gmail:M6,outlook:F6,yahoo:D6,proton:O6,icloud:_6,hey:Hl,aol:Hl,mailru:Hl},U6={gmail:v("Open Gmail"),outlook:v("Open Outlook"),yahoo:v("Open Yahoo Mail"),proton:v("Open Proton Mail"),icloud:v("Open iCloud Mail"),hey:v("Open Hey"),aol:v("Open AOL Mail"),mailru:v("Open Mail.ru")};function Fx({sniperLinks:{android:e,desktop:t,provider:n}}){return u.jsxs("a",{href:I6(navigator)?e:t,target:"_blank",rel:"noreferrer noopener",className:"gh-portal-btn gh-portal-btn-sniper-link",children:[Mx(R6,n)??Hl,u.jsx("span",{children:Mx(U6,n)??v("Open email")})]})}const L6=`
|
|
5726
|
+
`,Xp=class Xp extends re.Component{constructor(t){super(t),this.handleSelectPlan=(n,a)=>{n&&n.preventDefault(),this.timeoutId=setTimeout(()=>{this.setState(()=>({plan:a}))},5)},this.state={name:"",email:"",plan:"free",showNewsletterSelection:!1,termsCheckboxChecked:!1},this.termsRef=re.createRef()}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"}),this.handleSelectedPlan()}componentDidUpdate(){this.handleSelectedPlan()}handleSelectedPlan(){const{site:t,pageQuery:n}=this.context,a=Ml({site:t,pageQuery:n}),i=this.getSelectedPriceId(a,this.state.plan);i!==this.state.plan&&this.setState({plan:i})}componentWillUnmount(){clearTimeout(this.timeoutId)}getFormErrors(t){const a=this.context.site.portal_signup_checkbox_required&&this.context.site.portal_signup_terms_html&&!t.termsCheckboxChecked;return{...Ul({fields:this.getInputFields({state:t})}),checkbox:a}}doSignup(){this.setState(t=>({errors:this.getFormErrors(t)}),()=>{const{site:t,doAction:n}=this.context,{name:a,email:i,plan:r,phonenumber:o,token:s,errors:l}=this.state,c=l&&Object.values(l).filter(p=>!!p).length>0,m={...l};delete m.checkbox,(l==null?void 0:l.checkbox)&&Object.values(m).every(p=>!p)&&this.termsRef.current&&this.termsRef.current.scrollIntoView({behavior:"smooth",block:"center"}),c||(lo({site:t})?this.setState({showNewsletterSelection:!0,pageData:{name:a,email:i,plan:r,phonenumber:o,token:s},errors:{}}):(this.setState({errors:{}}),n("signup",{name:a,email:i,phonenumber:o,plan:r,token:s})))})}handleSignup(t){t.preventDefault(),this.doSignup()}handleChooseSignup(t,n){t.preventDefault(),this.setState({plan:n},()=>{this.doSignup()})}handleInputChange(t,n){const a=n.name,i=t.target.value;this.setState({[a]:i})}onKeyDown(t){t.keyCode===13&&this.handleSignup(t)}getSelectedPriceId(t=[],n){return!t||t.length===0||n==="free"?"free":t.some(i=>i.id===n)?n:t[0].id||"free"}getInputFields({state:t,fieldNames:n}){const{site:{portal_name:a}}=this.context,i=t.errors||{},r=[{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,tabIndex:2,errorMessage:i.email||""},{type:"text",value:t.phonenumber,placeholder:v("+1 (123) 456-7890"),label:v("Phone number"),name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}];return a&&r.unshift({type:"text",value:t.name,placeholder:v("Jamie Larson"),label:v("Name"),name:"name",required:!0,tabIndex:1,errorMessage:i.name||""}),r[0].autoFocus=!0,n&&n.length>0?r.filter(o=>n.includes(o.name)):r}renderSignupTerms(){var s;const{site:t}=this.context;if(t.portal_signup_terms_html===null||t.portal_signup_terms_html==="")return null;const n=l=>{this.setState({termsCheckboxChecked:l.target.checked})},a=u.jsx("div",{className:"gh-portal-signup-terms-content",dangerouslySetInnerHTML:{__html:Nx(t.portal_signup_terms_html)}}),i=t.portal_signup_checkbox_required?u.jsxs("label",{children:[u.jsx("input",{type:"checkbox",checked:!!this.state.termsCheckboxChecked,required:!0,onChange:n}),u.jsx("span",{className:"checkbox"}),a]}):a,o=`gh-portal-signup-terms ${(s=this.state.errors)!=null&&s.checkbox?"gh-portal-error":""}`;return u.jsx("div",{className:o,onClick:kx,ref:this.termsRef,children:i})}renderSubmitButton(){const{action:t,site:n,brandColor:a,pageQuery:i}=this.context;if(Ht({site:n})||!Sn({site:n,pageQuery:i}))return null;let r=v("Continue");const o=i==="free"&&tp({site:n});if(Ni({site:n})||o)r=v("Sign up");else return null;let s=!1;t==="signup:running"&&(r=v("Sending..."),s=!0);let l=!1;t==="signup:failed"&&(r=v("Retry"),l=!0);const c=t==="signup:running";return u.jsx(ze,{style:{width:"100%"},retry:l,onClick:m=>this.handleSignup(m),disabled:c,brandColor:a,label:r,isRunning:s,tabIndex:3})}renderProducts(){const{site:t,pageQuery:n}=this.context,a=Al({site:t,pageQuery:n}),i=this.state.errors||{},r={};return Object.keys(i).length>0&&this.state.plan&&(r[this.state.plan]=v("Please fill in required fields")),u.jsx(u.Fragment,{children:u.jsx(gx,{handleChooseSignup:(...o)=>this.handleChooseSignup(...o),products:a,onPlanSelect:this.handleSelectPlan,errors:r})})}renderFreeTrialMessage(){const{site:t,pageQuery:n}=this.context;return Nl({site:t,pageQuery:n})&&!Ht({site:t})&&Sn({site:t,pageQuery:n})?u.jsx("p",{className:"gh-portal-free-trial-notification","data-testid":"free-trial-notification-text",children:v("After a free trial ends, you will be charged the regular price for the tier you've chosen. You can always cancel before then.")}):null}renderLoginMessage(){const{brandColor:t,doAction:n}=this.context;return u.jsxs("div",{children:[this.renderFreeTrialMessage(),u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:v("Already a member?")}),u.jsx("button",{"data-test-button":"signin-switch","data-testid":"signin-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>n("switchPage",{page:"signin"}),children:u.jsx("span",{children:v("Sign in")})})]})]})}renderForm(){const t=this.getInputFields({state:this.state}),{site:n,pageQuery:a}=this.context;if(this.state.showNewsletterSelection)return u.jsx(Ep,{pageData:this.state.pageData,onBack:()=>{this.setState({showNewsletterSelection:!1})}});if(Ht({site:n}))return this.renderInviteOnlyMessage();if(PU({site:n})&&a==="free")return this.renderPaidMembersOnlyMessage();if(!$l({site:n})||!Sn({site:n,pageQuery:a}))return ea({site:n})?this.renderInviteOnlyMessage():this.renderMembersDisabledMessage();const i=a==="free"&&tp({site:n}),r=Ni({site:n})||i,o=this.renderSignupTerms();return u.jsx("section",{className:"gh-portal-signup",children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsx(Rl,{fields:t,onChange:(s,l)=>this.handleInputChange(s,l),onKeyDown:s=>this.onKeyDown(s)})}),u.jsxs("div",{children:[r?u.jsxs(u.Fragment,{children:[this.renderProducts(),o&&u.jsx("div",{className:"gh-portal-signup-terms-wrapper free-only",children:o})]}):u.jsxs(u.Fragment,{children:[o&&u.jsx("div",{className:"gh-portal-signup-terms-wrapper",children:o}),this.renderProducts()]}),r?u.jsx("div",{className:"gh-portal-btn-container",children:u.jsxs("div",{className:"gh-portal-logged-out-form-container",children:[this.renderSubmitButton(),this.renderLoginMessage()]})}):this.renderLoginMessage()]})]})})}renderPaidMembersOnlyMessage(){return u.jsx("section",{children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-paid-members-only-notification","data-testid":"paid-members-only-notification-text",children:v("This site only accepts paid members.")}),this.renderLoginMessage()]})})}renderInviteOnlyMessage(){return u.jsx("section",{children:u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-invite-only-notification","data-testid":"invite-only-notification-text",children:v("This site is invite-only, contact the owner for access.")}),this.renderLoginMessage()]})})}renderMembersDisabledMessage(){return u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:v("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t,pageQuery:n}=this.context,a=t.icon;return a?u.jsx("img",{className:"gh-portal-signup-logo",src:a,alt:t.title}):!Sn({site:t,pageQuery:n})||Ht({site:t})||!$l({site:t})?u.jsx(bx,{className:"gh-portal-icon gh-portal-icon-invitation"}):null}renderFormHeader(){const{site:t}=this.context,n=t.title||"";return u.jsxs("header",{className:"gh-portal-signup-header",children:[this.renderSiteIcon(),u.jsx("h1",{className:"gh-portal-main-title","data-testid":"site-title-text",children:n})]})}getClassNames(){const{site:t,pageQuery:n}=this.context,a=Ml({site:t,pageQuery:n}),i=this.getInputFields({state:this.state});let r="",o="";return(a.length<=1||Ht({site:t}))&&(a.length===1&&a[0].type==="free"||Ht({site:t})?(r=MU({site:t})?"singleplan":"noplan",i.length===1&&(r="single-field"),Ht({site:t})&&(o="invite-only",r="invite-only")):r="singleplan"),{sectionClass:r,footerClass:o}}render(){let{sectionClass:t}=this.getClassNames();return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"gh-portal-back-sitetitle",children:u.jsx(xp,{onBack:()=>{this.state.showNewsletterSelection?this.setState({showNewsletterSelection:!1}):this.context.doAction("closePopup")}})}),u.jsx(Oe,{}),u.jsxs("div",{className:"gh-portal-content signup "+t,children:[this.renderFormHeader(),this.renderForm()]})]})}};Xp.contextType=V;let Ip=Xp;const Ix=e=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1px;}")),C.createElement("rect",{className:"a",x:.75,y:4.5,width:22.5,height:15,rx:1.5,ry:1.5}),C.createElement("line",{className:"a",x1:15.687,y1:9.975,x2:19.5,y2:13.5}),C.createElement("line",{className:"a",x1:8.313,y1:9.975,x2:4.5,y2:13.5}),C.createElement("path",{className:"a",d:"M22.88,5.014l-9.513,6.56a2.406,2.406,0,0,1-2.734,0L1.12,5.014"})),A6=e=>{var t;return typeof((t=e.userAgentData)==null?void 0:t.platform)=="string"?e.userAgentData.platform==="Android":/android/i.test(e.userAgent)},N6=e=>/chrome/i.test(e.userAgent),I6=e=>A6(e)&&N6(e),Mx=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,M6=u.jsx("svg",{height:"24",width:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 49.4 512 399.4200000000001",children:u.jsxs("g",{fill:"none",fillRule:"evenodd",children:[u.jsxs("g",{fillRule:"nonzero",children:[u.jsx("path",{d:"M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z",fill:"#4285f4"}),u.jsx("path",{d:"M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z",fill:"#34a853"}),u.jsx("path",{d:"M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z",fill:"#fbbc04"})]}),u.jsx("path",{d:"M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z",fill:"#ea4335"}),u.jsx("path",{d:"M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z",fill:"#c5221f",fillRule:"nonzero"})]})}),F6=u.jsx("svg",{clipRule:"evenodd",fillRule:"evenodd",height:"2500",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 6876 6994",width:"2457",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M0 779L4033 0l-14 6994L0 6160zm1430 3632c-305-357-390-918-244-1384 203-648 718-867 1149-717 246 86 465 293 582 610 56 152 86 326 88 503 4 318-106 692-324 953-335 400-903 441-1250 35zm314-339c-150-223-191-573-120-864 99-404 352-541 563-447 121 54 228 183 285 381 27 95 42 203 43 314 2 198-52 432-159 595-164 250-442 275-612 22zm2552-2598h2341c131 0 238 107 238 238v86L5035 3039c-24 16-83 62-132 93-72 47-77 38-153-5-117-65-319-203-455-297V1474zm2580 875v2504c0 200-164 365-365 365H4296V3366c133 88 310 204 419 271 88 54 104 79 202 22 45-26 89-60 119-80l1840-1229z",fill:"#0072c6"})}),D6=u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 3386.34 3010.5",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",imageRendering:"optimizeQuality",fillRule:"evenodd",clipRule:"evenodd",children:u.jsx("path",{d:"M0 732.88h645.84l376.07 962.1 380.96-962.1h628.76l-946.8 2277.62H451.98l259.19-603.53L.02 732.88zm2763.84 768.75h-704.26L2684.65 0l701.69.03-622.5 1501.6zm-519.78 143.72c216.09 0 391.25 175.17 391.25 391.22 0 216.06-175.16 391.23-391.25 391.23-216.06 0-391.19-175.17-391.19-391.23 0-216.05 175.16-391.22 391.19-391.22z",fill:"#5f01d1",fillRule:"nonzero"})}),O6=u.jsxs("svg",{viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:"2",children:[u.jsx("path",{d:"M22.86 13.464l.002.002-10.005 11.105L0 10.419V4.315a.827.827 0 011.356-.637l14.265 11.846a3.722 3.722 0 004.758 0l2.481-2.06z",fill:"url(#prefix___Linear1)",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsx("path",{d:"M28.286 8.958l-5.426 4.506.002.002-7.184 6.345a3.31 3.31 0 01-4.308.065L0 10.42v18.142a3.724 3.724 0 003.724 3.724h24.562l2.571-11.664-2.571-11.664z",fill:"url(#prefix___Radial2)",fillRule:"nonzero",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsx("path",{d:"M28.286 8.963v23.323h3.99A3.724 3.724 0 0036 28.562V4.315a.827.827 0 00-1.356-.637l-6.358 5.285z",fill:"url(#prefix___Linear3)",transform:"matrix(13.8889 0 0 13.8889 6 6)"}),u.jsxs("defs",{children:[u.jsxs("linearGradient",{id:"prefix___Linear1",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"scale(-43.6455) rotate(73.941 .222 -.49)",children:[u.jsx("stop",{offset:"0",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:"1",stopColor:"#7341ff"})]}),u.jsxs("linearGradient",{id:"prefix___Linear3",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"scale(-66.0342) rotate(65.129 .243 -.95)",children:[u.jsx("stop",{offset:"0",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:".27",stopColor:"#e3d9ff"}),u.jsx("stop",{offset:"1",stopColor:"#7341ff"})]}),u.jsxs("radialGradient",{id:"prefix___Radial2",cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(35.9848 0 0 33.9185 30.723 11.814)",children:[u.jsx("stop",{offset:"0",stopColor:"#6d4aff"}),u.jsx("stop",{offset:".56",stopColor:"#6d4aff"}),u.jsx("stop",{offset:".99",stopColor:"#aa8eff"}),u.jsx("stop",{offset:"1",stopColor:"#aa8eff"})]})]})]}),_6=u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"2500",height:"2432",viewBox:"85.04 232.402 412.912 401.703",children:[u.jsx("path",{d:"M391.631 424.861l-4.477-1.119v-4.477c0-40.281-32.449-72.73-71.611-72.73-29.094 0-55.947 17.904-67.138 44.758l-3.355 7.834-5.595-5.596c-5.597-5.594-13.429-8.951-21.262-8.951a30.086 30.086 0 0 0-30.211 30.211l1.118 6.715-4.476 1.117c-21.26 6.715-35.807 25.736-35.807 46.996 0 26.854 22.38 49.234 49.234 49.234h185.745c25.734 0 48.113-21.262 48.113-48.115-1.114-22.379-16.78-41.401-40.278-45.877z",fill:"#333"}),u.jsx("path",{d:"M394.989 232.402H189.102c-58.185 0-104.062 46.996-104.062 104.062v193.578c0 58.186 46.995 104.062 104.062 104.062H393.87c58.187 0 104.062-46.996 104.062-104.062V337.583c1.118-58.185-45.877-105.181-102.943-105.181zm-11.19 298.76H198.054c-33.568 0-60.424-26.855-60.424-60.424 0-25.734 15.666-46.996 39.164-55.947 1.118-22.379 19.021-40.281 41.4-40.281 7.833 0 15.666 2.238 22.379 6.713 14.547-27.973 42.521-44.758 73.852-44.758 44.758 0 81.684 35.809 82.802 79.447 25.736 6.713 44.759 30.211 44.759 57.066-.001 31.328-25.737 58.184-58.187 58.184z",fill:"#333"}),u.jsx("path",{d:"M398.345 414.791c-2.237-44.758-38.044-79.445-82.802-79.445-31.33 0-60.424 17.904-73.852 44.76-6.714-4.477-14.546-6.715-22.379-6.715-22.379 0-40.282 17.902-41.401 40.281-23.498 8.951-39.163 31.33-39.163 55.947 0 33.568 26.855 60.424 60.424 60.424h185.746c32.448 0 59.304-26.854 59.304-59.305-2.237-25.737-20.14-49.233-45.877-55.947zm-14.546 105.181H198.054c-26.854 0-49.233-22.379-49.233-49.232 0-22.379 14.546-40.283 35.806-46.996l4.476-1.119-1.118-6.713c0-16.785 13.427-30.213 30.211-30.213 7.833 0 15.666 3.357 21.262 8.953l5.595 5.594 3.355-7.832c11.189-26.855 36.925-44.758 67.138-44.758 40.281 0 71.611 32.449 71.611 72.73v4.477l4.477 1.119c23.498 3.355 39.164 23.498 39.164 46.996-.003 25.734-21.264 46.994-46.999 46.994z",fill:"#e4e4e4"})]}),Hl=u.jsx(Ix,{className:"gh-portal-inbox-link-icon"}),R6={gmail:M6,outlook:F6,yahoo:D6,proton:O6,icloud:_6,hey:Hl,aol:Hl,mailru:Hl},U6={gmail:v("Open Gmail"),outlook:v("Open Outlook"),yahoo:v("Open Yahoo Mail"),proton:v("Open Proton Mail"),icloud:v("Open iCloud Mail"),hey:v("Open Hey"),aol:v("Open AOL Mail"),mailru:v("Open Mail.ru")};function Fx({inboxLinks:{android:e,desktop:t,provider:n}}){return u.jsxs("a",{href:I6(navigator)?e:t,target:"_blank",rel:"noreferrer noopener",className:"gh-portal-btn gh-portal-btn-inbox-link",children:[Mx(R6,n)??Hl,u.jsx("span",{children:Mx(U6,n)??v("Open email")})]})}const L6=`
|
|
5727
5727
|
.gh-portal-icon-envelope {
|
|
5728
5728
|
width: 44px;
|
|
5729
5729
|
margin: 12px 0 10px;
|
|
@@ -5789,7 +5789,7 @@ html[dir=rtl] .gh-portal-signup-terms .checkbox:before {
|
|
|
5789
5789
|
line-height: 1.6em;
|
|
5790
5790
|
margin-bottom: 0;
|
|
5791
5791
|
}
|
|
5792
|
-
`,Di="otc",Qp=class Qp extends re.Component{constructor(t){super(t),this.state={[Di]:"",errors:{},isFocused:!1}}getDescriptionConfig(t){return{signin:{withOTC:v("An email has been sent to {submittedEmailOrInbox}. Click the link inside or enter your code below.",{submittedEmailOrInbox:t}),withoutOTC:v("A login link has been sent to your inbox. If it doesn't arrive in 3 minutes, be sure to check your spam folder."),withoutOTCInviteOnly:v("If you have an account, a sign in link will be sent to you shortly. Please check your inbox and spam folder.")},signup:v("To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!")}}getTranslatedDescription({lastPage:t,otcRef:n,submittedEmailOrInbox:a}){const i=this.getDescriptionConfig(a);if((t==="signup"||t==="signin"?t:"signin")==="signup")return i.signup;if(n)return i.signin.withOTC;const{site:o}=this.context;return Ht({site:o})?i.signin.withoutOTCInviteOnly:i.signin.withoutOTC}renderFormHeader(){const{otcRef:t,pageData:n,lastPage:a}=this.context,i=n!=null&&n.email?n.email:v("your inbox"),r=v("Now check your email!"),o=this.getTranslatedDescription({lastPage:a,otcRef:t,submittedEmailOrInbox:i});return u.jsxs("section",{className:"gh-portal-inbox-notification",children:[u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(Ix,{className:"gh-portal-icon gh-portal-icon-envelope"}),u.jsx("h2",{className:"gh-portal-main-title",children:r})]}),u.jsx("p",{children:o})]})}renderLoginMessage(){return u.jsx(u.Fragment,{children:u.jsx("div",{style:{color:"#1d1d1d",fontWeight:"bold",cursor:"pointer"},onClick:()=>this.context.doAction("switchPage",{page:"signin"}),children:v("Back to Log in")})})}handleClose(){this.context.doAction("closePopup")}renderCloseButton(){var i;const{site:t,
|
|
5792
|
+
`,Di="otc",Qp=class Qp extends re.Component{constructor(t){super(t),this.state={[Di]:"",errors:{},isFocused:!1}}getDescriptionConfig(t){return{signin:{withOTC:v("An email has been sent to {submittedEmailOrInbox}. Click the link inside or enter your code below.",{submittedEmailOrInbox:t}),withoutOTC:v("A login link has been sent to your inbox. If it doesn't arrive in 3 minutes, be sure to check your spam folder."),withoutOTCInviteOnly:v("If you have an account, a sign in link will be sent to you shortly. Please check your inbox and spam folder.")},signup:v("To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!")}}getTranslatedDescription({lastPage:t,otcRef:n,submittedEmailOrInbox:a}){const i=this.getDescriptionConfig(a);if((t==="signup"||t==="signin"?t:"signin")==="signup")return i.signup;if(n)return i.signin.withOTC;const{site:o}=this.context;return Ht({site:o})?i.signin.withoutOTCInviteOnly:i.signin.withoutOTC}renderFormHeader(){const{otcRef:t,pageData:n,lastPage:a}=this.context,i=n!=null&&n.email?n.email:v("your inbox"),r=v("Now check your email!"),o=this.getTranslatedDescription({lastPage:a,otcRef:t,submittedEmailOrInbox:i});return u.jsxs("section",{className:"gh-portal-inbox-notification",children:[u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(Ix,{className:"gh-portal-icon gh-portal-icon-envelope"}),u.jsx("h2",{className:"gh-portal-main-title",children:r})]}),u.jsx("p",{children:o})]})}renderLoginMessage(){return u.jsx(u.Fragment,{children:u.jsx("div",{style:{color:"#1d1d1d",fontWeight:"bold",cursor:"pointer"},onClick:()=>this.context.doAction("switchPage",{page:"signin"}),children:v("Back to Log in")})})}handleClose(){this.context.doAction("closePopup")}renderCloseButton(){var i;const{site:t,inboxLinks:n}=this.context;return((i=t.labs)==null?void 0:i.inboxlinks)!==!1&&n?u.jsx(Fx,{inboxLinks:n}):u.jsx(ze,{style:{width:"100%"},onClick:r=>this.handleClose(r),brandColor:this.context.brandColor,label:v("Close")})}handleSubmit(t){t.preventDefault();const{action:n}=this.context;n==="verifyOTC:running"||this.doVerifyOTC()}doVerifyOTC(){const t=v("Enter code above");this.setState(n=>{const a=(n.otc||"").trim();return{errors:{[Di]:a?"":t}}},()=>{const{otc:n,errors:a}=this.state,{otcRef:i}=this.context,{redirect:r}=this.context.pageData??{};!(a&&Object.values(a).filter(s=>!!s).length>0)&&i&&this.context.doAction("verifyOTC",{otc:n,otcRef:i,redirect:r})})}handleInputChange(t,n){const a=n.name,i=t.target.value;if(a===Di){const r=i.replace(/[^0-9]/g,"");this.setState({[a]:r},()=>{r.length===6&&this.doVerifyOTC()})}else this.setState({[a]:i})}renderOTCForm(){var f;const{action:t,actionErrorMessage:n,otcRef:a,site:i,inboxLinks:r}=this.context,o=((f=i.labs)==null?void 0:f.inboxlinks)!==!1,s=this.state.errors||{};if(!a)return null;const l=t==="verifyOTC:running",c=t==="verifyOTC:failed",m=c&&n?n:s.otc;return u.jsxs("form",{onSubmit:p=>this.handleSubmit(p),children:[u.jsxs("section",{className:"gh-portal-section gh-portal-otp",children:[u.jsx("div",{className:`gh-portal-otp-container ${this.state.isFocused&&"focused"} ${m&&"error"}`,children:u.jsx("input",{id:`input-${Di}`,className:`gh-portal-input ${this.state.otc&&"entry"} ${m&&"error"}`,placeholder:"––––––",name:Di,type:"text",value:this.state.otc,inputMode:"numeric",maxLength:6,pattern:"[0-9]*",autoComplete:"one-time-code",autoCorrect:"off",autoCapitalize:"off",autoFocus:!0,"aria-label":v("Code"),onChange:p=>this.handleInputChange(p,{name:Di}),onFocus:()=>this.setState({isFocused:!0}),onBlur:()=>this.setState({isFocused:!1})})}),m&&u.jsx("div",{className:"gh-portal-otp-error",children:m})]}),u.jsx("footer",{className:"gh-portal-signin-footer gh-button-row",children:o&&r&&!this.state.otc?u.jsx(Fx,{inboxLinks:r}):u.jsx(ze,{style:{width:"100%"},onClick:p=>this.handleSubmit(p),brandColor:this.context.brandColor,label:v(l?"Verifying...":"Continue"),isRunning:l,retry:c,disabled:l})})]})}render(){const{otcRef:t}=this.context,n=!!t;return u.jsxs("div",{className:"gh-portal-content",children:[u.jsx(Oe,{}),this.renderFormHeader(),n?this.renderOTCForm():this.renderCloseButton()]})}};Qp.contextType=V;let Mp=Qp;const Y6=`
|
|
5793
5793
|
.gh-portal-popupnotification {
|
|
5794
5794
|
right: 42px;
|
|
5795
5795
|
}
|
|
@@ -6519,14 +6519,14 @@ html[dir="rtl"] .gh-portal-btn-site-title-back span {
|
|
|
6519
6519
|
stroke: var(--grey3);
|
|
6520
6520
|
}
|
|
6521
6521
|
|
|
6522
|
-
.gh-portal-btn-
|
|
6522
|
+
.gh-portal-btn-inbox-link {
|
|
6523
6523
|
background: var(--white);
|
|
6524
6524
|
gap: 8px;
|
|
6525
6525
|
min-width: unset;
|
|
6526
6526
|
width: 100%;
|
|
6527
6527
|
}
|
|
6528
6528
|
|
|
6529
|
-
.gh-portal-btn-
|
|
6529
|
+
.gh-portal-btn-inbox-link svg {
|
|
6530
6530
|
width: 20px;
|
|
6531
6531
|
height: 20px;
|
|
6532
6532
|
flex-shrink: 0;
|
|
@@ -7520,5 +7520,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
|
|
|
7520
7520
|
.gh-portal-hide {
|
|
7521
7521
|
display: none;
|
|
7522
7522
|
}
|
|
7523
|
-
`;function y5({site:e}){return Zm+h5+uL+LL+XL+TL()+lL+iL+sL+Ow+L6+z6+V6()+lp+Y6+f5+g5+G6+e5+t5+n5+i5+s5+c5}const nh=class nh extends re.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Ul({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:v("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=$l({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:v("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):ea({site:t})?null:u.jsx(bx,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:v("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};nh.contextType=V;let _p=nh;const b5=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:v("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:v("Contact support")})})})})]})},k5=()=>{const{member:e,brandColor:t}=C.useContext(V),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Jm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},v5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(V);if(!$l({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},w5=()=>{const{member:e,site:t}=C.useContext(V),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=Ft({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const r=a==null?void 0:a.current_period_end;if(i&&Qm({member:e})){const o=Qm({member:e}),s=En(o);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(np({sub:a})){const o=En(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will start on {subscriptionStart}",{subscriptionStart:o})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will renew on {renewalDate}",{renewalDate:En(r)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(v5,{})]})},x5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(V),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:En(m)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},E5=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},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"})),S5=()=>{const{member:e,site:t,doAction:n}=C.useContext(V),a=()=>{const p=Ft({member:e});n("editBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:y,subscription:k})=>{const{next_payment:j}=k||{};let b="";if(p){const{amount:z=0,currency:R,interval:_}=p;b=`${Intl.NumberFormat("en",{currency:R,style:"currency"}).format(z/100)}/${v(_)}`}const w=Qm({member:e});y&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";const P=np({sub:k});if(P&&(E="gh-portal-account-old-price"),P)return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(C5,{subscription:k})]});let $=$5({nextPayment:j});$&&(E="gh-portal-account-old-price");const F=()=>$?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(E5,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:$})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(F,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:y=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const y=`**** **** **** ${p}`;return u.jsx("p",{children:y})}return null},l=({defaultCardLast4:p,isComplimentary:y})=>{const{action:k}=C.useContext(V),j=k==="editBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return y?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"update-billing",children:j})]})},c=Ft({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:y}=c||{};let k=v("Plan");return jl({site:t})&&Uw({member:e})&&(k=Uw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:y})]})}return null};function C5({subscription:e}){if(np({sub:e})){const t=En(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function $5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("Ends {offerEndDate}",{offerEndDate:En(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function j5(){const{member:e,site:t,doAction:n}=C.useContext(V);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ap({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Dl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Ux=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},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 T5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Ux,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function P5(){const{doAction:e,member:t,site:n}=C.useContext(V),a=Bw({member:t}),i=oo({site:n}),r=Tl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(T5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:v("Manage")})]})}const z5=(e,t)=>lo({site:e})&&oo({site:e})||Tl({site:e})||Bw({member:t}),A5=e=>!lo({site:e})&&oo({site:e})&&!Tl({site:e}),N5=()=>{const{member:e,doAction:t,site:n}=C.useContext(V),{name:a,email:i}=e,r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},o=z5(n,e),s=A5(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||v("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:l=>r(),children:v("Edit")})]}),u.jsx(S5,{}),o&&u.jsx(P5,{}),s&&u.jsx(j5,{})]})})},I5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(k5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(w5,{}),u.jsx(x5,{}),u.jsx(N5,{})]})]}),ah=class ah extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=uo({site:n});return!t||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(I5,{}),u.jsx(b5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ah.contextType=V;let Rp=ah;const ih=class ih extends re.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Ul({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=v("Save");this.context.action==="updateProfile:failed"&&(n=v("Retry"));const a=!!t;return u.jsx(ze,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:v("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(Jm,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};ih.contextType=V;let Up=ih;function M5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(V);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Email preferences")})]})}function F5({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function D5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(V),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function O5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(V),i=za({site:a});return n?i.map(r=>u.jsx(F5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function _5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Lx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=C.useContext(V),y=!(n!=null&&n.length)&&(s&&!l||!s),j=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(M5,{}),u.jsx(j,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(O5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(D5,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(ze,{isRunning:!1,onClick:()=>{r()},disabled:y,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ap({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(_5,{isPaid:o,site:p,subscribedNewsletters:n})}),ap({member:f})&&!y&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function R5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(V);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);y(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[p,y]=C.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:j}=e||{};return C.useEffect(()=>{y((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Lx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{y(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{y([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:j})}function U5(){const{site:e}=C.useContext(V),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function L5(){const{site:e}=C.useContext(V),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(U5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Yx({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function Y5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(V),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=C.useState(!1),[y,k]=C.useState(m),[j,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),$=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Yx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},F=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Yx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await $([]):n.newsletterUuid?await $(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await F(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(ko,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(cp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!j)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(L5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Lx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:y,updateSubscribedNewsletters:async _=>{await $(_),p(!0)},updateCommentNotifications:F,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function B5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(V);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Tl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Ux,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:v("Emails disabled")}),u.jsx("p",{children:v("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.")})]}),u.jsx(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:v("Re-enable emails"),isRunning:r})]})}function H5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(V),i=`mailto:${uo({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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).")}),u.jsx("h4",{children:v("Spam complaints")}),u.jsx("p",{children:v("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:v("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.")}),u.jsx("h4",{children:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:v("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:v("Need more help? Contact support")})})]})]})}function V5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(V),o=uo({site:n}),s=`mailto:${o}`,l=LU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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".`)}),u.jsx("h4",{children:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}const Lp={signin:_p,signup:Ip,accountHome:Rp,accountPlan:wp,accountProfile:Up,accountEmail:R5,signupNewsletter:Ep,unsubscribe:Y5,magiclink:Mp,loading:ko,offer:Dp,feedback:Q6,emailSuppressed:B5,emailSuppressionFAQ:H5,emailReceivingFAQ:V5,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(V);return C.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,y=Vl({siteUrl:c});try{const k=await y.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(Op,{error:n}):i?u.jsx(Op,{error:i}):null},supportSuccess:r5,supportError:Op,recommendations:p5},Yp=function({page:e}){return Object.keys(Lp).includes(e)?e:"signup"},W5=function({page:e}){return e.includes("account")},G5=function({page:e}){return e.includes("offer")},K5=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},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"})),rh=class rh extends re.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(K5,{}),"Powered by Ghost"]})}};rh.contextType=V;let Wl=rh;const Bx=()=>({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 q5({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const oh=class oh extends re.Component{componentDidMount(){this.node&&!$e(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&$e(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Yp({page:t});const n=Lp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Fp,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,o=Al({site:a,pageQuery:n}).length;Yp({page:t});const l={...Bx().page[t]};let c="",m="regular",f="",p=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!Ht({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const y=so({site:a});(y&&o>2||!y&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const j=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:j,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(q5,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})})]})}};oh.contextType=V;let Bp=oh;const sh=class sh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Lp[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=y5({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=Bx(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(Km,{style:o,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(Bp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};sh.contextType=V;let Hp=sh;Gl({products:Vp({numOfProducts:1})});function Je(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function Gl({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Vp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:y=!0,portalButton:k=!0,portalName:j=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:F=[],posts:z=J5(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:m,free_price_name:f,free_price_description:p,is_stripe_configured:y,portal_button:k,portal_name:j,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:F,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:$,posts:z}}function Hx({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:f="active",tierId:p="",tierName:y="Basic",redemptionType:k="signup"}={}){return{id:`offer_${Je()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:f,tier:{id:`${p}`,name:y},redemption_type:k}}function Wt({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:`member_${Je()}`,email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function J5({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(Z5({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function Z5({id:e=`post_${Je()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function Vp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Vx({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Je()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:Wx({numOfBenefits:o}),trial_days:s}}function Vx({name:e="Free tier",description:t="Free tier description",id:n=`product_${Je()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Wx({numOfBenefits:a})}}function Wx({numOfBenefits:e}){const t=Je();return[Kl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Kl({name:`Latest gear reviews #${t.substring(6,12)}`}),Kl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Kl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Kl({id:e=`benefit_${Je()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${Je()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Je()}`,stripe_product_id:`prod_${Je()}`,type:"recurring"}}function Na({id:e=`sub_${Je()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=Q5,priceId:l=`price_${Je()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:y=null,tier:k=null}={}){return{id:e,customer:{id:`cus_${Je()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Je()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:m,trial_end_at:p,next_payment:y,tier:k,price:{id:`stripe_price_${Je()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Je()}`,product_id:`prod_${Je()}`}}}}function Gx(){const e=Vp({numOfProducts:1}),t=e.map(a=>a.id);return Gl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Gx();const X5=Gl({products:[Oi({numOfBenefits:2,type:"free"})]}),Q5=Hx({tierId:(Xx=X5.products[0])==null?void 0:Xx.id});Wt(),Wt({paid:!0,subscriptions:[Na()]}),Wt({paid:!0,subscriptions:[]}),Wt({paid:!0,subscriptions:[Na({amount:0})]}),Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Gx();const ql=[Vx({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=Gl({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:ql,portalProducts:ql.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),Kx=Hx({tierId:(Qx=_i.products[1])==null?void 0:Qx.id}),Jl={free:Wt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Wt({paid:!0,subscriptions:[Na({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:Wt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Wt({paid:!0,subscriptions:[Na({amount:0})]}),preview:Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function e8(){var n;if(!ql||!ql[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Wt({paid:!0,subscriptions:[Na({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:_i,member:t}}function t8(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function n8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function a8({state:e}){return{showPopup:!e.showPopup}}function i8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function r8({state:e}){return e.lastPage?{page:e.lastPage}:qx({state:e})}function qx({state:e}){return Xm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function o8({data:e}){return{showNotification:!0,...e}}function s8(){return{showNotification:!1}}async function l8({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to log out, please try again")})}}}async function u8({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,sniperLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},sniperLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:xn(a,v("Failed to log in, please try again"))})}}}function c8({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.sniperLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,sniperLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function d8({data:e,api:t}){var a;const n=v("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:xn((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:xn(i,n)}}}async function m8({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({sniperLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",sniperLinks:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,v("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function p8({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to process checkout, please try again")})}}}async function h8({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update subscription, please try again")})}}}async function f8({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function g8({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function y8({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function b8({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update billing information, please try again")})}}}async function k8({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to open billing portal, please try again")})}}}async function v8(){return{popupNotification:null}}async function w8({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function x8({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function E8({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function S8({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function C8({data:e,state:t,api:n}){const{email:a}=e,i=_U({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function $8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(UU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function j8({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function T8({data:e,state:t,api:n}){const[a,i]=await Promise.all([$8({data:e,state:t,api:n}),C8({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?v("Account details updated successfully"):v("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=xn(i.error,v("Failed to send verification email")):s=v("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Account details updated successfully")})}}async function P8({data:{siteUrl:e},state:t}){const n=Vl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Lw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function z8({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function A8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const N8={togglePopup:a8,openPopup:i8,closePopup:qx,switchPage:n8,openNotification:o8,closeNotification:s8,back:r8,signout:l8,signin:u8,startSigninOTCFromCustomForm:c8,verifyOTC:d8,signup:m8,updateSubscription:h8,cancelSubscription:f8,continueSubscription:g8,applyOffer:y8,updateNewsletter:S8,updateProfile:T8,refreshMemberData:j8,clearPopupNotification:v8,editBilling:b8,manageBilling:k8,checkoutPlan:p8,updateNewsletterPreference:x8,showPopupNotification:w8,removeEmailFromSuppressionList:E8,oneClickSubscribe:P8,trackRecommendationClicked:z8,trackRecommendationSubscribed:A8};async function I8({action:e,data:t,state:n,api:a}){const i=N8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Jx(e,t){e&&(e.innerText=t)}function M8(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");Jx(n,xn(e,a))}async function F8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var $,F;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=(($=t==null?void 0:t.dataset)==null?void 0:$.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,y=[],k=[],j=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<j.length;++z)y.push(j[z].value);let b=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let z=0;z<b.length;++z)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((F=t==null?void 0:t.dataset)==null?void 0:F.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:m,emailType:p,labels:y,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:X,sniperLinks:D==null?void 0:D.sniperLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await wn.fromApiResponse(_),X=xn(D,v("Failed to send magic link email"));Jx(n,X),t.classList.add("error")}}catch(z){M8(z,t,n)}}function D8({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=jU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const y=r?{checkoutType:"upgrade"}:{},k=co();return k&&(y.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(j){return j.ok?j.text():null}).then(function(j){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:j,successUrl:f,cancelUrl:p,metadata:y})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(j){return j.url?window.location.assign(j.url):window.Stripe(j.publicKey).redirectToCheckout({sessionId:j.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(j){console.error(j),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=j.message),t.classList.add("error")})}function O8({siteUrl:e,site:t={},member:n,doAction:a,captureException:i}={}){e&&(e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){F8({event:l,errorEl:o,form:r,siteUrl:e,submitHandler:s,doAction:a,captureException:i})}r.addEventListener("submit",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){D8({el:r,event:l,errorEl:o,member:n,site:t,siteUrl:e,clickHandler:s})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersSuccess,l=r.dataset.membersCancel,c,m;s&&(c=new URL(s,window.location.href).href),l&&(m=new URL(l,window.location.href).href);function f(p){r.removeEventListener("click",f),p.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(y){return y.ok?y.text():null}).then(function(y){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:y,successUrl:c,cancelUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create stripe checkout session"));return k.json()})}).then(function(y){return window.Stripe(y.publicKey).redirectToCheckout({sessionId:y.sessionId})}).then(function(y){if(y.error)throw new Error(v(y.error.message))}).catch(function(y){console.error(y),r.addEventListener("click",f),r.classList.remove("loading"),o&&(o.innerText=y.message),r.classList.add("error")})}r.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersReturn,l;s&&(l=new URL(s,window.location.href).href);function c(m){r.removeEventListener("click",c),m.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:l})}).then(function(p){if(!p.ok)throw new Error(v("Could not create Stripe billing portal session"));return p.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),r.addEventListener("click",c),r.classList.remove("loading"),o&&(o.innerText=f.message),r.classList.add("error")})}r.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(r){function o(s){r.removeEventListener("click",o),s.preventDefault(),r.classList.remove("error"),r.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(l){l.ok?window.location.replace(e):(r.addEventListener("click",o),r.classList.remove("loading"),r.classList.add("error"))})}r.addEventListener("click",o)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersCancelSubscription;return o&&(o.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error cancelling your subscription, please try again.")))})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersContinueSubscription;return o&&(o.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error continuing your subscription, please try again.")))})}r.addEventListener("click",s)}))}const _8={showPopup:!0,site:_i,member:Jl.free,page:"accountEmail",...e8(),pageData:Kx};function R8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Yd,{children:t}):u.jsx(u.Fragment,{children:t})}class U8 extends re.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.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)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),O8({siteUrl:o,site:s.site,member:s.member,doAction:s.doAction,captureException:Hs})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Sl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Sl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(y=>{y.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?_8:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){const n=new URLSearchParams(t),a={};for(let i of n.entries()){const r=i[0],o=decodeURIComponent(i[1]);r==="name"?a.name=o||"":r==="code"?a.code=o||"":r==="display_title"?a.display_title=o||"":r==="display_description"?a.display_description=o||"":r==="type"?a.type=o||"":r==="cadence"?a.cadence=o||"":r==="duration"?a.duration=o||"":r==="duration_in_months"&&!isNaN(Number(o))?a.duration_in_months=Number(o):r==="amount"&&!isNaN(Number(o))?a.amount=Number(o):r==="currency"?a.currency=o||"":r==="status"?a.status=o||"":r==="tier_id"&&(a.tier={id:o||Kx.tier.id})}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let r,o=null,s,l,c;for(let m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const y=p.toUpperCase();a.site.plans.currency=y,a.site.plans.currency_symbol=De(y),c=y}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p&&(a.site.portal_default_plan=p)}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:r}=Zw({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(zU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,y]=i.match(f),k=parseInt(y);if(k===1||k===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:y,pageQuery:k,pageData:j}=this.getPageFromLinkPath(p,t)||{},b=["accountPlan","accountProfile"].includes(y)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...y?{page:y}:{},...k?{pageQuery:k}:{},...j?{pageData:j}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Vl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.60.0|ghost@${i}`;n&&n.dsn&&mT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>vU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=RU({site:t});let i=ip({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),JU({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.push(["uid",c])}}}catch{}};const o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await I8({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:xn(a,v("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Xm(),!rn({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||HU({offer:o})||!VU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}Ww({site:t,pageQuery:n})&&(r=Ww({site:t,pageQuery:n}));const o=TU({site:t,priceId:r});if(n&&n!=="free"){Xm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return P6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ht({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Yp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?W5({page:t})||G5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Jl.free:$e(["preview"])?Jl.preview:Jl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,sniperLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,sniperLinks:b,doAction:(P,$)=>this.dispatchAction(P,$)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(t8)}render(){return this.state.initStatus==="success"?u.jsx(R8,{site:this.state.site,children:u.jsxs(V.Provider,{value:this.getContextFromState(),children:[u.jsx(Hp,{}),u.jsx(sp,{}),u.jsx(pp,{})]})}):null}}const Zx="ghost-portal-root";function L8(){const e=document.createElement("div");e.id=Zx,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function Y8(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function B8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function H8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=Y8(),r=e||window.location.origin;L8(),B8(),wC.render(u.jsx(re.StrictMode,{children:u.jsx(U8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Zx))}H8()});
|
|
7523
|
+
`;function y5({site:e}){return Zm+h5+uL+LL+XL+TL()+lL+iL+sL+Ow+L6+z6+V6()+lp+Y6+f5+g5+G6+e5+t5+n5+i5+s5+c5}const nh=class nh extends re.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Ul({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:v("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=$l({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:v("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):ea({site:t})?null:u.jsx(bx,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:v("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};nh.contextType=V;let _p=nh;const b5=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:v("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:v("Contact support")})})})})]})},k5=()=>{const{member:e,brandColor:t}=C.useContext(V),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Jm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},v5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(V);if(!$l({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},w5=()=>{const{member:e,site:t}=C.useContext(V),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=Ft({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const r=a==null?void 0:a.current_period_end;if(i&&Qm({member:e})){const o=Qm({member:e}),s=En(o);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(np({sub:a})){const o=En(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will start on {subscriptionStart}",{subscriptionStart:o})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will renew on {renewalDate}",{renewalDate:En(r)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(v5,{})]})},x5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(V),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:En(m)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},E5=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},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"})),S5=()=>{const{member:e,site:t,doAction:n}=C.useContext(V),a=()=>{const p=Ft({member:e});n("editBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:y,subscription:k})=>{const{next_payment:j}=k||{};let b="";if(p){const{amount:z=0,currency:R,interval:_}=p;b=`${Intl.NumberFormat("en",{currency:R,style:"currency"}).format(z/100)}/${v(_)}`}const w=Qm({member:e});y&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";const P=np({sub:k});if(P&&(E="gh-portal-account-old-price"),P)return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(C5,{subscription:k})]});let $=$5({nextPayment:j});$&&(E="gh-portal-account-old-price");const F=()=>$?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(E5,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:$})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(F,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:y=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const y=`**** **** **** ${p}`;return u.jsx("p",{children:y})}return null},l=({defaultCardLast4:p,isComplimentary:y})=>{const{action:k}=C.useContext(V),j=k==="editBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return y?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"update-billing",children:j})]})},c=Ft({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:y}=c||{};let k=v("Plan");return jl({site:t})&&Uw({member:e})&&(k=Uw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:y})]})}return null};function C5({subscription:e}){if(np({sub:e})){const t=En(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function $5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("Ends {offerEndDate}",{offerEndDate:En(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function j5(){const{member:e,site:t,doAction:n}=C.useContext(V);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ap({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Dl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Ux=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},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 T5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Ux,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function P5(){const{doAction:e,member:t,site:n}=C.useContext(V),a=Bw({member:t}),i=oo({site:n}),r=Tl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(T5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:v("Manage")})]})}const z5=(e,t)=>lo({site:e})&&oo({site:e})||Tl({site:e})||Bw({member:t}),A5=e=>!lo({site:e})&&oo({site:e})&&!Tl({site:e}),N5=()=>{const{member:e,doAction:t,site:n}=C.useContext(V),{name:a,email:i}=e,r=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},o=z5(n,e),s=A5(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||v("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:l=>r(),children:v("Edit")})]}),u.jsx(S5,{}),o&&u.jsx(P5,{}),s&&u.jsx(j5,{})]})})},I5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(k5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(w5,{}),u.jsx(x5,{}),u.jsx(N5,{})]})]}),ah=class ah extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=uo({site:n});return!t||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(I5,{}),u.jsx(b5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ah.contextType=V;let Rp=ah;const ih=class ih extends re.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Ul({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=v("Save");this.context.action==="updateProfile:failed"&&(n=v("Retry"));const a=!!t;return u.jsx(ze,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:v("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(Jm,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};ih.contextType=V;let Up=ih;function M5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(V);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:v("Email preferences")})]})}function F5({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function D5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(V),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function O5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(V),i=za({site:a});return n?i.map(r=>u.jsx(F5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function _5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Lx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=C.useContext(V),y=!(n!=null&&n.length)&&(s&&!l||!s),j=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(M5,{}),u.jsx(j,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(O5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(D5,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(ze,{isRunning:!1,onClick:()=>{r()},disabled:y,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ap({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(_5,{isPaid:o,site:p,subscribedNewsletters:n})}),ap({member:f})&&!y&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function R5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(V);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);y(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[p,y]=C.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:j}=e||{};return C.useEffect(()=>{y((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Lx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{y(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{y([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:j})}function U5(){const{site:e}=C.useContext(V),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function L5(){const{site:e}=C.useContext(V),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(U5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Yx({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function Y5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(V),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=C.useState(!1),[y,k]=C.useState(m),[j,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),$=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Yx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},F=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Yx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await $([]):n.newsletterUuid?await $(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await F(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(ko,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(cp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!j)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(L5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:v("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Lx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:y,updateSubscribedNewsletters:async _=>{await $(_),p(!0)},updateCommentNotifications:F,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function B5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(V);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Tl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Ux,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:v("Emails disabled")}),u.jsx("p",{children:v("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.")})]}),u.jsx(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:v("Re-enable emails"),isRunning:r})]})}function H5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(V),i=`mailto:${uo({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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).")}),u.jsx("h4",{children:v("Spam complaints")}),u.jsx("p",{children:v("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:v("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.")}),u.jsx("h4",{children:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:v("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:v("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.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:v("Need more help? Contact support")})})]})]})}function V5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(V),o=uo({site:n}),s=`mailto:${o}`,l=LU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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".`)}),u.jsx("h4",{children:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}const Lp={signin:_p,signup:Ip,accountHome:Rp,accountPlan:wp,accountProfile:Up,accountEmail:R5,signupNewsletter:Ep,unsubscribe:Y5,magiclink:Mp,loading:ko,offer:Dp,feedback:Q6,emailSuppressed:B5,emailSuppressionFAQ:H5,emailReceivingFAQ:V5,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(V);return C.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,y=Vl({siteUrl:c});try{const k=await y.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(Op,{error:n}):i?u.jsx(Op,{error:i}):null},supportSuccess:r5,supportError:Op,recommendations:p5},Yp=function({page:e}){return Object.keys(Lp).includes(e)?e:"signup"},W5=function({page:e}){return e.includes("account")},G5=function({page:e}){return e.includes("offer")},K5=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},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"})),rh=class rh extends re.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(K5,{}),"Powered by Ghost"]})}};rh.contextType=V;let Wl=rh;const Bx=()=>({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 q5({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const oh=class oh extends re.Component{componentDidMount(){this.node&&!$e(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&$e(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Yp({page:t});const n=Lp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Fp,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,o=Al({site:a,pageQuery:n}).length;Yp({page:t});const l={...Bx().page[t]};let c="",m="regular",f="",p=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!Ht({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const y=so({site:a});(y&&o>2||!y&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const j=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:j,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(q5,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})})]})}};oh.contextType=V;let Bp=oh;const sh=class sh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Lp[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=y5({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=Bx(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(Km,{style:o,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(Bp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};sh.contextType=V;let Hp=sh;Gl({products:Vp({numOfProducts:1})});function Je(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function Gl({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Vp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:y=!0,portalButton:k=!0,portalName:j=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:F=[],posts:z=J5(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:m,free_price_name:f,free_price_description:p,is_stripe_configured:y,portal_button:k,portal_name:j,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:F,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:$,posts:z}}function Hx({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:m=null,status:f="active",tierId:p="",tierName:y="Basic",redemptionType:k="signup"}={}){return{id:`offer_${Je()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:m,status:f,tier:{id:`${p}`,name:y},redemption_type:k}}function Wt({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:`member_${Je()}`,email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function J5({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(Z5({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function Z5({id:e=`post_${Je()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function Vp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Vx({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${Je()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:Wx({numOfBenefits:o}),trial_days:s}}function Vx({name:e="Free tier",description:t="Free tier description",id:n=`product_${Je()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Wx({numOfBenefits:a})}}function Wx({numOfBenefits:e}){const t=Je();return[Kl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Kl({name:`Latest gear reviews #${t.substring(6,12)}`}),Kl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Kl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Kl({id:e=`benefit_${Je()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${Je()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${Je()}`,stripe_product_id:`prod_${Je()}`,type:"recurring"}}function Na({id:e=`sub_${Je()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=Q5,priceId:l=`price_${Je()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:y=null,tier:k=null}={}){return{id:e,customer:{id:`cus_${Je()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${Je()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:m,trial_end_at:p,next_payment:y,tier:k,price:{id:`stripe_price_${Je()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${Je()}`,product_id:`prod_${Je()}`}}}}function Gx(){const e=Vp({numOfProducts:1}),t=e.map(a=>a.id);return Gl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Gx();const X5=Gl({products:[Oi({numOfBenefits:2,type:"free"})]}),Q5=Hx({tierId:(Xx=X5.products[0])==null?void 0:Xx.id});Wt(),Wt({paid:!0,subscriptions:[Na()]}),Wt({paid:!0,subscriptions:[]}),Wt({paid:!0,subscriptions:[Na({amount:0})]}),Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Gx();const ql=[Vx({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=Gl({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:ql,portalProducts:ql.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),Kx=Hx({tierId:(Qx=_i.products[1])==null?void 0:Qx.id}),Jl={free:Wt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Wt({paid:!0,subscriptions:[Na({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:Wt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Wt({paid:!0,subscriptions:[Na({amount:0})]}),preview:Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function e8(){var n;if(!ql||!ql[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Wt({paid:!0,subscriptions:[Na({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:_i,member:t}}function t8(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function n8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function a8({state:e}){return{showPopup:!e.showPopup}}function i8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function r8({state:e}){return e.lastPage?{page:e.lastPage}:qx({state:e})}function qx({state:e}){return Xm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function o8({data:e}){return{showNotification:!0,...e}}function s8(){return{showNotification:!1}}async function l8({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to log out, please try again")})}}}async function u8({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},inboxLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:xn(a,v("Failed to log in, please try again"))})}}}function c8({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.inboxLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function d8({data:e,api:t}){var a;const n=v("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:xn((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:xn(i,n)}}}async function m8({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:m}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,v("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function p8({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to process checkout, please try again")})}}}async function h8({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update subscription, please try again")})}}}async function f8({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function g8({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to cancel subscription, please try again")})}}}async function y8({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function b8({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to update billing information, please try again")})}}}async function k8({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:v("Failed to open billing portal, please try again")})}}}async function v8(){return{popupNotification:null}}async function w8({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function x8({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function E8({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function S8({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function C8({data:e,state:t,api:n}){const{email:a}=e,i=_U({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function $8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(UU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function j8({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function T8({data:e,state:t,api:n}){const[a,i]=await Promise.all([$8({data:e,state:t,api:n}),C8({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?v("Account details updated successfully"):v("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=xn(i.error,v("Failed to send verification email")):s=v("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:v("Account details updated successfully")})}}async function P8({data:{siteUrl:e},state:t}){const n=Vl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Lw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function z8({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function A8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const N8={togglePopup:a8,openPopup:i8,closePopup:qx,switchPage:n8,openNotification:o8,closeNotification:s8,back:r8,signout:l8,signin:u8,startSigninOTCFromCustomForm:c8,verifyOTC:d8,signup:m8,updateSubscription:h8,cancelSubscription:f8,continueSubscription:g8,applyOffer:y8,updateNewsletter:S8,updateProfile:T8,refreshMemberData:j8,clearPopupNotification:v8,editBilling:b8,manageBilling:k8,checkoutPlan:p8,updateNewsletterPreference:x8,showPopupNotification:w8,removeEmailFromSuppressionList:E8,oneClickSubscribe:P8,trackRecommendationClicked:z8,trackRecommendationSubscribed:A8};async function I8({action:e,data:t,state:n,api:a}){const i=N8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Jx(e,t){e&&(e.innerText=t)}function M8(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");Jx(n,xn(e,a))}async function F8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var $,F;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=(($=t==null?void 0:t.dataset)==null?void 0:$.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,y=[],k=[],j=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<j.length;++z)y.push(j[z].value);let b=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let z=0;z<b.length;++z)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((F=t==null?void 0:t.dataset)==null?void 0:F.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:m,emailType:p,labels:y,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(m||"").trim(),otcRef:X,inboxLinks:D==null?void 0:D.inboxLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await wn.fromApiResponse(_),X=xn(D,v("Failed to send magic link email"));Jx(n,X),t.classList.add("error")}}catch(z){M8(z,t,n)}}function D8({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=jU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const y=r?{checkoutType:"upgrade"}:{},k=co();return k&&(y.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(j){return j.ok?j.text():null}).then(function(j){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:j,successUrl:f,cancelUrl:p,metadata:y})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(j){return j.url?window.location.assign(j.url):window.Stripe(j.publicKey).redirectToCheckout({sessionId:j.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(j){console.error(j),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=j.message),t.classList.add("error")})}function O8({siteUrl:e,site:t={},member:n,doAction:a,captureException:i}={}){e&&(e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){F8({event:l,errorEl:o,form:r,siteUrl:e,submitHandler:s,doAction:a,captureException:i})}r.addEventListener("submit",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){D8({el:r,event:l,errorEl:o,member:n,site:t,siteUrl:e,clickHandler:s})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersSuccess,l=r.dataset.membersCancel,c,m;s&&(c=new URL(s,window.location.href).href),l&&(m=new URL(l,window.location.href).href);function f(p){r.removeEventListener("click",f),p.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(y){return y.ok?y.text():null}).then(function(y){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:y,successUrl:c,cancelUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create stripe checkout session"));return k.json()})}).then(function(y){return window.Stripe(y.publicKey).redirectToCheckout({sessionId:y.sessionId})}).then(function(y){if(y.error)throw new Error(v(y.error.message))}).catch(function(y){console.error(y),r.addEventListener("click",f),r.classList.remove("loading"),o&&(o.innerText=y.message),r.classList.add("error")})}r.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersReturn,l;s&&(l=new URL(s,window.location.href).href);function c(m){r.removeEventListener("click",c),m.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:l})}).then(function(p){if(!p.ok)throw new Error(v("Could not create Stripe billing portal session"));return p.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),r.addEventListener("click",c),r.classList.remove("loading"),o&&(o.innerText=f.message),r.classList.add("error")})}r.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(r){function o(s){r.removeEventListener("click",o),s.preventDefault(),r.classList.remove("error"),r.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(l){l.ok?window.location.replace(e):(r.addEventListener("click",o),r.classList.remove("loading"),r.classList.add("error"))})}r.addEventListener("click",o)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersCancelSubscription;return o&&(o.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error cancelling your subscription, please try again.")))})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersContinueSubscription;return o&&(o.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error continuing your subscription, please try again.")))})}r.addEventListener("click",s)}))}const _8={showPopup:!0,site:_i,member:Jl.free,page:"accountEmail",...e8(),pageData:Kx};function R8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Yd,{children:t}):u.jsx(u.Fragment,{children:t})}class U8 extends re.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.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)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),O8({siteUrl:o,site:s.site,member:s.member,doAction:s.doAction,captureException:Hs})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Sl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Sl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(y=>{y.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?_8:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){const n=new URLSearchParams(t),a={};for(let i of n.entries()){const r=i[0],o=decodeURIComponent(i[1]);r==="name"?a.name=o||"":r==="code"?a.code=o||"":r==="display_title"?a.display_title=o||"":r==="display_description"?a.display_description=o||"":r==="type"?a.type=o||"":r==="cadence"?a.cadence=o||"":r==="duration"?a.duration=o||"":r==="duration_in_months"&&!isNaN(Number(o))?a.duration_in_months=Number(o):r==="amount"&&!isNaN(Number(o))?a.amount=Number(o):r==="currency"?a.currency=o||"":r==="status"?a.status=o||"":r==="tier_id"&&(a.tier={id:o||Kx.tier.id})}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let r,o=null,s,l,c;for(let m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const y=p.toUpperCase();a.site.plans.currency=y,a.site.plans.currency_symbol=De(y),c=y}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p&&(a.site.portal_default_plan=p)}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:r}=Zw({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(zU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,y]=i.match(f),k=parseInt(y);if(k===1||k===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:y,pageQuery:k,pageData:j}=this.getPageFromLinkPath(p,t)||{},b=["accountPlan","accountProfile"].includes(y)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...y?{page:y}:{},...k?{pageQuery:k}:{},...j?{pageData:j}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Vl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.61.0|ghost@${i}`;n&&n.dsn&&mT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>vU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=RU({site:t});let i=ip({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),JU({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.push(["uid",c])}}}catch{}};const o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await I8({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:xn(a,v("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Xm(),!rn({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||HU({offer:o})||!VU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}Ww({site:t,pageQuery:n})&&(r=Ww({site:t,pageQuery:n}));const o=TU({site:t,priceId:r});if(n&&n!=="free"){Xm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return P6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Ht({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Yp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?W5({page:t})||G5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Jl.free:$e(["preview"])?Jl.preview:Jl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b,doAction:(P,$)=>this.dispatchAction(P,$)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(t8)}render(){return this.state.initStatus==="success"?u.jsx(R8,{site:this.state.site,children:u.jsxs(V.Provider,{value:this.getContextFromState(),children:[u.jsx(Hp,{}),u.jsx(sp,{}),u.jsx(pp,{})]})}):null}}const Zx="ghost-portal-root";function L8(){const e=document.createElement("div");e.id=Zx,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function Y8(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function B8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function H8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=Y8(),r=e||window.location.origin;L8(),B8(),wC.render(u.jsx(re.StrictMode,{children:u.jsx(U8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Zx))}H8()});
|
|
7524
7524
|
//# sourceMappingURL=portal.min.js.map
|