"use strict";(()=>{var e={};e.id=8932,e.ids=[8932],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")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},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}}})},36629:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>_,routeModule:()=>p});var a={};t.r(a),t.d(a,{default:()=>d});var s=t(89947),o=t(2706),n=t(96762),l=t(69842),i=t(67619),c=t(60125),u=t(30944);async function d(e,r){if("POST"!==e.method)return r.json({user:null,msg:"Registration Failed!"});let{user:t,appData:a}=await (0,l.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let s=e.body;try{let a=await (0,c.A)({databaseSlug:s.dbName,request:e,user:t,query:e.query}),o=a?a?.rootUserId?a.rootUserId:a.dbUserId:null;if(!o)throw Error("User not Found!");let n=`datasquirel_user_${o}_${s.dbName}`,l=s.tableName,i=s.page,d=20*i,_=`SELECT * FROM ${n}.${l}`,S=[];s.search&&s.searchField&&(_+=` WHERE LOWER(\`${s.searchField.toLowerCase().replace(/ /g,"_")}\`) LIKE ?`,S.push(`%${s.search.toLowerCase()}%`)),_+=` ORDER BY id DESC LIMIT 20 OFFSET ${d}`;let p=await (0,u.A)({database:n,queryString:_,queryValuesArray:S,tableSchema:s.tableSchema}),D={success:!0,data:p,page:Number(i)+1};r.json(D)}catch(e){(0,i.A)({component:"/api/infiniteScroll/catch-error",message:e.message,user:t}),r.json({success:!1,data:null})}}let _=(0,n.M)(a,"default"),S=(0,n.M)(a,"config"),p=new s.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/infiniteScroll",pathname:"/api/infiniteScroll",bundlePath:"",filename:""},userland:a})},55153:(e,r,t)=>{t.d(r,{On:()=>s.a,_n:()=>n}),t(76102);var a=t(65967),s=t.n(a);t(30889);var o=t(93726);let n=t.n(o)()},60125:(e,r,t)=>{t.d(r,{A:()=>s});var a=t(95969);async function s({request:e,databaseSlug:r,user:t,query:s}){try{let o=t.id,n=null;if(!s?.delegated)return{dbUserId:o};let l=s.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${l}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[c])throw Error("Cookie not present");let t=(0,a.A)({encryptedString:e.cookies[c]});if(!t)throw Error("Invalid Token");if((n=JSON.parse(t)).databaseSlug===r)return{dbUserId:o=n.rootUserId,rootUserId:n.rootUserId,rootUserName:n.rootUserName,rootUserEmail:n.rootUserEmail,rootUserImage:n.rootUserImage,databaseFullName:n.databaseFullName,databaseSlug:n.databaseSlug,allowedTables:n.allowedTables,priviledges:n.priviledges,database:n.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:o}}catch(e){return null}}},69842:(e,r,t)=>{t.d(r,{A:()=>n});var a=t(39383),s=t.n(a),o=t(55153);async function n(e,r,t,a){let n=s()({req:e,level:t?"deep":void 0}),l={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 a&&n.payload?.id&&(0,o._n)(process.env.DSQL_SU_USER_ID)!==n.payload.id?{user:null,appData:l}:{user:n.payload,appData:l}}},43775:(e,r,t)=>{t.d(r,{A:()=>o});var a=t(95969);let s=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function o({unparsedResults:e,tableSchema:r}){let t=[];try{for(let o=0;o<e.length;o++){let n=e[o],l=Object.keys(n);for(let e=0;e<l.length;e++){let t=l[e],o=r?.fields[e];if(t?.match(s))continue;let i=n[t];("number"==typeof i||i)&&o?.encrypted&&i?.match(/./)&&(n[t]=(0,a.A)({encryptedString:i}))}t.push(n)}return t}catch(r){return console.log("ERROR in parseDbResults Function =>",r.message),e}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var a=t(29021),s=t.n(a);async function o({user:e,message:r,component:t,noMail:a,req:o}){let n=new Date,l=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],a=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||a||r||o.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let a=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(a+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(a+=`
URL: ${o.url}`),o?.body&&(a+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),l&&(a+=`
IP: ${l}`),a+=`
Date: ${n.toDateString()}
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let i=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",a),s().appendFileSync("./.tmp/error.log",`




${i}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,r,t)=>{t.d(r,{A:()=>l});var a=t(43775),s=t(67619),o=t(7447),n=t(64292);async function l({queryString:e,queryValuesArray:r,database:t,tableSchema:l,debug:i}){let c=(0,o.A)({fa:!0});global.DSQL_USE_LOCAL&&(c=(0,o.A)({local:!0})),t?.match(/^datasquirel$/)&&(c=(0,o.A)()),i&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",r),console.log("varDatabaseDbHandler:CONNECTION:",c.getConfig()));let u=await (0,n.A)(c,e,r);if(i&&console.log("varDatabaseDbHandler:results:",u),u&&l)try{return await (0,a.A)({unparsedResults:u,tableSchema:l})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),global.ERROR_CALLBACK?.("VarDb Handler Error",e),(0,s.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(u)return u;else return null}},95969:(e,r,t)=>{t.d(r,{A:()=>n});var a=t(55511),s=t(79428),o=t(31542);function n({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:n,salt:l,keyLen:i,algorithm:c,bufferAllocSize:u}=(0,o.A)({encryptionKey:r});if(!n?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=(0,a.scryptSync)(n,l,i),_=s.Buffer.alloc(u,0),S=(0,a.createDecipheriv)(c,d,_);try{let r=S.update(e,"hex","utf8");return r+=S.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),global.ERROR_CALLBACK?.("Error Decrypting data",r),e}}},64292:(e,r,t)=>{async function a(e,r,t){try{if(!e)throw Error("No Connection Found!");if(!r)throw Error("Query String Required!");if("string"==typeof r){let a=await e.query(s(r),t);return JSON.parse(JSON.stringify(a))}if("object"!=typeof r)return null;{let t=[];for(let a=0;a<r.length;a++)try{let o=r[a],n=await e.query(s(o.query),o.values);t.push(JSON.parse(JSON.stringify(n)))}catch(e){global.ERROR_CALLBACK?.("Connection DB Handler Query Error",e),t.push(null)}return t}}catch(e){return global.ERROR_CALLBACK?.("Connection DB Handler Error",e),null}finally{e?.end()}}function s(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>a})},7447:(e,r,t)=>{t.d(r,{A:()=>o});var a=t(9973),s=t.n(a);function o(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.DSQL_READ_ONLY_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},31542:(e,r,t)=>{t.d(r,{A:()=>s});var a=t(82535);function s(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?(0,a.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,r,t)=>{t.d(r,{A:()=>a});function a(e,r){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;if(r)return Number(t.toFixed(r));return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},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=36629);module.exports=t})();