@local-civics/mgmt-ui 0.1.3 → 0.1.4

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.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './providers/MgmtProvider/MgmtProvider';
2
2
  export * from './shells/Mgmt/Mgmt';
3
+ export * from './shells/Mgmt/SwitchAccount/SwitchAccount';
3
4
  export * from './hooks/notifications';
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n,Fragment as a}from"react/jsx-runtime";import{MantineProvider as t,Tabs as i,UnstyledButton as r,Group as o,Avatar as l,Text as c,ScrollArea as d,Table as s,createStyles as h,Container as u,Stack as m,Grid as p,Badge as g,ActionIcon as f,Title as v,Button as C,Divider as S,Select as k,Autocomplete as b,Modal as y,Navbar as z,Center as w,Image as x,Tooltip as E,Anchor as N,Timeline as D,Paper as L,Blockquote as B,Drawer as O,TextInput as T,Menu as G,Card as P,Overlay as A,ThemeIcon as M,SimpleGrid as R,AppShell as W}from"@mantine/core";import{ModalsProvider as V,openConfirmModal as U}from"@mantine/modals";import{NotificationsProvider as F}from"@mantine/notifications";export{showNotification,updateNotification}from"@mantine/notifications";import{IconArrowLeft as I,IconCategory2 as j,IconSwitchHorizontal as H,IconLogout as _,IconHome2 as q,IconGauge as K,IconAlbum as $,IconLambda as J,IconBadges as Q,IconSchool as Y,IconActivityHeartbeat as Z,IconTimelineEvent as X,IconTrash as ee,IconPlaylistAdd as ne,IconDownload as ae,IconX as te,IconCloudUpload as ie,IconUsers as re,IconDots as oe,IconInfoCircle as le,IconArrowUpRight as ce,IconArrowDownRight as de,IconCalendar as se,IconBrandInstagram as he,IconBrandLinkedin as ue,IconBrandFacebook as me}from"@tabler/icons";import*as pe from"react";import{useState as ge,createElement as fe,useRef as ve}from"react";import{useForm as Ce}from"@mantine/form";import{Dropzone as Se,MIME_TYPES as ke}from"@mantine/dropzone";import*as be from"papaparse";import{DateRangePicker as ye}from"@mantine/dates";import{ResponsiveContainer as ze,AreaChart as we,XAxis as xe,YAxis as Ee,CartesianGrid as Ne,Tooltip as De,Area as Le}from"recharts";var Be=function(){return Be=Object.assign||function(e){for(var n,a=1,t=arguments.length;a<t;a++)for(var i in n=arguments[a])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Be.apply(this,arguments)};var Oe=function(n){return e(t,Be({withNormalizeCSS:!0,withGlobalStyles:!0},{children:e(F,Be({limit:n.notificationLimit||5},{children:e(V,{children:n.children})}))}))},Te=function(n){var a,t=null===(a=n.data)||void 0===a?void 0:a.map((function(n){return e(i.Tab,Be({value:n.value},{children:n.label||n.value}),n.value)}));return e(i,Be({value:n.value,onTabChange:n.onChange},{children:e(i.List,{children:t})}))};function Ge(a){var t=a.data.map((function(t){return e("tr",{children:e("td",{children:e(r,Be({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(t)}},{children:n(o,{children:[e(l,{size:40,src:t.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:t.name})),e(c,Be({size:"xs",color:"dimmed"},{children:t.email}))]})]})}))})},t.name)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:t})}))}))}var Pe=[{value:"Complete"},{value:"Incomplete"}],Ae=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Me=function(a){var t=Re(a.data.groups,a.onGroupChange),i=We(a.data.tab,a.onTabChange),r=Ae().classes;return e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",leftSection:e(f,Be({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Badges"})),n(o,{children:[n(m,Be({spacing:0},{children:[e(v,Be({order:2,className:r.title,mt:"md"},{children:a.data.name||"Badge"})),e(c,Be({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(m,Be({ml:"auto"},{children:[e(C,Be({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(S,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(k,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:t.select,onChange:t.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Te,{data:Pe,value:i.value,onChange:i.onChange}),e(Ge,{data:a.data.users,onClick:a.onUserClick})]})]}))}))},Re=function(e,n){var a=e.filter((function(e){return e.active})),t=pe.useState(a.length>0?a[0].name:null),i=t[0],r=t[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},We=function(e,n){var a=pe.useState(e),t=a[0],i=a[1];return{value:t,onChange:function(e){i(e),n&&n(e)}}};function Ve(a){var t=a.data.map((function(t){return e("tr",{children:e("td",{children:e(r,Be({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(t)}},{children:e(o,{children:n("div",{children:[e(c,Be({size:"sm",weight:500},{children:t.name})),e(c,Be({size:"xs",color:"dimmed"},{children:t.description}))]})})}))})},t.key)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:t})}))}))}var Ue=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Fe=function(a){var t=Ue().classes,i=ge(a.data.badgeOpen),r=i[0],o=i[1];return r?e(Me,{data:a.data.badge,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",size:"lg"},{children:"Badges"})),e(v,Be({order:2,className:t.title,mt:"md"},{children:"Badges and micro-credentials"})),e(c,Be({color:"dimmed",className:t.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),e(b,{placeholder:"Search for a badge that fits your needs",data:a.data.badges.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),e(Ve,{data:a.data.badges,onClick:function(e){a.onBadgeClick&&a.onBadgeClick(e),o(!0)}})]}))}))};function Ie(a){var t=a.data.map((function(t){return e("tr",{children:e("td",{children:e(r,Be({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(t)}},{children:n(o,{children:[e(l,{size:40,src:t.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:t.name})),e(c,Be({size:"xs",color:"dimmed"},{children:t.email}))]})]})}))})},t.name)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:t})}))}))}var je=[{value:"Complete"},{value:"Incomplete"}],He=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),_e=function(a){var t=qe(a.data.groups,a.onGroupChange),i=Ke(a.data.tab,a.onTabChange),r=He().classes;return e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",leftSection:e(f,Be({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Lessons"})),n(o,{children:[n(m,Be({spacing:0},{children:[e(v,Be({order:2,className:r.title,mt:"md"},{children:a.data.name||"Lesson"})),e(c,Be({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(m,Be({ml:"auto"},{children:[e(C,Be({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(S,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(k,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:t.select,onChange:t.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Te,{data:je,value:i.value,onChange:i.onChange}),e(Ie,{data:a.data.users,onClick:a.onUserClick})]})]}))}))},qe=function(e,n){var a=e.filter((function(e){return e.active})),t=pe.useState(a.length>0?a[0].name:null),i=t[0],r=t[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},Ke=function(e,n){var a=pe.useState(e),t=a[0],i=a[1];return{value:t,onChange:function(e){i(e),n&&n(e)}}};function $e(a){var t=a.data.map((function(t){return e("tr",{children:e("td",{children:e(r,Be({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(t)}},{children:e(o,{children:n("div",{children:[e(c,Be({size:"sm",weight:500},{children:t.name})),e(c,Be({size:"xs",color:"dimmed"},{children:t.description}))]})})}))})},t.key)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:t})}))}))}var Je=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Qe=function(a){var t=Je().classes,i=ge(a.data.lessonOpen),r=i[0],o=i[1];return r?e(_e,{data:a.data.lesson,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",size:"lg"},{children:"Lessons"})),e(v,Be({order:2,className:t.title,mt:"md"},{children:"Lessons"})),e(c,Be({color:"dimmed",className:t.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),e(b,{placeholder:"Search for a lesson that fits your needs",data:a.data.lessons.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),e($e,{data:a.data.lessons,onClick:function(e){a.onLessonClick&&a.onLessonClick(e),o(!0)}})]}))}))},Ye=function(a){var t=Ce({initialValues:a.data.active});return e(y,Be({centered:!0,opened:!a.data.hidden,onClose:function(){return a.onClose&&a.onClose()},size:"sm",title:e(v,Be({size:"h5"},{children:"Accounts"}))},{children:n("form",Be({onSubmit:t.onSubmit((function(){a.onChange&&a.onChange(t.values)}))},{children:[e(k,{required:!0,placeholder:"Select an account",defaultValue:a.data.active,data:a.data.accounts.map((function(e){return{value:e.key,label:e.name}}))}),e(C,Be({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},Ze=h((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}}}})),Xe=[{icon:q,label:"Home"},{icon:K,label:"Dashboard"},{icon:j,label:"Groups"},{icon:$,label:"Badges"},{icon:J,label:"Lessons"}],en=function(n){var a,t=n.icon,i=n.label,o=n.active,l=n.onClick,c=Ze(),d=c.classes,s=c.cx;return e(E,Be({label:i,position:"right",transitionDuration:0},{children:e(r,Be({onClick:l,className:s(d.link,(a={},a[d.active]=o,a))},{children:e(t,{stroke:1.5})}))}))},nn=["Logout","Change account"],an=function(a){var t=Xe.map((function(e){return fe(en,Be({},e,{key:e.label,active:e.label===a.active,onClick:function(){return a.onClick&&a.onClick(e.label)}}))}));return n(z,Be({width:{base:80},p:"md"},{children:[e(w,{children:e(l,Be({color:"blue",radius:"sm"},{children:e("div",Be({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:e(x,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),e(z.Section,Be({grow:!0,mt:50},{children:e(m,Be({justify:"center",spacing:0},{children:t}))})),e(z.Section,{children:n(m,Be({justify:"center",spacing:0},{children:[e(en,{icon:H,label:"Change account",onClick:function(){return a.onClick&&a.onClick("Change account")}}),e(en,{icon:_,label:"Logout",onClick:function(){return a.onClick&&a.onClick("Logout")}})]}))})]}))},tn=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],rn=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function on(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,a=tn;n<a.length;n++){var t=a[n],i=t.unit,r=t.ms;if(Math.abs(e)>=r||"second"===i)return rn.format(Math.round(e/r),i)}return""}(e.getTime()-n.getTime()):""}var ln={BadgeCompleted:e(Q,{size:12}),BadgeStarted:e(Q,{size:12}),LessonCompleted:e(Y,{size:12}),LessonStarted:e(Y,{size:12}),ProblemSolved:e(Z,{size:12})},cn=function(a){var t,i=ve(null),r=ge({x:0,y:0}),o=r[0],l=r[1];pe.useEffect((function(){i.current&&o.y===i.current.scrollHeight-i.current.offsetHeight&&a.onScrollBottom&&a.onScrollBottom()}),[o.y]);var s=a.data.map((function(a){var i=a.name.split(/(?=[A-Z])/),r=i[0]===t?"dashed":"solid";t=i[0];var o=a.link?e(N,Be({color:"dark",unstyled:!0,href:a.link,target:"_blank"},{children:"".concat(i[0]," ").concat(i[1].toLowerCase())})):"".concat(i[0]," ").concat(i[1].toLowerCase());return n(D.Item,Be({bullet:dn(a.name),lineVariant:r,title:o},{children:[e(c,Be({color:"dimmed",size:"sm"},{children:a.description})),e(c,Be({size:"xs",mt:4},{children:on(new Date(a.time))}))]}),a.key)}));return e(d.Autosize,Be({maxHeight:300,onScrollPositionChange:l,viewportRef:i},{children:e(D,Be({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:s}))}))},dn=function(n){var a=ln[n];return a||e(X,{size:12})},sn=h((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)}}})),hn=function(a){var t=a.data,i=sn().classes,r=t.map((function(a){return n("div",Be({className:i.stat},{children:[e(c,Be({className:i.count},{children:a.value.toLocaleString()})),e(c,Be({className:i.title},{children:a.title})),e(c,Be({className:i.description},{children:"".concat(a.diff,"% ").concat(a.diff<0?"decrease":"increase"," compared to last period")}))]}),a.title)}));return e("div",Be({className:i.root},{children:r}))},un=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),mn=function(t){var i=un().classes,r=t.data.givenName?[t.data.givenName,t.data.familyName].join(" ").trim():t.data.email,o=t.data.givenName?t.data.givenName:"Me";return"compact"===t.variant?n(a,{children:[e(v,Be({className:i.title},{children:r})),e(c,Be({color:"dimmed",className:i.description,mt:"xs"},{children:t.data.quote}))]}):n(a,{children:[n(L,Be({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[e(l,{src:t.data.avatar,size:135,radius:120,mx:"auto"}),e(c,Be({align:"center",size:"lg",weight:500,mt:"md"},{children:r})),n(c,Be({align:"center",color:"dimmed",size:"sm"},{children:[t.data.email," • ",t.data.job]}))]})),e(B,Be({mt:"xl",color:"blue",cite:"– ".concat(o)},{children:t.data.quote}))]})},pn=["Member","Admin"];function gn(a){var t=a.data.map((function(t){return n("tr",{children:[e("td",{children:e(r,Be({onClick:function(){return a.onViewProfile&&a.onViewProfile(t)}},{children:n(o,Be({spacing:"sm"},{children:[e(l,{size:40,src:t.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:t.givenName&&t.familyName?"".concat(t.givenName," ").concat(t.familyName):t.email})),e(c,Be({size:"xs",color:"dimmed"},{children:t.email}))]})]}))}))}),e("td",{children:e(k,{data:pn,defaultValue:t.role,variant:"unstyled",onChange:function(e){return a.onChangeRole&&a.onChangeRole(t,e)}})}),e("td",{children:t.lastActivity?on(t.lastActivity):""}),e("td",{children:e(o,Be({noWrap:!0,spacing:0,position:"right"},{children:e(f,Be({color:"red"},{children:e(ee,{onClick:function(){return U({title:'Delete "'.concat((n=t).givenName&&n.familyName?"".concat(n.givenName," ").concat(n.familyName):n.email,'"?'),centered:!0,children:e(c,Be({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})}))}))})]},t.email)}));return e(d,{children:n(s,Be({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:t})]}))})}var fn=h((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}}})),vn=function(t){var i=fn().classes,r=Ce({initialValues:{key:"",email:"",givenName:"",familyName:"",avatar:"",role:"",lastActivity:null},validate:{email:function(e){return/^\S+@\S+$/.test(e)&&0===t.data.users.filter((function(n){return n.email===e})).length?null:"Invalid email"}}}),l=ge(!1),d=l[0],s=l[1],h=ge(t.data.groupUserHomeOpen),k=h[0],b=h[1];return k?e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",leftSection:e(f,Be({onClick:function(){return b(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Users"})),e(mn,{variant:"compact",data:t.data.user})]}))}),n(m,Be({spacing:"lg"},{children:[e(hn,{data:[{title:"PROBLEMS SOLVED",value:t.data.stats["PROBLEMS SOLVED"].value,diff:t.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:t.data.stats["LESSONS COMPLETED"].value,diff:t.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:t.data.stats["BADGES EARNED"].value,diff:t.data.stats["BADGES EARNED"].diff}]}),e(cn,{onScrollBottom:t.onTimelineScrollBottom,data:t.data.timeline})]}))]}))})):n(a,{children:[e(O,Be({opened:d,onClose:function(){return s(!1)},title:e(v,Be({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(Cn,Be({},t,{close:function(){return s(!1)}})),e(S,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),e("form",Be({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),t.onCreateUsers&&t.onCreateUsers([e])}))},{children:n(m,{children:[e(T,Be({withAsterisk:!0,label:"Email",placeholder:"Email"},r.getInputProps("email"))),n(o,Be({grow:!0},{children:[e(T,Be({label:"Given name",placeholder:"Given name"},r.getInputProps("givenName"))),e(T,Be({label:"Family name",placeholder:"Family name"},r.getInputProps("familyName")))]})),e(C,Be({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",leftSection:e(f,Be({onClick:t.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Groups"})),e(v,Be({order:2,className:i.title,mt:"md"},{children:t.data.name||"Group"})),e(c,Be({color:"dimmed",className:i.description,mt:"sm"},{children:t.data.description||"No description"}))]})),e(p.Col,Be({sm:"content"},{children:e(C,Be({onClick:function(){return s(!0)},leftIcon:e(ne,{size:14})},{children:"Add people"}))}))]}),e(gn,{data:t.data.users,onDelete:t.onDelete,onChangeRole:t.onRoleChange,onViewProfile:function(e){return t.onViewProfile(e).then((function(){b(!0)}))}})]}))}))]})},Cn=function(a){var t=fn(),i=t.classes,r=t.theme,l=pe.useRef(null),d=pe.useState(!1),s=d[0],h=d[1],u=pe.useCallback((function(e){h(!0),e.forEach((function(e){be.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",Be({className:i.wrapper},{children:[e(Se,Be({loading:s,openRef:l,onDrop:u,className:i.dropzone,radius:"md",accept:[ke.csv],maxSize:5*Math.pow(1024,2)},{children:n("div",Be({style:{pointerEvents:"none"}},{children:[n(o,Be({position:"center"},{children:[e(Se.Accept,{children:e(ae,{size:50,color:r.colors[r.primaryColor][6],stroke:1.5})}),e(Se.Reject,{children:e(te,{size:50,color:r.colors.red[6],stroke:1.5})}),e(Se.Idle,{children:e(ie,{size:50,color:"dark"===r.colorScheme?r.colors.dark[0]:r.black,stroke:1.5})})]})),n(c,Be({align:"center",weight:700,size:"lg",mt:"xl"},{children:[e(Se.Accept,{children:"Drop files here"}),e(Se.Reject,{children:"Csv file less than 5mb"}),e(Se.Idle,{children:"Upload multiple"})]})),n(c,Be({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(C,Be({className:i.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)}},{children:"Select file"}))]}))};function Sn(a){var t=a.data.map((function(t){return n("tr",{children:[e("td",{children:e(c,Be({size:14},{children:t.name}))}),e("td",{children:e(c,Be({size:14},{children:t.description}))}),e("td",{children:n(o,Be({noWrap:!0,spacing:0,position:"right"},{children:[e(f,Be({color:"blue",onClick:function(){return a.onEditGroup&&a.onEditGroup(t)},variant:"subtle"},{children:e(re,{size:16,stroke:1.5})})),n(G,Be({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[e(G.Target,{children:e(f,{children:e(oe,{size:16,stroke:1.5})})}),e(G.Dropdown,{children:e(G.Item,Be({onClick:function(){return U({title:'Delete "'.concat((n=t).name,'"?'),centered:!0,children:e(c,Be({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(ee,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},t.name)}));return e(d.Autosize,Be({maxHeight:300},{children:n(s,Be({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:t})]}))}))}var kn=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),bn=function(t){var i=kn().classes,r=Ce({initialValues:{name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=ge(t.data.formOpen),d=l[0],s=l[1],h=ge(t.data.groupOpen),S=h[0],k=h[1];return S?e(vn,{data:t.data.group,onBackClick:function(){return k(!1)},onCreateUsers:t.onCreateGroupUsers,onDelete:t.onDeleteGroupUser,onViewProfile:t.onViewGroupUser,onRoleChange:t.onGroupUserRoleChange,onTimelineScrollBottom:t.onTimelineScrollBottom}):n(a,{children:[e(O,Be({opened:d,onClose:function(){return s(!1)},title:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5"},{children:"Create a group"})),e(E,Be({label:"Groups settings cannot be modified once created"},{children:e(f,{children:e(le,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n("form",Be({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),t.onCreateGroup&&t.onCreateGroup(e)}))},{children:[n(m,{children:[e(T,Be({withAsterisk:!0,label:"Name",placeholder:"Group name"},r.getInputProps("name"))),e(T,Be({label:"Description",placeholder:"A group for my first period class"},r.getInputProps("description")))]}),e(C,Be({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(g,Be({variant:"filled",size:"lg"},{children:"Groups"})),e(v,Be({order:2,className:i.title,mt:"md"},{children:"Organize people into groups"})),e(c,Be({color:"dimmed",className:i.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),e(p.Col,Be({sm:"content"},{children:e(C,Be({onClick:function(){return s(!0)},leftIcon:e(ne,{size:14})},{children:"Create group"}))}))]}),e(Sn,{data:t.data.groups,onDeleteGroup:t.onDeleteGroup,onEditGroup:function(e){t.onEditGroup&&t.onEditGroup(e),k(!0)}})]}))}))]})},yn=h((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}}})),zn=function(a){var t=a.title,i=a.description,r=a.image,o=a.action,l=a.style,d=a.className,s=function(e,n){var a={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(a[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(a[t[i]]=e[t[i]])}return a}(a,["title","description","image","action","style","className"]),h=yn(),u=h.classes,m=h.cx,p=h.theme;return n(P,Be({radius:"md",style:Be({backgroundImage:"url(".concat(r,")")},l),className:m(u.card,d)},s,{children:[e(A,{gradient:"linear-gradient(105deg, ".concat(p.black," 20%, #312f2f 50%, ").concat(p.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n("div",Be({className:u.content},{children:[e(c,Be({size:"lg",weight:700,className:u.title},{children:t})),e(c,Be({size:"sm",className:u.description},{children:i})),e(C,Be({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},wn=function(a){return e(u,Be({size:"lg"},{children:n(m,Be({spacing:"lg"},{children:[n(p,Be({gutter:"md"},{children:[e(p.Col,Be({md:6},{children:e(mn,{data:a.data.user})})),e(p.Col,Be({md:6},{children:e(zn,{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(hn,{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(cn,{onScrollBottom:a.onTimelineScrollBottom,data:a.data.timeline})]}))}))},xn=h((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}}})),En=function(a){var t,i=a.data,r=xn(),o=r.classes,l=r.cx,c=ge(!1),h=c[0],u=c[1],m=i.map((function(e){return e.value})),p=Math.round(m.reduce((function(e,n){return e+n}))/m.length),f=i.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(g,{children:"Above average"}):a.value===p?e(g,Be({color:"gray"},{children:"Average"})):e(g,Be({color:"red"},{children:"Below average"}))})]},a.name)}));return e(d,Be({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n(s,Be({verticalSpacing:"md",sx:{minWidth:700}},{children:[e("thead",Be({className:l(o.header,(t={},t[o.scrolled]=h,t))},{children:n("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Email"}),e("th",{children:"Value"}),e("th",{children:"Status"})]})})),e("tbody",{children:f})]}))}))},Nn=function(a){return e(L,Be({mih:150,p:"lg",withBorder:!0},{children:n(m,{children:[e(p,{children:e(p.Col,Be({sm:"auto"},{children:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5",mb:0},{children:"Performance History"})),e(E,Be({label:"Shows group performance per person"},{children:e(f,{children:e(le,{color:"#3b82f6",size:14})})}))]}))}))}),e(o,Be({spacing:"sm"},{children:e(k,{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(En,{data:a.data.users})]})}))},Dn=h((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),Ln=function(a){var t=Dn().theme;return e(L,Be({p:"lg",withBorder:!0},{children:n(m,{children:[n(p,{children:[e(p.Col,Be({sm:"auto"},{children:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5",mb:0},{children:"Performance History"})),e(E,Be({label:"Shows daily increase or decrease across group"},{children:e(f,{children:e(le,{color:"#3b82f6",size:14})})}))]}))})),e(p.Col,Be({sm:5},{children:e(k,{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(ze,Be({width:"100%",height:400},{children:n(we,Be({width:730,height:250,data:a.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[e("defs",{children:n("linearGradient",Be({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(xe,{tick:{fontSize:12,fontFamily:t.fontFamily},dataKey:"name"}),e(Ee,{tick:{fontSize:12,fontFamily:t.fontFamily}}),e(Ne,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),e(De,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:t.fontFamily},labelStyle:{fontSize:12,fontFamily:t.fontFamily}}),e(Le,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},Bn=h((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),On=function(a){var t=a.data,i=Bn().classes,r=t.map((function(a){var t=a.diff>0?ce:de;return n(L,Be({withBorder:!0,p:"md",radius:"md"},{children:[n(o,Be({position:"apart"},{children:[n("div",{children:[e(c,Be({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:i.label},{children:a.title})),e(c,Be({weight:700,size:"xl"},{children:a.value.toLocaleString()}))]}),e(M,Be({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(t,{size:28,stroke:1.5})}))]})),n(c,Be({color:"dimmed",size:"sm",mt:"md"},{children:[n(c,Be({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",Be({className:i.root},{children:e(R,Be({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:r}))}))},Tn=function(t){return n(a,{children:[e(On,{data:[{title:"PROBLEMS SOLVED",value:t.data.stats["PROBLEMS SOLVED"].value,diff:t.data.stats["PROBLEMS SOLVED"].diff},{title:"LESSONS COMPLETED",value:t.data.stats["LESSONS COMPLETED"].value,diff:t.data.stats["LESSONS COMPLETED"].diff},{title:"BADGES EARNED",value:t.data.stats["BADGES EARNED"].value,diff:t.data.stats["BADGES EARNED"].diff}]}),e(Ln,{data:t.data.areaChart,onMetricChange:t.onMetricChange})]})},Gn=[{value:"Overview"},{value:"Breakdown"}],Pn=function(a){var t=Mn(a.data.breakdown,a.onBreakdownMetricChange),i=Rn(a.data.dateRange,a.onDateRangeChange),r=Wn(a.data.groups,a.onGroupChange),o=Vn(a.data.overview,a.onOverviewMetricChange),l=Un(a.data.tab,a.onTabChange);return e(u,Be({size:"lg",py:"xl"},{children:n(m,{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(v,Be({size:"h3"},{children:"Dashboard"})),e(c,Be({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),e(p.Col,Be({sm:2.5},{children:e(k,{placeholder:"Select a group",nothingFound:"No options",value:r.select,onChange:r.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})})),e(p.Col,Be({sm:"auto"},{children:e(ye,{placeholder:"Select a date",allowSingleDateInRange:!0,value:i.value,onChange:i.onChange,icon:e(se,{size:16})})}))]}),n(m,{children:[e(Te,{data:Gn,value:l.value,onChange:l.onChange}),e(An,Be({},a,{data:Be(Be({},a.data),{overview:o.data,breakdown:t.data}),active:l.value,onBreakdownMetricChange:t.onMetricChange,onOverviewMetricChange:o.onMetricChange}))]})]})}))},An=function(n){switch(n.active){case"Overview":return e(Tn,{data:n.data.overview,onMetricChange:n.onOverviewMetricChange});case"Breakdown":return e(Nn,{data:n.data.breakdown,onMetricChange:n.onBreakdownMetricChange});default:return null}},Mn=function(e,n){var a=pe.useState(e.metric),t=a[0],i=a[1];return{data:Be(Be({},e),{metric:t}),onMetricChange:function(e){i(e),n&&n(e)}}},Rn=function(e,n){var a=pe.useState(e),t=a[0],i=a[1];return{value:t,onChange:function(e){i(e),n&&n(e)}}},Wn=function(e,n){var a=e.filter((function(e){return e.active})),t=pe.useState(a.length>0?a[0].name:null),i=t[0],r=t[1];return{select:i,onSelectChange:function(e){r(e),n&&n(e)}}},Vn=function(e,n){var a=pe.useState(e.areaChart.metric),t=a[0],i=a[1];return{data:Be(Be({},e),{areaChart:Be(Be({},e.areaChart),{metric:t})}),onMetricChange:function(e){i(e),n&&n(e)}}},Un=function(e,n){var a=pe.useState(e),t=a[0],i=a[1];return{value:t,onChange:function(e){i(e),n&&n(e)}}},Fn=h((function(e){var n,a,t,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:(a={marginTop:5},a[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs,textAlign:"center"},a),inner:(t={display:"flex",justifyContent:"space-between"},t[e.fn.smallerThan("sm")]={flexDirection:"column",alignItems:"center"},t),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)}})),In=function(a){var t=Fn().classes,i=jn(a.data.account,a.onAccountChange),r=Hn(a.data.navbar.active,(function(e){if("Change account"===e)i.setChangeModalOpen(!0);a.onNavbarClick&&a.onNavbarClick(e)}));return n(W,Be({padding:"xs",navbar:e(an,{active:r.active,onClick:r.onClick},r.key),footer:n("footer",Be({className:t.footer},{children:[n(u,Be({className:t.inner},{children:[n("div",Be({className:t.logo},{children:[n(o,Be({spacing:"xs"},{children:[e("div",Be({style:{width:15}},{children:e(x,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),e(v,Be({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),e(c,Be({size:"xs",color:"dimmed",className:t.description},{children:"We connect students to powerful civic learning experiences."}))]})),e("div",Be({className:t.groups},{children:n("div",Be({className:t.wrapper},{children:[e(c,Be({className:t.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),e(c,Be({className:t.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),e(c,Be({className:t.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),e(c,Be({className:t.link,component:"a",href:"https://docs.google.com/document/d/19d8bO2D_KSxyvT8HPS8RqJTRMla6jgBtVPV5HgcSAk8/view",target:"_blank"},{children:"FAQ"}))]}))}))]})),n(u,Be({className:t.afterFooter},{children:[n(c,Be({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n(o,Be({spacing:0,className:t.social,position:"right",noWrap:!0},{children:[e(f,Be({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:e(he,{size:18,stroke:1.5})})),e(f,Be({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:e(ue,{size:18,stroke:1.5})})),e(f,Be({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:e(me,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[e(_n,Be({},a,{active:r.active})),e(Ye,{data:i.data,onChange:i.onAccountChange,onClose:function(){return i.setChangeModalOpen(!1)}})]}))},jn=function(e,n){var a=ge(!e.hidden),t=a[0],i=a[1],r=ge(e.active),o=r[0],l=r[1];return{data:Be(Be({},e),{active:o,hidden:!t}),setChangeModalOpen:i,onAccountChange:function(e){l(e),i(!1),n&&n(e)}}},Hn=function(e,n){var a=ge(e||"Home"),t=a[0],i=a[1];return{key:t,active:t,onClick:function(e){var a;t!==e&&(a=e,-1===nn.indexOf(a)&&i(e),n&&n(e))}}},_n=function(n){switch(n.active){case"Dashboard":return e(Pn,{data:n.data.dashboard,onBreakdownMetricChange:n.onDashboardBreakdownMetricChange,onDateRangeChange:n.onDashboardDateRangeChange,onGroupChange:n.onDashboardGroupChange,onOverviewMetricChange:n.onDashboardOverviewMetricChange,onTabChange:n.onDashboardTabChange});case"Home":return e(wn,{data:n.data.home,onTimelineScrollBottom:n.onHomeTimelineScrollBottom});case"Groups":return e(bn,{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(Qe,{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(Fe,{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{In as Mgmt,Oe as MgmtProvider};
1
+ import{jsx as e,jsxs as n,Fragment as a}from"react/jsx-runtime";import{MantineProvider as i,Tabs as t,UnstyledButton as r,Group as o,Avatar as l,Text as c,ScrollArea as d,Table as s,createStyles as h,Container as u,Stack as m,Grid as p,Badge as f,ActionIcon as g,Title as v,Button as C,Divider as S,Select as b,Autocomplete as k,Modal as y,Navbar as z,Center as w,Image as x,Tooltip as E,Anchor as N,Timeline as D,Paper as L,Blockquote as B,Drawer as O,TextInput as T,Menu as G,Card as P,Overlay as A,ThemeIcon as M,SimpleGrid as R,AppShell as W}from"@mantine/core";import{ModalsProvider as U,openConfirmModal as F}from"@mantine/modals";import{NotificationsProvider as V}from"@mantine/notifications";export{showNotification,updateNotification}from"@mantine/notifications";import{IconArrowLeft as I,IconCategory2 as j,IconSwitchHorizontal as H,IconLogout as _,IconHome2 as q,IconGauge as K,IconAlbum as $,IconLambda as Q,IconBadges as Y,IconSchool as Z,IconActivityHeartbeat as J,IconTimelineEvent as X,IconTrash as ee,IconPlaylistAdd as ne,IconDownload as ae,IconX as ie,IconCloudUpload as te,IconUsers as re,IconDots as oe,IconInfoCircle as le,IconArrowUpRight as ce,IconArrowDownRight as de,IconCalendar as se,IconBrandInstagram as he,IconBrandLinkedin as ue,IconBrandFacebook as me}from"@tabler/icons";import*as pe from"react";import{useState as fe,createElement as ge,useRef as ve}from"react";import{useForm as Ce}from"@mantine/form";import{Dropzone as Se,MIME_TYPES as be}from"@mantine/dropzone";import*as ke from"papaparse";import{DateRangePicker as ye}from"@mantine/dates";import{ResponsiveContainer as ze,AreaChart as we,XAxis as xe,YAxis as Ee,CartesianGrid as Ne,Tooltip as De,Area as Le}from"recharts";var Be=function(){return Be=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},Be.apply(this,arguments)};var Oe=function(n){return e(i,Be({withNormalizeCSS:!0,withGlobalStyles:!0},{children:e(V,Be({limit:n.notificationLimit||5},{children:e(U,{children:n.children})}))}))},Te=function(n){var a,i=null===(a=n.data)||void 0===a?void 0:a.map((function(n){return e(t.Tab,Be({value:n.value},{children:n.label||n.value}),n.value)}));return e(t,Be({value:n.value,onTabChange:n.onChange},{children:e(t.List,{children:i})}))};function Ge(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(r,Be({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(o,{children:[e(l,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:i.name})),e(c,Be({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Pe=[{value:"Complete"},{value:"Incomplete"}],Ae=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),Me=function(a){var i=Re(a.data.groups,a.onGroupChange),t=We(a.data.tab,a.onTabChange),r=Ae().classes;return e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",leftSection:e(g,Be({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Badges"})),n(o,{children:[n(m,Be({spacing:0},{children:[e(v,Be({order:2,className:r.title,mt:"md"},{children:a.data.name||"Badge"})),e(c,Be({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(m,Be({ml:"auto"},{children:[e(C,Be({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(S,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(b,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Te,{data:Pe,value:t.value,onChange:t.onChange}),e(Ge,{data:a.data.users,onClick:a.onUserClick})]})]}))}))},Re=function(e,n){var a=e.filter((function(e){return e.active})),i=pe.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)}}},We=function(e,n){var a=pe.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}};function Ue(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(r,Be({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(o,{children:n("div",{children:[e(c,Be({size:"sm",weight:500},{children:i.name})),e(c,Be({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Fe=h((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=Fe().classes,t=fe(a.data.badgeOpen),r=t[0],o=t[1];return r?e(Me,{data:a.data.badge,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",size:"lg"},{children:"Badges"})),e(v,Be({order:2,className:i.title,mt:"md"},{children:"Badges and micro-credentials"})),e(c,Be({color:"dimmed",className:i.description,mt:"sm"},{children:"Project-sized skills acquisition and standards alignment."}))]}))}),e(k,{placeholder:"Search for a badge that fits your needs",data:a.data.badges.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),e(Ue,{data:a.data.badges,onClick:function(e){a.onBadgeClick&&a.onBadgeClick(e),o(!0)}})]}))}))};function Ie(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(r,Be({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(o,{children:[e(l,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:i.name})),e(c,Be({size:"xs",color:"dimmed"},{children:i.email}))]})]})}))})},i.name)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var je=[{value:"Complete"},{value:"Incomplete"}],He=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),_e=function(a){var i=qe(a.data.groups,a.onGroupChange),t=Ke(a.data.tab,a.onTabChange),r=He().classes;return e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",leftSection:e(g,Be({onClick:a.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Lessons"})),n(o,{children:[n(m,Be({spacing:0},{children:[e(v,Be({order:2,className:r.title,mt:"md"},{children:a.data.name||"Lesson"})),e(c,Be({color:"dimmed",className:r.description,mt:"sm"},{children:a.data.description||"No description"}))]})),n(m,Be({ml:"auto"},{children:[e(C,Be({variant:"gradient",onClick:function(){return a.onPreview&&a.onPreview(a.data)}},{children:"Preview"})),e(S,{label:"or",labelPosition:"center",my:"xs",variant:"dashed"}),e(b,{size:"sm",placeholder:"Select a group",nothingFound:"No options",value:i.select,onChange:i.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n("div",{children:[e(Te,{data:je,value:t.value,onChange:t.onChange}),e(Ie,{data:a.data.users,onClick:a.onUserClick})]})]}))}))},qe=function(e,n){var a=e.filter((function(e){return e.active})),i=pe.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)}}},Ke=function(e,n){var a=pe.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}};function $e(a){var i=a.data.map((function(i){return e("tr",{children:e("td",{children:e(r,Be({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(o,{children:n("div",{children:[e(c,Be({size:"sm",weight:500},{children:i.name})),e(c,Be({size:"xs",color:"dimmed"},{children:i.description}))]})})}))})},i.key)}));return e(d.Autosize,Be({maxHeight:500},{children:e(s,Be({horizontalSpacing:0,verticalSpacing:0,sx:{minWidth:700}},{children:e("tbody",{children:i})}))}))}var Qe=h((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=fe(a.data.lessonOpen),r=t[0],o=t[1];return r?e(_e,{data:a.data.lesson,onBackClick:function(){return o(!1)},onGroupChange:a.onGroupChange,onTabChange:a.onTabChange,onUserClick:a.onUserClick,onPreview:a.onPreview}):e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",size:"lg"},{children:"Lessons"})),e(v,Be({order:2,className:i.title,mt:"md"},{children:"Lessons"})),e(c,Be({color:"dimmed",className:i.description,mt:"sm"},{children:"Well crafted units of instruction."}))]}))}),e(k,{placeholder:"Search for a lesson that fits your needs",data:a.data.lessons.map((function(e){return e.name})),onChange:a.onAutocompleteChange}),e($e,{data:a.data.lessons,onClick:function(e){a.onLessonClick&&a.onLessonClick(e),o(!0)}})]}))}))},Ze=function(a){var i=Ce({initialValues:a.data.active});return e(y,Be({centered:!0,opened:!a.data.hidden,onClose:function(){return a.onClose&&a.onClose()},size:"sm",title:e(v,Be({size:"h5"},{children:"Accounts"}))},{children:n("form",Be({onSubmit:i.onSubmit((function(){a.onChange&&a.onChange(i.values)}))},{children:[e(b,{required:!0,placeholder:"Select an account",defaultValue:a.data.active,data:a.data.accounts.map((function(e){return{value:e.key,label:e.name}}))}),e(C,Be({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},Je=h((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}}}})),Xe=[{icon:q,label:"Home"},{icon:K,label:"Dashboard"},{icon:j,label:"Groups"},{icon:$,label:"Badges"},{icon:Q,label:"Lessons"}],en=function(n){var a,i=n.icon,t=n.label,o=n.active,l=n.onClick,c=Je(),d=c.classes,s=c.cx;return e(E,Be({label:t,position:"right",transitionDuration:0},{children:e(r,Be({onClick:l,className:s(d.link,(a={},a[d.active]=o,a))},{children:e(i,{stroke:1.5})}))}))},nn=["Logout","Change account"],an=function(a){var i=Xe.map((function(e){return ge(en,Be({},e,{key:e.label,active:e.label===a.active,onClick:function(){return a.onClick&&a.onClick(e.label)}}))}));return n(z,Be({width:{base:80},p:"md"},{children:[e(w,{children:e(l,Be({color:"blue",radius:"sm"},{children:e("div",Be({style:{width:15,marginLeft:"auto",marginRight:"auto"}},{children:e(x,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})}))}))}),e(z.Section,Be({grow:!0,mt:50},{children:e(m,Be({justify:"center",spacing:0},{children:i}))})),e(z.Section,{children:n(m,Be({justify:"center",spacing:0},{children:[e(en,{icon:H,label:"Change account",onClick:function(){return a.onClick&&a.onClick("Change account")}}),e(en,{icon:_,label:"Logout",onClick:function(){return a.onClick&&a.onClick("Logout")}})]}))})]}))},tn=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],rn=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function on(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,a=tn;n<a.length;n++){var i=a[n],t=i.unit,r=i.ms;if(Math.abs(e)>=r||"second"===t)return rn.format(Math.round(e/r),t)}return""}(e.getTime()-n.getTime()):""}var ln={BadgeCompleted:e(Y,{size:12}),BadgeStarted:e(Y,{size:12}),LessonCompleted:e(Z,{size:12}),LessonStarted:e(Z,{size:12}),ProblemSolved:e(J,{size:12})},cn=function(a){var i,t=ve(null),r=fe({x:0,y:0}),o=r[0],l=r[1];pe.useEffect((function(){t.current&&o.y===t.current.scrollHeight-t.current.offsetHeight&&a.onScrollBottom&&a.onScrollBottom()}),[o.y]);var s=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(N,Be({color:"dark",unstyled:!0,href:a.link},{children:"".concat(t[0]," ").concat(t[1].toLowerCase())})):"".concat(t[0]," ").concat(t[1].toLowerCase());return n(D.Item,Be({bullet:dn(a.name),lineVariant:r,title:o},{children:[e(c,Be({color:"dimmed",size:"sm"},{children:a.description})),e(c,Be({size:"xs",mt:4},{children:on(new Date(a.time))}))]}),a.key)}));return e(d.Autosize,Be({maxHeight:300,onScrollPositionChange:l,viewportRef:t},{children:e(D,Be({ml:"lg",active:1,bulletSize:24,lineWidth:2},{children:s}))}))},dn=function(n){var a=ln[n];return a||e(X,{size:12})},sn=h((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)}}})),hn=function(a){var i=a.data,t=sn().classes,r=i.map((function(a){return n("div",Be({className:t.stat},{children:[e(c,Be({className:t.count},{children:a.value.toLocaleString()})),e(c,Be({className:t.title},{children:a.title})),e(c,Be({className:t.description},{children:"".concat(a.diff,"% ").concat(a.diff<0?"decrease":"increase"," compared to last period")}))]}),a.title)}));return e("div",Be({className:t.root},{children:r}))},un=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900,marginTop:16},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),mn=function(i){var t=un().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(v,Be({className:t.title},{children:r})),e(c,Be({color:"dimmed",className:t.description,mt:"xs"},{children:i.data.quote}))]}):n(a,{children:[n(L,Be({radius:"md",withBorder:!0,p:"lg",sx:function(e){return{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.white}}},{children:[e(l,{src:i.data.avatar,size:135,radius:120,mx:"auto"}),e(c,Be({align:"center",size:"lg",weight:500,mt:"md"},{children:r})),n(c,Be({align:"center",color:"dimmed",size:"sm"},{children:[i.data.email," • ",i.data.job]}))]})),e(B,Be({mt:"xl",color:"blue",cite:"– ".concat(o)},{children:i.data.quote}))]})},pn=["Member","Admin"];function fn(a){var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(r,Be({onClick:function(){return a.onViewProfile&&a.onViewProfile(i)}},{children:n(o,Be({spacing:"sm"},{children:[e(l,{size:40,src:i.avatar,radius:40}),n("div",{children:[e(c,Be({size:"sm",weight:500},{children:i.givenName&&i.familyName?"".concat(i.givenName," ").concat(i.familyName):i.email})),e(c,Be({size:"xs",color:"dimmed"},{children:i.email}))]})]}))}))}),e("td",{children:e(b,{data:pn,defaultValue:i.role,variant:"unstyled",onChange:function(e){return a.onChangeRole&&a.onChangeRole(i,e)}})}),e("td",{children:i.lastActivity?on(i.lastActivity):""}),e("td",{children:e(o,Be({noWrap:!0,spacing:0,position:"right"},{children:e(g,Be({color:"red"},{children:e(ee,{onClick:function(){return F({title:'Delete "'.concat((n=i).givenName&&n.familyName?"".concat(n.givenName," ").concat(n.familyName):n.email,'"?'),centered:!0,children:e(c,Be({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 e(d,{children:n(s,Be({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 gn=h((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}}})),vn=function(i){var t=gn().classes,r=Ce({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"}}}),l=fe(!1),d=l[0],s=l[1],h=fe(i.data.groupUserHomeOpen),b=h[0],k=h[1];return b?e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(p,{children:n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",leftSection:e(g,Be({onClick:function(){return k(!1)},color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Users"})),e(mn,{variant:"compact",data:i.data.user})]}))}),n(m,Be({spacing:"lg"},{children:[e(hn,{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(cn,{onScrollBottom:i.onTimelineScrollBottom,data:i.data.timeline})]}))]}))})):n(a,{children:[e(O,Be({opened:d,onClose:function(){return s(!1)},title:e(v,Be({size:"h5"},{children:"Add people"})),padding:"xl",size:"xl"},{children:n(m,Be({spacing:"md"},{children:[e(Cn,Be({},i,{close:function(){return s(!1)}})),e(S,{label:"or",labelPosition:"center",my:"md",variant:"dashed"}),e("form",Be({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateUsers&&i.onCreateUsers([e])}))},{children:n(m,{children:[e(T,Be({withAsterisk:!0,label:"Email",placeholder:"Email"},r.getInputProps("email"))),n(o,Be({grow:!0},{children:[e(T,Be({label:"Given name",placeholder:"Given name"},r.getInputProps("givenName"))),e(T,Be({label:"Family name",placeholder:"Family name"},r.getInputProps("familyName")))]})),e(C,Be({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]})}))]}))})),e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",leftSection:e(g,Be({onClick:i.onBackClick,color:"blue",size:"xs",radius:"xl",variant:"filled"},{children:e(I,{size:14})})),size:"lg"},{children:"Groups"})),e(v,Be({order:2,className:t.title,mt:"md"},{children:i.data.name||"Group"})),e(c,Be({color:"dimmed",className:t.description,mt:"sm"},{children:i.data.description||"No description"}))]})),e(p.Col,Be({sm:"content"},{children:e(C,Be({onClick:function(){return s(!0)},leftIcon:e(ne,{size:14})},{children:"Add people"}))}))]}),e(fn,{data:i.data.users,onDelete:i.onDelete,onChangeRole:i.onRoleChange,onViewProfile:function(e){return i.onViewProfile(e).then((function(){k(!0)}))}})]}))}))]})},Cn=function(a){var i=gn(),t=i.classes,r=i.theme,l=pe.useRef(null),d=pe.useState(!1),s=d[0],h=d[1],u=pe.useCallback((function(e){h(!0),e.forEach((function(e){ke.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",Be({className:t.wrapper},{children:[e(Se,Be({loading:s,openRef:l,onDrop:u,className:t.dropzone,radius:"md",accept:[be.csv],maxSize:5*Math.pow(1024,2)},{children:n("div",Be({style:{pointerEvents:"none"}},{children:[n(o,Be({position:"center"},{children:[e(Se.Accept,{children:e(ae,{size:50,color:r.colors[r.primaryColor][6],stroke:1.5})}),e(Se.Reject,{children:e(ie,{size:50,color:r.colors.red[6],stroke:1.5})}),e(Se.Idle,{children:e(te,{size:50,color:"dark"===r.colorScheme?r.colors.dark[0]:r.black,stroke:1.5})})]})),n(c,Be({align:"center",weight:700,size:"lg",mt:"xl"},{children:[e(Se.Accept,{children:"Drop files here"}),e(Se.Reject,{children:"Csv file less than 5mb"}),e(Se.Idle,{children:"Upload multiple"})]})),n(c,Be({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(C,Be({className:t.control,size:"md",radius:"xl",onClick:function(){var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)}},{children:"Select file"}))]}))};function Sn(a){var i=a.data.map((function(i){return n("tr",{children:[e("td",{children:e(c,Be({size:14},{children:i.name}))}),e("td",{children:e(c,Be({size:14},{children:i.description}))}),e("td",{children:n(o,Be({noWrap:!0,spacing:0,position:"right"},{children:[e(g,Be({color:"blue",onClick:function(){return a.onEditGroup&&a.onEditGroup(i)},variant:"subtle"},{children:e(re,{size:16,stroke:1.5})})),n(G,Be({transition:"pop",withArrow:!0,position:"bottom-end"},{children:[e(G.Target,{children:e(g,{children:e(oe,{size:16,stroke:1.5})})}),e(G.Dropdown,{children:e(G.Item,Be({onClick:function(){return F({title:'Delete "'.concat((n=i).name,'"?'),centered:!0,children:e(c,Be({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(ee,{size:16,stroke:1.5}),color:"red"},{children:"Delete"}))})]}))]}))})]},i.name)}));return e(d.Autosize,Be({maxHeight:300},{children:n(s,Be({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 bn=h((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),kn=function(i){var t=bn().classes,r=Ce({initialValues:{name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=fe(i.data.formOpen),d=l[0],s=l[1],h=fe(i.data.groupOpen),S=h[0],b=h[1];return S?e(vn,{data:i.data.group,onBackClick:function(){return b(!1)},onCreateUsers:i.onCreateGroupUsers,onDelete:i.onDeleteGroupUser,onViewProfile:i.onViewGroupUser,onRoleChange:i.onGroupUserRoleChange,onTimelineScrollBottom:i.onTimelineScrollBottom}):n(a,{children:[e(O,Be({opened:d,onClose:function(){return s(!1)},title:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5"},{children:"Create a group"})),e(E,Be({label:"Groups settings cannot be modified once created"},{children:e(g,{children:e(le,{color:"#3b82f6",size:14})})}))]})),padding:"xl",size:"xl"},{children:n("form",Be({onSubmit:r.onSubmit((function(){var e=r.values;r.reset(),s(!1),i.onCreateGroup&&i.onCreateGroup(e)}))},{children:[n(m,{children:[e(T,Be({withAsterisk:!0,label:"Name",placeholder:"Group name"},r.getInputProps("name"))),e(T,Be({label:"Description",placeholder:"A group for my first period class"},r.getInputProps("description")))]}),e(C,Be({type:"submit",fullWidth:!0,mt:"md"},{children:"Submit"}))]}))})),e(u,Be({size:"lg",py:"xl"},{children:n(m,Be({spacing:"md"},{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(f,Be({variant:"filled",size:"lg"},{children:"Groups"})),e(v,Be({order:2,className:t.title,mt:"md"},{children:"Organize people into groups"})),e(c,Be({color:"dimmed",className:t.description,mt:"sm"},{children:"A group can be a class, team, or other functioning organizations."}))]})),e(p.Col,Be({sm:"content"},{children:e(C,Be({onClick:function(){return s(!0)},leftIcon:e(ne,{size:14})},{children:"Create group"}))}))]}),e(Sn,{data:i.data.groups,onDeleteGroup:i.onDeleteGroup,onEditGroup:function(e){i.onEditGroup&&i.onEditGroup(e),b(!0)}})]}))}))]})},yn=h((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}}})),zn=function(a){var i=a.title,t=a.description,r=a.image,o=a.action,l=a.style,d=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=yn(),u=h.classes,m=h.cx,p=h.theme;return n(P,Be({radius:"md",style:Be({backgroundImage:"url(".concat(r,")")},l),className:m(u.card,d)},s,{children:[e(A,{gradient:"linear-gradient(105deg, ".concat(p.black," 20%, #312f2f 50%, ").concat(p.colors.gray[4]," 100%)"),opacity:.55,zIndex:0}),n("div",Be({className:u.content},{children:[e(c,Be({size:"lg",weight:700,className:u.title},{children:i})),e(c,Be({size:"sm",className:u.description},{children:t})),e(C,Be({className:u.action,variant:"white",color:"dark",component:"a",size:"xs",href:o.link,target:"_blank"},{children:o.label}))]}))]}))},wn=function(a){return e(u,Be({size:"lg"},{children:n(m,Be({spacing:"lg"},{children:[n(p,Be({gutter:"md"},{children:[e(p.Col,Be({md:6},{children:e(mn,{data:a.data.user})})),e(p.Col,Be({md:6},{children:e(zn,{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(hn,{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(cn,{onScrollBottom:a.onTimelineScrollBottom,data:a.data.timeline})]}))}))},xn=h((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}}})),En=function(a){var i,t=a.data,r=xn(),o=r.classes,l=r.cx,c=fe(!1),h=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,Be({color:"gray"},{children:"Average"})):e(f,Be({color:"red"},{children:"Below average"}))})]},a.name)}));return e(d,Be({sx:{height:500},onScrollPositionChange:function(e){var n=e.y;return u(0!==n)}},{children:n(s,Be({verticalSpacing:"md",sx:{minWidth:700}},{children:[e("thead",Be({className:l(o.header,(i={},i[o.scrolled]=h,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})]}))}))},Nn=function(a){return e(L,Be({mih:150,p:"lg",withBorder:!0},{children:n(m,{children:[e(p,{children:e(p.Col,Be({sm:"auto"},{children:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5",mb:0},{children:"Performance History"})),e(E,Be({label:"Shows group performance per person"},{children:e(g,{children:e(le,{color:"#3b82f6",size:14})})}))]}))}))}),e(o,Be({spacing:"sm"},{children:e(b,{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(En,{data:a.data.users})]})}))},Dn=h((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),Ln=function(a){var i=Dn().theme;return e(L,Be({p:"lg",withBorder:!0},{children:n(m,{children:[n(p,{children:[e(p.Col,Be({sm:"auto"},{children:n(o,Be({spacing:0},{children:[e(v,Be({size:"h5",mb:0},{children:"Performance History"})),e(E,Be({label:"Shows daily increase or decrease across group"},{children:e(g,{children:e(le,{color:"#3b82f6",size:14})})}))]}))})),e(p.Col,Be({sm:5},{children:e(b,{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(ze,Be({width:"100%",height:400},{children:n(we,Be({width:730,height:250,data:a.data.points,margin:{top:10,right:30,left:0,bottom:0}},{children:[e("defs",{children:n("linearGradient",Be({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(xe,{tick:{fontSize:12,fontFamily:i.fontFamily},dataKey:"name"}),e(Ee,{tick:{fontSize:12,fontFamily:i.fontFamily}}),e(Ne,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),e(De,{contentStyle:{fontWeight:700,fontSize:12,fontFamily:i.fontFamily},labelStyle:{fontSize:12,fontFamily:i.fontFamily}}),e(Le,{type:"monotone",dataKey:"value",stroke:"#3b82f6",fillOpacity:1,fill:"url(#colorBlue)"})]}))}))]})}))},Bn=h((function(e){return{root:{paddingTop:1.5*e.spacing.xl,paddingBottom:1.5*e.spacing.xl},label:{fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),On=function(a){var i=a.data,t=Bn().classes,r=i.map((function(a){var i=a.diff>0?ce:de;return n(L,Be({withBorder:!0,p:"md",radius:"md"},{children:[n(o,Be({position:"apart"},{children:[n("div",{children:[e(c,Be({color:"dimmed",transform:"uppercase",weight:700,size:"xs",className:t.label},{children:a.title})),e(c,Be({weight:700,size:"xl"},{children:a.value.toLocaleString()}))]}),e(M,Be({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(c,Be({color:"dimmed",size:"sm",mt:"md"},{children:[n(c,Be({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",Be({className:t.root},{children:e(R,Be({cols:3,breakpoints:[{maxWidth:"sm",cols:1}]},{children:r}))}))},Tn=function(i){return n(a,{children:[e(On,{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(Ln,{data:i.data.areaChart,onMetricChange:i.onMetricChange})]})},Gn=[{value:"Overview"},{value:"Breakdown"}],Pn=function(a){var i=Mn(a.data.breakdown,a.onBreakdownMetricChange),t=Rn(a.data.dateRange,a.onDateRangeChange),r=Wn(a.data.groups,a.onGroupChange),o=Un(a.data.overview,a.onOverviewMetricChange),l=Fn(a.data.tab,a.onTabChange);return e(u,Be({size:"lg",py:"xl"},{children:n(m,{children:[n(p,{children:[n(p.Col,Be({sm:"auto"},{children:[e(v,Be({size:"h3"},{children:"Dashboard"})),e(c,Be({color:"dimmed",size:"sm",mt:"md"},{children:"View core metrics on the state of your groups."}))]})),e(p.Col,Be({sm:2.5},{children:e(b,{placeholder:"Select a group",nothingFound:"No options",value:r.select,onChange:r.onSelectChange,icon:e(j,{}),data:a.data.groups.map((function(e){return e.name}))})})),e(p.Col,Be({sm:"auto"},{children:e(ye,{placeholder:"Select a date",allowSingleDateInRange:!0,value:t.value,onChange:t.onChange,icon:e(se,{size:16})})}))]}),n(m,{children:[e(Te,{data:Gn,value:l.value,onChange:l.onChange}),e(An,Be({},a,{data:Be(Be({},a.data),{overview:o.data,breakdown:i.data}),active:l.value,onBreakdownMetricChange:i.onMetricChange,onOverviewMetricChange:o.onMetricChange}))]})]})}))},An=function(n){switch(n.active){case"Overview":return e(Tn,{data:n.data.overview,onMetricChange:n.onOverviewMetricChange});case"Breakdown":return e(Nn,{data:n.data.breakdown,onMetricChange:n.onBreakdownMetricChange});default:return null}},Mn=function(e,n){var a=pe.useState(e.metric),i=a[0],t=a[1];return{data:Be(Be({},e),{metric:i}),onMetricChange:function(e){t(e),n&&n(e)}}},Rn=function(e,n){var a=pe.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},Wn=function(e,n){var a=e.filter((function(e){return e.active})),i=pe.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)}}},Un=function(e,n){var a=pe.useState(e.areaChart.metric),i=a[0],t=a[1];return{data:Be(Be({},e),{areaChart:Be(Be({},e.areaChart),{metric:i})}),onMetricChange:function(e){t(e),n&&n(e)}}},Fn=function(e,n){var a=pe.useState(e),i=a[0],t=a[1];return{value:i,onChange:function(e){t(e),n&&n(e)}}},Vn=h((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)}})),In=function(a){var i=Vn().classes,t=jn(a.data.account,a.onAccountChange),r=Hn(a.data.navbar.active,(function(e){if("Change account"===e)t.setChangeModalOpen(!0);a.onNavbarClick&&a.onNavbarClick(e)}));return n(W,Be({padding:"xs",navbar:e(an,{active:r.active,onClick:r.onClick},r.key),footer:n("footer",Be({className:i.footer},{children:[n(u,Be({className:i.inner},{children:[n("div",Be({className:i.logo},{children:[n(o,Be({spacing:"xs"},{children:[e("div",Be({style:{width:15}},{children:e(x,{fit:"contain",src:"https://cdn.localcivics.io/brand/l.png"})})),e(v,Be({color:"dimmed",size:"h5"},{children:"Local Civics"}))]})),e(c,Be({size:"xs",color:"dimmed",className:i.description},{children:"We connect students to powerful civic learning experiences."}))]})),e("div",Be({className:i.groups},{children:n("div",Be({className:i.wrapper},{children:[e(c,Be({className:i.link,component:"a",href:"https://www.localcivics.io",target:"_blank"},{children:"About"})),e(c,Be({className:i.link,component:"a",href:"https://www.localcivics.io/terms-of-service",target:"_blank"},{children:"Terms"})),e(c,Be({className:i.link,component:"a",href:"https://www.localcivics.io/privacy-policy",target:"_blank"},{children:"Privacy"})),e(c,Be({className:i.link,component:"a",href:"https://localcivics.notion.site/Help-Center-b52300f587b64fc0a61f512686e7626d",target:"_blank"},{children:"FAQ"}))]}))}))]})),n(u,Be({className:i.afterFooter},{children:[n(c,Be({color:"dimmed",size:"sm"},{children:["© ",(new Date).getFullYear()," Local Civics. All rights reserved."]})),n(o,Be({spacing:0,className:i.social,position:"right",noWrap:!0},{children:[e(g,Be({component:"a",target:"_blank",href:"https://www.instagram.com/localcivics/",size:"lg"},{children:e(he,{size:18,stroke:1.5})})),e(g,Be({component:"a",target:"_blank",href:"https://www.linkedin.com/company/localcivics",size:"lg"},{children:e(ue,{size:18,stroke:1.5})})),e(g,Be({component:"a",target:"_blank",href:"https://www.facebook.com/localcivics/",size:"lg"},{children:e(me,{size:18,stroke:1.5})}))]}))]}))]})),styles:function(e){return{main:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[0]}}}},{children:[e(_n,Be({},a,{active:r.active})),e(Ze,{data:t.data,onChange:t.onAccountChange,onClose:function(){return t.setChangeModalOpen(!1)}})]}))},jn=function(e,n){var a=fe(!e.hidden),i=a[0],t=a[1],r=fe(e.active),o=r[0],l=r[1];return{data:Be(Be({},e),{active:o,hidden:!i}),setChangeModalOpen:t,onAccountChange:function(e){l(e),t(!1),n&&n(e)}}},Hn=function(e,n){var a=fe(e||"Home"),i=a[0],t=a[1];return{key:i,active:i,onClick:function(e){var a;i!==e&&(a=e,-1===nn.indexOf(a)&&t(e),n&&n(e))}}},_n=function(n){switch(n.active){case"Dashboard":return e(Pn,{data:n.data.dashboard,onBreakdownMetricChange:n.onDashboardBreakdownMetricChange,onDateRangeChange:n.onDashboardDateRangeChange,onGroupChange:n.onDashboardGroupChange,onOverviewMetricChange:n.onDashboardOverviewMetricChange,onTabChange:n.onDashboardTabChange});case"Home":return e(wn,{data:n.data.home,onTimelineScrollBottom:n.onHomeTimelineScrollBottom});case"Groups":return e(kn,{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(Ye,{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(Ve,{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{In as Mgmt,Oe as MgmtProvider,Ze 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,r,o,i,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(i),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)};var g=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 f(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 j=[{value:"Complete"},{value:"Incomplete"}],v=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),C=function(e){var a=S(e.data.groups,e.onGroupChange),r=b(e.data.tab,e.onTabChange),i=v().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(o.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:i.title,mt:"md"},{children:e.data.name||"Badge"})),n.jsx(t.Text,p({color:"dimmed",className:i.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(o.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(g,{data:j,value:r.value,onChange:r.onChange}),n.jsx(f,{data:e.data.users,onClick:e.onUserClick})]})]}))}))},S=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},b=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 k(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.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 y=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),T=function(e){var a=y().classes,r=i.useState(e.data.badgeOpen),o=r[0],s=r[1];return o?n.jsx(C,{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.jsx(k,{data:e.data.badges,onClick:function(n){e.onBadgeClick&&e.onBadgeClick(n),s(!0)}})]}))}))};function z(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 w=[{value:"Complete"},{value:"Incomplete"}],E=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),G=function(e){var a=D(e.data.groups,e.onGroupChange),r=B(e.data.tab,e.onTabChange),i=E().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(o.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:i.title,mt:"md"},{children:e.data.name||"Lesson"})),n.jsx(t.Text,p({color:"dimmed",className:i.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(o.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(g,{data:w,value:r.value,onChange:r.onChange}),n.jsx(z,{data:e.data.users,onClick:e.onUserClick})]})]}))}))},D=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},B=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 N(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.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 A=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),L=function(e){var a=A().classes,r=i.useState(e.data.lessonOpen),o=r[0],s=r[1];return o?n.jsx(G,{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.jsx(N,{data:e.data.lessons,onClick:function(n){e.onLessonClick&&e.onLessonClick(n),s(!0)}})]}))}))},O=function(e){var a=s.useForm({initialValues: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)}))},{children:[n.jsx(t.Select,{required:!0,placeholder:"Select an account",defaultValue:e.data.active,data:e.data.accounts.map((function(e){return{value:e.key,label:e.name}}))}),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},I=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}}}})),P=[{icon:o.IconHome2,label:"Home"},{icon:o.IconGauge,label:"Dashboard"},{icon:o.IconCategory2,label:"Groups"},{icon:o.IconAlbum,label:"Badges"},{icon:o.IconLambda,label:"Lessons"}],M=function(e){var a,r=e.icon,o=e.label,i=e.active,s=e.onClick,l=I(),c=l.classes,d=l.cx;return n.jsx(t.Tooltip,p({label:o,position:"right",transitionDuration:0},{children:n.jsx(t.UnstyledButton,p({onClick:s,className:d(c.link,(a={},a[c.active]=i,a))},{children:n.jsx(r,{stroke:1.5})}))}))},R=["Logout","Change account"],F=function(e){var a=P.map((function(n){return i.createElement(M,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(M,{icon:o.IconSwitchHorizontal,label:"Change account",onClick:function(){return e.onClick&&e.onClick("Change account")}}),n.jsx(M,{icon:o.IconLogout,label:"Logout",onClick:function(){return e.onClick&&e.onClick("Logout")}})]}))})]}))},U=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],W=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function V(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,t=U;n<t.length;n++){var a=t[n],r=a.unit,o=a.ms;if(Math.abs(e)>=o||"second"===r)return W.format(Math.round(e/o),r)}return""}(e.getTime()-n.getTime()):""}var H={BadgeCompleted:n.jsx(o.IconBadges,{size:12}),BadgeStarted:n.jsx(o.IconBadges,{size:12}),LessonCompleted:n.jsx(o.IconSchool,{size:12}),LessonStarted:n.jsx(o.IconSchool,{size:12}),ProblemSolved:n.jsx(o.IconActivityHeartbeat,{size:12})},q=function(e){var a,r=i.useRef(null),o=i.useState({x:0,y:0}),s=o[0],l=o[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])/),o=r[0]===a?"dashed":"solid";a=r[0];var i=e.link?n.jsx(t.Anchor,p({color:"dark",unstyled:!0,href:e.link,target:"_blank"},{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:o,title:i},{children:[n.jsx(t.Text,p({color:"dimmed",size:"sm"},{children:e.description})),n.jsx(t.Text,p({size:"xs",mt:4},{children:V(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=H[e];return t||n.jsx(o.IconTimelineEvent,{size:12})},K=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)}}})),X=function(e){var a=e.data,r=K().classes,o=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:o}))},Y=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}}})),J=function(e){var a=Y().classes,r=e.data.givenName?[e.data.givenName,e.data.familyName].join(" ").trim():e.data.email,o=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(o)},{children:e.data.quote}))]})},$=["Member","Admin"];function Q(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:$,defaultValue:r.role,variant:"unstyled",onChange:function(n){return e.onChangeRole&&e.onChangeRole(r,n)}})}),n.jsx("td",{children:r.lastActivity?V(r.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(o.IconTrash,{onClick:function(){return o=r,a.openConfirmModal({title:'Delete "'.concat(o.givenName&&o.familyName?"".concat(o.givenName," ").concat(o.familyName):o.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(o)}});var o},size:16,stroke:1.5})}))}))})]},r.email)}));return 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 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},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}}})),ee=function(e){var a=Z().classes,r=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=i.useState(!1),c=l[0],d=l[1],u=i.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(o.IconArrowLeft,{size:14})})),size:"lg"},{children:"Users"})),n.jsx(J,{variant:"compact",data:e.data.user})]}))}),n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsx(X,{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(q,{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(ne,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(o.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(o.IconPlaylistAdd,{size:14})},{children:"Add people"}))}))]}),n.jsx(Q,{data:e.data.users,onDelete:e.onDelete,onChangeRole:e.onRoleChange,onViewProfile:function(n){return e.onViewProfile(n).then((function(){m(!0)}))}})]}))}))]})},ne=function(e){var a=Z(),r=a.classes,i=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(o.IconDownload,{size:50,color:i.colors[i.primaryColor][6],stroke:1.5})}),n.jsx(l.Dropzone.Reject,{children:n.jsx(o.IconX,{size:50,color:i.colors.red[6],stroke:1.5})}),n.jsx(l.Dropzone.Idle,{children:n.jsx(o.IconCloudUpload,{size:50,color:"dark"===i.colorScheme?i.colors.dark[0]:i.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 te(e){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(o.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(o.IconDots,{size:16,stroke:1.5})})}),n.jsx(t.Menu.Dropdown,{children:n.jsx(t.Menu.Item,p({onClick:function(){return o=r,a.openConfirmModal({title:'Delete "'.concat(o.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(o)}});var o},icon:n.jsx(o.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 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}}})),re=function(e){var a=ae().classes,r=s.useForm({initialValues:{name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=i.useState(e.data.formOpen),c=l[0],d=l[1],u=i.useState(e.data.groupOpen),h=u[0],m=u[1];return h?n.jsx(ee,{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(o.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(o.IconPlaylistAdd,{size:14})},{children:"Create group"}))}))]}),n.jsx(te,{data:e.data.groups,onDeleteGroup:e.onDeleteGroup,onEditGroup:function(n){e.onEditGroup&&e.onEditGroup(n),m(!0)}})]}))}))]})},oe=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}}})),ie=function(e){var a=e.title,r=e.description,o=e.image,i=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=oe(),u=d.classes,h=d.cx,m=d.theme;return n.jsxs(t.Card,p({radius:"md",style:p({backgroundImage:"url(".concat(o,")")},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:i.link,target:"_blank"},{children:i.label}))]}))]}))},se=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(J,{data:e.data.user})})),n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(ie,{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(X,{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(q,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))}))},le=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}}})),ce=function(e){var a,r=e.data,o=le(),s=o.classes,l=o.cx,c=i.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})]}))}))},de=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(o.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(ce,{data:e.data.users})]})}))},ue=t.createStyles((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),he=function(e){var a=ue().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(o.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)"})]}))}))]})}))},me=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)}}})),xe=function(e){var a=e.data,r=me().classes,i=a.map((function(e){var a=e.diff>0?o.IconArrowUpRight:o.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:i}))}))},pe=function(e){return n.jsxs(n.Fragment,{children:[n.jsx(xe,{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(he,{data:e.data.areaChart,onMetricChange:e.onMetricChange})]})},ge=[{value:"Overview"},{value:"Breakdown"}],fe=function(e){var a=ve(e.data.breakdown,e.onBreakdownMetricChange),r=Ce(e.data.dateRange,e.onDateRangeChange),i=Se(e.data.groups,e.onGroupChange),s=be(e.data.overview,e.onOverviewMetricChange),l=ke(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:i.select,onChange:i.onSelectChange,icon:n.jsx(o.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(o.IconCalendar,{size:16})})}))]}),n.jsxs(t.Stack,{children:[n.jsx(g,{data:ge,value:l.value,onChange:l.onChange}),n.jsx(je,p({},e,{data:p(p({},e.data),{overview:s.data,breakdown:a.data}),active:l.value,onBreakdownMetricChange:a.onMetricChange,onOverviewMetricChange:s.onMetricChange}))]})]})}))},je=function(e){switch(e.active){case"Overview":return n.jsx(pe,{data:e.data.overview,onMetricChange:e.onOverviewMetricChange});case"Breakdown":return n.jsx(de,{data:e.data.breakdown,onMetricChange:e.onBreakdownMetricChange});default:return null}},ve=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)}}},Ce=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)}}},Se=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},be=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)}}},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)}}},ye=t.createStyles((function(e){var n,t,a,r,o,i;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:(o={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])},o[e.fn.smallerThan("sm")]={flexDirection:"column"},o),social:(i={},i[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},i)}})),Te=function(e,n){var t=i.useState(!e.hidden),a=t[0],r=t[1],o=i.useState(e.active),s=o[0],l=o[1];return{data:p(p({},e),{active:s,hidden:!a}),setChangeModalOpen:r,onAccountChange:function(e){l(e),r(!1),n&&n(e)}}},ze=function(e,n){var t=i.useState(e||"Home"),a=t[0],r=t[1];return{key:a,active:a,onClick:function(e){var t;a!==e&&(t=e,-1===R.indexOf(t)&&r(e),n&&n(e))}}},we=function(e){switch(e.active){case"Dashboard":return n.jsx(fe,{data:e.data.dashboard,onBreakdownMetricChange:e.onDashboardBreakdownMetricChange,onDateRangeChange:e.onDashboardDateRangeChange,onGroupChange:e.onDashboardGroupChange,onOverviewMetricChange:e.onDashboardOverviewMetricChange,onTabChange:e.onDashboardTabChange});case"Home":return n.jsx(se,{data:e.data.home,onTimelineScrollBottom:e.onHomeTimelineScrollBottom});case"Groups":return n.jsx(re,{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(L,{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(T,{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=ye().classes,r=Te(e.data.account,e.onAccountChange),i=ze(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(F,{active:i.active,onClick:i.onClick},i.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://docs.google.com/document/d/19d8bO2D_KSxyvT8HPS8RqJTRMla6jgBtVPV5HgcSAk8/view",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(o.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(o.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(o.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.jsx(we,p({},e,{active:i.active})),n.jsx(O,{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},{children:n.jsx(r.NotificationsProvider,p({limit:e.notificationLimit||5},{children:n.jsx(a.ModalsProvider,{children:e.children})}))}))},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,o,i,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(i),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)};var g=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 f(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 j=[{value:"Complete"},{value:"Incomplete"}],v=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),C=function(e){var a=S(e.data.groups,e.onGroupChange),r=b(e.data.tab,e.onTabChange),i=v().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(o.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:i.title,mt:"md"},{children:e.data.name||"Badge"})),n.jsx(t.Text,p({color:"dimmed",className:i.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(o.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(g,{data:j,value:r.value,onChange:r.onChange}),n.jsx(f,{data:e.data.users,onClick:e.onUserClick})]})]}))}))},S=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},b=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 k(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.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 y=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),T=function(e){var a=y().classes,r=i.useState(e.data.badgeOpen),o=r[0],s=r[1];return o?n.jsx(C,{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.jsx(k,{data:e.data.badges,onClick:function(n){e.onBadgeClick&&e.onBadgeClick(n),s(!0)}})]}))}))};function z(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 w=[{value:"Complete"},{value:"Incomplete"}],E=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),G=function(e){var a=D(e.data.groups,e.onGroupChange),r=B(e.data.tab,e.onTabChange),i=E().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(o.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:i.title,mt:"md"},{children:e.data.name||"Lesson"})),n.jsx(t.Text,p({color:"dimmed",className:i.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(o.IconCategory2,{}),data:e.data.groups.map((function(e){return e.name}))})]}))]})]}))}),n.jsxs("div",{children:[n.jsx(g,{data:w,value:r.value,onChange:r.onChange}),n.jsx(z,{data:e.data.users,onClick:e.onUserClick})]})]}))}))},D=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},B=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 N(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.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 A=t.createStyles((function(e){var n;return{title:(n={fontSize:34,fontWeight:900},n[e.fn.smallerThan("sm")]={fontSize:24},n),description:{maxWidth:600}}})),L=function(e){var a=A().classes,r=i.useState(e.data.lessonOpen),o=r[0],s=r[1];return o?n.jsx(G,{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.jsx(N,{data:e.data.lessons,onClick:function(n){e.onLessonClick&&e.onLessonClick(n),s(!0)}})]}))}))},O=function(e){var a=s.useForm({initialValues: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)}))},{children:[n.jsx(t.Select,{required:!0,placeholder:"Select an account",defaultValue:e.data.active,data:e.data.accounts.map((function(e){return{value:e.key,label:e.name}}))}),n.jsx(t.Button,p({type:"submit",fullWidth:!0,mt:"xl"},{children:"Switch"}))]}))}))},I=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}}}})),P=[{icon:o.IconHome2,label:"Home"},{icon:o.IconGauge,label:"Dashboard"},{icon:o.IconCategory2,label:"Groups"},{icon:o.IconAlbum,label:"Badges"},{icon:o.IconLambda,label:"Lessons"}],M=function(e){var a,r=e.icon,o=e.label,i=e.active,s=e.onClick,l=I(),c=l.classes,d=l.cx;return n.jsx(t.Tooltip,p({label:o,position:"right",transitionDuration:0},{children:n.jsx(t.UnstyledButton,p({onClick:s,className:d(c.link,(a={},a[c.active]=i,a))},{children:n.jsx(r,{stroke:1.5})}))}))},R=["Logout","Change account"],F=function(e){var a=P.map((function(n){return i.createElement(M,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(M,{icon:o.IconSwitchHorizontal,label:"Change account",onClick:function(){return e.onClick&&e.onClick("Change account")}}),n.jsx(M,{icon:o.IconLogout,label:"Logout",onClick:function(){return e.onClick&&e.onClick("Logout")}})]}))})]}))},U=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],W=new Intl.RelativeTimeFormat("en",{numeric:"auto"});function V(e,n){return void 0===n&&(n=new Date),e?function(e){for(var n=0,t=U;n<t.length;n++){var a=t[n],r=a.unit,o=a.ms;if(Math.abs(e)>=o||"second"===r)return W.format(Math.round(e/o),r)}return""}(e.getTime()-n.getTime()):""}var H={BadgeCompleted:n.jsx(o.IconBadges,{size:12}),BadgeStarted:n.jsx(o.IconBadges,{size:12}),LessonCompleted:n.jsx(o.IconSchool,{size:12}),LessonStarted:n.jsx(o.IconSchool,{size:12}),ProblemSolved:n.jsx(o.IconActivityHeartbeat,{size:12})},q=function(e){var a,r=i.useRef(null),o=i.useState({x:0,y:0}),s=o[0],l=o[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])/),o=r[0]===a?"dashed":"solid";a=r[0];var i=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:o,title:i},{children:[n.jsx(t.Text,p({color:"dimmed",size:"sm"},{children:e.description})),n.jsx(t.Text,p({size:"xs",mt:4},{children:V(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=H[e];return t||n.jsx(o.IconTimelineEvent,{size:12})},X=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)}}})),Y=function(e){var a=e.data,r=X().classes,o=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:o}))},K=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}}})),$=function(e){var a=K().classes,r=e.data.givenName?[e.data.givenName,e.data.familyName].join(" ").trim():e.data.email,o=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(o)},{children:e.data.quote}))]})},J=["Member","Admin"];function Q(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:J,defaultValue:r.role,variant:"unstyled",onChange:function(n){return e.onChangeRole&&e.onChangeRole(r,n)}})}),n.jsx("td",{children:r.lastActivity?V(r.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(o.IconTrash,{onClick:function(){return o=r,a.openConfirmModal({title:'Delete "'.concat(o.givenName&&o.familyName?"".concat(o.givenName," ").concat(o.familyName):o.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(o)}});var o},size:16,stroke:1.5})}))}))})]},r.email)}));return 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 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},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}}})),ee=function(e){var a=Z().classes,r=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=i.useState(!1),c=l[0],d=l[1],u=i.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(o.IconArrowLeft,{size:14})})),size:"lg"},{children:"Users"})),n.jsx($,{variant:"compact",data:e.data.user})]}))}),n.jsxs(t.Stack,p({spacing:"lg"},{children:[n.jsx(Y,{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(q,{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(ne,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(o.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(o.IconPlaylistAdd,{size:14})},{children:"Add people"}))}))]}),n.jsx(Q,{data:e.data.users,onDelete:e.onDelete,onChangeRole:e.onRoleChange,onViewProfile:function(n){return e.onViewProfile(n).then((function(){m(!0)}))}})]}))}))]})},ne=function(e){var a=Z(),r=a.classes,i=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(o.IconDownload,{size:50,color:i.colors[i.primaryColor][6],stroke:1.5})}),n.jsx(l.Dropzone.Reject,{children:n.jsx(o.IconX,{size:50,color:i.colors.red[6],stroke:1.5})}),n.jsx(l.Dropzone.Idle,{children:n.jsx(o.IconCloudUpload,{size:50,color:"dark"===i.colorScheme?i.colors.dark[0]:i.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 te(e){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(o.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(o.IconDots,{size:16,stroke:1.5})})}),n.jsx(t.Menu.Dropdown,{children:n.jsx(t.Menu.Item,p({onClick:function(){return o=r,a.openConfirmModal({title:'Delete "'.concat(o.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(o)}});var o},icon:n.jsx(o.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 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}}})),re=function(e){var a=ae().classes,r=s.useForm({initialValues:{name:"",description:""},validate:{name:function(e){return e.length<=6?"Name should include at least 6 characters":null}}}),l=i.useState(e.data.formOpen),c=l[0],d=l[1],u=i.useState(e.data.groupOpen),h=u[0],m=u[1];return h?n.jsx(ee,{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(o.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(o.IconPlaylistAdd,{size:14})},{children:"Create group"}))}))]}),n.jsx(te,{data:e.data.groups,onDeleteGroup:e.onDeleteGroup,onEditGroup:function(n){e.onEditGroup&&e.onEditGroup(n),m(!0)}})]}))}))]})},oe=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}}})),ie=function(e){var a=e.title,r=e.description,o=e.image,i=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=oe(),u=d.classes,h=d.cx,m=d.theme;return n.jsxs(t.Card,p({radius:"md",style:p({backgroundImage:"url(".concat(o,")")},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:i.link,target:"_blank"},{children:i.label}))]}))]}))},se=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($,{data:e.data.user})})),n.jsx(t.Grid.Col,p({md:6},{children:n.jsx(ie,{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(Y,{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(q,{onScrollBottom:e.onTimelineScrollBottom,data:e.data.timeline})]}))}))},le=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}}})),ce=function(e){var a,r=e.data,o=le(),s=o.classes,l=o.cx,c=i.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})]}))}))},de=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(o.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(ce,{data:e.data.users})]})}))},ue=t.createStyles((function(e){return{axis:{fontSize:"12px",fontFamily:"Greycliff CF, ".concat(e.fontFamily)}}})),he=function(e){var a=ue().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(o.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)"})]}))}))]})}))},me=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)}}})),xe=function(e){var a=e.data,r=me().classes,i=a.map((function(e){var a=e.diff>0?o.IconArrowUpRight:o.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:i}))}))},pe=function(e){return n.jsxs(n.Fragment,{children:[n.jsx(xe,{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(he,{data:e.data.areaChart,onMetricChange:e.onMetricChange})]})},ge=[{value:"Overview"},{value:"Breakdown"}],fe=function(e){var a=ve(e.data.breakdown,e.onBreakdownMetricChange),r=Ce(e.data.dateRange,e.onDateRangeChange),i=Se(e.data.groups,e.onGroupChange),s=be(e.data.overview,e.onOverviewMetricChange),l=ke(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:i.select,onChange:i.onSelectChange,icon:n.jsx(o.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(o.IconCalendar,{size:16})})}))]}),n.jsxs(t.Stack,{children:[n.jsx(g,{data:ge,value:l.value,onChange:l.onChange}),n.jsx(je,p({},e,{data:p(p({},e.data),{overview:s.data,breakdown:a.data}),active:l.value,onBreakdownMetricChange:a.onMetricChange,onOverviewMetricChange:s.onMetricChange}))]})]})}))},je=function(e){switch(e.active){case"Overview":return n.jsx(pe,{data:e.data.overview,onMetricChange:e.onOverviewMetricChange});case"Breakdown":return n.jsx(de,{data:e.data.breakdown,onMetricChange:e.onBreakdownMetricChange});default:return null}},ve=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)}}},Ce=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)}}},Se=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],o=a[1];return{select:r,onSelectChange:function(e){o(e),n&&n(e)}}},be=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)}}},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)}}},ye=t.createStyles((function(e){var n,t,a,r,o,i;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:(o={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])},o[e.fn.smallerThan("sm")]={flexDirection:"column"},o),social:(i={},i[e.fn.smallerThan("sm")]={marginTop:e.spacing.xs},i)}})),Te=function(e,n){var t=i.useState(!e.hidden),a=t[0],r=t[1],o=i.useState(e.active),s=o[0],l=o[1];return{data:p(p({},e),{active:s,hidden:!a}),setChangeModalOpen:r,onAccountChange:function(e){l(e),r(!1),n&&n(e)}}},ze=function(e,n){var t=i.useState(e||"Home"),a=t[0],r=t[1];return{key:a,active:a,onClick:function(e){var t;a!==e&&(t=e,-1===R.indexOf(t)&&r(e),n&&n(e))}}},we=function(e){switch(e.active){case"Dashboard":return n.jsx(fe,{data:e.data.dashboard,onBreakdownMetricChange:e.onDashboardBreakdownMetricChange,onDateRangeChange:e.onDashboardDateRangeChange,onGroupChange:e.onDashboardGroupChange,onOverviewMetricChange:e.onDashboardOverviewMetricChange,onTabChange:e.onDashboardTabChange});case"Home":return n.jsx(se,{data:e.data.home,onTimelineScrollBottom:e.onHomeTimelineScrollBottom});case"Groups":return n.jsx(re,{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(L,{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(T,{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=ye().classes,r=Te(e.data.account,e.onAccountChange),i=ze(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(F,{active:i.active,onClick:i.onClick},i.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(o.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(o.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(o.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.jsx(we,p({},e,{active:i.active})),n.jsx(O,{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},{children:n.jsx(r.NotificationsProvider,p({limit:e.notificationLimit||5},{children:n.jsx(a.ModalsProvider,{children:e.children})}))}))},e.SwitchAccount=O,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { SwitchAccountProps } from "./SwitchAccount";
3
+ import { Story } from "@storybook/react";
4
+ /**
5
+ * Storybook component configuration
6
+ */
7
+ declare const _default: {
8
+ title: string;
9
+ component: (props: SwitchAccountProps) => JSX.Element;
10
+ };
11
+ export default _default;
12
+ /**
13
+ * Component stories
14
+ */
15
+ export declare const Component: Story<SwitchAccountProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@local-civics/mgmt-ui",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "scripts": {