@australiangreens/ag-internal-components 0.0.77 → 0.0.78

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 dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,s=(e,t)=>{for(var o in t||(t={}))ye.call(t,o)&&ae(e,o,t[o]);if(X)for(var o of X(t))je.call(t,o)&&ae(e,o,t[o]);return e},j=(e,t)=>ut(e,pt(t));var Be=(e,t)=>{var o={};for(var i in e)ye.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&X)for(var i of X(e))t.indexOf(i)<0&&je.call(e,i)&&(o[i]=e[i]);return o};var De=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var $=(e,t,o)=>new Promise((i,a)=>{var l=d=>{try{p(o.next(d))}catch(u){a(u)}},c=d=>{try{p(o.throw(d))}catch(u){a(u)}},p=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,c);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react"),r=require("@mui/material"),gt=require("@mui/material/CssBaseline"),T=require("@mui/material/styles"),ht=require("@australiangreens/ag-error"),U=require("souvlaki"),xt=require("@mui/material/List"),W=require("@mui/icons-material"),ft=require("autosuggest-highlight/match"),mt=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),Ct=require("@auth0/auth0-react"),vt=require("buffer"),b=require("jotai"),Me=require("jotai/utils"),ee=e=>e&&e.__esModule?e:{default:e},At=ee(gt),He=ee(xt),wt=ee(ft),St=ee(mt);function bt({text:e}){const[t,o]=h.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},yt=T.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${q.root}`]:{display:"flex"},[`& .${q.menuButton}`]:{marginRight:36},[`& .${q.hide}`]:{display:"none"},[`& .${q.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),Re=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),jt=()=>s({width:de},Re()),Bt=()=>s({width:ue},Re()),Dt=T.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>s(s({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":jt()}),!t&&{"& .MuiDrawer-paper":Bt()}));class te extends ht.AgError{}De(te,"errorName","ContextError");const qe=h.createContext(null),kt={},Tt={},We=({overrideState:e=kt,overrideActions:t=Tt,children:o})=>{const[{open:i},a]=h.useState({open:!0}),l=h.useCallback(d=>{a({open:d})},[]),c=h.useCallback(()=>{a(d=>j(s({},d),{open:!d.open}))},[]),p=s(s({open:i,setOpen:l,toggleOpen:c},e),t);return n.jsx(qe.Provider,{value:p,children:o})},ze=()=>{const e=h.useContext(qe);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ve=(e={})=>s({open:!0},e),Ot=U.createHelper((e=Ve(),t={})=>({children:o})=>n.jsx(We,{overrideState:e,overrideActions:t,children:o})),ke=7,It=T.styled(He.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${ke}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${ke}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Et=T.styled(He.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function $t({"data-testid":e,children:t}){const{open:o}=ze();return n.jsxs(yt,{className:q.root,"data-testid":e,children:[n.jsx(At.default,{}),n.jsx(Dt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const pe=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:l,onClose:c,sx:p,"data-testid":d,disableCloseOnBackdropOrEscape:u=!1})=>{var w,x;const[C,A]=h.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(y,B)=>$(exports,null,function*(){u&&(B==="backdropClick"||B==="escapeKeyDown")||C||(l!=null&&l.onClick?yield l.onClick():c())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":d,sx:p,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(w=l==null?void 0:l.onClick)!=null?w:c,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||C,color:l==null?void 0:l.buttonColor,children:(x=l==null?void 0:l.text)!=null?x:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>$(exports,null,function*(){var y;A(!0),yield(y=a.onClick)==null?void 0:y.call(a),A(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},ge=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>ce.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Pt({lookup:e=()=>$(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:l,"data-testid":c,sx:p,textFieldColor:d,textFieldVariant:u="filled",loadingText:C="Loading...",noOptionsText:A="No options",popupIcon:w=n.jsx(W.ArrowDropDown,{}),error:x=!1,helperText:y="",preLoadedOptions:B=void 0,disablePortal:k=!1}){const[f,D]=h.useState(""),_=(g,m)=>{const E=l.filter(F=>F.id!==m);o(E,"delete",g)},{data:P,isLoading:N}=ge({inputValue:f,label:a,lookup:e,minLength:i,preLoadedOptions:B}),O=f.length>=i;return n.jsxs("div",{"data-testid":c,children:[n.jsx(r.Autocomplete,{sx:p,"data-testid":c?`${c}:Autocomplete`:void 0,disablePortal:k,multiple:!0,getOptionLabel:g=>typeof g=="string"?g:g.label,loading:O?N:!1,options:[...l,...P!=null?P:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(g,m,E)=>{o(m,E,g)},onInputChange:(g,m)=>D(m),noOptionsText:O?A:"Start typing to search",loadingText:C,popupIcon:w,renderInput:g=>n.jsx(r.TextField,j(s({},g),{label:a,fullWidth:!0,variant:u,error:x,helperText:y,InputProps:j(s({},g.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[N?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,g.InputProps.endAdornment]})}),"data-testid":c?`${c}:Autocomplete:TextField`:void 0,onKeyDown:m=>{(m.key==="Backspace"||m.key==="Delete")&&m.stopPropagation()},color:d})),renderTags:()=>null,isOptionEqualToValue:(g,m)=>g.id===m.id,renderOption:(g,m,E)=>{if(t){const F=wt.default(m.label,E.inputValue,{insideWords:!0,findAllOccurrences:!0}),S=St.default(m.label,F);return h.createElement("li",j(s({},g),{key:m.id,"data-testid":c?`${c}:Autocomplete:option(${m.id.toString()})`:void 0}),n.jsx("div",{children:S.map((v,L)=>n.jsx("span",{style:{fontWeight:v.highlight?700:400},children:v.text},L))}))}else return h.createElement("li",j(s({},g),{key:m.id,"data-testid":c?`${c}:option(${m.id.toString()})`:void 0}),m.label)}}),l.length>0&&n.jsx(r.Box,{children:l.map(g=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:g.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:g.chipLabel?g.chipLabel:g.label})}),"data-testid":c?`${c}:Chip(${g.id.toString()})`:void 0,onDelete:m=>_(m,g.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":c?`${c}:Chip(${g.id.toString()}):deleteIcon`:void 0})},g.id))})]})}const Ft=({lookup:e=()=>$(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:l,textFieldVariant:c="filled","data-testid":p,noOptionsText:d="No options",minLength:u=3,disablePortal:C=!1,preLoadedOptions:A})=>{const[w,x]=h.useState(""),{data:y,isLoading:B}=ge({inputValue:w,label:o,lookup:e,minLength:u!=null?u:0,preLoadedOptions:A}),k=w.length>=u;return n.jsx("div",{"data-testid":p,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:a,"data-testid":p?`${p}:Autocomplete`:void 0,loading:k?B:!1,options:y!=null?y:[],onChange:(f,D)=>{t(f,D)},disablePortal:C,filterOptions:f=>f,value:i,noOptionsText:k?d:"Start typing to search",getOptionLabel:f=>f.label,renderInput:f=>n.jsx(r.TextField,j(s({"data-testid":p?`${p}:Autocomplete:TextField`:void 0},f),{variant:c,label:o,color:l})),isOptionEqualToValue:(f,D)=>f.id===D.id,onInputChange:(f,D)=>{x(D)},renderOption:(f,D)=>h.createElement("li",j(s({},f),{key:D.id,"data-testid":p?`${p}:Autocomplete:option(${D.id.toString()})`:void 0}),D.label)})})})},Ue=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(vt.Buffer.from(o,"base64").toString("utf8").split("").map(function(l){return"%"+("00"+l.charCodeAt(0).toString(16)).slice(-2)}).join("")),a=JSON.parse(i);return a!=null&&a.exp?a.exp:-1}catch(t){return-1}},Nt=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:a}=Ct.useAuth0(),[l,c]=h.useState(0),p=()=>$(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),d=()=>$(exports,null,function*(){c(l+1),t()});h.useEffect(()=>{(()=>$(exports,null,function*(){if(l>0){const w=yield a({cacheMode:"off"}),x=Ue(w)*1e3;o(x)}}))()},[l,a,o]);const u={text:"Continue",onClick:d,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},C={text:"Log out",onClick:p,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(pe,{isOpen:e,primaryButton:u,secondaryButton:C,onClose:t,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:n.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})},Lt=24,_t=64,R="TopBar",I={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Mt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return{width:"100%",[`& .${I.topStripe}`]:{width:"100%",height:`${Lt}px`,backgroundColor:e.palette.primary.main},[`& .${I.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${_t}px`,padding:e.spacing(0,3),width:"100%"},[`& .${I.titleSlider}`]:s(s({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${I.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${I.titleText}`]:{flexGrow:1},[`& .${I.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}});function Ht({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Mt,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:I.topStripe}),n.jsx("div",{className:I.titleBar,children:n.jsxs(r.Box,{className:I.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:I.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:I.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:I.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,Rt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:a,navBarWidthClosed:l})=>({width:e,"& .MuiDrawer-paper":s(s({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&s({marginLeft:`${l}px`},i&&{marginLeft:`${a}px`}))})),qt=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(s({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function Oe({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:l=Ge,showCloseArrow:c=!0,debugOpacity:p=!1,headerBoxProps:d={},onOpened:u,onClosed:C,"data-testid":A,navBarOpen:w=!1,navBarWidthOpen:x=0,navBarWidthClosed:y=0}){return n.jsxs(Rt,{SlideProps:{onEntered:()=>u==null?void 0:u(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:l,debugOpacity:p,"data-testid":A,navBarOpen:w,navBarWidthOpen:x,navBarWidthClosed:y,children:[n.jsx(qt,j(s({anchor:t},d),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a}),c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a})]})})),e]})}const Wt=T.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return s(s({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}),zt=T.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,K={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 Vt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:l=!1,pageContainerProps:c,pageContentDataTestId:p,topBarDataTestId:d,navBarOpen:u,navBarWidthOpen:C,navBarWidthClosed:A}){const[w,x]=h.useState(se),[y,B]=h.useState(le),[k,f]=h.useState(se),[D,_]=h.useState(le),P=o!==void 0,N=i!==void 0,{titleText:O,content:g,flavour:m,open:E,onChangeOpen:F,width:S,arrowButtons:v,startOpen:L,onOpened:nt,onClosed:ot,dataTestId:rt}=o?s(s({},K),o):s({},K),{titleText:it,content:at,flavour:Ae,open:ne,onChangeOpen:we,width:oe,arrowButtons:G,startOpen:Q,onOpened:st,onClosed:lt,dataTestId:ct}=i?s(s({},K),i):s({},K);h.useEffect(()=>{L!==se&&(x(L),f(L))},[L]),h.useEffect(()=>{Q!==le&&(B(Q),_(Q))},[Q]);const re=E===void 0?w:E,ie=ne===void 0?y:ne,Se=M=>{E===void 0&&(x(M),a&&N&&(M?(B(!1),_(y)):B(D))),F&&F(M)},be=M=>{ne===void 0&&(B(M),a&&P&&(M?(x(!1),f(w)):x(k))),we&&we(M)};return n.jsxs(r.Box,{children:[P&&n.jsx(Oe,{"data-testid":rt,anchor:"left",open:re,onClose:()=>Se(!1),width:S,titleText:O,debugOpacity:l,showCloseArrow:v==="both"||v==="close",onOpened:nt,onClosed:ot,navBarOpen:u,navBarWidthOpen:C,navBarWidthClosed:A,children:g}),N&&n.jsx(Oe,{"data-testid":ct,anchor:"right",open:ie,onClose:()=>be(!1),width:oe,titleText:it,debugOpacity:l,showCloseArrow:G==="both"||G==="close",onOpened:st,onClosed:lt,navBarOpen:u,navBarWidthOpen:C,navBarWidthClosed:A,children:at}),n.jsx(Ht,s(s({titleText:t,"data-testid":d},P&&m==="push"?{leftPanel:{open:re,width:S,onOpen:()=>Se(!0),showOpenArrow:v==="both"||v==="open"}}:{}),N&&Ae==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>be(!0),showOpenArrow:G==="both"||G==="open"}}:{})),n.jsx(Wt,j(s(s({},m==="push"?{leftPanel:{open:re,width:S}}:{}),Ae==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(zt,j(s({"data-testid":p},c),{children:e}))}))]})}const Qe=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Ut=64,Gt=64,Qt=256,z=b.atom(!0),he=b.atom(Qt),xe=b.atom(Gt),Y=b.atom(""),Xe=b.atom(void 0),fe=b.atom(Ut),me=b.atom(void 0);function Xt({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",V={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},Kt=T.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${V.root}`]:{display:"flex"},[`& .${V.menuButton}`]:{marginRight:36},[`& .${V.hide}`]:{display:"none"},[`& .${V.content}`]:{flexGrow:1,padding:e.spacing(3)}})),Z=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),Jt=e=>{const t=r.useTheme();return n.jsx(r.Collapse,s({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Ke=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Ie=(e,t)=>s({width:t,transition:Z(e,"width","entering")},Ke(e)),Ee=(e,t)=>s({width:t,transition:Z(e,"width","leaving")},Ke(e)),Yt=T.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>s(s({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(s({},Ie(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,o)})),!t&&j(s({},Ee(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Ee(e,a?o:i)})));function Zt(e){let t=0;for(let o=0,i=e.length;o<i;o++){const a=e.charCodeAt(o);t=(t<<5)-t+a,t|=0}return t}const $e=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],en=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function tn({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?Z(i,["width","height"],"entering"):Z(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:$e[Math.abs(Zt(e.name))%$e.length]},children:en(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(Jt,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function nn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:l,bottom:c,user:p,domainCode:d}){const u=Qe(),C=b.useSetAtom(z);return n.jsx(Kt,{className:V.root,"data-testid":i,children:n.jsxs(Yt,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:u?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{C(!1)},isSmallScreen:u,children:[!u&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle"})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(l)?n.jsx(Xt,{links:l}):l}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle"}),n.jsx(tn,{user:p,domainCode:d,open:e}),c&&n.jsx(n.Fragment,{children:c})]})]})})}function on({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const rn="TopBar",an={titleText:`${rn}-titleText`};function sn({titleText:e="",height:t,"data-testid":o,middle:i}){const a=b.useSetAtom(z),l=()=>a(d=>!d),c=r.useTheme(),p=Qe();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t,zIndex:p?0:c.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:l,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:an.titleText,variant:"h6",children:e}),i]})})}function ln({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:l,navBarDataTestId:c,navBarMiddle:p,navBarBottom:d,user:u,domainCode:C}){Me.useHydrateAtoms([[z,o!=null?o:!0],[Y,t!=null?t:""]]);const A=b.useAtomValue(z),[w]=b.useAtom(he),[x]=b.useAtom(xe),y=b.useAtomValue(Y),[B]=b.useAtom(fe),[k]=b.useAtom(Xe),[f]=b.useAtom(me);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(sn,{titleText:y,"data-testid":l,height:B,middle:k}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(nn,{open:A,top:f,middle:p,bottom:d,user:u,domainCode:C,widthOpen:w,widthClosed:x,offsetTop:B,"data-testid":c}),n.jsx(on,j(s({"data-testid":a,topBarHeight:B},i),{children:e}))]})]})}const cn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},dn={shouldClose:(e,t)=>t!=="clickaway"},Pe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Fe=100,Ne=2e3,un=2e3,pn=(()=>{let e=0;return()=>(e+=1,e)})(),gn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},hn={},xn={},Ce=h.createContext(null);function Je(l){var c=l,{overrideState:e=hn,overrideActions:t=xn,shouldClose:o=dn.shouldClose,children:i}=c,a=Be(c,["overrideState","overrideActions","shouldClose","children"]);var F;const[{open:p},d]=h.useState({open:!1}),u=h.useRef([]),C=h.useRef(Date.now()),A=h.useRef(0),w=h.useCallback(S=>{d({open:S})},[]),x=h.useCallback((S={})=>{A.current+=1,u.current.length>=Fe&&Date.now()-C.current>=Ne&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Fe}) hit ${A.current} times in last ${Ne}ms)`),A.current=0);const v=s(j(s({},Pe),{key:pn()}),S);return u.current.push(v),u.current.length===1&&d({open:!0}),v.key},[]),y=(S="",v={})=>x(s({message:S,severity:"success"},v)),B=(S="",v={})=>x(s({message:S,severity:"info"},v)),k=(S="",v={})=>x(s({message:S,severity:"warning"},v)),f=(S="",v={})=>x(s({message:S,severity:"error"},v)),D=S=>{const v=u.current.findIndex(L=>L.key===S);if(v!==-1)return v===0?(d({open:!1}),u.current[0]):u.current.splice(v,1)},_=(S,v)=>{o(S,v)&&d({open:!1})},P=()=>{},N=()=>{u.current.shift(),u.current.length>0&&d({open:!0})},O=(F=u.current[0])!=null?F:s({},Pe),g={};"autoHideDuration"in O&&(g.autoHideDuration=O.autoHideDuration);const m=s(s({},cn),a),E=s(s({open:p,setOpen:w,enqueueNotification:x,enqueueSuccessNotification:y,enqueueInfoNotification:B,enqueueWarningNotification:k,enqueueErrorNotification:f,removeNotification:D},e),t);return n.jsxs(Ce.Provider,{value:E,children:[i,n.jsx(r.Snackbar,j(s(s({},m),g),{open:p,onClose:_,TransitionProps:{onExited:N,onExit:P},sx:{zIndex:un},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:S=>_(S,"closeAlert"),severity:O.severity,variant:"filled",icon:O.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:O.progressIndicator==="linear"?gn:void 0,children:O.message}),O.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Ye(){const e=h.useContext(Ce);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const fn=U.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Je,j(s({},e),{overrideState:t,overrideActions:o,children:i}))),Ze=b.getDefaultStore(),mn=({children:e,store:t})=>n.jsx(b.Provider,{store:t!=null?t:Ze,children:e}),et="domainCode";var _e;const Le=b.atom(JSON.parse((_e=localStorage.getItem(et))!=null?_e:'{"domainCode": ""}').domainCode),ve=b.atom(e=>e(Le),(e,t,o)=>{t(Le,o),localStorage.setItem(et,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","":""},vn=e=>{var t;return e===null?"N/A":(t=Cn[e])!=null?t:""},An=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:l})=>{const[c,p]=b.useAtom(ve),[d,u]=h.useState(c),{enqueueSuccessNotification:C}=Ye(),A=i.length===0,w=!!c&&!i.includes(c)&&!i.includes(d),x=!c||A||w,y=()=>$(exports,null,function*(){d?(p(d),C(`Set domain to ${d}`),o()):p("")}),B=()=>$(exports,null,function*(){c&&!A&&!w?(u(c),o()):x&&l()});let k;return A?k="Unable to retrieve your active organisations. Try logging in again.":w&&(k="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(pe,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:y,disabled:!d||A||w,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:B},onClose:x?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",a,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:d!==""?d:null,onChange:(f,D)=>u(D!=null?D:""),getOptionLabel:vn,options:[...i],renderInput:f=>n.jsx(r.TextField,j(s({},f),{variant:"filled",label:"Select organisation",InputProps:j(s({},f.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,f.InputProps.endAdornment]})})}))}),k&&n.jsx(r.FormHelperText,{error:!0,children:k})]})},wn=T.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"}}),Sn=T.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:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),bn={domainCode:ve,navBarOpen:z,navBarWidthOpen:he,navBarWidthClosed:xe,titleText:Y,topBarHeight:fe,navBarTop:me},yn=U.createHelper(()=>({children:e})=>n.jsx(b.Provider,{children:e})),tt=({initialValues:e,children:t})=>(Me.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),jn=U.createHelper(e=>({children:t})=>n.jsx(tt,{initialValues:Object.entries(e).map(([o,i])=>[bn[o],i]),children:t})),Bn=U.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=pe;exports.AppLayout=ln;exports.AtomProvider=mn;exports.Context=Ce;exports.ContextError=te;exports.DomainCodeDialog=An;exports.ExampleComponent=bt;exports.FetchAutocomplete=Pt;exports.HydrateAtoms=tt;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=$t;exports.NavBarDarkStyledList=It;exports.NavBarLightStyledList=Et;exports.NavBarProvider=We;exports.PageLayout=Vt;exports.SaladBarProvider=Je;exports.SessionExpiryDialog=Nt;exports.SingleAutocomplete=Ft;exports.atomStore=Ze;exports.buildNavBarState=Ve;exports.domainCodeAtom=ve;exports.fed21Theme=wn;exports.getAuth0Expiry=Ue;exports.internalAgSystemsTheme=Sn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=me;exports.navBarWidthClosedAtom=xe;exports.navBarWidthOpenAtom=he;exports.titleTextAtom=Y;exports.topBarHeightAtom=fe;exports.topBarMiddleAtom=Xe;exports.useAutocompleteOptions=ge;exports.useNavBar=ze;exports.useSaladBar=Ye;exports.withAtomProvider=yn;exports.withNavBarProvider=Ot;exports.withOverrideDefaults=jn;exports.withQueryClient=Bn;exports.withSaladBarProvider=fn;
1
+ "use strict";var ct=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&ae(e,o,t[o]);if(X)for(var o of X(t))je.call(t,o)&&ae(e,o,t[o]);return e},y=(e,t)=>dt(e,ut(t));var ye=(e,t)=>{var o={};for(var i in e)be.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&X)for(var i of X(e))t.indexOf(i)<0&&je.call(e,i)&&(o[i]=e[i]);return o};var Be=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var M=(e,t,o)=>new Promise((i,s)=>{var l=d=>{try{p(o.next(d))}catch(u){s(u)}},c=d=>{try{p(o.throw(d))}catch(u){s(u)}},p=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,c);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),x=require("react"),r=require("@mui/material"),pt=require("@mui/material/CssBaseline"),k=require("@mui/material/styles"),ht=require("@australiangreens/ag-error"),G=require("souvlaki"),gt=require("@mui/material/List"),W=require("@mui/icons-material"),xt=require("autosuggest-highlight/match"),ft=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),S=require("jotai"),_e=require("jotai/utils"),ee=e=>e&&e.__esModule?e:{default:e},mt=ee(pt),Me=ee(gt),Ct=ee(xt),vt=ee(ft);function wt({text:e}){const[t,o]=x.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},At=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${q.root}`]:{display:"flex"},[`& .${q.menuButton}`]:{marginRight:36},[`& .${q.hide}`]:{display:"none"},[`& .${q.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),He=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),St=()=>a({width:de},He()),bt=()=>a({width:ue},He()),jt=k.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>a(a({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":St()}),!t&&{"& .MuiDrawer-paper":bt()}));class te extends ht.AgError{}Be(te,"errorName","ContextError");const Re=x.createContext(null),yt={},Bt={},qe=({overrideState:e=yt,overrideActions:t=Bt,children:o})=>{const[{open:i},s]=x.useState({open:!0}),l=x.useCallback(d=>{s({open:d})},[]),c=x.useCallback(()=>{s(d=>y(a({},d),{open:!d.open}))},[]),p=a(a({open:i,setOpen:l,toggleOpen:c},e),t);return n.jsx(Re.Provider,{value:p,children:o})},We=()=>{const e=x.useContext(Re);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},ze=(e={})=>a({open:!0},e),Dt=G.createHelper((e=ze(),t={})=>({children:o})=>n.jsx(qe,{overrideState:e,overrideActions:t,children:o})),De=7,Tt=k.styled(Me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",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}}})),Te=7,kt=k.styled(Me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Ot({"data-testid":e,children:t}){const{open:o}=We();return n.jsxs(At,{className:q.root,"data-testid":e,children:[n.jsx(mt.default,{}),n.jsx(jt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const Ve=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:s,secondaryButton:l,onClose:c,sx:p,"data-testid":d,disableCloseOnBackdropOrEscape:u=!1})=>{var b,m;const[v,A]=x.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(j,B)=>M(exports,null,function*(){u&&(B==="backdropClick"||B==="escapeKeyDown")||v||(l!=null&&l.onClick?yield l.onClick():c())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":d,sx:p,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(b=l==null?void 0:l.onClick)!=null?b:c,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||v,color:l==null?void 0:l.buttonColor,children:(m=l==null?void 0:l.text)!=null?m:"Cancel"}),s&&n.jsx(r.Button,{onClick:()=>M(exports,null,function*(){var j;A(!0),yield(j=s.onClick)==null?void 0:j.call(s),A(!1)}),"data-testid":s.testId,disabled:s.disabled||v,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},pe=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:s})=>ce.useQuery({queryFn:()=>e&&s.length<e?t!=null?t:[]:t?t.filter(l=>l.label.toLowerCase().includes(s.toLowerCase())):o(s),queryKey:["autocomplete",i,s]});function It({lookup:e=()=>M(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:s,value:l,"data-testid":c,sx:p,textFieldColor:d,textFieldVariant:u="filled",loadingText:v="Loading...",noOptionsText:A="No options",popupIcon:b=n.jsx(W.ArrowDropDown,{}),error:m=!1,helperText:j="",preLoadedOptions:B=void 0,disablePortal:T=!1}){const[g,D]=x.useState(""),L=(h,f)=>{const $=l.filter(P=>P.id!==f);o($,"delete",h)},{data:F,isLoading:E}=pe({inputValue:g,label:s,lookup:e,minLength:i,preLoadedOptions:B}),O=g.length>=i;return n.jsxs("div",{"data-testid":c,children:[n.jsx(r.Autocomplete,{sx:p,"data-testid":c?`${c}:Autocomplete`:void 0,disablePortal:T,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:O?E:!1,options:[...l,...F!=null?F:[]],filterSelectedOptions:!0,includeInputInList:!0,value:l,onChange:(h,f,$)=>{o(f,$,h)},onInputChange:(h,f)=>D(f),noOptionsText:O?A:"Start typing to search",loadingText:v,popupIcon:b,renderInput:h=>n.jsx(r.TextField,y(a({},h),{label:s,fullWidth:!0,variant:u,error:m,helperText:j,InputProps:y(a({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[E?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})}),"data-testid":c?`${c}:Autocomplete:TextField`:void 0,onKeyDown:f=>{(f.key==="Backspace"||f.key==="Delete")&&f.stopPropagation()},color:d})),renderTags:()=>null,isOptionEqualToValue:(h,f)=>h.id===f.id,renderOption:(h,f,$)=>{if(t){const P=Ct.default(f.label,$.inputValue,{insideWords:!0,findAllOccurrences:!0}),w=vt.default(f.label,P);return x.createElement("li",y(a({},h),{key:f.id,"data-testid":c?`${c}:Autocomplete:option(${f.id.toString()})`:void 0}),n.jsx("div",{children:w.map((C,N)=>n.jsx("span",{style:{fontWeight:C.highlight?700:400},children:C.text},N))}))}else return x.createElement("li",y(a({},h),{key:f.id,"data-testid":c?`${c}:option(${f.id.toString()})`:void 0}),f.label)}}),l.length>0&&n.jsx(r.Box,{children:l.map(h=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:h.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":c?`${c}:Chip(${h.id.toString()})`:void 0,onDelete:f=>L(f,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":c?`${c}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const $t=({lookup:e=()=>M(exports,null,function*(){}),onChange:t,label:o,value:i,sx:s,textFieldColor:l,textFieldVariant:c="filled","data-testid":p,noOptionsText:d="No options",minLength:u=3,disablePortal:v=!1,preLoadedOptions:A})=>{const[b,m]=x.useState(""),{data:j,isLoading:B}=pe({inputValue:b,label:o,lookup:e,minLength:u!=null?u:0,preLoadedOptions:A}),T=b.length>=u;return n.jsx("div",{"data-testid":p,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:s,"data-testid":p?`${p}:Autocomplete`:void 0,loading:T?B:!1,options:j!=null?j:[],onChange:(g,D)=>{t(g,D)},disablePortal:v,filterOptions:g=>g,value:i,noOptionsText:T?d:"Start typing to search",getOptionLabel:g=>g.label,renderInput:g=>n.jsx(r.TextField,y(a({"data-testid":p?`${p}:Autocomplete:TextField`:void 0},g),{variant:c,label:o,color:l})),isOptionEqualToValue:(g,D)=>g.id===D.id,onInputChange:(g,D)=>{m(D)},renderOption:(g,D)=>x.createElement("li",y(a({},g),{key:D.id,"data-testid":p?`${p}:Autocomplete:option(${D.id.toString()})`:void 0}),D.label)})})})},Ft=24,Pt=64,R="TopBar",I={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Et=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,s;return{width:"100%",[`& .${I.topStripe}`]:{width:"100%",height:`${Ft}px`,backgroundColor:e.palette.primary.main},[`& .${I.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Pt}px`,padding:e.spacing(0,3),width:"100%"},[`& .${I.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}),[`& .${I.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${I.titleText}`]:{flexGrow:1},[`& .${I.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}});function Nt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Et,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:I.topStripe}),n.jsx("div",{className:I.titleBar,children:n.jsxs(r.Box,{className:I.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:I.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:I.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:I.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,Lt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:s,navBarWidthClosed:l})=>({width:e,"& .MuiDrawer-paper":a(a({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&a({marginLeft:`${l}px`},i&&{marginLeft:`${s}px`}))})),_t=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>y(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 ke({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:s="",width:l=Ge,showCloseArrow:c=!0,debugOpacity:p=!1,headerBoxProps:d={},onOpened:u,onClosed:v,"data-testid":A,navBarOpen:b=!1,navBarWidthOpen:m=0,navBarWidthClosed:j=0}){return n.jsxs(Lt,{SlideProps:{onEntered:()=>u==null?void 0:u(),onExited:()=>v==null?void 0:v()},variant:"persistent",anchor:t,open:o,width:l,debugOpacity:p,"data-testid":A,navBarOpen:b,navBarWidthOpen:m,navBarWidthClosed:j,children:[n.jsx(_t,y(a({anchor:t},d),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[c&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Mt=k.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,s;return a(a({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=o==null?void 0:o.width)!=null?s:0}px`})}),Ht=k.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,K={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 Rt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:l=!1,pageContainerProps:c,pageContentDataTestId:p,topBarDataTestId:d,navBarOpen:u,navBarWidthOpen:v,navBarWidthClosed:A}){const[b,m]=x.useState(se),[j,B]=x.useState(le),[T,g]=x.useState(se),[D,L]=x.useState(le),F=o!==void 0,E=i!==void 0,{titleText:O,content:h,flavour:f,open:$,onChangeOpen:P,width:w,arrowButtons:C,startOpen:N,onOpened:tt,onClosed:nt,dataTestId:ot}=o?a(a({},K),o):a({},K),{titleText:rt,content:it,flavour:ve,open:ne,onChangeOpen:we,width:oe,arrowButtons:U,startOpen:Q,onOpened:at,onClosed:st,dataTestId:lt}=i?a(a({},K),i):a({},K);x.useEffect(()=>{N!==se&&(m(N),g(N))},[N]),x.useEffect(()=>{Q!==le&&(B(Q),L(Q))},[Q]);const re=$===void 0?b:$,ie=ne===void 0?j:ne,Ae=_=>{$===void 0&&(m(_),s&&E&&(_?(B(!1),L(j)):B(D))),P&&P(_)},Se=_=>{ne===void 0&&(B(_),s&&F&&(_?(m(!1),g(b)):m(T))),we&&we(_)};return n.jsxs(r.Box,{children:[F&&n.jsx(ke,{"data-testid":ot,anchor:"left",open:re,onClose:()=>Ae(!1),width:w,titleText:O,debugOpacity:l,showCloseArrow:C==="both"||C==="close",onOpened:tt,onClosed:nt,navBarOpen:u,navBarWidthOpen:v,navBarWidthClosed:A,children:h}),E&&n.jsx(ke,{"data-testid":lt,anchor:"right",open:ie,onClose:()=>Se(!1),width:oe,titleText:rt,debugOpacity:l,showCloseArrow:U==="both"||U==="close",onOpened:at,onClosed:st,navBarOpen:u,navBarWidthOpen:v,navBarWidthClosed:A,children:it}),n.jsx(Nt,a(a({titleText:t,"data-testid":d},F&&f==="push"?{leftPanel:{open:re,width:w,onOpen:()=>Ae(!0),showOpenArrow:C==="both"||C==="open"}}:{}),E&&ve==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>Se(!0),showOpenArrow:U==="both"||U==="open"}}:{})),n.jsx(Mt,y(a(a({},f==="push"?{leftPanel:{open:re,width:w}}:{}),ve==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(Ht,y(a({"data-testid":p},c),{children:e}))}))]})}const Ue=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},qt=64,Wt=64,zt=256,z=S.atom(!0),he=S.atom(zt),ge=S.atom(Wt),Y=S.atom(""),Qe=S.atom(void 0),xe=S.atom(qt),fe=S.atom(void 0);function Vt({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",V={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},Gt=k.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${V.root}`]:{display:"flex"},[`& .${V.menuButton}`]:{marginRight:36},[`& .${V.hide}`]:{display:"none"},[`& .${V.content}`]:{flexGrow:1,padding:e.spacing(3)}})),Z=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),Ut=e=>{const t=r.useTheme();return n.jsx(r.Collapse,a({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Xe=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Oe=(e,t)=>a({width:t,transition:Z(e,"width","entering")},Xe(e)),Ie=(e,t)=>a({width:t,transition:Z(e,"width","leaving")},Xe(e)),Qt=k.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:s})=>a(a({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&y(a({},Oe(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,o)})),!t&&y(a({},Ie(e,s?o:i)),{backgroundColor:"","& .MuiDrawer-paper":Ie(e,s?o:i)})));function Xt(e){let t=0;for(let o=0,i=e.length;o<i;o++){const s=e.charCodeAt(o);t=(t<<5)-t+s,t|=0}return t}const $e=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Kt=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function Jt({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?Z(i,["width","height"],"entering"):Z(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:$e[Math.abs(Xt(e.name))%$e.length]},children:Kt(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(Ut,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function Yt({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:s,middle:l,bottom:c,user:p,domainCode:d}){const u=Ue(),v=S.useSetAtom(z);return n.jsx(Gt,{className:V.root,"data-testid":i,children:n.jsxs(Qt,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:u?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{v(!1)},isSmallScreen:u,children:[!u&&n.jsx(r.Toolbar,{}),s&&n.jsxs(r.Box,{flexGrow:"0",children:[s,n.jsx(r.Divider,{variant:"middle"})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(l)?n.jsx(Vt,{links:l}):l}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle"}),n.jsx(Jt,{user:p,domainCode:d,open:e}),c&&n.jsx(n.Fragment,{children:c})]})]})})}function Zt({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const en="TopBar",tn={titleText:`${en}-titleText`};function nn({titleText:e="",height:t,"data-testid":o,middle:i}){const s=S.useSetAtom(z),l=()=>s(d=>!d),c=r.useTheme(),p=Ue();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t,zIndex:p?0:c.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:l,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:tn.titleText,variant:"h6",children:e}),i]})})}function on({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:s,topBarDataTestId:l,navBarDataTestId:c,navBarMiddle:p,navBarBottom:d,user:u,domainCode:v}){_e.useHydrateAtoms([[z,o!=null?o:!0],[Y,t!=null?t:""]]);const A=S.useAtomValue(z),[b]=S.useAtom(he),[m]=S.useAtom(ge),j=S.useAtomValue(Y),[B]=S.useAtom(xe),[T]=S.useAtom(Qe),[g]=S.useAtom(fe);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(nn,{titleText:j,"data-testid":l,height:B,middle:T}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(Yt,{open:A,top:g,middle:p,bottom:d,user:u,domainCode:v,widthOpen:b,widthClosed:m,offsetTop:B,"data-testid":c}),n.jsx(Zt,y(a({"data-testid":s,topBarHeight:B},i),{children:e}))]})]})}const rn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},an={shouldClose:(e,t)=>t!=="clickaway"},Fe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Pe=100,Ee=2e3,sn=2e3,ln=(()=>{let e=0;return()=>(e+=1,e)})(),cn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},dn={},un={},me=x.createContext(null);function Ke(l){var c=l,{overrideState:e=dn,overrideActions:t=un,shouldClose:o=an.shouldClose,children:i}=c,s=ye(c,["overrideState","overrideActions","shouldClose","children"]);var P;const[{open:p},d]=x.useState({open:!1}),u=x.useRef([]),v=x.useRef(Date.now()),A=x.useRef(0),b=x.useCallback(w=>{d({open:w})},[]),m=x.useCallback((w={})=>{A.current+=1,u.current.length>=Pe&&Date.now()-v.current>=Ee&&(v.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Pe}) hit ${A.current} times in last ${Ee}ms)`),A.current=0);const C=a(y(a({},Fe),{key:ln()}),w);return u.current.push(C),u.current.length===1&&d({open:!0}),C.key},[]),j=(w="",C={})=>m(a({message:w,severity:"success"},C)),B=(w="",C={})=>m(a({message:w,severity:"info"},C)),T=(w="",C={})=>m(a({message:w,severity:"warning"},C)),g=(w="",C={})=>m(a({message:w,severity:"error"},C)),D=w=>{const C=u.current.findIndex(N=>N.key===w);if(C!==-1)return C===0?(d({open:!1}),u.current[0]):u.current.splice(C,1)},L=(w,C)=>{o(w,C)&&d({open:!1})},F=()=>{},E=()=>{u.current.shift(),u.current.length>0&&d({open:!0})},O=(P=u.current[0])!=null?P:a({},Fe),h={};"autoHideDuration"in O&&(h.autoHideDuration=O.autoHideDuration);const f=a(a({},rn),s),$=a(a({open:p,setOpen:b,enqueueNotification:m,enqueueSuccessNotification:j,enqueueInfoNotification:B,enqueueWarningNotification:T,enqueueErrorNotification:g,removeNotification:D},e),t);return n.jsxs(me.Provider,{value:$,children:[i,n.jsx(r.Snackbar,y(a(a({},f),h),{open:p,onClose:L,TransitionProps:{onExited:E,onExit:F},sx:{zIndex:sn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:w=>L(w,"closeAlert"),severity:O.severity,variant:"filled",icon:O.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:O.progressIndicator==="linear"?cn:void 0,children:O.message}),O.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Je(){const e=x.useContext(me);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const pn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Ke,y(a({},e),{overrideState:t,overrideActions:o,children:i}))),Ye=S.getDefaultStore(),hn=({children:e,store:t})=>n.jsx(S.Provider,{store:t!=null?t:Ye,children:e}),Ze="domainCode";var Le;const Ne=S.atom(JSON.parse((Le=localStorage.getItem(Ze))!=null?Le:'{"domainCode": ""}').domainCode),Ce=S.atom(e=>e(Ne),(e,t,o)=>{t(Ne,o),localStorage.setItem(Ze,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","":""},xn=e=>{var t;return e===null?"N/A":(t=gn[e])!=null?t:""},fn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:s,handleLogout:l})=>{const[c,p]=S.useAtom(Ce),[d,u]=x.useState(c),{enqueueSuccessNotification:v}=Je(),A=i.length===0,b=!!c&&!i.includes(c)&&!i.includes(d),m=!c||A||b,j=()=>M(exports,null,function*(){d?(p(d),v(`Set domain to ${d}`),o()):p("")}),B=()=>M(exports,null,function*(){c&&!A&&!b?(u(c),o()):m&&l()});let T;return A?T="Unable to retrieve your active organisations. Try logging in again.":b&&(T="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(Ve,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:j,disabled:!d||A||b,buttonColor:"primary"},secondaryButton:{text:m?"Logout":"Cancel",onClick:B},onClose:m?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",s,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:d!==""?d:null,onChange:(g,D)=>u(D!=null?D:""),getOptionLabel:xn,options:[...i],renderInput:g=>n.jsx(r.TextField,y(a({},g),{variant:"filled",label:"Select organisation",InputProps:y(a({},g.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,g.InputProps.endAdornment]})})}))}),T&&n.jsx(r.FormHelperText,{error:!0,children:T})]})},mn=k.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"}}),Cn=k.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:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:k.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:k.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:Ce,navBarOpen:z,navBarWidthOpen:he,navBarWidthClosed:ge,titleText:Y,topBarHeight:xe,navBarTop:fe},wn=G.createHelper(()=>({children:e})=>n.jsx(S.Provider,{children:e})),et=({initialValues:e,children:t})=>(_e.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),An=G.createHelper(e=>({children:t})=>n.jsx(et,{initialValues:Object.entries(e).map(([o,i])=>[vn[o],i]),children:t})),Sn=G.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=Ve;exports.AppLayout=on;exports.AtomProvider=hn;exports.Context=me;exports.ContextError=te;exports.DomainCodeDialog=fn;exports.ExampleComponent=wt;exports.FetchAutocomplete=It;exports.HydrateAtoms=et;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=Ot;exports.NavBarDarkStyledList=Tt;exports.NavBarLightStyledList=kt;exports.NavBarProvider=qe;exports.PageLayout=Rt;exports.SaladBarProvider=Ke;exports.SingleAutocomplete=$t;exports.atomStore=Ye;exports.buildNavBarState=ze;exports.domainCodeAtom=Ce;exports.fed21Theme=mn;exports.internalAgSystemsTheme=Cn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=fe;exports.navBarWidthClosedAtom=ge;exports.navBarWidthOpenAtom=he;exports.titleTextAtom=Y;exports.topBarHeightAtom=xe;exports.topBarMiddleAtom=Qe;exports.useAutocompleteOptions=pe;exports.useNavBar=We;exports.useSaladBar=Je;exports.withAtomProvider=wn;exports.withNavBarProvider=Dt;exports.withOverrideDefaults=An;exports.withQueryClient=Sn;exports.withSaladBarProvider=pn;
2
2
  //# sourceMappingURL=index.cjs.map