"use strict";(()=>{var e={};e.id=9157,e.ids=[9157],e.modules={52093:(e,s,r)=>{r.a(e,async(e,t)=>{try{r.r(s),r.d(s,{config:()=>m,default:()=>u,getServerSideProps:()=>p,getStaticPaths:()=>h,getStaticProps:()=>x,reportWebVitals:()=>g,routeModule:()=>y,unstable_getServerProps:()=>S,unstable_getServerSideProps:()=>b,unstable_getStaticParams:()=>v,unstable_getStaticPaths:()=>f,unstable_getStaticProps:()=>j});var a=r(63865),n=r(9455),l=r(30671),i=r(49407),c=r(89600),o=r(64232),d=e([o]);o=(d.then?(await d)():d)[0];let u=(0,l.M)(o,"default"),x=(0,l.M)(o,"getStaticProps"),h=(0,l.M)(o,"getStaticPaths"),p=(0,l.M)(o,"getServerSideProps"),m=(0,l.M)(o,"config"),g=(0,l.M)(o,"reportWebVitals"),j=(0,l.M)(o,"unstable_getStaticProps"),f=(0,l.M)(o,"unstable_getStaticPaths"),v=(0,l.M)(o,"unstable_getStaticParams"),S=(0,l.M)(o,"unstable_getServerProps"),b=(0,l.M)(o,"unstable_getServerSideProps"),y=new a.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su/load-balancing",pathname:"/su/load-balancing",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:o});t()}catch(e){t(e)}})},94010:(e,s,r)=>{r.a(e,async(e,t)=>{try{r.d(s,{A:()=>c});var a=r(8732);r(82015);var n=r(96089),l=r(75979),i=e([l]);function c({slugText:e,justIcon:s,noIcon:r,title:t,outlined:i,extraClasses:c}){return(0,a.jsxs)("div",{className:(0,l.twMerge)("button small-text hover:!bg-transparent",i?" outlined gray bg-white":" ghost light-gray",c),onClick:s=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:i?void 0:{padding:0},children:[!r&&(0,a.jsx)(n.A,{size:i?15:20}),!s&&(0,a.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:t||"Copy Slug"})]})}l=(i.then?(await i)():i)[0],t()}catch(e){t(e)}})},36299:(e,s,r)=>{r.d(s,{A:()=>o});var t=r(8732),a=r(82015),n=r.n(a),l=r(63715),i=r(32415),c=r(21498);function o({data:e}){Object.keys(e.users[0]);let[s,r]=n().useState(null),[a,o]=n().useState(0),[d,u]=n().useState(!1);return console.log(typeof s),(0,t.jsx)(n().Fragment,{children:(0,t.jsxs)("div",{className:"items-stretch gap-10 w-full",children:[(0,t.jsxs)("section",{className:"paper w-full",children:[(0,t.jsx)("h2",{className:"text-xl m-0 mb-6",children:"Users"}),(0,t.jsx)("div",{className:"flex-col items-stretch gap-10",children:e.users.map((e,s)=>(0,t.jsx)(c.A,{userObject:e},s+1))})]}),(0,t.jsxs)("section",{className:"paper",children:[(0,t.jsxs)("div",{className:"w-full justify-between",children:[(0,t.jsx)("h2",{className:"text-xl m-0",children:"Error Logs"}),(0,t.jsx)("div",{children:(0,t.jsxs)("button",{onClick:e=>{window.confirm("Clear Error Logs?")&&(u(!0),(0,l.A)("/api/admin/clearErrorLogs","post").then(e=>{o(e=>e+1)}),setTimeout(()=>{u(!1)},2e3))},className:"outlined gray relative",children:[d&&(0,t.jsx)(i.A,{width:"20px"}),"Clear Error Log"]})})]}),s&&(0,t.jsx)("p",{dangerouslySetInnerHTML:{__html:s||"No Log"}}),"string"!=typeof s&&(0,t.jsx)(i.A,{position:"relative",width:"25px"})]})]})})}},19262:(e,s,r)=>{r.d(s,{A:()=>c});var t=r(8732),a=r(82015),n=r.n(a),l=r(63715),i=r(32415);function c(e){let[s,r]=n().useState(null),[a,c]=n().useState(!1),[o,d]=n().useState(0);return(0,t.jsxs)(n().Fragment,{children:[(0,t.jsxs)("div",{className:"w-full justify-between",children:[(0,t.jsx)("h2",{className:"text-xl m-0",children:"Error Logs"}),(0,t.jsx)("div",{children:(0,t.jsxs)("button",{onClick:e=>{window.confirm("Clear Error Logs?")&&(c(!0),(0,l.A)("/api/admin/clearErrorLogs","post").then(e=>{console.log(e),d(e=>e+1)}),setTimeout(()=>{c(!1)},2e3))},className:"outlined gray relative",children:[a&&(0,t.jsx)(i.A,{width:"20px"}),"Clear Error Log"]})})]}),(0,t.jsxs)("section",{className:"paper",children:[s&&(0,t.jsx)("p",{dangerouslySetInnerHTML:{__html:s||"No Log"}}),!s&&(0,t.jsx)(i.A,{position:"relative",width:"25px"})]})]})}},21498:(e,s,r)=>{r.d(s,{A:()=>l});var t=r(8732),a=r(82015),n=r.n(a);function l({userObject:e,userPage:s}){let r=Object.keys(e),[a,l]=n().useState(!1),[i,c]=n().useState(0),[o,d]=n().useState(!s);return(0,t.jsxs)("div",{className:"card col green w-full overflow-hidden"+(o?s?" h-[100px]":" h-[85px]":" "),children:[(0,t.jsxs)("div",{className:"items-center w-full",children:[(0,t.jsx)("img",{src:e.image_thumbnail,alt:"",className:"rounded-full object-cover"+(s?" w-16 h-16":" w-12 h-12")}),!s&&(0,t.jsxs)("h3",{className:"m-0 text-xl",children:[e.first_name," ",e.last_name," "]}),(0,t.jsxs)("div",{className:"ml-auto",children:[(0,t.jsx)("button",{className:"outlined gray small-text",onClick:e=>{o?d(!1):d(!0)},children:o?"More Details":"Collapse"}),!s&&(0,t.jsx)("a",{href:`/su/users/${e.id}`,className:"button outlined gray small-text",children:"View User"})]})]}),(0,t.jsx)("div",{className:"card no-hover col w-full light-gray-bg",children:r.map((s,a)=>(0,t.jsxs)(n().Fragment,{children:[(0,t.jsx)("div",{children:(0,t.jsxs)("span",{style:{wordBreak:"break-all"},children:[s,":"," ",(0,t.jsx)("b",{children:e[s]})]})}),a{d(!0)},children:"Collapse"})]})}},77306:(e,s,r)=>{r.a(e,async(e,t)=>{try{r.d(s,{A:()=>o});var a=r(8732),n=r(94010),l=r(2459),i=r(75979),c=e([n,i]);function o({server:e,noLoadBalance:s}){return(0,a.jsxs)("div",{className:"stack w-full",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l.A,{size:15,opacity:.5}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:e.host}),s?(0,a.jsx)(a.Fragment,{}):e.loadBalanced?(0,a.jsx)("span",{className:"info green small",children:"Load Balanced"}):(0,a.jsx)("button",{children:"Add to Load Balancer"})]})]}),(0,a.jsx)("div",{className:(0,i.twMerge)("stack border-0 border-l border-solid border-s-slate-200 dark:border-white/20","pl-6 ml-2 -mt-4 pt-2 w-full gap-0"),children:(0,a.jsx)("ul",{className:"p-0 m-0 pl-4",children:e.users?.map((e,s)=>a.jsx(d,{user:e},s))})})]})}function d({user:e}){return(0,a.jsx)("li",{className:(0,i.twMerge)("w-full"),children:(0,a.jsxs)("div",{className:"stack gap-0",children:[(0,a.jsxs)("span",{children:["user: ",(0,a.jsx)("b",{children:e.name})]}),(0,a.jsxs)("span",{children:["pass:"," ",(0,a.jsx)("b",{children:(0,a.jsx)(n.A,{slugText:e.password,title:"********",extraClasses:"inline",noIcon:!0})})]})]})})}[n,i]=c.then?(await c)():c,t()}catch(e){t(e)}})},72179:(e,s,r)=>{r.a(e,async(e,t)=>{try{r.d(s,{A:()=>d});var a=r(8732),n=r(89600),l=r(82015),i=r.n(l),c=r(77306),o=e([c]);function d(){let e=i().useContext(n.AppContext).pageProps;e.user;let s=e.servers;return(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-2",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"Load Balancing"}),(0,a.jsx)("span",{children:"Distribute database load accross servers"})]}),(0,a.jsx)("div",{})]}),(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h2",{className:"text-base m-0",children:"Servers"}),(0,a.jsx)("div",{className:"flex flex-col gap-2 w-full",children:s.map((e,s)=>(0,a.jsx)(c.A,{server:e},s))})]})]})}c=(o.then?(await o)():o)[0],t()}catch(e){t(e)}})},92127:(e,s,r)=>{r(33873);let t=r(29021);r(56248);let a=r(70956);e.exports=function(){try{let e=a();if(!t.existsSync(e.path)){let s={host:String(process.env.DSQL_DB_TARGET_IP_ADDRESS),port:3306,primary:!0,loadBalanced:!0,users:[{host:String(process.env.DSQL_DB_HOST),name:"root",password:process.env.DSQL_MARIADB_ROOT_PASSWORD||"password"}]};t.writeFileSync(e.path,JSON.stringify([s]))}return!0}catch(e){return console.log(`Error checking servers ${e.message}`),!1}}},70956:(e,s,r)=>{let t=r(33873);e.exports=function(){let e=process.env.DSQL_SU_USER_ID||"1",s=t.resolve(process.cwd(),`./jsonData/dbSchemas/users/user-${e}`),r=`${s}/servers.json`;return{dir:s,path:r}}},31511:(e,s,r)=>{r(33873);let t=r(29021),a=r(56248),n=r(92127),l=r(70956);e.exports=function(){try{n();let e=l();return a.parse(t.readFileSync(e.path,"utf-8"))}catch(e){console.log(`Error getting servers ${e.message}`);return}}},96089:(e,s,r)=>{r.d(s,{A:()=>t});let t=(0,r(82544).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},56248:e=>{e.exports={parse:function(e,s){if(e){if("object"==typeof e)return e;if("string"==typeof e)try{return JSON.parse(e,s)}catch(e){return}}},stringify:function(e,s,r){try{return JSON.stringify(e,s,r)}catch(e){return}}}},64232:(e,s,r)=>{r.a(e,async(e,t)=>{try{r.r(s),r.d(s,{default:()=>x,getServerSideProps:()=>h});var a=r(8732);r(82015);var n=r(93615),l=r.n(n),i=r(49888);r(36299),r(19262);var c=r(72179),o=r(31511),d=r.n(o),u=e([c]);function x({user:e,data:s}){let r=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"Load Balancing"}),(0,a.jsx)("meta",{name:"description",content:"Distribute db load accross servers"})]});return(0,a.jsx)(i.A,{head:r,user:e,children:(0,a.jsx)(c.A,{})})}async function h({req:e,res:s,query:r}){try{let s=await l()(e);if(!s?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let r=d()();if(!r)throw Error("No servers found");return{props:{user:s,servers:r}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}c=(u.then?(await u)():u)[0],t()}catch(e){t(e)}})},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},75979:e=>{e.exports=import("tailwind-merge")}};var s=require("../../webpack-runtime.js");s.C(e);var r=e=>s(s.s=e),t=s.X(0,[883,9821,9600,3932],()=>r(52093));module.exports=t})();