"use strict";(()=>{vare={};e.id=2678,e.ids=[2678],e.modules={28187:e=>{e.exports=require("@moduletrace/datasquirel")},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")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},10304:(e,r,t)=>{t.r(r),t.d(r,{config:()=>E,default:()=>f,routeModule:()=>v});vars={};t.r(s),t.d(s,{default:()=>S});vari=t(89947),n=t(2706),a=t(96762),o=t(51348),c=t.n(o),u=t(6420),l=t.n(u),d=t(33873),_=t.n(d);letp=t(29021),m=t(28187);asyncfunctionS(e,r){if("POST"!==e.method)returnr.json({success:!1,msg:"Failed!"});lett=awaitl()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});lets=m.sanitizeSql(e.body,null);if(s.media_url?.match(/\.\./)||s.folder?.match(/\.\./)||s.id?.toString()?.match(/\.\./))returnr.json({success:!1,msg:"Error!",error:"Invalid url"});try{lete=s?.private==1,i=e?s?.media_path?.replace(/\@\/media/i,"")||s?.media_url.replace(/\@\/media/i,""):s?.media_path?.match(/\/user-images\/user-.*/)||s?.media_url?.match(/\/user-images\/user-.*/),n=s.folder?`/${s.folder}`:"",a=process.env.DSQL_STATIC_SERVER_DIR;if(!a)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");leto=_().join(a,"images"),u=`${process.env.DSQL_STATIC_HOST}/images/user-images/user-${t.id}`,l=`/images/user-images/user-${t.id}`,d=(e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/media`:o)+i,m=e?`${o}/user-images/user-${t.id}`:`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/media`;if(!p.existsSync(m))try{p.mkdirSync(m,{recursive:!0})}catch(e){console.log("LINE 88 error:",e.message)}n&&n.split("/").reduce((e,r)=>{lett=e?.match(/./)?`${e}/${r}`:m;returnp.existsSync(t)||p.mkdirSync(t,{recursive:!0}),t},"");letS=d?.match(/[^\/]+$/)?.[0];if(!S)throwError("No File Name Detected!");letf=S.split(".")[0],E=S.split(".")[1],v=e?`${u}${n?n+"/":"/"}${S}`:`@/media${n?n+"/":"/"}${S}`,h=e?`${l}${n?n+"/":"/"}${S}`:`@/media${n?n+"/":"/"}${S}`;p.copyFileSync(d,m+n+"/"+S),p.unlinkSync(d);letP=f+"_thumbnail."+E,g=d.replace(S,P),$=e?`${u}${n?n+"/":"/"}${P}`:`@/media${n?n+"/":"/"}${P}`,D=e?`${l}${n?n+"/":"/"}${P}`:`@/media${n?n+"/":"/"}${P}`;try{p.copyFileSync(g,m+n+"/"+P),p.unlinkSync(g)}catch(e){}awaitc()("UPDATE user_media SET private = ?, media_url= ?, media_thumbnail_url= ?, media_path = ?, media_thumbnail_path = ? WHERE id = ?",[e?0:1,v,$,h,D,s.id]),r.json({success:!0,msg:"Success!"})}catch(e){console.log(e.message),r.json({success:!1,msg:"Error!",error:e})}}letf=(0,a.M)(s,"default"),E=(0,a.M)(s,"config"),v=newi.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/media/addPrivateMedia",pathname:"/api/media/addPrivateMedia",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),i=t(72835),n=t(29021),a=t(31341);asyncfunctiono(e,r,t,o){let{keyCookieName:c,csrfCookieName:u}=a();if(!e.cookies?.[c]?.match(/./))returnnull;letl=i({encryptedString:e.cookies[c]});if(!l)returnnull;letd=JSON.parse(l);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!n.existsSync(`${_}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d.date>6048e5?null:d}e.exports=o},31341:e=>{e.exports=function(){lete=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NA