@australiangreens/ag-internal-components 0.0.51 → 0.0.53

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