"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")},21820:e=>{e.exports=require("os")},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}}})},53382:(e,r,t)=>{t.r(r),t.d(r,{config:()=>y,default:()=>g,routeModule:()=>h});vars={};t.r(s),t.d(s,{default:()=>S});varn=t(89947),a=t(2706),o=t(96762),i=t(29021),l=t.n(i),c=t(21820),u=t.n(c),d=t(79646),p=t(30802),_=t(67619),f=t(69842),m=t(30944);asyncfunctionS(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,f.A)(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:i,db_full_name:c,active_clone:S,active_clone_parent_db:g}=e.body;c?.match(/datasquirel_user_.*/)||r.json({success:!1,msg:"Unauthorized"});lety=`datasquirel_user_${t.id}_${a}`;if(await(0,p.A)({dbFullName:"datasquirel",tableName:"user_databases",identifierColumnName:"id",identifierValue:s,data:{db_name:n,db_slug:a,db_description:o,db_image:i,db_full_name:y}}),c&&c!==y){console.log("Renaming Database");lete=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql",r=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{await(0,m.A)({queryString:`CREATE DATABASE \`${y}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`});lett={cwd:process.cwd()};u().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.ts exe => ${s}`),(0,d.execSync)(s,t),(0,d.execSync)(`${e} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${y} < tmpDbFile.sql`,t),await(0,m.A)({queryString:`DROP DATABASE \`${c}\``})}catch(e){(0,_.A)({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(l().readFileSync(e,"utf8")),u=s.filter(e=>e.dbFullName===c);if(u[0].dbName=n,u[0].dbFullName=y,u[0].dbDescription=o,u[0].dbImage=i,u[0].dbSlug=a,S){lete=s.filter(e=>e.dbFullName===u[0].childDatabaseDbFullName)[0],r=e.childrenDatabases?.find(e=>e.dbFullName===c);r&&(r.dbFullName=y)}l().writeFileSync(`${e}`,JSON.stringify(s),"utf8"),r.json({success:!0})}catch(e){(0,_.A)({component:"/api/updateUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}letg=(0,o.M)(s,"default"),y=(0,o.M)(s,"config"),h=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUserDatabase",pathname:"/api/updateUserDatabase",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>l});vars=t(48786),n=t(95969),a=t(29021),o=t.n(a),i=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:a,csrfCookieName:l}=(0,i.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letc=(0,n.A)({encryptedString:e.cookies[a]});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&&!o().existsSync(`${d}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,s.A)(`SELECT verificatio