"use strict";exports.id=1223,exports.ids=[1223],exports.modules={30671:(e,a)=>{Object.defineProperty(a,"M",{enumerable:!0,get:function(){return function e(a,t){return t in a?a[t]:"then"in a&&"function"==typeof a.then?a.then(a=>e(a,t)):"function"==typeof a&&"default"===t?a:void 0}}})},14587:(e,a,t)=>{t.d(a,{A:()=>x});var s=t(8732),l=t(82015),d=t.n(l),i=t(86173),n=t(55158),r=t(63715),c=t(32415),o=t(62506),h=t(6070);function x({database:e,setTargetDatabase:a,delegated:t,icons:l,user:x}){let m=`/admin/${x?.id}/databases/${e.db_slug}`+(t?`?delegated=true&dbUserId=${e.user_id}`:""),{active_clone:p,active_clone_parent_db:u}=e,[v,j]=d().useState(!1);return(0,s.jsxs)("a",{href:m,className:"card",onClick:a=>{(a.target.closest(".db-list-item-actions-block")||a.target.closest(".cancel-link"))&&a.preventDefault(),t&&(a.preventDefault(),j(!0),(0,r.A)("/api/getDelegatedDatabaseToken",{method:"post",body:{rootUserId:e.user_id,priviledges:e.user_priviledge,database:e.db_slug}},!0).then(e=>{e.success&&(window.location.href=m)}),setTimeout(()=>{j(!1)},1e3))},children:[v&&(0,s.jsx)(c.A,{width:"20px"}),(0,s.jsx)("img",{src:e.db_image?e.db_image:"/images/folder.svg",alt:"Folder Image",width:20,className:e.db_image?"avatar":"avatar opacity-50"}),(0,s.jsxs)("div",{className:"flex-col items-start grow",children:[(0,s.jsx)("span",{className:"title",children:e.db_name}),u&&(0,s.jsxs)("span",{className:"text-xs bg-emerald-100 dark:bg-emerald-100/10 text-emerald-700 dark:text-emerald-200 px-2 py-0.5 rounded-full mb-1",children:["This Database is an active Clone of"," ",(0,s.jsx)("b",{children:u.replace(/datasquirel_user_\d+_/,"")})]}),(0,s.jsx)("div",{className:"-mt-2",children:(0,s.jsx)(i.A,{slugText:e.db_slug,smaller:!0})}),(0,s.jsx)("div",{className:"-mt-1 gap-1",children:(0,s.jsx)(i.A,{slugText:e.db_full_name,smaller:!0,full:!0})}),!t&&(0,s.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",e.date_created?.substring(0,21)]}),t&&(0,s.jsxs)("div",{className:"flex items-center mt-2",children:[(0,s.jsx)("img",{src:e.image_thumbnail,alt:"",className:"w-8 h-8 rounded-full object-cover"}),(0,s.jsxs)("div",{className:"flex-col items-start gap-0",children:[(0,s.jsxs)("span",{className:"text-xs text-slate-600",children:[e.first_name," ",e.last_name]}),(0,s.jsx)("span",{className:"text-xs text-slate-400",children:e.email})]})]}),(0,s.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,s.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,s.jsxs)(o.A,{children:[!t&&(0,s.jsx)("button",{className:"outlined light-gray small-text",onClick:a=>{window.location.pathname=`/admin/${x?.id}/databases/${e.db_slug}/edit-database`},children:(0,s.jsx)("span",{children:"Edit"})}),!t&&!p&&(0,s.jsx)("button",{className:"outlined light-gray small-text",onClick:a=>{window.location.href=`/admin/${x?.id}/databases/add-database?duplicate=${e.db_full_name}`},children:(0,s.jsx)("span",{children:"Duplicate"})}),!t&&(0,s.jsx)("button",{className:"outlined light-gray small-text",onClick:t=>{a&&a(e),(0,n.PB)("delete-database-confirmation")},children:(0,s.jsx)("span",{children:"Delete"})})]})}),(0,s.jsx)(h.A,{className:"text-slate-600",size:20})]})]})]})}},37515:(e,a,t)=>{t.d(a,{A:()=>h});var s=t(8732),l=t(82015),d=t.n(l),i=t(86176),n=t(58548),r=t(24671),c=t(42602),o=t(92736);function h(e){let{databases:a,setTargetDatabase:t,user:l}=d().useContext(i.DatabasesContext);return(0,s.jsxs)(d().Fragment,{children:[(0,s.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,s.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,s.jsx)("h1",{className:"text-3xl m-0",children:"Databases"}),(0,s.jsxs)("a",{href:`/admin/${l?.id}/databases/add-database`,className:"button flex items-center gap-2",children:[(0,s.jsx)("span",{className:"symbol",children:"+"}),(0,s.jsx)("span",{children:"Add Database"})]})]}),(0,s.jsx)(n.A,{user:l})]}),l?.verification_status?.toString().match(/1/)?(0,s.jsxs)(d().Fragment,{children:[(0,s.jsx)(c.A,{databases:a,setTargetDatabase:t,user:l}),(0,s.jsx)(o.A,{user:l})]}):(0,s.jsx)(r.A,{})]})}},42602:(e,a,t)=>{t.d(a,{A:()=>x});var s=t(8732),l=t(82015),d=t.n(l),i=t(14587),n=t(6078),r=t(18129),c=t(8248),o=t(69290),h=t(68253);function x({databases:e,setTargetDatabase:a,title:t,more:l,user:x}){return(0,s.jsx)(d().Fragment,{children:(0,s.jsxs)("section",{className:"paper",children:[(0,s.jsx)("h2",{className:"text-xl m-0",children:t||"Database List"}),x&&e&&e[0]&&a&&(0,s.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:e.map(e=>(0,s.jsx)(i.A,{database:e,setTargetDatabase:a,icons:{edit:n.A,duplicate:r.A,delete:c.A,copy:o.A},user:x},e.id))}),l&&e&&e[0]&&(0,s.jsx)("a",{href:`/admin/${x?.id}/databases`,className:"button w-full more-padding",children:"See All Databases"}),!e||!e[0]&&(0,s.jsxs)("a",{href:`/admin/${x?.id}/databases/add-database`,className:"button outlined gray dashed w-full p-10 flex-col",children:[(0,s.jsx)("span",{className:"text-slate-400",children:"No Databases Created."}),(0,s.jsx)(h.A,{color:"action",sx:{fontSize:80},className:"opacity-40"}),(0,s.jsx)("span",{className:"",children:"Add Database"})]})]})})}},92736:(e,a,t)=>{t.d(a,{A:()=>x});var s=t(8732),l=t(82015),d=t.n(l),i=t(6078),n=t(18129),r=t(8248),c=t(69290),o=t(32415);t(63715);var h=t(14587);function x({user:e}){let[a,t]=d().useState(null),[l,x]=d().useState(!1);return(0,s.jsxs)("section",{className:"paper",children:[(0,s.jsx)("h2",{className:"text-xl m-0 text-left w-full",children:"Delegated Databases"}),l&&(0,s.jsx)(o.A,{}),e&&a?a[0]?(0,s.jsx)(d().Fragment,{children:(0,s.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:a.map(a=>(0,s.jsx)(h.A,{database:a,delegated:!0,icons:{edit:i.A,duplicate:n.A,delete:r.A,copy:c.A},user:e},a.id))})}):(0,s.jsx)(d().Fragment,{children:(0,s.jsx)("span",{className:"info gray w-full font-normal justify-center",children:"No Delegated Databases Yet"})}):(0,s.jsx)(d().Fragment,{children:(0,s.jsx)("div",{className:"w-full justify-center",children:(0,s.jsx)(o.A,{position:"relative",width:"20px"})})})]})}},34033:(e,a,t)=>{t.d(a,{A:()=>c});var s=t(8732),l=t(82015),d=t.n(l),i=t(63715),n=t(55158),r=t(32415);function c({targetDatabase:e}){let[a,t]=d().useState(!1);return(0,s.jsxs)(n.Ay,{title:"delete-database-confirmation",children:[a&&(0,s.jsx)(r.A,{width:"20px"}),(0,s.jsxs)("h4",{className:"m-0",children:["Delete '",e?.db_name?e.db_name:"This Database","' database?"]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("button",{className:"outlined"+(a?" pointer-events-none opacity-40":""),onClick:a=>{if(!e){alert("No Target Database Selected!");return}t(!0),window.confirm("Note that you will loose all data in this database. Continue?")?(0,i.A)("/api/deleteUserDatabase",{method:"post",body:e},!0).then(e=>{e.success&&window.location.reload()}):t(!1)},children:(0,s.jsx)("span",{children:"Yes"})}),(0,s.jsx)("button",{onClick:e=>{(0,n.fs)()},children:(0,s.jsx)("span",{children:"Cancel"})})]})]})}},86173:(e,a,t)=>{t.d(a,{A:()=>d});var s=t(8732);t(82015);var l=t(69290);function d({slugText:e,smaller:a,outlined:t,full:d}){return(0,s.jsxs)("span",{className:"button break-words text-wrap cancel-link "+(t?" outlined gray":"light-gray")+(a?" small-text":""),onClick:a=>{navigator.clipboard.writeText(e).then(()=>{alert(`${d?"Database Full name":"Database Slug"} "${e}" Copied to Clipboard. Use this as the database name when querying data`)})},style:{wordWrap:"break-word",wordBreak:"break-all"},children:[(0,s.jsx)(l.A,{color:"action",sx:{opacity:.5,fontSize:15}}),(0,s.jsx)("span",{children:e})]})}},55158:(e,a,t)=>{t.d(a,{Ay:()=>n,PB:()=>r,fs:()=>c});var s=t(8732),l=t(58150),d=t(82015),i=t.n(d);function n({children:e,title:a,data:t,fullPage:d,wrapperClasses:n,closePopupDispatch:r,wrapperStyle:o,noContainer:h}){return d?(0,s.jsxs)("div",{className:"popup-bg overflow-hidden "+(n||""),"data-popupid":a||null,style:o,children:[h?(0,s.jsx)(i().Fragment,{children:e}):(0,s.jsx)("div",{className:"relative w-full h-full z-50","data-data":t?JSON.stringify(t):"",children:e}),(0,s.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{c(),r&&r()},children:(0,s.jsx)(l.A,{color:"white",size:20})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),r&&r()}})]}):(0,s.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[h?(0,s.jsx)(i().Fragment,{children:e}):(0,s.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":t?JSON.stringify(t):"",children:[e,(0,s.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{c(),r&&r()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})})]}),h&&(0,s.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{c(),r&&r()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),r&&r()}})]})}function r(e,a){let t=document.querySelector(`[data-popupid='${e}']`);t&&(t.style.display="flex",a&&a(t))}function c(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e&&e()}},24671:(e,a,t)=>{t.d(a,{A:()=>l});var s=t(8732);function l(e){return(0,s.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,s.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,s.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}t(82015)},26406:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)([(0,d.jsx)("path",{d:"M22 15c0-1.66-1.34-3-3-3h-1.5v-.5C17.5 8.46 15.04 6 12 6c-.77 0-1.49.17-2.16.46L20.79 17.4c.73-.55 1.21-1.41 1.21-2.4M2 14c0 2.21 1.79 4 4 4h9.73l-8-8H6c-2.21 0-4 1.79-4 4",opacity:".3"},"0"),(0,d.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.33 0-2.57.36-3.65.97l1.49 1.49C10.51 6.17 11.23 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 .99-.48 1.85-1.21 2.4l1.41 1.41c1.09-.92 1.8-2.27 1.8-3.81 0-2.64-2.05-4.78-4.65-4.96M3 5.27l2.77 2.77h-.42C2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h11.73l2 2 1.41-1.41L4.41 3.86zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4z"},"1")],"CloudOffTwoTone")},69290:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)([(0,d.jsx)("path",{d:"M9 4h9v12H9z",opacity:".3"},"0"),(0,d.jsx)("path",{d:"M18 2H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m0 14H9V4h9zM3 15v-2h2v2zm0-5.5h2v2H3zM10 20h2v2h-2zm-7-1.5v-2h2v2zM5 22c-1.1 0-2-.9-2-2h2zm3.5 0h-2v-2h2zm5 0v-2h2c0 1.1-.9 2-2 2M5 6v2H3c0-1.1.9-2 2-2"},"1")],"CopyAllTwoTone")},8248:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)([(0,d.jsx)("path",{d:"M16 9H8v10h8zm-.47 7.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14z",opacity:".3"},"0"),(0,d.jsx)("path",{d:"M14.12 10.47 12 12.59l-2.13-2.12-1.41 1.41L10.59 14l-2.12 2.12 1.41 1.41L12 15.41l2.12 2.12 1.41-1.41L13.41 14l2.12-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4zM6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8z"},"1")],"DeleteForeverTwoTone")},18129:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)([(0,d.jsx)("path",{d:"M14.17 3H8v14h11V7.83zm2.33 12h-6v-2h6zm0-6h-2v2h-2V9h-2V7h2V5h2v2h2z",opacity:".3"},"0"),(0,d.jsx)("path",{d:"M18 23H4c-1.1 0-2-.9-2-2V7h2v14h14zM14.5 7V5h-2v2h-2v2h2v2h2V9h2V7zm2 6h-6v2h6zM15 1H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7zm4 16H8V3h6.17L19 7.83z"},"1")],"DifferenceTwoTone")},6078:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)([(0,d.jsx)("path",{d:"M12.06 10.02 5 17.08V18h.92l7.06-7.06z",opacity:".3"},"0"),(0,d.jsx)("path",{d:"m15 16-4 4h10v-4zm-2.94-8.81L3 16.25V20h3.75l9.06-9.06zM5.92 18H5v-.92l7.06-7.06.92.92zm12.79-9.96c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75z"},"1")],"DriveFileRenameOutlineTwoTone")},68253:(e,a,t)=>{var s=t(24994);a.A=void 0;var l=s(t(30887)),d=t(8732);a.A=(0,l.default)((0,d.jsx)("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}),"StorageTwoTone")},92441:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20",key:"t4utmx"}],["path",{d:"M8 7h6",key:"1f0q6e"}],["path",{d:"M8 11h8",key:"vwpz6n"}]])},6070:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},34637:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},29743:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]])},10643:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},66916:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(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"}]])},83158:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]])},66918:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},10321:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]])},25294:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},58150:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(82544).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},86176:(e,a,t)=>{t.r(a),t.d(a,{DatabasesContext:()=>m,default:()=>p,getServerSideProps:()=>u});var s=t(8732),l=t(82015),d=t.n(l),i=t(95222),n=t(20048),r=t.n(n),c=t(37515),o=t(34033),h=t(67216),x=t.n(h);let m=d().createContext({});function p({user:e,databases:a}){let t=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:"Databases | Datasquirel"}),(0,s.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[l,n]=d().useState(0);return(0,s.jsx)(i.A,{head:t,user:e,children:(0,s.jsxs)(m.Provider,{value:{user:e,databases:a,targetDatabase:l,setTargetDatabase:n},children:[(0,s.jsx)(c.A,{}),(0,s.jsx)(o.A,{targetDatabase:l})]})})}async function u({req:e,res:a,query:t}){let s=await r()(e,a);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let l=await x()("SELECT * FROM user_databases WHERE user_id=? ORDER BY id DESC",[s.id]);return{props:{user:s,databases:l}}}},9455:(e,a)=>{var t;Object.defineProperty(a,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))}};