@australiangreens/ag-internal-components 0.1.21 → 0.1.23

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 K=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))we.call(t,o)&&ae(e,o,t[o]);if(K)for(var o of K(t))Se.call(t,o)&&ae(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(t));var ye=(e,t)=>{var o={};for(var r in e)we.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&K)for(var r of K(e))t.indexOf(r)<0&&Se.call(e,r)&&(o[r]=e[r]);return o};var be=(e,t,o)=>ae(e,typeof t!="symbol"?t+"":t,o);var O=(e,t,o)=>new Promise((r,s)=>{var l=d=>{try{c(o.next(d))}catch(p){s(p)}},u=d=>{try{c(o.throw(d))}catch(p){s(p)}},c=d=>d.done?r(d.value):Promise.resolve(d.value).then(l,u);c((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("react"),i=require("@mui/material"),gt=require("@mui/material/CssBaseline"),_=require("@mui/material/styles"),ue=require("souvlaki"),xt=require("react-router-dom"),ft=require("@mui/material/List"),W=require("@mui/icons-material"),B=require("jotai"),mt=require("jotai/utils"),Ct=require("react-avatar"),vt=require("autosuggest-highlight/match"),At=require("autosuggest-highlight/parse"),wt=require("@tanstack/react-query"),Le=require("@auth0/auth0-react"),St=require("buffer"),yt=require("@mui/material/Skeleton"),z=e=>e&&e.__esModule?e:{default:e},bt=z(gt),Me=z(ft),je=z(Ct),jt=z(vt),Bt=z(At),Tt=z(yt);function It({text:e}){const[t,o]=f.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(i.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(i.Button,{variant:"outlined",onClick:()=>o(r=>r+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(i.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`},kt=_.styled(i.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"}})),Re=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Dt=()=>a({width:pe},Re()),Et=()=>a({width:he},Re()),_t=_.styled(i.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>a(a({width:t?pe:he,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Dt()}),!t&&{"& .MuiDrawer-paper":Et()}));class te extends Error{}be(te,"errorName","ContextError");const He=f.createContext(null),$t={},Ft={},qe=({overrideState:e=$t,overrideActions:t=Ft,children:o})=>{const[{open:r},s]=f.useState({open:!0}),l=f.useCallback(d=>{s({open:d})},[]),u=f.useCallback(()=>{s(d=>j(a({},d),{open:!d.open}))},[]),c=a(a({open:r,setOpen:l,toggleOpen:u},e),t);return n.jsx(He.Provider,{value:c,children:o})},We=()=>{const e=f.useContext(He);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ue=(e={})=>a({open:!0},e),Ot=ue.createHelper((e=Ue(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),Nt=ue.createHelper(()=>({children:e})=>n.jsx(xt.BrowserRouter,{children:e})),Be=7,Pt=_.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Lt=_.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Mt({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(kt,{className:q.root,"data-testid":e,children:[n.jsx(bt.default,{}),n.jsx(_t,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Rt=24,Ht=64,H="TopBar",$={topStripe:`${H}-topStripe`,titleBar:`${H}-titleBar`,titleSlider:`${H}-titleSlider`,titleText:`${H}-titleText`,leftPanelButton:`${H}-leftPanelButton`,rightPanelButton:`${H}-leftPanelButton`},qt=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:H})(({theme:e,leftPanel:t,rightPanel:o})=>{var r,s;return{width:"100%",[`& .${$.topStripe}`]:{width:"100%",height:`${Rt}px`,backgroundColor:e.palette.primary.main},[`& .${$.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ht}px`,padding:e.spacing(0,3),width:"100%"},[`& .${$.titleSlider}`]:a(a({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:`${(r=t==null?void 0:t.width)!=null?r:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}});function Wt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":r}){return n.jsxs(qt,{leftPanel:t,rightPanel:o,"data-testid":r,children:[n.jsx("div",{className:$.topStripe}),n.jsx("div",{className:$.titleBar,children:n.jsxs(i.Box,{className:$.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(i.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(i.Typography,{className:$.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(i.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 ze=400,Ut=i.styled(i.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:r,navBarWidthOpen:s,navBarWidthClosed:l})=>({width:e,"& .MuiDrawer-paper":a(a({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"&&a({marginLeft:`${l}px`},r&&{marginLeft:`${s}px`}))})),zt=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(a({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 Ie({children:e,anchor:t="left",open:o,onClose:r=()=>{},titleText:s="",width:l=ze,showCloseArrow:u=!0,debugOpacity:c=!1,headerBoxProps:d={},onOpened:p,onClosed:h,"data-testid":v,navBarOpen:w=!1,navBarWidthOpen:g=0,navBarWidthClosed:y=0}){return n.jsxs(Ut,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>h==null?void 0:h()},variant:"persistent",anchor:t,open:o,width:l,debugOpacity:c,"data-testid":v,navBarOpen:w,navBarWidthOpen:g,navBarWidthClosed:y,children:[n.jsx(zt,j(a({anchor:t},d),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),u&&n.jsxs(i.IconButton,{onClick:r,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[u&&n.jsxs(i.IconButton,{onClick:r,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Gt=_.styled(i.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var r,s;return a(a({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:`${(r=t==null?void 0:t.width)!=null?r:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}),Vt=_.styled(i.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),le=!1,ce=!1,J={titleText:"",flavour:"push",width:ze,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Xt({children:e,titleText:t="",leftPanel:o,rightPanel:r,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:l=!1,pageContainerProps:u,pageContentDataTestId:c,topBarDataTestId:d,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v}){const[w,g]=f.useState(le),[y,b]=f.useState(ce),[I,k]=f.useState(le),[E,D]=f.useState(ce),N=o!==void 0,F=r!==void 0,{titleText:A,content:T,flavour:P,open:x,onChangeOpen:m,width:C,arrowButtons:S,startOpen:L,onOpened:X,onClosed:ne,dataTestId:rt}=o?a(a({},J),o):a({},J),{titleText:st,content:at,flavour:me,open:oe,onChangeOpen:Ce,width:ie,arrowButtons:Y,startOpen:Q,onOpened:lt,onClosed:ct,dataTestId:dt}=r?a(a({},J),r):a({},J);f.useEffect(()=>{L!==le&&(g(L),k(L))},[L]),f.useEffect(()=>{Q!==ce&&(b(Q),D(Q))},[Q]);const re=x===void 0?w:x,se=oe===void 0?y:oe,ve=M=>{x===void 0&&(g(M),s&&F&&(M?(b(!1),D(y)):b(E))),m&&m(M)},Ae=M=>{oe===void 0&&(b(M),s&&N&&(M?(g(!1),k(w)):g(I))),Ce&&Ce(M)};return n.jsxs(i.Box,{children:[N&&n.jsx(Ie,{"data-testid":rt,anchor:"left",open:re,onClose:()=>ve(!1),width:C,titleText:A,debugOpacity:l,showCloseArrow:S==="both"||S==="close",onOpened:X,onClosed:ne,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:T}),F&&n.jsx(Ie,{"data-testid":dt,anchor:"right",open:se,onClose:()=>Ae(!1),width:ie,titleText:st,debugOpacity:l,showCloseArrow:Y==="both"||Y==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:at}),n.jsx(Wt,a(a({titleText:t,"data-testid":d},N&&P==="push"?{leftPanel:{open:re,width:C,onOpen:()=>ve(!0),showOpenArrow:S==="both"||S==="open"}}:{}),F&&me==="push"?{rightPanel:{open:se,width:ie,onOpen:()=>Ae(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Gt,j(a(a({},P==="push"?{leftPanel:{open:re,width:C}}:{}),me==="push"?{rightPanel:{open:se,width:ie}}:{}),{children:n.jsx(Vt,j(a({"data-testid":c},u),{children:e}))}))]})}const Ge=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},Yt=64,Qt=72,Kt=256,V=B.atom(!0),Ve=B.atom(Kt),Xe=B.atom(Qt),de=B.atom(""),Ye=B.atom(void 0),Qe=B.atom(Yt),Ke=B.atom(void 0);function Jt({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`},Zt=_.styled(i.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)}})),U=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),en=e=>{const t=i.useTheme();return n.jsx(i.Collapse,a({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"}},ke=(e,t)=>a({width:t,transition:U(e,"width","entering")},Je(e)),De=(e,t)=>a({width:t,transition:U(e,"width","leaving")},Je(e)),tn=_.styled(i.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:r,isSmallScreen:s})=>a(a({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(a({},ke(e,o)),{backgroundColor:"","& .MuiDrawer-paper":ke(e,o)})),!t&&j(a({},De(e,s?o:r)),{backgroundColor:"","& .MuiDrawer-paper":De(e,s?o:r)}))),ee={log:console.warn.bind(console),error:console.error.bind(console),warn:console.warn.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)};function nn(e,t){console[e]=(...o)=>{for(const r of t)if(typeof r=="function"){if(r(...o))return}else if(r instanceof RegExp&&o.length>0){for(const s of o)if(typeof s=="string"&&r.test(s))return}ee[e](o)}}function on(e){if(e)console[e]=ee[e];else for(const t of Object.keys(ee))console[t]=ee[t]}function Ze(e){let t=0;for(let o=0,r=e.length;o<r;o++){const s=e.charCodeAt(o);t=(t<<5)-t+s,t|=0}return t}const Ee=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],_e=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function rn({user:e,domainCode:t,open:o,useNewAvatar:r=!1}){const s=i.useTheme();return n.jsxs(i.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[!r&&n.jsx(i.Box,{sx:{width:o?"5rem":"2rem",transition:o?U(s,["width","height"],"entering"):U(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(n.Fragment,{children:n.jsx(i.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Ee[Math.abs(Ze(e==null?void 0:e.name))%Ee.length]},children:_e(e==null?void 0:e.name)})}):n.jsx(i.Avatar,{sx:{width:"100%",height:"100%"}})}),r&&n.jsx(i.Box,{sx:{width:o?"5rem":"2rem",transition:o?U(s,["width","height"],"entering"):U(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(n.Fragment,{children:n.jsxs(je.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:o?"80":"32",children:[" ",_e(e==null?void 0:e.name)," ","ab"]})}):n.jsx(je.default,{})}),n.jsx(en,{sx:{width:"100%"},in:o,children:n.jsx(i.Fade,{in:o,children:n.jsxs(i.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(i.Typography,{children:e==null?void 0:e.name}):n.jsx(i.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(i.Typography,{children:t.toUpperCase()}):n.jsx(i.Skeleton,{animation:!1,width:"25%"})]})})})]})}function sn({open:e,widthClosed:t,widthOpen:o,"data-testid":r,top:s,middle:l,bottom:u,user:c,domainCode:d,useNewAvatar:p=!1}){const h=Ge(),v=B.useSetAtom(V);return n.jsx(Zt,{className:G.root,"data-testid":r,children:n.jsxs(tn,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:h?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{v(!1)},isSmallScreen:h,children:[!h&&n.jsx(i.Toolbar,{}),s&&n.jsxs(i.Box,{flexGrow:"0",children:[s,n.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),n.jsx(i.Box,{flexGrow:"1",children:Array.isArray(l)?n.jsx(Jt,{links:l}):l}),n.jsxs(i.Box,{flexGrow:"0",children:[n.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(rn,{user:c,domainCode:d,open:e,useNewAvatar:p}),u&&n.jsx(n.Fragment,{children:u})]})]})})}function an({children:e,topBarHeight:t,maxWidth:o=!1,noPadding:r}){return n.jsx(i.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,flexGrow:1},children:r?n.jsx(i.Box,{component:"main",id:"main-content",height:"inherit",children:e}):n.jsx(i.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const ln="TopBar",cn={titleText:`${ln}-titleText`};function dn({titleText:e="",height:t,"data-testid":o,middle:r}){const s=B.useSetAtom(V),l=()=>s(d=>!d),u=i.useTheme(),c=Ge();return n.jsx("header",{"data-testid":o,children:n.jsxs(i.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:c?0:u.zIndex.drawer+101},children:[n.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:l,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(i.Typography,{className:cn.titleText,variant:"h6",component:"h1",children:e}),r]})})}function un({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:r,pageContentDataTestId:s,topBarDataTestId:l,navBarDataTestId:u,navBarMiddle:c,navBarBottom:d,user:p,domainCode:h,useNewAvatar:v=!1}){mt.useHydrateAtoms([[V,o!=null?o:!0],[de,t!=null?t:""]]);const w=B.useAtomValue(V),[g]=B.useAtom(Ve),[y]=B.useAtom(Xe),b=B.useAtomValue(de),[I]=B.useAtom(Qe),[k]=B.useAtom(Ye),[E]=B.useAtom(Ke);return n.jsxs(i.Box,{children:[n.jsx(i.CssBaseline,{}),n.jsx(dn,{titleText:b,"data-testid":l,height:I,middle:k}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(sn,{open:w,top:E,middle:c,bottom:d,user:p,domainCode:h,widthOpen:g,widthClosed:y,offsetTop:I,"data-testid":u,useNewAvatar:v}),n.jsx(an,j(a({"data-testid":s,topBarHeight:I},r),{children:e}))]})]})}const ge=({isOpen:e,dialogTitle:t,children:o,maxWidth:r,primaryButton:s,secondaryButton:l,onClose:u,sx:c,"data-testid":d,disableCloseOnBackdropOrEscape:p=!1,isLoading:h=!1})=>{var g,y;const[v,w]=f.useState(!1);return n.jsxs(i.Dialog,{open:e,onClose:(b,I)=>O(exports,null,function*(){p&&(I==="backdropClick"||I==="escapeKeyDown")||v||(l!=null&&l.onClick?yield l.onClick():u())}),fullWidth:!0,maxWidth:r!=null?r:"xs","data-testid":d,sx:c,children:[h&&n.jsx(i.LinearProgress,{sx:{height:"4px",marginBottom:"-4px"}}),n.jsx(i.DialogTitle,{children:t}),n.jsx(i.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(i.DialogActions,{children:[n.jsx(i.Button,{onClick:(g=l==null?void 0:l.onClick)!=null?g:u,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||v,color:l==null?void 0:l.buttonColor,children:(y=l==null?void 0:l.text)!=null?y:"Cancel"}),s&&n.jsx(i.Button,{onClick:()=>O(exports,null,function*(){var b;w(!0),yield(b=s.onClick)==null?void 0:b.call(s),w(!1)}),"data-testid":s.testId,disabled:s.disabled||v,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},xe=({minLength:e,preLoadedOptions:t,lookup:o,label:r,inputValue:s})=>wt.useQuery({queryFn:()=>e&&s.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(s.toLowerCase())):o(s),queryKey:["autocomplete",r,s]});function pn({lookup:e=()=>O(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:r=0,label:s,value:l,"data-testid":u,sx:c,boxSx:d,textFieldColor:p,textFieldVariant:h="filled",loadingText:v="Loading...",noOptionsText:w="No options",popupIcon:g=n.jsx(W.ArrowDropDown,{}),error:y=!1,helperText:b="",preLoadedOptions:I=void 0,disablePortal:k=!1,disableIconFlip:E=!1}){const[D,N]=f.useState(""),F=(x,m)=>{const C=l.filter(S=>S.id!==m);o(C,"delete",x)},{data:A,isLoading:T}=xe({inputValue:D,label:s,lookup:e,minLength:r,preLoadedOptions:I}),P=D.length>=r;return n.jsxs("div",{"data-testid":u,children:[n.jsx(i.Autocomplete,{sx:a(a({},c),E?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":u?`${u}:Autocomplete`:void 0,disablePortal:k,multiple:!0,getOptionLabel:x=>typeof x=="string"?x:x.label,loading:P?T:!1,options:[...l,...A!=null?A:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(x,m,C)=>{o(m,C,x)},onInputChange:(x,m)=>N(m),noOptionsText:P?w:"Start typing to search",loadingText:v,popupIcon:g,renderInput:x=>n.jsx(i.TextField,j(a({},x),{label:s,fullWidth:!0,variant:h,error:y,helperText:b,InputProps:j(a({},x.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[T?n.jsx(i.CircularProgress,{color:"inherit",size:20}):null,x.InputProps.endAdornment]})}),"data-testid":u?`${u}:Autocomplete:TextField`:void 0,onKeyDown:m=>{(m.key==="Backspace"||m.key==="Delete")&&m.stopPropagation()},color:p})),renderTags:()=>null,isOptionEqualToValue:(x,m)=>x.id===m.id,renderOption:(x,m,C)=>{if(t){const S=jt.default(m.label,C.inputValue,{insideWords:!0,findAllOccurrences:!0}),L=Bt.default(m.label,S);return f.createElement("li",j(a({},x),{key:m.id,"data-testid":u?`${u}:Autocomplete:option(${m.id.toString()})`:void 0}),n.jsx("div",{children:L.map((X,ne)=>n.jsx("span",{style:{fontWeight:X.highlight?700:400},children:X.text},ne))}))}else return f.createElement("li",j(a({},x),{key:m.id,"data-testid":u?`${u}:option(${m.id.toString()})`:void 0}),m.label)}}),l.length>0&&n.jsx(i.Box,{sx:d,children:l.map(x=>n.jsx(i.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(i.Tooltip,{title:x.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(i.Typography,{style:{whiteSpace:"normal"},children:x.chipLabel?x.chipLabel:x.label})}),"data-testid":u?`${u}:Chip(${x.id.toString()})`:void 0,onDelete:m=>F(m,x.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":u?`${u}:Chip(${x.id.toString()}):deleteIcon`:void 0})},x.id))})]})}const hn=/MUI: The value provided to.*is invalid/i,gn=({lookup:e=()=>O(exports,null,function*(){}),onChange:t,label:o,value:r,sx:s,textFieldColor:l,textFieldVariant:u="filled",error:c=!1,"data-testid":d,noOptionsText:p="No options",minLength:h=3,disablePortal:v=!1,preLoadedOptions:w,helperText:g="",disabled:y,popupIcon:b,disableIconFlip:I})=>{const[k,E]=f.useState(""),{data:D,isLoading:N}=xe({inputValue:k,label:o,lookup:e,minLength:h!=null?h:0,preLoadedOptions:w}),F=k.length>=h;return n.jsx("div",{"data-testid":d,children:n.jsx(i.Stack,{direction:"row",spacing:1,children:n.jsx(i.Autocomplete,{sx:a(a({},s),I?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":d?`${d}:Autocomplete`:void 0,loading:F?N:!1,options:D!=null?D:[],onChange:(A,T,P)=>{t(A,T,P)},disablePortal:v,filterOptions:A=>A,value:r,noOptionsText:F?p:"Start typing to search",getOptionLabel:A=>A.label,popupIcon:b,renderInput:A=>n.jsx(i.TextField,j(a({"data-testid":d?`${d}:Autocomplete:TextField`:void 0},A),{variant:u,label:o,color:l,error:c,helperText:g})),isOptionEqualToValue:(A,T)=>A.id===T.id,onInputChange:(A,T)=>{E(T)},renderOption:(A,T)=>f.createElement("li",j(a({},A),{key:T.id,"data-testid":d?`${d}:Autocomplete:option(${T.id.toString()})`:void 0}),T.label),disabled:y})})})},et=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(St.Buffer.from(o,"base64").toString("utf8").split("").map(function(l){return"%"+("00"+l.charCodeAt(0).toString(16)).slice(-2)}).join("")),s=JSON.parse(r);return s!=null&&s.exp?s.exp:-1}catch(t){return-1}},xn=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:r,getAccessTokenSilently:s}=Le.useAuth0(),[l,u]=f.useState(0),c=()=>O(exports,null,function*(){r({logoutParams:{returnTo:`${window.location.origin}`}})}),d=()=>O(exports,null,function*(){u(l+1),t()});f.useEffect(()=>{O(exports,null,function*(){if(l>0){const w=yield s({cacheMode:"off"}),g=et(w)*1e3;o(g)}})},[l,s,o]);const p={text:"Continue",onClick:d,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},h={text:"Log out",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(ge,{isOpen:e,primaryButton:p,secondaryButton:h,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 fn(e){return"error"in e}function mn(e){var r;const t=e.error,o=(r=e==null?void 0:e.error_description)!=null?r:"";return t==="access_denied"&&o.startsWith("You do not have the required authorization")}function Cn(e){var r;const t=e.error,o=(r=e==null?void 0:e.error_description)!=null?r:"";return t==="access_denied"&&o.startsWith("User did not authorize the request")}function vn(e){var r;const t=e.error,o=(r=e==null?void 0:e.error_description)!=null?r:"";return t==="access_denied"&&o.match(/Script.*time.*exceeded/)}function An({children:e,appName:t="the app",throwErrors:o="none",disableConsoleLogging:r=!1,onError:s=()=>{}}){var v,w;const{isAuthenticated:l,isLoading:u,error:c,loginWithRedirect:d,logout:p}=Le.useAuth0();f.useEffect(()=>{c&&s(c)},[c,s]);const h=f.useMemo(()=>({appState:{returnTo:`${window.location.pathname}${window.location.search}`}}),[]);if(f.useEffect(()=>{u||l||c||d(h)},[u,l,c,d,s,h]),c){if(r||console.error(`Error detected in AuthGuard [isAuthenticated=${l},isLoading=${u}]`,c),o==="all")throw c;if(fn(c)){let g="Auth error",y="An unknown Auth0 error occurred.";if(mn(c))g="Unauthorised",y=`You are not authorised to access ${t}.`;else if(Cn(c))g="App not authorised",y=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`;else if(vn(c))g="Auth0 script execution time exceeded",y="The Auth0 login flow exceeded the time limit (20s). Try again in a minute by clicking the RELOAD button below.";else if(c.message==="Invalid state"){const b=localStorage.getItem("auth0_redirect_count");b?b&&parseInt(b)<2&&(localStorage.setItem("auth0_redirect_count",String(parseInt(b)+1)),d(h)):(localStorage.setItem("auth0_redirect_count","1"),d(h))}else if(o==="unknown")throw c;return n.jsxs(i.Dialog,{open:!0,children:[n.jsx(i.DialogTitle,{children:g}),n.jsxs(i.DialogContent,{children:[n.jsx(i.Typography,{children:y}),n.jsx("br",{}),n.jsx(i.Typography,{variant:"subtitle2",children:"Details from Auth0"}),n.jsxs(i.Typography,{variant:"body2",children:["error: ",(v=c==null?void 0:c.error)!=null?v:"N/A"]}),n.jsxs(i.Typography,{variant:"body2",children:["description: ",(w=c==null?void 0:c.error_description)!=null?w:"N/A"]})]}),n.jsxs(i.DialogActions,{children:[g==="Auth0 script execution time exceeded"&&n.jsx(i.Button,{href:window.location.origin+window.location.pathname,children:"Reload"}),n.jsx(i.Button,{onClick:()=>p({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})]})]})}else if(o==="unknown")throw c}return l?(localStorage.removeItem("auth0_redirect_count"),n.jsx(n.Fragment,{children:e})):n.jsx(Tt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const wn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},Sn={shouldClose:(e,t)=>t!=="clickaway"},$e={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Fe=100,Oe=2e3,yn=2e3,bn=(()=>{let e=0;return()=>(e+=1,e)})(),jn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},Bn={},Tn={},fe=f.createContext(null);function tt(l){var u=l,{overrideState:e=Bn,overrideActions:t=Tn,shouldClose:o=Sn.shouldClose,children:r}=u,s=ye(u,["overrideState","overrideActions","shouldClose","children"]);var m;const[{open:c},d]=f.useState({open:!1}),p=f.useRef([]),h=f.useRef(Date.now()),v=f.useRef(0),w=f.useCallback(C=>{d({open:C})},[]),g=f.useCallback((C={})=>{v.current+=1,p.current.length>=Fe&&Date.now()-h.current>=Oe&&(h.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Fe}) hit ${v.current} times in last ${Oe}ms)`),v.current=0);const S=a(j(a({},$e),{key:bn()}),C);return p.current.push(S),p.current.length===1&&d({open:!0}),S.key},[]),y=(C="",S={})=>g(a({message:C,severity:"success"},S)),b=(C="",S={})=>g(a({message:C,severity:"info"},S)),I=(C="",S={})=>g(a({message:C,severity:"warning"},S)),k=(C="",S={})=>g(a({message:C,severity:"error"},S)),E=C=>{const S=p.current.findIndex(L=>L.key===C);if(S!==-1)return S===0?(d({open:!1}),p.current[0]):p.current.splice(S,1)},D=(C,S)=>{o(C,S)&&d({open:!1})},N=()=>{},F=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},A=(m=p.current[0])!=null?m:a({},$e),T={};"autoHideDuration"in A&&(T.autoHideDuration=A.autoHideDuration);const P=a(a({},wn),s),x=a(a({open:c,setOpen:w,enqueueNotification:g,enqueueSuccessNotification:y,enqueueInfoNotification:b,enqueueWarningNotification:I,enqueueErrorNotification:k,removeNotification:E},e),t);return n.jsxs(fe.Provider,{value:x,children:[r,n.jsx(i.Snackbar,j(a(a({},P),T),{open:c,onClose:D,TransitionProps:{onExited:F,onExit:N},sx:{zIndex:yn},children:n.jsxs("div",{children:[n.jsx(i.Alert,{onClose:C=>D(C,"closeAlert"),severity:A.severity,variant:"filled",icon:A.progressIndicator==="circular"?n.jsx(i.CircularProgress,{size:"1em"}):void 0,style:A.progressIndicator==="linear"?jn:void 0,children:A.message}),A.progressIndicator==="linear"&&n.jsx(i.LinearProgress,{color:"primary"})]})}))]})}function nt(){const e=f.useContext(fe);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const In=ue.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(tt,j(a({},e),{overrideState:t,overrideActions:o,children:r}))),ot="domainCode";var Pe;const Ne=B.atom(JSON.parse((Pe=localStorage.getItem(ot))!=null?Pe:'{"domainCode": ""}').domainCode),it=B.atom(e=>e(Ne),(e,t,o)=>{t(Ne,o),localStorage.setItem(ot,JSON.stringify({domainCode:o}))}),kn={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=kn[e])!=null?t:""},En=({isLoading:e,isOpen:t,onClose:o,onDomainChange:r,domainOptions:s,applicationName:l,handleLogout:u})=>{const[c,d]=B.useAtom(it),[p,h]=f.useState(c),{enqueueSuccessNotification:v}=nt(),w=s.length===0,g=!!c&&!s.includes(c)&&!s.includes(p),y=!c||w||g,b=()=>O(exports,null,function*(){p?(d(p),r==null||r(p),v(`Set organisation to ${p}`),o()):(d(""),r==null||r(""))}),I=()=>O(exports,null,function*(){c&&!w&&!g?(h(c),o()):y&&u()});let k;return w?k="Unable to retrieve your active organisations. Try logging in again.":g&&(k="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(ge,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:b,disabled:!p||w||g,buttonColor:"primary"},secondaryButton:{text:y?"Logout":"Cancel",onClick:I},onClose:y?()=>{}:o,children:[n.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",l,"."]}),n.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:p!==""?p:null,onChange:(E,D)=>h(D!=null?D:""),getOptionLabel:Dn,options:[...s],renderInput:E=>n.jsx(i.TextField,j(a({},E),{variant:"filled",label:"Select organisation",InputProps:j(a({},E.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(i.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,E.InputProps.endAdornment]})})}))}),k&&n.jsx(i.FormHelperText,{error:!0,children:k})]})},_n=_.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"}}),$n=_.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:_.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:_.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:_.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{h4:{fontSize:"1.88rem",fontWeight:500},h5:{fontWeight:500},explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}});exports.AgDialog=ge;exports.AppLayout=un;exports.AuthGuard=An;exports.Context=fe;exports.ContextError=te;exports.DomainCodeDialog=En;exports.ExampleComponent=It;exports.FetchAutocomplete=pn;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=hn;exports.NAVBAR_WIDTH_CLOSED=he;exports.NAVBAR_WIDTH_OPENED=pe;exports.NavBar=Mt;exports.NavBarDarkStyledList=Pt;exports.NavBarLightStyledList=Lt;exports.NavBarProvider=qe;exports.PageLayout=Xt;exports.SaladBarProvider=tt;exports.SessionExpiryDialog=xn;exports.SingleAutocomplete=gn;exports.buildNavBarState=Ue;exports.domainCodeAtom=it;exports.fed21Theme=_n;exports.getAuth0Expiry=et;exports.internalAgSystemsTheme=$n;exports.navBarClasses=q;exports.navBarOpenAtom=V;exports.navBarTopAtom=Ke;exports.navBarWidthClosedAtom=Xe;exports.navBarWidthOpenAtom=Ve;exports.simpleHashCode=Ze;exports.suppressConsole=nn;exports.titleTextAtom=de;exports.topBarHeightAtom=Qe;exports.topBarMiddleAtom=Ye;exports.unsuppressConsole=on;exports.useAutocompleteOptions=xe;exports.useNavBar=We;exports.useSaladBar=nt;exports.withBrowserRouter=Nt;exports.withNavBarProvider=Ot;exports.withSaladBarProvider=In;
1
+ "use strict";var ut=Object.defineProperty,pt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var ae=(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={}))we.call(t,o)&&ae(e,o,t[o]);if(Q)for(var o of Q(t))Se.call(t,o)&&ae(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(t));var ye=(e,t)=>{var o={};for(var i in e)we.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&Q)for(var i of Q(e))t.indexOf(i)<0&&Se.call(e,i)&&(o[i]=e[i]);return o};var be=(e,t,o)=>ae(e,typeof t!="symbol"?t+"":t,o);var O=(e,t,o)=>new Promise((i,s)=>{var a=d=>{try{c(o.next(d))}catch(p){s(p)}},u=d=>{try{c(o.throw(d))}catch(p){s(p)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(a,u);c((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("react"),r=require("@mui/material"),gt=require("@mui/material/CssBaseline"),F=require("@mui/material/styles"),ue=require("souvlaki"),xt=require("react-router-dom"),ft=require("@mui/material/List"),U=require("@mui/icons-material"),B=require("jotai"),mt=require("jotai/utils"),Ct=require("react-avatar"),vt=require("autosuggest-highlight/match"),At=require("autosuggest-highlight/parse"),wt=require("@tanstack/react-query"),Le=require("@auth0/auth0-react"),St=require("buffer"),yt=require("@mui/material/Skeleton"),z=e=>e&&e.__esModule?e:{default:e},bt=z(gt),Me=z(ft),je=z(Ct),jt=z(vt),Bt=z(At),Tt=z(yt);function Dt({text:e}){const[t,o]=f.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`},It=F.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"}})),Re=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),kt=()=>l({width:pe},Re()),Et=()=>l({width:he},Re()),Ft=F.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?pe:he,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":kt()}),!t&&{"& .MuiDrawer-paper":Et()}));class te extends Error{}be(te,"errorName","ContextError");const He=f.createContext(null),_t={},$t={},qe=({overrideState:e=_t,overrideActions:t=$t,children:o})=>{const[{open:i},s]=f.useState({open:!0}),a=f.useCallback(d=>{s({open:d})},[]),u=f.useCallback(()=>{s(d=>j(l({},d),{open:!d.open}))},[]),c=l(l({open:i,setOpen:a,toggleOpen:u},e),t);return n.jsx(He.Provider,{value:c,children:o})},Ue=()=>{const e=f.useContext(He);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},We=(e={})=>l({open:!0},e),Ot=ue.createHelper((e=We(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),Nt=ue.createHelper(()=>({children:e})=>n.jsx(xt.BrowserRouter,{children:e})),Be=7,Pt=F.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Lt=F.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Mt({"data-testid":e,children:t}){const{open:o}=Ue();return n.jsxs(It,{className:q.root,"data-testid":e,children:[n.jsx(bt.default,{}),n.jsx(Ft,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Rt=24,Ht=64,H="TopBar",_={topStripe:`${H}-topStripe`,titleBar:`${H}-titleBar`,titleSlider:`${H}-titleSlider`,titleText:`${H}-titleText`,leftPanelButton:`${H}-leftPanelButton`,rightPanelButton:`${H}-leftPanelButton`},qt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:H})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,s;return{width:"100%",[`& .${_.topStripe}`]:{width:"100%",height:`${Rt}px`,backgroundColor:e.palette.primary.main},[`& .${_.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ht}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:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}});function Ut({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(qt,{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(U.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(U.ArrowBack,{})]})]})})]})}const ze=400,Wt=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:s,navBarWidthClosed:a})=>({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:`${a}px`},i&&{marginLeft:`${s}px`}))})),zt=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 De({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:s="",width:a=ze,showCloseArrow:u=!0,debugOpacity:c=!1,headerBoxProps:d={},onOpened:p,onClosed:h,"data-testid":v,navBarOpen:w=!1,navBarWidthOpen:g=0,navBarWidthClosed:y=0}){return n.jsxs(Wt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>h==null?void 0:h()},variant:"persistent",anchor:t,open:o,width:a,debugOpacity:c,"data-testid":v,navBarOpen:w,navBarWidthOpen:g,navBarWidthClosed:y,children:[n.jsx(zt,j(l({anchor:t},d),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),u&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(U.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[u&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(U.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Gt=F.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,s;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:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}),Vt=F.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),le=!1,ce=!1,J={titleText:"",flavour:"push",width:ze,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Xt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:a=!1,pageContainerProps:u,pageContentDataTestId:c,topBarDataTestId:d,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v}){const[w,g]=f.useState(le),[y,b]=f.useState(ce),[D,I]=f.useState(le),[E,k]=f.useState(ce),N=o!==void 0,$=i!==void 0,{titleText:A,content:T,flavour:P,open:x,onChangeOpen:m,width:C,arrowButtons:S,startOpen:L,onOpened:X,onClosed:ne,dataTestId:rt}=o?l(l({},J),o):l({},J),{titleText:st,content:at,flavour:me,open:oe,onChangeOpen:Ce,width:ie,arrowButtons:Y,startOpen:K,onOpened:lt,onClosed:ct,dataTestId:dt}=i?l(l({},J),i):l({},J);f.useEffect(()=>{L!==le&&(g(L),I(L))},[L]),f.useEffect(()=>{K!==ce&&(b(K),k(K))},[K]);const re=x===void 0?w:x,se=oe===void 0?y:oe,ve=M=>{x===void 0&&(g(M),s&&$&&(M?(b(!1),k(y)):b(E))),m&&m(M)},Ae=M=>{oe===void 0&&(b(M),s&&N&&(M?(g(!1),I(w)):g(D))),Ce&&Ce(M)};return n.jsxs(r.Box,{children:[N&&n.jsx(De,{"data-testid":rt,anchor:"left",open:re,onClose:()=>ve(!1),width:C,titleText:A,debugOpacity:a,showCloseArrow:S==="both"||S==="close",onOpened:X,onClosed:ne,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:T}),$&&n.jsx(De,{"data-testid":dt,anchor:"right",open:se,onClose:()=>Ae(!1),width:ie,titleText:st,debugOpacity:a,showCloseArrow:Y==="both"||Y==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:at}),n.jsx(Ut,l(l({titleText:t,"data-testid":d},N&&P==="push"?{leftPanel:{open:re,width:C,onOpen:()=>ve(!0),showOpenArrow:S==="both"||S==="open"}}:{}),$&&me==="push"?{rightPanel:{open:se,width:ie,onOpen:()=>Ae(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Gt,j(l(l({},P==="push"?{leftPanel:{open:re,width:C}}:{}),me==="push"?{rightPanel:{open:se,width:ie}}:{}),{children:n.jsx(Vt,j(l({"data-testid":c},u),{children:e}))}))]})}const Ge=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Yt=64,Kt=72,Qt=256,V=B.atom(!0),Ve=B.atom(Qt),Xe=B.atom(Kt),de=B.atom(""),Ye=B.atom(void 0),Ke=B.atom(Yt),Qe=B.atom(void 0);function Jt({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`},Zt=F.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)}})),W=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),en=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"}},Ie=(e,t)=>l({width:t,transition:W(e,"width","entering")},Je(e)),ke=(e,t)=>l({width:t,transition:W(e,"width","leaving")},Je(e)),tn=F.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:s})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(l({},Ie(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,o)})),!t&&j(l({},ke(e,s?o:i)),{backgroundColor:"","& .MuiDrawer-paper":ke(e,s?o:i)}))),ee={log:console.warn.bind(console),error:console.error.bind(console),warn:console.warn.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)};function nn(e,t){console[e]=(...o)=>{for(const i of t)if(typeof i=="function"){if(i(...o))return}else if(i instanceof RegExp&&o.length>0){for(const s of o)if(typeof s=="string"&&i.test(s))return}ee[e](o)}}function on(e){if(e)console[e]=ee[e];else for(const t of Object.keys(ee))console[t]=ee[t]}function rn(e){return e.replace(/(^|-)([a-z])/g,(t,o,i)=>o==="-"?" "+i.toUpperCase():i.toUpperCase())}function sn(e,t,o,i){var u;if(!e)return"None";const a=Object.entries(e).filter(([c,d])=>c.startsWith("https://greens.org.au/roles/")&&d.includes(t)).map(([c])=>{var d;return rn((d=c.split("/").at(-1))!=null?d:"")});return(u=i.find(c=>o[c].some(d=>a.includes(d))))!=null?u:"None"}function Ze(e){let t=0;for(let o=0,i=e.length;o<i;o++){const s=e.charCodeAt(o);t=(t<<5)-t+s,t|=0}return t}const Ee=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Fe=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function an({user:e,domainCode:t,open:o,useNewAvatar:i=!1}){const s=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[!i&&n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?W(s,["width","height"],"entering"):W(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(n.Fragment,{children:n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Ee[Math.abs(Ze(e==null?void 0:e.name))%Ee.length]},children:Fe(e==null?void 0:e.name)})}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),i&&n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?W(s,["width","height"],"entering"):W(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(n.Fragment,{children:n.jsxs(je.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:o?"80":"32",children:[" ",Fe(e==null?void 0:e.name)," ","ab"]})}):n.jsx(je.default,{})}),n.jsx(en,{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==null?void 0: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 ln({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:s,middle:a,bottom:u,user:c,domainCode:d,useNewAvatar:p=!1}){const h=Ge(),v=B.useSetAtom(V);return n.jsx(Zt,{className:G.root,"data-testid":i,children:n.jsxs(tn,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:h?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{v(!1)},isSmallScreen:h,children:[!h&&n.jsx(r.Toolbar,{}),s&&n.jsxs(r.Box,{flexGrow:"0",children:[s,n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(a)?n.jsx(Jt,{links:a}):a}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(an,{user:c,domainCode:d,open:e,useNewAvatar:p}),u&&n.jsx(n.Fragment,{children:u})]})]})})}function cn({children:e,topBarHeight:t,maxWidth:o=!1,noPadding:i}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,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 dn="TopBar",un={titleText:`${dn}-titleText`};function pn({titleText:e="",height:t,"data-testid":o,middle:i}){const s=B.useSetAtom(V),a=()=>s(d=>!d),u=r.useTheme(),c=Ge();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:c?0:u.zIndex.drawer+101},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:a,children:n.jsx(U.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:un.titleText,variant:"h6",component:"h1",children:e}),i]})})}function hn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:s,topBarDataTestId:a,navBarDataTestId:u,navBarMiddle:c,navBarBottom:d,user:p,domainCode:h,useNewAvatar:v=!1}){mt.useHydrateAtoms([[V,o!=null?o:!0],[de,t!=null?t:""]]);const w=B.useAtomValue(V),[g]=B.useAtom(Ve),[y]=B.useAtom(Xe),b=B.useAtomValue(de),[D]=B.useAtom(Ke),[I]=B.useAtom(Ye),[E]=B.useAtom(Qe);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(pn,{titleText:b,"data-testid":a,height:D,middle:I}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(ln,{open:w,top:E,middle:c,bottom:d,user:p,domainCode:h,widthOpen:g,widthClosed:y,offsetTop:D,"data-testid":u,useNewAvatar:v}),n.jsx(cn,j(l({"data-testid":s,topBarHeight:D},i),{children:e}))]})]})}const ge=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:s,secondaryButton:a,onClose:u,sx:c,"data-testid":d,disableCloseOnBackdropOrEscape:p=!1,isLoading:h=!1})=>{var g,y;const[v,w]=f.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(b,D)=>O(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||v||(a!=null&&a.onClick?yield a.onClick():u())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":d,sx:c,children:[h&&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:(g=a==null?void 0:a.onClick)!=null?g:u,"data-testid":a==null?void 0:a.testId,disabled:(a==null?void 0:a.disabled)||v,color:a==null?void 0:a.buttonColor,children:(y=a==null?void 0:a.text)!=null?y:"Cancel"}),s&&n.jsx(r.Button,{onClick:()=>O(exports,null,function*(){var b;w(!0),yield(b=s.onClick)==null?void 0:b.call(s),w(!1)}),"data-testid":s.testId,disabled:s.disabled||v,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},xe=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:s})=>wt.useQuery({queryFn:()=>e&&s.length<e?t!=null?t:[]:t?t.filter(a=>a.label.toLowerCase().includes(s.toLowerCase())):o(s),queryKey:["autocomplete",i,s]});function gn({lookup:e=()=>O(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:s,value:a,"data-testid":u,sx:c,boxSx:d,textFieldColor:p,textFieldVariant:h="filled",loadingText:v="Loading...",noOptionsText:w="No options",popupIcon:g=n.jsx(U.ArrowDropDown,{}),error:y=!1,helperText:b="",preLoadedOptions:D=void 0,disablePortal:I=!1,disableIconFlip:E=!1}){const[k,N]=f.useState(""),$=(x,m)=>{const C=a.filter(S=>S.id!==m);o(C,"delete",x)},{data:A,isLoading:T}=xe({inputValue:k,label:s,lookup:e,minLength:i,preLoadedOptions:D}),P=k.length>=i;return n.jsxs("div",{"data-testid":u,children:[n.jsx(r.Autocomplete,{sx:l(l({},c),E?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":u?`${u}:Autocomplete`:void 0,disablePortal:I,multiple:!0,getOptionLabel:x=>typeof x=="string"?x:x.label,loading:P?T:!1,options:[...a,...A!=null?A:[]],filterSelectedOptions:!0,includeInputInList:!0,value:a,onChange:(x,m,C)=>{o(m,C,x)},onInputChange:(x,m)=>N(m),noOptionsText:P?w:"Start typing to search",loadingText:v,popupIcon:g,renderInput:x=>n.jsx(r.TextField,j(l({},x),{label:s,fullWidth:!0,variant:h,error:y,helperText:b,InputProps:j(l({},x.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[T?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,x.InputProps.endAdornment]})}),"data-testid":u?`${u}:Autocomplete:TextField`:void 0,onKeyDown:m=>{(m.key==="Backspace"||m.key==="Delete")&&m.stopPropagation()},color:p})),renderTags:()=>null,isOptionEqualToValue:(x,m)=>x.id===m.id,renderOption:(x,m,C)=>{if(t){const S=jt.default(m.label,C.inputValue,{insideWords:!0,findAllOccurrences:!0}),L=Bt.default(m.label,S);return f.createElement("li",j(l({},x),{key:m.id,"data-testid":u?`${u}:Autocomplete:option(${m.id.toString()})`:void 0}),n.jsx("div",{children:L.map((X,ne)=>n.jsx("span",{style:{fontWeight:X.highlight?700:400},children:X.text},ne))}))}else return f.createElement("li",j(l({},x),{key:m.id,"data-testid":u?`${u}:option(${m.id.toString()})`:void 0}),m.label)}}),a.length>0&&n.jsx(r.Box,{sx:d,children:a.map(x=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:x.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:x.chipLabel?x.chipLabel:x.label})}),"data-testid":u?`${u}:Chip(${x.id.toString()})`:void 0,onDelete:m=>$(m,x.id),deleteIcon:n.jsx(U.Cancel,{"data-testid":u?`${u}:Chip(${x.id.toString()}):deleteIcon`:void 0})},x.id))})]})}const xn=/MUI: The value provided to.*is invalid/i,fn=({lookup:e=()=>O(exports,null,function*(){}),onChange:t,label:o,value:i,sx:s,textFieldColor:a,textFieldVariant:u="filled",error:c=!1,"data-testid":d,noOptionsText:p="No options",minLength:h=3,disablePortal:v=!1,preLoadedOptions:w,helperText:g="",disabled:y,popupIcon:b,disableIconFlip:D})=>{const[I,E]=f.useState(""),{data:k,isLoading:N}=xe({inputValue:I,label:o,lookup:e,minLength:h!=null?h:0,preLoadedOptions:w}),$=I.length>=h;return n.jsx("div",{"data-testid":d,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:l(l({},s),D?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":d?`${d}:Autocomplete`:void 0,loading:$?N:!1,options:k!=null?k:[],onChange:(A,T,P)=>{t(A,T,P)},disablePortal:v,filterOptions:A=>A,value:i,noOptionsText:$?p:"Start typing to search",getOptionLabel:A=>A.label,popupIcon:b,renderInput:A=>n.jsx(r.TextField,j(l({"data-testid":d?`${d}:Autocomplete:TextField`:void 0},A),{variant:u,label:o,color:a,error:c,helperText:g})),isOptionEqualToValue:(A,T)=>A.id===T.id,onInputChange:(A,T)=>{E(T)},renderOption:(A,T)=>f.createElement("li",j(l({},A),{key:T.id,"data-testid":d?`${d}:Autocomplete:option(${T.id.toString()})`:void 0}),T.label),disabled:y})})})},et=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(St.Buffer.from(o,"base64").toString("utf8").split("").map(function(a){return"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)}).join("")),s=JSON.parse(i);return s!=null&&s.exp?s.exp:-1}catch(t){return-1}},mn=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:s}=Le.useAuth0(),[a,u]=f.useState(0),c=()=>O(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),d=()=>O(exports,null,function*(){u(a+1),t()});f.useEffect(()=>{O(exports,null,function*(){if(a>0){const w=yield s({cacheMode:"off"}),g=et(w)*1e3;o(g)}})},[a,s,o]);const p={text:"Continue",onClick:d,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},h={text:"Log out",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(ge,{isOpen:e,primaryButton:p,secondaryButton:h,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 Cn(e){return"error"in e}function vn(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 An(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 wn(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.match(/Script.*time.*exceeded/)}function Sn({children:e,appName:t="the app",throwErrors:o="none",disableConsoleLogging:i=!1,onError:s=()=>{}}){var v,w;const{isAuthenticated:a,isLoading:u,error:c,loginWithRedirect:d,logout:p}=Le.useAuth0();f.useEffect(()=>{c&&s(c)},[c,s]);const h=f.useMemo(()=>({appState:{returnTo:`${window.location.pathname}${window.location.search}`}}),[]);if(f.useEffect(()=>{u||a||c||d(h)},[u,a,c,d,s,h]),c){if(i||console.error(`Error detected in AuthGuard [isAuthenticated=${a},isLoading=${u}]`,c),o==="all")throw c;if(Cn(c)){let g="Auth error",y="An unknown Auth0 error occurred.";if(vn(c))g="Unauthorised",y=`You are not authorised to access ${t}.`;else if(An(c))g="App not authorised",y=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`;else if(wn(c))g="Auth0 script execution time exceeded",y="The Auth0 login flow exceeded the time limit (20s). Try again in a minute by clicking the RELOAD button below.";else if(c.message==="Invalid state"){const b=localStorage.getItem("auth0_redirect_count");b?b&&parseInt(b)<2&&(localStorage.setItem("auth0_redirect_count",String(parseInt(b)+1)),d(h)):(localStorage.setItem("auth0_redirect_count","1"),d(h))}else if(o==="unknown")throw c;return n.jsxs(r.Dialog,{open:!0,children:[n.jsx(r.DialogTitle,{children:g}),n.jsxs(r.DialogContent,{children:[n.jsx(r.Typography,{children:y}),n.jsx("br",{}),n.jsx(r.Typography,{variant:"subtitle2",children:"Details from Auth0"}),n.jsxs(r.Typography,{variant:"body2",children:["error: ",(v=c==null?void 0:c.error)!=null?v:"N/A"]}),n.jsxs(r.Typography,{variant:"body2",children:["description: ",(w=c==null?void 0:c.error_description)!=null?w:"N/A"]})]}),n.jsxs(r.DialogActions,{children:[g==="Auth0 script execution time exceeded"&&n.jsx(r.Button,{href:window.location.origin+window.location.pathname,children:"Reload"}),n.jsx(r.Button,{onClick:()=>p({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})]})]})}else if(o==="unknown")throw c}return a?(localStorage.removeItem("auth0_redirect_count"),n.jsx(n.Fragment,{children:e})):n.jsx(Tt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const yn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},bn={shouldClose:(e,t)=>t!=="clickaway"},_e={message:"",severity:"info",variant:"standard",progressIndicator:void 0},$e=100,Oe=2e3,jn=2e3,Bn=(()=>{let e=0;return()=>(e+=1,e)})(),Tn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},Dn={},In={},fe=f.createContext(null);function tt(a){var u=a,{overrideState:e=Dn,overrideActions:t=In,shouldClose:o=bn.shouldClose,children:i}=u,s=ye(u,["overrideState","overrideActions","shouldClose","children"]);var m;const[{open:c},d]=f.useState({open:!1}),p=f.useRef([]),h=f.useRef(Date.now()),v=f.useRef(0),w=f.useCallback(C=>{d({open:C})},[]),g=f.useCallback((C={})=>{v.current+=1,p.current.length>=$e&&Date.now()-h.current>=Oe&&(h.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${$e}) hit ${v.current} times in last ${Oe}ms)`),v.current=0);const S=l(j(l({},_e),{key:Bn()}),C);return p.current.push(S),p.current.length===1&&d({open:!0}),S.key},[]),y=(C="",S={})=>g(l({message:C,severity:"success"},S)),b=(C="",S={})=>g(l({message:C,severity:"info"},S)),D=(C="",S={})=>g(l({message:C,severity:"warning"},S)),I=(C="",S={})=>g(l({message:C,severity:"error"},S)),E=C=>{const S=p.current.findIndex(L=>L.key===C);if(S!==-1)return S===0?(d({open:!1}),p.current[0]):p.current.splice(S,1)},k=(C,S)=>{o(C,S)&&d({open:!1})},N=()=>{},$=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},A=(m=p.current[0])!=null?m:l({},_e),T={};"autoHideDuration"in A&&(T.autoHideDuration=A.autoHideDuration);const P=l(l({},yn),s),x=l(l({open:c,setOpen:w,enqueueNotification:g,enqueueSuccessNotification:y,enqueueInfoNotification:b,enqueueWarningNotification:D,enqueueErrorNotification:I,removeNotification:E},e),t);return n.jsxs(fe.Provider,{value:x,children:[i,n.jsx(r.Snackbar,j(l(l({},P),T),{open:c,onClose:k,TransitionProps:{onExited:$,onExit:N},sx:{zIndex:jn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:C=>k(C,"closeAlert"),severity:A.severity,variant:"filled",icon:A.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:A.progressIndicator==="linear"?Tn:void 0,children:A.message}),A.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function nt(){const e=f.useContext(fe);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const kn=ue.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(tt,j(l({},e),{overrideState:t,overrideActions:o,children:i}))),ot="domainCode";var Pe;const Ne=B.atom(JSON.parse((Pe=localStorage.getItem(ot))!=null?Pe:'{"domainCode": ""}').domainCode),it=B.atom(e=>e(Ne),(e,t,o)=>{t(Ne,o),localStorage.setItem(ot,JSON.stringify({domainCode:o}))}),En={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},Fn=e=>{var t;return e===null?"N/A":(t=En[e])!=null?t:""},_n=({isLoading:e,isOpen:t,onClose:o,onDomainChange:i,domainOptions:s,applicationName:a,handleLogout:u})=>{const[c,d]=B.useAtom(it),[p,h]=f.useState(c),{enqueueSuccessNotification:v}=nt(),w=s.length===0,g=!!c&&!s.includes(c)&&!s.includes(p),y=!c||w||g,b=()=>O(exports,null,function*(){p?(d(p),i==null||i(p),v(`Set organisation to ${p}`),o()):(d(""),i==null||i(""))}),D=()=>O(exports,null,function*(){c&&!w&&!g?(h(c),o()):y&&u()});let I;return w?I="Unable to retrieve your active organisations. Try logging in again.":g&&(I="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(ge,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:b,disabled:!p||w||g,buttonColor:"primary"},secondaryButton:{text:y?"Logout":"Cancel",onClick:D},onClose:y?()=>{}: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:p!==""?p:null,onChange:(E,k)=>h(k!=null?k:""),getOptionLabel:Fn,options:[...s],renderInput:E=>n.jsx(r.TextField,j(l({},E),{variant:"filled",label:"Select organisation",InputProps:j(l({},E.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,E.InputProps.endAdornment]})})}))}),I&&n.jsx(r.FormHelperText,{error:!0,children:I})]})},$n=F.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"}}),On=F.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:F.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:F.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:F.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{h4:{fontSize:"1.88rem",fontWeight:500},h5:{fontWeight:500},explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}});exports.AgDialog=ge;exports.AppLayout=hn;exports.AuthGuard=Sn;exports.Context=fe;exports.ContextError=te;exports.DomainCodeDialog=_n;exports.ExampleComponent=Dt;exports.FetchAutocomplete=gn;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=xn;exports.NAVBAR_WIDTH_CLOSED=he;exports.NAVBAR_WIDTH_OPENED=pe;exports.NavBar=Mt;exports.NavBarDarkStyledList=Pt;exports.NavBarLightStyledList=Lt;exports.NavBarProvider=qe;exports.PageLayout=Xt;exports.SaladBarProvider=tt;exports.SessionExpiryDialog=mn;exports.SingleAutocomplete=fn;exports.buildNavBarState=We;exports.determineUserLevelFromClaims=sn;exports.domainCodeAtom=it;exports.fed21Theme=$n;exports.getAuth0Expiry=et;exports.internalAgSystemsTheme=On;exports.navBarClasses=q;exports.navBarOpenAtom=V;exports.navBarTopAtom=Qe;exports.navBarWidthClosedAtom=Xe;exports.navBarWidthOpenAtom=Ve;exports.simpleHashCode=Ze;exports.suppressConsole=nn;exports.titleTextAtom=de;exports.topBarHeightAtom=Ke;exports.topBarMiddleAtom=Ye;exports.unsuppressConsole=on;exports.useAutocompleteOptions=xe;exports.useNavBar=Ue;exports.useSaladBar=nt;exports.withBrowserRouter=Nt;exports.withNavBarProvider=Ot;exports.withSaladBarProvider=kn;
2
2
  //# sourceMappingURL=index.cjs.map