@australiangreens/ag-internal-components 0.0.89 → 0.0.91

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