"use strict";(()=>{var e={};e.id=8105,e.ids=[8105],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},5134:(e,r,t)=>{t.r(r),t.d(r,{config:()=>g,default:()=>f,routeModule:()=>E});var n={};t.r(n),t.d(n,{default:()=>m});var a=t(89947),o=t(2706),i=t(96762),s=t(29021),l=t.n(s),u=t(33873),d=t.n(u),c=t(67619),_=t(69842),S=t(45185),p=t(61932);async function m(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{user:t}=await (0,_.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let n=e.body,{media_name:a,media_url:o,media_thumbnail_url:i,media_path:s,media_thumbnail_path:u,folder:m}=n;"production".match(/production/);try{let e=n?.private==1;if(!process.env.DSQL_STATIC_SERVER_DIR)throw console.log("Static File ENV not Found!"),Error("No Static Path!");let a=(0,S.A)({isPrivate:e,userId:t.id,folder:n.folder?n.folder+"/":"",video:!!n.media_type?.match(/video/i)});if(!a)throw Error("Couldn't grab paths!");let{fileRootPath:s,urlRootPath:u,relativePath:c}=a;m?.match(/./);let _=o.match(/[^\/]+$/)[0],f=i.match(/[^\/]+$/)[0],g=d().normalize(s+_),E=d().normalize(s+f);l().unlinkSync(g);try{l().unlinkSync(E)}catch(e){}await (0,p.A)({dbFullName:"datasquirel",tableName:"user_media",identifierColumnName:"id",identifierValue:n.id}),r.json({success:!0})}catch(e){console.log("ERROR in deleting user media =>",e.message),(0,c.A)({component:"/api/deleteUserMedia/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}let f=(0,i.M)(n,"default"),g=(0,i.M)(n,"config"),E=new a.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/deleteUserMedia",pathname:"/api/deleteUserMedia",bundlePath:"",filename:""},userland:n})},55153:(e,r,t)=>{t.d(r,{On:()=>a.a,_n:()=>i}),t(76102);var n=t(65967),a=t.n(n);t(30889);var o=t(93726);let i=t.n(o)()},45185:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(29021),a=t.n(n),o=t(33873),i=t.n(o);function s({isPrivate:e,userId:r,folder:t,video:n,pathOnly:o}){"production".match(/production/);let s=process.env.DSQL_STATIC_SERVER_DIR;if(!s)return console.log("Static File ENV not Found!"),null;let l=e?`@/${n?"videos":"media"}/${t?t+"/":""}`:n?`/videos/user-videos/user-${r}/${t?t+"/":""}`:`/images/user-images/user-${r}/${t?t+"/":""}`,u=e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r}/media/${t?t+"/":""}`:i().join(s,l);return a().existsSync(u)||o||a().mkdirSync(u,{recursive:!0}),{fileRootPath:u,urlRootPath:e?`@/media/${t?t+"/":""}`:`${process.env.DSQL_STATIC_HOST}${l}`,relativePath:l}}},69842:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(39383),a=t.n(n),o=t(55153);async function i(e,r,t,n){let i=a()({req:e,level:t?"deep":void 0}),s={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return n&&i.payload?.id&&(0,o._n)(process.env.DSQL_SU_USER_ID)!==i.payload.id?{user:null,appData:s}:{user:i.payload,appData:s}}},61932:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(52939),a=t(64292);async function o({dbContext:e,dbFullName:r,tableName:t,identifierColumnName:o,identifierValue:i,forceLocal:s}){try{let l=!!s||(0,n.A)({dbContext:e,dbFullName:r}),u=l?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;l?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let d=`DELETE FROM ${l?"":`\`${r}\`.`}\`${t}\` WHERE \`${o}\`=?`;return await (0,a.A)(u,d,[i])}catch(e){return null}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(29021),a=t.n(n);async function o({user:e,message:r,component:t,noMail:n,req:o}){let i=new Date,s=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||n||r||o.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(n+=`
URL: ${o.url}`),o?.body&&(n+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),s&&(n+=`
IP: ${s}`),n+=`
Date: ${i.toDateString()}
========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let l=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",n),a().appendFileSync("./.tmp/error.log",`




${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},52939:(e,r,t)=>{t.d(r,{A:()=>n});function n({dbContext:e,dbFullName:r}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!r||!!r.match(/^datasquirel$/))}},64292:(e,r,t)=>{async function n(e,r,t){try{if(!e)throw Error("No Connection Found!");if(!r)throw Error("Query String Required!");if("string"==typeof r){let n=await e.query(a(r),t);return JSON.parse(JSON.stringify(n))}if("object"!=typeof r)return null;{let t=[];for(let n=0;n<r.length;n++)try{let o=r[n],i=await e.query(a(o.query),o.values);t.push(JSON.parse(JSON.stringify(i)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),t.push(null)}return t}}catch(r){return console.log(`connDbHandler Error: ${r.message}`),console.log(e?.config()),null}finally{e?.end()}}function a(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=5134);module.exports=t})();