"use strict";(()=>{vare={};e.id=3751,e.ids=[3220,3751],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){returnfunctione(t,s){returnsint?t[s]:"then"int&&"function"==typeoft.then?t.then(t=>e(t,s)):"function"==typeoft&&"default"===s?t:void0}}})},76048:(e,t,s)=>{s.r(t),s.d(t,{config:()=>D,default:()=>j,getServerSideProps:()=>y,getStaticPaths:()=>E,getStaticProps:()=>P,reportWebVitals:()=>A,routeModule:()=>I,unstable_getServerProps:()=>M,unstable_getServerSideProps:()=>k,unstable_getStaticParams:()=>O,unstable_getStaticPaths:()=>L,unstable_getStaticProps:()=>N});varr={};s.r(r),s.d(r,{default:()=>b,getServerSideProps:()=>v});varn=s(63865),a=s(9455),i=s(30671),o=s(49407),c=s(89600),l=s(8732),u=s(82015),p=s.n(u),m=s(32415),d=s(87472),x=s(20048),h=s.n(x),f=s(63715),_=s(71457),g=s(67216),S=s.n(g);functionb({user:e,email:t,productionEnvironment:s,existingAlerts:r}){letn="Unsubscribe | Datasquirel",a="Unsubscribe from email alerts",i=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:n}),(0,l.jsx)("meta",{name:"description",content:a}),(0,l.jsx)(d.A,{pageTitle:n,pageDescription:a,pagePathname:"/unsubscribe"})]}),[o,c]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(_.A,{head:i,user:e,productionEnvironment:s,children:(0,l.jsx)("main",{children:(0,l.jsxs)("section",{children:[o&&(0,l.jsx)(m.A,{}),(0,l.jsxs)("div",{className:"flex-col",children:[(0,l.jsx)("h1",{className:"text-2xl",children:"Unsubscribe from Email alerts"}),!t&&(0,l.jsxs)("p",{className:"max-w-md",children:["No email please ",(0,l.jsx)("a",{href:"/login",children:"Login"})," ","to Access Email Subscriptions or click on"," ",(0,l.jsx)("i",{children:'"unsubscribe"'})," from your mail box"]}),t&&(0,l.jsxs)("form",{className:"flex flex-col items-start gap-4",onSubmit:s=>{s.preventDefault(),c(!0);letr=s.target;(0,f.A)("/api/unsubscribe",{method:"post",body:{email:t,alerts:r.alerts_checkbox.checked,userId:e?.id?e.id:null}}).then(e=>{console.log(e),c(!1)})},children:[(0,l.jsx)("span",{className:"bg-slate-100 py-1 px-3 rounded-full",children:t}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("input",{type:"checkbox",name:"alerts_checkbox",id:"alerts_checkbox",defaultChecked:!!r,className:"w-6 h-6"}),(0,l.jsx)("label",{htmlFor:"alerts_checkbox",className:"text-base whitespace-nowrap text-slate-800",children:"Alerts"})]}),(0,l.jsx)("button",{children:"Save Settings"})]})]})]})})})})}asyncfunctionv({req:e,res:t,query:s}){letr=process.env.DSQL_HOST_ENV,n=awaith()(e,t),a=s.email?s.email:n?.email?n.email:null,i=awaitS()(`SELECT email FROM unsubscribes WHERE email='${a}' AND type='alerts'`);return{props:{user:n,email:a,productionEnvironment:r,existingAlerts:!i[0]}}}letj=(0,i.M)(r,"default"),P=(0,i.M)(r,"getStaticProps"),E=(0,i.M)(r,"getStaticPaths"),y=(0,i.M)(r,"getServerSideProps"),D=(0,i.M)(r,"config"),A=(0,i.M)(r,"reportWebVitals"),N=(0,i.M)(r,"unstable_getStaticProps"),L=(0,i.M)(r,"unstable_getStaticPaths"),O=(0,i.M)(r,"unstable_getStaticParams"),M=(0,i.M)(r,"unstable_getServerProps"),k=(0,i.M)(r,"unstable_getServerSideProps"),I=newn.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:c.default,Document:o.default},userland:r})},20048:(e,t,s)=>{s(81630);letr=s(67216),n=s(77463),a=s(29021),i=s(6505);asyncfunctiono(e,t,s,o){let{keyCookieName:c,csrfCookieName:l}=i();if(!e.cookies?.[c]?.match(/./))returnnull;letu=n({encryptedString:e.cookies[c]});if(!u)returnnull;letp=JSON.parse(u);if(!p.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${p.csrf_k}`)))returnnull;letm=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!m)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!a.existsSync(`${m}/${p.csrf_k}`))returnnull;if(0==p.verification_status&&!s){lete=awaitr(`SELECT verification_status FROM users WHERE id='${p.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}returnp?.date&&Date.now()-p.date>604