"use strict";(()=>{var e={};e.id=3033,e.ids=[3033],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")},55591:e=>{e.exports=require("https")},79551:e=>{e.exports=require("url")},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}}})},77666:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>p,routeModule:()=>S});var s={};t.r(s),t.d(s,{default:()=>d});var n=t(89947),o=t(2706),a=t(96762),i=t(79551),l=t(64166),u=t(67619),c=t(69842);async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{user:t}=await (0,c.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{url:s,key:n,database:o,dbSchema:a,type:d}=e.body;try{let{hostname:e,port:t,protocol:o}=new i.URL(s),a=await (0,l.A)({scheme:o,headers:{Authorization:n},hostname:e,port:t,path:"/api/connect",method:"POST",body:{url:s,key:n}}),u=JSON.parse(a);if(!u?.success)throw Error(u.msg||"Remote request failed");r.json({success:!0,payload:u.payload})}catch(e){console.log("Connect Verification Initialtor Error, =>",e.message),(0,u.A)({component:"/api/connect/verify/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Operation Failed!"})}}let p=(0,a.M)(s,"default"),m=(0,a.M)(s,"config"),S=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/connect/verify",pathname:"/api/connect/verify",bundlePath:"",filename:""},userland:s})},55153:(e,r,t)=>{t.d(r,{On:()=>n.a,_n:()=>a}),t(76102);var s=t(65967),n=t.n(s);t(30889);var o=t(93726);let a=t.n(o)()},69842:(e,r,t)=>{t.d(r,{A:()=>a});var s=t(39383),n=t.n(s),o=t(55153);async function a(e,r,t,s){let a=n()({req:e,level:t?"deep":void 0}),i={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 s&&a.payload?.id&&(0,o._n)(process.env.DSQL_SU_USER_ID)!==a.payload.id?{user:null,appData:i}:{user:a.payload,appData:i}}},64166:(e,r,t)=>{t.d(r,{A:()=>l});var s=t(55591),n=t.n(s);let o=require("http");var a=t.n(o),i=t(79551);function l({url:e,method:r,hostname:t,path:s,headers:o,body:l,port:u,scheme:c}){let d=l?JSON.stringify(l):null,p=e?new i.URL(e):null,m={method:r||"GET",hostname:p?p.hostname:t,port:c?.match(/https/i)?443:p?p.protocol?.match(/https/i)?443:p.port:u?Number(u):80,headers:{}};return s&&(m.path=s),o&&(m.headers=o),l&&(m.headers["Content-Type"]="application/json",m.headers["Content-Length"]=d?Buffer.from(d).length:void 0),new Promise((e,r)=>{let t=(c?.match(/https/i)?n():p?.protocol?.match(/https/i)?n():a()).request(m,t=>{var s="";t.on("data",function(e){s+=e}),t.on("end",function(){e(s)}),t.on("error",e=>{console.log("HTTP response error =>",e.message),r(`HTTP response error =>, ${e.message}`)}),t.on("close",()=>{console.log("HTTP(S) Response Closed Successfully")})});l&&t.write(d),t.on("error",e=>{console.log("HTTPS request ERROR =>",e.message),r(`HTTP request error =>, ${e.message}`)}),t.end()})}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(29021),n=t.n(s);async function o({user:e,message:r,component:t,noMail:s,req:o}){let a=new Date,i=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||o.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(s+=`
URL: ${o.url}`),o?.body&&(s+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),i&&(s+=`
IP: ${i}`),s+=`
Date: ${a.toDateString()}
========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let l=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",s),n().appendFileSync("./.tmp/error.log",`




${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},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=77666);module.exports=t})();