Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(d){varu=d.querySelector("[data-members-error]");d.addEventListener("submit",functionr(e){d.removeEventListener("submit",r),e.preventDefault(),u&&(u.innerText=""),d.classList.remove("success","invalid","error");for(vart=e.target.querySelector("input[data-members-email]"),n=e.target.querySelector("input[data-members-name]"),o=t.value,s=n&&n.value||void0,i=void0,a=[],c=e.target.querySelectorAll("input[data-members-label]")||[],l=0;l<c.length;++l)a.push(c[l].value);d.dataset.membersForm&&(i=d.dataset.membersForm),d.classList.add("loading"),fetch("{{blog-url}}/members/api/send-magic-link/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,emailType:i,labels:a,name:s})}).then(function(e){d.addEventListener("submit",r),d.classList.remove("loading"),e.ok?d.classList.add("success"):(u&&(u.innerText="There was an error sending the email, please try again"),d.classList.add("error"))})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(a){varc=a.querySelector("[data-members-error]");a.addEventListener("click",functionr(e){a.removeEventListener("click",r),e.preventDefault();vart,n,o=a.dataset.membersPlan,s=a.dataset.membersSuccess,i=a.dataset.membersCancel;s&&(t=newURL(s,window.location.href).href),i&&(n=newURL(i,window.location.href).href),c&&(c.innerText=""),a.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{credentials:"same-origin"}).then(function(e){returne.ok?e.text():null}).then(function(e){returnfetch("{{blog-url}}/members/api/create-stripe-checkout-session/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:o,identity:e,successUrl:t,cancelUrl:n})}).then(function(e){if(!e.ok)thrownewError("Could not create stripe checkout session");returne.json()})}).then(function(e){returnStripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)thrownewError(e.error.message)}).catch(function(e){console.error(e),a.addEventListener("click",r),a.classList.remove("loading"),c&&(c.innerText=e.message),a.classList.add("error")})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(t){varn,o,s=t.querySelector("[data-members-error]"),e=t.dataset.membersSuccess,r=t.dataset.membersCancel;e&&(n=newURL(e,window.location.href).href),r&&(o=newURL(r,window.location.href).href),t.addEventListener("click",functionr(e){t.removeEventListener("click",r),e.preventDefault(),s&&(s.innerText=""),t.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{credentials:"same-origin"}).then(function(e){returne.ok?e.text():null}).then(function(e){returnfetch("{{blog-url}}/members/api/create-stripe-update-session/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:e,successUrl:n,cancelUrl:o})}).then(function(e){if(!e.ok)thrownewError("Could not create stripe checkout session");returne.json()})}).then(function(e){returnStripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)thrownewError(e.error.message)}).catch(function(e){console.error(e),t.addEventListener("click",r),t.classList.remove("loading"),s&&(s.innerText=e.message),t.classList.add("error")})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(t){t.addEventListener("click",functionr(e){t.removeEventListener("click",r),e.preventDefault(),t.classList.remove("error"),t.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{method:"DELETE"}).then(function(e){e.ok?window.location.reload():(t.addEventListener("click",r),t.classList.remove("loading"),t.classList.add("error"))})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(n){varo=n.parentElement.querySelector("[data-members-error]");n.addEventListener("click",functionr(e){n.removeEventListener("click",r),e.preventDefault(),n.classList.remo