@australiangreens/ag-internal-components 0.0.84 → 0.0.85

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/README.md CHANGED
@@ -32,3 +32,8 @@ As over v0.0.50 we have moved from React 17 to React 18 (also Node 16 to Node
32
32
  18). This breaks the peer dependency compatibility with some of our older apps.
33
33
  They will need be upgraded in the future to use newer versions, but for now can
34
34
  only use v0.0.50 of this library.
35
+
36
+ ## Move to pnpm
37
+
38
+ Because it is faster than yarn.
39
+
@@ -1,2 +1,2 @@
1
- "use strict";var ut=Object.defineProperty,pt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,l=(e,t)=>{for(var o in t||(t={}))je.call(t,o)&&se(e,o,t[o]);if(Y)for(var o of Y(t))De.call(t,o)&&se(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(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&&Y)for(var i of Y(e))t.indexOf(i)<0&&De.call(e,i)&&(o[i]=e[i]);return o};var ke=(e,t,o)=>(se(e,typeof t!="symbol"?t+"":t,o),o);var F=(e,t,o)=>new Promise((i,a)=>{var s=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(s,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"),gt=require("@mui/material/CssBaseline"),I=require("@mui/material/styles"),xt=require("@australiangreens/ag-error"),G=require("souvlaki"),ft=require("@mui/material/List"),W=require("@mui/icons-material"),mt=require("autosuggest-highlight/match"),Ct=require("autosuggest-highlight/parse"),de=require("@tanstack/react-query"),He=require("@auth0/auth0-react"),vt=require("buffer"),At=require("@mui/material/Skeleton"),y=require("jotai"),Re=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},wt=V(gt),qe=V(ft),St=V(mt),yt=V(Ct),bt=V(At);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 ue=330,pe=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`},Dt=I.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"}})),We=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>l({width:ue},We()),kt=()=>l({width:pe},We()),Tt=I.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?ue:pe,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":kt()}));class te extends xt.AgError{}ke(te,"errorName","ContextError");const ze=g.createContext(null),It={},Et={},Ue=({overrideState:e=It,overrideActions:t=Et,children:o})=>{const[{open:i},a]=g.useState({open:!0}),s=g.useCallback(c=>{a({open:c})},[]),d=g.useCallback(()=>{a(c=>j(l({},c),{open:!c.open}))},[]),u=l(l({open:i,setOpen:s,toggleOpen:d},e),t);return n.jsx(ze.Provider,{value:u,children:o})},Ge=()=>{const e=g.useContext(ze);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ve=(e={})=>l({open:!0},e),$t=G.createHelper((e=Ve(),t={})=>({children:o})=>n.jsx(Ue,{overrideState:e,overrideActions:t,children:o})),Te=7,Ot=I.styled(qe.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",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}}})),Ie=7,Ft=I.styled(qe.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Ie}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Ie}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 Pt({"data-testid":e,children:t}){const{open:o}=Ge();return n.jsxs(Dt,{className:q.root,"data-testid":e,children:[n.jsx(wt.default,{}),n.jsx(Tt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const he=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:s,onClose:d,sx:u,"data-testid":c,disableCloseOnBackdropOrEscape:p=!1})=>{var S,x;const[m,v]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(D,b)=>F(exports,null,function*(){p&&(b==="backdropClick"||b==="escapeKeyDown")||m||(s!=null&&s.onClick?yield s.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:(S=s==null?void 0:s.onClick)!=null?S:d,"data-testid":s==null?void 0:s.testId,disabled:(s==null?void 0:s.disabled)||m,color:s==null?void 0:s.buttonColor,children:(x=s==null?void 0:s.text)!=null?x:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>F(exports,null,function*(){var D;v(!0),yield(D=a.onClick)==null?void 0:D.call(a),v(!1)}),"data-testid":a.testId,disabled:a.disabled||m,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},ge=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>de.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(s=>s.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Nt({lookup:e=()=>F(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:s,"data-testid":d,sx:u,boxSx:c,textFieldColor:p,textFieldVariant:m="filled",loadingText:v="Loading...",noOptionsText:S="No options",popupIcon:x=n.jsx(W.ArrowDropDown,{}),error:D=!1,helperText:b="",preLoadedOptions:T=void 0,disablePortal:k=!1}){const[A,B]=g.useState(""),_=(h,f)=>{const O=s.filter(C=>C.id!==f);o(O,"delete",h)},{data:P,isLoading:E}=ge({inputValue:A,label:a,lookup:e,minLength:i,preLoadedOptions:T}),L=A.length>=i;return n.jsxs("div",{"data-testid":d,children:[n.jsx(r.Autocomplete,{sx:u,"data-testid":d?`${d}:Autocomplete`:void 0,disablePortal:k,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:L?E:!1,options:[...s,...P!=null?P:[]],filterSelectedOptions:!0,includeInputInList:!0,value:s,onChange:(h,f,O)=>{o(f,O,h)},onInputChange:(h,f)=>B(f),noOptionsText:L?S:"Start typing to search",loadingText:v,popupIcon:x,renderInput:h=>n.jsx(r.TextField,j(l({},h),{label:a,fullWidth:!0,variant:m,error:D,helperText:b,InputProps:j(l({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[E?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:p})),renderTags:()=>null,isOptionEqualToValue:(h,f)=>h.id===f.id,renderOption:(h,f,O)=>{if(t){const C=St.default(f.label,O.inputValue,{insideWords:!0,findAllOccurrences:!0}),w=yt.default(f.label,C);return g.createElement("li",j(l({},h),{key:f.id,"data-testid":d?`${d}:Autocomplete:option(${f.id.toString()})`:void 0}),n.jsx("div",{children:w.map((N,ne)=>n.jsx("span",{style:{fontWeight:N.highlight?700:400},children:N.text},ne))}))}else return g.createElement("li",j(l({},h),{key:f.id,"data-testid":d?`${d}:option(${f.id.toString()})`:void 0}),f.label)}}),s.length>0&&n.jsx(r.Box,{sx:c,children:s.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 _t=({lookup:e=()=>F(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:s,textFieldVariant:d="filled","data-testid":u,noOptionsText:c="No options",minLength:p=3,disablePortal:m=!1,preLoadedOptions:v,helperText:S=""})=>{const[x,D]=g.useState(""),{data:b,isLoading:T}=ge({inputValue:x,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:v}),k=x.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:k?T:!1,options:b!=null?b:[],onChange:(A,B)=>{t(A,B)},disablePortal:m,filterOptions:A=>A,value:i,noOptionsText:k?c:"Start typing to search",getOptionLabel:A=>A.label,renderInput:A=>n.jsx(r.TextField,j(l({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},A),{variant:d,label:o,color:s,helperText:S})),isOptionEqualToValue:(A,B)=>A.id===B.id,onInputChange:(A,B)=>{D(B)},renderOption:(A,B)=>g.createElement("li",j(l({},A),{key:B.id,"data-testid":u?`${u}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label)})})})},Qe=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(vt.Buffer.from(o,"base64").toString("utf8").split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join("")),a=JSON.parse(i);return a!=null&&a.exp?a.exp:-1}catch(t){return-1}},Lt=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:a}=He.useAuth0(),[s,d]=g.useState(0),u=()=>F(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),c=()=>F(exports,null,function*(){d(s+1),t()});g.useEffect(()=>{(()=>F(exports,null,function*(){if(s>0){const S=yield a({cacheMode:"off"}),x=Qe(S)*1e3;o(x)}}))()},[s,a,o]);const p={text:"Continue",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},m={text:"Log out",onClick:u,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(he,{isOpen:e,primaryButton:p,secondaryButton:m,onClose:t,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:n.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Mt(e){return"error"in e}function Ht(e){return e.error==="access_denied"}function Rt(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 qt(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 Wt({children:e,appName:t="the app"}){const{isAuthenticated:o,isLoading:i,error:a,loginWithRedirect:s,logout:d}=He.useAuth0();if(g.useEffect(()=>{if(i||o||a)return;const u={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};s(u)},[i,o,a,s]),a&&Mt(a)){let u="Auth error",c="An unknown Auth0 error occurred.";return Rt(a)?(u="Unauthorised",c=`You are not authorised to access ${t}.`):qt(a)?(u="App not authorised",c=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`):Ht(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(bt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const zt=24,Ut=64,R="TopBar",$={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Gt=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:`${zt}px`,backgroundColor:e.palette.primary.main},[`& .${$.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ut}px`,padding:e.spacing(0,3),width:"100%"},[`& .${$.titleSlider}`]:l(l({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 Vt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Gt,{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 Xe=400,Qt=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:s})=>({width:e,"& .MuiDrawer-paper":l(l({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"&&l({marginLeft:`${s}px`},i&&{marginLeft:`${a}px`}))})),Xt=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(l({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 Ee({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:s=Xe,showCloseArrow:d=!0,debugOpacity:u=!1,headerBoxProps:c={},onOpened:p,onClosed:m,"data-testid":v,navBarOpen:S=!1,navBarWidthOpen:x=0,navBarWidthClosed:D=0}){return n.jsxs(Qt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>m==null?void 0:m()},variant:"persistent",anchor:t,open:o,width:s,debugOpacity:u,"data-testid":v,navBarOpen:S,navBarWidthOpen:x,navBarWidthClosed:D,children:[n.jsx(Xt,j(l({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 Yt=I.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return l(l({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`})}),Kt=I.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),le=!1,ce=!1,K={titleText:"",flavour:"push",width:Xe,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 Jt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:s=!1,pageContainerProps:d,pageContentDataTestId:u,topBarDataTestId:c,navBarOpen:p,navBarWidthOpen:m,navBarWidthClosed:v}){const[S,x]=g.useState(le),[D,b]=g.useState(ce),[T,k]=g.useState(le),[A,B]=g.useState(ce),_=o!==void 0,P=i!==void 0,{titleText:E,content:L,flavour:h,open:f,onChangeOpen:O,width:C,arrowButtons:w,startOpen:N,onOpened:ne,onClosed:rt,dataTestId:it}=o?l(l({},K),o):l({},K),{titleText:at,content:st,flavour:we,open:oe,onChangeOpen:Se,width:re,arrowButtons:Q,startOpen:X,onOpened:lt,onClosed:ct,dataTestId:dt}=i?l(l({},K),i):l({},K);g.useEffect(()=>{N!==le&&(x(N),k(N))},[N]),g.useEffect(()=>{X!==ce&&(b(X),B(X))},[X]);const ie=f===void 0?S:f,ae=oe===void 0?D:oe,ye=M=>{f===void 0&&(x(M),a&&P&&(M?(b(!1),B(D)):b(A))),O&&O(M)},be=M=>{oe===void 0&&(b(M),a&&_&&(M?(x(!1),k(S)):x(T))),Se&&Se(M)};return n.jsxs(r.Box,{children:[_&&n.jsx(Ee,{"data-testid":it,anchor:"left",open:ie,onClose:()=>ye(!1),width:C,titleText:E,debugOpacity:s,showCloseArrow:w==="both"||w==="close",onOpened:ne,onClosed:rt,navBarOpen:p,navBarWidthOpen:m,navBarWidthClosed:v,children:L}),P&&n.jsx(Ee,{"data-testid":dt,anchor:"right",open:ae,onClose:()=>be(!1),width:re,titleText:at,debugOpacity:s,showCloseArrow:Q==="both"||Q==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:m,navBarWidthClosed:v,children:st}),n.jsx(Vt,l(l({titleText:t,"data-testid":c},_&&h==="push"?{leftPanel:{open:ie,width:C,onOpen:()=>ye(!0),showOpenArrow:w==="both"||w==="open"}}:{}),P&&we==="push"?{rightPanel:{open:ae,width:re,onOpen:()=>be(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Yt,j(l(l({},h==="push"?{leftPanel:{open:ie,width:C}}:{}),we==="push"?{rightPanel:{open:ae,width:re}}:{}),{children:n.jsx(Kt,j(l({"data-testid":u},d),{children:e}))}))]})}const Ye=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Zt=64,en=72,tn=256,z=y.atom(!0),xe=y.atom(tn),fe=y.atom(en),Z=y.atom(""),Ke=y.atom(void 0),me=y.atom(Zt),Ce=y.atom(void 0);function nn({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",U={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},on=I.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${U.root}`]:{display:"flex"},[`& .${U.menuButton}`]:{marginRight:36},[`& .${U.hide}`]:{display:"none"},[`& .${U.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}),rn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,l({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Je=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"}},$e=(e,t)=>l({width:t,transition:ee(e,"width","entering")},Je(e)),Oe=(e,t)=>l({width:t,transition:ee(e,"width","leaving")},Je(e)),an=I.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(l({},$e(e,o)),{backgroundColor:"","& .MuiDrawer-paper":$e(e,o)})),!t&&j(l({},Oe(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,a?o:i)})));function sn(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"],ln=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function cn({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(sn(e.name))%Fe.length]},children:ln(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(rn,{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 dn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:s,bottom:d,user:u,domainCode:c}){const p=Ye(),m=y.useSetAtom(z);return n.jsx(on,{className:U.root,"data-testid":i,children:n.jsxs(an,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{m(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(s)?n.jsx(nn,{links:s}):s}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(cn,{user:u,domainCode:c,open:e}),d&&n.jsx(n.Fragment,{children:d})]})]})})}function un({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 pn="TopBar",hn={titleText:`${pn}-titleText`};function gn({titleText:e="",height:t,"data-testid":o,middle:i}){const a=y.useSetAtom(z),s=()=>a(c=>!c),d=r.useTheme(),u=Ye();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,marginLeft:"12px"},onClick:s,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:hn.titleText,variant:"h6",children:e}),i]})})}function xn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:s,navBarDataTestId:d,navBarMiddle:u,navBarBottom:c,user:p,domainCode:m}){Re.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const v=y.useAtomValue(z),[S]=y.useAtom(xe),[x]=y.useAtom(fe),D=y.useAtomValue(Z),[b]=y.useAtom(me),[T]=y.useAtom(Ke),[k]=y.useAtom(Ce);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(gn,{titleText:D,"data-testid":s,height:b,middle:T}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(dn,{open:v,top:k,middle:u,bottom:c,user:p,domainCode:m,widthOpen:S,widthClosed:x,offsetTop:b,"data-testid":d}),n.jsx(un,j(l({"data-testid":a,topBarHeight:b},i),{children:e}))]})]})}const fn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},mn={shouldClose:(e,t)=>t!=="clickaway"},Pe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Ne=100,_e=2e3,Cn=2e3,vn=(()=>{let e=0;return()=>(e+=1,e)})(),An={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},wn={},Sn={},ve=g.createContext(null);function Ze(s){var d=s,{overrideState:e=wn,overrideActions:t=Sn,shouldClose:o=mn.shouldClose,children:i}=d,a=Be(d,["overrideState","overrideActions","shouldClose","children"]);var O;const[{open:u},c]=g.useState({open:!1}),p=g.useRef([]),m=g.useRef(Date.now()),v=g.useRef(0),S=g.useCallback(C=>{c({open:C})},[]),x=g.useCallback((C={})=>{v.current+=1,p.current.length>=Ne&&Date.now()-m.current>=_e&&(m.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Ne}) hit ${v.current} times in last ${_e}ms)`),v.current=0);const w=l(j(l({},Pe),{key:vn()}),C);return p.current.push(w),p.current.length===1&&c({open:!0}),w.key},[]),D=(C="",w={})=>x(l({message:C,severity:"success"},w)),b=(C="",w={})=>x(l({message:C,severity:"info"},w)),T=(C="",w={})=>x(l({message:C,severity:"warning"},w)),k=(C="",w={})=>x(l({message:C,severity:"error"},w)),A=C=>{const w=p.current.findIndex(N=>N.key===C);if(w!==-1)return w===0?(c({open:!1}),p.current[0]):p.current.splice(w,1)},B=(C,w)=>{o(C,w)&&c({open:!1})},_=()=>{},P=()=>{p.current.shift(),p.current.length>0&&c({open:!0})},E=(O=p.current[0])!=null?O:l({},Pe),L={};"autoHideDuration"in E&&(L.autoHideDuration=E.autoHideDuration);const h=l(l({},fn),a),f=l(l({open:u,setOpen:S,enqueueNotification:x,enqueueSuccessNotification:D,enqueueInfoNotification:b,enqueueWarningNotification:T,enqueueErrorNotification:k,removeNotification:A},e),t);return n.jsxs(ve.Provider,{value:f,children:[i,n.jsx(r.Snackbar,j(l(l({},h),L),{open:u,onClose:B,TransitionProps:{onExited:P,onExit:_},sx:{zIndex:Cn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:C=>B(C,"closeAlert"),severity:E.severity,variant:"filled",icon:E.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:E.progressIndicator==="linear"?An:void 0,children:E.message}),E.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function et(){const e=g.useContext(ve);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const yn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Ze,j(l({},e),{overrideState:t,overrideActions:o,children:i}))),tt=y.getDefaultStore(),bn=({children:e,store:t})=>n.jsx(y.Provider,{store:t!=null?t:tt,children:e}),nt="domainCode";var Me;const Le=y.atom(JSON.parse((Me=localStorage.getItem(nt))!=null?Me:'{"domainCode": ""}').domainCode),Ae=y.atom(e=>e(Le),(e,t,o)=>{t(Le,o),localStorage.setItem(nt,JSON.stringify({domainCode:o}))}),jn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},Dn=e=>{var t;return e===null?"N/A":(t=jn[e])!=null?t:""},Bn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:s})=>{const[d,u]=y.useAtom(Ae),[c,p]=g.useState(d),{enqueueSuccessNotification:m}=et(),v=i.length===0,S=!!d&&!i.includes(d)&&!i.includes(c),x=!d||v||S,D=()=>F(exports,null,function*(){c?(u(c),m(`Set domain to ${c}`),o()):u("")}),b=()=>F(exports,null,function*(){d&&!v&&!S?(p(d),o()):x&&s()});let T;return v?T="Unable to retrieve your active organisations. Try logging in again.":S&&(T="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(he,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:D,disabled:!c||v||S,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:b},onClose:x?()=>{}: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:(k,A)=>p(A!=null?A:""),getOptionLabel:Dn,options:[...i],renderInput:k=>n.jsx(r.TextField,j(l({},k),{variant:"filled",label:"Select organisation",InputProps:j(l({},k.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,k.InputProps.endAdornment]})})}))}),T&&n.jsx(r.FormHelperText,{error:!0,children:T})]})},kn=I.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"}}),Tn=I.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:I.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:I.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:I.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),In={domainCode:Ae,navBarOpen:z,navBarWidthOpen:xe,navBarWidthClosed:fe,titleText:Z,topBarHeight:me,navBarTop:Ce},En=G.createHelper(()=>({children:e})=>n.jsx(y.Provider,{children:e})),ot=({initialValues:e,children:t})=>(Re.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),$n=G.createHelper(e=>({children:t})=>n.jsx(ot,{initialValues:Object.entries(e).map(([o,i])=>[In[o],i]),children:t})),On=G.createHelper(()=>({children:e})=>{const t=new de.QueryClient;return n.jsx(de.QueryClientProvider,{client:t,children:e})});exports.AgDialog=he;exports.AppLayout=xn;exports.AtomProvider=bn;exports.AuthGuard=Wt;exports.Context=ve;exports.ContextError=te;exports.DomainCodeDialog=Bn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Nt;exports.HydrateAtoms=ot;exports.NAVBAR_WIDTH_CLOSED=pe;exports.NAVBAR_WIDTH_OPENED=ue;exports.NavBar=Pt;exports.NavBarDarkStyledList=Ot;exports.NavBarLightStyledList=Ft;exports.NavBarProvider=Ue;exports.PageLayout=Jt;exports.SaladBarProvider=Ze;exports.SessionExpiryDialog=Lt;exports.SingleAutocomplete=_t;exports.atomStore=tt;exports.buildNavBarState=Ve;exports.domainCodeAtom=Ae;exports.fed21Theme=kn;exports.getAuth0Expiry=Qe;exports.internalAgSystemsTheme=Tn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=Ce;exports.navBarWidthClosedAtom=fe;exports.navBarWidthOpenAtom=xe;exports.titleTextAtom=Z;exports.topBarHeightAtom=me;exports.topBarMiddleAtom=Ke;exports.useAutocompleteOptions=ge;exports.useNavBar=Ge;exports.useSaladBar=et;exports.withAtomProvider=En;exports.withNavBarProvider=$t;exports.withOverrideDefaults=$n;exports.withQueryClient=On;exports.withSaladBarProvider=yn;
1
+ "use strict";var ut=Object.defineProperty,pt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,l=(e,t)=>{for(var o in t||(t={}))je.call(t,o)&&se(e,o,t[o]);if(Y)for(var o of Y(t))De.call(t,o)&&se(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(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&&Y)for(var i of Y(e))t.indexOf(i)<0&&De.call(e,i)&&(o[i]=e[i]);return o};var ke=(e,t,o)=>(se(e,typeof t!="symbol"?t+"":t,o),o);var F=(e,t,o)=>new Promise((i,a)=>{var s=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(s,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"),gt=require("@mui/material/CssBaseline"),I=require("@mui/material/styles"),xt=require("@australiangreens/ag-error"),G=require("souvlaki"),ft=require("@mui/material/List"),W=require("@mui/icons-material"),mt=require("autosuggest-highlight/match"),Ct=require("autosuggest-highlight/parse"),de=require("@tanstack/react-query"),He=require("@auth0/auth0-react"),vt=require("buffer"),At=require("@mui/material/Skeleton"),b=require("jotai"),Re=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},wt=V(gt),qe=V(ft),St=V(mt),yt=V(Ct),bt=V(At);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 ue=330,pe=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`},Dt=I.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"}})),We=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>l({width:ue},We()),kt=()=>l({width:pe},We()),Tt=I.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?ue:pe,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":kt()}));class te extends xt.AgError{}ke(te,"errorName","ContextError");const ze=g.createContext(null),It={},Et={},Ue=({overrideState:e=It,overrideActions:t=Et,children:o})=>{const[{open:i},a]=g.useState({open:!0}),s=g.useCallback(c=>{a({open:c})},[]),d=g.useCallback(()=>{a(c=>j(l({},c),{open:!c.open}))},[]),u=l(l({open:i,setOpen:s,toggleOpen:d},e),t);return n.jsx(ze.Provider,{value:u,children:o})},Ge=()=>{const e=g.useContext(ze);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ve=(e={})=>l({open:!0},e),$t=G.createHelper((e=Ve(),t={})=>({children:o})=>n.jsx(Ue,{overrideState:e,overrideActions:t,children:o})),Te=7,Ot=I.styled(qe.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",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}}})),Ie=7,Ft=I.styled(qe.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Ie}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Ie}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 Pt({"data-testid":e,children:t}){const{open:o}=Ge();return n.jsxs(Dt,{className:q.root,"data-testid":e,children:[n.jsx(wt.default,{}),n.jsx(Tt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const he=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:s,onClose:d,sx:u,"data-testid":c,disableCloseOnBackdropOrEscape:p=!1,isLoading:v=!1})=>{var x,D;const[C,S]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(y,B)=>F(exports,null,function*(){p&&(B==="backdropClick"||B==="escapeKeyDown")||C||(s!=null&&s.onClick?yield s.onClick():d())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":c,sx:u,children:[v&&n.jsx(r.LinearProgress,{sx:{height:"4px",marginBottom:"-4px"}}),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:(x=s==null?void 0:s.onClick)!=null?x:d,"data-testid":s==null?void 0:s.testId,disabled:(s==null?void 0:s.disabled)||C,color:s==null?void 0:s.buttonColor,children:(D=s==null?void 0:s.text)!=null?D:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>F(exports,null,function*(){var y;S(!0),yield(y=a.onClick)==null?void 0:y.call(a),S(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},ge=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>de.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(s=>s.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Nt({lookup:e=()=>F(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:s,"data-testid":d,sx:u,boxSx:c,textFieldColor:p,textFieldVariant:v="filled",loadingText:C="Loading...",noOptionsText:S="No options",popupIcon:x=n.jsx(W.ArrowDropDown,{}),error:D=!1,helperText:y="",preLoadedOptions:B=void 0,disablePortal:T=!1}){const[A,k]=g.useState(""),L=(h,f)=>{const O=s.filter(m=>m.id!==f);o(O,"delete",h)},{data:P,isLoading:E}=ge({inputValue:A,label:a,lookup:e,minLength:i,preLoadedOptions:B}),_=A.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:_?E:!1,options:[...s,...P!=null?P:[]],filterSelectedOptions:!0,includeInputInList:!0,value:s,onChange:(h,f,O)=>{o(f,O,h)},onInputChange:(h,f)=>k(f),noOptionsText:_?S:"Start typing to search",loadingText:C,popupIcon:x,renderInput:h=>n.jsx(r.TextField,j(l({},h),{label:a,fullWidth:!0,variant:v,error:D,helperText:y,InputProps:j(l({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[E?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:p})),renderTags:()=>null,isOptionEqualToValue:(h,f)=>h.id===f.id,renderOption:(h,f,O)=>{if(t){const m=St.default(f.label,O.inputValue,{insideWords:!0,findAllOccurrences:!0}),w=yt.default(f.label,m);return g.createElement("li",j(l({},h),{key:f.id,"data-testid":d?`${d}:Autocomplete:option(${f.id.toString()})`:void 0}),n.jsx("div",{children:w.map((N,ne)=>n.jsx("span",{style:{fontWeight:N.highlight?700:400},children:N.text},ne))}))}else return g.createElement("li",j(l({},h),{key:f.id,"data-testid":d?`${d}:option(${f.id.toString()})`:void 0}),f.label)}}),s.length>0&&n.jsx(r.Box,{sx:c,children:s.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=>L(f,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":d?`${d}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const Lt=({lookup:e=()=>F(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:s,textFieldVariant:d="filled","data-testid":u,noOptionsText:c="No options",minLength:p=3,disablePortal:v=!1,preLoadedOptions:C,helperText:S=""})=>{const[x,D]=g.useState(""),{data:y,isLoading:B}=ge({inputValue:x,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:C}),T=x.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?B:!1,options:y!=null?y:[],onChange:(A,k)=>{t(A,k)},disablePortal:v,filterOptions:A=>A,value:i,noOptionsText:T?c:"Start typing to search",getOptionLabel:A=>A.label,renderInput:A=>n.jsx(r.TextField,j(l({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},A),{variant:d,label:o,color:s,helperText:S})),isOptionEqualToValue:(A,k)=>A.id===k.id,onInputChange:(A,k)=>{D(k)},renderOption:(A,k)=>g.createElement("li",j(l({},A),{key:k.id,"data-testid":u?`${u}:Autocomplete:option(${k.id.toString()})`:void 0}),k.label)})})})},Qe=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(vt.Buffer.from(o,"base64").toString("utf8").split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join("")),a=JSON.parse(i);return a!=null&&a.exp?a.exp:-1}catch(t){return-1}},_t=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:a}=He.useAuth0(),[s,d]=g.useState(0),u=()=>F(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),c=()=>F(exports,null,function*(){d(s+1),t()});g.useEffect(()=>{(()=>F(exports,null,function*(){if(s>0){const S=yield a({cacheMode:"off"}),x=Qe(S)*1e3;o(x)}}))()},[s,a,o]);const p={text:"Continue",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},v={text:"Log out",onClick:u,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(he,{isOpen:e,primaryButton:p,secondaryButton:v,onClose:t,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:n.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Mt(e){return"error"in e}function Ht(e){return e.error==="access_denied"}function Rt(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 qt(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 Wt({children:e,appName:t="the app"}){const{isAuthenticated:o,isLoading:i,error:a,loginWithRedirect:s,logout:d}=He.useAuth0();if(g.useEffect(()=>{if(i||o||a)return;const u={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};s(u)},[i,o,a,s]),a&&Mt(a)){let u="Auth error",c="An unknown Auth0 error occurred.";return Rt(a)?(u="Unauthorised",c=`You are not authorised to access ${t}.`):qt(a)?(u="App not authorised",c=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`):Ht(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(bt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const zt=24,Ut=64,R="TopBar",$={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Gt=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:`${zt}px`,backgroundColor:e.palette.primary.main},[`& .${$.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ut}px`,padding:e.spacing(0,3),width:"100%"},[`& .${$.titleSlider}`]:l(l({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 Vt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Gt,{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 Xe=400,Qt=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:s})=>({width:e,"& .MuiDrawer-paper":l(l({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"&&l({marginLeft:`${s}px`},i&&{marginLeft:`${a}px`}))})),Xt=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(l({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 Ee({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:s=Xe,showCloseArrow:d=!0,debugOpacity:u=!1,headerBoxProps:c={},onOpened:p,onClosed:v,"data-testid":C,navBarOpen:S=!1,navBarWidthOpen:x=0,navBarWidthClosed:D=0}){return n.jsxs(Qt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>v==null?void 0:v()},variant:"persistent",anchor:t,open:o,width:s,debugOpacity:u,"data-testid":C,navBarOpen:S,navBarWidthOpen:x,navBarWidthClosed:D,children:[n.jsx(Xt,j(l({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 Yt=I.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return l(l({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`})}),Kt=I.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),le=!1,ce=!1,K={titleText:"",flavour:"push",width:Xe,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 Jt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:s=!1,pageContainerProps:d,pageContentDataTestId:u,topBarDataTestId:c,navBarOpen:p,navBarWidthOpen:v,navBarWidthClosed:C}){const[S,x]=g.useState(le),[D,y]=g.useState(ce),[B,T]=g.useState(le),[A,k]=g.useState(ce),L=o!==void 0,P=i!==void 0,{titleText:E,content:_,flavour:h,open:f,onChangeOpen:O,width:m,arrowButtons:w,startOpen:N,onOpened:ne,onClosed:rt,dataTestId:it}=o?l(l({},K),o):l({},K),{titleText:at,content:st,flavour:we,open:oe,onChangeOpen:Se,width:re,arrowButtons:Q,startOpen:X,onOpened:lt,onClosed:ct,dataTestId:dt}=i?l(l({},K),i):l({},K);g.useEffect(()=>{N!==le&&(x(N),T(N))},[N]),g.useEffect(()=>{X!==ce&&(y(X),k(X))},[X]);const ie=f===void 0?S:f,ae=oe===void 0?D:oe,ye=M=>{f===void 0&&(x(M),a&&P&&(M?(y(!1),k(D)):y(A))),O&&O(M)},be=M=>{oe===void 0&&(y(M),a&&L&&(M?(x(!1),T(S)):x(B))),Se&&Se(M)};return n.jsxs(r.Box,{children:[L&&n.jsx(Ee,{"data-testid":it,anchor:"left",open:ie,onClose:()=>ye(!1),width:m,titleText:E,debugOpacity:s,showCloseArrow:w==="both"||w==="close",onOpened:ne,onClosed:rt,navBarOpen:p,navBarWidthOpen:v,navBarWidthClosed:C,children:_}),P&&n.jsx(Ee,{"data-testid":dt,anchor:"right",open:ae,onClose:()=>be(!1),width:re,titleText:at,debugOpacity:s,showCloseArrow:Q==="both"||Q==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:v,navBarWidthClosed:C,children:st}),n.jsx(Vt,l(l({titleText:t,"data-testid":c},L&&h==="push"?{leftPanel:{open:ie,width:m,onOpen:()=>ye(!0),showOpenArrow:w==="both"||w==="open"}}:{}),P&&we==="push"?{rightPanel:{open:ae,width:re,onOpen:()=>be(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Yt,j(l(l({},h==="push"?{leftPanel:{open:ie,width:m}}:{}),we==="push"?{rightPanel:{open:ae,width:re}}:{}),{children:n.jsx(Kt,j(l({"data-testid":u},d),{children:e}))}))]})}const Ye=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Zt=64,en=72,tn=256,z=b.atom(!0),xe=b.atom(tn),fe=b.atom(en),Z=b.atom(""),Ke=b.atom(void 0),me=b.atom(Zt),Ce=b.atom(void 0);function nn({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",U={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},on=I.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${U.root}`]:{display:"flex"},[`& .${U.menuButton}`]:{marginRight:36},[`& .${U.hide}`]:{display:"none"},[`& .${U.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}),rn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,l({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Je=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"}},$e=(e,t)=>l({width:t,transition:ee(e,"width","entering")},Je(e)),Oe=(e,t)=>l({width:t,transition:ee(e,"width","leaving")},Je(e)),an=I.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(l({},$e(e,o)),{backgroundColor:"","& .MuiDrawer-paper":$e(e,o)})),!t&&j(l({},Oe(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,a?o:i)})));function sn(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"],ln=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function cn({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(sn(e.name))%Fe.length]},children:ln(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(rn,{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 dn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:s,bottom:d,user:u,domainCode:c}){const p=Ye(),v=b.useSetAtom(z);return n.jsx(on,{className:U.root,"data-testid":i,children:n.jsxs(an,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{v(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(s)?n.jsx(nn,{links:s}):s}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(cn,{user:u,domainCode:c,open:e}),d&&n.jsx(n.Fragment,{children:d})]})]})})}function un({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 pn="TopBar",hn={titleText:`${pn}-titleText`};function gn({titleText:e="",height:t,"data-testid":o,middle:i}){const a=b.useSetAtom(z),s=()=>a(c=>!c),d=r.useTheme(),u=Ye();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,marginLeft:"12px"},onClick:s,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:hn.titleText,variant:"h6",children:e}),i]})})}function xn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:s,navBarDataTestId:d,navBarMiddle:u,navBarBottom:c,user:p,domainCode:v}){Re.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const C=b.useAtomValue(z),[S]=b.useAtom(xe),[x]=b.useAtom(fe),D=b.useAtomValue(Z),[y]=b.useAtom(me),[B]=b.useAtom(Ke),[T]=b.useAtom(Ce);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(gn,{titleText:D,"data-testid":s,height:y,middle:B}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(dn,{open:C,top:T,middle:u,bottom:c,user:p,domainCode:v,widthOpen:S,widthClosed:x,offsetTop:y,"data-testid":d}),n.jsx(un,j(l({"data-testid":a,topBarHeight:y},i),{children:e}))]})]})}const fn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},mn={shouldClose:(e,t)=>t!=="clickaway"},Pe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Ne=100,Le=2e3,Cn=2e3,vn=(()=>{let e=0;return()=>(e+=1,e)})(),An={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},wn={},Sn={},ve=g.createContext(null);function Ze(s){var d=s,{overrideState:e=wn,overrideActions:t=Sn,shouldClose:o=mn.shouldClose,children:i}=d,a=Be(d,["overrideState","overrideActions","shouldClose","children"]);var O;const[{open:u},c]=g.useState({open:!1}),p=g.useRef([]),v=g.useRef(Date.now()),C=g.useRef(0),S=g.useCallback(m=>{c({open:m})},[]),x=g.useCallback((m={})=>{C.current+=1,p.current.length>=Ne&&Date.now()-v.current>=Le&&(v.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Ne}) hit ${C.current} times in last ${Le}ms)`),C.current=0);const w=l(j(l({},Pe),{key:vn()}),m);return p.current.push(w),p.current.length===1&&c({open:!0}),w.key},[]),D=(m="",w={})=>x(l({message:m,severity:"success"},w)),y=(m="",w={})=>x(l({message:m,severity:"info"},w)),B=(m="",w={})=>x(l({message:m,severity:"warning"},w)),T=(m="",w={})=>x(l({message:m,severity:"error"},w)),A=m=>{const w=p.current.findIndex(N=>N.key===m);if(w!==-1)return w===0?(c({open:!1}),p.current[0]):p.current.splice(w,1)},k=(m,w)=>{o(m,w)&&c({open:!1})},L=()=>{},P=()=>{p.current.shift(),p.current.length>0&&c({open:!0})},E=(O=p.current[0])!=null?O:l({},Pe),_={};"autoHideDuration"in E&&(_.autoHideDuration=E.autoHideDuration);const h=l(l({},fn),a),f=l(l({open:u,setOpen:S,enqueueNotification:x,enqueueSuccessNotification:D,enqueueInfoNotification:y,enqueueWarningNotification:B,enqueueErrorNotification:T,removeNotification:A},e),t);return n.jsxs(ve.Provider,{value:f,children:[i,n.jsx(r.Snackbar,j(l(l({},h),_),{open:u,onClose:k,TransitionProps:{onExited:P,onExit:L},sx:{zIndex:Cn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:m=>k(m,"closeAlert"),severity:E.severity,variant:"filled",icon:E.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:E.progressIndicator==="linear"?An:void 0,children:E.message}),E.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function et(){const e=g.useContext(ve);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const yn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Ze,j(l({},e),{overrideState:t,overrideActions:o,children:i}))),tt=b.getDefaultStore(),bn=({children:e,store:t})=>n.jsx(b.Provider,{store:t!=null?t:tt,children:e}),nt="domainCode";var Me;const _e=b.atom(JSON.parse((Me=localStorage.getItem(nt))!=null?Me:'{"domainCode": ""}').domainCode),Ae=b.atom(e=>e(_e),(e,t,o)=>{t(_e,o),localStorage.setItem(nt,JSON.stringify({domainCode:o}))}),jn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},Dn=e=>{var t;return e===null?"N/A":(t=jn[e])!=null?t:""},Bn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:s})=>{const[d,u]=b.useAtom(Ae),[c,p]=g.useState(d),{enqueueSuccessNotification:v}=et(),C=i.length===0,S=!!d&&!i.includes(d)&&!i.includes(c),x=!d||C||S,D=()=>F(exports,null,function*(){c?(u(c),v(`Set domain to ${c}`),o()):u("")}),y=()=>F(exports,null,function*(){d&&!C&&!S?(p(d),o()):x&&s()});let B;return C?B="Unable to retrieve your active organisations. Try logging in again.":S&&(B="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(he,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:D,disabled:!c||C||S,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:y},onClose:x?()=>{}: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:(T,A)=>p(A!=null?A:""),getOptionLabel:Dn,options:[...i],renderInput:T=>n.jsx(r.TextField,j(l({},T),{variant:"filled",label:"Select organisation",InputProps:j(l({},T.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,T.InputProps.endAdornment]})})}))}),B&&n.jsx(r.FormHelperText,{error:!0,children:B})]})},kn=I.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"}}),Tn=I.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:I.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:I.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:I.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),In={domainCode:Ae,navBarOpen:z,navBarWidthOpen:xe,navBarWidthClosed:fe,titleText:Z,topBarHeight:me,navBarTop:Ce},En=G.createHelper(()=>({children:e})=>n.jsx(b.Provider,{children:e})),ot=({initialValues:e,children:t})=>(Re.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),$n=G.createHelper(e=>({children:t})=>n.jsx(ot,{initialValues:Object.entries(e).map(([o,i])=>[In[o],i]),children:t})),On=G.createHelper(()=>({children:e})=>{const t=new de.QueryClient;return n.jsx(de.QueryClientProvider,{client:t,children:e})});exports.AgDialog=he;exports.AppLayout=xn;exports.AtomProvider=bn;exports.AuthGuard=Wt;exports.Context=ve;exports.ContextError=te;exports.DomainCodeDialog=Bn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Nt;exports.HydrateAtoms=ot;exports.NAVBAR_WIDTH_CLOSED=pe;exports.NAVBAR_WIDTH_OPENED=ue;exports.NavBar=Pt;exports.NavBarDarkStyledList=Ot;exports.NavBarLightStyledList=Ft;exports.NavBarProvider=Ue;exports.PageLayout=Jt;exports.SaladBarProvider=Ze;exports.SessionExpiryDialog=_t;exports.SingleAutocomplete=Lt;exports.atomStore=tt;exports.buildNavBarState=Ve;exports.domainCodeAtom=Ae;exports.fed21Theme=kn;exports.getAuth0Expiry=Qe;exports.internalAgSystemsTheme=Tn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=Ce;exports.navBarWidthClosedAtom=fe;exports.navBarWidthOpenAtom=xe;exports.titleTextAtom=Z;exports.topBarHeightAtom=me;exports.topBarMiddleAtom=Ke;exports.useAutocompleteOptions=ge;exports.useNavBar=Ge;exports.useSaladBar=et;exports.withAtomProvider=En;exports.withNavBarProvider=$t;exports.withOverrideDefaults=$n;exports.withQueryClient=On;exports.withSaladBarProvider=yn;
2
2
  //# sourceMappingURL=index.cjs.map