"use strict";(()=>{vare={};e.id=8932,e.ids=[8932],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},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")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},36629:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>_,routeModule:()=>p});vara={};t.r(a),t.d(a,{default:()=>d});vars=t(89947),n=t(2706),o=t(96762),l=t(69842),i=t(67619),c=t(60125),u=t(30944);asyncfunctiond(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=await(0,l.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});leta=e.body;try{lets=await(0,c.A)({databaseSlug:a.dbName,request:e,user:t,query:e.query}),n=s?s?.rootUserId?s.rootUserId:s.dbUserId:null;if(!n)throwError("User not Found!");leto=`datasquirel_user_${n}_${a.dbName}`,l=a.tableName,i=a.page,d=20*i,_=`SELECT * FROM ${o}.${l}`,f=[];a.search&&a.searchField&&(_+=` WHERE LOWER(\`${a.searchField.toLowerCase().replace(/ /g,"_")}\`) LIKE ?`,f.push(`%${a.search.toLowerCase()}%`)),_+=` ORDER BY id DESC LIMIT 20 OFFSET ${d}`;letp=await(0,u.A)({database:o,queryString:_,queryValuesArray:f,tableSchema:a.tableSchema}),S={success:!0,data:p,page:Number(i)+1};r.json(S)}catch(e){(0,i.default)({component:"/api/infiniteScroll/catch-error",message:e.message,user:t}),r.json({success:!1,data:null})}}t(29021);let_=(0,o.M)(a,"default"),f=(0,o.M)(a,"config"),p=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/infiniteScroll",pathname:"/api/infiniteScroll",bundlePath:"",filename:""},userland:a})},60125:(e,r,t)=>{t.d(r,{A:()=>s});vara=t(95969);asyncfunctions({request:e,databaseSlug:r,user:t,query:s}){try{letn=t.id,o=null;if(!s?.delegated)return{dbUserId:n};letl=s.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${l}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[c])throwError("Cookie not present");lett=(0,a.A)({encryptedString:e.cookies[c]});if(!t)throwError("Invalid Token");if((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:n=o.rootUserId,rootUserId:o.rootUserId,rootUserName:o.rootUserName,rootUserEmail:o.rootUserEmail,rootUserImage:o.rootUserImage,databaseFullName:o.databaseFullName,databaseSlug:o.databaseSlug,allowedTables:o.allowedTables,priviledges:o.priviledges,database:o.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:n}}catch(e){returnnull}}},69842:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(48786),s=t(95969),n=t(29021),o=t.n(n),l=t(89159);asyncfunctioni(e,r,t){let{keyCookieName:n,csrfCookieName:i}=(0,l.A)();if(!e.cookies?.[n]?.match(/./))returnnull;letc=(0,s.A)({encryptedString:e.cookies[n]});if(!c)returnnull;letu=JSON.parse(c);if(!u.csrf_k||t&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))returnnull;letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o().existsSync(`${d}/${u.csrf_k}`))returnnull;if(0==u.verification_status&&!t){lete=await(0,a.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnu?.date&&Date.now()-u.date>6048e5?null:u}},89159:(e,r,t)=>{t.d(r,{A:()=>a});functiona(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",a=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",n=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),n&&(o+=`${n}_`),o+=t;letl=r;e?.userId&&(l+=`user_${e.userId}_`),n&&(l+=`${n}_`),l+=a;leti=r;returne?.userId&&(i+=`user_${e.userId}_`),n&&(i+=`${n}_`),{keyCookieName:o,csrfCookieName:l