"use strict";(()=>{vare={};e.id=9785,e.ids=[9785],e.modules={28187:e=>{e.exports=require("@moduletrace/datasquirel")},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:()=>_});vara=t(89947),s=t(2706),n=t(96762),l=t(6420),u=t.n(l),d=t(98968),o=t.n(d);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitu()(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=awaito()({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=newa.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/addAdminUserUser",pathname:"/api/addAdminUserUser",bundlePath:"",filename:""},userland:i})},98968:(e,r,t)=>{t(29021),t(28187);leti=t(77538),a=t(51348),s=t(47670);e.exports=asyncfunction({query:e,user:r}){try{let{invite:t,database_access:i,priviledge:n,email:l}=e,u=awaita("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[t,l]);if(!u||!u[0])throwError("No Invitation Found");letd=awaita("SELECT first_name,last_name,email FROM users WHERE id=?",[t]);if(d?.[0]){lete=awaita("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[t,r.id,l]);if(e?.[0])console.log("User already added");else{s({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:t,invited_user_id:r.id,database_access:i,first_name:r.first_name,last_name:r.last_name,phone:r.phone,email:r.email,username:r.username,user_type:"admin",user_priviledge:n,image:r.image,image_thumbnail:r.image_thumbnail}});lete=awaita("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[t,l]);if(awaita("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[t,r.id]),e&&e[0]){leti=e[0].db_tables_data.split("|");for(lete=0;e<i.length;e++){let[a,l]=i[e].split("-");awaits({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:r.id,root_user_id:t,database:a,table:l,priviledge:n}})}}}awaita("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[t,l])}}catch(e){i({component:"addAdminUserOnLogin",message:e.message,user:r})}}},77538:(e,r,t)=>{leti=t(29021),{IncomingMessage:a}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:a,req:s}){letn=newDate,l=(()=>{if(!s)returnnull;try{lete=s.headers["x-forwarded-for"],r=s.headers["x-real-ip"],t=s.headers["cf-connecting-ip"],i=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||i||r||s.socket.remoteAddress;if(!a)returnnull;returnString(a)}catch(e){returnnull}})();try{leta=`🚀 SERVER ERROR ===========================