"use strict";(()=>{vare={};e.id=3133,e.ids=[3133],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},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")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,s){returnsinr?r[s]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,s)):"function"==typeofr&&"default"===s?r:void0}}})},25477:(e,r,s)=>{s.r(r),s.d(r,{config:()=>D,default:()=>S,routeModule:()=>f});vart={};s.r(t),s.d(t,{default:()=>p});varo=s(89947),a=s(2706),n=s(96762),i=s(29021),l=s.n(i),u=s(60125),c=s(67619),d=s(69842),_=s(76856);asyncfunctionp(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lets=await(0,d.A)(e,r,!0);if(!s)returnr.json({success:!1,msg:"Unauthorized"});let{tableData:t}=e.body,o=e.body.database,a=e.body.dbSlug;e.body.delegated;letn=o.replace(/[^a-z\_0-9]/g,"");try{leti=await(0,u.A)({request:e,user:s,databaseSlug:a,query:e.query}),c=i?.rootUserId?i.rootUserId:s.id,d=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${c}/main.json`,p=JSON.parse(l().readFileSync(d,"utf-8")),S=p.findIndex(e=>e.dbFullName===o),D=p[S].tables.findIndex(e=>e.childTable&&e.childTableDbFullName===t.childTableDbFullName&&e.childTableName===t.childTableName&&e.tableName===t.tableName);p[S].tables[D]=t,l().writeFileSync(`${d}`,JSON.stringify(p),"utf8"),await(0,_.A)({userId:c,targetDatabase:n}),r.json({success:!0})}catch(e){console.log(e.message),(0,c.A)({component:"/api/addApiKey/catch-error",message:e.message,user:s}),r.json({success:!1,msg:"Foreign Key update Failed."})}}letS=(0,n.M)(t,"default"),D=(0,n.M)(t,"config"),f=newo.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateClonedTableForeignKeys",pathname:"/api/updateClonedTableForeignKeys",bundlePath:"",filename:""},userland:t})},60125:(e,r,s)=>{s.d(r,{A:()=>o});vart=s(95969);asyncfunctiono({request:e,databaseSlug:r,user:s,query:o}){try{leta=s.id,n=null;if(!o?.delegated)return{dbUserId:a};leti=o.dbUserId,l=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,u=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${l}`;try{if(!e.cookies?.[u])throwError("Cookie not present");lets=(0,t.A)({encryptedString:e.cookies[u]});if(!s)throwError("Invalid Token");if((n=JSON.parse(s)).databaseSlug===r)return{dbUserId:a=n.rootUserId,rootUserId:n.rootUserId,rootUserName:n.rootUserName,rootUserEmail:n.rootUserEmail,rootUserImage:n.rootUserImage,databaseFullName:n.databaseFullName,databaseSlug:n.databaseSlug,allowedTables:n.allowedTables,priviledges:n.priviledges,database:n.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:a}}catch(e){returnnull}}},69842:(e,r,s)=>{s.d(r,{A:()=>a});vart=s(39908),o=s.n(t);asyncfunctiona(e,r,s){lett=o()({req:e,level:s?"deep":void0});returnconsole.log(t),t.payload}},95969:(e,r,s)=>{s.d(r,{A:()=>n});vart=s(55511),o=s(79428),a=s(32443);functionn({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;let{key:n,salt:i,keyLen:l,algorithm:u,bufferAllocSize:c}=(0,a.A)({encryptionKey:r});if(!n?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;letd=(0,t.scryptSync)(n,i,l),_=o.Buffer.alloc(c,0),p=(0,t.createDecipheriv)(u,d,_);try{letr=p.update(e,"hex","utf8");returnr+=p.final("utf8")}catch(r){returnconsole.log("Error in decrypting =>",r.message),e}}},7447:(e,r,s)=>{s.d(r,{A:()=>a});vart=s(9973),o=s.n(t);functiona(e){returne?.ro?DSQL_READ_ONLY_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOS