"use strict";(()=>{vare={};e.id=4436,e.ids=[4436],e.modules={27825:e=>{e.exports=require("lodash")},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")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},13461:(e,a,t)=>{t.r(a),t.d(a,{config:()=>A,default:()=>y,routeModule:()=>b});varl={};t.r(l),t.d(l,{default:()=>R});varr=t(89947),s=t(2706),i=t(96762),d=t(51348),u=t.n(d),n=t(77538),o=t.n(n),p=t(6420),m=t.n(p),f=t(47670),c=t.n(f);let_=t(29021),N=t(33873),{execSync:T}=t(79646);asyncfunctionR(e,a){if("POST"!==e.method)returna.json({msg:"Failed!"});letl=awaitm()(e,a,!0);if(!l)returna.json({success:!1,msg:"Unauthorized"});let{dbFullName:r,dbSlug:s,dbId:i}=e.body,d=t(87924),n=t(83434),p=[...n.slice(0,2),...d.fields,...n.slice(2)];d.fields=[...p];try{lete;lett=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${l.id}/main.json`,n=JSON.parse(_.readFileSync(t,"utf8")),p=n.filter(e=>e.dbFullName===r)[0],m=p.tables.filter((a,t)=>{if("users"===a.tableName)returne=t,!0});if(m?.[0]&&"number"==typeofe?p.tables[e]=d:p.tables.push(d),p.childrenDatabases)for(lete=0;e<p.childrenDatabases.length;e++){leta=p.childrenDatabases[e];try{n.filter(e=>e.dbFullName===a.dbFullName)[0].tables=p.tables;lete=awaitu()("SELECT * FROM user_databases WHERE user_id = ? AND db_full_name = ?",[l.id,a.dbFullName]);awaitc()({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:l.id,db_id:e[0].id,db_slug:e[0].db_slug,table_name:"Users",table_slug:"users"}})}catch(e){o()({component:"/api/addUsersTableToDatabase/lines-100-115",message:e.message,user:l})}}_.writeFileSync(`${t}`,JSON.stringify(n),"utf8"),awaitc()({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:l.id,db_id:i,db_slug:s,table_name:"Users",table_slug:"users"}});letf=N.join(process.cwd(),"/shell"),R=r.replace(/[^a-z\_0-9]/g,""),y=T(`node createDbFromSchema.js --user ${l.id} --database ${R}`,{cwd:f});console.log(y.toString()),a.json({success:!0})}catch(e){o()({component:"/api/addUsersTableToDatabase/main-catch-error",message:e.message,user:l}),a.json({success:!1,msg:"Database Files could not be written!"})}}lety=(0,i.M)(l,"default"),A=(0,i.M)(l,"config"),b=newr.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/addUsersTableToDatabase",pathname:"/api/addUsersTableToDatabase",bundlePath:"",filename:""},userland:l})},77538:(e,a,t)=>{letl=t(29021),{IncomingMessage:r}=t(81630);e.exports=asyncfunction({user:e,message:a,component:t,noMail:r,req:s}){leti=newDate,d=(()=>{if(!s)returnnull;try{lete=s.headers["x-forwarded-for"],a=s.headers["x-real-ip"],t=s.headers["cf-connecting-ip"],l=Array.isArray(e)?e[0]:e?.split(",")[0],r=t||l||a||s.socket.remoteAddress;if(!r)returnnull;returnString(r)}catch(e){returnnull}})();try{letr=`🚀 SERVER ERROR ===========================