"use strict";(()=>{vare={};e.id=3040,e.ids=[3040],e.modules={27825:e=>{e.exports=require("lodash")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},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")},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}}})},0:(e,r,t)=>{t.r(r),t.d(r,{config:()=>h,default:()=>m,routeModule:()=>y});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),o=t(2706),a=t(96762),i=t(2258),l=t(48225),u=t.n(l),c=t(6420),d=t.n(c),p=t(27825),f=t.n(p),_=t(51348),S=t.n(_);t(29021),t(33873);let{execSync:E}=t(79646);asyncfunctiong(e,r){if("GET"!==e.method)returnr.json({msg:"Failed!"});lett=awaitd()(e,r);if(!t)returnr.json({success:!1,msg:"Unauthorized"});lets=e.query.dbUserId;e.query.delegated;try{if(!s)throwError("No Root user Id Found!");lete=awaitS()("SELECT * FROM datasquirel.delegated_user_tables WHERE delegated_user_id=? AND root_user_id=?",[String(t.id),String(s)]),n=(0,i.default)({userId:String(s)});if(!n)throwError("Root user schema not found!");leto=[];e.forEach(e=>{letr=o.findIndex(r=>r.dbSlug===e.database),t=n.find(r=>r.dbSlug===e.database);if(t){lets=o[r]?o[r]:{...t,tables:[]},n=f().cloneDeep(t.tables).find(r=>r.tableName===e.table);n&&o[r]?o[r]={...s,tables:[...o[r].tables,n]}:n&&!o[r]&&o.push({...t,tables:[n]})}}),r.json({success:!0,payload:o})}catch(e){console.log("ERROR:",e.message),u()({component:"/api/get-authorized-databases",message:e.message,user:t}),r.json({success:!1,msg:e.message})}}letm=(0,a.M)(s,"default"),h=(0,a.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/get-authorized-databases",pathname:"/api/get-authorized-databases",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),o=t(29021),a=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:u}=a();if(!e.cookies?.[l]?.match(/./))returnnull;letc=n({encryptedString:e.cookies[l]});if(!c)returnnull;letd=JSON.parse(c);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;letp=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o.existsSync(`${p}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d.date>6048e5?null:d}e.exports=i},31341:e=>{e.exports=function(){lete=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},2258:(e,r,t)=>{t.r(r),t.d(r,{default:()=>a});lets=t(48225),n=t(29021),o=t(33873);functiona({userId:e}){try{letr=o.resolve(process.cwd(),`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${e}/main.json`);returnJSON.parse(n.readFileSync(r,"utf-8"))}catch(e){returns({component:"grabUserSchemaData",message:e.message}),null}}},48225:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:o}){leta=newDate,i=(()=>{if(!o)returnnull;try{lete=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||o.socket.remoteAddress;if(!n)returnnull;returnString(n)}catch(e){returnnull}})();try{letn=`🚀 SERVER ERROR ===========================