"use strict";(()=>{vare={};e.id=8103,e.ids=[8103],e.modules={27825:e=>{e.exports=require("lodash")},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}}})},8639:(e,r,t)=>{t.r(r),t.d(r,{config:()=>E,default:()=>f,routeModule:()=>S});varn={};t.r(n),t.d(n,{default:()=>p});vari=t(89947),a=t(2706),o=t(96762),s=t(69842),u=t(67619),l=t(48786),c=t(45185),d=t(27825),_=t.n(d);letm=t(29021);asyncfunctionp(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=await(0,s.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});letn=e.body.mediaObject,i=e.body.newName,a=e.body.newThumbnailName,o=e.body.replace;try{"production".match(/production/);lete=n.media_url.match(/\..{3,4}$/)[0],s=n?.private==1;if(!process.env.DSQL_STATIC_SERVER_DIR)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");letu=(0,c.A)({isPrivate:s,userId:t.id,folder:n.folder?n.folder+"/":"",video:!!n.media_type?.match(/video/i)});if(!u)throwError("Couldn't grab paths!");let{fileRootPath:d,urlRootPath:p,relativePath:f}=u,E=`${d}${n.media_name}${e}`,S=`${d}${i}${e}`,h=`${d}${n.media_name}_thumbnail${e}`,y=`${d}${i}_thumbnail${e}`,g=newRegExp(_().escapeRegExp(`${n.media_name}`)),A=n.media_url.replace(g,i),$=n.media_url.replace(g,i+"_thumbnail"),v=n.media_path?n.media_path.replace(g,i):`${f}${i}`,P=n.media_thumbnail_path?n.media_thumbnail_path.replace(g,i):`${f}${a}`;if(m.existsSync(S)&&!o)returnr.json({success:!1,msg:"File already exists"});m.renameSync(E,S);try{m.renameSync(h,y)}catch(e){}await(0,l.A)("UPDATE user_media SET media_name = ?, media_url = ?, media_thumbnail_url = ?, media_path = ?, media_thumbnail_path = ? WHERE id = ?",[i,A,$,v,P,n.id]),r.json({success:!0})}catch(e){console.log("Error in renaming media =>",e.message),(0,u.default)({component:"/api/renameMedia/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Renaming failed. Please try again."})}}letf=(0,o.M)(n,"default"),E=(0,o.M)(n,"config"),S=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/renameMedia",pathname:"/api/renameMedia",bundlePath:"",filename:""},userland:n})},45185:(e,r,t)=>{t.d(r,{A:()=>s});varn=t(29021),i=t.n(n),a=t(33873),o=t.n(a);functions({isPrivate:e,userId:r,folder:t,video:n,pathOnly:a}){"production".match(/production/);lets=process.env.DSQL_STATIC_SERVER_DIR;if(!s)returnconsole.log("Static File ENV not Found!"),null;letu=e?`@/${n?"videos":"media"}/${t?t+"/":""}`:n?`/videos/user-videos/user-${r}/${t?t+"/":""}`:`/images/user-images/user-${r}/${t?t+"/":""}`,l=e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r}/media/${t?t+"/":""}`:o().join(s,u);returni().existsSync(l)||a||i().mkdirSync(l,{recursive:!0}),{fileRootPath:l,urlRootPath:e?`@/media/${t?t+"/":""}`:`${process.env.DSQL_STATIC_HOST}${u}`,relativePath:u}}},69842:(e,r,t)=>{t.d(r,{A:()=>u});varn=t(48786),i=t(95969),a=t(29021),o=t.n(a),s=t(89159);asyncfunctionu(e,r,t){try{let{keyCookieName:a,csrfCookieName:u}=(0,s.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letl=(0,i.A)({encryptedString:e.cookies[a]});if(!l)throwError("Couldn't decrypt auth cookie!");letc=JSON.parse(l);if(!c.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(c.csrf_k)))throwError("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&&!o().existsSync(`${d}/${c.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==c.verification_status&&!t){lete=await(0,n.A)(`SELECT verification_status FROM users WHE