"use strict";(()=>{var e={};e.id=7537,e.ids=[636,7537],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},75370:(e,t,r)=>{r.r(t),r.d(t,{config:()=>N,default:()=>A,getServerSideProps:()=>M,getStaticPaths:()=>R,getStaticProps:()=>D,reportWebVitals:()=>L,routeModule:()=>C,unstable_getServerProps:()=>k,unstable_getServerSideProps:()=>I,unstable_getStaticParams:()=>O,unstable_getStaticPaths:()=>$,unstable_getStaticProps:()=>T});var s={};r.r(s),r.d(s,{ResetPasswordContext:()=>v,default:()=>E,getServerSideProps:()=>b});var i=r(63865),a=r(9455),n=r(30671),o=r(49407),u=r(68268),l=r(8732),c=r(82015),p=r.n(c),m=r(71457),d=r(87472),x=r(32415),g=r(20048),f=r.n(g),h=r(63715),S=r(13002),y=r(83007),P=r.n(y),w=r(68942),q=r.n(w),_=r(27825),j=r.n(_);let v=p().createContext({});function E(e){let{email:t}=e,r="Reset Password | Datasquirel",s="Set a new password",i=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:r}),(0,l.jsx)("meta",{name:"description",content:s}),(0,l.jsx)(d.A,{pageTitle:r,pageDescription:s,pagePathname:"/"})]}),[a,n]=p().useState(!1),[o,u]=p().useState(!1);return(0,l.jsx)(m.A,{head:i,user:e.user,children:(0,l.jsx)(v.Provider,{value:{user:e.user},children:(0,l.jsx)("main",{children:(0,l.jsxs)("section",{children:[a&&(0,l.jsx)(x.A,{}),(0,l.jsx)("div",{className:"main-container flex-col items-start",children:o?(0,l.jsx)(S.A,{message:"Password Updated Sucessfully. Redirecting you ..."}):(0,l.jsxs)(p().Fragment,{children:[(0,l.jsx)("h1",{className:"m-0 text-4xl",children:"Reset Password"}),(0,l.jsx)("span",{children:"Please enter new passord and confirm it"}),(0,l.jsxs)("form",{className:"max-w-xl w-full flex flex-col items-stretch gap-4",onSubmit:e=>{n(!0),e.preventDefault();let r=e.target,s=r.password.value,i=r["confirm-password"].classList.contains("warning");if(s?.length<8){window.alert("Password must be at least 8 characters"),setTimeout(()=>{n(!1)},500);return}if(i){window.alert("Passwords don't match"),setTimeout(()=>{n(!1)},500);return}(0,h.A)(`/api/resetPassword?email=${t}&password=${s}`).then(e=>{setTimeout(()=>{n(!1)},500),setTimeout(()=>{window.location.href="/logout?login=true"},1e3),e.success&&u(!0)})},children:[(0,l.jsx)("input",{type:"password",name:"password",id:"password",className:"w-full",placeholder:"New Password",required:!0}),(0,l.jsx)("input",{type:"password",name:"confirm-password",id:"confirm-password",className:"w-full",placeholder:"Confirm New Password",required:!0,onInput:e=>{let t=e.target,r=t.closest("form");try{r.password.value.match(RegExp(`^${j().escapeRegExp(t.value)}$`))?t.classList.remove("warning"):t.classList.add("warning")}catch(t){(0,h.A)("/api/admin/clientError",{method:"post",body:{component:"reset-password-page-component/lines-170-177",message:t.message,user:{}}}),e.target.classList.add("warning")}}}),(0,l.jsx)("button",{children:"Reset Password"})]})]})})]})})})})}async function b({req:e,res:t,query:r}){let s=await f()(e,t);if(!r?.token?.toString()?.match(/./))return{redirect:{destination:"/",permanent:!1}};let i=null;try{let e=P()(r.token.toString()),t=JSON.parse(e||"");if(Date.now()-t.dateCode>36e5)return{redirect:{destination:"/",permanent:!1}};i=t.email}catch(e){return q()({component:"reset-password-page-component/getServersideProps/lines-251-260",message:e.message,user:s}),{redirect:{destination:"/",permanent:!1}}}return i?.match(/./)?{props:{user:s,email:i}}:{redirect:{destination:"/",permanent:!1}}}let A=(0,n.M)(s,"default"),D=(0,n.M)(s,"getStaticProps"),R=(0,n.M)(s,"getStaticPaths"),M=(0,n.M)(s,"getServerSideProps"),N=(0,n.M)(s,"config"),L=(0,n.M)(s,"reportWebVitals"),T=(0,n.M)(s,"unstable_getStaticProps"),$=(0,n.M)(s,"unstable_getStaticPaths"),O=(0,n.M)(s,"unstable_getStaticParams"),k=(0,n.M)(s,"unstable_getServerProps"),I=(0,n.M)(s,"unstable_getServerSideProps"),C=new i.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/reset-password",pathname:"/reset-password",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:s})},13002:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(8732);function i({message:e,className:t}){return(0,s.jsxs)("div",{className:"info green"+(t?" "+t:""),children:[(0,s.jsx)("img",{src:"/images/checkmark.svg",alt:"Warning Image Icon",width:22,className:"-my-2"}),(0,s.jsx)("span",{children:e})]})}r(82015)},68942:(e,t,r)=>{let s=r(29021),{IncomingMessage:i}=r(81630);e.exports=async function({user:e,message:t,component:r,noMail:i,req:a}){let n=new Date,o=(()=>{if(!a)return null;try{let e=a.headers["x-forwarded-for"],t=a.headers["x-real-ip"],r=a.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],i=r||s||t||a.socket.remoteAddress;if(!i)return null;return String(i)}catch(e){return null}})();try{let i=`🚀 SERVER ERROR =========================== Error Message: ${t} Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(i+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),a?.url&&(i+=` URL: ${a.url}`),a?.body&&(i+=` Request Body: ${JSON.stringify(a.body,null,4)}`),o&&(i+=` IP: ${o}`),i+=` Date: ${n.toDateString()} ========================================`,s.existsSync("./.tmp/error.log")||s.writeFileSync("./.tmp/error.log","","utf-8");let u=s.readFileSync("./.tmp/error.log","utf-8");s.writeFileSync("./.tmp/error.log",i),s.appendFileSync("./.tmp/error.log",` ${u}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(83007),a=r(29021);async function n(e,t,r,n){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let o=i(e.cookies.datasquirelAuthKey);if(!o)return null;let u=JSON.parse(o);if(!u.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${u.csrf_k}`)))return null;let l=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!l)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!a.existsSync(`${l}/${u.csrf_k}`))return null;if(0==u.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return u?.date&&Date.now()-u.date>6048e5?null:u}e.exports=n},83007:(e,t,r)=>{let{scryptSync:s,createDecipheriv:i}=r(55511),{Buffer:a}=r(79428);e.exports=e=>{let t=i("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),a.alloc(16,0));try{let r=t.update(e,"hex","utf8");return r+=t.final("utf8")}catch(e){return null}}},67216:(e,t,r)=>{let s=r(9973),i=r(31976),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:i()}});async function n(...e){try{let t=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=n},31976:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},49407:(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(8732);r(82015);var i=r(20883);function a(e){return(0,s.jsxs)(i.Html,{lang:"en",children:[(0,s.jsxs)(i.Head,{children:[(0,s.jsx)("meta",{name:"author",content:"Datasquirel"}),(0,s.jsx)("meta",{name:"Copyright",content:`Copyright (c) ${new Date().getFullYear()} Datasquirel`}),"dev_dev".match(/dev/)&&(0,s.jsx)("meta",{name:"robots",content:"noindex,nofollow"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com/",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Poppins"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Inter"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=IBM+Plex+Mono"}),(0,s.jsx)("script",{src:"/scripts/themeSelector.js"}),(0,s.jsx)("meta",{httpEquiv:"Content-Type",content:"text/html; charset=UTF-8"}),(0,s.jsx)("meta",{property:"og:site_name",content:"DATASQUIREL"}),(0,s.jsx)("meta",{property:"og:type",content:"website"}),(0,s.jsx)("meta",{name:"twitter:card",content:"summary"}),(0,s.jsx)("meta",{property:"og:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{itemProp:"image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{name:"twitter:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("link",{rel:"stylesheet",href:"/styles/prism.css"}),(0,s.jsx)("script",{src:"/scripts/prism.js",async:!0}),(0,s.jsx)("script",{dangerouslySetInnerHTML:{__html:"var DSQL = {}"}})]}),(0,s.jsxs)("body",{children:[(0,s.jsx)(i.Main,{}),(0,s.jsx)(i.NextScript,{})]})]})}},9455:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},74956:e=>{e.exports=require("clsx")},27825:e=>{e.exports=require("lodash")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")}};var t=require("../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[9764,883,8268],()=>r(75370));module.exports=s})();