"use strict";(()=>{vare={};e.id=3319,e.ids=[3319],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")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},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}}})},62229:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>S,routeModule:()=>m});vars={};t.r(s),t.d(s,{default:()=>p});vara=t(89947),n=t(2706),o=t(96762),i=t(57638),l=t.n(i);letc=t(73677),u=t(39831),d=t(48225),_=t(6420);asyncfunctionp(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await_(e,r,!0);if(!t)returnr.json({success:!1,msg:"User Auth Failed"});let{tableName:s,dbSlug:a,dbId:n,isTitle:o,isSlug:i,isFullName:p,defaultField:S}=e.body;try{letd=awaitu({databaseSlug:a,request:e,user:t,query:e.query});if(!awaitc({user:t,confirmedDelegetedUser:d,database:a,table:s,dbId:n,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});let_=d?.rootUserId?`datasquirel_user_${d.rootUserId}_${a}`:`datasquirel_user_${t.id}_${a}`,f=`SELECT id${o?",title":i?",slug":p?",CONCAT(first_name, ' ', last_name) AS full_name":S?","+S:""} FROM ${s}`,m=awaitl()({database:_,queryString:f});r.json({success:!0,entries:m})}catch(e){d({component:"/api/addTableEntry/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}letS=(0,o.M)(s,"default"),f=(0,o.M)(s,"config"),m=newa.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/fetch-entries-basic",pathname:"/api/fetch-entries-basic",bundlePath:"",filename:""},userland:s})},73677:(e,r,t)=>{lets=t(51348),a=t(48225);e.exports=asyncfunction({user:e,confirmedDelegetedUser:r,database:t,table:n,priviledgeRegex:o,dbId:i}){letl,c;try{r?.delegated?(l=awaits("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,n]),c=l[0]?.priviledge?.match(o)):(l=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,n,i]),c=!0)}catch(r){a({component:"checkUserRights",message:r.message,user:e})}return!!l&&!!l[0]&&!!c}},39831:(e,r,t)=>{t(81630);lets=t(72835);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:a}){try{letn=t.id,o=null;if(!a?.delegated)return{dbUserId:n};leti=a.dbUserId,l=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${l}`;try{if(!e.cookies?.[c])throwError("Cookie not present");lett=s({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}}},6420:(e,r,t)=>{t(81630);lets=t(51348),a=t(72835),n=t(29021),o=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=o();if(!e.cookies?.[l]?.match(/./))returnnull;letu=a({encryptedString:e.cookies[l]});if(!u)returnnull;letd=JSON.parse(u);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!n.existsSync(`${_}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d