"use strict";(()=>{vare={};e.id=9785,e.ids=[9785],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")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},81764:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>c,routeModule:()=>p});vari={};t.r(i),t.d(i,{default:()=>_});vars=t(89947),a=t(2706),n=t(96762),l=t(6420),o=t.n(l),d=t(44767),u=t.n(d);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaito()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});console.log("Invitation Received by current logged in user, Loggin in VIA API ...");leti=awaitu()({query:e.body.query,user:t});r.json({success:!0,result:i})}letc=(0,n.M)(i,"default"),m=(0,n.M)(i,"config"),p=news.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/addAdminUserUser",pathname:"/api/addAdminUserUser",bundlePath:"",filename:""},userland:i})},6420:(e,r,t)=>{t(81630);leti=t(51348),s=t(72835),a=t(29021),n=t(31341);asyncfunctionl(e,r,t,l){let{keyCookieName:o,csrfCookieName:d}=n();if(!e.cookies?.[o]?.match(/./))returnnull;letu=s({encryptedString:e.cookies[o]});if(!u)returnnull;let_=JSON.parse(u);if(!_.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${_.csrf_k}`)))returnnull;letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!a.existsSync(`${c}/${_.csrf_k}`))returnnull;if(0==_.verification_status&&!t){lete=awaiti(`SELECT verification_status FROM users WHERE id='${_.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return_?.date&&Date.now()-_.date>6048e5?null:_}e.exports=l},44767:(e,r,t)=>{leti=t(48225),s=t(51348),a=t(47670),n=t(44900);e.exports=asyncfunction({query:e,user:r,useLocal:t}){try{leti=t?n:s,{invite:l,database_access:o,priviledge:d,email:u}=e,_=[l,u],c=awaiti("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",_);if(!c||!c[0])throwError("No Invitation Found");letm=[l],p=awaiti("SELECT first_name,last_name,email FROM users WHERE id=?",m);if(p?.[0]){lete=awaiti("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[l,r.id,u]);if(e?.[0])console.log("User already added");else{a({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:l,invited_user_id:r.id,database_access:o,first_name:r.first_name,last_name:r.last_name,phone:r.phone,email:r.email,username:r.username,user_type:"admin",user_priviledge:d,image:r.image,image_thumbnail:r.image_thumbnail},useLocal:t});lete=awaiti("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[l,u]);if(awaiti("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[l,r.id]),e&&e[0]){leti=e[0].db_tables_data.split("|");for(lete=0;e<i.length;e++){let[s,n]=i[e].split("-");awaita({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:r.id,root_user_id:l,database:s,table:n,priviledge:d},useLocal:t})}}}awaiti("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[l,u])}}catch(e){i({component:"addAdminUserOnLogin",message:e.message,user:r})}}},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",i=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=r;e?.userId&&(s+=`user_${e.userId}_`),e?.database&&(s+=`${e.database}_`),s+=t;leta=r;returne?.userId&&(a+=`user_${e.userId}_`),e?.database&&(a+=`${e.database}_`),{keyCookieName:s,csrfCookieName:a+=i}}},48225:(e,r,t)=>{leti=t(29021),{IncomingMessage:s}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:s,req:a}){letn=newDate,l=(()