"use strict";(()=>{vare={};e.id=1658,e.ids=[1658],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}}})},17675:(e,r,t)=>{t.r(r),t.d(r,{config:()=>E,default:()=>f,routeModule:()=>p});vars={};t.r(s),t.d(s,{default:()=>_});varn=t(89947),a=t(2706),o=t(96762),l=t(61932),i=t(31495),u=t(60125),c=t(67619),d=t(69842);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,d.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{dbFullName:s,tableName:n,entryId:a,dbSlug:o,dbId:_,delegated:f}=e.body;try{letc=await(0,u.A)({databaseSlug:o,request:e,user:t,query:e.query});if(!await(0,i.A)({user:t,confirmedDelegetedUser:c,database:o,table:n,dbId:_,priviledgeRegex:/Delete Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});await(0,l.A)({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:s,tableName:n,identifierColumnName:"id",identifierValue:a}),r.json({success:!0})}catch(e){(0,c.default)({component:"/api/deleteTableEntry/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Deletion Failed!"})}}letf=(0,o.M)(s,"default"),E=(0,o.M)(s,"config"),p=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/deleteTableEntry",pathname:"/api/deleteTableEntry",bundlePath:"",filename:""},userland:s})},31495:(e,r,t)=>{t.d(r,{A:()=>a});vars=t(48786),n=t(67619);asyncfunctiona({user:e,confirmedDelegetedUser:r,database:t,table:a,priviledgeRegex:o,dbId:l}){leti,u;try{r?.delegated?(i=await(0,s.A)("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,a]),u=i[0]?.priviledge?.match(o)):(i=await(0,s.A)("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,a,l]),u=!0)}catch(r){(0,n.default)({component:"checkUserRights",message:r.message,user:e})}return!!i&&!!i[0]&&!!u}},60125:(e,r,t)=>{t.d(r,{A:()=>n});vars=t(95969);asyncfunctionn({request:e,databaseSlug:r,user:t,query:n}){try{leta=t.id,o=null;if(!n?.delegated)return{dbUserId:a};letl=n.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${l}_${r}`,u=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[u])throwError("Cookie not present");lett=(0,s.A)({encryptedString:e.cookies[u]});if(!t)throwError("Invalid Token");if((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:a=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:a}}catch(e){returnnull}}},69842:(e,r,t)=>{t.d(r,{A:()=>i});vars=t(48786),n=t(95969),a=t(29021),o=t.n(a),l=t(89159);asyncfunctioni(e,r,t){let{keyCookieName:a,csrfCookieName:i}=(0,l.A)();if(!e.cookies?.[a]?.match(/./))returnnull;letu=(0,n.A)({encryptedString:e.cookies[a]});if(!u)returnnull;letc=JSON.parse(u);if(!c.csrf_k||t&&!Object.keys(e.headers).find(e=>e.includes(c.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}/${c.csrf_k}`))returnnull;if(0==c.verification_status&&!t){lete=await(0,s.A)(`SELECT verification_status FROM users WHERE id='${c.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnc?.date&&Date.now()-c.date>6048e5?null:c}},89159:(e,r,t)=>{t.d(r,{A:()=>s});functions(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||