@australiangreens/ag-internal-components 0.0.79 → 0.0.80
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/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ct=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,s=(e,t)=>{for(var o in t||(t={}))je.call(t,o)&&ae(e,o,t[o]);if(K)for(var o of K(t))ye.call(t,o)&&ae(e,o,t[o]);return e},b=(e,t)=>dt(e,ut(t));var be=(e,t)=>{var o={};for(var i in e)je.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&K)for(var i of K(e))t.indexOf(i)<0&&ye.call(e,i)&&(o[i]=e[i]);return o};var De=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var M=(e,t,o)=>new Promise((i,a)=>{var l=d=>{try{u(o.next(d))}catch(p){a(p)}},c=d=>{try{u(o.throw(d))}catch(p){a(p)}},u=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,c);u((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),r=require("@mui/material"),pt=require("@mui/material/CssBaseline"),k=require("@mui/material/styles"),ht=require("@australiangreens/ag-error"),U=require("souvlaki"),gt=require("@mui/material/List"),W=require("@mui/icons-material"),xt=require("autosuggest-highlight/match"),ft=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),mt=require("@auth0/auth0-react"),vt=require("@mui/material/Skeleton"),S=require("jotai"),Le=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},Ct=V(pt),Me=V(gt),At=V(xt),wt=V(ft),St=V(vt);function jt({text:e}){const[t,o]=g.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},yt=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${q.root}`]:{display:"flex"},[`& .${q.menuButton}`]:{marginRight:36},[`& .${q.hide}`]:{display:"none"},[`& .${q.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),He=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),bt=()=>s({width:de},He()),Dt=()=>s({width:ue},He()),Bt=k.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>s(s({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":bt()}),!t&&{"& .MuiDrawer-paper":Dt()}));class te extends ht.AgError{}De(te,"errorName","ContextError");const Re=g.createContext(null),Tt={},kt={},qe=({overrideState:e=Tt,overrideActions:t=kt,children:o})=>{const[{open:i},a]=g.useState({open:!0}),l=g.useCallback(d=>{a({open:d})},[]),c=g.useCallback(()=>{a(d=>b(s({},d),{open:!d.open}))},[]),u=s(s({open:i,setOpen:l,toggleOpen:c},e),t);return n.jsx(Re.Provider,{value:u,children:o})},We=()=>{const e=g.useContext(Re);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},ze=(e={})=>s({open:!0},e),It=U.createHelper((e=ze(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),Be=7,Ft=k.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,$t=k.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Ot({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(yt,{className:q.root,"data-testid":e,children:[n.jsx(Ct.default,{}),n.jsx(Bt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Ge=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:l,onClose:c,sx:u,"data-testid":d,disableCloseOnBackdropOrEscape:p=!1})=>{var j,m;const[C,w]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(y,D)=>M(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||C||(l!=null&&l.onClick?yield l.onClick():c())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":d,sx:u,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(j=l==null?void 0:l.onClick)!=null?j:c,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||C,color:l==null?void 0:l.buttonColor,children:(m=l==null?void 0:l.text)!=null?m:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>M(exports,null,function*(){var y;w(!0),yield(y=a.onClick)==null?void 0:y.call(a),w(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},pe=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>ce.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Et({lookup:e=()=>M(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:l,"data-testid":c,sx:u,textFieldColor:d,textFieldVariant:p="filled",loadingText:C="Loading...",noOptionsText:w="No options",popupIcon:j=n.jsx(W.ArrowDropDown,{}),error:m=!1,helperText:y="",preLoadedOptions:D=void 0,disablePortal:T=!1}){const[x,B]=g.useState(""),_=(h,f)=>{const $=l.filter(E=>E.id!==f);o($,"delete",h)},{data:O,isLoading:P}=pe({inputValue:x,label:a,lookup:e,minLength:i,preLoadedOptions:D}),I=x.length>=i;return n.jsxs("div",{"data-testid":c,children:[n.jsx(r.Autocomplete,{sx:u,"data-testid":c?`${c}:Autocomplete`:void 0,disablePortal:T,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:I?P:!1,options:[...l,...O!=null?O:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(h,f,$)=>{o(f,$,h)},onInputChange:(h,f)=>B(f),noOptionsText:I?w:"Start typing to search",loadingText:C,popupIcon:j,renderInput:h=>n.jsx(r.TextField,b(s({},h),{label:a,fullWidth:!0,variant:p,error:m,helperText:y,InputProps:b(s({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[P?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})}),"data-testid":c?`${c}:Autocomplete:TextField`:void 0,onKeyDown:f=>{(f.key==="Backspace"||f.key==="Delete")&&f.stopPropagation()},color:d})),renderTags:()=>null,isOptionEqualToValue:(h,f)=>h.id===f.id,renderOption:(h,f,$)=>{if(t){const E=At.default(f.label,$.inputValue,{insideWords:!0,findAllOccurrences:!0}),A=wt.default(f.label,E);return g.createElement("li",b(s({},h),{key:f.id,"data-testid":c?`${c}:Autocomplete:option(${f.id.toString()})`:void 0}),n.jsx("div",{children:A.map((v,N)=>n.jsx("span",{style:{fontWeight:v.highlight?700:400},children:v.text},N))}))}else return g.createElement("li",b(s({},h),{key:f.id,"data-testid":c?`${c}:option(${f.id.toString()})`:void 0}),f.label)}}),l.length>0&&n.jsx(r.Box,{children:l.map(h=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:h.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":c?`${c}:Chip(${h.id.toString()})`:void 0,onDelete:f=>_(f,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":c?`${c}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const Pt=({lookup:e=()=>M(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:l,textFieldVariant:c="filled","data-testid":u,noOptionsText:d="No options",minLength:p=3,disablePortal:C=!1,preLoadedOptions:w})=>{const[j,m]=g.useState(""),{data:y,isLoading:D}=pe({inputValue:j,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:w}),T=j.length>=p;return n.jsx("div",{"data-testid":u,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:a,"data-testid":u?`${u}:Autocomplete`:void 0,loading:T?D:!1,options:y!=null?y:[],onChange:(x,B)=>{t(x,B)},disablePortal:C,filterOptions:x=>x,value:i,noOptionsText:T?d:"Start typing to search",getOptionLabel:x=>x.label,renderInput:x=>n.jsx(r.TextField,b(s({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},x),{variant:c,label:o,color:l})),isOptionEqualToValue:(x,B)=>x.id===B.id,onInputChange:(x,B)=>{m(B)},renderOption:(x,B)=>g.createElement("li",b(s({},x),{key:B.id,"data-testid":u?`${u}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label)})})})};function Nt(e){return"error"in e}function _t(e){return e.error==="access_denied"}function Lt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("You do not have the required authorization")}function Mt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("User did not authorize the request")}function Ht({children:e}){const{isAuthenticated:t,isLoading:o,error:i,loginWithRedirect:a,logout:l}=mt.useAuth0();if(g.useEffect(()=>{if(o||t||i)return;const c={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};a(c)},[o,t,i,a]),i&&Nt(i)){let c="Auth error",u="An unknown Auth0 error occurred.";return Lt(i)?(c="Unauthorised",u="You are not authorised to access the app."):Mt(i)?(c="App not authorised",u="You have not authorised the application to access your user profile. This is necessary to use the app."):_t(i)&&(c="Unauthorised",u="Authorisation with auth0 failed for an unknown reason."),n.jsxs(r.Dialog,{open:!0,children:[n.jsx(r.DialogTitle,{children:c}),n.jsx(r.DialogContent,{children:n.jsx(r.Typography,{children:u})}),n.jsx(r.DialogActions,{children:n.jsx(r.Button,{onClick:()=>l({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}return t?n.jsx(n.Fragment,{children:e}):n.jsx(St.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const Rt=24,qt=64,R="TopBar",F={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Wt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return{width:"100%",[`& .${F.topStripe}`]:{width:"100%",height:`${Rt}px`,backgroundColor:e.palette.primary.main},[`& .${F.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${qt}px`,padding:e.spacing(0,3),width:"100%"},[`& .${F.titleSlider}`]:s(s({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${F.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${F.titleText}`]:{flexGrow:1},[`& .${F.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}});function zt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Wt,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:F.topStripe}),n.jsx("div",{className:F.titleBar,children:n.jsxs(r.Box,{className:F.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:F.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:F.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:F.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Ue=400,Gt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:a,navBarWidthClosed:l})=>({width:e,"& .MuiDrawer-paper":s(s({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&s({marginLeft:`${l}px`},i&&{marginLeft:`${a}px`}))})),Ut=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>b(s({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function ke({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:l=Ue,showCloseArrow:c=!0,debugOpacity:u=!1,headerBoxProps:d={},onOpened:p,onClosed:C,"data-testid":w,navBarOpen:j=!1,navBarWidthOpen:m=0,navBarWidthClosed:y=0}){return n.jsxs(Gt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:l,debugOpacity:u,"data-testid":w,navBarOpen:j,navBarWidthOpen:m,navBarWidthClosed:y,children:[n.jsx(Ut,b(s({anchor:t},d),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a}),c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a})]})})),e]})}const Vt=k.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return s(s({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}),Qt=k.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,Y={titleText:"",flavour:"push",width:Ue,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Xt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:l=!1,pageContainerProps:c,pageContentDataTestId:u,topBarDataTestId:d,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w}){const[j,m]=g.useState(se),[y,D]=g.useState(le),[T,x]=g.useState(se),[B,_]=g.useState(le),O=o!==void 0,P=i!==void 0,{titleText:I,content:h,flavour:f,open:$,onChangeOpen:E,width:A,arrowButtons:v,startOpen:N,onOpened:tt,onClosed:nt,dataTestId:ot}=o?s(s({},Y),o):s({},Y),{titleText:rt,content:it,flavour:Ce,open:ne,onChangeOpen:Ae,width:oe,arrowButtons:Q,startOpen:X,onOpened:at,onClosed:st,dataTestId:lt}=i?s(s({},Y),i):s({},Y);g.useEffect(()=>{N!==se&&(m(N),x(N))},[N]),g.useEffect(()=>{X!==le&&(D(X),_(X))},[X]);const re=$===void 0?j:$,ie=ne===void 0?y:ne,we=L=>{$===void 0&&(m(L),a&&P&&(L?(D(!1),_(y)):D(B))),E&&E(L)},Se=L=>{ne===void 0&&(D(L),a&&O&&(L?(m(!1),x(j)):m(T))),Ae&&Ae(L)};return n.jsxs(r.Box,{children:[O&&n.jsx(ke,{"data-testid":ot,anchor:"left",open:re,onClose:()=>we(!1),width:A,titleText:I,debugOpacity:l,showCloseArrow:v==="both"||v==="close",onOpened:tt,onClosed:nt,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w,children:h}),P&&n.jsx(ke,{"data-testid":lt,anchor:"right",open:ie,onClose:()=>Se(!1),width:oe,titleText:rt,debugOpacity:l,showCloseArrow:Q==="both"||Q==="close",onOpened:at,onClosed:st,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w,children:it}),n.jsx(zt,s(s({titleText:t,"data-testid":d},O&&f==="push"?{leftPanel:{open:re,width:A,onOpen:()=>we(!0),showOpenArrow:v==="both"||v==="open"}}:{}),P&&Ce==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>Se(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Vt,b(s(s({},f==="push"?{leftPanel:{open:re,width:A}}:{}),Ce==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(Qt,b(s({"data-testid":u},c),{children:e}))}))]})}const Ve=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Kt=64,Yt=64,Jt=256,z=S.atom(!0),he=S.atom(Jt),ge=S.atom(Yt),Z=S.atom(""),Qe=S.atom(void 0),xe=S.atom(Kt),fe=S.atom(void 0);function Zt({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",G={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},en=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${G.root}`]:{display:"flex"},[`& .${G.menuButton}`]:{marginRight:36},[`& .${G.hide}`]:{display:"none"},[`& .${G.content}`]:{flexGrow:1,padding:e.spacing(3)}})),ee=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),tn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,s({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Xe=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Ie=(e,t)=>s({width:t,transition:ee(e,"width","entering")},Xe(e)),Fe=(e,t)=>s({width:t,transition:ee(e,"width","leaving")},Xe(e)),nn=k.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>s(s({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&b(s({},Ie(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,o)})),!t&&b(s({},Fe(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Fe(e,a?o:i)})));function on(e){let t=0;for(let o=0,i=e.length;o<i;o++){const a=e.charCodeAt(o);t=(t<<5)-t+a,t|=0}return t}const $e=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],rn=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function an({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?ee(i,["width","height"],"entering"):ee(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:$e[Math.abs(on(e.name))%$e.length]},children:rn(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(tn,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function sn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:l,bottom:c,user:u,domainCode:d}){const p=Ve(),C=S.useSetAtom(z);return n.jsx(en,{className:G.root,"data-testid":i,children:n.jsxs(nn,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{C(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle"})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(l)?n.jsx(Zt,{links:l}):l}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle"}),n.jsx(an,{user:u,domainCode:d,open:e}),c&&n.jsx(n.Fragment,{children:c})]})]})})}function ln({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const cn="TopBar",dn={titleText:`${cn}-titleText`};function un({titleText:e="",height:t,"data-testid":o,middle:i}){const a=S.useSetAtom(z),l=()=>a(d=>!d),c=r.useTheme(),u=Ve();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t,zIndex:u?0:c.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:l,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:dn.titleText,variant:"h6",children:e}),i]})})}function pn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:l,navBarDataTestId:c,navBarMiddle:u,navBarBottom:d,user:p,domainCode:C}){Le.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const w=S.useAtomValue(z),[j]=S.useAtom(he),[m]=S.useAtom(ge),y=S.useAtomValue(Z),[D]=S.useAtom(xe),[T]=S.useAtom(Qe),[x]=S.useAtom(fe);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(un,{titleText:y,"data-testid":l,height:D,middle:T}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(sn,{open:w,top:x,middle:u,bottom:d,user:p,domainCode:C,widthOpen:j,widthClosed:m,offsetTop:D,"data-testid":c}),n.jsx(ln,b(s({"data-testid":a,topBarHeight:D},i),{children:e}))]})]})}const hn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},gn={shouldClose:(e,t)=>t!=="clickaway"},Oe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Ee=100,Pe=2e3,xn=2e3,fn=(()=>{let e=0;return()=>(e+=1,e)})(),mn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},vn={},Cn={},me=g.createContext(null);function Ke(l){var c=l,{overrideState:e=vn,overrideActions:t=Cn,shouldClose:o=gn.shouldClose,children:i}=c,a=be(c,["overrideState","overrideActions","shouldClose","children"]);var E;const[{open:u},d]=g.useState({open:!1}),p=g.useRef([]),C=g.useRef(Date.now()),w=g.useRef(0),j=g.useCallback(A=>{d({open:A})},[]),m=g.useCallback((A={})=>{w.current+=1,p.current.length>=Ee&&Date.now()-C.current>=Pe&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Ee}) hit ${w.current} times in last ${Pe}ms)`),w.current=0);const v=s(b(s({},Oe),{key:fn()}),A);return p.current.push(v),p.current.length===1&&d({open:!0}),v.key},[]),y=(A="",v={})=>m(s({message:A,severity:"success"},v)),D=(A="",v={})=>m(s({message:A,severity:"info"},v)),T=(A="",v={})=>m(s({message:A,severity:"warning"},v)),x=(A="",v={})=>m(s({message:A,severity:"error"},v)),B=A=>{const v=p.current.findIndex(N=>N.key===A);if(v!==-1)return v===0?(d({open:!1}),p.current[0]):p.current.splice(v,1)},_=(A,v)=>{o(A,v)&&d({open:!1})},O=()=>{},P=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},I=(E=p.current[0])!=null?E:s({},Oe),h={};"autoHideDuration"in I&&(h.autoHideDuration=I.autoHideDuration);const f=s(s({},hn),a),$=s(s({open:u,setOpen:j,enqueueNotification:m,enqueueSuccessNotification:y,enqueueInfoNotification:D,enqueueWarningNotification:T,enqueueErrorNotification:x,removeNotification:B},e),t);return n.jsxs(me.Provider,{value:$,children:[i,n.jsx(r.Snackbar,b(s(s({},f),h),{open:u,onClose:_,TransitionProps:{onExited:P,onExit:O},sx:{zIndex:xn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:A=>_(A,"closeAlert"),severity:I.severity,variant:"filled",icon:I.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:I.progressIndicator==="linear"?mn:void 0,children:I.message}),I.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Ye(){const e=g.useContext(me);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const An=U.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Ke,b(s({},e),{overrideState:t,overrideActions:o,children:i}))),Je=S.getDefaultStore(),wn=({children:e,store:t})=>n.jsx(S.Provider,{store:t!=null?t:Je,children:e}),Ze="domainCode";var _e;const Ne=S.atom(JSON.parse((_e=localStorage.getItem(Ze))!=null?_e:'{"domainCode": ""}').domainCode),ve=S.atom(e=>e(Ne),(e,t,o)=>{t(Ne,o),localStorage.setItem(Ze,JSON.stringify({domainCode:o}))}),Sn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},jn=e=>{var t;return e===null?"N/A":(t=Sn[e])!=null?t:""},yn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:l})=>{const[c,u]=S.useAtom(ve),[d,p]=g.useState(c),{enqueueSuccessNotification:C}=Ye(),w=i.length===0,j=!!c&&!i.includes(c)&&!i.includes(d),m=!c||w||j,y=()=>M(exports,null,function*(){d?(u(d),C(`Set domain to ${d}`),o()):u("")}),D=()=>M(exports,null,function*(){c&&!w&&!j?(p(c),o()):m&&l()});let T;return w?T="Unable to retrieve your active organisations. Try logging in again.":j&&(T="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(Ge,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:y,disabled:!d||w||j,buttonColor:"primary"},secondaryButton:{text:m?"Logout":"Cancel",onClick:D},onClose:m?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",a,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:d!==""?d:null,onChange:(x,B)=>p(B!=null?B:""),getOptionLabel:jn,options:[...i],renderInput:x=>n.jsx(r.TextField,b(s({},x),{variant:"filled",label:"Select organisation",InputProps:b(s({},x.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,x.InputProps.endAdornment]})})}))}),T&&n.jsx(r.FormHelperText,{error:!0,children:T})]})},bn=k.createTheme({palette:{primary:{dark:"#00A651",light:"#A3D39C",main:"#007236",contrastText:"#FFF"},warning:{main:"#F5871F",light:"#FCC589",dark:"#A2590A",contrastText:"#FFF"},secondary:{main:"#662D91",light:"#BD8CBF",dark:"#440E62",contrastText:"#FFF"},error:{main:"#D43C95",light:"#8F2064",dark:"#F9CDE0",contrastText:"#FFF"},info:{main:"#00A88D",light:"#ADDCCF",dark:"#005243",contrastText:"#FFF"},success:{main:"#00A651",light:"#A3D39C",dark:"#007236",contrastText:"#FFF"}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}}),Dn=k.createTheme({palette:{primary:{main:"#007236",dark:"#005221",light:"#00A04E",contrastText:"#FFFFFF"},secondary:{main:"#662D91",dark:"#440E62",light:"#93268F",contrastText:"#FFFFFF"},error:{main:"#D32F2F",dark:"#C62828",light:"#EF5350"},info:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"},success:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"}},components:{MuiTextField:{defaultProps:{color:"secondary"}},MuiToggleButtonGroup:{defaultProps:{color:"secondary"}},MuiCheckbox:{defaultProps:{color:"secondary"}},MuiSelect:{defaultProps:{color:"secondary"}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiFormControl:{defaultProps:{color:"secondary"}},MuiMenuItem:{styleOverrides:{root:({theme:e})=>({"&.Mui-selected":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),Bn={domainCode:ve,navBarOpen:z,navBarWidthOpen:he,navBarWidthClosed:ge,titleText:Z,topBarHeight:xe,navBarTop:fe},Tn=U.createHelper(()=>({children:e})=>n.jsx(S.Provider,{children:e})),et=({initialValues:e,children:t})=>(Le.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),kn=U.createHelper(e=>({children:t})=>n.jsx(et,{initialValues:Object.entries(e).map(([o,i])=>[Bn[o],i]),children:t})),In=U.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=Ge;exports.AppLayout=pn;exports.AtomProvider=wn;exports.AuthGuard=Ht;exports.Context=me;exports.ContextError=te;exports.DomainCodeDialog=yn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Et;exports.HydrateAtoms=et;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=Ot;exports.NavBarDarkStyledList=Ft;exports.NavBarLightStyledList=$t;exports.NavBarProvider=qe;exports.PageLayout=Xt;exports.SaladBarProvider=Ke;exports.SingleAutocomplete=Pt;exports.atomStore=Je;exports.buildNavBarState=ze;exports.domainCodeAtom=ve;exports.fed21Theme=bn;exports.internalAgSystemsTheme=Dn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=fe;exports.navBarWidthClosedAtom=ge;exports.navBarWidthOpenAtom=he;exports.titleTextAtom=Z;exports.topBarHeightAtom=xe;exports.topBarMiddleAtom=Qe;exports.useAutocompleteOptions=pe;exports.useNavBar=We;exports.useSaladBar=Ye;exports.withAtomProvider=Tn;exports.withNavBarProvider=It;exports.withOverrideDefaults=kn;exports.withQueryClient=In;exports.withSaladBarProvider=An;
|
|
1
|
+
"use strict";var ct=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,s=(e,t)=>{for(var o in t||(t={}))je.call(t,o)&&ae(e,o,t[o]);if(K)for(var o of K(t))ye.call(t,o)&&ae(e,o,t[o]);return e},b=(e,t)=>dt(e,ut(t));var be=(e,t)=>{var o={};for(var i in e)je.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&K)for(var i of K(e))t.indexOf(i)<0&&ye.call(e,i)&&(o[i]=e[i]);return o};var De=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var M=(e,t,o)=>new Promise((i,a)=>{var l=c=>{try{u(o.next(c))}catch(p){a(p)}},d=c=>{try{u(o.throw(c))}catch(p){a(p)}},u=c=>c.done?i(c.value):Promise.resolve(c.value).then(l,d);u((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),r=require("@mui/material"),pt=require("@mui/material/CssBaseline"),k=require("@mui/material/styles"),ht=require("@australiangreens/ag-error"),U=require("souvlaki"),gt=require("@mui/material/List"),W=require("@mui/icons-material"),xt=require("autosuggest-highlight/match"),ft=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),mt=require("@auth0/auth0-react"),vt=require("@mui/material/Skeleton"),S=require("jotai"),Le=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},Ct=V(pt),Me=V(gt),At=V(xt),wt=V(ft),St=V(vt);function jt({text:e}){const[t,o]=g.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},yt=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${q.root}`]:{display:"flex"},[`& .${q.menuButton}`]:{marginRight:36},[`& .${q.hide}`]:{display:"none"},[`& .${q.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),He=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),bt=()=>s({width:de},He()),Dt=()=>s({width:ue},He()),Bt=k.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>s(s({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":bt()}),!t&&{"& .MuiDrawer-paper":Dt()}));class te extends ht.AgError{}De(te,"errorName","ContextError");const Re=g.createContext(null),Tt={},kt={},qe=({overrideState:e=Tt,overrideActions:t=kt,children:o})=>{const[{open:i},a]=g.useState({open:!0}),l=g.useCallback(c=>{a({open:c})},[]),d=g.useCallback(()=>{a(c=>b(s({},c),{open:!c.open}))},[]),u=s(s({open:i,setOpen:l,toggleOpen:d},e),t);return n.jsx(Re.Provider,{value:u,children:o})},We=()=>{const e=g.useContext(Re);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},ze=(e={})=>s({open:!0},e),It=U.createHelper((e=ze(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),Be=7,$t=k.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Ft=k.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Ot({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(yt,{className:q.root,"data-testid":e,children:[n.jsx(Ct.default,{}),n.jsx(Bt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Ge=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:l,onClose:d,sx:u,"data-testid":c,disableCloseOnBackdropOrEscape:p=!1})=>{var j,m;const[C,w]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(y,D)=>M(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||C||(l!=null&&l.onClick?yield l.onClick():d())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":c,sx:u,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(j=l==null?void 0:l.onClick)!=null?j:d,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||C,color:l==null?void 0:l.buttonColor,children:(m=l==null?void 0:l.text)!=null?m:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>M(exports,null,function*(){var y;w(!0),yield(y=a.onClick)==null?void 0:y.call(a),w(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},pe=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>ce.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Et({lookup:e=()=>M(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:l,"data-testid":d,sx:u,textFieldColor:c,textFieldVariant:p="filled",loadingText:C="Loading...",noOptionsText:w="No options",popupIcon:j=n.jsx(W.ArrowDropDown,{}),error:m=!1,helperText:y="",preLoadedOptions:D=void 0,disablePortal:T=!1}){const[x,B]=g.useState(""),_=(h,f)=>{const F=l.filter(E=>E.id!==f);o(F,"delete",h)},{data:O,isLoading:P}=pe({inputValue:x,label:a,lookup:e,minLength:i,preLoadedOptions:D}),I=x.length>=i;return n.jsxs("div",{"data-testid":d,children:[n.jsx(r.Autocomplete,{sx:u,"data-testid":d?`${d}:Autocomplete`:void 0,disablePortal:T,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:I?P:!1,options:[...l,...O!=null?O:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(h,f,F)=>{o(f,F,h)},onInputChange:(h,f)=>B(f),noOptionsText:I?w:"Start typing to search",loadingText:C,popupIcon:j,renderInput:h=>n.jsx(r.TextField,b(s({},h),{label:a,fullWidth:!0,variant:p,error:m,helperText:y,InputProps:b(s({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[P?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})}),"data-testid":d?`${d}:Autocomplete:TextField`:void 0,onKeyDown:f=>{(f.key==="Backspace"||f.key==="Delete")&&f.stopPropagation()},color:c})),renderTags:()=>null,isOptionEqualToValue:(h,f)=>h.id===f.id,renderOption:(h,f,F)=>{if(t){const E=At.default(f.label,F.inputValue,{insideWords:!0,findAllOccurrences:!0}),A=wt.default(f.label,E);return g.createElement("li",b(s({},h),{key:f.id,"data-testid":d?`${d}:Autocomplete:option(${f.id.toString()})`:void 0}),n.jsx("div",{children:A.map((v,N)=>n.jsx("span",{style:{fontWeight:v.highlight?700:400},children:v.text},N))}))}else return g.createElement("li",b(s({},h),{key:f.id,"data-testid":d?`${d}:option(${f.id.toString()})`:void 0}),f.label)}}),l.length>0&&n.jsx(r.Box,{children:l.map(h=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:h.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":d?`${d}:Chip(${h.id.toString()})`:void 0,onDelete:f=>_(f,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":d?`${d}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const Pt=({lookup:e=()=>M(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:l,textFieldVariant:d="filled","data-testid":u,noOptionsText:c="No options",minLength:p=3,disablePortal:C=!1,preLoadedOptions:w})=>{const[j,m]=g.useState(""),{data:y,isLoading:D}=pe({inputValue:j,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:w}),T=j.length>=p;return n.jsx("div",{"data-testid":u,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:a,"data-testid":u?`${u}:Autocomplete`:void 0,loading:T?D:!1,options:y!=null?y:[],onChange:(x,B)=>{t(x,B)},disablePortal:C,filterOptions:x=>x,value:i,noOptionsText:T?c:"Start typing to search",getOptionLabel:x=>x.label,renderInput:x=>n.jsx(r.TextField,b(s({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},x),{variant:d,label:o,color:l})),isOptionEqualToValue:(x,B)=>x.id===B.id,onInputChange:(x,B)=>{m(B)},renderOption:(x,B)=>g.createElement("li",b(s({},x),{key:B.id,"data-testid":u?`${u}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label)})})})};function Nt(e){return"error"in e}function _t(e){return e.error==="access_denied"}function Lt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("You do not have the required authorization")}function Mt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("User did not authorize the request")}function Ht({children:e,appName:t="the app"}){const{isAuthenticated:o,isLoading:i,error:a,loginWithRedirect:l,logout:d}=mt.useAuth0();if(g.useEffect(()=>{if(i||o||a)return;const u={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};l(u)},[i,o,a,l]),a&&Nt(a)){let u="Auth error",c="An unknown Auth0 error occurred.";return Lt(a)?(u="Unauthorised",c=`You are not authorised to access ${t}.`):Mt(a)?(u="App not authorised",c=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`):_t(a)&&(u="Unauthorised",c="Authorisation with auth0 failed for an unknown reason."),n.jsxs(r.Dialog,{open:!0,children:[n.jsx(r.DialogTitle,{children:u}),n.jsx(r.DialogContent,{children:n.jsx(r.Typography,{children:c})}),n.jsx(r.DialogActions,{children:n.jsx(r.Button,{onClick:()=>d({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}return o?n.jsx(n.Fragment,{children:e}):n.jsx(St.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const Rt=24,qt=64,R="TopBar",$={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Wt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return{width:"100%",[`& .${$.topStripe}`]:{width:"100%",height:`${Rt}px`,backgroundColor:e.palette.primary.main},[`& .${$.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${qt}px`,padding:e.spacing(0,3),width:"100%"},[`& .${$.titleSlider}`]:s(s({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${$.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${$.titleText}`]:{flexGrow:1},[`& .${$.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}});function zt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Wt,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:$.topStripe}),n.jsx("div",{className:$.titleBar,children:n.jsxs(r.Box,{className:$.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:$.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:$.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:$.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Ue=400,Gt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:a,navBarWidthClosed:l})=>({width:e,"& .MuiDrawer-paper":s(s({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&s({marginLeft:`${l}px`},i&&{marginLeft:`${a}px`}))})),Ut=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>b(s({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function ke({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:l=Ue,showCloseArrow:d=!0,debugOpacity:u=!1,headerBoxProps:c={},onOpened:p,onClosed:C,"data-testid":w,navBarOpen:j=!1,navBarWidthOpen:m=0,navBarWidthClosed:y=0}){return n.jsxs(Gt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:l,debugOpacity:u,"data-testid":w,navBarOpen:j,navBarWidthOpen:m,navBarWidthClosed:y,children:[n.jsx(Ut,b(s({anchor:t},c),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a}),d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a})]})})),e]})}const Vt=k.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return s(s({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}),Qt=k.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,Y={titleText:"",flavour:"push",width:Ue,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Xt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:l=!1,pageContainerProps:d,pageContentDataTestId:u,topBarDataTestId:c,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w}){const[j,m]=g.useState(se),[y,D]=g.useState(le),[T,x]=g.useState(se),[B,_]=g.useState(le),O=o!==void 0,P=i!==void 0,{titleText:I,content:h,flavour:f,open:F,onChangeOpen:E,width:A,arrowButtons:v,startOpen:N,onOpened:tt,onClosed:nt,dataTestId:ot}=o?s(s({},Y),o):s({},Y),{titleText:rt,content:it,flavour:Ce,open:ne,onChangeOpen:Ae,width:oe,arrowButtons:Q,startOpen:X,onOpened:at,onClosed:st,dataTestId:lt}=i?s(s({},Y),i):s({},Y);g.useEffect(()=>{N!==se&&(m(N),x(N))},[N]),g.useEffect(()=>{X!==le&&(D(X),_(X))},[X]);const re=F===void 0?j:F,ie=ne===void 0?y:ne,we=L=>{F===void 0&&(m(L),a&&P&&(L?(D(!1),_(y)):D(B))),E&&E(L)},Se=L=>{ne===void 0&&(D(L),a&&O&&(L?(m(!1),x(j)):m(T))),Ae&&Ae(L)};return n.jsxs(r.Box,{children:[O&&n.jsx(ke,{"data-testid":ot,anchor:"left",open:re,onClose:()=>we(!1),width:A,titleText:I,debugOpacity:l,showCloseArrow:v==="both"||v==="close",onOpened:tt,onClosed:nt,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w,children:h}),P&&n.jsx(ke,{"data-testid":lt,anchor:"right",open:ie,onClose:()=>Se(!1),width:oe,titleText:rt,debugOpacity:l,showCloseArrow:Q==="both"||Q==="close",onOpened:at,onClosed:st,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:w,children:it}),n.jsx(zt,s(s({titleText:t,"data-testid":c},O&&f==="push"?{leftPanel:{open:re,width:A,onOpen:()=>we(!0),showOpenArrow:v==="both"||v==="open"}}:{}),P&&Ce==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>Se(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Vt,b(s(s({},f==="push"?{leftPanel:{open:re,width:A}}:{}),Ce==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(Qt,b(s({"data-testid":u},d),{children:e}))}))]})}const Ve=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Kt=64,Yt=64,Jt=256,z=S.atom(!0),he=S.atom(Jt),ge=S.atom(Yt),Z=S.atom(""),Qe=S.atom(void 0),xe=S.atom(Kt),fe=S.atom(void 0);function Zt({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",G={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},en=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${G.root}`]:{display:"flex"},[`& .${G.menuButton}`]:{marginRight:36},[`& .${G.hide}`]:{display:"none"},[`& .${G.content}`]:{flexGrow:1,padding:e.spacing(3)}})),ee=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),tn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,s({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Xe=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Ie=(e,t)=>s({width:t,transition:ee(e,"width","entering")},Xe(e)),$e=(e,t)=>s({width:t,transition:ee(e,"width","leaving")},Xe(e)),nn=k.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>s(s({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&b(s({},Ie(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,o)})),!t&&b(s({},$e(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":$e(e,a?o:i)})));function on(e){let t=0;for(let o=0,i=e.length;o<i;o++){const a=e.charCodeAt(o);t=(t<<5)-t+a,t|=0}return t}const Fe=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],rn=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function an({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?ee(i,["width","height"],"entering"):ee(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Fe[Math.abs(on(e.name))%Fe.length]},children:rn(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(tn,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function sn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:l,bottom:d,user:u,domainCode:c}){const p=Ve(),C=S.useSetAtom(z);return n.jsx(en,{className:G.root,"data-testid":i,children:n.jsxs(nn,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{C(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle"})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(l)?n.jsx(Zt,{links:l}):l}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle"}),n.jsx(an,{user:u,domainCode:c,open:e}),d&&n.jsx(n.Fragment,{children:d})]})]})})}function ln({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const cn="TopBar",dn={titleText:`${cn}-titleText`};function un({titleText:e="",height:t,"data-testid":o,middle:i}){const a=S.useSetAtom(z),l=()=>a(c=>!c),d=r.useTheme(),u=Ve();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t,zIndex:u?0:d.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:l,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:dn.titleText,variant:"h6",children:e}),i]})})}function pn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:l,navBarDataTestId:d,navBarMiddle:u,navBarBottom:c,user:p,domainCode:C}){Le.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const w=S.useAtomValue(z),[j]=S.useAtom(he),[m]=S.useAtom(ge),y=S.useAtomValue(Z),[D]=S.useAtom(xe),[T]=S.useAtom(Qe),[x]=S.useAtom(fe);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(un,{titleText:y,"data-testid":l,height:D,middle:T}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(sn,{open:w,top:x,middle:u,bottom:c,user:p,domainCode:C,widthOpen:j,widthClosed:m,offsetTop:D,"data-testid":d}),n.jsx(ln,b(s({"data-testid":a,topBarHeight:D},i),{children:e}))]})]})}const hn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},gn={shouldClose:(e,t)=>t!=="clickaway"},Oe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Ee=100,Pe=2e3,xn=2e3,fn=(()=>{let e=0;return()=>(e+=1,e)})(),mn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},vn={},Cn={},me=g.createContext(null);function Ke(l){var d=l,{overrideState:e=vn,overrideActions:t=Cn,shouldClose:o=gn.shouldClose,children:i}=d,a=be(d,["overrideState","overrideActions","shouldClose","children"]);var E;const[{open:u},c]=g.useState({open:!1}),p=g.useRef([]),C=g.useRef(Date.now()),w=g.useRef(0),j=g.useCallback(A=>{c({open:A})},[]),m=g.useCallback((A={})=>{w.current+=1,p.current.length>=Ee&&Date.now()-C.current>=Pe&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Ee}) hit ${w.current} times in last ${Pe}ms)`),w.current=0);const v=s(b(s({},Oe),{key:fn()}),A);return p.current.push(v),p.current.length===1&&c({open:!0}),v.key},[]),y=(A="",v={})=>m(s({message:A,severity:"success"},v)),D=(A="",v={})=>m(s({message:A,severity:"info"},v)),T=(A="",v={})=>m(s({message:A,severity:"warning"},v)),x=(A="",v={})=>m(s({message:A,severity:"error"},v)),B=A=>{const v=p.current.findIndex(N=>N.key===A);if(v!==-1)return v===0?(c({open:!1}),p.current[0]):p.current.splice(v,1)},_=(A,v)=>{o(A,v)&&c({open:!1})},O=()=>{},P=()=>{p.current.shift(),p.current.length>0&&c({open:!0})},I=(E=p.current[0])!=null?E:s({},Oe),h={};"autoHideDuration"in I&&(h.autoHideDuration=I.autoHideDuration);const f=s(s({},hn),a),F=s(s({open:u,setOpen:j,enqueueNotification:m,enqueueSuccessNotification:y,enqueueInfoNotification:D,enqueueWarningNotification:T,enqueueErrorNotification:x,removeNotification:B},e),t);return n.jsxs(me.Provider,{value:F,children:[i,n.jsx(r.Snackbar,b(s(s({},f),h),{open:u,onClose:_,TransitionProps:{onExited:P,onExit:O},sx:{zIndex:xn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:A=>_(A,"closeAlert"),severity:I.severity,variant:"filled",icon:I.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:I.progressIndicator==="linear"?mn:void 0,children:I.message}),I.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Ye(){const e=g.useContext(me);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const An=U.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Ke,b(s({},e),{overrideState:t,overrideActions:o,children:i}))),Je=S.getDefaultStore(),wn=({children:e,store:t})=>n.jsx(S.Provider,{store:t!=null?t:Je,children:e}),Ze="domainCode";var _e;const Ne=S.atom(JSON.parse((_e=localStorage.getItem(Ze))!=null?_e:'{"domainCode": ""}').domainCode),ve=S.atom(e=>e(Ne),(e,t,o)=>{t(Ne,o),localStorage.setItem(Ze,JSON.stringify({domainCode:o}))}),Sn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},jn=e=>{var t;return e===null?"N/A":(t=Sn[e])!=null?t:""},yn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:l})=>{const[d,u]=S.useAtom(ve),[c,p]=g.useState(d),{enqueueSuccessNotification:C}=Ye(),w=i.length===0,j=!!d&&!i.includes(d)&&!i.includes(c),m=!d||w||j,y=()=>M(exports,null,function*(){c?(u(c),C(`Set domain to ${c}`),o()):u("")}),D=()=>M(exports,null,function*(){d&&!w&&!j?(p(d),o()):m&&l()});let T;return w?T="Unable to retrieve your active organisations. Try logging in again.":j&&(T="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(Ge,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:y,disabled:!c||w||j,buttonColor:"primary"},secondaryButton:{text:m?"Logout":"Cancel",onClick:D},onClose:m?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",a,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:c!==""?c:null,onChange:(x,B)=>p(B!=null?B:""),getOptionLabel:jn,options:[...i],renderInput:x=>n.jsx(r.TextField,b(s({},x),{variant:"filled",label:"Select organisation",InputProps:b(s({},x.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,x.InputProps.endAdornment]})})}))}),T&&n.jsx(r.FormHelperText,{error:!0,children:T})]})},bn=k.createTheme({palette:{primary:{dark:"#00A651",light:"#A3D39C",main:"#007236",contrastText:"#FFF"},warning:{main:"#F5871F",light:"#FCC589",dark:"#A2590A",contrastText:"#FFF"},secondary:{main:"#662D91",light:"#BD8CBF",dark:"#440E62",contrastText:"#FFF"},error:{main:"#D43C95",light:"#8F2064",dark:"#F9CDE0",contrastText:"#FFF"},info:{main:"#00A88D",light:"#ADDCCF",dark:"#005243",contrastText:"#FFF"},success:{main:"#00A651",light:"#A3D39C",dark:"#007236",contrastText:"#FFF"}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}}),Dn=k.createTheme({palette:{primary:{main:"#007236",dark:"#005221",light:"#00A04E",contrastText:"#FFFFFF"},secondary:{main:"#662D91",dark:"#440E62",light:"#93268F",contrastText:"#FFFFFF"},error:{main:"#D32F2F",dark:"#C62828",light:"#EF5350"},info:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"},success:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"}},components:{MuiTextField:{defaultProps:{color:"secondary"}},MuiToggleButtonGroup:{defaultProps:{color:"secondary"}},MuiCheckbox:{defaultProps:{color:"secondary"}},MuiSelect:{defaultProps:{color:"secondary"}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiFormControl:{defaultProps:{color:"secondary"}},MuiMenuItem:{styleOverrides:{root:({theme:e})=>({"&.Mui-selected":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),Bn={domainCode:ve,navBarOpen:z,navBarWidthOpen:he,navBarWidthClosed:ge,titleText:Z,topBarHeight:xe,navBarTop:fe},Tn=U.createHelper(()=>({children:e})=>n.jsx(S.Provider,{children:e})),et=({initialValues:e,children:t})=>(Le.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),kn=U.createHelper(e=>({children:t})=>n.jsx(et,{initialValues:Object.entries(e).map(([o,i])=>[Bn[o],i]),children:t})),In=U.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=Ge;exports.AppLayout=pn;exports.AtomProvider=wn;exports.AuthGuard=Ht;exports.Context=me;exports.ContextError=te;exports.DomainCodeDialog=yn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Et;exports.HydrateAtoms=et;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=Ot;exports.NavBarDarkStyledList=$t;exports.NavBarLightStyledList=Ft;exports.NavBarProvider=qe;exports.PageLayout=Xt;exports.SaladBarProvider=Ke;exports.SingleAutocomplete=Pt;exports.atomStore=Je;exports.buildNavBarState=ze;exports.domainCodeAtom=ve;exports.fed21Theme=bn;exports.internalAgSystemsTheme=Dn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=fe;exports.navBarWidthClosedAtom=ge;exports.navBarWidthOpenAtom=he;exports.titleTextAtom=Z;exports.topBarHeightAtom=xe;exports.topBarMiddleAtom=Qe;exports.useAutocompleteOptions=pe;exports.useNavBar=We;exports.useSaladBar=Ye;exports.withAtomProvider=Tn;exports.withNavBarProvider=It;exports.withOverrideDefaults=kn;exports.withQueryClient=In;exports.withSaladBarProvider=An;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|