"use strict";(()=>{vare={};e.id=5757,e.ids=[5757],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}}})},96332:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>_,routeModule:()=>E});vara={};t.r(a),t.d(a,{default:()=>f});vars=t(89947),n=t(2706),l=t(96762),o=t(30944),i=t(67619),c=t(69842),u=t(48786);letd=t(29021);asyncfunctionf(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,c.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});leta=e.body,{id:s,user_id:n,table_name:l,table_slug:f,table_description:_}=a.table,{db_full_name:p}=a.database;await(0,o.A)({database:p,queryString:`DROP TABLE \`${p}\`.\`${f}\``});letE=s?[s]:[f,t.id,a.database.id];await(0,u.A)(s?"DELETE FROM user_database_tables WHERE id=?":"DELETE FROM user_database_tables WHERE table_slug=? AND user_id=? AND db_id=?",E);try{lete;leta=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,s=JSON.parse(d.readFileSync(a,"utf8")),n=s.filter((e,r)=>{if(e.dbFullName===p)return!0}),l=n[0].tables.filter((r,t)=>{if(r?.tableName===f)returne=t,!0});if(l[0].childTable){lete;letr=s.filter(e=>e.dbFullName===l[0].childTableDbFullName)[0].tables.filter(e=>{if(e.tableName===l[0].childTableName)return!0})[0];r.childrenTables?.filter((r,t)=>{r.tableName===f&&(e=t)}),"number"==typeofe&&r.childrenTables?.splice(e,1)}if(n[0].tables.splice(e,1),n[0].childrenDatabases)for(lete=0;e<n[0].childrenDatabases.length;e++){letr=n[0].childrenDatabases[e];try{lete=s.filter(e=>e.dbFullName===r.dbFullName)[0];e.tables=n[0].tables,await(0,u.A)("DELETE FROM user_database_tables WHERE table_slug=? AND user_id=? AND db_slug=?",[f,t.id,e.dbSlug])}catch(e){(0,i.default)({component:"/api/deleteUserTable/lines-125-128",message:e.message,user:t})}}d.writeFileSync(`${a}`,JSON.stringify(s),"utf8"),r.json({success:!0})}catch(e){(0,i.default)({component:"/api/deleteUserTable/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"File Updates Failed"})}}let_=(0,l.M)(a,"default"),p=(0,l.M)(a,"config"),E=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/deleteUserTable",pathname:"/api/deleteUserTable",bundlePath:"",filename:""},userland:a})},69842:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(48786),s=t(95969),n=t(29021),l=t.n(n),o=t(89159);asyncfunctioni(e,r,t){try{let{keyCookieName:n,csrfCookieName:i}=(0,o.A)();if(!e.cookies?.[n]?.match(/./))throwError("Request Cookies not Found!");letc=(0,s.A)({encryptedString:e.cookies[n]});if(!c)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(c);if(!u.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throwError("Deep Auth Failed. `csrf` key not found in request headers!");letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!l().existsSync(`${d}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");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"])}if(u?.date&&Date.now()-u.date>6048e5)throwError("Key expired!");returnu}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},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+_/,""