@australiangreens/ag-internal-components 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/FetchAutocomplete/FetchAutocomplete.d.ts +1 -1
- package/dist/components/FetchAutocomplete/FetchAutocomplete.d.ts.map +1 -1
- package/dist/components/NavBar/NavBarContext.d.ts.map +1 -1
- package/dist/errors/ContextError.d.ts +1 -2
- package/dist/errors/ContextError.d.ts.map +1 -1
- package/dist/esm/index.js +441 -472
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/wrappers.d.ts.map +1 -1
- package/package.json +8 -11
- package/dist/errors/ContextError.unit.test.d.ts +0 -2
- package/dist/errors/ContextError.unit.test.d.ts.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var gt=Object.defineProperty,xt=Object.defineProperties;var ft=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ce=(e,t,o)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))Te.call(t,o)&&ce(e,o,t[o]);if(J)for(var o of J(t))De.call(t,o)&&ce(e,o,t[o]);return e},j=(e,t)=>xt(e,ft(t));var Ie=(e,t)=>{var o={};for(var i in e)Te.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&J)for(var i of J(e))t.indexOf(i)<0&&De.call(e,i)&&(o[i]=e[i]);return o};var ke=(e,t,o)=>ce(e,typeof t!="symbol"?t+"":t,o);var F=(e,t,o)=>new Promise((i,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?i(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"),r=require("@mui/material"),mt=require("@mui/material/CssBaseline"),O=require("@mui/material/styles"),Ct=require("@australiangreens/ag-error"),G=require("souvlaki"),vt=require("react-router-dom"),At=require("@mui/material/List"),W=require("@mui/icons-material"),B=require("jotai"),Ue=require("jotai/utils"),wt=require("react-avatar"),yt=require("autosuggest-highlight/match"),St=require("autosuggest-highlight/parse"),pe=require("@tanstack/react-query"),ze=require("@auth0/auth0-react"),bt=require("buffer"),jt=require("@mui/material/Skeleton"),V=e=>e&&e.__esModule?e:{default:e},Bt=V(mt),Ge=V(At),Ee=V(wt),Tt=V(yt),Dt=V(St),It=V(jt);function kt({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 he=330,ge=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`},Et=O.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"}})),Ve=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Ot=()=>a({width:he},Ve()),_t=()=>a({width:ge},Ve()),$t=O.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>a(a({width:t?he:ge,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Ot()}),!t&&{"& .MuiDrawer-paper":_t()}));class oe extends Ct.AgError{}ke(oe,"errorName","ContextError");const Xe=f.createContext(null),Ft={},Pt={},Qe=({overrideState:e=Ft,overrideActions:t=Pt,children:o})=>{const[{open:i},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:i,setOpen:l,toggleOpen:u},e),t);return n.jsx(Xe.Provider,{value:c,children:o})},Ye=()=>{const e=f.useContext(Xe);if(e===null)throw new oe("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ke=(e={})=>a({open:!0},e),Nt=G.createHelper((e=Ke(),t={})=>({children:o})=>n.jsx(Qe,{overrideState:e,overrideActions:t,children:o})),Lt=G.createHelper(()=>({children:e})=>n.jsx(vt.BrowserRouter,{children:e})),Oe=7,Mt=O.styled(Ge.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Oe}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Oe}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),_e=7,Rt=O.styled(Ge.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${_e}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${_e}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 Ht({"data-testid":e,children:t}){const{open:o}=Ye();return n.jsxs(Et,{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 qt=24,Wt=64,H="TopBar",_={topStripe:`${H}-topStripe`,titleBar:`${H}-titleBar`,titleSlider:`${H}-titleSlider`,titleText:`${H}-titleText`,leftPanelButton:`${H}-leftPanelButton`,rightPanelButton:`${H}-leftPanelButton`},Ut=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:`${qt}px`,backgroundColor:e.palette.primary.main},[`& .${_.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Wt}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:`${(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 zt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Ut,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:_.topStripe}),n.jsx("div",{className:_.titleBar,children:n.jsxs(r.Box,{className:_.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:_.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:_.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:_.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Je=400,Gt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen: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`},i&&{marginLeft:`${s}px`}))})),Vt=r.styled(r.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 $e({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:s="",width:l=Je,showCloseArrow:u=!0,debugOpacity:c=!1,headerBoxProps:d={},onOpened:p,onClosed:h,"data-testid":v,navBarOpen:w=!1,navBarWidthOpen:g=0,navBarWidthClosed:S=0}){return n.jsxs(Gt,{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:S,children:[n.jsx(Vt,j(a({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(W.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(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Xt=O.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,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:`${(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`})}),Qt=O.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),de=!1,ue=!1,Z={titleText:"",flavour:"push",width:Je,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 Yt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:l=!1,pageContainerProps:u,pageContentDataTestId:c,topBarDataTestId:d,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v}){const[w,g]=f.useState(de),[S,b]=f.useState(ue),[D,I]=f.useState(de),[E,k]=f.useState(ue),P=o!==void 0,$=i!==void 0,{titleText:A,content:T,flavour:N,open:x,onChangeOpen:m,width:C,arrowButtons:y,startOpen:L,onOpened:Q,onClosed:ie,dataTestId:lt}=o?a(a({},Z),o):a({},Z),{titleText:ct,content:dt,flavour:Se,open:re,onChangeOpen:be,width:se,arrowButtons:Y,startOpen:K,onOpened:ut,onClosed:pt,dataTestId:ht}=i?a(a({},Z),i):a({},Z);f.useEffect(()=>{L!==de&&(g(L),I(L))},[L]),f.useEffect(()=>{K!==ue&&(b(K),k(K))},[K]);const ae=x===void 0?w:x,le=re===void 0?S:re,je=M=>{x===void 0&&(g(M),s&&$&&(M?(b(!1),k(S)):b(E))),m&&m(M)},Be=M=>{re===void 0&&(b(M),s&&P&&(M?(g(!1),I(w)):g(D))),be&&be(M)};return n.jsxs(r.Box,{children:[P&&n.jsx($e,{"data-testid":lt,anchor:"left",open:ae,onClose:()=>je(!1),width:C,titleText:A,debugOpacity:l,showCloseArrow:y==="both"||y==="close",onOpened:Q,onClosed:ie,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:T}),$&&n.jsx($e,{"data-testid":ht,anchor:"right",open:le,onClose:()=>Be(!1),width:se,titleText:ct,debugOpacity:l,showCloseArrow:Y==="both"||Y==="close",onOpened:ut,onClosed:pt,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:dt}),n.jsx(zt,a(a({titleText:t,"data-testid":d},P&&N==="push"?{leftPanel:{open:ae,width:C,onOpen:()=>je(!0),showOpenArrow:y==="both"||y==="open"}}:{}),$&&Se==="push"?{rightPanel:{open:le,width:se,onOpen:()=>Be(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Xt,j(a(a({},N==="push"?{leftPanel:{open:ae,width:C}}:{}),Se==="push"?{rightPanel:{open:le,width:se}}:{}),{children:n.jsx(Qt,j(a({"data-testid":c},u),{children:e}))}))]})}const Ze=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Kt=64,Jt=72,Zt=256,z=B.atom(!0),xe=B.atom(Zt),fe=B.atom(Jt),ne=B.atom(""),et=B.atom(void 0),me=B.atom(Kt),Ce=B.atom(void 0);function en({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const ee="Navbar",X={root:`${ee}-root`,menuButton:`${ee}-menuButton`,hide:`${ee}-hide`,content:`${ee}-content`},tn=O.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${X.root}`]:{display:"flex"},[`& .${X.menuButton}`]:{marginRight:36},[`& .${X.hide}`]:{display:"none"},[`& .${X.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}),nn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,a({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},tt=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"}},Fe=(e,t)=>a({width:t,transition:U(e,"width","entering")},tt(e)),Pe=(e,t)=>a({width:t,transition:U(e,"width","leaving")},tt(e)),on=O.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:s})=>a(a({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(a({},Fe(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Fe(e,o)})),!t&&j(a({},Pe(e,s?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Pe(e,s?o:i)}))),te={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 rn(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}te[e](o)}}function sn(e){if(e)console[e]=te[e];else for(const t of Object.keys(te))console[t]=te[t]}function nt(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 Ne=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Le=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?U(s,["width","height"],"entering"):U(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:Ne[Math.abs(nt(e==null?void 0:e.name))%Ne.length]},children:Le(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?U(s,["width","height"],"entering"):U(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(n.Fragment,{children:n.jsxs(Ee.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:o?"80":"32",children:[" ",Le(e==null?void 0:e.name)," ","ab"]})}):n.jsx(Ee.default,{})}),n.jsx(nn,{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:l,bottom:u,user:c,domainCode:d,useNewAvatar:p=!1}){const h=Ze(),v=B.useSetAtom(z);return n.jsx(tn,{className:X.root,"data-testid":i,children:n.jsxs(on,{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(l)?n.jsx(en,{links:l}):l}),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(z),l=()=>s(d=>!d),u=r.useTheme(),c=Ze();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:l,children:n.jsx(W.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:l,navBarDataTestId:u,navBarMiddle:c,navBarBottom:d,user:p,domainCode:h,useNewAvatar:v=!1}){Ue.useHydrateAtoms([[z,o!=null?o:!0],[ne,t!=null?t:""]]);const w=B.useAtomValue(z),[g]=B.useAtom(xe),[S]=B.useAtom(fe),b=B.useAtomValue(ne),[D]=B.useAtom(me),[I]=B.useAtom(et),[E]=B.useAtom(Ce);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(pn,{titleText:b,"data-testid":l,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:S,offsetTop:D,"data-testid":u,useNewAvatar:v}),n.jsx(cn,j(a({"data-testid":s,topBarHeight:D},i),{children:e}))]})]})}const ve=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:s,secondaryButton:l,onClose:u,sx:c,"data-testid":d,disableCloseOnBackdropOrEscape:p=!1,isLoading:h=!1})=>{var g,S;const[v,w]=f.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(b,D)=>F(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||v||(l!=null&&l.onClick?yield l.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=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:(S=l==null?void 0:l.text)!=null?S:"Cancel"}),s&&n.jsx(r.Button,{onClick:()=>F(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})]})]})},Ae=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:s})=>pe.useQuery({queryFn:()=>e&&s.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(s.toLowerCase())):o(s),queryKey:["autocomplete",i,s]});function gn({lookup:e=()=>F(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=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:S=!1,helperText:b="",preLoadedOptions:D=void 0,disablePortal:I=!1,disableIconFlip:E=!1}){const[k,P]=f.useState(""),$=(x,m)=>{const C=l.filter(y=>y.id!==m);o(C,"delete",x)},{data:A,isLoading:T}=Ae({inputValue:k,label:s,lookup:e,minLength:i,preLoadedOptions:D}),N=k.length>=i;return n.jsxs("div",{"data-testid":u,children:[n.jsx(r.Autocomplete,{sx:a(a({},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:N?T:!1,options:[...l,...A!=null?A:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(x,m,C)=>{o(m,C,x)},onInputChange:(x,m)=>P(m),noOptionsText:N?w:"Start typing to search",loadingText:v,popupIcon:g,renderInput:x=>n.jsx(r.TextField,j(a({},x),{label:s,fullWidth:!0,variant:h,error:S,helperText:b,InputProps:j(a({},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 y=Tt.default(m.label,C.inputValue,{insideWords:!0,findAllOccurrences:!0}),L=Dt.default(m.label,y);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((Q,ie)=>n.jsx("span",{style:{fontWeight:Q.highlight?700:400},children:Q.text},ie))}))}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(r.Box,{sx:d,children:l.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(W.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=()=>F(exports,null,function*(){}),onChange:t,label:o,value:i,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:S,popupIcon:b,disableIconFlip:D})=>{const[I,E]=f.useState(""),{data:k,isLoading:P}=Ae({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:a(a({},s),D?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":d?`${d}:Autocomplete`:void 0,loading:$?P:!1,options:k!=null?k:[],onChange:(A,T,N)=>{t(A,T,N)},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(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:S})})})},ot=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(bt.Buffer.from(o,"base64").toString("utf8").split("").map(function(l){return"%"+("00"+l.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}=ze.useAuth0(),[l,u]=f.useState(0),c=()=>F(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),d=()=>F(exports,null,function*(){u(l+1),t()});f.useEffect(()=>{F(exports,null,function*(){if(l>0){const w=yield s({cacheMode:"off"}),g=ot(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(ve,{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 yn({children:e,appName:t="the app",throwErrors:o="none",disableConsoleLogging:i=!1,onError:s=()=>{}}){var v,w;const{isAuthenticated:l,isLoading:u,error:c,loginWithRedirect:d,logout:p}=ze.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(i||console.error(`Error detected in AuthGuard [isAuthenticated=${l},isLoading=${u}]`,c),o==="all")throw c;if(Cn(c)){let g="Auth error",S="An unknown Auth0 error occurred.";if(vn(c))g="Unauthorised",S=`You are not authorised to access ${t}.`;else if(An(c))g="App not authorised",S=`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",S="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:S}),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 l?(localStorage.removeItem("auth0_redirect_count"),n.jsx(n.Fragment,{children:e})):n.jsx(It.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const Sn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},bn={shouldClose:(e,t)=>t!=="clickaway"},Me={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Re=100,He=2e3,jn=2e3,Bn=(()=>{let e=0;return()=>(e+=1,e)})(),Tn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},Dn={},In={},we=f.createContext(null);function it(l){var u=l,{overrideState:e=Dn,overrideActions:t=In,shouldClose:o=bn.shouldClose,children:i}=u,s=Ie(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>=Re&&Date.now()-h.current>=He&&(h.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Re}) hit ${v.current} times in last ${He}ms)`),v.current=0);const y=a(j(a({},Me),{key:Bn()}),C);return p.current.push(y),p.current.length===1&&d({open:!0}),y.key},[]),S=(C="",y={})=>g(a({message:C,severity:"success"},y)),b=(C="",y={})=>g(a({message:C,severity:"info"},y)),D=(C="",y={})=>g(a({message:C,severity:"warning"},y)),I=(C="",y={})=>g(a({message:C,severity:"error"},y)),E=C=>{const y=p.current.findIndex(L=>L.key===C);if(y!==-1)return y===0?(d({open:!1}),p.current[0]):p.current.splice(y,1)},k=(C,y)=>{o(C,y)&&d({open:!1})},P=()=>{},$=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},A=(m=p.current[0])!=null?m:a({},Me),T={};"autoHideDuration"in A&&(T.autoHideDuration=A.autoHideDuration);const N=a(a({},Sn),s),x=a(a({open:c,setOpen:w,enqueueNotification:g,enqueueSuccessNotification:S,enqueueInfoNotification:b,enqueueWarningNotification:D,enqueueErrorNotification:I,removeNotification:E},e),t);return n.jsxs(we.Provider,{value:x,children:[i,n.jsx(r.Snackbar,j(a(a({},N),T),{open:c,onClose:k,TransitionProps:{onExited:$,onExit:P},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 rt(){const e=f.useContext(we);if(e===null)throw new oe("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const kn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(it,j(a({},e),{overrideState:t,overrideActions:o,children:i}))),st="domainCode";var We;const qe=B.atom(JSON.parse((We=localStorage.getItem(st))!=null?We:'{"domainCode": ""}').domainCode),ye=B.atom(e=>e(qe),(e,t,o)=>{t(qe,o),localStorage.setItem(st,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","":""},On=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:l,handleLogout:u})=>{const[c,d]=B.useAtom(ye),[p,h]=f.useState(c),{enqueueSuccessNotification:v}=rt(),w=s.length===0,g=!!c&&!s.includes(c)&&!s.includes(p),S=!c||w||g,b=()=>F(exports,null,function*(){p?(d(p),i==null||i(p),v(`Set organisation to ${p}`),o()):(d(""),i==null||i(""))}),D=()=>F(exports,null,function*(){c&&!w&&!g?(h(c),o()):S&&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(ve,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:b,disabled:!p||w||g,buttonColor:"primary"},secondaryButton:{text:S?"Logout":"Cancel",onClick:D},onClose:S?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",l,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:p!==""?p:null,onChange:(E,k)=>h(k!=null?k:""),getOptionLabel:On,options:[...s],renderInput:E=>n.jsx(r.TextField,j(a({},E),{variant:"filled",label:"Select organisation",InputProps:j(a({},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={domainCode:ye,navBarOpen:z,navBarWidthOpen:xe,navBarWidthClosed:fe,titleText:ne,topBarHeight:me,navBarTop:Ce},Fn=G.createHelper(()=>({children:e})=>n.jsx(B.Provider,{children:e})),at=({initialValues:e,children:t})=>(Ue.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),Pn=G.createHelper(e=>({children:t})=>n.jsx(at,{initialValues:Object.entries(e).map(([o,i])=>[$n[o],i]),children:t})),Nn=G.createHelper(()=>({children:e})=>{const t=new pe.QueryClient;return n.jsx(pe.QueryClientProvider,{client:t,children:e})}),Ln=O.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"}}),Mn=O.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:O.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:O.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:O.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=ve;exports.AppLayout=hn;exports.AuthGuard=yn;exports.Context=we;exports.ContextError=oe;exports.DomainCodeDialog=_n;exports.ExampleComponent=kt;exports.FetchAutocomplete=gn;exports.HydrateAtoms=at;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=xn;exports.NAVBAR_WIDTH_CLOSED=ge;exports.NAVBAR_WIDTH_OPENED=he;exports.NavBar=Ht;exports.NavBarDarkStyledList=Mt;exports.NavBarLightStyledList=Rt;exports.NavBarProvider=Qe;exports.PageLayout=Yt;exports.SaladBarProvider=it;exports.SessionExpiryDialog=mn;exports.SingleAutocomplete=fn;exports.buildNavBarState=Ke;exports.domainCodeAtom=ye;exports.fed21Theme=Ln;exports.getAuth0Expiry=ot;exports.internalAgSystemsTheme=Mn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=Ce;exports.navBarWidthClosedAtom=fe;exports.navBarWidthOpenAtom=xe;exports.simpleHashCode=nt;exports.suppressConsole=rn;exports.titleTextAtom=ne;exports.topBarHeightAtom=me;exports.topBarMiddleAtom=et;exports.unsuppressConsole=sn;exports.useAutocompleteOptions=Ae;exports.useNavBar=Ye;exports.useSaladBar=rt;exports.withAtomProvider=Fn;exports.withBrowserRouter=Lt;exports.withNavBarProvider=Nt;exports.withOverrideDefaults=Pn;exports.withQueryClient=Nn;exports.withSaladBarProvider=kn;
|
|
1
|
+
"use strict";var pt=Object.defineProperty,ht=Object.defineProperties;var gt=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))Ae.call(t,o)&&se(e,o,t[o]);if(K)for(var o of K(t))we.call(t,o)&&se(e,o,t[o]);return e},j=(e,t)=>ht(e,gt(t));var Se=(e,t)=>{var o={};for(var r in e)Ae.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&&we.call(e,r)&&(o[r]=e[r]);return o};var ye=(e,t,o)=>se(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"),xt=require("@mui/material/CssBaseline"),_=require("@mui/material/styles"),Pe=require("src/errors"),de=require("souvlaki"),ft=require("react-router-dom"),mt=require("@mui/material/List"),W=require("@mui/icons-material"),B=require("jotai"),Ct=require("jotai/utils"),vt=require("react-avatar"),At=require("autosuggest-highlight/match"),wt=require("autosuggest-highlight/parse"),St=require("@tanstack/react-query"),Le=require("@auth0/auth0-react"),yt=require("buffer"),bt=require("@mui/material/Skeleton"),z=e=>e&&e.__esModule?e:{default:e},jt=z(xt),Me=z(mt),be=z(vt),Bt=z(At),Tt=z(wt),It=z(bt);function kt({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 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=_.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"}),Et=()=>a({width:ue},Re()),_t=()=>a({width:pe},Re()),$t=_.styled(i.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>a(a({width:t?ue:pe,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Et()}),!t&&{"& .MuiDrawer-paper":_t()})),He=f.createContext(null),Ft={},Ot={},qe=({overrideState:e=Ft,overrideActions:t=Ot,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 Pe.ContextError("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ue=(e={})=>a({open:!0},e),Nt=de.createHelper((e=Ue(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),Pt=de.createHelper(()=>({children:e})=>n.jsx(ft.BrowserRouter,{children:e})),je=7,Lt=_.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${je}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${je}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Be=7,Mt=_.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",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}}}));function Rt({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(Dt,{className:q.root,"data-testid":e,children:[n.jsx(jt.default,{}),n.jsx($t,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Ht=24,qt=64,H="TopBar",$={topStripe:`${H}-topStripe`,titleBar:`${H}-titleBar`,titleSlider:`${H}-titleSlider`,titleText:`${H}-titleText`,leftPanelButton:`${H}-leftPanelButton`,rightPanelButton:`${H}-leftPanelButton`},Wt=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:`${Ht}px`,backgroundColor:e.palette.primary.main},[`& .${$.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${qt}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 Ut({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":r}){return n.jsxs(Wt,{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,zt=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`}))})),Gt=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 Te({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(zt,{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(Gt,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 Vt=_.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`})}),Xt=_.styled(i.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),ae=!1,le=!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 Yt({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(ae),[y,b]=f.useState(le),[I,k]=f.useState(ae),[E,D]=f.useState(le),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:te,dataTestId:st}=o?a(a({},J),o):a({},J),{titleText:at,content:lt,flavour:fe,open:ne,onChangeOpen:me,width:oe,arrowButtons:Y,startOpen:Q,onOpened:ct,onClosed:dt,dataTestId:ut}=r?a(a({},J),r):a({},J);f.useEffect(()=>{L!==ae&&(g(L),k(L))},[L]),f.useEffect(()=>{Q!==le&&(b(Q),D(Q))},[Q]);const ie=x===void 0?w:x,re=ne===void 0?y:ne,Ce=M=>{x===void 0&&(g(M),s&&F&&(M?(b(!1),D(y)):b(E))),m&&m(M)},ve=M=>{ne===void 0&&(b(M),s&&N&&(M?(g(!1),k(w)):g(I))),me&&me(M)};return n.jsxs(i.Box,{children:[N&&n.jsx(Te,{"data-testid":st,anchor:"left",open:ie,onClose:()=>Ce(!1),width:C,titleText:A,debugOpacity:l,showCloseArrow:S==="both"||S==="close",onOpened:X,onClosed:te,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:T}),F&&n.jsx(Te,{"data-testid":ut,anchor:"right",open:re,onClose:()=>ve(!1),width:oe,titleText:at,debugOpacity:l,showCloseArrow:Y==="both"||Y==="close",onOpened:ct,onClosed:dt,navBarOpen:p,navBarWidthOpen:h,navBarWidthClosed:v,children:lt}),n.jsx(Ut,a(a({titleText:t,"data-testid":d},N&&P==="push"?{leftPanel:{open:ie,width:C,onOpen:()=>Ce(!0),showOpenArrow:S==="both"||S==="open"}}:{}),F&&fe==="push"?{rightPanel:{open:re,width:oe,onOpen:()=>ve(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Vt,j(a(a({},P==="push"?{leftPanel:{open:ie,width:C}}:{}),fe==="push"?{rightPanel:{open:re,width:oe}}:{}),{children:n.jsx(Xt,j(a({"data-testid":c},u),{children:e}))}))]})}const Ge=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},Qt=64,Kt=72,Jt=256,V=B.atom(!0),Ve=B.atom(Jt),Xe=B.atom(Kt),ce=B.atom(""),Ye=B.atom(void 0),Qe=B.atom(Qt),Ke=B.atom(void 0);function Zt({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`},en=_.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}),tn=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"}},Ie=(e,t)=>a({width:t,transition:U(e,"width","entering")},Je(e)),ke=(e,t)=>a({width:t,transition:U(e,"width","leaving")},Je(e)),nn=_.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({},Ie(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,o)})),!t&&j(a({},ke(e,s?o:r)),{backgroundColor:"","& .MuiDrawer-paper":ke(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 on(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 rn(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 De=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Ee=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function sn({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:De[Math.abs(Ze(e==null?void 0:e.name))%De.length]},children:Ee(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(be.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:o?"80":"32",children:[" ",Ee(e==null?void 0:e.name)," ","ab"]})}):n.jsx(be.default,{})}),n.jsx(tn,{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 an({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(en,{className:G.root,"data-testid":r,children:n.jsxs(nn,{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(Zt,{links:l}):l}),n.jsxs(i.Box,{flexGrow:"0",children:[n.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(sn,{user:c,domainCode:d,open:e,useNewAvatar:p}),u&&n.jsx(n.Fragment,{children:u})]})]})})}function ln({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 cn="TopBar",dn={titleText:`${cn}-titleText`};function un({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:dn.titleText,variant:"h6",component:"h1",children:e}),r]})})}function pn({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}){Ct.useHydrateAtoms([[V,o!=null?o:!0],[ce,t!=null?t:""]]);const w=B.useAtomValue(V),[g]=B.useAtom(Ve),[y]=B.useAtom(Xe),b=B.useAtomValue(ce),[I]=B.useAtom(Qe),[k]=B.useAtom(Ye),[E]=B.useAtom(Ke);return n.jsxs(i.Box,{children:[n.jsx(i.CssBaseline,{}),n.jsx(un,{titleText:b,"data-testid":l,height:I,middle:k}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(an,{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(ln,j(a({"data-testid":s,topBarHeight:I},r),{children:e}))]})]})}const he=({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})]})]})},ge=({minLength:e,preLoadedOptions:t,lookup:o,label:r,inputValue:s})=>St.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 hn({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}=ge({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=Bt.default(m.label,C.inputValue,{insideWords:!0,findAllOccurrences:!0}),L=Tt.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,te)=>n.jsx("span",{style:{fontWeight:X.highlight?700:400},children:X.text},te))}))}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 gn=/MUI: The value provided to.*is invalid/i,xn=({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}=ge({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(yt.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}},fn=({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(he,{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 mn(e){return"error"in e}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("You do not have the required authorization")}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.startsWith("User did not authorize the request")}function An(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 wn({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(mn(c)){let g="Auth error",y="An unknown Auth0 error occurred.";if(Cn(c))g="Unauthorised",y=`You are not authorised to access ${t}.`;else if(vn(c))g="App not authorised",y=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`;else if(An(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(It.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const Sn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},yn={shouldClose:(e,t)=>t!=="clickaway"},_e={message:"",severity:"info",variant:"standard",progressIndicator:void 0},$e=100,Fe=2e3,bn=2e3,jn=(()=>{let e=0;return()=>(e+=1,e)})(),Bn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},Tn={},In={},xe=f.createContext(null);function tt(l){var u=l,{overrideState:e=Tn,overrideActions:t=In,shouldClose:o=yn.shouldClose,children:r}=u,s=Se(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>=Fe&&(h.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${$e}) hit ${v.current} times in last ${Fe}ms)`),v.current=0);const S=a(j(a({},_e),{key:jn()}),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({},Sn),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(xe.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:bn},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"?Bn:void 0,children:A.message}),A.progressIndicator==="linear"&&n.jsx(i.LinearProgress,{color:"primary"})]})}))]})}function nt(){const e=f.useContext(xe);if(e===null)throw new Pe.ContextError("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const kn=de.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(tt,j(a({},e),{overrideState:t,overrideActions:o,children:r}))),ot="domainCode";var Ne;const Oe=B.atom(JSON.parse((Ne=localStorage.getItem(ot))!=null?Ne:'{"domainCode": ""}').domainCode),it=B.atom(e=>e(Oe),(e,t,o)=>{t(Oe,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","":""},En=e=>{var t;return e===null?"N/A":(t=Dn[e])!=null?t:""},_n=({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(he,{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:En,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})]})};class rt extends Error{}ye(rt,"errorName","ContextError");const $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"}}),Fn=_.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=he;exports.AppLayout=pn;exports.AuthGuard=wn;exports.Context=xe;exports.ContextError=rt;exports.DomainCodeDialog=_n;exports.ExampleComponent=kt;exports.FetchAutocomplete=hn;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=gn;exports.NAVBAR_WIDTH_CLOSED=pe;exports.NAVBAR_WIDTH_OPENED=ue;exports.NavBar=Rt;exports.NavBarDarkStyledList=Lt;exports.NavBarLightStyledList=Mt;exports.NavBarProvider=qe;exports.PageLayout=Yt;exports.SaladBarProvider=tt;exports.SessionExpiryDialog=fn;exports.SingleAutocomplete=xn;exports.buildNavBarState=Ue;exports.domainCodeAtom=it;exports.fed21Theme=$n;exports.getAuth0Expiry=et;exports.internalAgSystemsTheme=Fn;exports.navBarClasses=q;exports.navBarOpenAtom=V;exports.navBarTopAtom=Ke;exports.navBarWidthClosedAtom=Xe;exports.navBarWidthOpenAtom=Ve;exports.simpleHashCode=Ze;exports.suppressConsole=on;exports.titleTextAtom=ce;exports.topBarHeightAtom=Qe;exports.topBarMiddleAtom=Ye;exports.unsuppressConsole=rn;exports.useAutocompleteOptions=ge;exports.useNavBar=We;exports.useSaladBar=nt;exports.withBrowserRouter=Pt;exports.withNavBarProvider=Nt;exports.withSaladBarProvider=kn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|