"use strict";(()=>{var e={};e.id=964,e.ids=[964],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")},72583:e=>{e.exports=require("sanitize-html")},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}}})},48171:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>d,routeModule:()=>_});var n={};t.r(n),t.d(n,{default:()=>u});var o=t(89947),a=t(2706),i=t(96762),s=t(67619),l=t(69842),c=t(30802);async function u(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{user:t}=await (0,l.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbId:n}=e.body;try{if(!n)throw Error("No Target Database ID provided");await (0,c.A)({tableName:"user_databases",data:{remote_connected:0,remote_connection_host:"",remote_connection_key:"",remote_connection_type:"",remote_db_full_name:""},identifierColumnName:"id",identifierValue:n}),r.json({success:!0})}catch(e){console.log("Disconnect Error, =>",e.message),(0,s.A)({component:"/api/connect/verify/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Operation Failed!"})}}let d=(0,i.M)(n,"default"),p=(0,i.M)(n,"config"),_=new o.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/connect/disconnect",pathname:"/api/connect/disconnect",bundlePath:"",filename:""},userland:n})},55153:(e,r,t)=>{t.d(r,{On:()=>o.a,_n:()=>i}),t(76102);var n=t(65967),o=t.n(n);t(30889);var a=t(93726);let i=t.n(a)()},69842:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(39383),o=t.n(n),a=t(55153);async function i(e,r,t,n){let i=o()({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,a._n)(process.env.DSQL_SU_USER_ID)!==i.payload.id?{user:null,appData:s}:{user:i.payload,appData:s}}},30802:(e,r,t)=>{t.d(r,{A:()=>c});var n=t(72583),o=t.n(n),a=t(92652),i=t(68829),s=t(52939),l=t(64292);async function c({dbContext:e,dbFullName:r,tableName:t,data:n,tableSchema:c,identifierColumnName:u,identifierValue:d,encryptionKey:p,encryptionSalt:_,forceLocal:f}){if(!n||!Object.keys(n).length)return null;let S=!!f||(0,s.A)({dbContext:e,dbFullName:r}),g=S?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;S?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let m=Object.keys(n),y=[],E=[];for(let e=0;e<m.length;e++)try{let r=m[e],t=n[r],s=c?c?.fields?.filter(e=>e.fieldName===r):null,l=s&&s[0]?s[0]:null;if(null==t||void 0==t)continue;let u=/<[^>]+>/g;(l?.richText||String(t).match(u))&&(t=o()(t,a.A)),l?.encrypted&&(t=(0,i.A)({data:t,encryptionKey:p,encryptionSalt:_})),"object"==typeof t&&(t=JSON.stringify(t)),l?.pattern&&!new RegExp(l.pattern,l.patternFlags||"").test(t)&&(console.log("DSQL: Pattern not matched =>",t),t=""),"string"==typeof t&&t.match(/^null$/i)&&(t={toSqlString:function(){return"NULL"}}),"string"!=typeof t||t.match(/./i)||(t={toSqlString:function(){return"NULL"}}),y.push(`\`${r}\`=?`),"number"==typeof t?E.push(String(t)):E.push(t)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}y.push(`date_updated='${Date()}'`),y.push(`date_updated_code='${Date.now()}'`);let h=`UPDATE ${S?"":`\`${r}\`.`}\`${t}\` SET ${y.join(",")} WHERE \`${u}\`=?`;return E.push(d),await (0,l.A)(g,h,E)}},92652:(e,r,t)=>{t.d(r,{A:()=>n});let n={allowedTags:["b","i","em","strong","a","p","span","ul","ol","li","h1","h2","h3","h4","h5","h6","img","div","button","pre","code","br"],allowedAttributes:{a:["href"],img:["src","alt","width","height","class","style"],"*":["style","class"]}}},67619:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(29021),o=t.n(n);async function a({user:e,message:r,component:t,noMail:n,req:a}){let i=new Date,s=(()=>{if(!a)return null;try{let e=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],o=t||n||r||a.socket.remoteAddress;if(!o)return null;return String(o)}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}`),a?.url&&(n+=`
URL: ${a.url}`),a?.body&&(n+=`
Request Body: ${JSON.stringify(a.body,null,4)}`),s&&(n+=`
IP: ${s}`),n+=`
Date: ${i.toDateString()}
========================================`,o().existsSync("./.tmp/error.log")||o().writeFileSync("./.tmp/error.log","","utf-8");let l=o().readFileSync("./.tmp/error.log","utf-8");o().writeFileSync("./.tmp/error.log",n),o().appendFileSync("./.tmp/error.log",`




${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(55511),o=t(79428),a=t(31542);function i({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:i,salt:s,keyLen:l,algorithm:c,bufferAllocSize:u}=(0,a.A)({encryptionKey:r});if(!i?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!s?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(i,s,l),p=o.Buffer.alloc(u,0),_=(0,n.createCipheriv)(c,d,p);try{let r=_.update(e,"utf8","hex");return r+=_.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},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(o(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 a=r[n],i=await e.query(o(a.query),a.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 o(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},31542:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(82535);function o(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,n.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,r,t)=>{t.d(r,{A:()=>n});function n(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=48171);module.exports=t})();