"use strict";(()=>{vare={};e.id=979,e.ids=[979],e.modules={27825:e=>{e.exports=require("lodash")},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")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},93851:(e,r,t)=>{t.r(r),t.d(r,{config:()=>$,default:()=>b,routeModule:()=>N});vara={};t.r(a),t.d(a,{config:()=>y,default:()=>E});vari=t(89947),s=t(2706),l=t(96762),n=t(47670),o=t.n(n),u=t(10701),d=t.n(u),c=t(48227),m=t.n(c),p=t(48225),_=t.n(p),f=t(6420),h=t.n(f);letg=t(29021),S=t(33873),{execSync:v}=t(79646),y={api:{responseLimit:"1mb",bodyParser:{sizeLimit:"200mb"}}};asyncfunctionE(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaith()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});leta=e.body,{media:i}=a;console.log(a.type);lets=a.folder,l=a.type;"production".match(/production/);letn=process.env.DSQL_STATIC_SERVER_DIR;if(!n)returnconsole.log("Static File ENV not Found!"),r.json({success:!1,msg:"No Static File Path"});if(s){lete=S.join(n,`images/user-images/user-${t.id}/${s}`);g.existsSync(e)||g.mkdirSync(e,{recursive:!0});letr=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/media/${s}`;g.existsSync(r)||g.mkdirSync(r,{recursive:!0})}try{lete=[];for(letr=0;r<i.length;r++){leta=i[r];if(l?.match(/image/i)){let{imageBase64:r,imageName:i,imageSize:l,mimeType:n}=a,u=awaitd()({imageName:i.replace(/ /g,"-"),imageSourceBase64:r,user:t,folder:s,mimeType:n,isPrivate:a.private});if(!u){console.log("Image Write Failed!");continue}let{urlPath:c,urlThumbnailPath:m,urlRelativePath:p,urlThumbnailRelativePath:_}=u;awaito()({dbFullName:"datasquirel",tableName:"user_media",data:{user_id:t.id,media_name:i.replace(/ /g,"-"),media_url:c,media_type:"image",media_thumbnail_url:m,media_path:p,media_thumbnail_path:_,folder:s,private:a.private?1:0},duplicateColumnName:"media_url",duplicateColumnValue:c}),e.push({media_name:i.replace(/ /g,"-"),media_url:c,media_thumbnail_url:m})}elseif(l?.match(/file/i)){let{fileBase64:r,fileSize:i,fileType:l}=a,n=a.fileName.replace(/ /g,"-").replace(/\./g,""),u=m()({isPrivate:a.private,user:t,folder:s});if(!u)continue;let{fileRootPath:d,urlRootPath:c,relativePath:p}=u,_=l?.match(/pdf/)?".pdf":l?.match(/xlsx/)?".xlsx":l?.match(/csv/)?".csv":l?.match(/json/)?".json":null;if(!_)continue;letf=d+n+_,h=c+n+_,S=p+n+_;g.writeFileSync(f,r,"base64"),awaito()({dbFullName:"datasquirel",tableName:"user_media",data:{user_id:t.id,media_name:n,media_url:h,media_thumbnail_url:h,media_path:S,media_thumbnail_path:S,media_type:"file/"+_.replace(/\./,""),folder:s,private:a.private?1:0},duplicateColumnName:"media_url",duplicateColumnValue:h}),e.push({media_name:n,media_url:h,media_thumbnail_url:h})}elseif(l?.match(/video/i)){let{fileBase64:r,fileSize:i,fileType:l}=a,n=a.fileName.replace(/ /g,"-").replace(/\./g,""),u=m()({isPrivate:a.private,user:t,folder:s,video:!0});if(!u)continue;let{fileRootPath:d,urlRootPath:c,relativePath:p}=u,_=l?.match(/mp4/)?".mp4":null;if(!_)continue;letf=d+n+_,h=c+n+_,S=p+n+_;g.writeFileSync(f,r,"base64"),awaito()({dbFullName:"datasquirel",tableName:"user_media",data:{user_id:t.id,media_name:n,media_url:h,media_thumbnail_url:h,media_path:S,media_thumbnail_path:S,media_type:"video/"+_.replace(/\./,""),folder:s,private:a.private?1:0},duplicateColumnName:"media_url",duplicateColumnValue:h}),e.push({media_name:n,media_url:h,media_thumbnail_url:h})}}r.json({success:!0,mediaData:e})}catch(e){console.log(`Add User Media Error: ${e.message}`),_()({component:"/api/addUserMedia/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}letb=(0,l.M)(a,"default"),$=(0,l.M)(a,"config"),N=newi.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/addUserMedia",pathna