"use strict";(()=>{vare={};e.id=4436,e.ids=[4436],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")},32551:(e,a,s)=>{s.r(a),s.d(a,{config:()=>b,default:()=>p,routeModule:()=>A});vart={};s.r(t),s.d(t,{default:()=>c});varl=s(89947),r=s(2706),d=s(96762),i=s(48786),u=s(67619),n=s(69842),o=s(98e3),_=s(76856);letf=s(29021);s(33873);let{execSync:m}=s(79646);asyncfunctionc(e,a){if("POST"!==e.method)returna.json({msg:"Failed!"});lett=await(0,n.A)(e,a,!0);if(!t)returna.json({success:!1,msg:"Unauthorized"});let{dbFullName:l,dbSlug:r,dbId:d}=e.body,m=s(8693),c=s(95610),p=[...c.slice(0,2),...m.fields,...c.slice(2)];m.fields=[...p];try{lete;lets=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,n=JSON.parse(f.readFileSync(s,"utf8")),c=n.filter(e=>e.dbFullName===l)[0],p=c.tables.filter((a,s)=>{if("users"===a.tableName)returne=s,!0});if(p?.[0]&&"number"==typeofe?c.tables[e]=m:c.tables.push(m),c.childrenDatabases)for(lete=0;e<c.childrenDatabases.length;e++){leta=c.childrenDatabases[e];try{n.filter(e=>e.dbFullName===a.dbFullName)[0].tables=c.tables;lete=await(0,i.A)("SELECT * FROM user_databases WHERE user_id = ? AND db_full_name = ?",[t.id,a.dbFullName]);await(0,o.A)({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:t.id,db_id:e[0].id,db_slug:e[0].db_slug,table_name:"Users",table_slug:"users"}})}catch(e){(0,u.default)({component:"/api/addUsersTableToDatabase/lines-100-115",message:e.message,user:t})}}f.writeFileSync(`${s}`,JSON.stringify(n),"utf8"),await(0,o.A)({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:t.id,db_id:d,db_slug:r,table_name:"Users",table_slug:"users"}});letb=l.replace(/[^a-z\_0-9]/g,"");await(0,_.A)({userId:t.id,targetDatabase:b}),a.json({success:!0})}catch(e){(0,u.default)({component:"/api/addUsersTableToDatabase/main-catch-error",message:e.message,user:t}),a.json({success:!1,msg:"Database Files could not be written!"})}}letp=(0,d.M)(t,"default"),b=(0,d.M)(t,"config"),A=newl.PagesAPIRouteModule({definition:{kind:r.A.PAGES_API,page:"/api/addUsersTableToDatabase",pathname:"/api/addUsersTableToDatabase",bundlePath:"",filename:""},userland:t})},69842:(e,a,s)=>{s.d(a,{A:()=>u});vart=s(48786),l=s(95969),r=s(29021),d=s.n(r),i=s(89159);asyncfunctionu(e,a,s){let{keyCookieName:r,csrfCookieName:u}=(0,i.A)();if(!e.cookies?.[r]?.match(/./))returnnull;letn=(0,l.A)({encryptedString:e.cookies[r]});if(!n)returnnull;leto=JSON.parse(n);if(!o.csrf_k||s&&!Object.keys(e.headers).find(e=>e.includes(o.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(s&&!d().existsSync(`${_}/${o.csrf_k}`))returnnull;if(0==o.verification_status&&!s){lete=await(0,t.A)(`SELECT verification_status FROM users WHERE id='${o.id}'`);e&&e[0]&&1==e[0].verification_status&&a.setHeader("Set-Cookie",["user_refresh=1"])}returno?.date&&Date.now()-o.date>6048e5?null:o}},89159:(e,a,s)=>{s.d(a,{A:()=>t});functiont(e){leta=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",l=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",r=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),d=a;e?.userId&&(d+=`user_${e.userId}_`),r&&(d+=`${r}_`),d+=s;leti=a;e?.userId&&(i+=`user_${e.userId}_`),r&&(i+=`${r}_`),i+=t;letu=a;returne?.userId&&(u+=`user_${e.userId}_`),r&&(u+=`${r}_`),{keyCookieName:d,csrfCookieName:i,oneTimeCodeName:u+=l}}},8693:e=>{e.exports=JSON.parse('{"tableName":"users","tableFullName":"Users","fields":[{"fieldName":"first_name","dataType":"VARCHAR(100)","notNullValue":