@australiangreens/ag-internal-components 0.0.54-experiment1 → 0.0.55

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 it=Object.defineProperty,st=Object.defineProperties;var lt=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,i=(e,t)=>{for(var o in t||(t={}))Ae.call(t,o)&&ae(e,o,t[o]);if(V)for(var o of V(t))Be.call(t,o)&&ae(e,o,t[o]);return e},A=(e,t)=>st(e,lt(t));var be=(e,t)=>{var o={};for(var r in e)Ae.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&V)for(var r of V(e))t.indexOf(r)<0&&Be.call(e,r)&&(o[r]=e[r]);return o};var Se=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var X=(e,t,o)=>new Promise((r,s)=>{var d=l=>{try{p(o.next(l))}catch(c){s(c)}},u=l=>{try{p(o.throw(l))}catch(c){s(c)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,u);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),x=require("react"),a=require("@mui/material"),dt=require("@mui/material/CssBaseline"),b=require("@mui/material/styles"),ct=require("@australiangreens/ag-error"),K=require("souvlaki"),ut=require("@mui/material/List"),pt=require("@mui/material/Button"),xt=require("@mui/material/Dialog"),gt=require("@mui/material/DialogActions"),ht=require("@mui/material/DialogContent"),ft=require("@mui/material/DialogTitle"),W=require("@mui/icons-material"),f=require("jotai"),mt=require("jotai/utils"),F=e=>e&&e.__esModule?e:{default:e},vt=F(dt),_e=F(ut),je=F(pt),Ct=F(xt),wt=F(gt),At=F(ht),Bt=F(ft);function bt({text:e}){const[t,o]=x.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(a.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(a.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(a.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(a.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const le=330,de=73,k="Navbar",N={root:`${k}-root`,menuButton:`${k}-menuButton`,hide:`${k}-hide`,content:`${k}-content`,userInfoHolder:`${k}-userInfoHolder`,settings:`${k}-settings`,pieChartIcon:`${k}-pieChartIcon`},St=b.styled(a.Box,{name:"NavBar"})(({theme:e})=>({[`&.${N.root}`]:{display:"flex"},[`& .${N.menuButton}`]:{marginRight:36},[`& .${N.hide}`]:{display:"none"},[`& .${N.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${N.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),Me=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),jt=()=>i({width:le},Me()),Tt=()=>i({width:de},Me()),Dt=b.styled(a.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>i(i({width:t?le:de,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":jt()}),!t&&{"& .MuiDrawer-paper":Tt()}));class Z extends ct.AgError{}Se(Z,"errorName","ContextError");const He=x.createContext(null),It={},Ot={},Re=({overrideState:e=It,overrideActions:t=Ot,children:o})=>{const[{open:r},s]=x.useState({open:!0}),d=x.useCallback(l=>{s({open:l})},[]),u=x.useCallback(()=>{s(l=>A(i({},l),{open:!l.open}))},[]),p=i(i({open:r,setOpen:d,toggleOpen:u},e),t);return n.jsx(He.Provider,{value:p,children:o})},We=()=>{const e=x.useContext(He);if(e===null)throw new Z("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},qe=(e={})=>i({open:!0},e),yt=K.createHelper((e=qe(),t={})=>({children:o})=>n.jsx(Re,{overrideState:e,overrideActions:t,children:o})),Te=7,kt=b.styled(_e.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),De=7,Et=b.styled(_e.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${De}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${De}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 Nt({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(St,{className:N.root,"data-testid":e,children:[n.jsx(vt.default,{}),n.jsx(Dt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const ze=({isOpen:e,dialogTitle:t,children:o,maxWidth:r,primaryButton:s,secondaryButton:d,onClose:u})=>{var c,C;const[p,l]=x.useState(!1);return n.jsxs(Ct.default,{open:e,onClose:()=>{p||u()},fullWidth:!0,maxWidth:r!=null?r:"xs",children:[n.jsx(Bt.default,{children:t}),n.jsx(At.default,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(wt.default,{children:[n.jsx(je.default,{onClick:(c=d==null?void 0:d.onClick)!=null?c:u,"data-testid":d==null?void 0:d.testId,disabled:(d==null?void 0:d.disabled)||p,color:d==null?void 0:d.buttonColor,children:(C=d==null?void 0:d.text)!=null?C:"Cancel"}),s&&n.jsx(je.default,{onClick:()=>X(exports,null,function*(){var m;l(!0),yield(m=s.onClick)==null?void 0:m.call(s),l(!1)}),"data-testid":s.testId,disabled:s.disabled||p,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},Ft=24,Pt=64,E="TopBar",S={topStripe:`${E}-topStripe`,titleBar:`${E}-titleBar`,titleSlider:`${E}-titleSlider`,titleText:`${E}-titleText`,leftPanelButton:`${E}-leftPanelButton`,rightPanelButton:`${E}-leftPanelButton`},$t=a.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:E})(({theme:e,leftPanel:t,rightPanel:o})=>{var r,s;return{width:"100%",[`& .${S.topStripe}`]:{width:"100%",height:`${Ft}px`,backgroundColor:e.palette.primary.main},[`& .${S.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Pt}px`,padding:e.spacing(0,3),width:"100%"},[`& .${S.titleSlider}`]:i(i({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${S.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${S.titleText}`]:{flexGrow:1},[`& .${S.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 Lt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":r}){return n.jsxs($t,{leftPanel:t,rightPanel:o,"data-testid":r,children:[n.jsx("div",{className:S.topStripe}),n.jsx("div",{className:S.titleBar,children:n.jsxs(a.Box,{className:S.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(a.IconButton,{className:S.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(a.Typography,{className:S.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(a.IconButton,{className:S.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Ue=400,_t=a.styled(a.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:d})=>({width:e,"& .MuiDrawer-paper":i(i({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"&&i({marginLeft:`${d}px`},r&&{marginLeft:`${s}px`}))})),Mt=a.styled(a.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>A(i({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:d=Ue,showCloseArrow:u=!0,debugOpacity:p=!1,headerBoxProps:l={},onOpened:c,onClosed:C,"data-testid":m,navBarOpen:w=!1,navBarWidthOpen:v=0,navBarWidthClosed:T=0}){return n.jsxs(_t,{SlideProps:{onEntered:()=>c==null?void 0:c(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:d,debugOpacity:p,"data-testid":m,navBarOpen:w,navBarWidthOpen:v,navBarWidthClosed:T,children:[n.jsx(Mt,A(i({anchor:t},l),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(a.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),u&&n.jsxs(a.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(a.IconButton,{onClick:r,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(a.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Ht=b.styled(a.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var r,s;return i(i({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`})}),Rt=b.styled(a.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),ie=!1,se=!1,Q={titleText:"",flavour:"push",width:Ue,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Wt({children:e,titleText:t="",leftPanel:o,rightPanel:r,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:d=!1,pageContainerProps:u,pageContentDataTestId:p,topBarDataTestId:l,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m}){const[w,v]=x.useState(ie),[T,D]=x.useState(se),[j,B]=x.useState(ie),[I,$]=x.useState(se),L=o!==void 0,_=r!==void 0,{titleText:O,content:q,flavour:z,open:M,onChangeOpen:H,width:g,arrowButtons:h,startOpen:P,onOpened:Ke,onClosed:Ze,dataTestId:et}=o?i(i({},Q),o):i({},Q),{titleText:tt,content:nt,flavour:me,open:te,onChangeOpen:ve,width:ne,arrowButtons:U,startOpen:G,onOpened:ot,onClosed:rt,dataTestId:at}=r?i(i({},Q),r):i({},Q);x.useEffect(()=>{P!==ie&&(v(P),B(P))},[P]),x.useEffect(()=>{G!==se&&(D(G),$(G))},[G]);const oe=M===void 0?w:M,re=te===void 0?T:te,Ce=y=>{M===void 0&&(v(y),s&&_&&(y?(D(!1),$(T)):D(I))),H&&H(y)},we=y=>{te===void 0&&(D(y),s&&L&&(y?(v(!1),B(w)):v(j))),ve&&ve(y)};return n.jsxs(a.Box,{children:[L&&n.jsx(Ie,{"data-testid":et,anchor:"left",open:oe,onClose:()=>Ce(!1),width:g,titleText:O,debugOpacity:d,showCloseArrow:h==="both"||h==="close",onOpened:Ke,onClosed:Ze,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m,children:q}),_&&n.jsx(Ie,{"data-testid":at,anchor:"right",open:re,onClose:()=>we(!1),width:ne,titleText:tt,debugOpacity:d,showCloseArrow:U==="both"||U==="close",onOpened:ot,onClosed:rt,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m,children:nt}),n.jsx(Lt,i(i({titleText:t,"data-testid":l},L&&z==="push"?{leftPanel:{open:oe,width:g,onOpen:()=>Ce(!0),showOpenArrow:h==="both"||h==="open"}}:{}),_&&me==="push"?{rightPanel:{open:re,width:ne,onOpen:()=>we(!0),showOpenArrow:U==="both"||U==="open"}}:{})),n.jsx(Ht,A(i(i({},z==="push"?{leftPanel:{open:oe,width:g}}:{}),me==="push"?{rightPanel:{open:re,width:ne}}:{}),{children:n.jsx(Rt,A(i({"data-testid":p},u),{children:e}))}))]})}const Y="Navbar",R={root:`${Y}-root`,menuButton:`${Y}-menuButton`,hide:`${Y}-hide`,content:`${Y}-content`},qt=b.styled(a.Box,{name:"NavBar"})(({theme:e})=>({[`&.${R.root}`]:{display:"flex"},[`& .${R.menuButton}`]:{marginRight:36},[`& .${R.hide}`]:{display:"none"},[`& .${R.content}`]:{flexGrow:1,padding:e.spacing(3)}})),Ge=(e,t)=>{var o,r;return{height:`calc(100vh - ${t}px)`,top:t,overflowX:"hidden",overflowY:"hidden",color:"inherit",backgroundColor:(r=(o=e==null?void 0:e.navBar)==null?void 0:o.backgroundColor)!=null?r:"white"}},Oe=(e,t,o)=>i({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})},Ge(e,o)),ye=(e,t,o)=>i({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden"},Ge(e,o)),zt=b.styled(a.Drawer,{shouldForwardProp:e=>!["open","widthOpen","widthClosed","offsetTop"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:r,offsetTop:s})=>i(i({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&A(i({},Oe(e,o,s)),{"& .MuiDrawer-paper":Oe(e,o,s)})),!t&&A(i({},ye(e,r,s)),{"& .MuiDrawer-paper":ye(e,r,s)})));function Ut({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}function ke(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 J=["#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 Gt({user:e,domainCode:t,open:o,navBarWidthClosed:r,navBarWidthOpen:s}){return n.jsx(a.Box,{sx:{paddingTop:3},children:n.jsx(a.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:o?n.jsxs(n.Fragment,{children:[n.jsx(a.Box,{sx:{width:`${s*.33}px`,aspectRatio:1,marginBottom:1},children:e!=null&&e.name?n.jsx(a.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:J[Math.abs(ke(e.name))%J.length]},children:Ee(e.name)}):n.jsx(a.Avatar,{sx:{width:"100%",height:"100%"}})}),e!=null&&e.name?n.jsx(a.Typography,{children:e.name}):n.jsx(a.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(a.Typography,{children:t.toUpperCase()}):n.jsx(a.Skeleton,{animation:!1,width:"25%"})]}):n.jsx(a.Box,{sx:{width:`${r*.5}px`,aspectRatio:1,marginBottom:1},children:e!=null&&e.name?n.jsx(a.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:J[Math.abs(ke(e.name))%J.length]},children:Ee(e.name)}):n.jsx(a.Avatar,{sx:{width:"100%",height:"100%"}})})})})}function Vt({open:e,offsetTop:t=0,widthOpen:o,widthClosed:r,"data-testid":s,top:d,middle:u,bottom:p,user:l,domainCode:c}){return n.jsx(qt,{className:R.root,"data-testid":s,children:n.jsxs(zt,{variant:"permanent",anchor:"left",open:e,widthOpen:o,widthClosed:r,offsetTop:t,PaperProps:{component:"nav"},children:[d&&n.jsxs(a.Box,{sx:{flex:"0 0 auto"},children:[d,n.jsx(a.Divider,{variant:"middle"})]}),n.jsx(a.Box,{sx:{flex:"1 0 auto"},children:Array.isArray(u)?n.jsx(Ut,{links:u}):u}),n.jsxs(a.Box,{sx:{flex:"0 0 auto"},children:[n.jsx(a.Divider,{variant:"middle"}),n.jsx(Gt,{user:l,domainCode:c,open:e,navBarWidthClosed:r,navBarWidthOpen:o}),p&&n.jsx(n.Fragment,{children:p})]})]})})}function Xt({children:e,topBarHeight:t}){return n.jsx(a.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(a.Container,{component:"main",id:"main-content",sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const Qt=64,Yt=64,Jt=256,ee=f.atom(!0),ce=f.atom(Jt),ue=f.atom(Yt),pe=f.atom(""),xe=f.atom(Qt),ge=f.atom(void 0),Kt="TopBar",Zt={titleText:`${Kt}-titleText`};function en({titleText:e="",height:t,"data-testid":o}){const r=f.useSetAtom(ee),s=()=>r(d=>!d);return n.jsx("header",{"data-testid":o,children:n.jsxs(a.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},children:[n.jsx(a.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:s,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(a.Typography,{className:Zt.titleText,variant:"h6",children:e})]})})}function tn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:r,pageContentDataTestId:s,topBarDataTestId:d,navBarDataTestId:u,navBarMiddle:p,navBarBottom:l,user:c,domainCode:C}){const[m,w]=f.useAtom(ee),[v]=f.useAtom(ce),[T]=f.useAtom(ue),[D,j]=f.useAtom(pe),[B]=f.useAtom(xe),[I]=f.useAtom(ge);return x.useEffect(()=>{t!==void 0&&j(t)},[t,j]),x.useEffect(()=>{o!==void 0&&w(o)},[o,w]),n.jsxs(a.Box,{children:[n.jsx(a.CssBaseline,{}),n.jsx(en,{titleText:D,"data-testid":d,height:B}),n.jsxs(a.Box,{sx:{display:"flex"},children:[n.jsx(Vt,{open:m,top:I,middle:p,bottom:l,user:c,domainCode:C,widthOpen:v,widthClosed:T,offsetTop:B,"data-testid":u}),n.jsx(Xt,A(i({"data-testid":s,topBarHeight:B},r),{children:e}))]})]})}const nn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},on={shouldClose:(e,t)=>t!=="clickaway"},Ne={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Fe=100,Pe=2e3,rn=2e3,an=(()=>{let e=0;return()=>(e+=1,e)})(),sn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},ln={},dn={},he=x.createContext(null);function Ve(d){var u=d,{overrideState:e=ln,overrideActions:t=dn,shouldClose:o=on.shouldClose,children:r}=u,s=be(u,["overrideState","overrideActions","shouldClose","children"]);var H;const[{open:p},l]=x.useState({open:!1}),c=x.useRef([]),C=x.useRef(Date.now()),m=x.useRef(0),w=x.useCallback(g=>{l({open:g})},[]),v=x.useCallback((g={})=>{m.current+=1,c.current.length>=Fe&&Date.now()-C.current>=Pe&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Fe}) hit ${m.current} times in last ${Pe}ms)`),m.current=0);const h=i(A(i({},Ne),{key:an()}),g);return c.current.push(h),c.current.length===1&&l({open:!0}),h.key},[]),T=(g="",h={})=>v(i({message:g,severity:"success"},h)),D=(g="",h={})=>v(i({message:g,severity:"info"},h)),j=(g="",h={})=>v(i({message:g,severity:"warning"},h)),B=(g="",h={})=>v(i({message:g,severity:"error"},h)),I=g=>{const h=c.current.findIndex(P=>P.key===g);if(h!==-1)return h===0?(l({open:!1}),c.current[0]):c.current.splice(h,1)},$=(g,h)=>{o(g,h)&&l({open:!1})},L=()=>{},_=()=>{c.current.shift(),c.current.length>0&&l({open:!0})},O=(H=c.current[0])!=null?H:i({},Ne),q={};"autoHideDuration"in O&&(q.autoHideDuration=O.autoHideDuration);const z=i(i({},nn),s),M=i(i({open:p,setOpen:w,enqueueNotification:v,enqueueSuccessNotification:T,enqueueInfoNotification:D,enqueueWarningNotification:j,enqueueErrorNotification:B,removeNotification:I},e),t);return n.jsxs(he.Provider,{value:M,children:[r,n.jsx(a.Snackbar,A(i(i({},z),q),{open:p,onClose:$,TransitionProps:{onExited:_,onExit:L},sx:{zIndex:rn},children:n.jsxs("div",{children:[n.jsx(a.Alert,{onClose:g=>$(g,"closeAlert"),severity:O.severity,variant:"filled",icon:O.progressIndicator==="circular"?n.jsx(a.CircularProgress,{size:"1em"}):void 0,style:O.progressIndicator==="linear"?sn:void 0,children:O.message}),O.progressIndicator==="linear"&&n.jsx(a.LinearProgress,{color:"primary"})]})}))]})}function Xe(){const e=x.useContext(he);if(e===null)throw new Z("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const cn=K.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(Ve,A(i({},e),{overrideState:t,overrideActions:o,children:r}))),Qe=f.getDefaultStore(),un=({children:e,store:t})=>n.jsx(f.Provider,{store:t!=null?t:Qe,children:e}),Ye="domainCode";var Le;const $e=f.atom(JSON.parse((Le=localStorage.getItem(Ye))!=null?Le:'{"domainCode": ""}').domainCode),fe=f.atom(e=>e($e),(e,t,o)=>{t($e,o),localStorage.setItem(Ye,JSON.stringify({domainCode:o}))}),pn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},xn=e=>{var t;return e===null?"N/A":(t=pn[e])!=null?t:""},gn=({isLoading:e,isOpen:t,onClose:o,domainOptions:r,applicationName:s,handleLogout:d})=>{const[u,p]=f.useAtom(fe),[l,c]=x.useState(u),{enqueueSuccessNotification:C}=Xe(),m=r.length===0,w=!!u&&!r.includes(u)&&!r.includes(l),v=!u||m||w,T=()=>X(exports,null,function*(){l?(p(l),C(`Set domain to ${l}`),o()):p("")}),D=()=>X(exports,null,function*(){u&&!m&&!w?(c(u),o()):v&&d()});let j;return m?j="Unable to retrieve your active organisations. Try logging in again.":w&&(j="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(ze,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:T,disabled:!l||m||w,buttonColor:"primary"},secondaryButton:{text:v?"Logout":"Cancel",onClick:D},onClose:v?()=>{}:o,children:[n.jsxs(a.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",s,"."]}),n.jsx(a.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:l!==""?l:null,onChange:(B,I)=>c(I!=null?I:""),getOptionLabel:xn,options:[...r],renderInput:B=>n.jsx(a.TextField,A(i({},B),{variant:"filled",label:"Select organisation",InputProps:A(i({},B.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(a.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,B.InputProps.endAdornment]})})}))}),j&&n.jsx(a.FormHelperText,{error:!0,children:j})]})},hn=b.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=b.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:b.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:b.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:b.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),mn={domainCode:fe,navBarOpen:ee,navBarWidthOpen:ce,navBarWidthClosed:ue,titleText:pe,topBarHeight:xe,navBarTop:ge},vn=K.createHelper(()=>({children:e})=>n.jsx(f.Provider,{children:e})),Je=({initialValues:e,children:t})=>(mt.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),Cn=K.createHelper(e=>({children:t})=>n.jsx(Je,{initialValues:Object.entries(e).map(([o,r])=>[mn[o],r]),children:t}));exports.AgDialog=ze;exports.AppLayout=tn;exports.AtomProvider=un;exports.Context=he;exports.ContextError=Z;exports.DomainCodeDialog=gn;exports.ExampleComponent=bt;exports.HydrateAtoms=Je;exports.NAVBAR_WIDTH_CLOSED=de;exports.NAVBAR_WIDTH_OPENED=le;exports.NavBar=Nt;exports.NavBarDarkStyledList=kt;exports.NavBarLightStyledList=Et;exports.NavBarProvider=Re;exports.PageLayout=Wt;exports.SaladBarProvider=Ve;exports.atomStore=Qe;exports.buildNavBarState=qe;exports.domainCodeAtom=fe;exports.fed21Theme=hn;exports.internalAgSystemsTheme=fn;exports.navBarClasses=N;exports.navBarOpenAtom=ee;exports.navBarTopAtom=ge;exports.navBarWidthClosedAtom=ue;exports.navBarWidthOpenAtom=ce;exports.titleTextAtom=pe;exports.topBarHeightAtom=xe;exports.useNavBar=We;exports.useSaladBar=Xe;exports.withAtomProvider=vn;exports.withNavBarProvider=yt;exports.withOverrideDefaults=Cn;exports.withSaladBarProvider=cn;
1
+ "use strict";var it=Object.defineProperty,at=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var ie=(e,t,o)=>t in e?it(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)&&ie(e,o,t[o]);if(V)for(var o of V(t))Se.call(t,o)&&ie(e,o,t[o]);return e},A=(e,t)=>at(e,st(t));var be=(e,t)=>{var o={};for(var r in e)Ae.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&V)for(var r of V(e))t.indexOf(r)<0&&Se.call(e,r)&&(o[r]=e[r]);return o};var Be=(e,t,o)=>(ie(e,typeof t!="symbol"?t+"":t,o),o);var X=(e,t,o)=>new Promise((r,s)=>{var d=l=>{try{p(o.next(l))}catch(c){s(c)}},u=l=>{try{p(o.throw(l))}catch(c){s(c)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,u);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),i=require("@mui/material"),lt=require("@mui/material/CssBaseline"),b=require("@mui/material/styles"),dt=require("@australiangreens/ag-error"),K=require("souvlaki"),ct=require("@mui/material/List"),ut=require("@mui/material/Button"),pt=require("@mui/material/Dialog"),gt=require("@mui/material/DialogActions"),ht=require("@mui/material/DialogContent"),xt=require("@mui/material/DialogTitle"),q=require("@mui/icons-material"),f=require("jotai"),ft=require("jotai/utils"),F=e=>e&&e.__esModule?e:{default:e},mt=F(lt),Le=F(ct),Te=F(ut),vt=F(pt),Ct=F(gt),wt=F(ht),At=F(xt);function St({text:e}){const[t,o]=g.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 le=330,de=73,k="Navbar",N={root:`${k}-root`,menuButton:`${k}-menuButton`,hide:`${k}-hide`,content:`${k}-content`,userInfoHolder:`${k}-userInfoHolder`,settings:`${k}-settings`,pieChartIcon:`${k}-pieChartIcon`},bt=b.styled(i.Box,{name:"NavBar"})(({theme:e})=>({[`&.${N.root}`]:{display:"flex"},[`& .${N.menuButton}`]:{marginRight:36},[`& .${N.hide}`]:{display:"none"},[`& .${N.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${N.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),_e=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>a({width:le},_e()),Tt=()=>a({width:de},_e()),jt=b.styled(i.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>a(a({width:t?le:de,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":Tt()}));class Z extends dt.AgError{}Be(Z,"errorName","ContextError");const Me=g.createContext(null),Dt={},It={},He=({overrideState:e=Dt,overrideActions:t=It,children:o})=>{const[{open:r},s]=g.useState({open:!0}),d=g.useCallback(l=>{s({open:l})},[]),u=g.useCallback(()=>{s(l=>A(a({},l),{open:!l.open}))},[]),p=a(a({open:r,setOpen:d,toggleOpen:u},e),t);return n.jsx(Me.Provider,{value:p,children:o})},Re=()=>{const e=g.useContext(Me);if(e===null)throw new Z("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},qe=(e={})=>a({open:!0},e),Ot=K.createHelper((e=qe(),t={})=>({children:o})=>n.jsx(He,{overrideState:e,overrideActions:t,children:o})),je=7,yt=b.styled(Le.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}}})),De=7,kt=b.styled(Le.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${De}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${De}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 Et({"data-testid":e,children:t}){const{open:o}=Re();return n.jsxs(bt,{className:N.root,"data-testid":e,children:[n.jsx(mt.default,{}),n.jsx(jt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const We=({isOpen:e,dialogTitle:t,children:o,maxWidth:r,primaryButton:s,secondaryButton:d,onClose:u})=>{var c,C;const[p,l]=g.useState(!1);return n.jsxs(vt.default,{open:e,onClose:()=>{p||u()},fullWidth:!0,maxWidth:r!=null?r:"xs",children:[n.jsx(At.default,{children:t}),n.jsx(wt.default,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(Ct.default,{children:[n.jsx(Te.default,{onClick:(c=d==null?void 0:d.onClick)!=null?c:u,"data-testid":d==null?void 0:d.testId,disabled:(d==null?void 0:d.disabled)||p,color:d==null?void 0:d.buttonColor,children:(C=d==null?void 0:d.text)!=null?C:"Cancel"}),s&&n.jsx(Te.default,{onClick:()=>X(exports,null,function*(){var m;l(!0),yield(m=s.onClick)==null?void 0:m.call(s),l(!1)}),"data-testid":s.testId,disabled:s.disabled||p,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},Nt=24,Ft=64,E="TopBar",B={topStripe:`${E}-topStripe`,titleBar:`${E}-titleBar`,titleSlider:`${E}-titleSlider`,titleText:`${E}-titleText`,leftPanelButton:`${E}-leftPanelButton`,rightPanelButton:`${E}-leftPanelButton`},Pt=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:E})(({theme:e,leftPanel:t,rightPanel:o})=>{var r,s;return{width:"100%",[`& .${B.topStripe}`]:{width:"100%",height:`${Nt}px`,backgroundColor:e.palette.primary.main},[`& .${B.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ft}px`,padding:e.spacing(0,3),width:"100%"},[`& .${B.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}),[`& .${B.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${B.titleText}`]:{flexGrow:1},[`& .${B.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 $t({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":r}){return n.jsxs(Pt,{leftPanel:t,rightPanel:o,"data-testid":r,children:[n.jsx("div",{className:B.topStripe}),n.jsx("div",{className:B.titleBar,children:n.jsxs(i.Box,{className:B.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(i.IconButton,{className:B.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(q.ArrowForward,{})]}),n.jsx(i.Typography,{className:B.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(i.IconButton,{className:B.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(q.ArrowBack,{})]})]})})]})}const ze=400,Lt=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:d})=>({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:`${d}px`},r&&{marginLeft:`${s}px`}))})),_t=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>A(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:d=ze,showCloseArrow:u=!0,debugOpacity:p=!1,headerBoxProps:l={},onOpened:c,onClosed:C,"data-testid":m,navBarOpen:w=!1,navBarWidthOpen:v=0,navBarWidthClosed:j=0}){return n.jsxs(Lt,{SlideProps:{onEntered:()=>c==null?void 0:c(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:d,debugOpacity:p,"data-testid":m,navBarOpen:w,navBarWidthOpen:v,navBarWidthClosed:j,children:[n.jsx(_t,A(a({anchor:t},l),{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(q.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(q.ArrowForward,{})," "]}),n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Mt=b.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`})}),Ht=b.styled(i.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),ae=!1,se=!1,Q={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 Rt({children:e,titleText:t="",leftPanel:o,rightPanel:r,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:d=!1,pageContainerProps:u,pageContentDataTestId:p,topBarDataTestId:l,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m}){const[w,v]=g.useState(ae),[j,D]=g.useState(se),[T,S]=g.useState(ae),[I,$]=g.useState(se),L=o!==void 0,_=r!==void 0,{titleText:O,content:W,flavour:z,open:M,onChangeOpen:H,width:h,arrowButtons:x,startOpen:P,onOpened:Je,onClosed:Ke,dataTestId:Ze}=o?a(a({},Q),o):a({},Q),{titleText:et,content:tt,flavour:me,open:te,onChangeOpen:ve,width:ne,arrowButtons:G,startOpen:U,onOpened:nt,onClosed:ot,dataTestId:rt}=r?a(a({},Q),r):a({},Q);g.useEffect(()=>{P!==ae&&(v(P),S(P))},[P]),g.useEffect(()=>{U!==se&&(D(U),$(U))},[U]);const oe=M===void 0?w:M,re=te===void 0?j:te,Ce=y=>{M===void 0&&(v(y),s&&_&&(y?(D(!1),$(j)):D(I))),H&&H(y)},we=y=>{te===void 0&&(D(y),s&&L&&(y?(v(!1),S(w)):v(T))),ve&&ve(y)};return n.jsxs(i.Box,{children:[L&&n.jsx(Ie,{"data-testid":Ze,anchor:"left",open:oe,onClose:()=>Ce(!1),width:h,titleText:O,debugOpacity:d,showCloseArrow:x==="both"||x==="close",onOpened:Je,onClosed:Ke,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m,children:W}),_&&n.jsx(Ie,{"data-testid":rt,anchor:"right",open:re,onClose:()=>we(!1),width:ne,titleText:et,debugOpacity:d,showCloseArrow:G==="both"||G==="close",onOpened:nt,onClosed:ot,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:m,children:tt}),n.jsx($t,a(a({titleText:t,"data-testid":l},L&&z==="push"?{leftPanel:{open:oe,width:h,onOpen:()=>Ce(!0),showOpenArrow:x==="both"||x==="open"}}:{}),_&&me==="push"?{rightPanel:{open:re,width:ne,onOpen:()=>we(!0),showOpenArrow:G==="both"||G==="open"}}:{})),n.jsx(Mt,A(a(a({},z==="push"?{leftPanel:{open:oe,width:h}}:{}),me==="push"?{rightPanel:{open:re,width:ne}}:{}),{children:n.jsx(Ht,A(a({"data-testid":p},u),{children:e}))}))]})}function qt({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const Y="Navbar",R={root:`${Y}-root`,menuButton:`${Y}-menuButton`,hide:`${Y}-hide`,content:`${Y}-content`},Wt=b.styled(i.Box,{name:"NavBar"})(({theme:e})=>({[`&.${R.root}`]:{display:"flex"},[`& .${R.menuButton}`]:{marginRight:36},[`& .${R.hide}`]:{display:"none"},[`& .${R.content}`]:{flexGrow:1,padding:e.spacing(3)}})),J=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),Ge=(e,t)=>{var o,r;return{height:`calc(100vh - ${t}px)`,top:t,overflowX:"hidden",overflowY:"hidden",color:"inherit",backgroundColor:(r=(o=e==null?void 0:e.navBar)==null?void 0:o.backgroundColor)!=null?r:"white"}},Oe=(e,t,o)=>a({width:t,transition:J(e,"width","entering")},Ge(e,o)),ye=(e,t,o)=>a({width:t,transition:J(e,"width","leaving"),overflowX:"hidden"},Ge(e,o)),zt=b.styled(i.Drawer,{shouldForwardProp:e=>!["open","widthOpen","widthClosed","offsetTop"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:r,offsetTop:s})=>a(a({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&A(a({},Oe(e,o,s)),{"& .MuiDrawer-paper":Oe(e,o,s)})),!t&&A(a({},ye(e,r,s)),{"& .MuiDrawer-paper":ye(e,r,s)})));function Gt(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 ke=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Ut=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function Vt({user:e,domainCode:t,open:o}){const r=i.useTheme();return n.jsxs(i.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"8px"},children:[n.jsx(i.Box,{sx:{width:o?"5rem":"2rem",transition:o?J(r,["width","height"],"entering"):J(r,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(i.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:ke[Math.abs(Gt(e.name))%ke.length]},children:Ut(e.name)}):n.jsx(i.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(i.Collapse,{sx:{width:"100%"},easing:r.transitions.easing.sharp,timeout:{enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen-37},in:o,unmountOnExit:!0,children:n.jsxs(i.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(i.Typography,{children: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 Xt({open:e,offsetTop:t=0,widthOpen:o,widthClosed:r,"data-testid":s,top:d,middle:u,bottom:p,user:l,domainCode:c}){return n.jsx(Wt,{className:R.root,"data-testid":s,children:n.jsxs(zt,{variant:"permanent",anchor:"left",open:e,widthOpen:o,widthClosed:r,offsetTop:t,PaperProps:{component:"nav"},children:[d&&n.jsxs(i.Box,{flexGrow:"0",children:[d,n.jsx(i.Divider,{variant:"middle"})]}),n.jsx(i.Box,{flexGrow:"1",children:Array.isArray(u)?n.jsx(qt,{links:u}):u}),n.jsxs(i.Box,{flexGrow:"0",children:[n.jsx(i.Divider,{variant:"middle"}),n.jsx(Vt,{user:l,domainCode:c,open:e}),p&&n.jsx(n.Fragment,{children:p})]})]})})}function Qt({children:e,topBarHeight:t}){return n.jsx(i.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(i.Container,{component:"main",id:"main-content",sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const Yt=64,Jt=64,Kt=256,ee=f.atom(!0),ce=f.atom(Kt),ue=f.atom(Jt),pe=f.atom(""),ge=f.atom(Yt),he=f.atom(void 0),Zt="TopBar",en={titleText:`${Zt}-titleText`};function tn({titleText:e="",height:t,"data-testid":o}){const r=f.useSetAtom(ee),s=()=>r(d=>!d);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},children:[n.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:s,children:n.jsx(q.ViewHeadline,{fontSize:"medium"})}),n.jsx(i.Typography,{className:en.titleText,variant:"h6",children:e})]})})}function nn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:r,pageContentDataTestId:s,topBarDataTestId:d,navBarDataTestId:u,navBarMiddle:p,navBarBottom:l,user:c,domainCode:C}){const[m,w]=f.useAtom(ee),[v]=f.useAtom(ce),[j]=f.useAtom(ue),[D,T]=f.useAtom(pe),[S]=f.useAtom(ge),[I]=f.useAtom(he);return g.useEffect(()=>{t!==void 0&&T(t)},[t,T]),g.useEffect(()=>{o!==void 0&&w(o)},[o,w]),n.jsxs(i.Box,{children:[n.jsx(i.CssBaseline,{}),n.jsx(tn,{titleText:D,"data-testid":d,height:S}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(Xt,{open:m,top:I,middle:p,bottom:l,user:c,domainCode:C,widthOpen:v,widthClosed:j,offsetTop:S,"data-testid":u}),n.jsx(Qt,A(a({"data-testid":s,topBarHeight:S},r),{children:e}))]})]})}const on={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},rn={shouldClose:(e,t)=>t!=="clickaway"},Ee={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Ne=100,Fe=2e3,an=2e3,sn=(()=>{let e=0;return()=>(e+=1,e)})(),ln={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},dn={},cn={},xe=g.createContext(null);function Ue(d){var u=d,{overrideState:e=dn,overrideActions:t=cn,shouldClose:o=rn.shouldClose,children:r}=u,s=be(u,["overrideState","overrideActions","shouldClose","children"]);var H;const[{open:p},l]=g.useState({open:!1}),c=g.useRef([]),C=g.useRef(Date.now()),m=g.useRef(0),w=g.useCallback(h=>{l({open:h})},[]),v=g.useCallback((h={})=>{m.current+=1,c.current.length>=Ne&&Date.now()-C.current>=Fe&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Ne}) hit ${m.current} times in last ${Fe}ms)`),m.current=0);const x=a(A(a({},Ee),{key:sn()}),h);return c.current.push(x),c.current.length===1&&l({open:!0}),x.key},[]),j=(h="",x={})=>v(a({message:h,severity:"success"},x)),D=(h="",x={})=>v(a({message:h,severity:"info"},x)),T=(h="",x={})=>v(a({message:h,severity:"warning"},x)),S=(h="",x={})=>v(a({message:h,severity:"error"},x)),I=h=>{const x=c.current.findIndex(P=>P.key===h);if(x!==-1)return x===0?(l({open:!1}),c.current[0]):c.current.splice(x,1)},$=(h,x)=>{o(h,x)&&l({open:!1})},L=()=>{},_=()=>{c.current.shift(),c.current.length>0&&l({open:!0})},O=(H=c.current[0])!=null?H:a({},Ee),W={};"autoHideDuration"in O&&(W.autoHideDuration=O.autoHideDuration);const z=a(a({},on),s),M=a(a({open:p,setOpen:w,enqueueNotification:v,enqueueSuccessNotification:j,enqueueInfoNotification:D,enqueueWarningNotification:T,enqueueErrorNotification:S,removeNotification:I},e),t);return n.jsxs(xe.Provider,{value:M,children:[r,n.jsx(i.Snackbar,A(a(a({},z),W),{open:p,onClose:$,TransitionProps:{onExited:_,onExit:L},sx:{zIndex:an},children:n.jsxs("div",{children:[n.jsx(i.Alert,{onClose:h=>$(h,"closeAlert"),severity:O.severity,variant:"filled",icon:O.progressIndicator==="circular"?n.jsx(i.CircularProgress,{size:"1em"}):void 0,style:O.progressIndicator==="linear"?ln:void 0,children:O.message}),O.progressIndicator==="linear"&&n.jsx(i.LinearProgress,{color:"primary"})]})}))]})}function Ve(){const e=g.useContext(xe);if(e===null)throw new Z("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const un=K.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(Ue,A(a({},e),{overrideState:t,overrideActions:o,children:r}))),Xe=f.getDefaultStore(),pn=({children:e,store:t})=>n.jsx(f.Provider,{store:t!=null?t:Xe,children:e}),Qe="domainCode";var $e;const Pe=f.atom(JSON.parse(($e=localStorage.getItem(Qe))!=null?$e:'{"domainCode": ""}').domainCode),fe=f.atom(e=>e(Pe),(e,t,o)=>{t(Pe,o),localStorage.setItem(Qe,JSON.stringify({domainCode:o}))}),gn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},hn=e=>{var t;return e===null?"N/A":(t=gn[e])!=null?t:""},xn=({isLoading:e,isOpen:t,onClose:o,domainOptions:r,applicationName:s,handleLogout:d})=>{const[u,p]=f.useAtom(fe),[l,c]=g.useState(u),{enqueueSuccessNotification:C}=Ve(),m=r.length===0,w=!!u&&!r.includes(u)&&!r.includes(l),v=!u||m||w,j=()=>X(exports,null,function*(){l?(p(l),C(`Set domain to ${l}`),o()):p("")}),D=()=>X(exports,null,function*(){u&&!m&&!w?(c(u),o()):v&&d()});let T;return m?T="Unable to retrieve your active organisations. Try logging in again.":w&&(T="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(We,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:j,disabled:!l||m||w,buttonColor:"primary"},secondaryButton:{text:v?"Logout":"Cancel",onClick:D},onClose:v?()=>{}:o,children:[n.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",s,"."]}),n.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:l!==""?l:null,onChange:(S,I)=>c(I!=null?I:""),getOptionLabel:hn,options:[...r],renderInput:S=>n.jsx(i.TextField,A(a({},S),{variant:"filled",label:"Select organisation",InputProps:A(a({},S.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(i.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,S.InputProps.endAdornment]})})}))}),T&&n.jsx(i.FormHelperText,{error:!0,children:T})]})},fn=b.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=b.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:b.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:b.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:b.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),vn={domainCode:fe,navBarOpen:ee,navBarWidthOpen:ce,navBarWidthClosed:ue,titleText:pe,topBarHeight:ge,navBarTop:he},Cn=K.createHelper(()=>({children:e})=>n.jsx(f.Provider,{children:e})),Ye=({initialValues:e,children:t})=>(ft.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),wn=K.createHelper(e=>({children:t})=>n.jsx(Ye,{initialValues:Object.entries(e).map(([o,r])=>[vn[o],r]),children:t}));exports.AgDialog=We;exports.AppLayout=nn;exports.AtomProvider=pn;exports.Context=xe;exports.ContextError=Z;exports.DomainCodeDialog=xn;exports.ExampleComponent=St;exports.HydrateAtoms=Ye;exports.NAVBAR_WIDTH_CLOSED=de;exports.NAVBAR_WIDTH_OPENED=le;exports.NavBar=Et;exports.NavBarDarkStyledList=yt;exports.NavBarLightStyledList=kt;exports.NavBarProvider=He;exports.PageLayout=Rt;exports.SaladBarProvider=Ue;exports.atomStore=Xe;exports.buildNavBarState=qe;exports.domainCodeAtom=fe;exports.fed21Theme=fn;exports.internalAgSystemsTheme=mn;exports.navBarClasses=N;exports.navBarOpenAtom=ee;exports.navBarTopAtom=he;exports.navBarWidthClosedAtom=ue;exports.navBarWidthOpenAtom=ce;exports.titleTextAtom=pe;exports.topBarHeightAtom=ge;exports.useNavBar=Re;exports.useSaladBar=Ve;exports.withAtomProvider=Cn;exports.withNavBarProvider=Ot;exports.withOverrideDefaults=wn;exports.withSaladBarProvider=un;
2
2
  //# sourceMappingURL=index.cjs.map