@local-civics/mgmt-ui 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n,Fragment as a}from"react/jsx-runtime";import{createEmotionCache as i,MantineProvider as t,Tabs as r,UnstyledButton as o,Group as l,Avatar as c,Text as d,ScrollArea as s,Table as h,createStyles as u,Container as m,Stack as p,Grid as g,Badge as f,ActionIcon as v,Title as C,Button as b,Divider as k,Select as S,LoadingOverlay as y,Image as w,Autocomplete as x,Modal as z,Navbar as E,Center as N,Tooltip as D,Anchor as B,Timeline as L,Paper as O,Blockquote as T,Drawer as G,TextInput as P,Menu as A,Card as R,Overlay as M,ThemeIcon as W,SimpleGrid as F,AppShell as U,Loader as V}from"@mantine/core";import{ModalsProvider as I,openConfirmModal as j}from"@mantine/modals";import{NotificationsProvider as H}from"@mantine/notifications";export{showNotification,updateNotification}from"@mantine/notifications";import{IconArrowLeft as _,IconCategory2 as q,IconSwitchHorizontal as Y,IconLogout as K,IconHome2 as $,IconGauge as Q,IconAlbum as Z,IconLambda as J,IconBadges as X,IconSchool as ee,IconActivityHeartbeat as ne,IconTimelineEvent as ae,IconTrash as ie,IconPlaylistAdd as te,IconDownload as re,IconX as oe,IconCloudUpload as le,IconUsers as ce,IconDots as de,IconInfoCircle as se,IconArrowUpRight as he,IconArrowDownRight as ue,IconCalendar as me,IconBrandInstagram as pe,IconBrandLinkedin as ge,IconBrandFacebook as fe}from"@tabler/icons";import*as ve from"react";import{useState as Ce,createElement as be,useRef as ke}from"react";import{useForm as Se}from"@mantine/form";import{Dropzone as ye,MIME_TYPES as we}from"@mantine/dropzone";import*as xe from"papaparse";import{DateRangePicker as ze}from"@mantine/dates";import{ResponsiveContainer as Ee,AreaChart as Ne,XAxis as De,YAxis as Be,CartesianGrid as Le,Tooltip as Oe,Area as Te}from"recharts";var Ge=function(){return Ge=Object.assign||function(e){for(var n,a=1,i=arguments.length;a<i;a++)for(var t in n=arguments[a])Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e},Ge.apply(this,arguments)};var Pe=i({key:"mantine",prepend:!1}),Ae=function(n){return e(t,Ge({withNormalizeCSS:!0,withGlobalStyles:!0,emotionCache:Pe,theme:{loader:"bars"}},{children:e(H,Ge({limit:n.notificationLimit||5},{children:e(I,{children:n.children})}))}))},Re=function(n){var a,i=null===(a=n.data)||void 0===a?void 0:a.map((function(n){return e(r.Tab,Ge({value:n.value},{children:n.label||n.value}),n.value)}));return e(r,Ge({value:n.value,onTabChange:n.onChange},{children:e(r.List,{children:i})}))};function Me(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:n(l,{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var We=[{value:"Complete"},{value:"Incomplete"}],Fe=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Ue=function(a){var i=Ve(a.data.groups,a.onGroupChange),t=Ie(a.data.tab,a.onTabChange),r=Fe().classes;return e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Badges"})),n(l,{children:[n(p,Ge({spacing:0},{children:[e(C,Ge({order:2,className:r.title,mt:"md"},{children:a.data.name||"Badge"})),e(d,Ge({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(p,Ge({ml:"auto"},{children:[e(b,Ge({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(k,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(S,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Re,{data:We,value:t.value,onChange:t.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(Me,{data:a.data.users,onClick:a.onUserClick})]}))]})]}))}))},Ve=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},Ie=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},je=u((function(e){var n,a,i;return{wrapper:(n={display:"flex",alignItems:"center",padding:2*e.spacing.xl,borderRadius:e.radius.md,backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white,border:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[3])},n["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={flexDirection:"column-reverse",padding:e.spacing.xl},n),image:(a={maxWidth:"40%"},a["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={maxWidth:"100%"},a),body:(i={paddingRight:4*e.spacing.xl},i["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={paddingRight:0,marginTop:e.spacing.xl},i),title:{color:"dark"===e.colorScheme?e.white:e.black,fontFamily:"Greycliff CF, ".concat(e.fontFamily),lineHeight:1,marginBottom:e.spacing.md},controls:{display:"flex",marginTop:e.spacing.xl},inputWrapper:{width:"100%",flex:"1"},input:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRight:0},control:{borderTopLeftRadius:0,borderBottomLeftRadius:0}}})),He=function(a){var i=je().classes;return n("div",Ge({className:i.wrapper},{children:[n("div",Ge({className:i.body},{children:[e(C,Ge({className:i.title},{children:a.data.title})),e(d,Ge({size:"sm",color:"dimmed"},{children:a.data.description}))]})),e(w,{src:"https://cdn.localcivics.io/illustrations/".concat(a.data.icon,".svg"),className:i.image})]}))};function _e(a){if(0===a.data.length)return e(He,{data:{title:"No badges available",icon:"badges",description:"Adjust your search or contact a representative if your expecting results."}});var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:e(l,{children:n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var qe=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Ye=function(a){var i=qe().classes,t=Ce(a.data.badgeOpen),r=t[0],o=t[1];return r?e(Ue,{data:a.data.badge,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Badges"})),e(C,Ge({order:2,className:i.title,mt:"md"},{children:"Badges and micro-credentials"})),e(d,Ge({color:"dimmed",className:i.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),e(x,{placeholder:"Search for a badge that fits your needs",data:a.data.badges.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(_e,{data:a.data.badges,onClick:function(e){a.onBadgeClick&&a.onBadgeClick(e),o(!0)}})]}))]}))}))};function Ke(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:n(l,{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var $e=[{value:"Complete"},{value:"Incomplete"}],Qe=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Ze=function(a){var i=Je(a.data.groups,a.onGroupChange),t=Xe(a.data.tab,a.onTabChange),r=Qe().classes;return e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Lessons"})),n(l,{children:[n(p,Ge({spacing:0},{children:[e(C,Ge({order:2,className:r.title,mt:"md"},{children:a.data.name||"Lesson"})),e(d,Ge({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(p,Ge({ml:"auto"},{children:[e(b,Ge({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(k,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(S,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Re,{data:$e,value:t.value,onChange:t.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(Ke,{data:a.data.users,onClick:a.onUserClick})]}))]})]}))}))},Je=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},Xe=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}};function en(a){if(0===a.data.length)return e(He,{data:{title:"No lessons available",icon:"lessons",description:"Adjust your search or contact a representative if your expecting results."}});var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:e(l,{children:n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var nn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),an=function(a){var i=nn().classes,t=Ce(a.data.lessonOpen),r=t[0],o=t[1];return r?e(Ze,{data:a.data.lesson,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Lessons"})),e(C,Ge({order:2,className:i.title,mt:"md"},{children:"Lessons"})),e(d,Ge({color:"dimmed",className:i.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),e(x,{placeholder:"Search for a lesson that fits your needs",data:a.data.lessons.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(en,{data:a.data.lessons,onClick:function(e){a.onLessonClick&&a.onLessonClick(e),o(!0)}})]}))]}))}))},tn=function(a){var i=Se({initialValues:{active:a.data.active}});return e(z,Ge({centered:!0,opened:!a.data.hidden,onClose:function(){return a.onClose&&a.onClose()},size:"sm",title:e(C,Ge({size:"h5"},{children:"Accounts"}))},{children:n("form",Ge({onSubmit:i.onSubmit((function(){a.onChange&&a.onChange(i.values.active)}))},{children:[e(S,Ge({required:!0,placeholder:"Select an account",defaultValue:a.data.active,data:a.data.accounts.map((function(e){return{value:e.key,label:e.name}}))},i.getInputProps("active"))),e(b,Ge({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},rn=u((function(e){return{link:{width:50,height:50,borderRadius:e.radius.md,display:"flex",alignItems:"center",justifyContent:"center",color:"dark"===e.colorScheme?e.colors.dark[0]:e.colors.gray[7],"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[0]}},active:{"&, &:hover":{backgroundColor:e.fn.variant({variant:"light",color:e.primaryColor}).background,color:e.fn.variant({variant:"light",color:e.primaryColor}).color}}}})),on=[{icon:$,label:"Home"},{icon:Q,label:"Dashboard"},{icon:q,label:"Groups"},{icon:Z,label:"Badges"},{icon:J,label:"Lessons"}],ln=function(n){var a,i=n.icon,t=n.label,r=n.active,l=n.onClick,c=rn(),d=c.classes,s=c.cx;return e(D,Ge({label:t,position:"right",transitionDuration:0},{children:e(o,Ge({onClick:l,className:s(d.link,(a={},a[d.active]=r,a))},{children:e(i,{stroke:1.5})}))}))},cn=["Logout","Change account"],dn=function(a){var i=on.map((function(e){return be(ln,Ge({},e,{key:e.label,active:e.label===a.active,onClick:function(){return a.onClick&&a.onClick(e.label)}}))}));return n(E,Ge({width:{base:80},p:"md"},{children:[e(N,{children:e(c,Ge({color:"blue",radius:"sm"},{children:e("div",Ge({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:e(w,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),e(E.Section,Ge({grow:!0,mt:50},{children:e(p,Ge({justify:"center",spacing:0},{children:i}))})),e(E.Section,{children:n(p,Ge({justify:"center",spacing:0},{children:[e(ln,{icon:Y,label:"Change account",onClick:function(){return a.onClick&&a.onClick("Change account")}}),e(ln,{icon:K,label:"Logout",onClick:function(){return a.onClick&&a.onClick("Logout")}})]}))})]}))},sn=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],hn=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function un(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,a=sn;n<a.length;n++){var i=a[n],t=i.unit,r=i.ms;if(Math.abs(e)>=r||"second"===t)return hn.format(Math.round(e/r),t)}return""}(e.getTime()-n.getTime()):""}var mn={BadgeCompleted:e(X,{size:12}),BadgeStarted:e(X,{size:12}),LessonCompleted:e(ee,{size:12}),LessonStarted:e(ee,{size:12}),ProblemSolved:e(ne,{size:12})},pn=function(a){var i,t=ke(null),r=Ce({x:0,y:0}),o=r[0],l=r[1];ve.useEffect((function(){t.current&&o.y===t.current.scrollHeight-t.current.offsetHeight&&a.onScrollBottom&&a.onScrollBottom()}),[o.y]);var c=a.data.map((function(a){var t=a.name.split(/(?=[A-Z])/),r=t[0]===i?"dashed":"solid";i=t[0];var o=a.link?e(B,Ge({color:"dark",unstyled:!0,href:a.link},{children:"".concat(t[0]," ").concat(t[1].toLowerCase())})):"".concat(t[0]," ").concat(t[1].toLowerCase());return n(L.Item,Ge({bullet:gn(a.name),lineVariant:r,title:o},{children:[e(d,Ge({color:"dimmed",size:"sm"},{children:a.description})),e(d,Ge({size:"xs",mt:4},{children:un(new Date(a.time))}))]}),a.key)}));return e(s.Autosize,Ge({maxHeight:300,onScrollPositionChange:l,viewportRef:t},{children:e(L,Ge({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:c}))}))},gn=function(n){var a=mn[n];return a||e(ae,{size:12})},fn=u((function(e){var n,a;return{root:(n={display:"flex",backgroundImage:"linear-gradient(-60deg, ".concat(e.colors[e.primaryColor][4]," 0%, ").concat(e.colors[e.primaryColor][7]," 100%)"),padding:1.5*e.spacing.xl,borderRadius:e.radius.md},n[e.fn.smallerThan("sm")]={flexDirection:"column"},n),title:{color:e.white,textTransform:"uppercase",fontWeight:700,fontSize:e.fontSizes.sm},count:{color:e.white,fontSize:32,lineHeight:1,fontWeight:700,marginBottom:e.spacing.md,fontFamily:"Greycliff CF, ".concat(e.fontFamily)},description:{color:e.colors[e.primaryColor][0],fontSize:e.fontSizes.sm,marginTop:5},stat:{flex:1,"& + &":(a={paddingLeft:e.spacing.xl,marginLeft:e.spacing.xl,borderLeft:"1px solid ".concat(e.colors[e.primaryColor][3])},a[e.fn.smallerThan("sm")]={paddingLeft:0,marginLeft:0,borderLeft:0,paddingTop:e.spacing.xl,marginTop:e.spacing.xl,borderTop:"1px solid ".concat(e.colors[e.primaryColor][3])},a)}}})),vn=function(a){var i=a.data,t=fn().classes,r=i.map((function(a){return n("div",Ge({className:t.stat},{children:[e(d,Ge({className:t.count},{children:a.value.toLocaleString()})),e(d,Ge({className:t.title},{children:a.title})),e(d,Ge({className:t.description},{children:"".concat(a.diff,"% ").concat(a.diff<0?"decrease":"increase"," compared to last period")}))]}),a.title)}));return e("div",Ge({className:t.root},{children:r}))},Cn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),bn=function(i){var t=Cn().classes,r=i.data.givenName?[i.data.givenName,i.data.familyName].join(" ").trim():i.data.email,o=i.data.givenName?i.data.givenName:"Me";return"compact"===i.variant?n(a,{children:[e(C,Ge({className:t.title},{children:r})),e(d,Ge({color:"dimmed",className:t.description,mt:"xs"},{children:i.data.quote}))]}):n(a,{children:[n(O,Ge({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[e(c,{src:i.data.avatar,size:135,radius:120,mx:"auto"}),e(d,Ge({align:"center",size:"lg",weight:500,mt:"md"},{children:r})),n(d,Ge({align:"center",color:"dimmed",size:"sm"},{children:[i.data.email," • ",i.data.job]}))]})),e(T,Ge({mt:"xl",color:"blue",cite:"– ".concat(o)},{children:i.data.quote}))]})},kn=["Member","Admin"];function Sn(a){var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(o,Ge({onClick:function(){return a.onViewProfile&&a.onViewProfile(i)}},{children:n(l,Ge({spacing:"sm"},{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.givenName&&i.familyName?"".concat(i.givenName," ").concat(i.familyName):i.email})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]}))}))}),e("td",{children:e(S,{data:kn,defaultValue:i.role,variant:"unstyled",onChange:function(e){return a.onChangeRole&&a.onChangeRole(i,e)}})}),e("td",{children:i.lastActivity?un(i.lastActivity):""}),e("td",{children:e(l,Ge({noWrap:!0,spacing:0,position:"right"},{children:e(v,Ge({color:"red"},{children:e(ie,{onClick:function(){return j({title:'Delete "'.concat((n=i).givenName&&n.familyName?"".concat(n.givenName," ").concat(n.familyName):n.email,'"?'),centered:!0,children:e(d,Ge({size:"sm"},{children:"Are you sure you want to delete this person? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete",cancel:"No don't delete them"},confirmProps:{color:"red"},onConfirm:function(){return a.onDelete&&a.onDelete(n)}});var n},size:16,stroke:1.5})}))}))})]},i.email)}));return 0===a.data.length?e(He,{data:{title:"No one in group",icon:"thinking",description:"You don't have any people in this group yet. When your ready, get started by clicking the 'Add people' button above."}}):e(s,{children:n(h,Ge({verticalSpacing:20,sx:{minWidth:700}},{children:[e("thead",{children:n("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Last active"}),e("th",{})]})}),e("tbody",{children:i})]}))})}var yn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600},wrapper:{position:"relative",marginBottom:30},dropzone:{borderWidth:1,paddingBottom:50},icon:{color:"dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[4]},control:{position:"absolute",width:250,left:"calc(50% - 125px)",bottom:-20}}})),wn=function(i){var t=yn().classes,r=Se({initialValues:{key:"",email:"",givenName:"",familyName:"",avatar:"",role:"",lastActivity:null},validate:{email:function(e){return/^\S+@\S+$/.test(e)&&0===i.data.users.filter((function(n){return n.email===e})).length?null:"Invalid email"}}}),o=Ce(!1),c=o[0],s=o[1],h=Ce(i.data.groupUserHomeOpen),u=h[0],S=h[1];return u?e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:function(){return S(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Users"})),e(bn,{variant:"compact",data:i.data.user})]}))}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.user.loading,overlayBlur:2}),n(p,Ge({spacing:"lg"},{children:[e(vn,{data:[{title:"PROBLEMS SOLVED",value:i.data.stats["PROBLEMS SOLVED"].value,diff:i.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:i.data.stats["LESSONS COMPLETED"].value,diff:i.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:i.data.stats["BADGES EARNED"].value,diff:i.data.stats["BADGES EARNED"].diff}]}),e(pn,{onScrollBottom:i.onTimelineScrollBottom,data:i.data.timeline})]}))]}))]}))})):n(a,{children:[e(G,Ge({opened:c,onClose:function(){return s(!1)},title:e(C,Ge({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(xn,Ge({},i,{close:function(){return s(!1)}})),e(k,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),e("form",Ge({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateUsers&&i.onCreateUsers([e])}))},{children:n(p,{children:[e(P,Ge({withAsterisk:!0,label:"Email",placeholder:"Email"},r.getInputProps("email"))),n(l,Ge({grow:!0},{children:[e(P,Ge({label:"Given name",placeholder:"Given name"},r.getInputProps("givenName"))),e(P,Ge({label:"Family name",placeholder:"Family name"},r.getInputProps("familyName")))]})),e(b,Ge({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:i.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Groups"})),e(C,Ge({order:2,className:t.title,mt:"md"},{children:i.data.name||"Group"})),e(d,Ge({color:"dimmed",className:t.description,mt:"sm"},{children:i.data.description||"No description"}))]})),e(g.Col,Ge({sm:"content"},{children:e(b,Ge({onClick:function(){return s(!0)},leftIcon:e(te,{size:14})},{children:"Add people"}))}))]}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.loading,overlayBlur:2}),e(Sn,{data:i.data.users,onDelete:i.onDelete,onChangeRole:i.onRoleChange,onViewProfile:function(e){return i.onViewProfile(e).then((function(){S(!0)}))}})]}))]}))}))]})},xn=function(a){var i=yn(),t=i.classes,r=i.theme,o=ve.useRef(null),c=ve.useState(!1),s=c[0],h=c[1],u=ve.useCallback((function(e){h(!0),e.forEach((function(e){xe.parse(e,{download:!0,header:!0,dynamicTyping:!0,skipEmptyLines:!0,worker:!0,complete:function(e){var n=e.data.filter((function(e){return/^\S+@\S+$/.test(e.email)&&0===a.data.users.filter((function(n){return n.email===e.email})).length}));n.length>0&&a.onCreateUsers&&a.onCreateUsers(n),h(!1),a.close()}})}))}),[]);return n("div",Ge({className:t.wrapper},{children:[e(ye,Ge({loading:s,openRef:o,onDrop:u,className:t.dropzone,radius:"md",accept:[we.csv],maxSize:5*Math.pow(1024,2)},{children:n("div",Ge({style:{pointerEvents:"none"}},{children:[n(l,Ge({position:"center"},{children:[e(ye.Accept,{children:e(re,{size:50,color:r.colors[r.primaryColor][6],stroke:1.5})}),e(ye.Reject,{children:e(oe,{size:50,color:r.colors.red[6],stroke:1.5})}),e(ye.Idle,{children:e(le,{size:50,color:"dark"===r.colorScheme?r.colors.dark[0]:r.black,stroke:1.5})})]})),n(d,Ge({align:"center",weight:700,size:"lg",mt:"xl"},{children:[e(ye.Accept,{children:"Drop files here"}),e(ye.Reject,{children:"Csv file less than 5mb"}),e(ye.Idle,{children:"Upload multiple"})]})),n(d,Ge({align:"center",size:"sm",mt:"xs",color:"dimmed"},{children:["Drag'n'drop files here to upload. We can accept only ",e("i",{children:".csv"})," files that are less than 5mb in size."]}))]}))})),e(b,Ge({className:t.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=o.current)||void 0===e?void 0:e.call(o)}},{children:"Select file"}))]}))};function zn(a){if(0===a.data.length)return e(He,{data:{title:"No groups",icon:"groups",description:"You don't have any groups just yet. When your ready, get started by clicking the 'Create group' button above."}});var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(d,Ge({size:14},{children:i.name}))}),e("td",{children:e(d,Ge({size:14},{children:i.description}))}),e("td",{children:n(l,Ge({noWrap:!0,spacing:0,position:"right"},{children:[e(v,Ge({color:"blue",onClick:function(){return a.onEditGroup&&a.onEditGroup(i)},variant:"subtle"},{children:e(ce,{size:16,stroke:1.5})})),n(A,Ge({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[e(A.Target,{children:e(v,{children:e(de,{size:16,stroke:1.5})})}),e(A.Dropdown,{children:e(A.Item,Ge({onClick:function(){return j({title:'Delete "'.concat((n=i).name,'"?'),centered:!0,children:e(d,Ge({size:"sm"},{children:"Are you sure you want to delete this group? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete group",cancel:"No don't delete it"},confirmProps:{color:"red"},onConfirm:function(){return a.onDeleteGroup&&a.onDeleteGroup(n)}});var n},icon:e(ie,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},i.name)}));return e(s.Autosize,Ge({maxHeight:300},{children:n(h,Ge({verticalSpacing:20,sx:{minWidth:700}},{children:[e("thead",{children:n("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Description"}),e("th",{})]})}),e("tbody",{children:i})]}))}))}var En=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Nn=function(i){var t=En().classes,r=Se({initialValues:{key:"",name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),o=Ce(i.data.formOpen),c=o[0],s=o[1],h=Ce(i.data.groupOpen),u=h[0],k=h[1];return u?e(wn,{data:i.data.group,onBackClick:function(){return k(!1)},onCreateUsers:i.onCreateGroupUsers,onDelete:i.onDeleteGroupUser,onViewProfile:i.onViewGroupUser,onRoleChange:i.onGroupUserRoleChange,onTimelineScrollBottom:i.onTimelineScrollBottom}):n(a,{children:[e(G,Ge({opened:c,onClose:function(){return s(!1)},title:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5"},{children:"Create a group"})),e(D,Ge({label:"Groups settings cannot be modified once created"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n("form",Ge({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateGroup&&i.onCreateGroup(e)}))},{children:[n(p,{children:[e(P,Ge({withAsterisk:!0,label:"Name",placeholder:"Group name"},r.getInputProps("name"))),e(P,Ge({label:"Description",placeholder:"A group for my first period class"},r.getInputProps("description")))]}),e(b,Ge({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Groups"})),e(C,Ge({order:2,className:t.title,mt:"md"},{children:"Organize people into groups"})),e(d,Ge({color:"dimmed",className:t.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),e(g.Col,Ge({sm:"content"},{children:e(b,Ge({onClick:function(){return s(!0)},leftIcon:e(te,{size:14})},{children:"Create group"}))}))]}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.loading,overlayBlur:2}),e(zn,{data:i.data.groups,onDeleteGroup:i.onDeleteGroup,onEditGroup:function(e){i.onEditGroup&&i.onEditGroup(e),k(!0)}})]}))]}))}))]})},Dn=u((function(e){return{card:{height:240,backgroundSize:"cover",backgroundPosition:"center"},content:{position:"absolute",padding:e.spacing.xl,zIndex:1,top:0,bottom:0,right:0,left:0},action:{position:"absolute",bottom:e.spacing.xl,right:e.spacing.xl},title:{color:e.white,marginBottom:e.spacing.xs/2},description:{color:e.white,maxWidth:220}}})),Bn=function(a){var i=a.title,t=a.description,r=a.image,o=a.action,l=a.style,c=a.className,s=function(e,n){var a={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(a[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(i=Object.getOwnPropertySymbols(e);t<i.length;t++)n.indexOf(i[t])<0&&Object.prototype.propertyIsEnumerable.call(e,i[t])&&(a[i[t]]=e[i[t]])}return a}(a,["title","description","image","action","style","className"]),h=Dn(),u=h.classes,m=h.cx,p=h.theme;return n(R,Ge({radius:"md",style:Ge({backgroundImage:"url(".concat(r,")")},l),className:m(u.card,c)},s,{children:[e(M,{gradient:"linear-gradient(105deg, ".concat(p.black," 20%, #312f2f 50%, ").concat(p.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n("div",Ge({className:u.content},{children:[e(d,Ge({size:"lg",weight:700,className:u.title},{children:i})),e(d,Ge({size:"sm",className:u.description},{children:t})),e(b,Ge({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},Ln=function(a){return e(m,Ge({size:"lg"},{children:n(p,Ge({spacing:"lg"},{children:[n(g,Ge({gutter:"md"},{children:[e(g.Col,Ge({md:6},{children:e(bn,{data:a.data.user})})),e(g.Col,Ge({md:6},{children:e(Bn,{title:a.data.tenant.name,description:a.data.tenant.description,image:a.data.tenant.image,action:{label:"Visit website",link:a.data.tenant.website}})}))]})),e(vn,{data:[{title:"PROBLEMS SOLVED",value:a.data.stats["PROBLEMS SOLVED"].value,diff:a.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:a.data.stats["LESSONS COMPLETED"].value,diff:a.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:a.data.stats["BADGES EARNED"].value,diff:a.data.stats["BADGES EARNED"].diff}]}),e(pn,{onScrollBottom:a.onTimelineScrollBottom,data:a.data.timeline})]}))}))},On=u((function(e){return{header:{position:"sticky",top:0,backgroundColor:"dark"===e.colorScheme?e.colors.dark[7]:e.white,transition:"box-shadow 150ms ease","&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,borderBottom:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[2])}},scrolled:{boxShadow:e.shadows.sm}}})),Tn=function(a){var i,t=a.data,r=On(),o=r.classes,l=r.cx,c=Ce(!1),d=c[0],u=c[1],m=t.map((function(e){return e.value})),p=Math.round(m.reduce((function(e,n){return e+n}))/m.length),g=t.map((function(a){return n("tr",{children:[e("td",{children:a.name}),e("td",{children:a.email}),e("td",{children:a.value}),e("td",{children:a.value>p?e(f,{children:"Above average"}):a.value===p?e(f,Ge({color:"gray"},{children:"Average"})):e(f,Ge({color:"red"},{children:"Below average"}))})]},a.name)}));return e(s,Ge({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n(h,Ge({verticalSpacing:"md",sx:{minWidth:700}},{children:[e("thead",Ge({className:l(o.header,(i={},i[o.scrolled]=d,i))},{children:n("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Email"}),e("th",{children:"Value"}),e("th",{children:"Status"})]})})),e("tbody",{children:g})]}))}))},Gn=function(a){return e(O,Ge({mih:150,p:"lg",withBorder:!0},{children:n(p,{children:[e(g,{children:e(g.Col,Ge({sm:"auto"},{children:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5",mb:0},{children:"Performance History"})),e(D,Ge({label:"Shows group performance per person"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]}))}))}),e(l,Ge({spacing:"sm"},{children:e(S,{placeholder:"Select a metric",value:a.data.metric,onChange:a.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})})),e(Tn,{data:a.data.users})]})}))},Pn=u((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),An=function(a){var i=Pn().theme;return e(O,Ge({p:"lg",withBorder:!0},{children:n(p,{children:[n(g,{children:[e(g.Col,Ge({sm:"auto"},{children:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5",mb:0},{children:"Performance History"})),e(D,Ge({label:"Shows daily increase or decrease across group"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]}))})),e(g.Col,Ge({sm:5},{children:e(S,{placeholder:"Select a metric",value:a.data.metric,onChange:a.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})}))]}),e(Ee,Ge({width:"100%",height:400},{children:n(Ne,Ge({width:730,height:250,data:a.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[e("defs",{children:n("linearGradient",Ge({id:"colorBlue",x1:"0",y1:"0",x2:"0",y2:"1"},{children:[e("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.4}),e("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}))}),e(De,{tick:{fontSize:12,fontFamily:i.fontFamily},dataKey:"name"}),e(Be,{tick:{fontSize:12,fontFamily:i.fontFamily}}),e(Le,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),e(Oe,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:i.fontFamily},labelStyle:{fontSize:12,fontFamily:i.fontFamily}}),e(Te,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},Rn=u((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),Mn=function(a){var i=a.data,t=Rn().classes,r=i.map((function(a){var i=a.diff>0?he:ue;return n(O,Ge({withBorder:!0,p:"md",radius:"md"},{children:[n(l,Ge({position:"apart"},{children:[n("div",{children:[e(d,Ge({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:t.label},{children:a.title})),e(d,Ge({weight:700,size:"xl"},{children:a.value.toLocaleString()}))]}),e(W,Ge({color:"gray",variant:"light",sx:function(e){return{color:a.diff>0?e.colors.teal[6]:e.colors.red[6]}},size:38,radius:"md"},{children:e(i,{size:28,stroke:1.5})}))]})),n(d,Ge({color:"dimmed",size:"sm",mt:"md"},{children:[n(d,Ge({component:"span",color:a.diff>0?"teal":"red",weight:700},{children:[a.diff,"%"]}))," ",a.diff>0?"increase":"decrease"," compared to last period"]}))]}),a.title)}));return e("div",Ge({className:t.root},{children:e(F,Ge({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:r}))}))},Wn=function(i){return n(a,{children:[e(Mn,{data:[{title:"PROBLEMS SOLVED",value:i.data.stats["PROBLEMS SOLVED"].value,diff:i.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:i.data.stats["LESSONS COMPLETED"].value,diff:i.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:i.data.stats["BADGES EARNED"].value,diff:i.data.stats["BADGES EARNED"].diff}]}),e(An,{data:i.data.areaChart,onMetricChange:i.onMetricChange})]})},Fn=[{value:"Overview"},{value:"Breakdown"}],Un=function(a){var i=In(a.data.breakdown,a.onBreakdownMetricChange),t=jn(a.data.dateRange,a.onDateRangeChange),r=Hn(a.data.groups,a.onGroupChange),o=_n(a.data.overview,a.onOverviewMetricChange),l=qn(a.data.tab,a.onTabChange);return e(m,Ge({size:"lg",py:"xl"},{children:n(p,{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(C,Ge({size:"h3"},{children:"Dashboard"})),e(d,Ge({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),e(g.Col,Ge({sm:2.5},{children:e(S,{placeholder:"Select a group",nothingFound:"No options",value:r.select,onChange:r.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})})),e(g.Col,Ge({sm:"auto"},{children:e(ze,{placeholder:"Select a date",allowSingleDateInRange:!0,value:t.value,onChange:t.onChange,icon:e(me,{size:16})})}))]}),n(p,{children:[e(Re,{data:Fn,value:l.value,onChange:l.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(Vn,Ge({},a,{data:Ge(Ge({},a.data),{overview:o.data,breakdown:i.data}),active:l.value,onBreakdownMetricChange:i.onMetricChange,onOverviewMetricChange:o.onMetricChange}))]}))]})]})}))},Vn=function(n){if(0===n.data.overview.stats["PROBLEMS SOLVED"].value)return e(He,{data:{title:"No data for period",icon:"dashboard",description:"We haven't received any data yet for your group during this period. Check back later once progress has been made."}});switch(n.active){case"Overview":return e(Wn,{data:n.data.overview,onMetricChange:n.onOverviewMetricChange});case"Breakdown":return e(Gn,{data:n.data.breakdown,onMetricChange:n.onBreakdownMetricChange});default:return null}},In=function(e,n){var a=ve.useState(e.metric),i=a[0],t=a[1];return{data:Ge(Ge({},e),{metric:i}),onMetricChange:function(e){t(e),n&&n(e)}}},jn=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},Hn=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},_n=function(e,n){var a=ve.useState(e.areaChart.metric),i=a[0],t=a[1];return{data:Ge(Ge({},e),{areaChart:Ge(Ge({},e.areaChart),{metric:i})}),onMetricChange:function(e){t(e),n&&n(e)}}},qn=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},Yn=u((function(e){var n,a,i,t,r,o;return{footer:{paddingTop:2*e.spacing.xl,paddingBottom:2*e.spacing.xl,paddingLeft:3*e.spacing.xl,backgroundColor:"dark"===e.colorScheme?e.colors.dark[6]:e.colors.gray[0],borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[2])},logo:(n={maxWidth:200},n[e.fn.smallerThan("sm")]={display:"flex",flexDirection:"column",alignItems:"center"},n),description:(a={marginTop:5},a[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs,textAlign:"center"},a),inner:(i={display:"flex",justifyContent:"space-between"},i[e.fn.smallerThan("sm")]={flexDirection:"column",alignItems:"center"},i),groups:(t={display:"flex",flexWrap:"wrap"},t[e.fn.smallerThan("sm")]={display:"none"},t),wrapper:{width:160},link:{display:"block",color:"dark"===e.colorScheme?e.colors.dark[1]:e.colors.gray[6],fontSize:e.fontSizes.sm,paddingTop:3,paddingBottom:3,"&:hover":{textDecoration:"underline"}},title:{fontSize:e.fontSizes.md,fontWeight:700,fontFamily:"Greycliff CF, ".concat(e.fontFamily),marginBottom:e.spacing.xs/2,color:"dark"===e.colorScheme?e.white:e.black},afterFooter:(r={display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:e.spacing.xl,paddingTop:e.spacing.xl,paddingBottom:e.spacing.xl,borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[4]:e.colors.gray[2])},r[e.fn.smallerThan("sm")]={flexDirection:"column"},r),social:(o={},o[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},o)}})),Kn=function(a){var i=Yn().classes,t=$n(a.data.account,a.onAccountChange),r=Qn(a.data.navbar.active,(function(e){if("Change account"===e)t.setChangeModalOpen(!0);a.onNavbarClick&&a.onNavbarClick(e)}));return n(U,Ge({padding:"xs",navbar:e(dn,{active:r.active,onClick:r.onClick},r.key),footer:n("footer",Ge({className:i.footer},{children:[n(m,Ge({className:i.inner},{children:[n("div",Ge({className:i.logo},{children:[n(l,Ge({spacing:"xs"},{children:[e("div",Ge({style:{width:15}},{children:e(w,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),e(C,Ge({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),e(d,Ge({size:"xs",color:"dimmed",className:i.description},{children:"We connect students to powerful civic learning experiences."}))]})),e("div",Ge({className:i.groups},{children:n("div",Ge({className:i.wrapper},{children:[e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),e(d,Ge({className:i.link,component:"a",href:"https://localcivics.notion.site/Help-Center-b52300f587b64fc0a61f512686e7626d",target:"_blank"},{children:"FAQ"}))]}))}))]})),n(m,Ge({className:i.afterFooter},{children:[n(d,Ge({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n(l,Ge({spacing:0,className:i.social,position:"right",noWrap:!0},{children:[e(v,Ge({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:e(pe,{size:18,stroke:1.5})})),e(v,Ge({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:e(ge,{size:18,stroke:1.5})})),e(v,Ge({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:e(fe,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[n("div",Ge({style:{position:"relative"}},{children:[a.data.loading&&e(N,Ge({style:{height:400}},{children:e(V,{})})),!a.data.loading&&e(Zn,Ge({},a,{active:r.active}))]})),e(tn,{data:t.data,onChange:t.onAccountChange,onClose:function(){return t.setChangeModalOpen(!1)}})]}))},$n=function(e,n){var a=Ce(!e.hidden),i=a[0],t=a[1],r=Ce(e.active),o=r[0],l=r[1];return{data:Ge(Ge({},e),{active:o,hidden:!i}),setChangeModalOpen:t,onAccountChange:function(e){l(e),t(!1),n&&n(e)}}},Qn=function(e,n){var a=Ce(e||"Home"),i=a[0],t=a[1];return{key:i,active:i,onClick:function(e){var a;i!==e&&(a=e,-1===cn.indexOf(a)&&t(e),n&&n(e))}}},Zn=function(n){switch(n.active){case"Dashboard":return e(Un,{data:n.data.dashboard,onBreakdownMetricChange:n.onDashboardBreakdownMetricChange,onDateRangeChange:n.onDashboardDateRangeChange,onGroupChange:n.onDashboardGroupChange,onOverviewMetricChange:n.onDashboardOverviewMetricChange,onTabChange:n.onDashboardTabChange});case"Home":return e(Ln,{data:n.data.home,onTimelineScrollBottom:n.onHomeTimelineScrollBottom});case"Groups":return e(Nn,{data:n.data.groups,onCreateGroup:n.onCreateGroup,onCreateGroupUsers:n.onCreateGroupUsers,onDeleteGroup:n.onDeleteGroup,onDeleteGroupUser:n.onDeleteGroupUser,onEditGroup:n.onEditGroup,onViewGroupUser:n.onViewGroupUser,onGroupUserRoleChange:n.onGroupUserRoleChange,onTimelineScrollBottom:n.onGroupUserTimelineScrollBottom});case"Lessons":return e(an,{data:n.data.lessons,onAutocompleteChange:n.onLessonAutocompleteChange,onGroupChange:n.onLessonGroupChange,onLessonClick:n.onLessonClick,onPreview:n.onLessonPreview,onTabChange:n.onLessonTabChange,onUserClick:n.onLessonUserClick});case"Badges":return e(Ye,{data:n.data.badges,onAutocompleteChange:n.onBadgeAutocompleteChange,onGroupChange:n.onBadgeGroupChange,onBadgeClick:n.onBadgeClick,onPreview:n.onBadgePreview,onTabChange:n.onBadgeTabChange,onUserClick:n.onBadgeUserClick});default:return null}};export{Kn as Mgmt,Ae as MgmtProvider,tn as SwitchAccount};
1
+ import{jsx as e,jsxs as n,Fragment as a}from"react/jsx-runtime";import{createEmotionCache as i,MantineProvider as t,Tabs as r,UnstyledButton as o,Group as l,Avatar as c,Text as d,ScrollArea as s,Table as h,createStyles as u,Container as m,Stack as p,Grid as g,Badge as f,ActionIcon as v,Title as C,Button as b,Divider as k,Select as S,LoadingOverlay as y,Image as w,Autocomplete as x,Modal as z,Navbar as E,Center as N,Tooltip as D,Anchor as B,Timeline as L,Paper as O,Blockquote as T,Drawer as G,TextInput as A,Menu as P,Card as R,Overlay as M,ThemeIcon as W,SimpleGrid as F,AppShell as U,Loader as V}from"@mantine/core";import{ModalsProvider as I,openConfirmModal as j}from"@mantine/modals";import{NotificationsProvider as H}from"@mantine/notifications";export{showNotification,updateNotification}from"@mantine/notifications";import{IconArrowLeft as _,IconCategory2 as q,IconSwitchHorizontal as Y,IconLogout as K,IconHome2 as $,IconGauge as Q,IconAlbum as Z,IconLambda as J,IconBadges as X,IconSchool as ee,IconActivityHeartbeat as ne,IconTimelineEvent as ae,IconTrash as ie,IconPlaylistAdd as te,IconDownload as re,IconX as oe,IconCloudUpload as le,IconUsers as ce,IconDots as de,IconInfoCircle as se,IconArrowUpRight as he,IconArrowDownRight as ue,IconCalendar as me,IconBrandInstagram as pe,IconBrandLinkedin as ge,IconBrandFacebook as fe}from"@tabler/icons";import*as ve from"react";import{useState as Ce,createElement as be,useRef as ke}from"react";import{useForm as Se}from"@mantine/form";import{Dropzone as ye,MIME_TYPES as we}from"@mantine/dropzone";import*as xe from"papaparse";import{DateRangePicker as ze}from"@mantine/dates";import{ResponsiveContainer as Ee,AreaChart as Ne,XAxis as De,YAxis as Be,CartesianGrid as Le,Tooltip as Oe,Area as Te}from"recharts";var Ge=function(){return Ge=Object.assign||function(e){for(var n,a=1,i=arguments.length;a<i;a++)for(var t in n=arguments[a])Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e},Ge.apply(this,arguments)};function Ae(e,n,a){if(a||2===arguments.length)for(var i,t=0,r=n.length;t<r;t++)!i&&t in n||(i||(i=Array.prototype.slice.call(n,0,t)),i[t]=n[t]);return e.concat(i||Array.prototype.slice.call(n))}var Pe=i({key:"mantine",prepend:!1}),Re=function(n){return e(t,Ge({withNormalizeCSS:!0,withGlobalStyles:!0,emotionCache:Pe,theme:{loader:"bars"}},{children:e(H,Ge({limit:n.notificationLimit||5},{children:e(I,{children:n.children})}))}))},Me=function(n){var a,i=null===(a=n.data)||void 0===a?void 0:a.map((function(n){return e(r.Tab,Ge({value:n.value},{children:n.label||n.value}),n.value)}));return e(r,Ge({value:n.value,onTabChange:n.onChange},{children:e(r.List,{children:i})}))};function We(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:n(l,{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Fe=[{value:"Complete"},{value:"Incomplete"}],Ue=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Ve=function(a){var i=Ie(a.data.groups,a.onGroupChange),t=je(a.data.tab,a.onTabChange),r=Ue().classes;return e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Badges"})),n(l,{children:[n(p,Ge({spacing:0},{children:[e(C,Ge({order:2,className:r.title,mt:"md"},{children:a.data.name||"Badge"})),e(d,Ge({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(p,Ge({ml:"auto"},{children:[e(b,Ge({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(k,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(S,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Me,{data:Fe,value:t.value,onChange:t.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(We,{data:a.data.users,onClick:a.onUserClick})]}))]})]}))}))},Ie=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},je=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},He=u((function(e){var n,a,i;return{wrapper:(n={display:"flex",alignItems:"center",padding:2*e.spacing.xl,borderRadius:e.radius.md,backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white,border:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[3])},n["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={flexDirection:"column-reverse",padding:e.spacing.xl},n),image:(a={maxWidth:"40%"},a["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={maxWidth:"100%"},a),body:(i={paddingRight:4*e.spacing.xl},i["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={paddingRight:0,marginTop:e.spacing.xl},i),title:{color:"dark"===e.colorScheme?e.white:e.black,fontFamily:"Greycliff CF, ".concat(e.fontFamily),lineHeight:1,marginBottom:e.spacing.md},controls:{display:"flex",marginTop:e.spacing.xl},inputWrapper:{width:"100%",flex:"1"},input:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRight:0},control:{borderTopLeftRadius:0,borderBottomLeftRadius:0}}})),_e=function(a){var i=He().classes;return n("div",Ge({className:i.wrapper},{children:[n("div",Ge({className:i.body},{children:[e(C,Ge({className:i.title},{children:a.data.title})),e(d,Ge({size:"sm",color:"dimmed"},{children:a.data.description}))]})),e(w,{src:"https://cdn.localcivics.io/illustrations/".concat(a.data.icon,".svg"),className:i.image})]}))};function qe(a){if(0===a.data.length)return e(_e,{data:{title:"No badges available",icon:"badges",description:"Adjust your search or contact a representative if your expecting results."}});var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:e(l,{children:n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Ye=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Ke=function(a){var i=Ye().classes,t=Ce(a.data.badgeOpen),r=t[0],o=t[1];return r?e(Ve,{data:a.data.badge,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Badges"})),e(C,Ge({order:2,className:i.title,mt:"md"},{children:"Badges and micro-credentials"})),e(d,Ge({color:"dimmed",className:i.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),e(x,{placeholder:"Search for a badge that fits your needs",data:a.data.badges.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(qe,{data:a.data.badges,onClick:function(e){a.onBadgeClick&&a.onBadgeClick(e),o(!0)}})]}))]}))}))};function $e(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:n(l,{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Qe=[{value:"Complete"},{value:"Incomplete"}],Ze=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Je=function(a){var i=Xe(a.data.groups,a.onGroupChange),t=en(a.data.tab,a.onTabChange),r=Ze().classes;return e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Lessons"})),n(l,{children:[n(p,Ge({spacing:0},{children:[e(C,Ge({order:2,className:r.title,mt:"md"},{children:a.data.name||"Lesson"})),e(d,Ge({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(p,Ge({ml:"auto"},{children:[e(b,Ge({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(k,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(S,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Me,{data:Qe,value:t.value,onChange:t.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e($e,{data:a.data.users,onClick:a.onUserClick})]}))]})]}))}))},Xe=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},en=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}};function nn(a){if(0===a.data.length)return e(_e,{data:{title:"No lessons available",icon:"lessons",description:"Adjust your search or contact a representative if your expecting results."}});var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(o,Ge({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return a.onClick&&a.onClick(i)}},{children:e(l,{children:n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.name})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(s.Autosize,Ge({maxHeight:500},{children:e(h,Ge({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var an=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),tn=function(a){var i=an().classes,t=Ce(a.data.lessonOpen),r=t[0],o=t[1];return r?e(Je,{data:a.data.lesson,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Lessons"})),e(C,Ge({order:2,className:i.title,mt:"md"},{children:"Lessons"})),e(d,Ge({color:"dimmed",className:i.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),e(x,{placeholder:"Search for a lesson that fits your needs",data:a.data.lessons.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(nn,{data:a.data.lessons,onClick:function(e){a.onLessonClick&&a.onLessonClick(e),o(!0)}})]}))]}))}))},rn=function(a){var i=Se({initialValues:{active:a.data.active}});return e(z,Ge({centered:!0,opened:!a.data.hidden,onClose:function(){return a.onClose&&a.onClose()},size:"sm",title:e(C,Ge({size:"h5"},{children:"Accounts"}))},{children:n("form",Ge({onSubmit:i.onSubmit((function(){a.onChange&&a.onChange(i.values.active)}))},{children:[e(S,Ge({required:!0,placeholder:"Select an account",defaultValue:a.data.active,data:a.data.accounts.map((function(e){return{value:e.key,label:e.name}}))},i.getInputProps("active"))),e(b,Ge({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},on=u((function(e){return{link:{width:50,height:50,borderRadius:e.radius.md,display:"flex",alignItems:"center",justifyContent:"center",color:"dark"===e.colorScheme?e.colors.dark[0]:e.colors.gray[7],"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[0]}},active:{"&, &:hover":{backgroundColor:e.fn.variant({variant:"light",color:e.primaryColor}).background,color:e.fn.variant({variant:"light",color:e.primaryColor}).color}}}})),ln=[{icon:$,label:"Home"},{icon:Q,label:"Dashboard"},{icon:q,label:"Groups"},{icon:Z,label:"Badges"},{icon:J,label:"Lessons"}],cn=function(n){var a,i=n.icon,t=n.label,r=n.active,l=n.onClick,c=on(),d=c.classes,s=c.cx;return e(D,Ge({label:t,position:"right",transitionDuration:0},{children:e(o,Ge({onClick:l,className:s(d.link,(a={},a[d.active]=r,a))},{children:e(i,{stroke:1.5})}))}))},dn=["Logout","Change account"],sn=function(a){var i=ln.map((function(e){return be(cn,Ge({},e,{key:e.label,active:e.label===a.active,onClick:function(){return a.onClick&&a.onClick(e.label)}}))}));return n(E,Ge({width:{base:80},p:"md"},{children:[e(N,{children:e(c,Ge({color:"blue",radius:"sm"},{children:e("div",Ge({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:e(w,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),e(E.Section,Ge({grow:!0,mt:50},{children:e(p,Ge({justify:"center",spacing:0},{children:i}))})),e(E.Section,{children:n(p,Ge({justify:"center",spacing:0},{children:[e(cn,{icon:Y,label:"Change account",onClick:function(){return a.onClick&&a.onClick("Change account")}}),e(cn,{icon:K,label:"Logout",onClick:function(){return a.onClick&&a.onClick("Logout")}})]}))})]}))},hn=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],un=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function mn(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,a=hn;n<a.length;n++){var i=a[n],t=i.unit,r=i.ms;if(Math.abs(e)>=r||"second"===t)return un.format(Math.round(e/r),t)}return""}(e.getTime()-n.getTime()):""}var pn={BadgeCompleted:e(X,{size:12}),BadgeStarted:e(X,{size:12}),LessonCompleted:e(ee,{size:12}),LessonStarted:e(ee,{size:12}),ProblemSolved:e(ne,{size:12})},gn=function(a){var i,t=ke(null),r=Ce({x:0,y:0}),o=r[0],l=r[1];ve.useEffect((function(){t.current&&o.y===t.current.scrollHeight-t.current.offsetHeight&&a.onScrollBottom&&a.onScrollBottom()}),[o.y]);var c=a.data.map((function(a){var t=a.name.split(/(?=[A-Z])/),r=t[0]===i?"dashed":"solid";i=t[0];var o=a.link?e(B,Ge({color:"dark",unstyled:!0,href:a.link},{children:"".concat(t[0]," ").concat(t[1].toLowerCase())})):"".concat(t[0]," ").concat(t[1].toLowerCase());return n(L.Item,Ge({bullet:fn(a.name),lineVariant:r,title:o},{children:[e(d,Ge({color:"dimmed",size:"sm"},{children:a.description})),e(d,Ge({size:"xs",mt:4},{children:mn(new Date(a.time))}))]}),a.key)}));return e(s.Autosize,Ge({maxHeight:300,onScrollPositionChange:l,viewportRef:t},{children:e(L,Ge({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:c}))}))},fn=function(n){var a=pn[n];return a||e(ae,{size:12})},vn=u((function(e){var n,a;return{root:(n={display:"flex",backgroundImage:"linear-gradient(-60deg, ".concat(e.colors[e.primaryColor][4]," 0%, ").concat(e.colors[e.primaryColor][7]," 100%)"),padding:1.5*e.spacing.xl,borderRadius:e.radius.md},n[e.fn.smallerThan("sm")]={flexDirection:"column"},n),title:{color:e.white,textTransform:"uppercase",fontWeight:700,fontSize:e.fontSizes.sm},count:{color:e.white,fontSize:32,lineHeight:1,fontWeight:700,marginBottom:e.spacing.md,fontFamily:"Greycliff CF, ".concat(e.fontFamily)},description:{color:e.colors[e.primaryColor][0],fontSize:e.fontSizes.sm,marginTop:5},stat:{flex:1,"& + &":(a={paddingLeft:e.spacing.xl,marginLeft:e.spacing.xl,borderLeft:"1px solid ".concat(e.colors[e.primaryColor][3])},a[e.fn.smallerThan("sm")]={paddingLeft:0,marginLeft:0,borderLeft:0,paddingTop:e.spacing.xl,marginTop:e.spacing.xl,borderTop:"1px solid ".concat(e.colors[e.primaryColor][3])},a)}}})),Cn=function(a){var i=a.data,t=vn().classes,r=i.map((function(a){return n("div",Ge({className:t.stat},{children:[e(d,Ge({className:t.count},{children:a.value.toLocaleString()})),e(d,Ge({className:t.title},{children:a.title})),e(d,Ge({className:t.description},{children:"".concat(a.diff,"% ").concat(a.diff<0?"decrease":"increase"," compared to last period")}))]}),a.title)}));return e("div",Ge({className:t.root},{children:r}))},bn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),kn=function(i){var t=bn().classes,r=i.data.givenName?[i.data.givenName,i.data.familyName].join(" ").trim():i.data.email,o=i.data.givenName?i.data.givenName:"Me";return"compact"===i.variant?n(a,{children:[e(C,Ge({className:t.title},{children:r})),e(d,Ge({color:"dimmed",className:t.description,mt:"xs"},{children:i.data.quote}))]}):n(a,{children:[n(O,Ge({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[e(c,{src:i.data.avatar,size:135,radius:120,mx:"auto"}),e(d,Ge({align:"center",size:"lg",weight:500,mt:"md"},{children:r})),n(d,Ge({align:"center",color:"dimmed",size:"sm"},{children:[i.data.email," • ",i.data.job]}))]})),e(T,Ge({mt:"xl",color:"blue",cite:"– ".concat(o)},{children:i.data.quote}))]})},Sn=[{value:"Member",label:"Member"},{value:"Admin",label:"Admin"}];function yn(a){var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(o,Ge({onClick:function(){return a.onViewProfile&&a.onViewProfile(i)}},{children:n(l,Ge({spacing:"sm"},{children:[e(c,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(d,Ge({size:"sm",weight:500},{children:i.givenName&&i.familyName?"".concat(i.givenName," ").concat(i.familyName):i.email})),e(d,Ge({size:"xs",color:"dimmed"},{children:i.email}))]})]}))}))}),e("td",{children:e(S,{data:Ae([],Sn,!0).map((function(e){return i.readonly?Ge(Ge({},e),{disabled:e.value!==i.role}):e})),defaultValue:i.role,variant:"unstyled",onChange:function(e){return!i.readonly&&a.onChangeRole&&a.onChangeRole(i,e)}})}),e("td",{children:i.lastActivity?mn(i.lastActivity):""}),e("td",{children:e(l,Ge({noWrap:!0,spacing:0,position:"right"},{children:!i.readonly&&e(v,Ge({color:"red"},{children:e(ie,{onClick:function(){return j({title:'Delete "'.concat((n=i).givenName&&n.familyName?"".concat(n.givenName," ").concat(n.familyName):n.email,'"?'),centered:!0,children:e(d,Ge({size:"sm"},{children:"Are you sure you want to delete this person? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete",cancel:"No don't delete them"},confirmProps:{color:"red"},onConfirm:function(){return a.onDelete&&a.onDelete(n)}});var n},size:16,stroke:1.5})}))}))})]},i.email)}));return 0===a.data.length?e(_e,{data:{title:"No one in group",icon:"thinking",description:"You don't have any people in this group yet. When your ready, get started by clicking the 'Add people' button above."}}):e(s,{children:n(h,Ge({verticalSpacing:20,sx:{minWidth:700}},{children:[e("thead",{children:n("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Last active"}),e("th",{})]})}),e("tbody",{children:i})]}))})}var wn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600},wrapper:{position:"relative",marginBottom:30},dropzone:{borderWidth:1,paddingBottom:50},icon:{color:"dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[4]},control:{position:"absolute",width:250,left:"calc(50% - 125px)",bottom:-20}}})),xn=function(i){var t=wn().classes,r=Se({initialValues:{key:"",email:"",givenName:"",familyName:"",avatar:"",role:"",readonly:!1,lastActivity:null},validate:{email:function(e){return/^\S+@\S+$/.test(e)&&0===i.data.users.filter((function(n){return n.email===e})).length?null:"Invalid email"}}}),o=Ce(!1),c=o[0],s=o[1],h=Ce(i.data.groupUserHomeOpen),u=h[0],S=h[1];return u?e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(g,{children:n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:function(){return S(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Users"})),e(kn,{variant:"compact",data:i.data.user})]}))}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.user.loading,overlayBlur:2}),n(p,Ge({spacing:"lg"},{children:[e(Cn,{data:[{title:"PROBLEMS SOLVED",value:i.data.stats["PROBLEMS SOLVED"].value,diff:i.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:i.data.stats["LESSONS COMPLETED"].value,diff:i.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:i.data.stats["BADGES EARNED"].value,diff:i.data.stats["BADGES EARNED"].diff}]}),e(gn,{onScrollBottom:i.onTimelineScrollBottom,data:i.data.timeline})]}))]}))]}))})):n(a,{children:[e(G,Ge({opened:c,onClose:function(){return s(!1)},title:e(C,Ge({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n(p,Ge({spacing:"md"},{children:[e(zn,Ge({},i,{close:function(){return s(!1)}})),e(k,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),e("form",Ge({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateUsers&&i.onCreateUsers([e])}))},{children:n(p,{children:[e(A,Ge({withAsterisk:!0,label:"Email",placeholder:"Email"},r.getInputProps("email"))),n(l,Ge({grow:!0},{children:[e(A,Ge({label:"Given name",placeholder:"Given name"},r.getInputProps("givenName"))),e(A,Ge({label:"Family name",placeholder:"Family name"},r.getInputProps("familyName")))]})),e(b,Ge({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",leftSection:e(v,Ge({onClick:i.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(_,{size:14})})),size:"lg"},{children:"Groups"})),e(C,Ge({order:2,className:t.title,mt:"md"},{children:i.data.name||"Group"})),e(d,Ge({color:"dimmed",className:t.description,mt:"sm"},{children:i.data.description||"No description"}))]})),e(g.Col,Ge({sm:"content"},{children:e(b,Ge({onClick:function(){return s(!0)},leftIcon:e(te,{size:14})},{children:"Add people"}))}))]}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.loading,overlayBlur:2}),e(yn,{data:i.data.users,onDelete:i.onDelete,onChangeRole:i.onRoleChange,onViewProfile:function(e){return i.onViewProfile(e).then((function(){S(!0)}))}})]}))]}))}))]})},zn=function(a){var i=wn(),t=i.classes,r=i.theme,o=ve.useRef(null),c=ve.useState(!1),s=c[0],h=c[1],u=ve.useCallback((function(e){h(!0),e.forEach((function(e){xe.parse(e,{download:!0,header:!0,dynamicTyping:!0,skipEmptyLines:!0,worker:!0,complete:function(e){var n=e.data.filter((function(e){return/^\S+@\S+$/.test(e.email)&&0===a.data.users.filter((function(n){return n.email===e.email})).length}));n.length>0&&a.onCreateUsers&&a.onCreateUsers(n),h(!1),a.close()}})}))}),[]);return n("div",Ge({className:t.wrapper},{children:[e(ye,Ge({loading:s,openRef:o,onDrop:u,className:t.dropzone,radius:"md",accept:[we.csv],maxSize:5*Math.pow(1024,2)},{children:n("div",Ge({style:{pointerEvents:"none"}},{children:[n(l,Ge({position:"center"},{children:[e(ye.Accept,{children:e(re,{size:50,color:r.colors[r.primaryColor][6],stroke:1.5})}),e(ye.Reject,{children:e(oe,{size:50,color:r.colors.red[6],stroke:1.5})}),e(ye.Idle,{children:e(le,{size:50,color:"dark"===r.colorScheme?r.colors.dark[0]:r.black,stroke:1.5})})]})),n(d,Ge({align:"center",weight:700,size:"lg",mt:"xl"},{children:[e(ye.Accept,{children:"Drop files here"}),e(ye.Reject,{children:"Csv file less than 5mb"}),e(ye.Idle,{children:"Upload multiple"})]})),n(d,Ge({align:"center",size:"sm",mt:"xs",color:"dimmed"},{children:["Drag'n'drop files here to upload. We can accept only ",e("i",{children:".csv"})," files that are less than 5mb in size."]}))]}))})),e(b,Ge({className:t.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=o.current)||void 0===e?void 0:e.call(o)}},{children:"Select file"}))]}))};function En(a){if(0===a.data.length)return e(_e,{data:{title:"No groups",icon:"groups",description:"You don't have any groups just yet. When your ready, get started by clicking the 'Create group' button above."}});var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(d,Ge({size:14},{children:i.name}))}),e("td",{children:e(d,Ge({size:14},{children:i.description}))}),e("td",{children:n(l,Ge({noWrap:!0,spacing:0,position:"right"},{children:[e(v,Ge({color:"blue",onClick:function(){return a.onEditGroup&&a.onEditGroup(i)},variant:"subtle"},{children:e(ce,{size:16,stroke:1.5})})),n(P,Ge({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[e(P.Target,{children:e(v,{children:e(de,{size:16,stroke:1.5})})}),e(P.Dropdown,{children:e(P.Item,Ge({onClick:function(){return j({title:'Delete "'.concat((n=i).name,'"?'),centered:!0,children:e(d,Ge({size:"sm"},{children:"Are you sure you want to delete this group? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete group",cancel:"No don't delete it"},confirmProps:{color:"red"},onConfirm:function(){return a.onDeleteGroup&&a.onDeleteGroup(n)}});var n},icon:e(ie,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},i.name)}));return e(s.Autosize,Ge({maxHeight:300},{children:n(h,Ge({verticalSpacing:20,sx:{minWidth:700}},{children:[e("thead",{children:n("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Description"}),e("th",{})]})}),e("tbody",{children:i})]}))}))}var Nn=u((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Dn=function(i){var t=Nn().classes,r=Se({initialValues:{key:"",name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),o=Ce(i.data.formOpen),c=o[0],s=o[1],h=Ce(i.data.groupOpen),u=h[0],k=h[1];return u?e(xn,{data:i.data.group,onBackClick:function(){return k(!1)},onCreateUsers:i.onCreateGroupUsers,onDelete:i.onDeleteGroupUser,onViewProfile:i.onViewGroupUser,onRoleChange:i.onGroupUserRoleChange,onTimelineScrollBottom:i.onTimelineScrollBottom}):n(a,{children:[e(G,Ge({opened:c,onClose:function(){return s(!1)},title:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5"},{children:"Create a group"})),e(D,Ge({label:"Groups settings cannot be modified once created"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n("form",Ge({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateGroup&&i.onCreateGroup(e)}))},{children:[n(p,{children:[e(A,Ge({withAsterisk:!0,label:"Name",placeholder:"Group name"},r.getInputProps("name"))),e(A,Ge({label:"Description",placeholder:"A group for my first period class"},r.getInputProps("description")))]}),e(b,Ge({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),e(m,Ge({size:"lg",py:"xl"},{children:n(p,Ge({spacing:"md"},{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(f,Ge({variant:"filled",size:"lg"},{children:"Groups"})),e(C,Ge({order:2,className:t.title,mt:"md"},{children:"Organize people into groups"})),e(d,Ge({color:"dimmed",className:t.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),e(g.Col,Ge({sm:"content"},{children:e(b,Ge({onClick:function(){return s(!0)},leftIcon:e(te,{size:14})},{children:"Create group"}))}))]}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:i.data.loading,overlayBlur:2}),e(En,{data:i.data.groups,onDeleteGroup:i.onDeleteGroup,onEditGroup:function(e){i.onEditGroup&&i.onEditGroup(e),k(!0)}})]}))]}))}))]})},Bn=u((function(e){return{card:{height:240,backgroundSize:"cover",backgroundPosition:"center"},content:{position:"absolute",padding:e.spacing.xl,zIndex:1,top:0,bottom:0,right:0,left:0},action:{position:"absolute",bottom:e.spacing.xl,right:e.spacing.xl},title:{color:e.white,marginBottom:e.spacing.xs/2},description:{color:e.white,maxWidth:220}}})),Ln=function(a){var i=a.title,t=a.description,r=a.image,o=a.action,l=a.style,c=a.className,s=function(e,n){var a={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(a[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(i=Object.getOwnPropertySymbols(e);t<i.length;t++)n.indexOf(i[t])<0&&Object.prototype.propertyIsEnumerable.call(e,i[t])&&(a[i[t]]=e[i[t]])}return a}(a,["title","description","image","action","style","className"]),h=Bn(),u=h.classes,m=h.cx,p=h.theme;return n(R,Ge({radius:"md",style:Ge({backgroundImage:"url(".concat(r,")")},l),className:m(u.card,c)},s,{children:[e(M,{gradient:"linear-gradient(105deg, ".concat(p.black," 20%, #312f2f 50%, ").concat(p.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n("div",Ge({className:u.content},{children:[e(d,Ge({size:"lg",weight:700,className:u.title},{children:i})),e(d,Ge({size:"sm",className:u.description},{children:t})),e(b,Ge({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},On=function(a){return e(m,Ge({size:"lg"},{children:n(p,Ge({spacing:"lg"},{children:[n(g,Ge({gutter:"md"},{children:[e(g.Col,Ge({md:6},{children:e(kn,{data:a.data.user})})),e(g.Col,Ge({md:6},{children:e(Ln,{title:a.data.tenant.name,description:a.data.tenant.description,image:a.data.tenant.image,action:{label:"Visit website",link:a.data.tenant.website}})}))]})),e(Cn,{data:[{title:"PROBLEMS SOLVED",value:a.data.stats["PROBLEMS SOLVED"].value,diff:a.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:a.data.stats["LESSONS COMPLETED"].value,diff:a.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:a.data.stats["BADGES EARNED"].value,diff:a.data.stats["BADGES EARNED"].diff}]}),e(gn,{onScrollBottom:a.onTimelineScrollBottom,data:a.data.timeline})]}))}))},Tn=u((function(e){return{header:{position:"sticky",top:0,backgroundColor:"dark"===e.colorScheme?e.colors.dark[7]:e.white,transition:"box-shadow 150ms ease","&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,borderBottom:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[2])}},scrolled:{boxShadow:e.shadows.sm}}})),Gn=function(a){var i,t=a.data,r=Tn(),o=r.classes,l=r.cx,c=Ce(!1),d=c[0],u=c[1],m=t.map((function(e){return e.value})),p=Math.round(m.reduce((function(e,n){return e+n}))/m.length),g=t.map((function(a){return n("tr",{children:[e("td",{children:a.name}),e("td",{children:a.email}),e("td",{children:a.value}),e("td",{children:a.value>p?e(f,{children:"Above average"}):a.value===p?e(f,Ge({color:"gray"},{children:"Average"})):e(f,Ge({color:"red"},{children:"Below average"}))})]},a.name)}));return e(s,Ge({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n(h,Ge({verticalSpacing:"md",sx:{minWidth:700}},{children:[e("thead",Ge({className:l(o.header,(i={},i[o.scrolled]=d,i))},{children:n("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Email"}),e("th",{children:"Value"}),e("th",{children:"Status"})]})})),e("tbody",{children:g})]}))}))},An=function(a){return e(O,Ge({mih:150,p:"lg",withBorder:!0},{children:n(p,{children:[e(g,{children:e(g.Col,Ge({sm:"auto"},{children:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5",mb:0},{children:"Performance History"})),e(D,Ge({label:"Shows group performance per person"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]}))}))}),e(l,Ge({spacing:"sm"},{children:e(S,{placeholder:"Select a metric",value:a.data.metric,onChange:a.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})})),e(Gn,{data:a.data.users})]})}))},Pn=u((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),Rn=function(a){var i=Pn().theme;return e(O,Ge({p:"lg",withBorder:!0},{children:n(p,{children:[n(g,{children:[e(g.Col,Ge({sm:"auto"},{children:n(l,Ge({spacing:0},{children:[e(C,Ge({size:"h5",mb:0},{children:"Performance History"})),e(D,Ge({label:"Shows daily increase or decrease across group"},{children:e(v,{children:e(se,{color:"#3b82f6",size:14})})}))]}))})),e(g.Col,Ge({sm:5},{children:e(S,{placeholder:"Select a metric",value:a.data.metric,onChange:a.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})}))]}),e(Ee,Ge({width:"100%",height:400},{children:n(Ne,Ge({width:730,height:250,data:a.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[e("defs",{children:n("linearGradient",Ge({id:"colorBlue",x1:"0",y1:"0",x2:"0",y2:"1"},{children:[e("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.4}),e("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}))}),e(De,{tick:{fontSize:12,fontFamily:i.fontFamily},dataKey:"name"}),e(Be,{tick:{fontSize:12,fontFamily:i.fontFamily}}),e(Le,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),e(Oe,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:i.fontFamily},labelStyle:{fontSize:12,fontFamily:i.fontFamily}}),e(Te,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},Mn=u((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),Wn=function(a){var i=a.data,t=Mn().classes,r=i.map((function(a){var i=a.diff>0?he:ue;return n(O,Ge({withBorder:!0,p:"md",radius:"md"},{children:[n(l,Ge({position:"apart"},{children:[n("div",{children:[e(d,Ge({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:t.label},{children:a.title})),e(d,Ge({weight:700,size:"xl"},{children:a.value.toLocaleString()}))]}),e(W,Ge({color:"gray",variant:"light",sx:function(e){return{color:a.diff>0?e.colors.teal[6]:e.colors.red[6]}},size:38,radius:"md"},{children:e(i,{size:28,stroke:1.5})}))]})),n(d,Ge({color:"dimmed",size:"sm",mt:"md"},{children:[n(d,Ge({component:"span",color:a.diff>0?"teal":"red",weight:700},{children:[a.diff,"%"]}))," ",a.diff>0?"increase":"decrease"," compared to last period"]}))]}),a.title)}));return e("div",Ge({className:t.root},{children:e(F,Ge({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:r}))}))},Fn=function(i){return n(a,{children:[e(Wn,{data:[{title:"PROBLEMS SOLVED",value:i.data.stats["PROBLEMS SOLVED"].value,diff:i.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:i.data.stats["LESSONS COMPLETED"].value,diff:i.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:i.data.stats["BADGES EARNED"].value,diff:i.data.stats["BADGES EARNED"].diff}]}),e(Rn,{data:i.data.areaChart,onMetricChange:i.onMetricChange})]})},Un=[{value:"Overview"},{value:"Breakdown"}],Vn=function(a){var i=jn(a.data.breakdown,a.onBreakdownMetricChange),t=Hn(a.data.dateRange,a.onDateRangeChange),r=_n(a.data.groups,a.onGroupChange),o=qn(a.data.overview,a.onOverviewMetricChange),l=Yn(a.data.tab,a.onTabChange);return e(m,Ge({size:"lg",py:"xl"},{children:n(p,{children:[n(g,{children:[n(g.Col,Ge({sm:"auto"},{children:[e(C,Ge({size:"h3"},{children:"Dashboard"})),e(d,Ge({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),e(g.Col,Ge({sm:2.5},{children:e(S,{placeholder:"Select a group",nothingFound:"No options",value:r.select,onChange:r.onSelectChange,icon:e(q,{}),data:a.data.groups.map((function(e){return e.name}))})})),e(g.Col,Ge({sm:"auto"},{children:e(ze,{placeholder:"Select a date",allowSingleDateInRange:!0,value:t.value,onChange:t.onChange,icon:e(me,{size:16})})}))]}),n(p,{children:[e(Me,{data:Un,value:l.value,onChange:l.onChange}),n("div",Ge({style:{position:"relative"}},{children:[e(y,{visible:a.data.loading,overlayBlur:2}),e(In,Ge({},a,{data:Ge(Ge({},a.data),{overview:o.data,breakdown:i.data}),active:l.value,onBreakdownMetricChange:i.onMetricChange,onOverviewMetricChange:o.onMetricChange}))]}))]})]})}))},In=function(n){if(0===n.data.overview.stats["PROBLEMS SOLVED"].value)return e(_e,{data:{title:"No data for period",icon:"dashboard",description:"We haven't received any data yet for your group during this period. Check back later once progress has been made."}});switch(n.active){case"Overview":return e(Fn,{data:n.data.overview,onMetricChange:n.onOverviewMetricChange});case"Breakdown":return e(An,{data:n.data.breakdown,onMetricChange:n.onBreakdownMetricChange});default:return null}},jn=function(e,n){var a=ve.useState(e.metric),i=a[0],t=a[1];return{data:Ge(Ge({},e),{metric:i}),onMetricChange:function(e){t(e),n&&n(e)}}},Hn=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},_n=function(e,n){var a=e.filter((function(e){return e.active})),i=ve.useState(a.length>0?a[0].name:null),t=i[0],r=i[1];return{select:t,onSelectChange:function(e){r(e),n&&n(e)}}},qn=function(e,n){var a=ve.useState(e.areaChart.metric),i=a[0],t=a[1];return{data:Ge(Ge({},e),{areaChart:Ge(Ge({},e.areaChart),{metric:i})}),onMetricChange:function(e){t(e),n&&n(e)}}},Yn=function(e,n){var a=ve.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},Kn=u((function(e){var n,a,i,t,r,o;return{footer:{paddingTop:2*e.spacing.xl,paddingBottom:2*e.spacing.xl,paddingLeft:3*e.spacing.xl,backgroundColor:"dark"===e.colorScheme?e.colors.dark[6]:e.colors.gray[0],borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[2])},logo:(n={maxWidth:200},n[e.fn.smallerThan("sm")]={display:"flex",flexDirection:"column",alignItems:"center"},n),description:(a={marginTop:5},a[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs,textAlign:"center"},a),inner:(i={display:"flex",justifyContent:"space-between"},i[e.fn.smallerThan("sm")]={flexDirection:"column",alignItems:"center"},i),groups:(t={display:"flex",flexWrap:"wrap"},t[e.fn.smallerThan("sm")]={display:"none"},t),wrapper:{width:160},link:{display:"block",color:"dark"===e.colorScheme?e.colors.dark[1]:e.colors.gray[6],fontSize:e.fontSizes.sm,paddingTop:3,paddingBottom:3,"&:hover":{textDecoration:"underline"}},title:{fontSize:e.fontSizes.md,fontWeight:700,fontFamily:"Greycliff CF, ".concat(e.fontFamily),marginBottom:e.spacing.xs/2,color:"dark"===e.colorScheme?e.white:e.black},afterFooter:(r={display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:e.spacing.xl,paddingTop:e.spacing.xl,paddingBottom:e.spacing.xl,borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[4]:e.colors.gray[2])},r[e.fn.smallerThan("sm")]={flexDirection:"column"},r),social:(o={},o[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},o)}})),$n=function(a){var i=Kn().classes,t=Qn(a.data.account,a.onAccountChange),r=Zn(a.data.navbar.active,(function(e){if("Change account"===e)t.setChangeModalOpen(!0);a.onNavbarClick&&a.onNavbarClick(e)}));return n(U,Ge({padding:"xs",navbar:e(sn,{active:r.active,onClick:r.onClick},r.key),footer:n("footer",Ge({className:i.footer},{children:[n(m,Ge({className:i.inner},{children:[n("div",Ge({className:i.logo},{children:[n(l,Ge({spacing:"xs"},{children:[e("div",Ge({style:{width:15}},{children:e(w,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),e(C,Ge({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),e(d,Ge({size:"xs",color:"dimmed",className:i.description},{children:"We connect students to powerful civic learning experiences."}))]})),e("div",Ge({className:i.groups},{children:n("div",Ge({className:i.wrapper},{children:[e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),e(d,Ge({className:i.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),e(d,Ge({className:i.link,component:"a",href:"https://localcivics.notion.site/Help-Center-b52300f587b64fc0a61f512686e7626d",target:"_blank"},{children:"FAQ"}))]}))}))]})),n(m,Ge({className:i.afterFooter},{children:[n(d,Ge({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n(l,Ge({spacing:0,className:i.social,position:"right",noWrap:!0},{children:[e(v,Ge({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:e(pe,{size:18,stroke:1.5})})),e(v,Ge({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:e(ge,{size:18,stroke:1.5})})),e(v,Ge({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:e(fe,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[n("div",Ge({style:{position:"relative"}},{children:[a.data.loading&&e(N,Ge({style:{height:400}},{children:e(V,{})})),!a.data.loading&&e(Jn,Ge({},a,{active:r.active}))]})),e(rn,{data:t.data,onChange:t.onAccountChange,onClose:function(){return t.setChangeModalOpen(!1)}})]}))},Qn=function(e,n){var a=Ce(!e.hidden),i=a[0],t=a[1],r=Ce(e.active),o=r[0],l=r[1];return{data:Ge(Ge({},e),{active:o,hidden:!i}),setChangeModalOpen:t,onAccountChange:function(e){l(e),t(!1),n&&n(e)}}},Zn=function(e,n){var a=Ce(e||"Home"),i=a[0],t=a[1];return{key:i,active:i,onClick:function(e){var a;i!==e&&(a=e,-1===dn.indexOf(a)&&t(e),n&&n(e))}}},Jn=function(n){switch(n.active){case"Dashboard":return e(Vn,{data:n.data.dashboard,onBreakdownMetricChange:n.onDashboardBreakdownMetricChange,onDateRangeChange:n.onDashboardDateRangeChange,onGroupChange:n.onDashboardGroupChange,onOverviewMetricChange:n.onDashboardOverviewMetricChange,onTabChange:n.onDashboardTabChange});case"Home":return e(On,{data:n.data.home,onTimelineScrollBottom:n.onHomeTimelineScrollBottom});case"Groups":return e(Dn,{data:n.data.groups,onCreateGroup:n.onCreateGroup,onCreateGroupUsers:n.onCreateGroupUsers,onDeleteGroup:n.onDeleteGroup,onDeleteGroupUser:n.onDeleteGroupUser,onEditGroup:n.onEditGroup,onViewGroupUser:n.onViewGroupUser,onGroupUserRoleChange:n.onGroupUserRoleChange,onTimelineScrollBottom:n.onGroupUserTimelineScrollBottom});case"Lessons":return e(tn,{data:n.data.lessons,onAutocompleteChange:n.onLessonAutocompleteChange,onGroupChange:n.onLessonGroupChange,onLessonClick:n.onLessonClick,onPreview:n.onLessonPreview,onTabChange:n.onLessonTabChange,onUserClick:n.onLessonUserClick});case"Badges":return e(Ke,{data:n.data.badges,onAutocompleteChange:n.onBadgeAutocompleteChange,onGroupChange:n.onBadgeGroupChange,onBadgeClick:n.onBadgeClick,onPreview:n.onBadgePreview,onTabChange:n.onBadgeTabChange,onUserClick:n.onBadgeUserClick});default:return null}};export{$n as Mgmt,Re as MgmtProvider,rn as SwitchAccount};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react/jsx-runtime"),require("@mantine/core"),require("@mantine/modals"),require("@mantine/notifications"),require("@tabler/icons"),require("react"),require("@mantine/form"),require("@mantine/dropzone"),require("papaparse"),require("@mantine/dates"),require("recharts")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@mantine/core","@mantine/modals","@mantine/notifications","@tabler/icons","react","@mantine/form","@mantine/dropzone","papaparse","@mantine/dates","recharts"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).components={},e.ReactJSXRuntime,e.MantineCore,e.MantineModals,e.MantineNotifications,e.TablerIcons,e.React,e.MantineForm,e.MantineDropzone,e.Papaparse,e.MantineDates,e.Recharts)}(this,(function(e,n,t,a,i,r,o,s,l,c,d,u){"use strict";function h(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var m=h(o),x=h(c),p=function(){return p=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},p.apply(this,arguments)};var g=t.createEmotionCache({key:"mantine",prepend:!1}),f=function(e){var a,i=null===(a=e.data)||void 0===a?void 0:a.map((function(e){return n.jsx(t.Tabs.Tab,p({value:e.value},{children:e.label||e.value}),e.value)}));return n.jsx(t.Tabs,p({value:e.value,onTabChange:e.onChange},{children:n.jsx(t.Tabs.List,{children:i})}))};function j(e){var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsxs(t.Group,{children:[n.jsx(t.Avatar,{size:40,src:a.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.email}))]})]})}))})},a.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var v=[{value:"Complete"},{value:"Incomplete"}],C=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),S=function(e){var a=b(e.data.groups,e.onGroupChange),i=y(e.data.tab,e.onTabChange),o=C().classes;return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(r.IconArrowLeft,{size:14})})),size:"lg"},{children:"Badges"})),n.jsxs(t.Group,{children:[n.jsxs(t.Stack,p({spacing:0},{children:[n.jsx(t.Title,p({order:2,className:o.title,mt:"md"},{children:e.data.name||"Badge"})),n.jsx(t.Text,p({color:"dimmed",className:o.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsxs(t.Stack,p({ml:"auto"},{children:[n.jsx(t.Button,p({variant:"gradient",onClick:function(){return e.onPreview&&e.onPreview(e.data)}},{children:"Preview"})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),n.jsx(t.Select,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:a.select,onChange:a.onSelectChange,icon:n.jsx(r.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(f,{data:v,value:i.value,onChange:i.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(j,{data:e.data.users,onClick:e.onUserClick})]}))]})]}))}))},b=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),i=a[0],r=a[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},y=function(e,n){var t=m.useState(e),a=t[0],i=t[1];return{value:a,onChange:function(e){i(e),n&&n(e)}}},k=t.createStyles((function(e){var n,t,a;return{wrapper:(n={display:"flex",alignItems:"center",padding:2*e.spacing.xl,borderRadius:e.radius.md,backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white,border:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[3])},n["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={flexDirection:"column-reverse",padding:e.spacing.xl},n),image:(t={maxWidth:"40%"},t["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={maxWidth:"100%"},t),body:(a={paddingRight:4*e.spacing.xl},a["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={paddingRight:0,marginTop:e.spacing.xl},a),title:{color:"dark"===e.colorScheme?e.white:e.black,fontFamily:"Greycliff CF, ".concat(e.fontFamily),lineHeight:1,marginBottom:e.spacing.md},controls:{display:"flex",marginTop:e.spacing.xl},inputWrapper:{width:"100%",flex:"1"},input:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRight:0},control:{borderTopLeftRadius:0,borderBottomLeftRadius:0}}})),T=function(e){var a=k().classes;return n.jsxs("div",p({className:a.wrapper},{children:[n.jsxs("div",p({className:a.body},{children:[n.jsx(t.Title,p({className:a.title},{children:e.data.title})),n.jsx(t.Text,p({size:"sm",color:"dimmed"},{children:e.data.description}))]})),n.jsx(t.Image,{src:"https://cdn.localcivics.io/illustrations/".concat(e.data.icon,".svg"),className:a.image})]}))};function w(e){if(0===e.data.length)return n.jsx(T,{data:{title:"No badges available",icon:"badges",description:"Adjust your search or contact a representative if your expecting results."}});var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsx(t.Group,{children:n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.description}))]})})}))})},a.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var z=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),B=function(e){var a=z().classes,i=o.useState(e.data.badgeOpen),r=i[0],s=i[1];return r?n.jsx(S,{data:e.data.badge,onBackClick:function(){return s(!1)},onGroupChange:e.onGroupChange,onTabChange:e.onTabChange,onUserClick:e.onUserClick,onPreview:e.onPreview}):n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Badges"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Badges and micro-credentials"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),n.jsx(t.Autocomplete,{placeholder:"Search for a badge that fits your needs",data:e.data.badges.map((function(e){return e.name})),onChange:e.onAutocompleteChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(w,{data:e.data.badges,onClick:function(n){e.onBadgeClick&&e.onBadgeClick(n),s(!0)}})]}))]}))}))};function E(e){var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsxs(t.Group,{children:[n.jsx(t.Avatar,{size:40,src:a.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.email}))]})]})}))})},a.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var G=[{value:"Complete"},{value:"Incomplete"}],N=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),D=function(e){var a=A(e.data.groups,e.onGroupChange),i=L(e.data.tab,e.onTabChange),o=N().classes;return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(r.IconArrowLeft,{size:14})})),size:"lg"},{children:"Lessons"})),n.jsxs(t.Group,{children:[n.jsxs(t.Stack,p({spacing:0},{children:[n.jsx(t.Title,p({order:2,className:o.title,mt:"md"},{children:e.data.name||"Lesson"})),n.jsx(t.Text,p({color:"dimmed",className:o.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsxs(t.Stack,p({ml:"auto"},{children:[n.jsx(t.Button,p({variant:"gradient",onClick:function(){return e.onPreview&&e.onPreview(e.data)}},{children:"Preview"})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),n.jsx(t.Select,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:a.select,onChange:a.onSelectChange,icon:n.jsx(r.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(f,{data:G,value:i.value,onChange:i.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(E,{data:e.data.users,onClick:e.onUserClick})]}))]})]}))}))},A=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),i=a[0],r=a[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},L=function(e,n){var t=m.useState(e),a=t[0],i=t[1];return{value:a,onChange:function(e){i(e),n&&n(e)}}};function O(e){if(0===e.data.length)return n.jsx(T,{data:{title:"No lessons available",icon:"lessons",description:"Adjust your search or contact a representative if your expecting results."}});var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsx(t.Group,{children:n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.description}))]})})}))})},a.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var I=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),P=function(e){var a=I().classes,i=o.useState(e.data.lessonOpen),r=i[0],s=i[1];return r?n.jsx(D,{data:e.data.lesson,onBackClick:function(){return s(!1)},onGroupChange:e.onGroupChange,onTabChange:e.onTabChange,onUserClick:e.onUserClick,onPreview:e.onPreview}):n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Lessons"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Lessons"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),n.jsx(t.Autocomplete,{placeholder:"Search for a lesson that fits your needs",data:e.data.lessons.map((function(e){return e.name})),onChange:e.onAutocompleteChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(O,{data:e.data.lessons,onClick:function(n){e.onLessonClick&&e.onLessonClick(n),s(!0)}})]}))]}))}))},M=function(e){var a=s.useForm({initialValues:{active:e.data.active}});return n.jsx(t.Modal,p({centered:!0,opened:!e.data.hidden,onClose:function(){return e.onClose&&e.onClose()},size:"sm",title:n.jsx(t.Title,p({size:"h5"},{children:"Accounts"}))},{children:n.jsxs("form",p({onSubmit:a.onSubmit((function(){e.onChange&&e.onChange(a.values.active)}))},{children:[n.jsx(t.Select,p({required:!0,placeholder:"Select an account",defaultValue:e.data.active,data:e.data.accounts.map((function(e){return{value:e.key,label:e.name}}))},a.getInputProps("active"))),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},R=t.createStyles((function(e){return{link:{width:50,height:50,borderRadius:e.radius.md,display:"flex",alignItems:"center",justifyContent:"center",color:"dark"===e.colorScheme?e.colors.dark[0]:e.colors.gray[7],"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[0]}},active:{"&, &:hover":{backgroundColor:e.fn.variant({variant:"light",color:e.primaryColor}).background,color:e.fn.variant({variant:"light",color:e.primaryColor}).color}}}})),W=[{icon:r.IconHome2,label:"Home"},{icon:r.IconGauge,label:"Dashboard"},{icon:r.IconCategory2,label:"Groups"},{icon:r.IconAlbum,label:"Badges"},{icon:r.IconLambda,label:"Lessons"}],F=function(e){var a,i=e.icon,r=e.label,o=e.active,s=e.onClick,l=R(),c=l.classes,d=l.cx;return n.jsx(t.Tooltip,p({label:r,position:"right",transitionDuration:0},{children:n.jsx(t.UnstyledButton,p({onClick:s,className:d(c.link,(a={},a[c.active]=o,a))},{children:n.jsx(i,{stroke:1.5})}))}))},U=["Logout","Change account"],V=function(e){var a=W.map((function(n){return o.createElement(F,p({},n,{key:n.label,active:n.label===e.active,onClick:function(){return e.onClick&&e.onClick(n.label)}}))}));return n.jsxs(t.Navbar,p({width:{base:80},p:"md"},{children:[n.jsx(t.Center,{children:n.jsx(t.Avatar,p({color:"blue",radius:"sm"},{children:n.jsx("div",p({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:n.jsx(t.Image,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),n.jsx(t.Navbar.Section,p({grow:!0,mt:50},{children:n.jsx(t.Stack,p({justify:"center",spacing:0},{children:a}))})),n.jsx(t.Navbar.Section,{children:n.jsxs(t.Stack,p({justify:"center",spacing:0},{children:[n.jsx(F,{icon:r.IconSwitchHorizontal,label:"Change account",onClick:function(){return e.onClick&&e.onClick("Change account")}}),n.jsx(F,{icon:r.IconLogout,label:"Logout",onClick:function(){return e.onClick&&e.onClick("Logout")}})]}))})]}))},H=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],q=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function _(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,t=H;n<t.length;n++){var a=t[n],i=a.unit,r=a.ms;if(Math.abs(e)>=r||"second"===i)return q.format(Math.round(e/r),i)}return""}(e.getTime()-n.getTime()):""}var Y={BadgeCompleted:n.jsx(r.IconBadges,{size:12}),BadgeStarted:n.jsx(r.IconBadges,{size:12}),LessonCompleted:n.jsx(r.IconSchool,{size:12}),LessonStarted:n.jsx(r.IconSchool,{size:12}),ProblemSolved:n.jsx(r.IconActivityHeartbeat,{size:12})},X=function(e){var a,i=o.useRef(null),r=o.useState({x:0,y:0}),s=r[0],l=r[1];m.useEffect((function(){i.current&&s.y===i.current.scrollHeight-i.current.offsetHeight&&e.onScrollBottom&&e.onScrollBottom()}),[s.y]);var c=e.data.map((function(e){var i=e.name.split(/(?=[A-Z])/),r=i[0]===a?"dashed":"solid";a=i[0];var o=e.link?n.jsx(t.Anchor,p({color:"dark",unstyled:!0,href:e.link},{children:"".concat(i[0]," ").concat(i[1].toLowerCase())})):"".concat(i[0]," ").concat(i[1].toLowerCase());return n.jsxs(t.Timeline.Item,p({bullet:K(e.name),lineVariant:r,title:o},{children:[n.jsx(t.Text,p({color:"dimmed",size:"sm"},{children:e.description})),n.jsx(t.Text,p({size:"xs",mt:4},{children:_(new Date(e.time))}))]}),e.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:300,onScrollPositionChange:l,viewportRef:i},{children:n.jsx(t.Timeline,p({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:c}))}))},K=function(e){var t=Y[e];return t||n.jsx(r.IconTimelineEvent,{size:12})},$=t.createStyles((function(e){var n,t;return{root:(n={display:"flex",backgroundImage:"linear-gradient(-60deg, ".concat(e.colors[e.primaryColor][4]," 0%, ").concat(e.colors[e.primaryColor][7]," 100%)"),padding:1.5*e.spacing.xl,borderRadius:e.radius.md},n[e.fn.smallerThan("sm")]={flexDirection:"column"},n),title:{color:e.white,textTransform:"uppercase",fontWeight:700,fontSize:e.fontSizes.sm},count:{color:e.white,fontSize:32,lineHeight:1,fontWeight:700,marginBottom:e.spacing.md,fontFamily:"Greycliff CF, ".concat(e.fontFamily)},description:{color:e.colors[e.primaryColor][0],fontSize:e.fontSizes.sm,marginTop:5},stat:{flex:1,"& + &":(t={paddingLeft:e.spacing.xl,marginLeft:e.spacing.xl,borderLeft:"1px solid ".concat(e.colors[e.primaryColor][3])},t[e.fn.smallerThan("sm")]={paddingLeft:0,marginLeft:0,borderLeft:0,paddingTop:e.spacing.xl,marginTop:e.spacing.xl,borderTop:"1px solid ".concat(e.colors[e.primaryColor][3])},t)}}})),J=function(e){var a=e.data,i=$().classes,r=a.map((function(e){return n.jsxs("div",p({className:i.stat},{children:[n.jsx(t.Text,p({className:i.count},{children:e.value.toLocaleString()})),n.jsx(t.Text,p({className:i.title},{children:e.title})),n.jsx(t.Text,p({className:i.description},{children:"".concat(e.diff,"% ").concat(e.diff<0?"decrease":"increase"," compared to last period")}))]}),e.title)}));return n.jsx("div",p({className:i.root},{children:r}))},Q=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Z=function(e){var a=Q().classes,i=e.data.givenName?[e.data.givenName,e.data.familyName].join(" ").trim():e.data.email,r=e.data.givenName?e.data.givenName:"Me";return"compact"===e.variant?n.jsxs(n.Fragment,{children:[n.jsx(t.Title,p({className:a.title},{children:i})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"xs"},{children:e.data.quote}))]}):n.jsxs(n.Fragment,{children:[n.jsxs(t.Paper,p({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[n.jsx(t.Avatar,{src:e.data.avatar,size:135,radius:120,mx:"auto"}),n.jsx(t.Text,p({align:"center",size:"lg",weight:500,mt:"md"},{children:i})),n.jsxs(t.Text,p({align:"center",color:"dimmed",size:"sm"},{children:[e.data.email," • ",e.data.job]}))]})),n.jsx(t.Blockquote,p({mt:"xl",color:"blue",cite:"– ".concat(r)},{children:e.data.quote}))]})},ee=["Member","Admin"];function ne(e){var i=e.data.map((function(i){return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx(t.UnstyledButton,p({onClick:function(){return e.onViewProfile&&e.onViewProfile(i)}},{children:n.jsxs(t.Group,p({spacing:"sm"},{children:[n.jsx(t.Avatar,{size:40,src:i.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:i.givenName&&i.familyName?"".concat(i.givenName," ").concat(i.familyName):i.email})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:i.email}))]})]}))}))}),n.jsx("td",{children:n.jsx(t.Select,{data:ee,defaultValue:i.role,variant:"unstyled",onChange:function(n){return e.onChangeRole&&e.onChangeRole(i,n)}})}),n.jsx("td",{children:i.lastActivity?_(i.lastActivity):""}),n.jsx("td",{children:n.jsx(t.Group,p({noWrap:!0,spacing:0,position:"right"},{children:n.jsx(t.ActionIcon,p({color:"red"},{children:n.jsx(r.IconTrash,{onClick:function(){return r=i,a.openConfirmModal({title:'Delete "'.concat(r.givenName&&r.familyName?"".concat(r.givenName," ").concat(r.familyName):r.email,'"?'),centered:!0,children:n.jsx(t.Text,p({size:"sm"},{children:"Are you sure you want to delete this person? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete",cancel:"No don't delete them"},confirmProps:{color:"red"},onConfirm:function(){return e.onDelete&&e.onDelete(r)}});var r},size:16,stroke:1.5})}))}))})]},i.email)}));return 0===e.data.length?n.jsx(T,{data:{title:"No one in group",icon:"thinking",description:"You don't have any people in this group yet. When your ready, get started by clicking the 'Add people' button above."}}):n.jsx(t.ScrollArea,{children:n.jsxs(t.Table,p({verticalSpacing:20,sx:{minWidth:700}},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Member"}),n.jsx("th",{children:"Role"}),n.jsx("th",{children:"Last active"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:i})]}))})}var te=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600},wrapper:{position:"relative",marginBottom:30},dropzone:{borderWidth:1,paddingBottom:50},icon:{color:"dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[4]},control:{position:"absolute",width:250,left:"calc(50% - 125px)",bottom:-20}}})),ae=function(e){var a=te().classes,i=s.useForm({initialValues:{key:"",email:"",givenName:"",familyName:"",avatar:"",role:"",lastActivity:null},validate:{email:function(n){return/^\S+@\S+$/.test(n)&&0===e.data.users.filter((function(e){return e.email===n})).length?null:"Invalid email"}}}),l=o.useState(!1),c=l[0],d=l[1],u=o.useState(e.data.groupUserHomeOpen),h=u[0],m=u[1];return h?n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:function(){return m(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(r.IconArrowLeft,{size:14})})),size:"lg"},{children:"Users"})),n.jsx(Z,{variant:"compact",data:e.data.user})]}))}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.user.loading,overlayBlur:2}),n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsx(J,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(X,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))]}))]}))})):n.jsxs(n.Fragment,{children:[n.jsx(t.Drawer,p({opened:c,onClose:function(){return d(!1)},title:n.jsx(t.Title,p({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(ie,p({},e,{close:function(){return d(!1)}})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),n.jsx("form",p({onSubmit:i.onSubmit((function(){var n=i.values;i.reset(),d(!1),e.onCreateUsers&&e.onCreateUsers([n])}))},{children:n.jsxs(t.Stack,{children:[n.jsx(t.TextInput,p({withAsterisk:!0,label:"Email",placeholder:"Email"},i.getInputProps("email"))),n.jsxs(t.Group,p({grow:!0},{children:[n.jsx(t.TextInput,p({label:"Given name",placeholder:"Given name"},i.getInputProps("givenName"))),n.jsx(t.TextInput,p({label:"Family name",placeholder:"Family name"},i.getInputProps("familyName")))]})),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(r.IconArrowLeft,{size:14})})),size:"lg"},{children:"Groups"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:e.data.name||"Group"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsx(t.Grid.Col,p({sm:"content"},{children:n.jsx(t.Button,p({onClick:function(){return d(!0)},leftIcon:n.jsx(r.IconPlaylistAdd,{size:14})},{children:"Add people"}))}))]}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(ne,{data:e.data.users,onDelete:e.onDelete,onChangeRole:e.onRoleChange,onViewProfile:function(n){return e.onViewProfile(n).then((function(){m(!0)}))}})]}))]}))}))]})},ie=function(e){var a=te(),i=a.classes,o=a.theme,s=m.useRef(null),c=m.useState(!1),d=c[0],u=c[1],h=m.useCallback((function(n){u(!0),n.forEach((function(n){x.parse(n,{download:!0,header:!0,dynamicTyping:!0,skipEmptyLines:!0,worker:!0,complete:function(n){var t=n.data.filter((function(n){return/^\S+@\S+$/.test(n.email)&&0===e.data.users.filter((function(e){return e.email===n.email})).length}));t.length>0&&e.onCreateUsers&&e.onCreateUsers(t),u(!1),e.close()}})}))}),[]);return n.jsxs("div",p({className:i.wrapper},{children:[n.jsx(l.Dropzone,p({loading:d,openRef:s,onDrop:h,className:i.dropzone,radius:"md",accept:[l.MIME_TYPES.csv],maxSize:5*Math.pow(1024,2)},{children:n.jsxs("div",p({style:{pointerEvents:"none"}},{children:[n.jsxs(t.Group,p({position:"center"},{children:[n.jsx(l.Dropzone.Accept,{children:n.jsx(r.IconDownload,{size:50,color:o.colors[o.primaryColor][6],stroke:1.5})}),n.jsx(l.Dropzone.Reject,{children:n.jsx(r.IconX,{size:50,color:o.colors.red[6],stroke:1.5})}),n.jsx(l.Dropzone.Idle,{children:n.jsx(r.IconCloudUpload,{size:50,color:"dark"===o.colorScheme?o.colors.dark[0]:o.black,stroke:1.5})})]})),n.jsxs(t.Text,p({align:"center",weight:700,size:"lg",mt:"xl"},{children:[n.jsx(l.Dropzone.Accept,{children:"Drop files here"}),n.jsx(l.Dropzone.Reject,{children:"Csv file less than 5mb"}),n.jsx(l.Dropzone.Idle,{children:"Upload multiple"})]})),n.jsxs(t.Text,p({align:"center",size:"sm",mt:"xs",color:"dimmed"},{children:["Drag'n'drop files here to upload. We can accept only ",n.jsx("i",{children:".csv"})," files that are less than 5mb in size."]}))]}))})),n.jsx(t.Button,p({className:i.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=s.current)||void 0===e?void 0:e.call(s)}},{children:"Select file"}))]}))};function re(e){if(0===e.data.length)return n.jsx(T,{data:{title:"No groups",icon:"groups",description:"You don't have any groups just yet. When your ready, get started by clicking the 'Create group' button above."}});var i=e.data.map((function(i){return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx(t.Text,p({size:14},{children:i.name}))}),n.jsx("td",{children:n.jsx(t.Text,p({size:14},{children:i.description}))}),n.jsx("td",{children:n.jsxs(t.Group,p({noWrap:!0,spacing:0,position:"right"},{children:[n.jsx(t.ActionIcon,p({color:"blue",onClick:function(){return e.onEditGroup&&e.onEditGroup(i)},variant:"subtle"},{children:n.jsx(r.IconUsers,{size:16,stroke:1.5})})),n.jsxs(t.Menu,p({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[n.jsx(t.Menu.Target,{children:n.jsx(t.ActionIcon,{children:n.jsx(r.IconDots,{size:16,stroke:1.5})})}),n.jsx(t.Menu.Dropdown,{children:n.jsx(t.Menu.Item,p({onClick:function(){return r=i,a.openConfirmModal({title:'Delete "'.concat(r.name,'"?'),centered:!0,children:n.jsx(t.Text,p({size:"sm"},{children:"Are you sure you want to delete this group? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete group",cancel:"No don't delete it"},confirmProps:{color:"red"},onConfirm:function(){return e.onDeleteGroup&&e.onDeleteGroup(r)}});var r},icon:n.jsx(r.IconTrash,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},i.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:300},{children:n.jsxs(t.Table,p({verticalSpacing:20,sx:{minWidth:700}},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Description"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:i})]}))}))}var oe=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),se=function(e){var a=oe().classes,i=s.useForm({initialValues:{key:"",name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=o.useState(e.data.formOpen),c=l[0],d=l[1],u=o.useState(e.data.groupOpen),h=u[0],m=u[1];return h?n.jsx(ae,{data:e.data.group,onBackClick:function(){return m(!1)},onCreateUsers:e.onCreateGroupUsers,onDelete:e.onDeleteGroupUser,onViewProfile:e.onViewGroupUser,onRoleChange:e.onGroupUserRoleChange,onTimelineScrollBottom:e.onTimelineScrollBottom}):n.jsxs(n.Fragment,{children:[n.jsx(t.Drawer,p({opened:c,onClose:function(){return d(!1)},title:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5"},{children:"Create a group"})),n.jsx(t.Tooltip,p({label:"Groups settings cannot be modified once created"},{children:n.jsx(t.ActionIcon,{children:n.jsx(r.IconInfoCircle,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n.jsxs("form",p({onSubmit:i.onSubmit((function(){var n=i.values;i.reset(),d(!1),e.onCreateGroup&&e.onCreateGroup(n)}))},{children:[n.jsxs(t.Stack,{children:[n.jsx(t.TextInput,p({withAsterisk:!0,label:"Name",placeholder:"Group name"},i.getInputProps("name"))),n.jsx(t.TextInput,p({label:"Description",placeholder:"A group for my first period class"},i.getInputProps("description")))]}),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Groups"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Organize people into groups"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),n.jsx(t.Grid.Col,p({sm:"content"},{children:n.jsx(t.Button,p({onClick:function(){return d(!0)},leftIcon:n.jsx(r.IconPlaylistAdd,{size:14})},{children:"Create group"}))}))]}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(re,{data:e.data.groups,onDeleteGroup:e.onDeleteGroup,onEditGroup:function(n){e.onEditGroup&&e.onEditGroup(n),m(!0)}})]}))]}))}))]})},le=t.createStyles((function(e){return{card:{height:240,backgroundSize:"cover",backgroundPosition:"center"},content:{position:"absolute",padding:e.spacing.xl,zIndex:1,top:0,bottom:0,right:0,left:0},action:{position:"absolute",bottom:e.spacing.xl,right:e.spacing.xl},title:{color:e.white,marginBottom:e.spacing.xs/2},description:{color:e.white,maxWidth:220}}})),ce=function(e){var a=e.title,i=e.description,r=e.image,o=e.action,s=e.style,l=e.className,c=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["title","description","image","action","style","className"]),d=le(),u=d.classes,h=d.cx,m=d.theme;return n.jsxs(t.Card,p({radius:"md",style:p({backgroundImage:"url(".concat(r,")")},s),className:h(u.card,l)},c,{children:[n.jsx(t.Overlay,{gradient:"linear-gradient(105deg, ".concat(m.black," 20%, #312f2f 50%, ").concat(m.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n.jsxs("div",p({className:u.content},{children:[n.jsx(t.Text,p({size:"lg",weight:700,className:u.title},{children:a})),n.jsx(t.Text,p({size:"sm",className:u.description},{children:i})),n.jsx(t.Button,p({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},de=function(e){return n.jsx(t.Container,p({size:"lg"},{children:n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsxs(t.Grid,p({gutter:"md"},{children:[n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(Z,{data:e.data.user})})),n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(ce,{title:e.data.tenant.name,description:e.data.tenant.description,image:e.data.tenant.image,action:{label:"Visit website",link:e.data.tenant.website}})}))]})),n.jsx(J,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(X,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))}))},ue=t.createStyles((function(e){return{header:{position:"sticky",top:0,backgroundColor:"dark"===e.colorScheme?e.colors.dark[7]:e.white,transition:"box-shadow 150ms ease","&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,borderBottom:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[2])}},scrolled:{boxShadow:e.shadows.sm}}})),he=function(e){var a,i=e.data,r=ue(),s=r.classes,l=r.cx,c=o.useState(!1),d=c[0],u=c[1],h=i.map((function(e){return e.value})),m=Math.round(h.reduce((function(e,n){return e+n}))/h.length),x=i.map((function(e){return n.jsxs("tr",{children:[n.jsx("td",{children:e.name}),n.jsx("td",{children:e.email}),n.jsx("td",{children:e.value}),n.jsx("td",{children:e.value>m?n.jsx(t.Badge,{children:"Above average"}):e.value===m?n.jsx(t.Badge,p({color:"gray"},{children:"Average"})):n.jsx(t.Badge,p({color:"red"},{children:"Below average"}))})]},e.name)}));return n.jsx(t.ScrollArea,p({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n.jsxs(t.Table,p({verticalSpacing:"md",sx:{minWidth:700}},{children:[n.jsx("thead",p({className:l(s.header,(a={},a[s.scrolled]=d,a))},{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Email"}),n.jsx("th",{children:"Value"}),n.jsx("th",{children:"Status"})]})})),n.jsx("tbody",{children:x})]}))}))},me=function(e){return n.jsx(t.Paper,p({mih:150,p:"lg",withBorder:!0},{children:n.jsxs(t.Stack,{children:[n.jsx(t.Grid,{children:n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5",mb:0},{children:"Performance History"})),n.jsx(t.Tooltip,p({label:"Shows group performance per person"},{children:n.jsx(t.ActionIcon,{children:n.jsx(r.IconInfoCircle,{color:"#3b82f6",size:14})})}))]}))}))}),n.jsx(t.Group,p({spacing:"sm"},{children:n.jsx(t.Select,{placeholder:"Select a metric",value:e.data.metric,onChange:e.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})})),n.jsx(he,{data:e.data.users})]})}))},xe=t.createStyles((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),pe=function(e){var a=xe().theme;return n.jsx(t.Paper,p({p:"lg",withBorder:!0},{children:n.jsxs(t.Stack,{children:[n.jsxs(t.Grid,{children:[n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5",mb:0},{children:"Performance History"})),n.jsx(t.Tooltip,p({label:"Shows daily increase or decrease across group"},{children:n.jsx(t.ActionIcon,{children:n.jsx(r.IconInfoCircle,{color:"#3b82f6",size:14})})}))]}))})),n.jsx(t.Grid.Col,p({sm:5},{children:n.jsx(t.Select,{placeholder:"Select a metric",value:e.data.metric,onChange:e.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})}))]}),n.jsx(u.ResponsiveContainer,p({width:"100%",height:400},{children:n.jsxs(u.AreaChart,p({width:730,height:250,data:e.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[n.jsx("defs",{children:n.jsxs("linearGradient",p({id:"colorBlue",x1:"0",y1:"0",x2:"0",y2:"1"},{children:[n.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.4}),n.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}))}),n.jsx(u.XAxis,{tick:{fontSize:12,fontFamily:a.fontFamily},dataKey:"name"}),n.jsx(u.YAxis,{tick:{fontSize:12,fontFamily:a.fontFamily}}),n.jsx(u.CartesianGrid,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),n.jsx(u.Tooltip,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:a.fontFamily},labelStyle:{fontSize:12,fontFamily:a.fontFamily}}),n.jsx(u.Area,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},ge=t.createStyles((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),fe=function(e){var a=e.data,i=ge().classes,o=a.map((function(e){var a=e.diff>0?r.IconArrowUpRight:r.IconArrowDownRight;return n.jsxs(t.Paper,p({withBorder:!0,p:"md",radius:"md"},{children:[n.jsxs(t.Group,p({position:"apart"},{children:[n.jsxs("div",{children:[n.jsx(t.Text,p({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:i.label},{children:e.title})),n.jsx(t.Text,p({weight:700,size:"xl"},{children:e.value.toLocaleString()}))]}),n.jsx(t.ThemeIcon,p({color:"gray",variant:"light",sx:function(n){return{color:e.diff>0?n.colors.teal[6]:n.colors.red[6]}},size:38,radius:"md"},{children:n.jsx(a,{size:28,stroke:1.5})}))]})),n.jsxs(t.Text,p({color:"dimmed",size:"sm",mt:"md"},{children:[n.jsxs(t.Text,p({component:"span",color:e.diff>0?"teal":"red",weight:700},{children:[e.diff,"%"]}))," ",e.diff>0?"increase":"decrease"," compared to last period"]}))]}),e.title)}));return n.jsx("div",p({className:i.root},{children:n.jsx(t.SimpleGrid,p({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:o}))}))},je=function(e){return n.jsxs(n.Fragment,{children:[n.jsx(fe,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(pe,{data:e.data.areaChart,onMetricChange:e.onMetricChange})]})},ve=[{value:"Overview"},{value:"Breakdown"}],Ce=function(e){var a=be(e.data.breakdown,e.onBreakdownMetricChange),i=ye(e.data.dateRange,e.onDateRangeChange),o=ke(e.data.groups,e.onGroupChange),s=Te(e.data.overview,e.onOverviewMetricChange),l=we(e.data.tab,e.onTabChange);return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Title,p({size:"h3"},{children:"Dashboard"})),n.jsx(t.Text,p({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),n.jsx(t.Grid.Col,p({sm:2.5},{children:n.jsx(t.Select,{placeholder:"Select a group",nothingFound:"No options",value:o.select,onChange:o.onSelectChange,icon:n.jsx(r.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})})),n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsx(d.DateRangePicker,{placeholder:"Select a date",allowSingleDateInRange:!0,value:i.value,onChange:i.onChange,icon:n.jsx(r.IconCalendar,{size:16})})}))]}),n.jsxs(t.Stack,{children:[n.jsx(f,{data:ve,value:l.value,onChange:l.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(Se,p({},e,{data:p(p({},e.data),{overview:s.data,breakdown:a.data}),active:l.value,onBreakdownMetricChange:a.onMetricChange,onOverviewMetricChange:s.onMetricChange}))]}))]})]})}))},Se=function(e){if(0===e.data.overview.stats["PROBLEMS SOLVED"].value)return n.jsx(T,{data:{title:"No data for period",icon:"dashboard",description:"We haven't received any data yet for your group during this period. Check back later once progress has been made."}});switch(e.active){case"Overview":return n.jsx(je,{data:e.data.overview,onMetricChange:e.onOverviewMetricChange});case"Breakdown":return n.jsx(me,{data:e.data.breakdown,onMetricChange:e.onBreakdownMetricChange});default:return null}},be=function(e,n){var t=m.useState(e.metric),a=t[0],i=t[1];return{data:p(p({},e),{metric:a}),onMetricChange:function(e){i(e),n&&n(e)}}},ye=function(e,n){var t=m.useState(e),a=t[0],i=t[1];return{value:a,onChange:function(e){i(e),n&&n(e)}}},ke=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),i=a[0],r=a[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},Te=function(e,n){var t=m.useState(e.areaChart.metric),a=t[0],i=t[1];return{data:p(p({},e),{areaChart:p(p({},e.areaChart),{metric:a})}),onMetricChange:function(e){i(e),n&&n(e)}}},we=function(e,n){var t=m.useState(e),a=t[0],i=t[1];return{value:a,onChange:function(e){i(e),n&&n(e)}}},ze=t.createStyles((function(e){var n,t,a,i,r,o;return{footer:{paddingTop:2*e.spacing.xl,paddingBottom:2*e.spacing.xl,paddingLeft:3*e.spacing.xl,backgroundColor:"dark"===e.colorScheme?e.colors.dark[6]:e.colors.gray[0],borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[2])},logo:(n={maxWidth:200},n[e.fn.smallerThan("sm")]={display:"flex",flexDirection:"column",alignItems:"center"},n),description:(t={marginTop:5},t[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs,textAlign:"center"},t),inner:(a={display:"flex",justifyContent:"space-between"},a[e.fn.smallerThan("sm")]={flexDirection:"column",alignItems:"center"},a),groups:(i={display:"flex",flexWrap:"wrap"},i[e.fn.smallerThan("sm")]={display:"none"},i),wrapper:{width:160},link:{display:"block",color:"dark"===e.colorScheme?e.colors.dark[1]:e.colors.gray[6],fontSize:e.fontSizes.sm,paddingTop:3,paddingBottom:3,"&:hover":{textDecoration:"underline"}},title:{fontSize:e.fontSizes.md,fontWeight:700,fontFamily:"Greycliff CF, ".concat(e.fontFamily),marginBottom:e.spacing.xs/2,color:"dark"===e.colorScheme?e.white:e.black},afterFooter:(r={display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:e.spacing.xl,paddingTop:e.spacing.xl,paddingBottom:e.spacing.xl,borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[4]:e.colors.gray[2])},r[e.fn.smallerThan("sm")]={flexDirection:"column"},r),social:(o={},o[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},o)}})),Be=function(e,n){var t=o.useState(!e.hidden),a=t[0],i=t[1],r=o.useState(e.active),s=r[0],l=r[1];return{data:p(p({},e),{active:s,hidden:!a}),setChangeModalOpen:i,onAccountChange:function(e){l(e),i(!1),n&&n(e)}}},Ee=function(e,n){var t=o.useState(e||"Home"),a=t[0],i=t[1];return{key:a,active:a,onClick:function(e){var t;a!==e&&(t=e,-1===U.indexOf(t)&&i(e),n&&n(e))}}},Ge=function(e){switch(e.active){case"Dashboard":return n.jsx(Ce,{data:e.data.dashboard,onBreakdownMetricChange:e.onDashboardBreakdownMetricChange,onDateRangeChange:e.onDashboardDateRangeChange,onGroupChange:e.onDashboardGroupChange,onOverviewMetricChange:e.onDashboardOverviewMetricChange,onTabChange:e.onDashboardTabChange});case"Home":return n.jsx(de,{data:e.data.home,onTimelineScrollBottom:e.onHomeTimelineScrollBottom});case"Groups":return n.jsx(se,{data:e.data.groups,onCreateGroup:e.onCreateGroup,onCreateGroupUsers:e.onCreateGroupUsers,onDeleteGroup:e.onDeleteGroup,onDeleteGroupUser:e.onDeleteGroupUser,onEditGroup:e.onEditGroup,onViewGroupUser:e.onViewGroupUser,onGroupUserRoleChange:e.onGroupUserRoleChange,onTimelineScrollBottom:e.onGroupUserTimelineScrollBottom});case"Lessons":return n.jsx(P,{data:e.data.lessons,onAutocompleteChange:e.onLessonAutocompleteChange,onGroupChange:e.onLessonGroupChange,onLessonClick:e.onLessonClick,onPreview:e.onLessonPreview,onTabChange:e.onLessonTabChange,onUserClick:e.onLessonUserClick});case"Badges":return n.jsx(B,{data:e.data.badges,onAutocompleteChange:e.onBadgeAutocompleteChange,onGroupChange:e.onBadgeGroupChange,onBadgeClick:e.onBadgeClick,onPreview:e.onBadgePreview,onTabChange:e.onBadgeTabChange,onUserClick:e.onBadgeUserClick});default:return null}};Object.defineProperty(e,"showNotification",{enumerable:!0,get:function(){return i.showNotification}}),Object.defineProperty(e,"updateNotification",{enumerable:!0,get:function(){return i.updateNotification}}),e.Mgmt=function(e){var a=ze().classes,i=Be(e.data.account,e.onAccountChange),o=Ee(e.data.navbar.active,(function(n){if("Change account"===n)i.setChangeModalOpen(!0);e.onNavbarClick&&e.onNavbarClick(n)}));return n.jsxs(t.AppShell,p({padding:"xs",navbar:n.jsx(V,{active:o.active,onClick:o.onClick},o.key),footer:n.jsxs("footer",p({className:a.footer},{children:[n.jsxs(t.Container,p({className:a.inner},{children:[n.jsxs("div",p({className:a.logo},{children:[n.jsxs(t.Group,p({spacing:"xs"},{children:[n.jsx("div",p({style:{width:15}},{children:n.jsx(t.Image,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),n.jsx(t.Title,p({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),n.jsx(t.Text,p({size:"xs",color:"dimmed",className:a.description},{children:"We connect students to powerful civic learning experiences."}))]})),n.jsx("div",p({className:a.groups},{children:n.jsxs("div",p({className:a.wrapper},{children:[n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://localcivics.notion.site/Help-Center-b52300f587b64fc0a61f512686e7626d",target:"_blank"},{children:"FAQ"}))]}))}))]})),n.jsxs(t.Container,p({className:a.afterFooter},{children:[n.jsxs(t.Text,p({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n.jsxs(t.Group,p({spacing:0,className:a.social,position:"right",noWrap:!0},{children:[n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:n.jsx(r.IconBrandInstagram,{size:18,stroke:1.5})})),n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:n.jsx(r.IconBrandLinkedin,{size:18,stroke:1.5})})),n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:n.jsx(r.IconBrandFacebook,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[n.jsxs("div",p({style:{position:"relative"}},{children:[e.data.loading&&n.jsx(t.Center,p({style:{height:400}},{children:n.jsx(t.Loader,{})})),!e.data.loading&&n.jsx(Ge,p({},e,{active:o.active}))]})),n.jsx(M,{data:i.data,onChange:i.onAccountChange,onClose:function(){return i.setChangeModalOpen(!1)}})]}))},e.MgmtProvider=function(e){return n.jsx(t.MantineProvider,p({withNormalizeCSS:!0,withGlobalStyles:!0,emotionCache:g,theme:{loader:"bars"}},{children:n.jsx(i.NotificationsProvider,p({limit:e.notificationLimit||5},{children:n.jsx(a.ModalsProvider,{children:e.children})}))}))},e.SwitchAccount=M,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react/jsx-runtime"),require("@mantine/core"),require("@mantine/modals"),require("@mantine/notifications"),require("@tabler/icons"),require("react"),require("@mantine/form"),require("@mantine/dropzone"),require("papaparse"),require("@mantine/dates"),require("recharts")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@mantine/core","@mantine/modals","@mantine/notifications","@tabler/icons","react","@mantine/form","@mantine/dropzone","papaparse","@mantine/dates","recharts"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).components={},e.ReactJSXRuntime,e.MantineCore,e.MantineModals,e.MantineNotifications,e.TablerIcons,e.React,e.MantineForm,e.MantineDropzone,e.Papaparse,e.MantineDates,e.Recharts)}(this,(function(e,n,t,a,r,i,o,s,l,c,d,u){"use strict";function h(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var m=h(o),x=h(c),p=function(){return p=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},p.apply(this,arguments)};function g(e,n,t){if(t||2===arguments.length)for(var a,r=0,i=n.length;r<i;r++)!a&&r in n||(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return e.concat(a||Array.prototype.slice.call(n))}var f=t.createEmotionCache({key:"mantine",prepend:!1}),j=function(e){var a,r=null===(a=e.data)||void 0===a?void 0:a.map((function(e){return n.jsx(t.Tabs.Tab,p({value:e.value},{children:e.label||e.value}),e.value)}));return n.jsx(t.Tabs,p({value:e.value,onTabChange:e.onChange},{children:n.jsx(t.Tabs.List,{children:r})}))};function v(e){var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsxs(t.Group,{children:[n.jsx(t.Avatar,{size:40,src:a.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.email}))]})]})}))})},a.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var C=[{value:"Complete"},{value:"Incomplete"}],S=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),b=function(e){var a=y(e.data.groups,e.onGroupChange),r=k(e.data.tab,e.onTabChange),o=S().classes;return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(i.IconArrowLeft,{size:14})})),size:"lg"},{children:"Badges"})),n.jsxs(t.Group,{children:[n.jsxs(t.Stack,p({spacing:0},{children:[n.jsx(t.Title,p({order:2,className:o.title,mt:"md"},{children:e.data.name||"Badge"})),n.jsx(t.Text,p({color:"dimmed",className:o.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsxs(t.Stack,p({ml:"auto"},{children:[n.jsx(t.Button,p({variant:"gradient",onClick:function(){return e.onPreview&&e.onPreview(e.data)}},{children:"Preview"})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),n.jsx(t.Select,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:a.select,onChange:a.onSelectChange,icon:n.jsx(i.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(j,{data:C,value:r.value,onChange:r.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(v,{data:e.data.users,onClick:e.onUserClick})]}))]})]}))}))},y=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),r=a[0],i=a[1];return{select:r,onSelectChange:function(e){i(e),n&&n(e)}}},k=function(e,n){var t=m.useState(e),a=t[0],r=t[1];return{value:a,onChange:function(e){r(e),n&&n(e)}}},T=t.createStyles((function(e){var n,t,a;return{wrapper:(n={display:"flex",alignItems:"center",padding:2*e.spacing.xl,borderRadius:e.radius.md,backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white,border:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[3])},n["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={flexDirection:"column-reverse",padding:e.spacing.xl},n),image:(t={maxWidth:"40%"},t["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={maxWidth:"100%"},t),body:(a={paddingRight:4*e.spacing.xl},a["@media (max-width: ".concat(e.breakpoints.sm,"px)")]={paddingRight:0,marginTop:e.spacing.xl},a),title:{color:"dark"===e.colorScheme?e.white:e.black,fontFamily:"Greycliff CF, ".concat(e.fontFamily),lineHeight:1,marginBottom:e.spacing.md},controls:{display:"flex",marginTop:e.spacing.xl},inputWrapper:{width:"100%",flex:"1"},input:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRight:0},control:{borderTopLeftRadius:0,borderBottomLeftRadius:0}}})),w=function(e){var a=T().classes;return n.jsxs("div",p({className:a.wrapper},{children:[n.jsxs("div",p({className:a.body},{children:[n.jsx(t.Title,p({className:a.title},{children:e.data.title})),n.jsx(t.Text,p({size:"sm",color:"dimmed"},{children:e.data.description}))]})),n.jsx(t.Image,{src:"https://cdn.localcivics.io/illustrations/".concat(e.data.icon,".svg"),className:a.image})]}))};function z(e){if(0===e.data.length)return n.jsx(w,{data:{title:"No badges available",icon:"badges",description:"Adjust your search or contact a representative if your expecting results."}});var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsx(t.Group,{children:n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.description}))]})})}))})},a.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var B=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),E=function(e){var a=B().classes,r=o.useState(e.data.badgeOpen),i=r[0],s=r[1];return i?n.jsx(b,{data:e.data.badge,onBackClick:function(){return s(!1)},onGroupChange:e.onGroupChange,onTabChange:e.onTabChange,onUserClick:e.onUserClick,onPreview:e.onPreview}):n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Badges"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Badges and micro-credentials"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),n.jsx(t.Autocomplete,{placeholder:"Search for a badge that fits your needs",data:e.data.badges.map((function(e){return e.name})),onChange:e.onAutocompleteChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(z,{data:e.data.badges,onClick:function(n){e.onBadgeClick&&e.onBadgeClick(n),s(!0)}})]}))]}))}))};function G(e){var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsxs(t.Group,{children:[n.jsx(t.Avatar,{size:40,src:a.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.email}))]})]})}))})},a.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var N=[{value:"Complete"},{value:"Incomplete"}],D=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),A=function(e){var a=L(e.data.groups,e.onGroupChange),r=O(e.data.tab,e.onTabChange),o=D().classes;return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(i.IconArrowLeft,{size:14})})),size:"lg"},{children:"Lessons"})),n.jsxs(t.Group,{children:[n.jsxs(t.Stack,p({spacing:0},{children:[n.jsx(t.Title,p({order:2,className:o.title,mt:"md"},{children:e.data.name||"Lesson"})),n.jsx(t.Text,p({color:"dimmed",className:o.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsxs(t.Stack,p({ml:"auto"},{children:[n.jsx(t.Button,p({variant:"gradient",onClick:function(){return e.onPreview&&e.onPreview(e.data)}},{children:"Preview"})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),n.jsx(t.Select,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:a.select,onChange:a.onSelectChange,icon:n.jsx(i.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(j,{data:N,value:r.value,onChange:r.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(G,{data:e.data.users,onClick:e.onUserClick})]}))]})]}))}))},L=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),r=a[0],i=a[1];return{select:r,onSelectChange:function(e){i(e),n&&n(e)}}},O=function(e,n){var t=m.useState(e),a=t[0],r=t[1];return{value:a,onChange:function(e){r(e),n&&n(e)}}};function I(e){if(0===e.data.length)return n.jsx(w,{data:{title:"No lessons available",icon:"lessons",description:"Adjust your search or contact a representative if your expecting results."}});var a=e.data.map((function(a){return n.jsx("tr",{children:n.jsx("td",{children:n.jsx(t.UnstyledButton,p({sx:function(e){return{display:"block",width:"100%",padding:e.spacing.md,color:"dark"===e.colorScheme?e.colors.dark[0]:e.black,"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[1]}}},onClick:function(){return e.onClick&&e.onClick(a)}},{children:n.jsx(t.Group,{children:n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:a.name})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:a.description}))]})})}))})},a.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:500},{children:n.jsx(t.Table,p({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:n.jsx("tbody",{children:a})}))}))}var P=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),M=function(e){var a=P().classes,r=o.useState(e.data.lessonOpen),i=r[0],s=r[1];return i?n.jsx(A,{data:e.data.lesson,onBackClick:function(){return s(!1)},onGroupChange:e.onGroupChange,onTabChange:e.onTabChange,onUserClick:e.onUserClick,onPreview:e.onPreview}):n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Lessons"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Lessons"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),n.jsx(t.Autocomplete,{placeholder:"Search for a lesson that fits your needs",data:e.data.lessons.map((function(e){return e.name})),onChange:e.onAutocompleteChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(I,{data:e.data.lessons,onClick:function(n){e.onLessonClick&&e.onLessonClick(n),s(!0)}})]}))]}))}))},R=function(e){var a=s.useForm({initialValues:{active:e.data.active}});return n.jsx(t.Modal,p({centered:!0,opened:!e.data.hidden,onClose:function(){return e.onClose&&e.onClose()},size:"sm",title:n.jsx(t.Title,p({size:"h5"},{children:"Accounts"}))},{children:n.jsxs("form",p({onSubmit:a.onSubmit((function(){e.onChange&&e.onChange(a.values.active)}))},{children:[n.jsx(t.Select,p({required:!0,placeholder:"Select an account",defaultValue:e.data.active,data:e.data.accounts.map((function(e){return{value:e.key,label:e.name}}))},a.getInputProps("active"))),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},W=t.createStyles((function(e){return{link:{width:50,height:50,borderRadius:e.radius.md,display:"flex",alignItems:"center",justifyContent:"center",color:"dark"===e.colorScheme?e.colors.dark[0]:e.colors.gray[7],"&:hover":{backgroundColor:"dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[0]}},active:{"&, &:hover":{backgroundColor:e.fn.variant({variant:"light",color:e.primaryColor}).background,color:e.fn.variant({variant:"light",color:e.primaryColor}).color}}}})),F=[{icon:i.IconHome2,label:"Home"},{icon:i.IconGauge,label:"Dashboard"},{icon:i.IconCategory2,label:"Groups"},{icon:i.IconAlbum,label:"Badges"},{icon:i.IconLambda,label:"Lessons"}],U=function(e){var a,r=e.icon,i=e.label,o=e.active,s=e.onClick,l=W(),c=l.classes,d=l.cx;return n.jsx(t.Tooltip,p({label:i,position:"right",transitionDuration:0},{children:n.jsx(t.UnstyledButton,p({onClick:s,className:d(c.link,(a={},a[c.active]=o,a))},{children:n.jsx(r,{stroke:1.5})}))}))},V=["Logout","Change account"],H=function(e){var a=F.map((function(n){return o.createElement(U,p({},n,{key:n.label,active:n.label===e.active,onClick:function(){return e.onClick&&e.onClick(n.label)}}))}));return n.jsxs(t.Navbar,p({width:{base:80},p:"md"},{children:[n.jsx(t.Center,{children:n.jsx(t.Avatar,p({color:"blue",radius:"sm"},{children:n.jsx("div",p({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:n.jsx(t.Image,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),n.jsx(t.Navbar.Section,p({grow:!0,mt:50},{children:n.jsx(t.Stack,p({justify:"center",spacing:0},{children:a}))})),n.jsx(t.Navbar.Section,{children:n.jsxs(t.Stack,p({justify:"center",spacing:0},{children:[n.jsx(U,{icon:i.IconSwitchHorizontal,label:"Change account",onClick:function(){return e.onClick&&e.onClick("Change account")}}),n.jsx(U,{icon:i.IconLogout,label:"Logout",onClick:function(){return e.onClick&&e.onClick("Logout")}})]}))})]}))},q=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],_=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function Y(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,t=q;n<t.length;n++){var a=t[n],r=a.unit,i=a.ms;if(Math.abs(e)>=i||"second"===r)return _.format(Math.round(e/i),r)}return""}(e.getTime()-n.getTime()):""}var X={BadgeCompleted:n.jsx(i.IconBadges,{size:12}),BadgeStarted:n.jsx(i.IconBadges,{size:12}),LessonCompleted:n.jsx(i.IconSchool,{size:12}),LessonStarted:n.jsx(i.IconSchool,{size:12}),ProblemSolved:n.jsx(i.IconActivityHeartbeat,{size:12})},K=function(e){var a,r=o.useRef(null),i=o.useState({x:0,y:0}),s=i[0],l=i[1];m.useEffect((function(){r.current&&s.y===r.current.scrollHeight-r.current.offsetHeight&&e.onScrollBottom&&e.onScrollBottom()}),[s.y]);var c=e.data.map((function(e){var r=e.name.split(/(?=[A-Z])/),i=r[0]===a?"dashed":"solid";a=r[0];var o=e.link?n.jsx(t.Anchor,p({color:"dark",unstyled:!0,href:e.link},{children:"".concat(r[0]," ").concat(r[1].toLowerCase())})):"".concat(r[0]," ").concat(r[1].toLowerCase());return n.jsxs(t.Timeline.Item,p({bullet:$(e.name),lineVariant:i,title:o},{children:[n.jsx(t.Text,p({color:"dimmed",size:"sm"},{children:e.description})),n.jsx(t.Text,p({size:"xs",mt:4},{children:Y(new Date(e.time))}))]}),e.key)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:300,onScrollPositionChange:l,viewportRef:r},{children:n.jsx(t.Timeline,p({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:c}))}))},$=function(e){var t=X[e];return t||n.jsx(i.IconTimelineEvent,{size:12})},J=t.createStyles((function(e){var n,t;return{root:(n={display:"flex",backgroundImage:"linear-gradient(-60deg, ".concat(e.colors[e.primaryColor][4]," 0%, ").concat(e.colors[e.primaryColor][7]," 100%)"),padding:1.5*e.spacing.xl,borderRadius:e.radius.md},n[e.fn.smallerThan("sm")]={flexDirection:"column"},n),title:{color:e.white,textTransform:"uppercase",fontWeight:700,fontSize:e.fontSizes.sm},count:{color:e.white,fontSize:32,lineHeight:1,fontWeight:700,marginBottom:e.spacing.md,fontFamily:"Greycliff CF, ".concat(e.fontFamily)},description:{color:e.colors[e.primaryColor][0],fontSize:e.fontSizes.sm,marginTop:5},stat:{flex:1,"& + &":(t={paddingLeft:e.spacing.xl,marginLeft:e.spacing.xl,borderLeft:"1px solid ".concat(e.colors[e.primaryColor][3])},t[e.fn.smallerThan("sm")]={paddingLeft:0,marginLeft:0,borderLeft:0,paddingTop:e.spacing.xl,marginTop:e.spacing.xl,borderTop:"1px solid ".concat(e.colors[e.primaryColor][3])},t)}}})),Q=function(e){var a=e.data,r=J().classes,i=a.map((function(e){return n.jsxs("div",p({className:r.stat},{children:[n.jsx(t.Text,p({className:r.count},{children:e.value.toLocaleString()})),n.jsx(t.Text,p({className:r.title},{children:e.title})),n.jsx(t.Text,p({className:r.description},{children:"".concat(e.diff,"% ").concat(e.diff<0?"decrease":"increase"," compared to last period")}))]}),e.title)}));return n.jsx("div",p({className:r.root},{children:i}))},Z=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),ee=function(e){var a=Z().classes,r=e.data.givenName?[e.data.givenName,e.data.familyName].join(" ").trim():e.data.email,i=e.data.givenName?e.data.givenName:"Me";return"compact"===e.variant?n.jsxs(n.Fragment,{children:[n.jsx(t.Title,p({className:a.title},{children:r})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"xs"},{children:e.data.quote}))]}):n.jsxs(n.Fragment,{children:[n.jsxs(t.Paper,p({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[n.jsx(t.Avatar,{src:e.data.avatar,size:135,radius:120,mx:"auto"}),n.jsx(t.Text,p({align:"center",size:"lg",weight:500,mt:"md"},{children:r})),n.jsxs(t.Text,p({align:"center",color:"dimmed",size:"sm"},{children:[e.data.email," • ",e.data.job]}))]})),n.jsx(t.Blockquote,p({mt:"xl",color:"blue",cite:"– ".concat(i)},{children:e.data.quote}))]})},ne=[{value:"Member",label:"Member"},{value:"Admin",label:"Admin"}];function te(e){var r=e.data.map((function(r){return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx(t.UnstyledButton,p({onClick:function(){return e.onViewProfile&&e.onViewProfile(r)}},{children:n.jsxs(t.Group,p({spacing:"sm"},{children:[n.jsx(t.Avatar,{size:40,src:r.avatar,radius:40}),n.jsxs("div",{children:[n.jsx(t.Text,p({size:"sm",weight:500},{children:r.givenName&&r.familyName?"".concat(r.givenName," ").concat(r.familyName):r.email})),n.jsx(t.Text,p({size:"xs",color:"dimmed"},{children:r.email}))]})]}))}))}),n.jsx("td",{children:n.jsx(t.Select,{data:g([],ne,!0).map((function(e){return r.readonly?p(p({},e),{disabled:e.value!==r.role}):e})),defaultValue:r.role,variant:"unstyled",onChange:function(n){return!r.readonly&&e.onChangeRole&&e.onChangeRole(r,n)}})}),n.jsx("td",{children:r.lastActivity?Y(r.lastActivity):""}),n.jsx("td",{children:n.jsx(t.Group,p({noWrap:!0,spacing:0,position:"right"},{children:!r.readonly&&n.jsx(t.ActionIcon,p({color:"red"},{children:n.jsx(i.IconTrash,{onClick:function(){return i=r,a.openConfirmModal({title:'Delete "'.concat(i.givenName&&i.familyName?"".concat(i.givenName," ").concat(i.familyName):i.email,'"?'),centered:!0,children:n.jsx(t.Text,p({size:"sm"},{children:"Are you sure you want to delete this person? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete",cancel:"No don't delete them"},confirmProps:{color:"red"},onConfirm:function(){return e.onDelete&&e.onDelete(i)}});var i},size:16,stroke:1.5})}))}))})]},r.email)}));return 0===e.data.length?n.jsx(w,{data:{title:"No one in group",icon:"thinking",description:"You don't have any people in this group yet. When your ready, get started by clicking the 'Add people' button above."}}):n.jsx(t.ScrollArea,{children:n.jsxs(t.Table,p({verticalSpacing:20,sx:{minWidth:700}},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Member"}),n.jsx("th",{children:"Role"}),n.jsx("th",{children:"Last active"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:r})]}))})}var ae=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600},wrapper:{position:"relative",marginBottom:30},dropzone:{borderWidth:1,paddingBottom:50},icon:{color:"dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[4]},control:{position:"absolute",width:250,left:"calc(50% - 125px)",bottom:-20}}})),re=function(e){var a=ae().classes,r=s.useForm({initialValues:{key:"",email:"",givenName:"",familyName:"",avatar:"",role:"",readonly:!1,lastActivity:null},validate:{email:function(n){return/^\S+@\S+$/.test(n)&&0===e.data.users.filter((function(e){return e.email===n})).length?null:"Invalid email"}}}),l=o.useState(!1),c=l[0],d=l[1],u=o.useState(e.data.groupUserHomeOpen),h=u[0],m=u[1];return h?n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(t.Grid,{children:n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:function(){return m(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(i.IconArrowLeft,{size:14})})),size:"lg"},{children:"Users"})),n.jsx(ee,{variant:"compact",data:e.data.user})]}))}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.user.loading,overlayBlur:2}),n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsx(Q,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(K,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))]}))]}))})):n.jsxs(n.Fragment,{children:[n.jsx(t.Drawer,p({opened:c,onClose:function(){return d(!1)},title:n.jsx(t.Title,p({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsx(ie,p({},e,{close:function(){return d(!1)}})),n.jsx(t.Divider,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),n.jsx("form",p({onSubmit:r.onSubmit((function(){var n=r.values;r.reset(),d(!1),e.onCreateUsers&&e.onCreateUsers([n])}))},{children:n.jsxs(t.Stack,{children:[n.jsx(t.TextInput,p({withAsterisk:!0,label:"Email",placeholder:"Email"},r.getInputProps("email"))),n.jsxs(t.Group,p({grow:!0},{children:[n.jsx(t.TextInput,p({label:"Given name",placeholder:"Given name"},r.getInputProps("givenName"))),n.jsx(t.TextInput,p({label:"Family name",placeholder:"Family name"},r.getInputProps("familyName")))]})),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",leftSection:n.jsx(t.ActionIcon,p({onClick:e.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:n.jsx(i.IconArrowLeft,{size:14})})),size:"lg"},{children:"Groups"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:e.data.name||"Group"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:e.data.description||"No description"}))]})),n.jsx(t.Grid.Col,p({sm:"content"},{children:n.jsx(t.Button,p({onClick:function(){return d(!0)},leftIcon:n.jsx(i.IconPlaylistAdd,{size:14})},{children:"Add people"}))}))]}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(te,{data:e.data.users,onDelete:e.onDelete,onChangeRole:e.onRoleChange,onViewProfile:function(n){return e.onViewProfile(n).then((function(){m(!0)}))}})]}))]}))}))]})},ie=function(e){var a=ae(),r=a.classes,o=a.theme,s=m.useRef(null),c=m.useState(!1),d=c[0],u=c[1],h=m.useCallback((function(n){u(!0),n.forEach((function(n){x.parse(n,{download:!0,header:!0,dynamicTyping:!0,skipEmptyLines:!0,worker:!0,complete:function(n){var t=n.data.filter((function(n){return/^\S+@\S+$/.test(n.email)&&0===e.data.users.filter((function(e){return e.email===n.email})).length}));t.length>0&&e.onCreateUsers&&e.onCreateUsers(t),u(!1),e.close()}})}))}),[]);return n.jsxs("div",p({className:r.wrapper},{children:[n.jsx(l.Dropzone,p({loading:d,openRef:s,onDrop:h,className:r.dropzone,radius:"md",accept:[l.MIME_TYPES.csv],maxSize:5*Math.pow(1024,2)},{children:n.jsxs("div",p({style:{pointerEvents:"none"}},{children:[n.jsxs(t.Group,p({position:"center"},{children:[n.jsx(l.Dropzone.Accept,{children:n.jsx(i.IconDownload,{size:50,color:o.colors[o.primaryColor][6],stroke:1.5})}),n.jsx(l.Dropzone.Reject,{children:n.jsx(i.IconX,{size:50,color:o.colors.red[6],stroke:1.5})}),n.jsx(l.Dropzone.Idle,{children:n.jsx(i.IconCloudUpload,{size:50,color:"dark"===o.colorScheme?o.colors.dark[0]:o.black,stroke:1.5})})]})),n.jsxs(t.Text,p({align:"center",weight:700,size:"lg",mt:"xl"},{children:[n.jsx(l.Dropzone.Accept,{children:"Drop files here"}),n.jsx(l.Dropzone.Reject,{children:"Csv file less than 5mb"}),n.jsx(l.Dropzone.Idle,{children:"Upload multiple"})]})),n.jsxs(t.Text,p({align:"center",size:"sm",mt:"xs",color:"dimmed"},{children:["Drag'n'drop files here to upload. We can accept only ",n.jsx("i",{children:".csv"})," files that are less than 5mb in size."]}))]}))})),n.jsx(t.Button,p({className:r.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=s.current)||void 0===e?void 0:e.call(s)}},{children:"Select file"}))]}))};function oe(e){if(0===e.data.length)return n.jsx(w,{data:{title:"No groups",icon:"groups",description:"You don't have any groups just yet. When your ready, get started by clicking the 'Create group' button above."}});var r=e.data.map((function(r){return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx(t.Text,p({size:14},{children:r.name}))}),n.jsx("td",{children:n.jsx(t.Text,p({size:14},{children:r.description}))}),n.jsx("td",{children:n.jsxs(t.Group,p({noWrap:!0,spacing:0,position:"right"},{children:[n.jsx(t.ActionIcon,p({color:"blue",onClick:function(){return e.onEditGroup&&e.onEditGroup(r)},variant:"subtle"},{children:n.jsx(i.IconUsers,{size:16,stroke:1.5})})),n.jsxs(t.Menu,p({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[n.jsx(t.Menu.Target,{children:n.jsx(t.ActionIcon,{children:n.jsx(i.IconDots,{size:16,stroke:1.5})})}),n.jsx(t.Menu.Dropdown,{children:n.jsx(t.Menu.Item,p({onClick:function(){return i=r,a.openConfirmModal({title:'Delete "'.concat(i.name,'"?'),centered:!0,children:n.jsx(t.Text,p({size:"sm"},{children:"Are you sure you want to delete this group? This action is destructive and you will have to contact support to restore your data."})),labels:{confirm:"Delete group",cancel:"No don't delete it"},confirmProps:{color:"red"},onConfirm:function(){return e.onDeleteGroup&&e.onDeleteGroup(i)}});var i},icon:n.jsx(i.IconTrash,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},r.name)}));return n.jsx(t.ScrollArea.Autosize,p({maxHeight:300},{children:n.jsxs(t.Table,p({verticalSpacing:20,sx:{minWidth:700}},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Description"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:r})]}))}))}var se=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),le=function(e){var a=se().classes,r=s.useForm({initialValues:{key:"",name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=o.useState(e.data.formOpen),c=l[0],d=l[1],u=o.useState(e.data.groupOpen),h=u[0],m=u[1];return h?n.jsx(re,{data:e.data.group,onBackClick:function(){return m(!1)},onCreateUsers:e.onCreateGroupUsers,onDelete:e.onDeleteGroupUser,onViewProfile:e.onViewGroupUser,onRoleChange:e.onGroupUserRoleChange,onTimelineScrollBottom:e.onTimelineScrollBottom}):n.jsxs(n.Fragment,{children:[n.jsx(t.Drawer,p({opened:c,onClose:function(){return d(!1)},title:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5"},{children:"Create a group"})),n.jsx(t.Tooltip,p({label:"Groups settings cannot be modified once created"},{children:n.jsx(t.ActionIcon,{children:n.jsx(i.IconInfoCircle,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n.jsxs("form",p({onSubmit:r.onSubmit((function(){var n=r.values;r.reset(),d(!1),e.onCreateGroup&&e.onCreateGroup(n)}))},{children:[n.jsxs(t.Stack,{children:[n.jsx(t.TextInput,p({withAsterisk:!0,label:"Name",placeholder:"Group name"},r.getInputProps("name"))),n.jsx(t.TextInput,p({label:"Description",placeholder:"A group for my first period class"},r.getInputProps("description")))]}),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,p({spacing:"md"},{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Badge,p({variant:"filled",size:"lg"},{children:"Groups"})),n.jsx(t.Title,p({order:2,className:a.title,mt:"md"},{children:"Organize people into groups"})),n.jsx(t.Text,p({color:"dimmed",className:a.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),n.jsx(t.Grid.Col,p({sm:"content"},{children:n.jsx(t.Button,p({onClick:function(){return d(!0)},leftIcon:n.jsx(i.IconPlaylistAdd,{size:14})},{children:"Create group"}))}))]}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(oe,{data:e.data.groups,onDeleteGroup:e.onDeleteGroup,onEditGroup:function(n){e.onEditGroup&&e.onEditGroup(n),m(!0)}})]}))]}))}))]})},ce=t.createStyles((function(e){return{card:{height:240,backgroundSize:"cover",backgroundPosition:"center"},content:{position:"absolute",padding:e.spacing.xl,zIndex:1,top:0,bottom:0,right:0,left:0},action:{position:"absolute",bottom:e.spacing.xl,right:e.spacing.xl},title:{color:e.white,marginBottom:e.spacing.xs/2},description:{color:e.white,maxWidth:220}}})),de=function(e){var a=e.title,r=e.description,i=e.image,o=e.action,s=e.style,l=e.className,c=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)n.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(t[a[r]]=e[a[r]])}return t}(e,["title","description","image","action","style","className"]),d=ce(),u=d.classes,h=d.cx,m=d.theme;return n.jsxs(t.Card,p({radius:"md",style:p({backgroundImage:"url(".concat(i,")")},s),className:h(u.card,l)},c,{children:[n.jsx(t.Overlay,{gradient:"linear-gradient(105deg, ".concat(m.black," 20%, #312f2f 50%, ").concat(m.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n.jsxs("div",p({className:u.content},{children:[n.jsx(t.Text,p({size:"lg",weight:700,className:u.title},{children:a})),n.jsx(t.Text,p({size:"sm",className:u.description},{children:r})),n.jsx(t.Button,p({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},ue=function(e){return n.jsx(t.Container,p({size:"lg"},{children:n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsxs(t.Grid,p({gutter:"md"},{children:[n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(ee,{data:e.data.user})})),n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(de,{title:e.data.tenant.name,description:e.data.tenant.description,image:e.data.tenant.image,action:{label:"Visit website",link:e.data.tenant.website}})}))]})),n.jsx(Q,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(K,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))}))},he=t.createStyles((function(e){return{header:{position:"sticky",top:0,backgroundColor:"dark"===e.colorScheme?e.colors.dark[7]:e.white,transition:"box-shadow 150ms ease","&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,borderBottom:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[3]:e.colors.gray[2])}},scrolled:{boxShadow:e.shadows.sm}}})),me=function(e){var a,r=e.data,i=he(),s=i.classes,l=i.cx,c=o.useState(!1),d=c[0],u=c[1],h=r.map((function(e){return e.value})),m=Math.round(h.reduce((function(e,n){return e+n}))/h.length),x=r.map((function(e){return n.jsxs("tr",{children:[n.jsx("td",{children:e.name}),n.jsx("td",{children:e.email}),n.jsx("td",{children:e.value}),n.jsx("td",{children:e.value>m?n.jsx(t.Badge,{children:"Above average"}):e.value===m?n.jsx(t.Badge,p({color:"gray"},{children:"Average"})):n.jsx(t.Badge,p({color:"red"},{children:"Below average"}))})]},e.name)}));return n.jsx(t.ScrollArea,p({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n.jsxs(t.Table,p({verticalSpacing:"md",sx:{minWidth:700}},{children:[n.jsx("thead",p({className:l(s.header,(a={},a[s.scrolled]=d,a))},{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Email"}),n.jsx("th",{children:"Value"}),n.jsx("th",{children:"Status"})]})})),n.jsx("tbody",{children:x})]}))}))},xe=function(e){return n.jsx(t.Paper,p({mih:150,p:"lg",withBorder:!0},{children:n.jsxs(t.Stack,{children:[n.jsx(t.Grid,{children:n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5",mb:0},{children:"Performance History"})),n.jsx(t.Tooltip,p({label:"Shows group performance per person"},{children:n.jsx(t.ActionIcon,{children:n.jsx(i.IconInfoCircle,{color:"#3b82f6",size:14})})}))]}))}))}),n.jsx(t.Group,p({spacing:"sm"},{children:n.jsx(t.Select,{placeholder:"Select a metric",value:e.data.metric,onChange:e.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})})),n.jsx(me,{data:e.data.users})]})}))},pe=t.createStyles((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),ge=function(e){var a=pe().theme;return n.jsx(t.Paper,p({p:"lg",withBorder:!0},{children:n.jsxs(t.Stack,{children:[n.jsxs(t.Grid,{children:[n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsxs(t.Group,p({spacing:0},{children:[n.jsx(t.Title,p({size:"h5",mb:0},{children:"Performance History"})),n.jsx(t.Tooltip,p({label:"Shows daily increase or decrease across group"},{children:n.jsx(t.ActionIcon,{children:n.jsx(i.IconInfoCircle,{color:"#3b82f6",size:14})})}))]}))})),n.jsx(t.Grid.Col,p({sm:5},{children:n.jsx(t.Select,{placeholder:"Select a metric",value:e.data.metric,onChange:e.onMetricChange,data:[{label:"PROBLEMS SOLVED",value:"PROBLEMS SOLVED"},{label:"LESSONS COMPLETED",value:"LESSONS COMPLETED"},{label:"BADGES EARNED",value:"BADGES EARNED"}]})}))]}),n.jsx(u.ResponsiveContainer,p({width:"100%",height:400},{children:n.jsxs(u.AreaChart,p({width:730,height:250,data:e.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[n.jsx("defs",{children:n.jsxs("linearGradient",p({id:"colorBlue",x1:"0",y1:"0",x2:"0",y2:"1"},{children:[n.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.4}),n.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}))}),n.jsx(u.XAxis,{tick:{fontSize:12,fontFamily:a.fontFamily},dataKey:"name"}),n.jsx(u.YAxis,{tick:{fontSize:12,fontFamily:a.fontFamily}}),n.jsx(u.CartesianGrid,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),n.jsx(u.Tooltip,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:a.fontFamily},labelStyle:{fontSize:12,fontFamily:a.fontFamily}}),n.jsx(u.Area,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},fe=t.createStyles((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),je=function(e){var a=e.data,r=fe().classes,o=a.map((function(e){var a=e.diff>0?i.IconArrowUpRight:i.IconArrowDownRight;return n.jsxs(t.Paper,p({withBorder:!0,p:"md",radius:"md"},{children:[n.jsxs(t.Group,p({position:"apart"},{children:[n.jsxs("div",{children:[n.jsx(t.Text,p({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:r.label},{children:e.title})),n.jsx(t.Text,p({weight:700,size:"xl"},{children:e.value.toLocaleString()}))]}),n.jsx(t.ThemeIcon,p({color:"gray",variant:"light",sx:function(n){return{color:e.diff>0?n.colors.teal[6]:n.colors.red[6]}},size:38,radius:"md"},{children:n.jsx(a,{size:28,stroke:1.5})}))]})),n.jsxs(t.Text,p({color:"dimmed",size:"sm",mt:"md"},{children:[n.jsxs(t.Text,p({component:"span",color:e.diff>0?"teal":"red",weight:700},{children:[e.diff,"%"]}))," ",e.diff>0?"increase":"decrease"," compared to last period"]}))]}),e.title)}));return n.jsx("div",p({className:r.root},{children:n.jsx(t.SimpleGrid,p({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:o}))}))},ve=function(e){return n.jsxs(n.Fragment,{children:[n.jsx(je,{data:[{title:"PROBLEMS SOLVED",value:e.data.stats["PROBLEMS SOLVED"].value,diff:e.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:e.data.stats["LESSONS COMPLETED"].value,diff:e.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:e.data.stats["BADGES EARNED"].value,diff:e.data.stats["BADGES EARNED"].diff}]}),n.jsx(ge,{data:e.data.areaChart,onMetricChange:e.onMetricChange})]})},Ce=[{value:"Overview"},{value:"Breakdown"}],Se=function(e){var a=ye(e.data.breakdown,e.onBreakdownMetricChange),r=ke(e.data.dateRange,e.onDateRangeChange),o=Te(e.data.groups,e.onGroupChange),s=we(e.data.overview,e.onOverviewMetricChange),l=ze(e.data.tab,e.onTabChange);return n.jsx(t.Container,p({size:"lg",py:"xl"},{children:n.jsxs(t.Stack,{children:[n.jsxs(t.Grid,{children:[n.jsxs(t.Grid.Col,p({sm:"auto"},{children:[n.jsx(t.Title,p({size:"h3"},{children:"Dashboard"})),n.jsx(t.Text,p({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),n.jsx(t.Grid.Col,p({sm:2.5},{children:n.jsx(t.Select,{placeholder:"Select a group",nothingFound:"No options",value:o.select,onChange:o.onSelectChange,icon:n.jsx(i.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})})),n.jsx(t.Grid.Col,p({sm:"auto"},{children:n.jsx(d.DateRangePicker,{placeholder:"Select a date",allowSingleDateInRange:!0,value:r.value,onChange:r.onChange,icon:n.jsx(i.IconCalendar,{size:16})})}))]}),n.jsxs(t.Stack,{children:[n.jsx(j,{data:Ce,value:l.value,onChange:l.onChange}),n.jsxs("div",p({style:{position:"relative"}},{children:[n.jsx(t.LoadingOverlay,{visible:e.data.loading,overlayBlur:2}),n.jsx(be,p({},e,{data:p(p({},e.data),{overview:s.data,breakdown:a.data}),active:l.value,onBreakdownMetricChange:a.onMetricChange,onOverviewMetricChange:s.onMetricChange}))]}))]})]})}))},be=function(e){if(0===e.data.overview.stats["PROBLEMS SOLVED"].value)return n.jsx(w,{data:{title:"No data for period",icon:"dashboard",description:"We haven't received any data yet for your group during this period. Check back later once progress has been made."}});switch(e.active){case"Overview":return n.jsx(ve,{data:e.data.overview,onMetricChange:e.onOverviewMetricChange});case"Breakdown":return n.jsx(xe,{data:e.data.breakdown,onMetricChange:e.onBreakdownMetricChange});default:return null}},ye=function(e,n){var t=m.useState(e.metric),a=t[0],r=t[1];return{data:p(p({},e),{metric:a}),onMetricChange:function(e){r(e),n&&n(e)}}},ke=function(e,n){var t=m.useState(e),a=t[0],r=t[1];return{value:a,onChange:function(e){r(e),n&&n(e)}}},Te=function(e,n){var t=e.filter((function(e){return e.active})),a=m.useState(t.length>0?t[0].name:null),r=a[0],i=a[1];return{select:r,onSelectChange:function(e){i(e),n&&n(e)}}},we=function(e,n){var t=m.useState(e.areaChart.metric),a=t[0],r=t[1];return{data:p(p({},e),{areaChart:p(p({},e.areaChart),{metric:a})}),onMetricChange:function(e){r(e),n&&n(e)}}},ze=function(e,n){var t=m.useState(e),a=t[0],r=t[1];return{value:a,onChange:function(e){r(e),n&&n(e)}}},Be=t.createStyles((function(e){var n,t,a,r,i,o;return{footer:{paddingTop:2*e.spacing.xl,paddingBottom:2*e.spacing.xl,paddingLeft:3*e.spacing.xl,backgroundColor:"dark"===e.colorScheme?e.colors.dark[6]:e.colors.gray[0],borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[5]:e.colors.gray[2])},logo:(n={maxWidth:200},n[e.fn.smallerThan("sm")]={display:"flex",flexDirection:"column",alignItems:"center"},n),description:(t={marginTop:5},t[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs,textAlign:"center"},t),inner:(a={display:"flex",justifyContent:"space-between"},a[e.fn.smallerThan("sm")]={flexDirection:"column",alignItems:"center"},a),groups:(r={display:"flex",flexWrap:"wrap"},r[e.fn.smallerThan("sm")]={display:"none"},r),wrapper:{width:160},link:{display:"block",color:"dark"===e.colorScheme?e.colors.dark[1]:e.colors.gray[6],fontSize:e.fontSizes.sm,paddingTop:3,paddingBottom:3,"&:hover":{textDecoration:"underline"}},title:{fontSize:e.fontSizes.md,fontWeight:700,fontFamily:"Greycliff CF, ".concat(e.fontFamily),marginBottom:e.spacing.xs/2,color:"dark"===e.colorScheme?e.white:e.black},afterFooter:(i={display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:e.spacing.xl,paddingTop:e.spacing.xl,paddingBottom:e.spacing.xl,borderTop:"1px solid ".concat("dark"===e.colorScheme?e.colors.dark[4]:e.colors.gray[2])},i[e.fn.smallerThan("sm")]={flexDirection:"column"},i),social:(o={},o[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},o)}})),Ee=function(e,n){var t=o.useState(!e.hidden),a=t[0],r=t[1],i=o.useState(e.active),s=i[0],l=i[1];return{data:p(p({},e),{active:s,hidden:!a}),setChangeModalOpen:r,onAccountChange:function(e){l(e),r(!1),n&&n(e)}}},Ge=function(e,n){var t=o.useState(e||"Home"),a=t[0],r=t[1];return{key:a,active:a,onClick:function(e){var t;a!==e&&(t=e,-1===V.indexOf(t)&&r(e),n&&n(e))}}},Ne=function(e){switch(e.active){case"Dashboard":return n.jsx(Se,{data:e.data.dashboard,onBreakdownMetricChange:e.onDashboardBreakdownMetricChange,onDateRangeChange:e.onDashboardDateRangeChange,onGroupChange:e.onDashboardGroupChange,onOverviewMetricChange:e.onDashboardOverviewMetricChange,onTabChange:e.onDashboardTabChange});case"Home":return n.jsx(ue,{data:e.data.home,onTimelineScrollBottom:e.onHomeTimelineScrollBottom});case"Groups":return n.jsx(le,{data:e.data.groups,onCreateGroup:e.onCreateGroup,onCreateGroupUsers:e.onCreateGroupUsers,onDeleteGroup:e.onDeleteGroup,onDeleteGroupUser:e.onDeleteGroupUser,onEditGroup:e.onEditGroup,onViewGroupUser:e.onViewGroupUser,onGroupUserRoleChange:e.onGroupUserRoleChange,onTimelineScrollBottom:e.onGroupUserTimelineScrollBottom});case"Lessons":return n.jsx(M,{data:e.data.lessons,onAutocompleteChange:e.onLessonAutocompleteChange,onGroupChange:e.onLessonGroupChange,onLessonClick:e.onLessonClick,onPreview:e.onLessonPreview,onTabChange:e.onLessonTabChange,onUserClick:e.onLessonUserClick});case"Badges":return n.jsx(E,{data:e.data.badges,onAutocompleteChange:e.onBadgeAutocompleteChange,onGroupChange:e.onBadgeGroupChange,onBadgeClick:e.onBadgeClick,onPreview:e.onBadgePreview,onTabChange:e.onBadgeTabChange,onUserClick:e.onBadgeUserClick});default:return null}};Object.defineProperty(e,"showNotification",{enumerable:!0,get:function(){return r.showNotification}}),Object.defineProperty(e,"updateNotification",{enumerable:!0,get:function(){return r.updateNotification}}),e.Mgmt=function(e){var a=Be().classes,r=Ee(e.data.account,e.onAccountChange),o=Ge(e.data.navbar.active,(function(n){if("Change account"===n)r.setChangeModalOpen(!0);e.onNavbarClick&&e.onNavbarClick(n)}));return n.jsxs(t.AppShell,p({padding:"xs",navbar:n.jsx(H,{active:o.active,onClick:o.onClick},o.key),footer:n.jsxs("footer",p({className:a.footer},{children:[n.jsxs(t.Container,p({className:a.inner},{children:[n.jsxs("div",p({className:a.logo},{children:[n.jsxs(t.Group,p({spacing:"xs"},{children:[n.jsx("div",p({style:{width:15}},{children:n.jsx(t.Image,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),n.jsx(t.Title,p({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),n.jsx(t.Text,p({size:"xs",color:"dimmed",className:a.description},{children:"We connect students to powerful civic learning experiences."}))]})),n.jsx("div",p({className:a.groups},{children:n.jsxs("div",p({className:a.wrapper},{children:[n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),n.jsx(t.Text,p({className:a.link,component:"a",href:"https://localcivics.notion.site/Help-Center-b52300f587b64fc0a61f512686e7626d",target:"_blank"},{children:"FAQ"}))]}))}))]})),n.jsxs(t.Container,p({className:a.afterFooter},{children:[n.jsxs(t.Text,p({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n.jsxs(t.Group,p({spacing:0,className:a.social,position:"right",noWrap:!0},{children:[n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:n.jsx(i.IconBrandInstagram,{size:18,stroke:1.5})})),n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:n.jsx(i.IconBrandLinkedin,{size:18,stroke:1.5})})),n.jsx(t.ActionIcon,p({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:n.jsx(i.IconBrandFacebook,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[n.jsxs("div",p({style:{position:"relative"}},{children:[e.data.loading&&n.jsx(t.Center,p({style:{height:400}},{children:n.jsx(t.Loader,{})})),!e.data.loading&&n.jsx(Ne,p({},e,{active:o.active}))]})),n.jsx(R,{data:r.data,onChange:r.onAccountChange,onClose:function(){return r.setChangeModalOpen(!1)}})]}))},e.MgmtProvider=function(e){return n.jsx(t.MantineProvider,p({withNormalizeCSS:!0,withGlobalStyles:!0,emotionCache:f,theme:{loader:"bars"}},{children:n.jsx(r.NotificationsProvider,p({limit:e.notificationLimit||5},{children:n.jsx(a.ModalsProvider,{children:e.children})}))}))},e.SwitchAccount=R,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -10,6 +10,7 @@ export type GroupUserItem = {
10
10
  familyName: string;
11
11
  role: string;
12
12
  lastActivity: Date | null;
13
+ readonly: boolean;
13
14
  };
14
15
  /**
15
16
  * GroupUserTableProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@local-civics/mgmt-ui",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "scripts": {