"use strict";(()=>{var e={};e.id=979,e.ids=[979],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},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")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},27973:(e,a,r)=>{r.r(a),r.d(a,{config:()=>S,default:()=>v,routeModule:()=>y});var i={};r.r(i),r.d(i,{config:()=>h,default:()=>g});var t=r(89947),l=r(2706),s=r(96762),n=r(29021),o=r.n(n),u=r(33873),d=r.n(u),m=r(98e3),c=r(96551),p=r(45185),_=r(67619),f=r(69842);let h={api:{responseLimit:"1mb",bodyParser:{sizeLimit:"200mb"}}};async function g(e,a){if("POST"!==e.method)return a.json({msg:"Failed!"});let r=await (0,f.A)(e,a,!0);if(!r)return a.json({success:!1,msg:"Unauthorized"});let i=e.body,{media:t}=i,l=i.folder,s=i.type;"production".match(/production/);let n=process.env.DSQL_STATIC_SERVER_DIR;if(!n)return console.log("Static File ENV not Found!"),a.json({success:!1,msg:"No Static File Path"});if(l){let e=d().join(n,`images/user-images/user-${r.id}/${l}`);o().existsSync(e)||o().mkdirSync(e,{recursive:!0});let a=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r.id}/media/${l}`;o().existsSync(a)||o().mkdirSync(a,{recursive:!0})}try{let e=[];for(let a=0;a{r.d(a,{A:()=>n});var i=r(9288),t=r.n(i),l=r(67619),s=r(45185);async function n({imageSourceBase64:e,imageName:a,userId:r,mimeType:i,thumbnailSize:n,folder:o,isPrivate:u}){try{let l=Buffer.from(e,"base64"),d=n?parseInt(n.toString()):400,m=t()(l),c=t()(l),p=(0,s.A)({isPrivate:u,userId:r,folder:o});if(!p)return null;let{fileRootPath:_,urlRootPath:f,relativePath:h}=p,{width:g,height:v,format:S}=await m.metadata(),y=i||S;g&&v&&g>1800&&m.resize(1800,Math.round(1800/g*v),{fit:"cover"}),m.toFormat(y,{quality:80}),await m.metadata();let b=`${a}.${y}`;if(await m.toFile(_+b),g&&v&&g>d){let e=d/g;c.resize(d,Math.round(v*e),{fit:"cover"})}else g&&v&&c.resize(150,Math.round(150/g*v),{fit:"cover"});c.toFormat(y,{quality:80});let $=`${a}_thumbnail.${y}`;return await c.toFile(_+$),{urlPath:f+b,urlThumbnailPath:f+$,urlRelativePath:h+b,urlThumbnailRelativePath:h+$}}catch(e){return console.log("Write Image to Disk error =>",e.message),(0,l.A)({component:"functions/backend/fsWriteImageToDiskFromBase64",message:e.message}),null}}},45185:(e,a,r)=>{r.d(a,{A:()=>n});var i=r(29021),t=r.n(i),l=r(33873),s=r.n(l);function n({isPrivate:e,userId:a,folder:r,video:i,pathOnly:l}){"production".match(/production/);let n=process.env.DSQL_STATIC_SERVER_DIR;if(!n)return console.log("Static File ENV not Found!"),null;let o=e?`@/${i?"videos":"media"}/${r?r+"/":""}`:i?`/videos/user-videos/user-${a}/${r?r+"/":""}`:`/images/user-images/user-${a}/${r?r+"/":""}`,u=e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${a}/media/${r?r+"/":""}`:s().join(n,o);return t().existsSync(u)||l||t().mkdirSync(u,{recursive:!0}),{fileRootPath:u,urlRootPath:e?`@/media/${r?r+"/":""}`:`${process.env.DSQL_STATIC_HOST}${o}`,relativePath:o}}},69842:(e,a,r)=>{r.d(a,{A:()=>l});var i=r(39908),t=r.n(i);async function l(e,a,r){let i=t()({req:e,level:r?"deep":void 0});return console.log(i),i.payload}},67619:(e,a,r)=>{r.d(a,{A:()=>l});var i=r(29021),t=r.n(i);async function l({user:e,message:a,component:r,noMail:i,req:l}){let s=new Date,n=(()=>{if(!l)return null;try{let e=l.headers["x-forwarded-for"],a=l.headers["x-real-ip"],r=l.headers["cf-connecting-ip"],i=Array.isArray(e)?e[0]:e?.split(",")[0],t=r||i||a||l.socket.remoteAddress;if(!t)return null;return String(t)}catch(e){return null}})();try{let i=`🚀 SERVER ERROR =========================== Error Message: ${a} Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(i+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),l?.url&&(i+=` URL: ${l.url}`),l?.body&&(i+=` Request Body: ${JSON.stringify(l.body,null,4)}`),n&&(i+=` IP: ${n}`),i+=` Date: ${s.toDateString()} ========================================`,t().existsSync("./.tmp/error.log")||t().writeFileSync("./.tmp/error.log","","utf-8");let o=t().readFileSync("./.tmp/error.log","utf-8");t().writeFileSync("./.tmp/error.log",i),t().appendFileSync("./.tmp/error.log",` ${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}}};var a=require("../../webpack-api-runtime.js");a.C(e);var r=e=>a(a.s=e),i=a.X(0,[1251],()=>r(27973));module.exports=i})();