"use strict";(()=>{vare={};e.id=4371,e.ids=[4371],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){returnfunctione(t,r){returnrint?t[r]:"then"int&&"function"==typeoft.then?t.then(t=>e(t,r)):"function"==typeoft&&"default"===r?t:void0}}})},81147:(e,t,r)=>{r.r(t),r.d(t,{config:()=>m,default:()=>E,routeModule:()=>b});vara={};r.r(a),r.d(a,{default:()=>S});vars=r(89947),n=r(2706),l=r(96762),o=r(48786),i=r(31495),u=r(60125),c=r(67619),d=r(69842),_=r(30802),f=r(76856);letp=r(29021);r(33873);let{execSync:g}=r(79646);asyncfunctionS(e,t){if("POST"!==e.method)returnt.json({msg:"Failed!"});letr=await(0,d.A)(e,t,!0);if(!r)returnt.json({success:!1,msg:"Unauthorized"});let{dbFullName:a,dbSlug:s,dbId:n,tableNameOld:l,payload:g,delegated:S}=e.body,{tableName:E,tableFullName:m,tableDescription:b}=g;if(!E?.match(/./)||E.match(/[^a-zA-Z0-9-_]/))returnt.json({success:!1,msg:"Bad Input"});try{letd=await(0,u.A)({databaseSlug:s,request:e,user:r,query:e.query});if(!await(0,i.A)({user:r,confirmedDelegetedUser:d,database:s,table:l,dbId:n,priviledgeRegex:/Edit Table/i}))returnconsole.log("User Unauthorized"),t.json({success:!1,msg:"Unauthorized"});letg=d?.rootUserId?d.rootUserId:r.id,h=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${g}/main.json`,y=JSON.parse(p.readFileSync(h,"utf8")),A=y.filter(e=>e.dbFullName===a)[0].tables.filter((e,t)=>{if(e.tableName===l)return!0});if(A&&A[0])A[0].tableName=E,A[0].tableNameOld=l,A[0].tableFullName=m,b&&(A[0].tableDescription=b),A[0].childrenTables&&A[0].childrenTables.forEach(e=>{try{y.filter(t=>t.dbFullName===e.dbNameFull)[0].tables.filter(t=>{if(t.tableName===e.tableName)return!0})[0].childTableName=E}catch(e){(0,c.default)({component:"/api/updateUserTable/lines-131-138",message:e.message,user:r})}});elsethrowError("Table Does not exist");p.writeFileSync(`${h}`,JSON.stringify(y),"utf8"),await(0,_.A)({dbFullName:"datasquirel",tableName:"user_database_tables",identifierColumnName:"table_slug",identifierValue:l,data:{table_name:m,table_slug:E,table_description:b}}),S&&d&&await(0,o.A)("UPDATE delegated_user_tables SET `table`=? WHERE delegated_user_id=? AND root_user_id=? AND `table`=? AND `database`=?",[E,r.id,d.rootUserId,l,s]);letN=a.replace(/[^a-z\_0-9]/g,"");await(0,f.A)({userId:g,targetDatabase:N}),t.json({success:!0})}catch(e){(0,c.default)({component:"/api/updateUserTable/main-catch-error",message:e.message,user:r}),t.json({success:!1,msg:"Database Files could not be written!"})}}letE=(0,l.M)(a,"default"),m=(0,l.M)(a,"config"),b=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/updateUserTable",pathname:"/api/updateUserTable",bundlePath:"",filename:""},userland:a})},31495:(e,t,r)=>{r.d(t,{A:()=>n});vara=r(48786),s=r(67619);asyncfunctionn({user:e,confirmedDelegetedUser:t,database:r,table:n,priviledgeRegex:l,dbId:o}){leti,u;try{t?.delegated?(i=await(0,a.A)("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[t.rootUserId,e.id,r,n]),u=i[0]?.priviledge?.match(l)):(i=await(0,a.A)("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,n,o]),u=!0)}catch(t){(0,s.default)({component:"checkUserRights",message:t.message,user:e})}return!!i&&!!i[0]&&!!u}},60125:(e,t,r)=>{r.d(t,{A:()=>s});vara=r(95969);asyncfunctions({request:e,databaseSlug:t,user:r,query:s}){try{letn=r.id,l=null;if(!s?.delegated)return{dbUserId:n};leto=s.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${o}_${t}`,u=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[u])throwError("Cookie not present");letr=(0,a.A)({encryptedString:e.cookies[u]});if(