"use strict";(()=>{vare={};e.id=460,e.ids=[460],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")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},66912:(e,r,t)=>{t.r(r),t.d(r,{config:()=>g,default:()=>f,routeModule:()=>p});vara={};t.r(a),t.d(a,{default:()=>E});vars=t(89947),i=t(2706),l=t(96762),n=t(77377),o=t(98e3),d=t(31495),u=t(60125),c=t(67619),_=t(69842);asyncfunctionE(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,_.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"User Auth Failed"});let{tableName:a,payload:s,tableSchema:i,dbSlug:l,dbId:E,delegated:f}=e.body;try{letc=await(0,u.A)({databaseSlug:l,request:e,user:t,query:e.query});if(!await(0,d.A)({user:t,confirmedDelegetedUser:c,database:l,table:a,dbId:E,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});let_=c?.rootUserId?`datasquirel_user_${c.rootUserId}_${l}`:`datasquirel_user_${t.id}_${l}`,f=await(0,o.A)({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:_,tableName:a,data:s,tableSchema:i});if(!f.insertId)throwconsole.log("Table Insertion Failed =>",f),Error(f?.error||"Table Insertion Failed");await(0,n.A)({dbName:_,entryId:f.insertId,entryOrder:s.order,tableName:a,tableSchema:i}),r.json({success:!0})}catch(e){(0,c.default)({component:"/api/addTableEntry/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}letf=(0,l.M)(a,"default"),g=(0,l.M)(a,"config"),p=news.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addTableEntry",pathname:"/api/addTableEntry",bundlePath:"",filename:""},userland:a})},31495:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(48786),s=t(67619);asyncfunctioni({user:e,confirmedDelegetedUser:r,database:t,table:i,priviledgeRegex:l,dbId:n}){leto,d;try{r?.delegated?(o=await(0,a.A)("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,i]),d=o[0]?.priviledge?.match(l)):(o=await(0,a.A)("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,i,n]),d=!0)}catch(r){(0,s.default)({component:"checkUserRights",message:r.message,user:e})}return!!o&&!!o[0]&&!!d}},60125:(e,r,t)=>{t.d(r,{A:()=>s});vara=t(95969);asyncfunctions({request:e,databaseSlug:r,user:t,query:s}){try{leti=t.id,l=null;if(!s?.delegated)return{dbUserId:i};letn=s.dbUserId,o=`${process.env.DSQL_USER_DB_PREFIX}${n}_${r}`,d=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${o}`;try{if(!e.cookies?.[d])throwError("Cookie not present");lett=(0,a.A)({encryptedString:e.cookies[d]});if(!t)throwError("Invalid Token");if((l=JSON.parse(t)).databaseSlug===r)return{dbUserId:i=l.rootUserId,rootUserId:l.rootUserId,rootUserName:l.rootUserName,rootUserEmail:l.rootUserEmail,rootUserImage:l.rootUserImage,databaseFullName:l.databaseFullName,databaseSlug:l.databaseSlug,allowedTables:l.allowedTables,priviledges:l.priviledges,database:l.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:i}}catch(e){returnnull}}},77377:(e,r,t)=>{t.d(r,{A:()=>s});leta=t(37275);asyncfunctions({dbName:e,entryId:r,entryOrder:t,tableName:s,tableSchema:i}){try{if(i.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){leti=awaita({database:e,paradigm:"Full Access",queryString:`SELECT * FROM ${s} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!i?.[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}}},69842:(e,r,t)=>{t.d(r,{A:()=>o});vara=t(48786),s=t(95969),i=t(29021),l=t.n(i),n=t(89159);asyncfunctiono(e,r,t){let{keyCookieName:i,csrfCookieName:o}=(0,n.A)();if(!e.cookies?.[i]?.match(/./))returnnull;letd=(0,s.A)({encryptedString:e.cookies[i]});if(!d)retur