"use strict";(()=>{vare={};e.id=3133,e.ids=[3133],e.modules={39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},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")},33873:e=>{e.exports=require("path")},25477:(e,r,a)=>{a.r(r),a.d(r,{config:()=>b,default:()=>m,routeModule:()=>f});vart={};a.r(t),a.d(t,{default:()=>g});vars=a(89947),o=a(2706),l=a(96762),i=a(29021),d=a.n(i),n=a(60125),u=a(67619),c=a(69842),p=a(10776);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});leta=await(0,c.A)(e,r,!0);if(!a)returnr.json({success:!1,msg:"Unauthorized"});let{tableData:t}=e.body,s=e.body.database,o=e.body.dbSlug;e.body.delegated;letl=s.replace(/[^a-z\_0-9]/g,"");try{leti=await(0,n.A)({request:e,user:a,databaseSlug:o,query:e.query}),u=i?.rootUserId?i.rootUserId:a.id,c=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${u}/main.json`,g=JSON.parse(d().readFileSync(c,"utf-8")),m=g.findIndex(e=>e.dbFullName===s),b=g[m].tables.findIndex(e=>e.childTable&&e.childTableDbFullName===t.childTableDbFullName&&e.childTableName===t.childTableName&&e.tableName===t.tableName);g[m].tables[b]=t,d().writeFileSync(`${c}`,JSON.stringify(g),"utf8"),await(0,p.A)({userId:u,targetDatabase:l}),r.json({success:!0})}catch(e){console.log(e.message),(0,u.A)({component:"/api/addApiKey/catch-error",message:e.message,user:a}),r.json({success:!1,msg:"Foreign Key update Failed."})}}letm=(0,l.M)(t,"default"),b=(0,l.M)(t,"config"),f=news.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/updateClonedTableForeignKeys",pathname:"/api/updateClonedTableForeignKeys",bundlePath:"",filename:""},userland:t})},60125:(e,r,a)=>{a.d(r,{A:()=>s});vart=a(95969);asyncfunctions({request:e,databaseSlug:r,user:a,query:s}){try{leto=a.id,l=null;if(!s?.delegated)return{dbUserId:o};leti=s.dbUserId,d=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,n=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${d}`;try{if(!e.cookies?.[n])throwError("Cookie not present");leta=(0,t.A)({encryptedString:e.cookies[n]});if(!a)throwError("Invalid Token");if((l=JSON.parse(a)).databaseSlug===r)return{dbUserId:o=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:o}}catch(e){returnnull}}},69842:(e,r,a)=>{a.d(r,{A:()=>o});vart=a(39383),s=a.n(t);asyncfunctiono(e,r,a){returns()({req:e,level:a?"deep":void0}).payload}},95969:(e,r,a)=>{a.d(r,{A:()=>l});vart=a(55511),s=a(79428),o=a(31542);functionl({encryptedString:e,encryptionKey:r,encryptionSalt:a}){if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;let{key:l,salt:i,keyLen:d,algorithm:n,bufferAllocSize:u}=(0,o.A)({encryptionKey:r});if(!l?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;letc=(0,t.scryptSync)(l,i,d),p=s.Buffer.alloc(u,0),g=(0,t.createDecipheriv)(n,c,p);try{letr=g.update(e,"hex","utf8");returnr+=g.final("utf8")}catch(r){returnconsole.log("Error in decrypting =>",r.message),e}}}};varr=require("../../webpack-api-runtime.js");r.C(e);vara=e=>r(r.s=e),t=r.X(0,[6060,776],()=>a(25477));module.exports=t})();