"use strict";(()=>{vare={};e.id=7214,e.ids=[7214],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")},81630:e=>{e.exports=require("http")},21820:e=>{e.exports=require("os")},33873:e=>{e.exports=require("path")},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}}})},29750:(e,r,t)=>{t.r(r),t.d(r,{config:()=>h,default:()=>E,routeModule:()=>y});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),a=t(2706),o=t(96762),l=t(33364),i=t.n(l),c=t(48225),u=t.n(c),p=t(6420),d=t.n(p),_=t(57638),S=t.n(_);letm=t(29021),f=t(21820);t(33873);let{execSync:D}=t(79646);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitd()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{id:s,db_name:n,db_slug:a,db_description:o,db_image:l,db_full_name:c,active_clone:p,active_clone_parent_db:_}=e.body;c?.match(/datasquirel_user_.*/)||r.json({success:!1,msg:"Unauthorized"});letg=`datasquirel_user_${t.id}_${a}`;if(awaiti()({dbFullName:"datasquirel",tableName:"user_databases",identifierColumnName:"id",identifierValue:s,data:{db_name:n,db_slug:a,db_description:o,db_image:l,db_full_name:g}}),c&&c!==g){console.log("Renaming Database");lete=f.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql",r=f.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{awaitS()({queryString:`CREATE DATABASE \`${g}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`,database:c});lett={cwd:process.cwd()};f.platform().match(/win/i)&&(t.shell="bash.exe");lets=`${r} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${c} > tmpDbFile.sql`;console.log(`updateUserDatabase.js exe => ${s}`),D(s,t),D(`${e} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${g} < tmpDbFile.sql`,t),awaitS()({queryString:`DROP DATABASE \`${c}\``,database:c})}catch(e){u()({component:"/api/updateUserDatabase/lines-88-111",message:e.message,user:t})}}try{lete=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,s=JSON.parse(m.readFileSync(e,"utf8")),i=s.filter(e=>e.dbFullName===c);if(i[0].dbName=n,i[0].dbFullName=g,i[0].dbDescription=o,i[0].dbImage=l,i[0].dbSlug=a,p){lete=s.filter(e=>e.dbFullName===i[0].childDatabaseDbFullName)[0],r=e.childrenDatabases?.find(e=>e.dbFullName===c);r&&(r.dbFullName=g)}m.writeFileSync(`${e}`,JSON.stringify(s),"utf8"),r.json({success:!0})}catch(e){u()({component:"/api/updateUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}letE=(0,o.M)(s,"default"),h=(0,o.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUserDatabase",pathname:"/api/updateUserDatabase",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),a=t(29021),o=t(31341);asyncfunctionl(e,r,t,l){let{keyCookieName:i,csrfCookieName:c}=o();if(!e.cookies?.[i]?.match(/./))returnnull;letu=n({encryptedString:e.cookies[i]});if(!u)returnnull;letp=JSON.parse(u);if(!p.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${p.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&&!a.existsSync(`${d}/${p.csrf_k}`))returnnull;if(0==p.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${p.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnp?.date&&Date.now()-p.date>6048