"use strict";(()=>{var e={};e.id=3632,e.ids=[3632],e.modules={17981:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.r(t),s.d(t,{config:()=>p,default:()=>u,getServerSideProps:()=>x,getStaticPaths:()=>m,getStaticProps:()=>h,reportWebVitals:()=>f,routeModule:()=>b,unstable_getServerProps:()=>v,unstable_getServerSideProps:()=>w,unstable_getStaticParams:()=>y,unstable_getStaticPaths:()=>g,unstable_getStaticProps:()=>j});var r=s(63865),l=s(9455),i=s(30671),n=s(5583),c=s(19796),o=s(24747),d=e([o]);o=(d.then?(await d)():d)[0];let u=(0,i.M)(o,"default"),h=(0,i.M)(o,"getStaticProps"),m=(0,i.M)(o,"getStaticPaths"),x=(0,i.M)(o,"getServerSideProps"),p=(0,i.M)(o,"config"),f=(0,i.M)(o,"reportWebVitals"),j=(0,i.M)(o,"unstable_getStaticProps"),g=(0,i.M)(o,"unstable_getStaticPaths"),y=(0,i.M)(o,"unstable_getStaticParams"),v=(0,i.M)(o,"unstable_getServerProps"),w=(0,i.M)(o,"unstable_getServerSideProps"),b=new r.PagesRouteModule({definition:{kind:l.A.PAGES,page:"/su/users/[single]",pathname:"/su/users/[single]",bundlePath:"",filename:""},components:{App:c.default,Document:n.default},userland:o});a()}catch(e){a(e)}})},6789:(e,t,s)=>{s.d(t,{A:()=>a});function a({editorHTMLElementRef:e,fieldObject:t,setRefresh:s,language:a="javascript",entry:r,jsonTextEditors:l,editorRef:i,readOnly:n,initialContent:c,options:o}){try{if(!ace?.edit||!e.current){console.log("Ace Editor not found!"),setTimeout(()=>{s?.(e=>e+1)},1e3);return}let d=ace.edit(e.current);d.setOptions({mode:"ace/mode/"+a,value:c||(t?.defaultValue?t.defaultValue:t?.fieldName&&r?.[t.fieldName]?(()=>{if("json"!==a)return r[t.fieldName];try{return JSON.stringify(JSON.parse(r[t.fieldName]),null,4)}catch(e){return r[t.fieldName]}})():""),placeholder:"json"==a?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:n,...o}),i&&t?.fieldName&&(l?.current.push({fieldName:t.fieldName,ref:i}),i.current=d);try{ace.require("ace/ext/beautify").beautify(d.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}},80830:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(8732),r=s(58526);function l({selectOptions:e,name:t,onChangeHandler:s,required:l,setAlert:i,title:n,defaultValue:c,info:o,id:d}){try{function u(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),s=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!s.classList.contains("hidden")){s.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&s.classList.contains("hidden"))){if(!t){s.classList.add("hidden");return}if(s.classList.contains("hidden")){s.classList.remove("hidden");return}s.classList.add("hidden")}}return(0,a.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(o?" pr-8":""),children:[n&&(0,a.jsxs)("label",{htmlFor:t,children:[n,l?"":" (optional)"]}),(0,a.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,a.jsx)("select",{name:t,id:d||t,className:"w-full bg-white",required:l,onChange:e=>{i&&i(null),e.target.classList.remove("warning"),s&&s(e)},defaultValue:c||void 0,children:e.map((e,t)=>{let{payload:s,title:r}=e;return(0,a.jsx)("option",{value:s,selected:!!e.default,children:r},t+1)})}),(0,a.jsx)(r.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),o&&(0,a.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:u,onMouseLeave:u,onClick:u,children:[(0,a.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,a.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,a.jsx)("span",{children:o})}),(0,a.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,a.jsx)("div",{children:"Form Select Error"})}}s(82015)},84894:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>o});var r=s(8732);s(46169);var l=s(82015),i=s.n(l);s(6789);var n=s(75979),c=e([n]);function o({editorRef:e,content:t,readOnly:s,language:a="javascript",options:l,wrapperProps:c}){try{let e=i().useRef(),[t,s]=i().useState(0);return(0,r.jsx)("div",{...c,ref:e,className:(0,n.twMerge)("ace-editor-wrapper w-full h-full minimal-scrollbars all-children",c?.className)})}catch(e){return(0,r.jsx)(i().Fragment,{children:(0,r.jsx)("h2",{className:"text-xl m-0",children:"Editor Error"})})}}n=(c.then?(await c)():c)[0],a()}catch(e){a(e)}})},59023:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(8732),r=s(23293);function l(){return(0,a.jsx)("button",{className:"outlined gray p-2 w-9 h-9 flex items-center justify-center rounded-full",onClick:e=>{window.history.back()},children:(0,a.jsx)(r.A,{})})}s(82015)},64126:(e,t,s)=>{s.d(t,{A:()=>n});var a=s(8732),r=s(82015),l=s.n(r),i=s(96089);function n({content:e,language:t,style:s,showCopy:r}){let[n,c]=l().useState(!1),o=()=>{c(!0)},d={};return(0,a.jsxs)("pre",{className:`language-${t||"javascript"} w-auto overflow-hidden skip-js code-block relative max-w-4xl flex items-center justify-center`,style:s?{...s,...d}:d,children:[(0,a.jsx)("code",{className:"w-auto px-10",style:{wordBreak:"break-all"},children:e}),(0,a.jsx)("button",{className:"outlined copy-code "+(r?"relative show":" absolute right-2 z-20 hover:opacity-50"),style:{padding:"2px",border:"none"},onClick:t=>{navigator.clipboard.writeText(e).then(()=>{o()})},children:(0,a.jsx)(i.A,{className:"text-white",size:20})})]})}},83180:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>x});var r=s(8732),l=s(82015),i=s.n(l),n=s(1360),c=s(59023),o=s(11201),d=s(46169),u=s(16757),h=s(58506),m=e([h]);function x({data:e}){let t=e.user,[s,a]=i().useState(0),[l,m]=i().useState(!1);return(0,r.jsxs)(i().Fragment,{children:[(0,r.jsxs)("div",{className:"w-full justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(c.A,{}),(0,r.jsxs)("h1",{className:"text-3xl m-0",children:[t.first_name," ",t.last_name]}),(0,r.jsx)("span",{className:"info w-auto gray font-normal",children:t.email})]}),(0,r.jsx)("div",{children:(0,r.jsxs)("button",{onClick:e=>{window.confirm(`Create a new backup for ${t.first_name}?`)&&(m(!0),(0,d.A)("/api/admin/addUserBackup",{method:"post",body:{user:t}}).then(e=>{console.log(e),e.success&&a(e=>e+1),setTimeout(()=>{m(!1)},1e3)}))},className:"relative",children:[l&&(0,r.jsx)(u.A,{width:"20px"}),"Backup User"]})})]}),(0,r.jsx)(n.A,{userObject:t,userPage:!0}),(0,r.jsx)(o.A,{user:t,refresh:s,setRefresh:a}),(0,r.jsx)(h.A,{user:t,refresh:s,setRefresh:a})]})}h=(m.then?(await m)():m)[0],a()}catch(e){a(e)}})},11201:(e,t,s)=>{s.d(t,{A:()=>c});var a=s(8732),r=s(82015),l=s.n(r),i=s(16757);s(46169);var n=s(47338);function c({user:e,refresh:t,setRefresh:s}){let[r,c]=l().useState(!1),[o,d]=l().useState([]);return(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"User Backups"}),!o&&(0,a.jsx)(i.A,{width:"20px",position:"relative"}),o&&!o[0]&&(0,a.jsx)("div",{children:"This user has no backups"}),o&&o[0]&&o.sort((e,t)=>parseInt(e)>parseInt(t)?-1:1).map((t,s)=>{let r=new Date(parseInt(t));return(0,a.jsxs)("a",{href:`/su/users/${e.id}/${t}`,className:"card w-full items-center",children:[(0,a.jsx)(n.A,{}),(0,a.jsx)("b",{children:"Backup:"}),(0,a.jsx)("span",{children:r.toString()})]},t)})]})}},1360:(e,t,s)=>{s.d(t,{A:()=>i});var a=s(8732),r=s(82015),l=s.n(r);function i({userObject:e,userPage:t}){let s=Object.keys(e),[r,i]=l().useState(!1),[n,c]=l().useState(0),[o,d]=l().useState(!t);return(0,a.jsxs)("div",{className:"card col green w-full overflow-hidden"+(o?t?" h-[100px]":" h-[85px]":" "),children:[(0,a.jsxs)("div",{className:"items-center w-full",children:[(0,a.jsx)("img",{src:e.image_thumbnail,alt:"",className:"rounded-full object-cover"+(t?" w-16 h-16":" w-12 h-12")}),!t&&(0,a.jsxs)("h3",{className:"m-0 text-xl",children:[e.first_name," ",e.last_name," "]}),(0,a.jsxs)("div",{className:"ml-auto",children:[(0,a.jsx)("button",{className:"outlined gray small-text",onClick:e=>{o?d(!1):d(!0)},children:o?"More Details":"Collapse"}),!t&&(0,a.jsx)("a",{href:`/su/users/${e.id}`,className:"button outlined gray small-text",children:"View User"})]})]}),(0,a.jsx)("div",{className:"card no-hover col w-full light-gray-bg",children:s.map((t,r)=>(0,a.jsxs)(l().Fragment,{children:[(0,a.jsx)("div",{children:(0,a.jsxs)("span",{style:{wordBreak:"break-all"},children:[t,":"," ",(0,a.jsx)("b",{children:e[t]})]})}),r{d(!0)},children:"Collapse"})]})}},58506:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>d});var r=s(8732),l=s(82015),i=s.n(l);s(46169);var n=s(50233),c=s(97012),o=e([c]);function d({user:e,refresh:t,setRefresh:s}){let[a,l]=i().useState(!1),[o,d]=i().useState(null),[u,h]=i().useState(null);return(0,r.jsxs)("div",{className:"paper w-full",children:[(0,r.jsx)("h2",{className:"text-xl m-0",children:"User Data"}),o&&(0,r.jsx)(n.A,{user:e,rootFilesArray:o}),u&&(0,r.jsx)(c.A,{user:e,databases:u})]})}c=(o.then?(await o)():o)[0],a()}catch(e){a(e)}})},97012:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>h});var r=s(8732),l=s(82015),i=s.n(l),n=s(16757),c=s(46169),o=s(64457),d=s(80830),u=e([o]);function h({user:e,databases:t}){try{let s=i().useRef(),a=i().useRef(),l=i().useRef(t[0]),[u,h]=i().useState(!1),[m,x]=i().useState(!1),[p,f]=i().useState(0),[j,g]=i().useState(t[0]),[y,v]=i().useState([]);return(0,r.jsxs)("div",{className:"paper w-full",children:[(0,r.jsx)("h3",{className:"text-lg m-0",children:(0,r.jsx)("span",{children:"Database Shell"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(d.A,{selectOptions:t.map(t=>({payload:t,title:t?.replace(RegExp(`datasquirel_user_${e.id}_`),"")})),name:"select-database",onChangeHandler:e=>{g(e.target.value),l.current=e.target.value},title:"Databases"}),j&&y&&(0,r.jsx)(d.A,{selectOptions:y.map(e=>({payload:e,title:e})),name:"select-database-table",title:"Tables"})]}),(0,r.jsxs)("div",{className:"w-full flex-col relative",children:[(0,r.jsx)("div",{ref:s,id:"ace-editor-wrapper",style:{height:"100px"}}),(0,r.jsxs)("button",{className:"absolute right-4 bottom-4"+(u?" pointer-events-none opacity-70":""),onClick:e=>{!function(){h(!0);let e=a.current?a.current.getValue():null;if(!e?.match(/./))return;let t=e.replace(/^--.*/gm,"").replace(/\n|\r|\n\r/gm,"").replace(/ {2,}/g," ");(0,c.A)("/api/admin/runUserDbQuery",{method:"post",body:{database:l.current,query:t}},!0).then(e=>{e.success?x(e.result):e.msg&&window.alert(e.msg),setTimeout(()=>{h(!1)},500)})}()},children:[u&&(0,r.jsx)(n.A,{position:"relative",width:"15px",borderWidth:"3px",style:{backgroundColor:"transparent"}}),u?"Running Query ...":"Run Query"]})]}),m&&!u&&(0,r.jsx)(o.A,{data:m,user:e})]})}catch(e){return console.log(e),(0,r.jsx)(i().Fragment,{children:(0,r.jsx)("section",{className:"card",children:(0,r.jsx)("h2",{className:"text-xl m-0",children:"Shell not available at this time"})})})}}o=(u.then?(await u)():u)[0],a()}catch(e){a(e)}})},64457:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>o});var r=s(8732),l=s(84894),i=s(82015),n=s.n(i),c=e([l]);function o({data:e,user:t}){try{return Object.keys(e[0]),(0,r.jsx)(n().Fragment,{children:(0,r.jsx)("div",{className:"p-4 bg-slate-200 rounded-md overflow-hidden w-full max-w-6xl",style:{width:"100%",height:"600px",overflow:"auto"},children:(0,r.jsx)(l.A,{content:JSON.stringify(e,null,4)})})})}catch(e){return(0,r.jsx)(n().Fragment,{children:(0,r.jsx)("span",{children:"No results"})})}}l=(c.then?(await c)():c)[0],a()}catch(e){a(e)}})},50233:(e,t,s)=>{s.d(t,{A:()=>m});var a=s(8732),r=s(82015),l=s.n(r),i=s(64126),n=s(46169),c=s(66916);function o({user:e,file:t,activeFile:s,setActiveFile:r}){return(0,a.jsxs)("button",{className:"justify-start gap-4"+(s?.path===`${t.root}/${t.name}`?" dark":" light-gray"),onClick:s=>{(0,n.A)("/api/admin/grabFile",{method:"post",body:{user:e,type:"file",path:`${t.root}/${t.name}`}}).then(e=>{if(e.success)try{r({title:t.name,path:`${t.root}/${t.name}`,data:JSON.stringify(JSON.parse(e.data),null,4)})}catch(s){r({title:t.name,path:`${t.root}/${t.name}`,data:e.data})}})},children:[(0,a.jsx)(c.A,{}),t.name]})}var d=s(96089),u=s(54677);function h({user:e,file:t,activeFile:s,setActiveFile:r}){let[i,n]=l().useState(null),[c,m]=l().useState(!1);return(0,a.jsxs)("div",{className:"flex-col w-full items-start relative",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(d.A,{fontSize:"small",className:"text-slate-400"}),t.name,(0,a.jsx)(u.A,{className:"ml-auto absolute right-2"})]}),t.content&&(0,a.jsx)("div",{className:"flex-col w-full pl-4 items-start ml-2",style:{borderLeft:"1px solid var(--slate-200)"},children:t.content.map((t,l)=>t?.type?.match(/file/i)?(0,a.jsx)(o,{user:e,file:t,activeFile:s,setActiveFile:r},l):(0,a.jsx)(h,{user:e,file:t,activeFile:s,setActiveFile:r},l))})]})}function m({user:e,rootFilesArray:t}){let[s,r]=l().useState(null);return(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h3",{className:"text-lg m-0",children:"User Files"}),(0,a.jsxs)("div",{className:"w-full items-start max-w-7xl",children:[(0,a.jsx)("div",{className:"flex-col items-stretch w-[40%]",children:t.map((t,l)=>t?.type?.match(/file/)?(0,a.jsx)(o,{user:e,file:t,activeFile:s||void 0,setActiveFile:r},l):(0,a.jsx)(h,{user:e,file:t,activeFile:s||void 0,setActiveFile:r},l))}),(0,a.jsx)("div",{className:"grow flex-col items-start justify-start w-[60%] h-full -mt-4",children:s&&(0,a.jsx)(i.A,{content:s.data||"",language:"javascript"})})]})]})}},23293:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},96089:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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"}]])},47338:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]])},66916:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},54677:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},71934:(e,t,s)=>{s.d(t,{A:()=>a});async function a(...e){let t=global.DSQL_DB_CONN;try{if(!t)throw Error("No Connection provided to DB_HANDLER function!");let s=await t.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await t?.end()}}},24747:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.r(t),s.d(t,{default:()=>h,getServerSideProps:()=>m});var r=s(8732),l=s(82015),i=s.n(l),n=s(61197),c=s(40778),o=s(83180),d=s(71934),u=e([o]);function h({user:e,data:t}){let s=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,r.jsx)("meta",{name:"description",content:"Welcome to your data app"}),(0,r.jsxs)(i().Fragment,{children:[(0,r.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js",integrity:"sha512-q6CTB0jS+VuJnSct82rVcWlI06LGzNjaG3CWenHWVUncRvc4UQMFkA3a5Ip880xr+lBx38FcHDclOxPdSg+sBw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"}),(0,r.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js",integrity:"sha512-6g6cvocV7eT/J8L44lL8gJKqq9onqQeYGgJO0DmrsYFcCfRl6wYkYA/KHS768r4QVTB4JxsCcMQ9gIezxpTCZw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"})]})]});return(0,r.jsx)(c.A,{head:s,user:e,children:(0,r.jsx)(o.A,{data:t})})}async function m({req:e,res:t,query:s}){let a=await (0,n.A)(e);if(!a?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let r=await (0,d.A)(`SELECT * FROM users WHERE id='${s.single}'`);return r?.[0]?{props:{user:a,data:{user:r?.[0]||{}}}}:{redirect:{destination:"/su/users",permanent:!1}}}o=(u.then?(await u)():u)[0],a()}catch(e){a(e)}})},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},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")},33873:e=>{e.exports=require("path")},75979:e=>{e.exports=import("tailwind-merge")}};var t=require("../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[883,9821,9796,6622],()=>s(17981));module.exports=a})();