"use strict";(()=>{vare={};e.id=538,e.ids=[538],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")},9288:e=>{e.exports=require("sharp")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},41848:(e,r,t)=>{t.r(r),t.d(r,{config:()=>v,default:()=>y,routeModule:()=>R});vara={};t.r(a),t.d(a,{default:()=>h});vars=t(89947),o=t(2706),l=t(96762);t(82703),t(10701);vari=t(77538),n=t.n(i),d=t(6420),u=t.n(d),c=t(27825),m=t.n(c),p=t(51348),f=t.n(p),b=t(27444);t(39831),t(81630),t(77538);let_=t(51348);asyncfunctionS({tbls:e,user:r,query:t}){leta;if(!t?.delegated)return{isPriviledged:!0,rootUserId:r.id};try{for(lett=0;t<e.length;t++){lets=e[t],o=await_(`SELECT * FROM delegated_user_tables WHERE delegated_user_id='${r.id}' AND \`database\`='${s.db}' AND \`table\`='${s.table}'`);if(!o?.[0]?.root_user_id)throwError("Unauthorized!");letl=o[0];a||(a=l.root_user_id)}return{isPriviledged:!0,rootUserId:a}}catch(e){return{isPriviledged:!1,rootUserId:a,error:e.message}}}varg=t(49827);t(29021),t(33873);let{execSync:E}=t(79646);asyncfunctionh(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitu()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{paradigm:a,src:s,dst:o}=e.body;try{letl=awaitS({tbls:[{db:s.db,table:s.table},{db:o.db,table:o.table}],user:t,query:e.query});if(!l.rootUserId||!l.isPriviledged)throwError(l.error||"Unauthorized!");leti=(0,g.default)({userId:l.rootUserId});if(!i)throwError("User Schema Data not Found!");letn=`${process.env.DSQL_USER_DB_PREFIX}${l.rootUserId}_${o.db}`,d=`${process.env.DSQL_USER_DB_PREFIX}${l.rootUserId}_${s.db}`,u=i.find(e=>e.dbFullName==n),c=i.find(e=>e.dbFullName==d),p=u?.tables.find(e=>e.tableName==o.table),_=c?.tables.find(e=>e.tableName==s.table);if(!p||!_)throwError("Operation Failed! Tables Schemas not present.");if(!m().isEqual(_.fields,p.fields))throwError("Tables incompatible");switch(a){case"Push":letE=awaitf()(`SELECT * FROM ${d}.${s.table}`),h=await(0,b.A)({dbName:o.db,paradigm:"import",payload:E,tableName:o.table,userId:l.rootUserId,payloadType:"object"});returnawait$({dbName:o.db,tableName:o.table,data:E,userId:l.rootUserId}),r.json({success:!0,payload:h});case"Pull":lety=awaitf()(`SELECT * FROM ${n}.${o.table}`),v=await(0,b.A)({dbName:s.db,paradigm:"import",payload:y,tableName:s.table,userId:l.rootUserId,payloadType:"object"});returnawait$({dbName:s.db,tableName:s.table,data:y,userId:l.rootUserId}),r.json({success:!0,payload:v})}r.json({success:!1})}catch(e){console.log(e.message),n()({component:"/api/sync-table-data",message:e.message,user:t}),r.json({success:!1,msg:e.message})}}asyncfunction$({dbName:e,tableName:r,data:t,userId:a}){lets=`${process.env.DSQL_USER_DB_PREFIX}${a}_${e.replace(/ /g,"")}`,o=t.map(e=>e.id),l=`DELETE FROM ${s}.${r}`;o?.[0]&&(l+=` WHERE id NOT IN (${o.join(",")})`),awaitf()(l)}lety=(0,l.M)(a,"default"),v=(0,l.M)(a,"config"),R=news.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/sync-table-data",pathname:"/api/sync-table-data",bundlePath:"",filename:""},userland:a})},10701:(e,r,t)=>{leta=t(9288),s=t(77538),o=t(48227);e.exports=asyncfunction({imageSourceBase64:e,imageName:r,user:t,mimeType:l,thumbnailSize:i,folder:n,isPrivate:d}){try{lets=Buffer.from(e,"base64"),u=i?parseInt(i.toString()):400,c=a(s),m=a(s),p=o({isPrivate:d,user:t,folder:n});if(!p)returnnull;let{fileRootPath:f,urlRootPath:b,relativePath:_}=p,{width:S,height:g,format:E}=awaitc.metadata(),h=l||E;S&&g&&S>1800&&c.resize(1800,Math.round(1800/S*g),{fit:"cover"}),c.toFormat(h,{quality:80}),awaitc.metadata();let$=`${r}.${h}`;if(awaitc.toFile(f+$),S&&g&&S>u){lete=u/S;m.resize(u,Math.round(g*e),{fit:"cover"})}elseS&&g&&m.resize(150,Math.round(150/S*g),{fit:"cove