"use strict";(()=>{vare={};e.id=460,e.ids=[460],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")},14373:(e,r,t)=>{t.r(r),t.d(r,{config:()=>_,default:()=>E,routeModule:()=>b});vara={};t.r(a),t.d(a,{default:()=>f});vars=t(89947),l=t(2706),i=t(96762),o=t(96771),n=t.n(o),d=t(47670),u=t.n(d);t(51348),t(21339);letc=t(73677),p=t(39831),g=t(77538),m=t(6420);asyncfunctionf(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitm(e,r,!0);if(!t)returnr.json({success:!1,msg:"User Auth Failed"});let{tableName:a,payload:s,tableSchema:l,dbSlug:i,dbId:o,delegated:d}=e.body;try{letd=awaitp({databaseSlug:i,request:e,user:t,query:e.query});if(!awaitc({user:t,confirmedDelegetedUser:d,database:i,table:a,dbId:o,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});letg=d?.rootUserId?`datasquirel_user_${d.rootUserId}_${i}`:`datasquirel_user_${t.id}_${i}`,m=awaitu()({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:g,tableName:a,data:s,tableSchema:l});if(!m.insertId)throwconsole.log("Table Insertion Failed =>",m),Error("Table Insertion Failed");awaitn()({dbName:g,entryId:m.insertId,entryOrder:s.order,tableName:a,tableSchema:l}),r.json({success:!0})}catch(e){g({component:"/api/addTableEntry/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}letE=(0,i.M)(a,"default"),_=(0,i.M)(a,"config"),b=news.PagesAPIRouteModule({definition:{kind:l.A.PAGES_API,page:"/api/addTableEntry",pathname:"/api/addTableEntry",bundlePath:"",filename:""},userland:a})},73677:(e,r,t)=>{leta=t(51348),s=t(77538);e.exports=asyncfunction({user:e,confirmedDelegetedUser:r,database:t,table:l,priviledgeRegex:i,dbId:o}){letn,d;try{r?.delegated?(n=awaita("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,l]),d=n[0]?.priviledge?.match(i)):(n=awaita("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,l,o]),d=!0)}catch(r){s({component:"checkUserRights",message:r.message,user:e})}return!!n&&!!n[0]&&!!d}},39831:(e,r,t)=>{t(81630);leta=t(72907);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:s}){try{letl=t.id,i=null;if(!s?.delegated)return{dbUserId:l};leto=s.dbUserId,n=`${process.env.DSQL_USER_DB_PREFIX}${o}_${r}`,d=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${n}`;try{if(!e.cookies?.[d])throwError("Cookie not present");lett=a(e.cookies[d]);if(!t)throwError("Invalid Token");if((i=JSON.parse(t)).databaseSlug===r)return{dbUserId:l=i.rootUserId,rootUserId:i.rootUserId,rootUserName:i.rootUserName,rootUserEmail:i.rootUserEmail,rootUserImage:i.rootUserImage,databaseFullName:i.databaseFullName,databaseSlug:i.databaseSlug,allowedTables:i.allowedTables,priviledges:i.priviledges,database:i.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:l}}catch(e){returnnull}}},96771:(e,r,t)=>{leta=t(21339);e.exports=asyncfunction({dbName:e,entryId:r,entryOrder:t,tableName:s,tableSchema:l}){try{if(l.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){letl=awaita({database:e,paradigm:"Full Access",queryString:`SELECT * FROM ${s} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!l?.[0])throwError("No Existing Order");awaita({database:e,paradigm:"Full Access",queryString:`UPDATE ${s} SET \`order\` = \`order\` + 1 WHERE \`order\` >= ${t} AND id != ?`,queryValues:[String(r)]})}return!0}catch(e){return!1}}},77538:(e,r,t)=>{leta=t(29021),{IncomingMessage:s}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:s,req:l}){leti=newDate,o=(()=>{if(!l)returnnull;try{lete=l.headers["x-forwarded-for"],r=l.headers