"use strict";(()=>{vare={};e.id=3338,e.ids=[3338],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},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,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},670:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>E,routeModule:()=>S});varo={};t.r(o),t.d(o,{default:()=>f});vars=t(89947),n=t(2706),i=t(96762),c=t(29021),a=t.n(c),u=t(48786),l=t(69842),d=t(33873),_=t.n(d);asyncfunctionf(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});if(!await(0,l.A)(e,r,!0))returnr.json({success:!1,msg:"Unauthorized"});let{paradigm:t,payload:o}=e.body;try{console.log("Deleting media =>",o.id);lete=o.media_url,t=process.env.DSQL_STATIC_SERVER_DIR,s=process.env.DSQL_STATIC_HOST;if(!t){console.log("No Static Root Path"),r.json({success:!1,msg:"No Static Root Path"});return}letn=e.replace(s,""),i=_().join(t,n),c=a().existsSync(i);if(console.log("relativePath",n),console.log("STATIC_ROOT",t),console.log("STATIC_HOST",s),console.log("filePath",i),console.log("fileExist",c),c){r.json({success:!1});return}}catch(e){console.log("File verification Error =>",e.message),console.log("File Truly doesn't exist, cotinuing ...")}"user_media"===t&&await(0,u.A)(`DELETE FROM user_media WHERE id='${o.id}'`),r.json({success:!0})}letE=(0,i.M)(o,"default"),p=(0,i.M)(o,"config"),S=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/purgeDb",pathname:"/api/purgeDb",bundlePath:"",filename:""},userland:o})},69842:(e,r,t)=>{t.d(r,{A:()=>a});varo=t(48786),s=t(95969),n=t(29021),i=t.n(n),c=t(89159);asyncfunctiona(e,r,t){try{let{keyCookieName:n,csrfCookieName:a}=(0,c.A)();if(!e.cookies?.[n]?.match(/./))throwError("Request Cookies not Found!");letu=(0,s.A)({encryptedString:e.cookies[n]});if(!u)throwError("Couldn't decrypt auth cookie!");letl=JSON.parse(u);if(!l.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(l.csrf_k)))throwconsole.log("req.headers",e.headers),console.log("userObject",l),Error("Deep Auth Failed. `csrf` key not found in request headers!");letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!i().existsSync(`${d}/${l.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==l.verification_status&&!t){lete=await(0,o.A)(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(l?.date&&Date.now()-l.date>6048e5)throwError("Key expired!");returnl}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>o});functiono(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",o=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",n=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),i=r;e?.userId&&(i+=`user_${e.userId}_`),n&&(i+=`${n}_`),i+=t;letc=r;e?.userId&&(c+=`user_${e.userId}_`),n&&(c+=`${n}_`),c+=o;leta=r;returne?.userId&&(a+=`user_${e.userId}_`),n&&(a+=`${n}_`),{keyCookieName:i,csrfCookieName:c,oneTimeCodeName:a+=s}}},95969:(e,r,t)=>{t.d(r,{A:()=>n});varo=t(55511),s=t(79428);functionn({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;letn=r||process.env.DSQL_ENCRYPTION_PASSWORD,i=t||process.env.DSQL_ENCRYPTION_SALT,c=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!n?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;le