@spotify/backstage-plugin-soundcheck 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/esm/{EntitySoundcheckContent-592fa779.esm.js → EntitySoundcheckContent-61aee236.esm.js} +2 -2
- package/dist/esm/{OverviewPageContent-7cf86a3a.esm.js → OverviewPageContent-31025374.esm.js} +2 -2
- package/dist/esm/{RefetchingIndicator-b042ec49.esm.js → RefetchingIndicator-e114bc04.esm.js} +2 -2
- package/dist/esm/index-0208f72c.esm.js +2 -0
- package/dist/esm/{index-95ae147b.esm.js → index-7b347cd4.esm.js} +2 -2
- package/dist/esm/{index-fcd50c7d.esm.js → index-7f1f7ff1.esm.js} +2 -2
- package/dist/esm/{index-540b325c.esm.js → index-e3458e3b.esm.js} +2 -2
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm/index-100619e3.esm.js +0 -2
package/CHANGELOG.md
CHANGED
package/dist/esm/{EntitySoundcheckContent-592fa779.esm.js → EntitySoundcheckContent-61aee236.esm.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useState as W,useEffect as $}from"react";import{Link as O,useParams as Q,Routes as j,Route as k,Navigate as I}from"react-router-dom";import{makeStyles as p,Typography as f,Box as U,Tab as L,Tabs as T,Paper as V,Divider as Y}from"@material-ui/core";import{SpotifyLicenseBanner as q}from"@spotify/backstage-plugin-core";import{useEntity as u}from"@backstage/plugin-catalog-react";import{R as G}from"./RefetchingIndicator-
|
|
2
|
-
//# sourceMappingURL=EntitySoundcheckContent-
|
|
1
|
+
import e,{useState as W,useEffect as $}from"react";import{Link as O,useParams as Q,Routes as j,Route as k,Navigate as I}from"react-router-dom";import{makeStyles as p,Typography as f,Box as U,Tab as L,Tabs as T,Paper as V,Divider as Y}from"@material-ui/core";import{SpotifyLicenseBanner as q}from"@spotify/backstage-plugin-core";import{useEntity as u}from"@backstage/plugin-catalog-react";import{R as G}from"./RefetchingIndicator-e114bc04.esm.js";import{s as H,R as o,A as y,F as B,a as J,u as x,L as K,N as X,b as C,c as g,d as Z,C as _,e as ee,i as te,f as F,S as ae}from"./index-7b347cd4.esm.js";import{Skeleton as s}from"@material-ui/lab";import{MarkdownContent as P}from"@backstage/core-components";import{stringifyEntityRef as ne}from"@backstage/catalog-model";import{useApi as re,useRouteRef as b,useRouteRefParams as ie}from"@backstage/core-plugin-api";import{useQuery as le}from"@tanstack/react-query";import ce from"react-use/lib/useMeasure";import A from"react-use/lib/usePrevious";import oe from"react-confetti";import"react-use/lib/useDebounce";import"graphql-request";import"graphql-tag";import"lodash";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function se(t,n,a){const r=re(H),i=ne(t);return le(["soundcheck/check-details",i,n,a],async()=>r.getCheckResultDetails(i,n,a),{enabled:!!n&&!!a})}const me=p({markdownContent:{"& :last-child":{marginBottom:0}}}),de=({state:t,notes:n})=>{const a=me(),r={[o.Passed]:"success",[o.Failed]:"error",[o.NotReported]:"info",[o.NotApplicable]:"info"}[t],i={[o.Passed]:"Check passed",[o.Failed]:"Check did not pass",[o.NotReported]:"Check not reported",[o.NotApplicable]:"Check not applicable"}[t];return e.createElement(y,{severity:r,title:i},n?e.createElement(P,{className:a.markdownContent,content:n}):null)},pe=()=>{const t=D();return e.createElement(B,null,e.createElement("div",{className:t.root,"data-testid":"check-details-view"},e.createElement("div",{className:t.topBar},e.createElement(f,{variant:"h2",className:t.title},e.createElement(s,{width:300,height:32})),e.createElement(s,{width:100,height:32})),e.createElement(s,{variant:"rect",height:120}),e.createElement("div",{"data-testid":"soundcheck-check-details-description"},e.createElement(f,{variant:"h3"},e.createElement(s,null)),e.createElement(s,null),e.createElement(s,null),e.createElement(s,null))))},D=p(t=>({root:{padding:`${t.spacing(3)}px ${t.spacing(5)}px`},title:{fontWeight:"normal",fontSize:t.typography.h5.fontSize},description:{padding:`${t.spacing(3)}px 0`},subtitle:{fontWeight:"normal",fontSize:t.typography.h6.fontSize},topBar:{display:"flex",justifyContent:"space-between",marginBottom:t.spacing(2)}})),ue=({programId:t,checkId:n})=>{const a=D(),{entity:r}=u(),{data:i,isLoading:l,isError:c}=se(r,t,n);if(c)return e.createElement(U,{padding:2},e.createElement(y,{severity:"error",title:"Error loading check details"}));if(l||!t||!n)return e.createElement(pe,null);if(!i)return null;const{name:h,description:d,result:v,timestamp:m,notes:E}=i;return e.createElement("div",{className:a.root,"data-testid":"check-details-view"},e.createElement("div",{className:a.topBar},e.createElement(f,{variant:"h2",className:a.title},h),m?e.createElement(J,{timestamp:m,description:"Last updated"}):null),e.createElement(de,{state:v,notes:E}),e.createElement("div",{className:a.description,"data-testid":"soundcheck-check-details-description"},e.createElement(f,{variant:"h3",className:a.subtitle},"Description"),e.createElement(P,{content:d})))},he=p(()=>({root:{position:"absolute",width:"100%",height:"100%"}})),Ee=({programId:t})=>{var n,a;const r=he(),{entity:i}=u(),{data:l,isLoading:c}=x(i,t),[h,{width:d,height:v}]=ce(),m=c?void 0:(a=(n=l==null?void 0:l.highestLevel)==null?void 0:n.ordinal)!=null?a:-1,E=A(m),R=A(t),[M,S]=W(!1);return $(()=>{typeof E!="undefined"&&typeof m!="undefined"&&t===R&&m>E&&S(!0)},[m,E,t,R]),M?e.createElement("div",{ref:h,className:r.root},e.createElement(oe,{width:d,height:v,numberOfPieces:1e3,gravity:1,initialVelocityY:20,recycle:!1,onConfettiComplete:()=>S(!1)})):null},z=p(t=>({root:{maxWidth:"80ch",textTransform:"uppercase",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)},wrapper:{display:"inline-block",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},badge:{marginRight:t.spacing(1)}})),fe=({id:t,name:n,badge:a,href:r,selected:i=!1})=>{const l=z();return e.createElement(L,{className:l.root,classes:{wrapper:l.wrapper},value:t,label:e.createElement(e.Fragment,null,a?e.createElement(K,{badge:a,className:l.badge}):e.createElement(X,{className:l.badge}),n),component:O,to:r,selected:i})},w=()=>{const t=z();return e.createElement(L,{className:t.root,classes:{wrapper:t.wrapper},label:e.createElement(s,{width:180})})},ge=()=>e.createElement(B,null,e.createElement(T,{value:!1,indicatorColor:"primary"},e.createElement(w,null),e.createElement(w,null),e.createElement(w,null)));function ve(t=[],n){const a=t.findIndex(r=>r.program.id===n);return a<0?!1:a}const ke=({trackId:t})=>{const{entity:n}=u(),{isLoading:a,data:r}=C(n),i=b(g);if(a||!t)return e.createElement(ge,null);const l=ve(r,t);return e.createElement(T,{value:l,indicatorColor:"primary","aria-label":"Certifications",variant:"scrollable"},r&&r.map(({program:{id:c,name:h},highestLevel:d})=>e.createElement(fe,{key:c,id:c,name:h,badge:d==null?void 0:d.badge,selected:c===t,href:i({trackId:c})})))},ye=p({paper:{overflow:"hidden",position:"relative"},view:{display:"grid",gridTemplateColumns:"1fr 2fr"}}),Ce=()=>{const{trackId:t,checkId:n}=Q(),a=ye(),{entity:r}=u(),{isError:i,isFetched:l,data:c}=C(r);return i?e.createElement(y,{severity:"error",title:"Error loading certifications"}):l&&!(c!=null&&c.length)?e.createElement(Z,null):e.createElement(V,{className:a.paper},e.createElement(G,null),e.createElement(ke,{trackId:t}),e.createElement(Y,null),e.createElement("div",{"data-testid":"soundcheck-certification-view",className:a.view},e.createElement(_,{trackId:t,checkId:n}),e.createElement(ue,{programId:t,checkId:n}),e.createElement(Ee,{programId:t})))},be=p(t=>({root:{"&:not(:first-child)":{marginTop:t.spacing(2)}}})),N=()=>{const t=be();return e.createElement(e.Fragment,null,e.createElement(q,{backend:ee,invalidLicenseMessage:te,inline:!0}),e.createElement("div",{className:t.root},e.createElement(Ce,null)))},we=()=>{var t;const{entity:n}=u(),a=b(g),{data:r}=C(n),i=(t=r==null?void 0:r[0])==null?void 0:t.program.id;return i?e.createElement(I,{to:a({trackId:i}),replace:!0}):null},Ne=()=>{var t,n;const{entity:a}=u(),{trackId:r}=ie(g),i=b(F),{data:l}=x(a,r),c=(n=(t=l==null?void 0:l.levels[0])==null?void 0:t.checks[0])==null?void 0:n.id;return c?e.createElement(I,{to:i({trackId:r,checkId:c}),replace:!0}):null},Re=()=>e.createElement(j,null,e.createElement(k,{path:"/",element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(we,null))}),e.createElement(k,{path:g.path,element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(Ne,null))}),e.createElement(k,{path:F.path,element:e.createElement(N,null)})),Se=()=>e.createElement(ae,null,e.createElement(Re,null));export{Se as EntitySoundcheckContent};
|
|
2
|
+
//# sourceMappingURL=EntitySoundcheckContent-61aee236.esm.js.map
|
package/dist/esm/{OverviewPageContent-7cf86a3a.esm.js → OverviewPageContent-31025374.esm.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{useState as I,useEffect as v,useMemo as O,useCallback as j,createContext as me,useContext as ue,memo as b,Fragment as ge}from"react";import{useSearchParams as he}from"react-router-dom";import{makeStyles as f,alpha as M,TextField as fe,CircularProgress as ye,Tooltip as K,LinearProgress as ve,withStyles as ke,Grid as C,Typography as k}from"@material-ui/core";import Ee from"@material-ui/lab/Autocomplete";import{stringifyEntityRef as W,parseEntityRef as w}from"@backstage/catalog-model";import{useApi as E,identityApiRef as U,useRouteRef as P,configApiRef as be}from"@backstage/core-plugin-api";import{useQuery as A}from"@tanstack/react-query";import{s as D,R as N,h as Ce,B as we,L as _,N as Q,A as Ne,d as Re,j as $e}from"./index-95ae147b.esm.js";import{catalogApiRef as G,humanizeEntityRef as T,entityRouteRef as F}from"@backstage/plugin-catalog-react";import xe from"react-use/lib/useAsync";import{HeaderTabs as q,MarkdownContent as Te,Link as B,EmptyState as Le}from"@backstage/core-components";import{R as Ie}from"./RefetchingIndicator-b042ec49.esm.js";import{countBy as J}from"lodash";import{Skeleton as S}from"@material-ui/lab";import{VariableSizeGrid as Oe}from"react-window";function X(e,r){const a=E(D);return A(["soundcheck/track-overview-for-owner",e,r],async()=>a.getProgramOverviewForOwner(e,r),{enabled:!!e&&!!(r!=null&&r.kind)})}function Y(){const e=E(G);return A(["soundcheck/all-groups"],async()=>{const{items:r}=await e.getEntities({filter:{kind:"Group"},fields:["spec.profile.displayName","metadata.title","metadata.name","metadata.namespace","kind"]});return r.filter(a=>(a==null?void 0:a.kind)==="Group").map(a=>{var n,l,i,s;return{name:(s=(i=(l=(n=a.spec)==null?void 0:n.profile)==null?void 0:l.displayName)!=null?i:a.metadata.title)!=null?s:a.metadata.name,ref:W(a)}})},{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Pe(){const e=E(U),r=E(G);return A(["soundcheck/user-groups-claims"],async()=>{const{ownershipEntityRefs:a}=await e.getBackstageIdentity();return(await r.getEntitiesByRefs({entityRefs:a})).items.filter(n=>(n==null?void 0:n.kind)==="Group").map(n=>{var l,i,s,c;return{name:(c=(s=(i=(l=n.spec)==null?void 0:l.profile)==null?void 0:i.displayName)!=null?s:n.metadata.title)!=null?c:n.metadata.name,ref:W(n)}})})}function Ae(e){const r=E(D);return A(["soundcheck/facets-for-owner",e],async()=>r.getFacetsForOwner(e),{enabled:!!e})}const Fe=()=>{const[e,r]=he(),a=Object.fromEntries(e.entries()),[n,l]=I(a);return v(()=>{r(n,{replace:!0})},[n]),[n,l]},Z=()=>{const{data:e,isLoading:r,isError:a}=Pe(),{data:n,isLoading:l,isError:i}=Y();return{options:O(()=>{const s=[];return e&&s.push(...e.map(({name:c,ref:o})=>({name:c,ref:o,key:"My Groups"}))),n&&s.push(...n.map(({name:c,ref:o})=>({name:c,ref:o,key:"All Groups"}))),s},[e,n]),isLoading:r||l,isError:a||i}},Be=f(e=>({root:{width:"100%",minWidth:250},textField:{"& $notchedOutline":{borderColor:M(e.page.fontColor,.25)},"&:hover $notchedOutline":{borderColor:e.page.fontColor}},input:{backgroundColor:"transparent",color:e.page.fontColor},clearIndicator:{color:e.page.fontColor},popupIndicator:{color:e.page.fontColor},notchedOutline:{}})),Se=e=>{const{onChange:r,initialValue:a,setError:n}=e,{options:l,isLoading:i,isError:s}=Z(),c=Be(),[o,d]=I(null);v(()=>{if(!i&&l!=null&&l.length&&!o){const m=a?l.find(p=>p.ref===a):l[0];m&&(d(m),r==null||r(m.ref))}},[i,l,o,r,a]);const u=j((m,p)=>{d(p),r==null||r(p==null?void 0:p.ref)},[r,d]);return v(()=>{n==null||n(s?new Error("Error loading groups"):void 0)},[s,n]),s?null:t.createElement(Ee,{"aria-label":"Current group",className:c.root,classes:{clearIndicator:c.clearIndicator,popupIndicator:c.popupIndicator},disableClearable:!0,options:l!=null?l:[],loading:i,groupBy:m=>m.key,value:o,freeSolo:!1,onChange:u,getOptionLabel:m=>m.name,renderInput:m=>t.createElement(fe,{...m,variant:"outlined",placeholder:i?"Loading":"Select a group",className:c.textField,InputProps:{...m.InputProps,className:c.input,classes:{notchedOutline:c.notchedOutline},endAdornment:t.createElement(t.Fragment,null,i?t.createElement(ye,{color:"inherit",size:20}):null,m.InputProps.endAdornment)}})})},ee={loading:!1},te=me(ee),ze=()=>ue(te),He=({children:e})=>{const[r,a]=I(ee),n=E(G),l=E(U),{value:i,loading:s,error:c}=xe(async()=>{const[{token:o},d]=await Promise.all([l.getCredentials(),l.getBackstageIdentity()]);return o?await n.getEntityByRef(d.userEntityRef):null},[n,l]);return v(()=>{if(i){const o=W(i);a({user:i,userEntityRef:o,loading:s,error:c})}else a({loading:s,error:c})},[i,s,c]),t.createElement(te.Provider,{value:r},e)},We=e=>({key:`skeleton${e}`,label:"",id:`skeleton${e}`}),Ge=()=>{const e=Array.from({length:4},(r,a)=>We(a));return t.createElement(q,{tabs:e})},Ve=f(e=>({root:{borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`},tab:{textTransform:"uppercase",paddingTop:e.spacing(2),paddingBottom:e.spacing(2)}})),je=({unfilteredFacets:e,onChange:r,kind:a,type:n})=>{var l,i,s;const c=Ve(),o={types:(l=e==null?void 0:e.types.filter(({count:p})=>p>0))!=null?l:[]},d=j(p=>{var g;r((g=o==null?void 0:o.types[p].kind)!=null?g:"",o==null?void 0:o.types[p].type)},[o==null?void 0:o.types,r]);v(()=>{var p,g,y;const h=(o==null?void 0:o.types)&&o.types.length>=0,L=!a&&h,H=a&&h&&!(o!=null&&o.types.find(({kind:$,type:x})=>a===$&&(!n&&!x||n===x)));(L||H)&&r((g=(p=o==null?void 0:o.types[0])==null?void 0:p.kind)!=null?g:"",(y=o==null?void 0:o.types[0])==null?void 0:y.type)},[a,n,o==null?void 0:o.types,r]);const u=(i=o==null?void 0:o.types.map(({kind:p,type:g,count:y})=>{const h=`${p}|${g!=null?g:""}`;return{key:h,label:`${g!=null?g:p} (${y>50?"50+":y})`,id:h,tabProps:{className:c.tab}}}))!=null?i:[];if(!u.length)return null;const m=(s=o==null?void 0:o.types.findIndex(p=>p.kind===a&&(!p.type&&!n||p.type===n)))!=null?s:-1;return t.createElement(t.Fragment,null,t.createElement(Ie,null),t.createElement(q,{onChange:d,tabs:u,selectedIndex:m>-1?m:void 0}))},Me=f(e=>({root:{height:"8px",minWidth:"64px",marginLeft:e.spacing(2),borderRadius:"100vh",backgroundColor:e.palette.background.default},bar:{backgroundColor:e.palette.success.main,transition:"none"}})),re=e=>{var r,a;const n=Me(e),l=O(()=>Object.entries(e.progress).reduce((s,[,c])=>s+c,0),[e.progress]);if(l===0)return null;const i=(r=e.progress[N.Passed])!=null?r:0;return t.createElement(K,{arrow:!0,title:`Check passing for ${i} of ${l} ${l===1?"entity":"entities"}`,enterDelay:0,placement:"top"},t.createElement(ve,{variant:"determinate",value:((a=e.progress[N.Passed])!=null?a:0)/l*100,classes:{root:n.root,bar:n.bar}}))},Ke=f(e=>({headerWrapper:{marginTop:e.spacing(.5)},entityRefName:{fontWeight:"bold"},iconWrapper:{padding:e.spacing(1.5,.5),display:"flex",alignItems:"center",justifyContent:"center"}})),Ue=({check:{name:e,description:r},icon:a,entityRef:n})=>{const l=Ke(),i=w(n);return t.createElement(C,{spacing:1},t.createElement(C,{container:!0,direction:"row",spacing:1,wrap:"nowrap"},t.createElement("div",{className:l.iconWrapper},a),t.createElement(k,{variant:"h6",className:l.headerWrapper,noWrap:!0},e)),t.createElement(C,{item:!0,wrap:"nowrap"},t.createElement(k,{variant:"subtitle2",className:l.entityRefName},T(i,{defaultKind:i.kind}))),t.createElement(Te,{content:r}))},De=ke(e=>{const r=e.palette.type==="dark"?e.palette.common.black:e.palette.grey[300];return{tooltip:{backgroundColor:r,color:e.palette.type==="dark"?e.palette.common.white:e.palette.grey[700]},arrow:{color:r}}})(K),_e=({children:e,check:r,icon:a,entityRef:n})=>t.createElement(De,{arrow:!0,title:t.createElement(Ue,{check:r,icon:a,entityRef:n}),enterDelay:150,placement:"top"},e),Qe=f(e=>({root:{padding:0},iconWrapper:{padding:e.spacing(1.5),display:"flex",alignItems:"center",justifyContent:"center"},link:{"&:hover $iconWrapper, &:active $iconWrapper, &:focus $iconWrapper":{backgroundColor:e.palette.infoBackground}},icon:{width:"17px",height:"17px"},virtualized:{borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),ae=b(({programId:e,check:r,entityRef:a,result:n,entityRoute:l,isVirtualized:i})=>{const s=Qe();if(typeof a!="string"){const u=t.createElement("div",{className:s.iconWrapper},t.createElement("div",{className:s.icon}));return i?t.createElement("div",{className:`${s.root} ${s.virtualized}`,"aria-hidden":!0},u):t.createElement("td",{className:s.root,"aria-hidden":!0},u)}const c=t.createElement(Ce,{className:s.icon,result:n!=null?n:N.NotReported}),o=t.createElement("div",{className:s.iconWrapper},c),d=n&&n===N.NotApplicable?o:t.createElement(B,{className:s.link,to:`${l(w(a))}/soundcheck/${e}/${r.id}`},o);return i?t.createElement("div",{className:`${s.root} ${s.virtualized}`},t.createElement(_e,{check:r,icon:c,entityRef:a},d)):t.createElement("td",{className:`${s.root}`},d)}),ne=8,qe=16,R={programTitle:70,levelTitle:30,check:42,entityRefFooter:100},z={programTitle:350+qe*2,checkResult:42},Je=e=>e.reduce((r,a)=>r+a.height,0),Xe=e=>e*z.checkResult+z.programTitle,Ye=e=>e.filter(r=>r!==void 0).map(r=>{const a=w(r);return T(a,{defaultKind:a.kind})}).reduce((r,a)=>r.length>a.length?r:a,""),Ze=e=>ne*e+ne,le="NoLevel",et=e=>({name:le,badge:{options:{level:0,color:""},variant:we.Medal},entityRef:e,ordinal:0}),oe=f(e=>({checkNameCell:{padding:0,backgroundColor:e.palette.background.paper},checkNameContent:{padding:`0 ${e.spacing(2)}px`,display:"flex",justifyContent:"space-between",alignItems:"center"},checkNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},checkIndicator:{flexBasis:e.spacing(8)},checkNameCellVirtualized:{height:`${R.check}px`,lineHeight:`${R.check}px`,borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),tt=b(({programId:e,programName:r,check:a,entityRefs:n,results:l,entityRoute:i})=>{const s=oe(),c=O(()=>J(l.filter(({result:d})=>d!==N.NotApplicable),"result"),[l]),o=new Map(l.map(d=>[d.entityRef,d.result]));return t.createElement("tr",{"data-testid":"track-check-row"},t.createElement("th",{scope:"row",className:s.checkNameCell,"aria-label":`${a.name} check for ${r} track`},t.createElement("div",{className:s.checkNameContent},t.createElement(k,{className:s.checkNameTypography,variant:"subtitle2",component:"p"},a.name),t.createElement(re,{className:s.checkIndicator,progress:c}))),n.map((d,u)=>t.createElement(ae,{key:u,programId:e,check:a,entityRef:d,result:typeof d=="string"?o.get(d):void 0,entityRoute:i})))}),rt=({name:e,progress:r})=>{const a=oe();return t.createElement("div",{className:a.checkNameCell,"aria-label":`${e} check`},t.createElement("div",{className:`${a.checkNameContent} ${a.checkNameCellVirtualized}`},t.createElement(k,{variant:"subtitle2",component:"p",className:a.checkNameTypography},e),t.createElement(re,{className:a.checkIndicator,progress:r})))},at=f(e=>({virtualized:{borderRight:`1px solid ${e.palette.divider}`,height:`${R.programTitle}px`,display:"flex",justifyContent:"center",alignItems:"center"}})),nt=b(({entityRef:e,highestLevels:r})=>{const a=r.find(n=>n.entityRef===e);return t.createElement(t.Fragment,null,a!=null&&a.badge?t.createElement(_,{badge:a.badge}):t.createElement(Q,null))}),lt=({highestLevel:e})=>{const r=at();if(!(e!=null&&e.badge))return t.createElement("div",{className:r.virtualized},"\xA0");const a=e.name!==le;return t.createElement("div",{className:r.virtualized},a?t.createElement(_,{badge:e.badge}):t.createElement(Q,null))},ie=f(e=>({programNameCell:{padding:0,position:"sticky",backgroundColor:e.palette.background.paper},programNameContent:{padding:e.spacing(2)},programNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},badgeCellContent:{display:"flex",justifyContent:"center",alignItems:"center"},programNameCellVirtualized:{borderRight:`1px solid ${e.palette.divider}`}})),ot=b(({program:e,entityRefs:r,highestLevels:a})=>{const n=ie();return t.createElement("tr",{"data-testid":"track-title-row"},t.createElement("th",{scope:"row",className:n.programNameCell},t.createElement("div",{className:n.programNameContent},t.createElement(k,{className:n.programNameTypography,variant:"h5",component:"p"},e.name))),r.map((l,i)=>typeof l!="string"?t.createElement("td",{key:i,"aria-hidden":!0}):t.createElement("td",{key:i,"data-testid":"track-certification-cell"},t.createElement("div",{className:n.badgeCellContent},t.createElement(nt,{entityRef:l,highestLevels:a})))))}),it=b(({name:e})=>{const r=ie();return t.createElement("div",{className:`${r.programNameCell} ${r.programNameCellVirtualized}`},t.createElement("div",{className:r.programNameContent},t.createElement(k,{className:r.programNameTypography,variant:"h5",component:"p"},e)))}),V=f(e=>{const r=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{root:{color:M(e.palette.getContrastText(r),.8),backgroundColor:r},levelContent:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,backgroundColor:r},levelTypography:{overflow:"hidden",textOverflow:"ellipsis"},levelHeaderCell:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,borderRight:`1px solid ${e.palette.divider}`,height:`${R.levelTitle}px`}}}),st=b(({level:e,entityRefs:r,programName:a})=>{const n=V();return t.createElement("tr",{className:n.root,"data-testid":"track-level-row"},t.createElement("th",{scope:"row",className:n.root},t.createElement("div",{className:n.levelContent},t.createElement(k,{className:n.levelTypography,variant:"subtitle2",component:"p","aria-label":`${e.name} for ${a} track`},e.name))),r.map((l,i)=>t.createElement("td",{key:i,className:n.root,"aria-hidden":!0})))}),ct=({name:e})=>{const r=V();return t.createElement("div",{className:`${r.levelHeaderCell} ${r.root}`,"aria-label":`${e}`},t.createElement(k,{variant:"subtitle2",component:"p",className:r.levelTypography},e))},dt=()=>{const e=V();return t.createElement("div",{className:`${e.levelHeaderCell} ${e.root}`},"\xA0")},pt=({program:e,highestLevels:r,levels:a,entityRefs:n,entityRoute:l})=>t.createElement("tbody",null,t.createElement(ot,{program:e,entityRefs:n,highestLevels:r}),a.map((i,s)=>t.createElement(ge,{key:s},t.createElement(st,{entityRefs:n,level:i,programName:e.name}),i.checks.map(({check:c,results:o},d)=>t.createElement(tt,{key:d,check:c,programId:e.id,programName:e.name,entityRefs:n,results:o,entityRoute:l}))))),se=f(e=>({root:{position:"sticky",bottom:"-1px",backgroundColor:e.palette.background.default,boxShadow:`0 -1px ${e.palette.divider}`,"& td$cell, & th$cell":{border:0,padding:e.spacing(1)},"& td$cell":{backgroundColor:e.palette.background.default}},row:{boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`},cell:{verticalAlign:"top"},cellInner:{textOrientation:"mixed",writingMode:"vertical-lr",transform:"rotate(-20deg)",transformOrigin:`100% ${e.spacing(1)}px`,wordBreak:"keep-all",fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",maxHeight:"max(15vh, 175px)"}})),mt=({entityRefs:e})=>{const r=P(F),a=se();return t.createElement("tfoot",{className:a.root,"data-testid":"results-table-footer"},t.createElement("tr",{className:a.row},t.createElement("td",{className:a.cell}),e.map((n,l)=>{if(typeof n!="string")return t.createElement("th",{key:l,className:a.cell,"aria-hidden":!0});const i=w(n);return t.createElement("th",{scope:"col",key:l,className:a.cell},t.createElement("div",{className:a.cellInner},t.createElement(B,{to:r(i)},T(i,{defaultKind:i.kind}))))})))},ut=({entityRef:e})=>{const r=P(F),a=se(),n=e?w(e):void 0,l=n?t.createElement(B,{to:r(n)},T(n,{defaultKind:n.kind})):t.createElement(t.Fragment,null);return t.createElement("div",{className:a.cell},t.createElement("div",{className:a.cellInner},l))},gt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},paddingBottom:e.spacing(2)},programTitle:{padding:e.spacing(2)},checkResult:{padding:e.spacing(1.5)},title:{padding:`${e.spacing(1)}px ${e.spacing(2)}px`},header:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100]}})),ce=()=>{const e=gt(),r=new Array(25).fill(void 0),a=new Array(5).fill(void 0),n=new Array(3).fill(void 0);return t.createElement("table",{className:e.table},t.createElement("tbody",null,t.createElement("tr",null,t.createElement("td",{className:e.programTitle},t.createElement(S,{width:180,height:40})),r.map((l,i)=>t.createElement("td",{key:i}))),n.map((l,i)=>t.createElement(t.Fragment,{key:i},t.createElement("tr",{className:e.header},t.createElement("td",{className:e.title},t.createElement(S,{width:180})),r.map((s,c)=>t.createElement("td",{key:c}))),a.map((s,c)=>t.createElement("tr",{key:c},t.createElement("td",{className:e.title},t.createElement(S,{width:240})),r.map((o,d)=>t.createElement("td",{key:d,className:e.checkResult},t.createElement(S,{width:18,height:18,variant:"rect"})))))))))},ht=f(e=>({root:{width:"100%"},table:{overflow:"auto",backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},"& th:first-of-type":{position:"sticky",left:0,zIndex:1,maxWidth:"60ch"},"& tfoot":{bottom:0,zIndex:1e3},"& tbody td:first-of-type":{border:`1px solid ${e.palette.divider}`,boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`}}})),ft=b(e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,i=ht(),s=P(F),{data:c,isLoading:o,isError:d}=X(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading track overview"):void 0)},[d,r]),o)return t.createElement(ce,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c;if(!o&&!u.length)return t.createElement(Le,{missing:"data",title:"Missing tracks",description:t.createElement(t.Fragment,null,"Looks like the group"," ",T(w(l),{defaultKind:"Group"})," ","doesn't own any ",n!=null?n:a," components that have Soundcheck tracks set up.",t.createElement("br",null),t.createElement("br",null),"If you're an administrator, you can learn more about configuring and filtering tracks in the"," ",t.createElement(B,{to:"https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#entity-filter"},"docs"),".")});if(d)return null;const p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})];return t.createElement("div",{className:i.root},t.createElement("table",{className:i.table,"aria-label":"Check results"},u.map(({program:g,levels:y,highestLevels:h},L)=>t.createElement(pt,{key:L,program:g,entityRefs:p,levels:y,highestLevels:h,entityRoute:s})),t.createElement(mt,{entityRefs:p})))}),yt=e=>t.createElement(it,{name:e}),vt=e=>({type:"ProgramHeader",render:()=>yt(e)}),kt=e=>e?t.createElement(ct,{name:e}):t.createElement(dt,null),de=e=>({type:"LevelHeader",render:()=>kt(e)}),Et=(e,r)=>t.createElement(rt,{name:e,progress:r}),bt=(e,r)=>({type:"CheckTitle",render:()=>Et(e,r)}),Ct=(e,r,a,n,l)=>t.createElement(ae,{check:r,entityRef:a,entityRoute:l,programId:e,result:n,isVirtualized:!0}),wt=(e,r,a,n,l)=>({type:"CheckResult",render:()=>Ct(e,r,a,n,l)}),Nt=e=>t.createElement(ut,{entityRef:e}),pe=e=>({type:"EntityHeader",render:()=>Nt(e)}),Rt=e=>t.createElement(lt,{highestLevel:e}),$t=e=>({type:"LevelBadge",render:()=>Rt(e)}),xt=e=>r=>{const a=e[r.rowIndex].cells[r.columnIndex];return a?t.createElement("div",{style:r.style},a.render()):t.createElement("div",{style:r.style})},Tt=(e,r,a)=>{var n;const l=[];for(const{program:s,levels:c,highestLevels:o}of e){l.push({height:R.programTitle,cells:[vt(s.name),...r.map(d=>{const u=d?o.find(m=>m.entityRef===d)||et(d):void 0;return $t(u)})]});for(const d of c){l.push({height:R.levelTitle,cells:[de(d.name),...r.map(u=>de(""))]});for(const{check:u,results:m}of d.checks)l.push({height:R.check,cells:[bt(u.name,J(m.filter(({result:p})=>p!==N.NotApplicable),"result")),...r.map(p=>{var g,y;return wt(s.id,u,p,(y=(g=m.find(h=>h.entityRef===p))==null?void 0:g.result)!=null?y:N.NotApplicable,a)})]})}}const i=Ye(r!=null?r:[]);return l.push({height:Ze((n=i.length)!=null?n:1),cells:[pe(""),...r.map(s=>pe(s||""))]}),l},Lt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left",overflow:"auto"}})),It=e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,i=Lt(),s=P(F),{data:c,isLoading:o,isError:d}=X(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading program overview"):void 0)},[d,r]),o)return t.createElement(ce,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c,p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})],g=Tt(u,p,s),y=xt(g);return t.createElement(C,{"aria-label":`Check results for ${n!=null?n:a}`,key:`${a}|${n!=null?n:""}`,item:!0,xs:12},t.createElement(Oe,{className:i.table,columnCount:p.length+1,columnWidth:h=>h===0?z.programTitle:z.checkResult,rowCount:g.length,rowHeight:h=>g[h].height,height:Je(g),width:Xe(p.length)},y))},Ot=({facets:e,ownerEntityRef:r,kind:a,type:n,setError:l})=>{const i=O(()=>{const s=new Map;return e.types.forEach(({kind:c,type:o})=>{const d=`${c}|${o!=null?o:""}`;s.set(d,t.createElement(It,{key:d,ownerEntityRef:r,kind:c,type:o,setError:l}))}),s},[e,r,l]);return t.createElement("div",null,i.get(`${a}|${n!=null?n:""}`))},Pt=f(()=>({scrollContainer:{overflow:"auto"}})),At=({facets:e,ownerEntityRef:r,hasError:a,kind:n,type:l,setError:i,useVirtualizedResultsTable:s,isFixedGroup:c})=>{var o,d,u;const m=Pt();if(a)return t.createElement(Ne,{severity:"error",title:a.message});const p="Use the groups drop-down list at the top-right of the page to select another group.";return e&&((d=(o=e.types)==null?void 0:o.length)!=null?d:0)>0?(u=e.types)!=null&&u.find(g=>g.count>0)?t.createElement("div",{className:m.scrollContainer},s?t.createElement(Ot,{facets:e,kind:n,type:l,setError:i,ownerEntityRef:r,hasError:a}):t.createElement(ft,{ownerEntityRef:r,kind:n,type:l,setError:i})):t.createElement(Re,{description:t.createElement(t.Fragment,null,"Looks like the group '",T(w(r),{defaultKind:"Group"}),"' doesn't own any entities that have any applicable tracks configured.",!c&&t.createElement(t.Fragment,null,t.createElement("br",null),t.createElement("br",null),p))}):t.createElement($e,{ownerEntityRef:r,selectGroupHint:c?void 0:p})},Ft=f(()=>({tableContainer:{padding:0,backgroundColor:"transparent"}})),Bt=({groupSelectorError:e,searchParams:r,setSearchParams:a,isFixedGroup:n=!1})=>{var l;const{group:i,kind:s,type:c}=r,[o,d]=I(void 0),[u,m]=I(void 0);v(()=>{((o==null?void 0:o.kind)!==s||(o==null?void 0:o.type)!==c)&&d({kind:s,type:c})},[s,c,o]);const{data:p,isLoading:g}=Ae(i),y=(l=E(be).getOptionalBoolean("soundcheck.virtualizeOverviewPage"))!=null?l:!0,h=u||e,L=($,x)=>{$&&(d({kind:$,type:x}),x?a({...r,kind:$,type:x}):(r!=null&&r.hasOwnProperty("type")&&delete r.type,a({...r,kind:$})))},H=Ft();return t.createElement(C,{container:!0,spacing:0},t.createElement(C,{item:!0,xs:12},g?t.createElement(Ge,null):t.createElement(je,{unfilteredFacets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,onChange:L})),t.createElement(C,{item:!0,xs:12,className:H.tableContainer},!g&&t.createElement(At,{facets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,setError:m,hasError:h,ownerEntityRef:i,useVirtualizedResultsTable:y,isFixedGroup:n})))};export{Se as G,Bt as O,He as U,Z as a,ze as b,Y as c,Fe as u};
|
|
2
|
-
//# sourceMappingURL=OverviewPageContent-
|
|
1
|
+
import t,{useState as I,useEffect as v,useMemo as O,useCallback as j,createContext as me,useContext as ue,memo as b,Fragment as ge}from"react";import{useSearchParams as he}from"react-router-dom";import{makeStyles as f,alpha as M,TextField as fe,CircularProgress as ye,Tooltip as K,LinearProgress as ve,withStyles as ke,Grid as C,Typography as k}from"@material-ui/core";import Ee from"@material-ui/lab/Autocomplete";import{stringifyEntityRef as W,parseEntityRef as w}from"@backstage/catalog-model";import{useApi as E,identityApiRef as U,useRouteRef as P,configApiRef as be}from"@backstage/core-plugin-api";import{useQuery as A}from"@tanstack/react-query";import{s as D,R as N,h as Ce,B as we,L as _,N as Q,A as Ne,d as Re,j as $e}from"./index-7b347cd4.esm.js";import{catalogApiRef as G,humanizeEntityRef as T,entityRouteRef as F}from"@backstage/plugin-catalog-react";import xe from"react-use/lib/useAsync";import{HeaderTabs as q,MarkdownContent as Te,Link as B,EmptyState as Le}from"@backstage/core-components";import{R as Ie}from"./RefetchingIndicator-e114bc04.esm.js";import{countBy as J}from"lodash";import{Skeleton as S}from"@material-ui/lab";import{VariableSizeGrid as Oe}from"react-window";function X(e,r){const a=E(D);return A(["soundcheck/track-overview-for-owner",e,r],async()=>a.getProgramOverviewForOwner(e,r),{enabled:!!e&&!!(r!=null&&r.kind)})}function Y(){const e=E(G);return A(["soundcheck/all-groups"],async()=>{const{items:r}=await e.getEntities({filter:{kind:"Group"},fields:["spec.profile.displayName","metadata.title","metadata.name","metadata.namespace","kind"]});return r.filter(a=>(a==null?void 0:a.kind)==="Group").map(a=>{var n,l,i,s;return{name:(s=(i=(l=(n=a.spec)==null?void 0:n.profile)==null?void 0:l.displayName)!=null?i:a.metadata.title)!=null?s:a.metadata.name,ref:W(a)}})},{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Pe(){const e=E(U),r=E(G);return A(["soundcheck/user-groups-claims"],async()=>{const{ownershipEntityRefs:a}=await e.getBackstageIdentity();return(await r.getEntitiesByRefs({entityRefs:a})).items.filter(n=>(n==null?void 0:n.kind)==="Group").map(n=>{var l,i,s,c;return{name:(c=(s=(i=(l=n.spec)==null?void 0:l.profile)==null?void 0:i.displayName)!=null?s:n.metadata.title)!=null?c:n.metadata.name,ref:W(n)}})})}function Ae(e){const r=E(D);return A(["soundcheck/facets-for-owner",e],async()=>r.getFacetsForOwner(e),{enabled:!!e})}const Fe=()=>{const[e,r]=he(),a=Object.fromEntries(e.entries()),[n,l]=I(a);return v(()=>{r(n,{replace:!0})},[n]),[n,l]},Z=()=>{const{data:e,isLoading:r,isError:a}=Pe(),{data:n,isLoading:l,isError:i}=Y();return{options:O(()=>{const s=[];return e&&s.push(...e.map(({name:c,ref:o})=>({name:c,ref:o,key:"My Groups"}))),n&&s.push(...n.map(({name:c,ref:o})=>({name:c,ref:o,key:"All Groups"}))),s},[e,n]),isLoading:r||l,isError:a||i}},Be=f(e=>({root:{width:"100%",minWidth:250},textField:{"& $notchedOutline":{borderColor:M(e.page.fontColor,.25)},"&:hover $notchedOutline":{borderColor:e.page.fontColor}},input:{backgroundColor:"transparent",color:e.page.fontColor},clearIndicator:{color:e.page.fontColor},popupIndicator:{color:e.page.fontColor},notchedOutline:{}})),Se=e=>{const{onChange:r,initialValue:a,setError:n}=e,{options:l,isLoading:i,isError:s}=Z(),c=Be(),[o,d]=I(null);v(()=>{if(!i&&l!=null&&l.length&&!o){const m=a?l.find(p=>p.ref===a):l[0];m&&(d(m),r==null||r(m.ref))}},[i,l,o,r,a]);const u=j((m,p)=>{d(p),r==null||r(p==null?void 0:p.ref)},[r,d]);return v(()=>{n==null||n(s?new Error("Error loading groups"):void 0)},[s,n]),s?null:t.createElement(Ee,{"aria-label":"Current group",className:c.root,classes:{clearIndicator:c.clearIndicator,popupIndicator:c.popupIndicator},disableClearable:!0,options:l!=null?l:[],loading:i,groupBy:m=>m.key,value:o,freeSolo:!1,onChange:u,getOptionLabel:m=>m.name,renderInput:m=>t.createElement(fe,{...m,variant:"outlined",placeholder:i?"Loading":"Select a group",className:c.textField,InputProps:{...m.InputProps,className:c.input,classes:{notchedOutline:c.notchedOutline},endAdornment:t.createElement(t.Fragment,null,i?t.createElement(ye,{color:"inherit",size:20}):null,m.InputProps.endAdornment)}})})},ee={loading:!1},te=me(ee),ze=()=>ue(te),He=({children:e})=>{const[r,a]=I(ee),n=E(G),l=E(U),{value:i,loading:s,error:c}=xe(async()=>{const[{token:o},d]=await Promise.all([l.getCredentials(),l.getBackstageIdentity()]);return o?await n.getEntityByRef(d.userEntityRef):null},[n,l]);return v(()=>{if(i){const o=W(i);a({user:i,userEntityRef:o,loading:s,error:c})}else a({loading:s,error:c})},[i,s,c]),t.createElement(te.Provider,{value:r},e)},We=e=>({key:`skeleton${e}`,label:"",id:`skeleton${e}`}),Ge=()=>{const e=Array.from({length:4},(r,a)=>We(a));return t.createElement(q,{tabs:e})},Ve=f(e=>({root:{borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`},tab:{textTransform:"uppercase",paddingTop:e.spacing(2),paddingBottom:e.spacing(2)}})),je=({unfilteredFacets:e,onChange:r,kind:a,type:n})=>{var l,i,s;const c=Ve(),o={types:(l=e==null?void 0:e.types.filter(({count:p})=>p>0))!=null?l:[]},d=j(p=>{var g;r((g=o==null?void 0:o.types[p].kind)!=null?g:"",o==null?void 0:o.types[p].type)},[o==null?void 0:o.types,r]);v(()=>{var p,g,y;const h=(o==null?void 0:o.types)&&o.types.length>=0,L=!a&&h,H=a&&h&&!(o!=null&&o.types.find(({kind:$,type:x})=>a===$&&(!n&&!x||n===x)));(L||H)&&r((g=(p=o==null?void 0:o.types[0])==null?void 0:p.kind)!=null?g:"",(y=o==null?void 0:o.types[0])==null?void 0:y.type)},[a,n,o==null?void 0:o.types,r]);const u=(i=o==null?void 0:o.types.map(({kind:p,type:g,count:y})=>{const h=`${p}|${g!=null?g:""}`;return{key:h,label:`${g!=null?g:p} (${y>50?"50+":y})`,id:h,tabProps:{className:c.tab}}}))!=null?i:[];if(!u.length)return null;const m=(s=o==null?void 0:o.types.findIndex(p=>p.kind===a&&(!p.type&&!n||p.type===n)))!=null?s:-1;return t.createElement(t.Fragment,null,t.createElement(Ie,null),t.createElement(q,{onChange:d,tabs:u,selectedIndex:m>-1?m:void 0}))},Me=f(e=>({root:{height:"8px",minWidth:"64px",marginLeft:e.spacing(2),borderRadius:"100vh",backgroundColor:e.palette.background.default},bar:{backgroundColor:e.palette.success.main,transition:"none"}})),re=e=>{var r,a;const n=Me(e),l=O(()=>Object.entries(e.progress).reduce((s,[,c])=>s+c,0),[e.progress]);if(l===0)return null;const i=(r=e.progress[N.Passed])!=null?r:0;return t.createElement(K,{arrow:!0,title:`Check passing for ${i} of ${l} ${l===1?"entity":"entities"}`,enterDelay:0,placement:"top"},t.createElement(ve,{variant:"determinate",value:((a=e.progress[N.Passed])!=null?a:0)/l*100,classes:{root:n.root,bar:n.bar}}))},Ke=f(e=>({headerWrapper:{marginTop:e.spacing(.5)},entityRefName:{fontWeight:"bold"},iconWrapper:{padding:e.spacing(1.5,.5),display:"flex",alignItems:"center",justifyContent:"center"}})),Ue=({check:{name:e,description:r},icon:a,entityRef:n})=>{const l=Ke(),i=w(n);return t.createElement(C,{spacing:1},t.createElement(C,{container:!0,direction:"row",spacing:1,wrap:"nowrap"},t.createElement("div",{className:l.iconWrapper},a),t.createElement(k,{variant:"h6",className:l.headerWrapper,noWrap:!0},e)),t.createElement(C,{item:!0,wrap:"nowrap"},t.createElement(k,{variant:"subtitle2",className:l.entityRefName},T(i,{defaultKind:i.kind}))),t.createElement(Te,{content:r}))},De=ke(e=>{const r=e.palette.type==="dark"?e.palette.common.black:e.palette.grey[300];return{tooltip:{backgroundColor:r,color:e.palette.type==="dark"?e.palette.common.white:e.palette.grey[700]},arrow:{color:r}}})(K),_e=({children:e,check:r,icon:a,entityRef:n})=>t.createElement(De,{arrow:!0,title:t.createElement(Ue,{check:r,icon:a,entityRef:n}),enterDelay:150,placement:"top"},e),Qe=f(e=>({root:{padding:0},iconWrapper:{padding:e.spacing(1.5),display:"flex",alignItems:"center",justifyContent:"center"},link:{"&:hover $iconWrapper, &:active $iconWrapper, &:focus $iconWrapper":{backgroundColor:e.palette.infoBackground}},icon:{width:"17px",height:"17px"},virtualized:{borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),ae=b(({programId:e,check:r,entityRef:a,result:n,entityRoute:l,isVirtualized:i})=>{const s=Qe();if(typeof a!="string"){const u=t.createElement("div",{className:s.iconWrapper},t.createElement("div",{className:s.icon}));return i?t.createElement("div",{className:`${s.root} ${s.virtualized}`,"aria-hidden":!0},u):t.createElement("td",{className:s.root,"aria-hidden":!0},u)}const c=t.createElement(Ce,{className:s.icon,result:n!=null?n:N.NotReported}),o=t.createElement("div",{className:s.iconWrapper},c),d=n&&n===N.NotApplicable?o:t.createElement(B,{className:s.link,to:`${l(w(a))}/soundcheck/${e}/${r.id}`},o);return i?t.createElement("div",{className:`${s.root} ${s.virtualized}`},t.createElement(_e,{check:r,icon:c,entityRef:a},d)):t.createElement("td",{className:`${s.root}`},d)}),ne=8,qe=16,R={programTitle:70,levelTitle:30,check:42,entityRefFooter:100},z={programTitle:350+qe*2,checkResult:42},Je=e=>e.reduce((r,a)=>r+a.height,0),Xe=e=>e*z.checkResult+z.programTitle,Ye=e=>e.filter(r=>r!==void 0).map(r=>{const a=w(r);return T(a,{defaultKind:a.kind})}).reduce((r,a)=>r.length>a.length?r:a,""),Ze=e=>ne*e+ne,le="NoLevel",et=e=>({name:le,badge:{options:{level:0,color:""},variant:we.Medal},entityRef:e,ordinal:0}),oe=f(e=>({checkNameCell:{padding:0,backgroundColor:e.palette.background.paper},checkNameContent:{padding:`0 ${e.spacing(2)}px`,display:"flex",justifyContent:"space-between",alignItems:"center"},checkNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},checkIndicator:{flexBasis:e.spacing(8)},checkNameCellVirtualized:{height:`${R.check}px`,lineHeight:`${R.check}px`,borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),tt=b(({programId:e,programName:r,check:a,entityRefs:n,results:l,entityRoute:i})=>{const s=oe(),c=O(()=>J(l.filter(({result:d})=>d!==N.NotApplicable),"result"),[l]),o=new Map(l.map(d=>[d.entityRef,d.result]));return t.createElement("tr",{"data-testid":"track-check-row"},t.createElement("th",{scope:"row",className:s.checkNameCell,"aria-label":`${a.name} check for ${r} track`},t.createElement("div",{className:s.checkNameContent},t.createElement(k,{className:s.checkNameTypography,variant:"subtitle2",component:"p"},a.name),t.createElement(re,{className:s.checkIndicator,progress:c}))),n.map((d,u)=>t.createElement(ae,{key:u,programId:e,check:a,entityRef:d,result:typeof d=="string"?o.get(d):void 0,entityRoute:i})))}),rt=({name:e,progress:r})=>{const a=oe();return t.createElement("div",{className:a.checkNameCell,"aria-label":`${e} check`},t.createElement("div",{className:`${a.checkNameContent} ${a.checkNameCellVirtualized}`},t.createElement(k,{variant:"subtitle2",component:"p",className:a.checkNameTypography},e),t.createElement(re,{className:a.checkIndicator,progress:r})))},at=f(e=>({virtualized:{borderRight:`1px solid ${e.palette.divider}`,height:`${R.programTitle}px`,display:"flex",justifyContent:"center",alignItems:"center"}})),nt=b(({entityRef:e,highestLevels:r})=>{const a=r.find(n=>n.entityRef===e);return t.createElement(t.Fragment,null,a!=null&&a.badge?t.createElement(_,{badge:a.badge}):t.createElement(Q,null))}),lt=({highestLevel:e})=>{const r=at();if(!(e!=null&&e.badge))return t.createElement("div",{className:r.virtualized},"\xA0");const a=e.name!==le;return t.createElement("div",{className:r.virtualized},a?t.createElement(_,{badge:e.badge}):t.createElement(Q,null))},ie=f(e=>({programNameCell:{padding:0,position:"sticky",backgroundColor:e.palette.background.paper},programNameContent:{padding:e.spacing(2)},programNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},badgeCellContent:{display:"flex",justifyContent:"center",alignItems:"center"},programNameCellVirtualized:{borderRight:`1px solid ${e.palette.divider}`}})),ot=b(({program:e,entityRefs:r,highestLevels:a})=>{const n=ie();return t.createElement("tr",{"data-testid":"track-title-row"},t.createElement("th",{scope:"row",className:n.programNameCell},t.createElement("div",{className:n.programNameContent},t.createElement(k,{className:n.programNameTypography,variant:"h5",component:"p"},e.name))),r.map((l,i)=>typeof l!="string"?t.createElement("td",{key:i,"aria-hidden":!0}):t.createElement("td",{key:i,"data-testid":"track-certification-cell"},t.createElement("div",{className:n.badgeCellContent},t.createElement(nt,{entityRef:l,highestLevels:a})))))}),it=b(({name:e})=>{const r=ie();return t.createElement("div",{className:`${r.programNameCell} ${r.programNameCellVirtualized}`},t.createElement("div",{className:r.programNameContent},t.createElement(k,{className:r.programNameTypography,variant:"h5",component:"p"},e)))}),V=f(e=>{const r=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{root:{color:M(e.palette.getContrastText(r),.8),backgroundColor:r},levelContent:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,backgroundColor:r},levelTypography:{overflow:"hidden",textOverflow:"ellipsis"},levelHeaderCell:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,borderRight:`1px solid ${e.palette.divider}`,height:`${R.levelTitle}px`}}}),st=b(({level:e,entityRefs:r,programName:a})=>{const n=V();return t.createElement("tr",{className:n.root,"data-testid":"track-level-row"},t.createElement("th",{scope:"row",className:n.root},t.createElement("div",{className:n.levelContent},t.createElement(k,{className:n.levelTypography,variant:"subtitle2",component:"p","aria-label":`${e.name} for ${a} track`},e.name))),r.map((l,i)=>t.createElement("td",{key:i,className:n.root,"aria-hidden":!0})))}),ct=({name:e})=>{const r=V();return t.createElement("div",{className:`${r.levelHeaderCell} ${r.root}`,"aria-label":`${e}`},t.createElement(k,{variant:"subtitle2",component:"p",className:r.levelTypography},e))},dt=()=>{const e=V();return t.createElement("div",{className:`${e.levelHeaderCell} ${e.root}`},"\xA0")},pt=({program:e,highestLevels:r,levels:a,entityRefs:n,entityRoute:l})=>t.createElement("tbody",null,t.createElement(ot,{program:e,entityRefs:n,highestLevels:r}),a.map((i,s)=>t.createElement(ge,{key:s},t.createElement(st,{entityRefs:n,level:i,programName:e.name}),i.checks.map(({check:c,results:o},d)=>t.createElement(tt,{key:d,check:c,programId:e.id,programName:e.name,entityRefs:n,results:o,entityRoute:l}))))),se=f(e=>({root:{position:"sticky",bottom:"-1px",backgroundColor:e.palette.background.default,boxShadow:`0 -1px ${e.palette.divider}`,"& td$cell, & th$cell":{border:0,padding:e.spacing(1)},"& td$cell":{backgroundColor:e.palette.background.default}},row:{boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`},cell:{verticalAlign:"top"},cellInner:{textOrientation:"mixed",writingMode:"vertical-lr",transform:"rotate(-20deg)",transformOrigin:`100% ${e.spacing(1)}px`,wordBreak:"keep-all",fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",maxHeight:"max(15vh, 175px)"}})),mt=({entityRefs:e})=>{const r=P(F),a=se();return t.createElement("tfoot",{className:a.root,"data-testid":"results-table-footer"},t.createElement("tr",{className:a.row},t.createElement("td",{className:a.cell}),e.map((n,l)=>{if(typeof n!="string")return t.createElement("th",{key:l,className:a.cell,"aria-hidden":!0});const i=w(n);return t.createElement("th",{scope:"col",key:l,className:a.cell},t.createElement("div",{className:a.cellInner},t.createElement(B,{to:r(i)},T(i,{defaultKind:i.kind}))))})))},ut=({entityRef:e})=>{const r=P(F),a=se(),n=e?w(e):void 0,l=n?t.createElement(B,{to:r(n)},T(n,{defaultKind:n.kind})):t.createElement(t.Fragment,null);return t.createElement("div",{className:a.cell},t.createElement("div",{className:a.cellInner},l))},gt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},paddingBottom:e.spacing(2)},programTitle:{padding:e.spacing(2)},checkResult:{padding:e.spacing(1.5)},title:{padding:`${e.spacing(1)}px ${e.spacing(2)}px`},header:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100]}})),ce=()=>{const e=gt(),r=new Array(25).fill(void 0),a=new Array(5).fill(void 0),n=new Array(3).fill(void 0);return t.createElement("table",{className:e.table},t.createElement("tbody",null,t.createElement("tr",null,t.createElement("td",{className:e.programTitle},t.createElement(S,{width:180,height:40})),r.map((l,i)=>t.createElement("td",{key:i}))),n.map((l,i)=>t.createElement(t.Fragment,{key:i},t.createElement("tr",{className:e.header},t.createElement("td",{className:e.title},t.createElement(S,{width:180})),r.map((s,c)=>t.createElement("td",{key:c}))),a.map((s,c)=>t.createElement("tr",{key:c},t.createElement("td",{className:e.title},t.createElement(S,{width:240})),r.map((o,d)=>t.createElement("td",{key:d,className:e.checkResult},t.createElement(S,{width:18,height:18,variant:"rect"})))))))))},ht=f(e=>({root:{width:"100%"},table:{overflow:"auto",backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},"& th:first-of-type":{position:"sticky",left:0,zIndex:1,maxWidth:"60ch"},"& tfoot":{bottom:0,zIndex:1e3},"& tbody td:first-of-type":{border:`1px solid ${e.palette.divider}`,boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`}}})),ft=b(e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,i=ht(),s=P(F),{data:c,isLoading:o,isError:d}=X(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading track overview"):void 0)},[d,r]),o)return t.createElement(ce,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c;if(!o&&!u.length)return t.createElement(Le,{missing:"data",title:"Missing tracks",description:t.createElement(t.Fragment,null,"Looks like the group"," ",T(w(l),{defaultKind:"Group"})," ","doesn't own any ",n!=null?n:a," components that have Soundcheck tracks set up.",t.createElement("br",null),t.createElement("br",null),"If you're an administrator, you can learn more about configuring and filtering tracks in the"," ",t.createElement(B,{to:"https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#entity-filter"},"docs"),".")});if(d)return null;const p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})];return t.createElement("div",{className:i.root},t.createElement("table",{className:i.table,"aria-label":"Check results"},u.map(({program:g,levels:y,highestLevels:h},L)=>t.createElement(pt,{key:L,program:g,entityRefs:p,levels:y,highestLevels:h,entityRoute:s})),t.createElement(mt,{entityRefs:p})))}),yt=e=>t.createElement(it,{name:e}),vt=e=>({type:"ProgramHeader",render:()=>yt(e)}),kt=e=>e?t.createElement(ct,{name:e}):t.createElement(dt,null),de=e=>({type:"LevelHeader",render:()=>kt(e)}),Et=(e,r)=>t.createElement(rt,{name:e,progress:r}),bt=(e,r)=>({type:"CheckTitle",render:()=>Et(e,r)}),Ct=(e,r,a,n,l)=>t.createElement(ae,{check:r,entityRef:a,entityRoute:l,programId:e,result:n,isVirtualized:!0}),wt=(e,r,a,n,l)=>({type:"CheckResult",render:()=>Ct(e,r,a,n,l)}),Nt=e=>t.createElement(ut,{entityRef:e}),pe=e=>({type:"EntityHeader",render:()=>Nt(e)}),Rt=e=>t.createElement(lt,{highestLevel:e}),$t=e=>({type:"LevelBadge",render:()=>Rt(e)}),xt=e=>r=>{const a=e[r.rowIndex].cells[r.columnIndex];return a?t.createElement("div",{style:r.style},a.render()):t.createElement("div",{style:r.style})},Tt=(e,r,a)=>{var n;const l=[];for(const{program:s,levels:c,highestLevels:o}of e){l.push({height:R.programTitle,cells:[vt(s.name),...r.map(d=>{const u=d?o.find(m=>m.entityRef===d)||et(d):void 0;return $t(u)})]});for(const d of c){l.push({height:R.levelTitle,cells:[de(d.name),...r.map(u=>de(""))]});for(const{check:u,results:m}of d.checks)l.push({height:R.check,cells:[bt(u.name,J(m.filter(({result:p})=>p!==N.NotApplicable),"result")),...r.map(p=>{var g,y;return wt(s.id,u,p,(y=(g=m.find(h=>h.entityRef===p))==null?void 0:g.result)!=null?y:N.NotApplicable,a)})]})}}const i=Ye(r!=null?r:[]);return l.push({height:Ze((n=i.length)!=null?n:1),cells:[pe(""),...r.map(s=>pe(s||""))]}),l},Lt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left",overflow:"auto"}})),It=e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,i=Lt(),s=P(F),{data:c,isLoading:o,isError:d}=X(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading program overview"):void 0)},[d,r]),o)return t.createElement(ce,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c,p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})],g=Tt(u,p,s),y=xt(g);return t.createElement(C,{"aria-label":`Check results for ${n!=null?n:a}`,key:`${a}|${n!=null?n:""}`,item:!0,xs:12},t.createElement(Oe,{className:i.table,columnCount:p.length+1,columnWidth:h=>h===0?z.programTitle:z.checkResult,rowCount:g.length,rowHeight:h=>g[h].height,height:Je(g),width:Xe(p.length)},y))},Ot=({facets:e,ownerEntityRef:r,kind:a,type:n,setError:l})=>{const i=O(()=>{const s=new Map;return e.types.forEach(({kind:c,type:o})=>{const d=`${c}|${o!=null?o:""}`;s.set(d,t.createElement(It,{key:d,ownerEntityRef:r,kind:c,type:o,setError:l}))}),s},[e,r,l]);return t.createElement("div",null,i.get(`${a}|${n!=null?n:""}`))},Pt=f(()=>({scrollContainer:{overflow:"auto"}})),At=({facets:e,ownerEntityRef:r,hasError:a,kind:n,type:l,setError:i,useVirtualizedResultsTable:s,isFixedGroup:c})=>{var o,d,u;const m=Pt();if(a)return t.createElement(Ne,{severity:"error",title:a.message});const p="Use the groups drop-down list at the top-right of the page to select another group.";return e&&((d=(o=e.types)==null?void 0:o.length)!=null?d:0)>0?(u=e.types)!=null&&u.find(g=>g.count>0)?t.createElement("div",{className:m.scrollContainer},s?t.createElement(Ot,{facets:e,kind:n,type:l,setError:i,ownerEntityRef:r,hasError:a}):t.createElement(ft,{ownerEntityRef:r,kind:n,type:l,setError:i})):t.createElement(Re,{description:t.createElement(t.Fragment,null,"Looks like the group '",T(w(r),{defaultKind:"Group"}),"' doesn't own any entities that have any applicable tracks configured.",!c&&t.createElement(t.Fragment,null,t.createElement("br",null),t.createElement("br",null),p))}):t.createElement($e,{ownerEntityRef:r,selectGroupHint:c?void 0:p})},Ft=f(()=>({tableContainer:{padding:0,backgroundColor:"transparent"}})),Bt=({groupSelectorError:e,searchParams:r,setSearchParams:a,isFixedGroup:n=!1})=>{var l;const{group:i,kind:s,type:c}=r,[o,d]=I(void 0),[u,m]=I(void 0);v(()=>{((o==null?void 0:o.kind)!==s||(o==null?void 0:o.type)!==c)&&d({kind:s,type:c})},[s,c,o]);const{data:p,isLoading:g}=Ae(i),y=(l=E(be).getOptionalBoolean("soundcheck.virtualizeOverviewPage"))!=null?l:!0,h=u||e,L=($,x)=>{$&&(d({kind:$,type:x}),x?a({...r,kind:$,type:x}):(r!=null&&r.hasOwnProperty("type")&&delete r.type,a({...r,kind:$})))},H=Ft();return t.createElement(C,{container:!0,spacing:0},t.createElement(C,{item:!0,xs:12},g?t.createElement(Ge,null):t.createElement(je,{unfilteredFacets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,onChange:L})),t.createElement(C,{item:!0,xs:12,className:H.tableContainer},!g&&t.createElement(At,{facets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,setError:m,hasError:h,ownerEntityRef:i,useVirtualizedResultsTable:y,isFixedGroup:n})))};export{Se as G,Bt as O,He as U,Z as a,ze as b,Y as c,Fe as u};
|
|
2
|
+
//# sourceMappingURL=OverviewPageContent-31025374.esm.js.map
|
package/dist/esm/{RefetchingIndicator-b042ec49.esm.js → RefetchingIndicator-e114bc04.esm.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{useState as n}from"react";import{makeStyles as a,LinearProgress as m}from"@material-ui/core";import s from"react-use/lib/useDebounce";import"@backstage/catalog-model";import"@backstage/core-plugin-api";import{useIsFetching as c}from"@tanstack/react-query";import{F as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=RefetchingIndicator-
|
|
1
|
+
import t,{useState as n}from"react";import{makeStyles as a,LinearProgress as m}from"@material-ui/core";import s from"react-use/lib/useDebounce";import"@backstage/catalog-model";import"@backstage/core-plugin-api";import{useIsFetching as c}from"@tanstack/react-query";import{F as d}from"./index-7b347cd4.esm.js";import"@backstage/plugin-catalog-react";import"react-router-dom";const p=a(e=>({indicator:{position:"absolute",width:"100%",zIndex:e.zIndex.speedDial}})),l=()=>{const e=c(),i=p(),[r,o]=n(!!e);return s(()=>{o(!!e)},250,[e]),r?t.createElement(d,null,t.createElement("div",{className:i.indicator},t.createElement(m,{variant:"indeterminate","data-testid":"refetching-indicator"}))):null};export{l as R};
|
|
2
|
+
//# sourceMappingURL=RefetchingIndicator-e114bc04.esm.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t,{useState as C,useCallback as j,createContext as Pe,useContext as Se,useEffect as A,useMemo as B,useReducer as Zt,useRef as Tn,memo as Pn}from"react";import{useSearchParams as Jt,useNavigate as Sn,Routes as ea,Route as ta,useLocation as Ln}from"react-router-dom";import{MarkdownContent as aa,Link as Rn,DismissableBanner as Dn,TabbedLayout as z,Page as In,Header as On}from"@backstage/core-components";import{DATA_VIZ_DARK_THEME as An,DATA_VIZ_LIGHT_THEME as Fn,SpotifyLicenseBanner as $n}from"@spotify/backstage-plugin-core";import{Box as k,Paper as Le,Grid as h,Button as _,Slide as Mn,Dialog as Bn,AppBar as Vn,Toolbar as zn,Typography as b,IconButton as he,TextField as M,Collapse as Gn,makeStyles as x,ButtonGroup as na,Menu as ra,MenuItem as ge,FormControl as dt,InputLabel as mt,Select as ut,RadioGroup as Hn,Radio as la,Divider as He,FormControlLabel as We,Checkbox as Re,Card as pt,ListItemIcon as fe,ListItemText as Ee,withStyles as Wn,CardHeader as qn,CardContent as _n,CardActions as Un,List as oa,ListItem as De,Tooltip as oe,InputAdornment as ia,NativeSelect as sa,TablePagination as ca,Chip as ht,CircularProgress as jn,useTheme as qe,Table as Kn,TableHead as Yn,TableRow as da,TableCell as ma,TableBody as Qn,Switch as Xn,Tabs as Zn,Tab as gt}from"@material-ui/core";import{makeStyles as G,createStyles as Jn}from"@material-ui/core/styles";import{a as er,b as _e,c as tr,u as ar,U as nr,G as rr,O as lr}from"./OverviewPageContent-31025374.esm.js";import ua from"@material-ui/icons/Close";import{Controller as H,useWatch as ft,useForm as pa}from"react-hook-form";import ha from"@material-ui/icons/ArrowDropUp";import Et from"@material-ui/icons/ArrowDropDown";import ga from"@material-ui/icons/Delete";import{useApi as L,alertApiRef as or,useRouteRef as Ue}from"@backstage/core-plugin-api";import{useQuery as F,useQueryClient as ie,useMutation as se}from"@tanstack/react-query";import{s as O,Q as R,k as ee,M as ce,l as je,t as ir,m as sr,n as cr,S as dr,w as mr}from"./index-7b347cd4.esm.js";import{asArray as vt,FrequencySchema as ur,parseFactRef as yt,stringifyFactRef as pr,soundcheckCheckUpdatePermission as hr,soundcheckCheckDeletePermission as gr,soundcheckCheckCreatePermission as fr,soundcheckTrackUpdatePermission as Er,soundcheckTrackDeletePermission as vr,soundcheckTrackCreatePermission as yr,soundcheckCollectorUpdatePermission as br,soundcheckCollectorReadPermission as Cr}from"@spotify/backstage-plugin-soundcheck-common";import kr from"lodash/isObject";import Ie from"lodash";import xr from"cron-validate";import wr from"cronstrue";import{v4 as fa}from"uuid";import{Autocomplete as bt,Skeleton as Ct}from"@material-ui/lab";import Ea from"@material-ui/icons/CheckBox";import va from"@material-ui/icons/CheckBoxOutlineBlank";import Nr from"@material-ui/icons/ExpandMore";import{catalogApiRef as ya,EntityRefLink as kt,humanizeEntityRef as Tr,entityRouteRef as ba}from"@backstage/plugin-catalog-react";import{parseEntityRef as K,stringifyEntityRef as Pr}from"@backstage/catalog-model";import Sr from"@material-ui/icons/MoreVert";import Ca from"@material-ui/icons/Group";import{usePermission as te}from"@backstage/plugin-permission-react";import Lr from"@material-ui/icons/Search";import{useDrag as Rr,useDrop as Dr,DndProvider as Ir}from"react-dnd";import{HTML5Backend as Or}from"react-dnd-html5-backend";import Ar from"@material-ui/icons/OpenInNew";import Fr from"@material-ui/icons/DoneAllRounded";import $r from"@material-ui/icons/Menu";import ka from"@material-ui/icons/DragIndicator";import Mr from"@material-ui/icons/Visibility";import Br from"@material-ui/icons/Add";import Vr from"@material-ui/icons/Remove";import{ResponsiveContainer as xa,LineChart as xt,CartesianGrid as Ke,XAxis as Oe,YAxis as Ae,Line as wt,Tooltip as wa,Legend as Na,BarChart as Ta,Bar as Pa,Cell as zr}from"recharts";import{DateTime as Nt}from"luxon";import{motion as Tt}from"framer-motion";import Sa from"react-use/lib/useLocalStorage";import{CircularProgressbar as Gr,buildStyles as Hr}from"react-circular-progressbar";import"react-circular-progressbar/dist/styles.css";import Wr from"../images/catalog.svg";import qr from"../images/git.svg";import _r from"../images/octocat.svg";import Ur from"../images/settings.svg";import jr from"../images/soundcheck.png";import Kr from"../images/tech_insights.png";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-e114bc04.esm.js";import"react-use/lib/useDebounce";import"react-window";import"graphql-request";import"graphql-tag";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"@material-ui/icons/Check";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function Pt(e,a,n){const r=L(O);return F([R.GetChecks,e,a,n],async()=>r.getChecks(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function La(e,a,n){const r=L(O);return F([R.GetAllPrograms,e,a,n],async()=>r.getAllPrograms(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const Yr="Error Creating Track";function Qr(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return se([ce.CreateProgram],r,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),n({severity:"error",title:Yr,message:o})}})}const Xr=()=>{const[e,a]=C([]),[n,r]=C([[]]),[l,o]=C([!1]),i=j((d,g)=>{r(p=>{const v=[...p];return v[g]=[...v[g],d],v}),a(p=>p==null?void 0:p.filter(v=>v.id!==d.id)),o(p=>{if(p[g]){const v=[...p];return v[g]=!1,v}return p})},[]),s=j((d,g)=>{r(p=>{const v=[...p];return v[g]=v[g].filter(f=>f.id!==d.id),v}),a(p=>[...p!=null?p:[],d])},[]),c=j(()=>{r(d=>[...d,[]]),o(d=>[...d,!1])},[]),u=j(d=>{n.length>1&&r(g=>{const p=[...g],v=p.splice(d,1)[0];return a(f=>[...f!=null?f:[],...v]),p})},[n]),m=j(()=>{const d=n.map(g=>g.length===0);return o(d),!d.some(g=>g)},[n]);return{chips:e,setChips:a,inputChipsList:n,handleDrop:i,handleDelete:s,addInput:c,removeInput:u,inputErrors:l,setInputErrors:o,areInputsValid:m,setInputChipsList:r}},Zr=e=>{const a=L(O);return F([R.GetOverallCheckPassRates,e],async()=>a.getOverallCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Jr=e=>{const a=L(O);return F([R.GetIndividualCheckPassRate,e],async()=>a.getIndividualCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},el=e=>{const a=L(O);return F([R.GetOverallTrackPassRate,e],async()=>a.getOverallTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},tl=e=>{const a=L(O);return F([R.GetIndividualTrackPassRate,e],async()=>a.getIndividualTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},al=e=>{const a=L(O);return F([R.GetOverallEntityPassRates,e],async()=>a.getOverallEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},nl=e=>{const a=L(O);return F([R.GetIndividualEntityPassRate,e],async()=>a.getIndividualEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},rl=e=>{const a=L(O);return F([R.GetOverallGroupPassRates,e],async()=>a.getOverallGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ll=e=>{const a=L(O);return F([R.GetIndividualGroupPassRates,e],async()=>a.getIndividualGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ol=G(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),St=({onCancel:e,saveButtonText:a,isLoading:n,onSave:r,disableSave:l})=>{const o=ol();return t.createElement(k,{className:o.box},t.createElement(Le,{elevation:3,className:o.footer},t.createElement(h,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(h,{item:!0},t.createElement(_,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(h,{item:!0},r&&t.createElement(_,{variant:"contained",color:"primary",disabled:n||l,onClick:r?()=>r():void 0},a)))))},Ra=Pe({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),il=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),[o,i]=C(!1);return t.createElement(Ra.Provider,{value:{selectedProgram:a,setSelectedProgram:n,isLoading:r,setIsLoading:l,showAddModal:o,setShowAddModal:i}},e)},ve=()=>Se(Ra),Da=Pe({selectedCheck:null,setSelectedCheck:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),sl=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),[o,i]=C(!1),[s,c]=C(!1),u=d=>{l(!0),n(d)},m=()=>{n(null),l(!1),c(!1)};return t.createElement(Da.Provider,{value:{selectedCheck:a,setSelectedCheck:n,isLoading:o,setIsLoading:i,showAddModal:s,setShowAddModal:c,isReadOnly:r,showReadOnlyModal:u,hideModal:m}},e)},Y=()=>Se(Da),cl=G(e=>({appBar:{position:"relative"},title:{flex:1,fontSize:e.typography.h6.fontSize},closeIcon:{marginRight:e.spacing(2)},content:{flex:"1 0 auto",padding:e.spacing(2),margin:"0 0 5rem",overflowX:"hidden",overflowY:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),dl=t.forwardRef(function(e,a){return t.createElement(Mn,{direction:"up",ref:a,...e})}),Lt=({open:e,handleClose:a,title:n,children:r})=>{const l=cl();return t.createElement(Bn,{fullScreen:!0,open:e,onClose:a,TransitionComponent:dl},t.createElement(Vn,{className:l.appBar},t.createElement(zn,null,t.createElement(b,{className:l.title},n),t.createElement(he,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",className:l.closeIcon},t.createElement(ua,null)))),t.createElement(k,{className:l.content},r))},Fe=({name:e,control:a,error:n,label:r,placeholder:l,disabled:o,rules:i,messages:s,helperText:c,multiline:u,minRows:m})=>t.createElement(H,{name:e,control:a,defaultValue:"",rules:i,render:({field:d})=>t.createElement(M,{...d,fullWidth:!0,multiline:u,minRows:m,placeholder:l,label:r,disabled:o,variant:"outlined",margin:"normal",error:!!n,helperText:n&&s?s[n.type]:c})}),ml=G(()=>({section:{gap:0}})),ul=({control:e,error:a,isLoading:n,disabled:r})=>{const l=ml();return t.createElement("div",{className:l.section},t.createElement(Fe,{name:"checkName",control:e,error:a,label:"Check Name",placeholder:"Choose a name",disabled:n||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},pl=G(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main,cursor:"pointer"}})),$e=({title:e,children:a})=>{const[n,r]=C(!1),l=pl(),o=()=>{r(!n)};return t.createElement("div",{className:l.root},t.createElement(h,{container:!0,alignItems:"center",spacing:0},t.createElement(h,{item:!0},t.createElement(he,{onClick:o,className:l.button},n?t.createElement(Et,{fontSize:"large"}):t.createElement(ha,{fontSize:"large"}))),t.createElement(h,{item:!0},t.createElement(b,{onClick:o,className:l.title},e))),t.createElement(Gn,{in:n},a))},hl=({control:e,passError:a,failError:n,isLoading:r,disabled:l})=>t.createElement($e,{title:l?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement(Fe,{name:"passMessage",control:e,error:a,label:"Pass Message",placeholder:"Enter pass message...",disabled:r||l}),t.createElement(Fe,{name:"failMessage",control:e,error:n,label:"Fail Message",placeholder:"Enter fail message...",disabled:r||l})),gl=({control:e,error:a,isLoading:n,disabled:r})=>t.createElement(Fe,{name:"description",control:e,error:a,label:"Check Description",disabled:n||r,multiline:!0,minRows:4,placeholder:r?void 0:"Enter a brief description about the check",helperText:r?void 0:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),fl=x(e=>({button:{backgroundColor:e.palette.background.default,color:e.palette.primary.main},label:{paddingRight:e.spacing(2)},icon:{borderLeft:`1px solid ${e.palette.primary.main}`,padding:e.spacing(1,0,0,1)},menu:{marginTop:"52px"}})),El=({onAddCondition:e,onAddExpression:a})=>{const n=fl(),[r,l]=C(null),o=!!r,i=c=>{l(c.currentTarget)},s=()=>{l(null)};return t.createElement(k,null,t.createElement(na,{color:"primary"},t.createElement(_,{id:"add-button",className:n.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:i},t.createElement(k,{className:n.label},"Add"),t.createElement(k,{className:n.icon},t.createElement(Et,null)))),t.createElement(ra,{id:"add-menu",anchorEl:r,open:o,onClose:s,classes:{paper:n.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(ge,{onClick:()=>{e(),s()}},"Add Condition"),t.createElement(ge,{onClick:()=>{a(),s()}},"Add Expression")))},Ia=({name:e,control:a,selectLabel:n,options:r,disabled:l,rules:o})=>t.createElement(H,{name:e,control:a,rules:o,render:({field:i,fieldState:s})=>t.createElement(dt,{variant:"outlined",style:{minWidth:200}},t.createElement(mt,{id:`${e}-select-label`},n),t.createElement(ut,{...i,disabled:l,error:s.invalid,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:n},r.map(({value:c,label:u})=>t.createElement(ge,{key:c,value:c},u))))});var ae=(e=>(e.AllOf="all",e.AnyOf="any",e))(ae||{});const vl={all:"ALL OF",any:"ANY OF"};var Oa=(e=>(e.Equal="equal",e.NotEqual="notEqual",e.Matches="matches",e.LessThan="lessThan",e.LessThanInclusive="lessThanInclusive",e.GreaterThan="greaterThan",e.GreaterThanInclusive="greaterThanInclusive",e.In="in",e.NotIn="notIn",e.Contains="contains",e.DoesNotContain="doesNotContain",e.SemverGt="semverGt",e.SemverGte="semverGte",e.SemverLt="semverLt",e.SemverLte="semverLte",e.SemverEq="semverEq",e.SemverNeq="semverNeq",e.SemverSatisfies="semverSatisfies",e.SemverGtr="semverGtr",e.SemverLtr="semverLtr",e.After="after",e.Before="before",e))(Oa||{});const yl={equal:"Equals",notEqual:"Does Not Equal",matches:"Matches",semverGt:"Version Greater Than",semverGte:"Version Greater Than or Equals",semverLt:"Version Less Than",semverLte:"Version Less Than or Equals",semverEq:"Version Equals",semverNeq:"Version Not Equals",semverSatisfies:"Version Satisfies Range",semverGtr:"Version Greater Than Range",semverLtr:"Version Less Than Range",lessThan:"Less Than",lessThanInclusive:"Less Than or Equals",greaterThan:"Greater Than",greaterThanInclusive:"Greater Than or Equals",in:"In Array",notIn:"Not in Array",contains:"Contains",doesNotContain:"Does Not Contain",after:"DateTime is After",before:"DateTime is Before"},bl=x(e=>({container:{borderLeft:`1px solid ${e.palette.grey[500]}`,marginLeft:e.spacing(2),padding:e.spacing(2,0,2,0),display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(0)},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"45px"},innerContainer:{backgroundColor:e.palette.background.default,border:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"column"},inputsContainer:{padding:e.spacing(2),display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:e.spacing(1)},header:{background:"linear-gradient(90deg, #007DFF 0%, #0057B2 100%)",width:"100%",height:"8px"},deleteButton:{marginLeft:e.spacing(1),width:"45px",height:"45px"},deleteIcon:{color:e.palette.type==="dark"?e.palette.background.default:e.palette.common.black}}));function Aa(e){const a=L(O);return F([R.GetCollectors,e],async()=>a.getCollectors(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Cl(e,a){const n=L(O);return F([R.GetFactSchema,e,a],()=>n.getFactSchema(e,a),{enabled:!!e&&!!a,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const Ye=()=>({selectedKinds:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[],selectedTypes:[]}),kl=[{facet:"kind",label:"Kind",key:"selectedKinds"},{facet:"spec.type",label:"Type",key:"selectedTypes"},{facet:"spec.lifecycle",label:"Lifecycle",key:"selectedLifecycles"},{facet:"spec.owner",label:"Owner",key:"selectedOwners"},{facet:"spec.system",label:"System",key:"selectedSystems"},{facet:"metadata.tags",label:"Tags",key:"selectedTags"}],ye={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},Fa=e=>!e||Object.values(e).every(a=>a.length===0)?void 0:{catalog:Object.entries(e).reduce((a,[n,r])=>{const l=ye[n];return r.length>0&&(a[l]=r),a},{})},$a=e=>Object.keys(ye).reduce((a,n)=>{var r,l;return a[n]=vt((l=(r=e==null?void 0:e.catalog)==null?void 0:r[ye[n]])!=null?l:[]),a},{}),Qe=e=>{if(!e||Object.values(e).every(n=>n.length===0))return;const a={};for(const[n,r]of Object.entries(e))(r==null?void 0:r.length)>0&&(a[ye[n]]=r);return[a]},Rt=e=>{if(e&&Array.isArray(e)&&e.length){const a=e[0];return Object.keys(ye).reduce((n,r)=>{var l;return n[r]=vt((l=a==null?void 0:a[ye[r]])!=null?l:[]),n},{})}return Ye()};var I=(e=>(e.Months="months",e.Weeks="weeks",e.Days="days",e.Hours="hours",e.Minutes="minutes",e.Seconds="seconds",e))(I||{});const Dt=()=>({type:"HumanDuration",unit:I.Hours,value:1,cron:""}),It=[I.Months,I.Weeks,I.Days,I.Hours,I.Minutes,I.Seconds];function xl(e){return It.includes(e)}function Xe(e){switch(e){case"months":return I.Months;case"weeks":return I.Weeks;case"days":return I.Days;case"hours":return I.Hours;case"minutes":return I.Minutes;case"seconds":return I.Seconds;default:return null}}function Ot(e){if(e){const{cron:a,type:n,unit:r,value:l}=e;return n==="HumanDuration"?{[r]:l}:{cron:a}}}function At(e){var a;const n=Dt();if(e&&Ie.isObject(e)){if("cron"in e)return{...n,type:"cron",cron:e.cron};const r=Object.entries(e);if(r.length){const[l,o]=r[0];return{...n,unit:(a=Xe(l))!=null?a:I.Hours,value:o}}}return n}const wl=e=>xr(e).isValid(),Ma=e=>{try{return wr.toString(e)}catch(a){return typeof a=="string"?a.replace(/^Error:\s*/,""):"Invalid cron expression"}},Ba=1,Va=31536e3,za=e=>{if(e){if(isNaN(e))return"Invalid value";if(e<1)return"Minimum of 1";if(e>31536e3)return"Maximum exceeded"}else return"Enter a value";return!0},Nl=x(e=>({divider:{marginTop:e.spacing(3),marginBottom:e.spacing(3)},title:{cursor:"pointer"}})),Ga=({value:e,onChange:a,disabled:n,errors:r})=>{var l;const o=Nl(),[i,s]=C(e),[c,u]=C(`${e.value}`);A(()=>{a&&a(i)},[i,a]);const m=E=>{s({...e,type:E.target.value})},d=E=>{u(E.target.value);const y=parseInt(E.target.value,10);s({...e,value:isNaN(y)?0:y})},g=E=>{var y;s({...i,unit:(y=Xe(E.target.value))!=null?y:I.Hours})},p=E=>{const y=E.target.value;s({...i,cron:y})},v=()=>{s({...i,type:"cron"})},f=()=>{s({...i,type:"HumanDuration"})};return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{item:!0},t.createElement(Hn,{name:"frequencyType",value:i.type,onChange:m},t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(la,{disabled:n,value:"HumanDuration"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:f},"Run on a regular interval"),t.createElement(b,{variant:"caption"},"Run on a regular interval that you define"),i.type==="HumanDuration"&&t.createElement(h,{container:!0,style:{alignItems:"flex-start"}},t.createElement(h,{item:!0},t.createElement(M,{id:"every",type:"number",inputProps:{min:Ba,max:Va},label:"Every",name:"every",disabled:n,value:c,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,onChange:d})),t.createElement(h,{item:!0},t.createElement(dt,null,t.createElement(mt,{id:"frequency-unit"},"Unit"),t.createElement(ut,{labelId:"frequency-unit",disabled:n,value:i.unit,onChange:g},It.map(E=>t.createElement(ge,{key:E,value:E},E)))))))),t.createElement(He,{className:o.divider}),t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(la,{disabled:n,value:"cron"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:v},"Run on a schedule"),t.createElement(b,{variant:"caption"},"Run on a schedule defined via cron expression"),i.type==="cron"&&t.createElement(h,{item:!0},t.createElement(M,{id:"cron-expression","data-testid":"cron-expression",style:{minWidth:250},label:(l=r==null?void 0:r.message)!=null?l:Ma(i.cron),disabled:n,placeholder:"* * * * *",error:!!(r!=null&&r.message),value:i.cron,onChange:p})))))))},Tl=(e,a,n,r)=>{const l={};return r&&r.forEach(o=>{var i,s,c;o&&(l[o.id]={id:o.id,name:(i=o.name)!=null?i:o.id,description:(s=o.description)!=null?s:"",filter:(c=o.filter)!=null?c:void 0})}),e.map((o,i)=>{const s=o.map(c=>l[c.id]);return{name:a[i],description:n[i],ordinal:i+1,checks:s}})},Pl=e=>e.map(a=>a.checks.map(n=>{var r;return{id:n.id,label:(r=n.name)!=null?r:n.id}})),Sl=e=>{var a;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((a=e.levels)==null?void 0:a.map(n=>({ordinal:n.ordinal,name:n.name||"",description:n.description||"",checks:n.checks.map(r=>({id:r.id,name:r.name,description:r.description}))})))||[],filter:e.filter}},Ll=e=>{var a;if(kr(e)&&"frequency"in e){const n=ur.safeParse(e.frequency);if(n.success){const r=n.data;if("cron"in r)return{enabled:!0,frequency:{type:"cron",unit:I.Hours,value:1,cron:r.cron}};const l=Object.keys(r);if(l.length){const o=l[0];if(xl(o))return{enabled:!0,frequency:{type:"HumanDuration",unit:o,value:(a=r[o])!=null?a:1,cron:""}}}}}return{enabled:!1,frequency:{type:"HumanDuration",unit:I.Hours,value:1,cron:""}}},Rl=(e,a)=>{const{enabled:n,frequency:r}=e;if(n){const{cron:l,type:o,unit:i,value:s}=r;return o==="HumanDuration"?{frequency:{[i]:s},filter:Qe(a)}:{frequency:{cron:l}}}},Dl=(e,a)=>{const n=e?Pl(e.levels):[[]],r=n.flat().map(o=>o.id),l=a.filter(o=>!r.includes(o.id));return{inputChips:n,used:l}},Il=()=>({enabled:!1,frequency:Dt()}),Ft=e=>{var a;if(!e)return{};if(e.expressionType){const n={[e.expressionType]:(a=e.conditions)==null?void 0:a.map(r=>({factRef:r.factRef,path:r.path,operator:r.operator,value:r.value}))};return e.expressions&&e.expressions.forEach(r=>{var l;(l=n[e.expressionType])==null||l.push(Ft(r))}),n}if(e.expressions)return e.expressions.map(Ft);if(e.conditions&&e.conditions.length===1){const n=e.conditions[0];return{factRef:n.factRef,path:n.path,operator:n.operator,value:n.value}}return{}},Ha=(e,a=!0)=>{if(!e)return{conditions:[]};const n=Object.keys(e),r=n.includes("all")||a&&!n.includes("any")?ae.AllOf:ae.AnyOf;if(n.includes(r)||a){const l=e[r]||[e],o=[],i=[];return l.forEach(s=>{const c=Object.keys(s);c.includes("all")||c.includes("any")?i.push(Ha(s,!1)):o.push({factRef:s.factRef,path:s.path,operator:s.operator,value:s.value})}),{expressions:i.length>0?i:void 0,conditions:o,expressionType:r}}return{expressionType:ae.AllOf,conditions:[{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value}]}},Ol=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expressions:Ha(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:$a(e.filter),schedule:Ll(e.schedule)}),Al=(e,a)=>{var n,r,l,o;return{id:a?a.id:fa(),ownerEntityRef:(n=e.teamOwner)!=null?n:void 0,name:e.checkName,description:e.description,passedMessage:(r=e.passMessage)!=null?r:void 0,failedMessage:(l=e.failMessage)!=null?l:void 0,rule:Ft(e.expressions),filter:e.filters?Fa(e.filters):void 0,supportChannel:(o=e.supportChannel)!=null?o:void 0,schedule:Rl(e.schedule,e.filters)}},$t=(e,a="$")=>{const n=[];if(e.type==="object"&&e.properties){const r=e.properties;for(const l in r)if(r.hasOwnProperty(l)){const o=`${a}.${l}`;n.push(o);const i=r[l];n.push(...$t(i,o))}}if(e.type==="array"&&e.items){const r=`${a}[*]`;n.push(r);const l=Array.isArray(e.items)?e.items:[e.items];for(const o of l)n.push(...$t(o,r))}return n},Fl={checkName:"",description:"",teamOwner:"",supportChannel:"",expressions:{expressionType:ae.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:Ye(),schedule:Il()},$l=(e,a)=>{const{data:n,isLoading:r}=Aa(),l=ft({control:a,name:`${e}.factRef`}),[o,i]=C(()=>Wa(l));A(()=>{i(Wa(l))},[l]);const{data:s}=Cl(o==null?void 0:o.source,o==null?void 0:o.name),c=B(()=>s?$t(s.schema):[],[s]),u=B(()=>n==null?void 0:n.flatMap(m=>m.factNames.map(d=>{const g=yt(d,{defaultSource:m.id,defaultScope:"default"});return{label:g.name,value:pr(g)}})),[n]);return{isLoading:r,pathOptions:c,factRefOptions:u}};function Wa(e){if(e)try{return yt(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const qa=({name:e,rules:a,label:n,control:r,options:l,getOptionLabel:o,getOptionValue:i,onChange:s,onInputChange:c,disabled:u})=>t.createElement(H,{name:e,control:r,rules:a,render:({field:m,fieldState:d})=>t.createElement(bt,{...m,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:u,options:l,getOptionLabel:o,renderInput:g=>t.createElement(M,{...g,variant:"outlined",label:n,error:d.invalid,helperText:d.error?d.error.message:null}),onChange:(g,p)=>{const v=i?i(p):p;s==null||s(v),m.onChange(v)},onInputChange:(g,p)=>{const v=i?i(p):p;c==null||c(v),m.onChange(v)}})}),Ml=e=>{try{return yt(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},Bl=({control:e,name:a,handleDelete:n,disabled:r,disableDelete:l,setValue:o,getValues:i})=>{var s;const c=bl(),u=B(()=>Object.values(Oa).map(y=>({value:y,label:yl[y]})),[]),{pathOptions:m,factRefOptions:d,isLoading:g}=$l(a,e),p={required:!0},v=B(()=>{var y;return(y=d==null?void 0:d.map(w=>w.value))!=null?y:[]},[d]),f=(s=i("expressions.conditions"))==null?void 0:s.map(({factRef:y})=>y),E=y=>{y&&!(f!=null&&f.includes(y))&&(o(`${a}.path`,""),o(`${a}.operator`,""),o(`${a}.value`,""))};return t.createElement(k,{className:c.container},t.createElement(k,{className:c.connector}),t.createElement(k,{className:c.innerContainer},t.createElement(k,{className:c.header}),t.createElement(k,{className:c.inputsContainer},d&&t.createElement(qa,{name:`${a}.factRef`,control:e,rules:{...p,maxLength:500,validate:Ml},label:"Fact",options:v,getOptionLabel:y=>{var w,N;return(N=(w=d==null?void 0:d.find(D=>y===D.value))==null?void 0:w.label)!=null?N:y},getOptionValue:y=>{var w,N,D;return(D=(N=(w=d==null?void 0:d.find($=>y===$.label))==null?void 0:w.value)!=null?N:y)!=null?D:""},disabled:r||g,onChange:E,onInputChange:E}),t.createElement(qa,{name:`${a}.path`,label:"Path",rules:p,control:e,disabled:r||g,options:m}),t.createElement(Ia,{name:`${a}.operator`,rules:p,control:e,selectLabel:"Operator",options:u,disabled:r}),t.createElement(H,{name:`${a}.value`,control:e,defaultValue:"",rules:p,render:({field:y,fieldState:w})=>t.createElement(M,{...y,label:"Value",variant:"outlined",placeholder:"Enter a value",error:w.invalid,helperText:w.error?w.error.message:null,disabled:r})}))),!r&&!l&&t.createElement(he,{onClick:n,className:c.deleteButton,"data-test-id":`${a}-delete-button`},t.createElement(ga,{className:c.deleteIcon})))},Vl=({conditions:e,control:a,name:n,handleDelete:r,disabled:l,disableDelete:o,setValue:i,getValues:s,depth:c})=>t.createElement(t.Fragment,null,e.map((u,m)=>t.createElement(h,{item:!0,key:m},t.createElement(Bl,{control:a,name:`${n}.conditions[${m}]`,"data-testid":`${n}-condition-input`,handleDelete:()=>r(m),disabled:l,disableDelete:c===0&&m===0?!0:o,setValue:i,getValues:s})))),zl=({expression:e,control:a,name:n,depth:r,getValues:l,setValue:o,trigger:i,disabled:s})=>e?t.createElement(h,{item:!0},t.createElement(_a,{control:a,name:`${n}`,depth:r+1,getValues:l,setValue:o,trigger:i,disabled:s})):null,Gl=x(e=>({button:{fontWeight:700,backgroundColor:e.palette.background.default,color:e.palette.primary.main,"&:hover":{backgroundColor:"rgba(46, 119, 208, 0.2)"}},selectedButton:{backgroundColor:"rgba(46, 119, 208, 0.15)"}})),Hl=({control:e,name:a,getValues:n,disabled:r})=>{const l=Gl(),o=`${a}`,i=n(o),[s,c]=C(i||ae.AllOf),u=m=>{c(m)};return t.createElement(H,{control:e,name:a,render:({field:{onChange:m}})=>t.createElement(na,{color:"primary"},Object.values(ae).map(d=>t.createElement(_,{key:d,className:s===d?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{u(d),m(d)},disabled:r},vl[d])))})},Wl=(e,a,n,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=a(l),i=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],s=`${e}.conditions`;n(s,i),await r(s)},handleAddExpression:async()=>{const l=`${e}.expressions`,o=a(l)||[];o.push({expressionType:ae.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:""}]}),n(l,o),await r(l)},handleDeleteCondition:async(l,o)=>{const i=o.split("[")[0],s=`${o}.conditions`,c=a(s);if(c.splice(l,1),c.length===0){n(s,void 0);const u=parseInt(o.slice(o.lastIndexOf("[")+1,o.lastIndexOf("]")),10),m=a(i);m.splice(u,1),n(i,m.length>0?m:void 0),await r(i)}else n(s,c),await r(s)}}),ql=G(e=>({root:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100],border:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(2)},inner:{marginLeft:e.spacing(2),paddingBottom:e.spacing(2),borderLeft:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"row",gap:0},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"20px"}})),_a=({control:e,name:a,depth:n,getValues:r,setValue:l,trigger:o,disabled:i})=>{const s=ql(),{handleAddCondition:c,handleAddExpression:u,handleDeleteCondition:m}=Wl(a,r,l,o),d=`${a}`,g=r(d),p=(g==null?void 0:g.conditions)||[],v=g==null?void 0:g.expressions;return t.createElement(k,{className:n>0?s.inner:s.root},n>0&&t.createElement(k,{className:s.connector}),t.createElement(h,{container:!0,spacing:0,direction:"column"},t.createElement(h,{item:!0},t.createElement(Hl,{control:e,disabled:i,name:`${a}.expressionType`,getValues:r})),t.createElement(h,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(Vl,{depth:n,handleDelete:f=>m(f,a),disabled:i,conditions:p,control:e,name:a,setValue:l,getValues:r}),v==null?void 0:v.map((f,E)=>t.createElement(zl,{key:E,expression:f,control:e,name:`${a}.expressions[${E}]`,depth:n,getValues:r,setValue:l,trigger:o,disabled:i}))),!i&&t.createElement(h,{item:!0},t.createElement(El,{onAddCondition:c,onAddExpression:u}))))},_l=({control:e,supportContactError:a,disabled:n,isLoading:r,options:l})=>{var o;return t.createElement($e,{title:n?"Owner Details":"Owner Details (optional)"},t.createElement(Ia,{name:"teamOwner",control:e,selectLabel:"Owner",options:(o=l==null?void 0:l.map(i=>({value:i.ref,label:i.name})))!=null?o:[],disabled:n||r}),t.createElement(Fe,{name:"supportChannel",control:e,error:a,label:"Support channel",placeholder:"Enter a channel or email to get check support",disabled:n||r,rules:{},messages:{}}))},Ul=e=>{const a=L(or),n=L(ya);return F([R.GetEntityFacets,e],async()=>{var r;return((r=(await n.getEntityFacets({facets:[e]})).facets[e])==null?void 0:r.map(l=>l.value).sort())||[]},{onError:()=>{a.post({message:`Failed to load facet: ${e}`,severity:"error"})}})},jl=x({container:{padding:0},formControl:{flexGrow:1}}),Kl=({facet:e,label:a,values:n,onChange:r,disabled:l})=>{var o;const i=jl(),{data:s,isLoading:c,error:u}=Ul(e),m=B(()=>s==null?void 0:s.map(f=>f.toLocaleLowerCase("en-US")),[s]),d=(o=n==null?void 0:n.map(f=>f.toLocaleLowerCase("en-US")))!=null?o:[],g=j((f,E)=>{r(m&&m.every(y=>E.includes(y))?void 0:E)},[m,r]),p=j(()=>{r(n!=null&&n.length?n:void 0)},[n,r]);if(!s||!m||u)return t.createElement(b,{color:"error"},"Failed to load facet: ",e);const v=l||c||!(n!=null&&n.length)&&(!(s!=null&&s.length)||!(m!=null&&m.length));return t.createElement(k,{pb:1,pt:1,className:i.container},t.createElement(b,{variant:"subtitle2"},a),t.createElement(bt,{className:i.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":a,options:m,value:d,getOptionLabel:f=>{var E;return(E=s[m.indexOf(f)])!=null?E:f},onChange:g,onBlur:p,disabled:v,renderOption:(f,{selected:E})=>{var y;return t.createElement(We,{control:t.createElement(Re,{icon:t.createElement(va,{fontSize:"small"}),checkedIcon:t.createElement(Ea,{fontSize:"small"}),checked:E}),label:(y=s[m.indexOf(f)])!=null?y:f})},size:"small",popupIcon:t.createElement(Nr,{"data-testid":"selected-facets-expand"}),renderInput:f=>t.createElement(M,{...f,variant:"outlined"})}))},Yl=x(()=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap"}})),Mt=({value:e,onChange:a,disabled:n})=>{const r=Yl(),l=o=>i=>{a({...e,[o]:i!=null?i:[]})};return t.createElement(h,{container:!0,className:r.filterContainer,spacing:2},kl.map(o=>t.createElement(h,{item:!0,xs:12,sm:6,md:4,key:o.key},t.createElement(Kl,{facet:o.facet,label:o.label,values:e==null?void 0:e[o.key],onChange:l(o.key),disabled:n}))))},Ql=x(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Xl=({control:e,disabled:a})=>{const n=Ql();return t.createElement($e,{title:a?"Filters":"Filters (optional)"},t.createElement(h,{className:n.container,item:!0,xs:12},!a&&t.createElement(b,{variant:"body2"},"Apply filters so it's only applicable to relevant entities."),t.createElement(h,{item:!0,xs:12},t.createElement(Le,null,t.createElement(H,{name:"filters",control:e,render:({field:r})=>{var l;return t.createElement(Mt,{value:(l=r.value)!=null?l:Ye(),onChange:r.onChange})}})))))},Ua=({type:e,cron:a,value:n})=>{if(e==="cron"){if(!wl(a))return Ma(a)}else if(e==="HumanDuration")return za(n);return!0},Zl=x(e=>({container:{padding:e.spacing(0,1.5)}})),Jl=({control:e,disabled:a})=>{const n=Zl(),r=ft({control:e,name:"schedule"});return t.createElement(h,{className:n.container,item:!0,xs:12},t.createElement(h,{item:!0},t.createElement(H,{name:"schedule.enabled",control:e,render:({field:l})=>t.createElement(We,{disabled:a,control:t.createElement(Re,{checked:l.value,onChange:l.onChange}),label:"Schedule check"})})),t.createElement(h,{item:!0},t.createElement(H,{name:"schedule.frequency",control:e,rules:{validate:Ua},render:({field:l})=>t.createElement(Ga,{disabled:a||!r.enabled,value:l.value,onChange:l.onChange})})))},eo=x(e=>({container:{padding:e.spacing(0,1.5)},scheduleContainer:{padding:e.spacing(2)}})),to=({control:e,disabled:a})=>{const n=eo();return t.createElement($e,{title:a?"Schedule":"Schedule (optional)"},t.createElement(h,{className:n.container,item:!0,xs:12},t.createElement(h,{item:!0},t.createElement(b,{variant:"body2"},"By default checks are execute when any fact they depend on is updated. However, you may also schedule a check to run on a schedule.")),t.createElement(h,{item:!0,xs:12},t.createElement(Le,{className:n.scheduleContainer},t.createElement(Jl,{disabled:a,control:e})))))},ao=e=>{const{selectedCheck:a}=Y();let n=Fl;a&&(n=Ol(a));const{control:r,handleSubmit:l,getValues:o,setValue:i,trigger:s,formState:{errors:c}}=pa({defaultValues:n}),{showModal:u}=je();return{control:r,handleSubmit:l,getValues:o,setValue:i,trigger:s,errors:c,onSubmit:async m=>{if(!await u({title:"Save Check",message:`Are you sure you want to save check: ${m.checkName}?`,error:!1}))return;const d=Al(m,a);e(d)}}},no=()=>t.createElement("div",{style:{display:"flex",gap:"10px",flexDirection:"column"}},t.createElement(b,{variant:"h6"},"Creating and managing checks"),t.createElement(b,{variant:"body1"},"Checks are entities created from four components: facts, paths, operators and values. These components are then organized via a boolean calculator in the UI."),t.createElement(b,{variant:"body1"},"To create a check, select the components that you want to use, organize them into rules and give your check a meaningful name and a description."),t.createElement(b,{variant:"body1"},"Once created, you will be able to manage and edit your track on its detail page.")),ja=G(e=>({root:{overflow:"hidden",display:"flex",marginBottom:"53px"},card:{padding:e.spacing(3),display:"flex",gap:e.spacing(2.5)},sectionLabel:{fontWeight:700,margin:e.spacing(2,0),color:e.palette.primary.main}})),Bt=({title:e,open:a,onSave:n})=>{const r=ja(),{hideModal:l,isLoading:o,isReadOnly:i}=Y(),{control:s,handleSubmit:c,getValues:u,setValue:m,trigger:d,errors:g,onSubmit:p}=ao(n),{options:v}=er();return t.createElement(Lt,{handleClose:l,title:e,open:a},t.createElement("form",{onSubmit:c(p)},t.createElement(h,{container:!0,spacing:2,className:r.root},t.createElement(h,{item:!0,xs:9},t.createElement(pt,{className:r.card},t.createElement(b,{className:r.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(ul,{control:s,error:g.checkName,isLoading:o,disabled:i}),t.createElement(gl,{control:s,error:g.description,isLoading:o,disabled:i}),t.createElement(_l,{control:s,disabled:i,isLoading:o,options:v}),t.createElement(b,{className:r.sectionLabel},"Rules"),t.createElement(_a,{control:s,getValues:u,setValue:m,trigger:d,disabled:i,name:"expressions",depth:0}),t.createElement(Xl,{control:s,disabled:i}),t.createElement(hl,{control:s,passError:g.passMessage,failError:g.failMessage,isLoading:o,disabled:i}),t.createElement(to,{control:s,disabled:i}))),t.createElement(h,{item:!0,xs:3},t.createElement(no,null))),t.createElement(h,{container:!0,spacing:4,className:r.root},t.createElement(St,{onCancel:l,saveButtonText:"Save Check",isLoading:o,onSave:i?void 0:c(p)}))))},ro="Error Creating Check";function lo(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return se([ce.UpdateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),n({severity:"error",title:ro,message:o})}})}const oo=()=>{const{selectedCheck:e,hideModal:a}=Y(),{setIsLoading:n}=Y(),{mutateAsync:r,isLoading:l}=lo();return A(()=>{n(l)},[n,l]),t.createElement(Bt,{title:"Edit a Check",open:!!e,onSave:async o=>{await r(o)&&a()}})},io="Error Creating Check";function so(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return se([ce.CreateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),n({severity:"error",title:io,message:o})}})}const co=()=>{const{hideModal:e,showAddModal:a,setIsLoading:n}=Y(),{mutateAsync:r,isLoading:l}=so();return A(()=>{n(l)},[n,l]),t.createElement(Bt,{title:"Create a Check",open:a,onSave:async o=>{await r(o)&&e()}})},mo=({handleDelete:e})=>{const[a,n]=C(null),r=!!a,l=i=>{i.stopPropagation(),n(i.currentTarget)},o=i=>{i.stopPropagation(),n(null)};return t.createElement(t.Fragment,null,t.createElement(he,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":r?"summary-card-action-menu":void 0,"aria-expanded":r?"true":void 0,"aria-haspopup":"true",onClick:l},t.createElement(Sr,null)),t.createElement(ra,{id:"summary-card-action-menu",anchorEl:a,open:r,onClose:o,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e&&t.createElement(ge,{"data-testid":"summary-card-action-delete",onClick:i=>{e(i),o(i)}},t.createElement(fe,null,t.createElement(ga,{fontSize:"small"})),t.createElement(Ee,null,"Delete"))))},uo=Wn(e=>Jn({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(pt),po=x(e=>({root:{position:"relative",height:"100%"},summaryName:{fontSize:e.typography.pxToRem(24),color:e.palette.primary.main,maxHeight:"250px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical","-webkit-line-clamp":4,"-webkit-box-orient":"vertical",wordBreak:"break-word"},summaryDescription:{padding:0,maxHeight:"175px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"},card:{paddingTop:e.spacing(1),paddingBottom:0,paddingLeft:e.spacing(1),paddingRight:e.spacing(1)}})),Vt=({title:e,description:a,viewLabel:n="View",editLabel:r="Edit",children:l,handleDelete:o,handleEdit:i,handleView:s})=>{const c=po();return t.createElement(uo,{className:c.card},t.createElement(qn,{title:e,titleTypographyProps:{className:c.summaryName},subheader:t.createElement(aa,{className:c.summaryDescription,content:a!=null?a:""}),action:o&&t.createElement(mo,{handleDelete:o})}),t.createElement(_n,null,l),t.createElement(He,null),t.createElement(Un,null,t.createElement(_,{size:"medium",color:"primary",role:"link",onClick:i||s,disabled:!s&&!i},i?r:n)))},ho="Error Deleting Check";function go(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return se([ce.DeleteCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:(l,o)=>{let i=`Failed to delete check ${o}`;l instanceof Error&&(i=l.message),n({severity:"error",title:ho,message:i})}})}const fo=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Eo=({check:e})=>{var a;const n=fo();return t.createElement(oa,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(De,{disableGutters:!0,className:n.listItem},t.createElement(oe,{title:"Owner"},t.createElement(fe,null,t.createElement(Ca,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:n.listItemText,primary:t.createElement(kt,{entityRef:(a=e.ownerEntityRef)!=null?a:"No Owner"})})))},vo=({check:e})=>{const{id:a,name:n,description:r,isEditable:l,ownerEntityRef:o}=e,{loading:i,allowed:s}=te({permission:hr,resourceRef:a}),{loading:c,allowed:u}=te({permission:gr,resourceRef:a}),{showModal:m}=je(),{mutate:d}=go(),{showReadOnlyModal:g,setSelectedCheck:p}=Y(),v=j(async()=>{await m({title:"Delete Check",message:`Are you sure you want to delete the check '${n!=null?n:a}'?`})&&d(a)},[m,n,d,a]);return t.createElement(Vt,{title:n!=null?n:a,description:r,children:o&&t.createElement(Eo,{check:e}),handleView:()=>g(e),handleEdit:l&&!i&&s?()=>p(e):void 0,handleDelete:l&&!c&&u?v:void 0})},yo=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385})))),bo=x(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),Ka=({searchTerm:e,setSearchTerm:a,showClear:n=!0,placeholder:r="Search...",...l})=>{const o=bo(),i=c=>{a(c.target.value)},s=()=>{a("")};return t.createElement(M,{...l,fullWidth:!0,placeholder:r,value:e,onChange:i,InputProps:{startAdornment:t.createElement(ia,{position:"start"},t.createElement(Lr,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:n&&e?t.createElement(ia,{position:"end"},t.createElement(he,{edge:"end",onClick:s,className:o.clearButton},t.createElement(ua,null))):null}})},Co=x(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),Ya=({searchPlaceholder:e,isLoading:a,searchTerm:n,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:i,handleOwnerFilterChange:s,owners:c})=>{const u=Co();return t.createElement(h,{item:!0,xs:9,className:u.filters},t.createElement(Ka,{searchTerm:n,disabled:a,setSearchTerm:r,placeholder:e||"Search",variant:"outlined",size:"small",className:u.searchbar}),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Sort by: "),t.createElement(sa,{className:u.selectHolder,value:l,onChange:o},t.createElement("option",{value:"default"},"Default"),t.createElement("option",{value:"ascending"},"Name A-Z"),t.createElement("option",{value:"descending"},"Name Z-A"))),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Filter by owner: "),t.createElement(sa,{className:u.selectHolder,value:i,onChange:s},t.createElement("option",{key:"all",value:"all"},"All"),c==null?void 0:c.map((m,d)=>t.createElement("option",{key:m+d,value:m},m)))))},ko=(e,a)=>e==null?void 0:e.sort((n,r)=>{var l,o,i,s;const c=(o=(l=n==null?void 0:n.name)==null?void 0:l.toLocaleLowerCase())!=null?o:n==null?void 0:n.id.toLocaleLowerCase(),u=(s=(i=r==null?void 0:r.name)==null?void 0:i.toLocaleLowerCase())!=null?s:r==null?void 0:r.id.toLocaleLowerCase();return!c||!u?0:c<u?a==="ascending"?-1:1:c>u?a==="ascending"?1:-1:0}),Qa=e=>{const a=e==null?void 0:e.map(n=>n==null?void 0:n.ownerEntityRef).filter(n=>n!=="");return[...new Set(a)]},be=({searchTermProp:e,filterAlphaProp:a,filterOwnerProp:n,checks:r,tracks:l})=>{var o,i;const s=r||l||[],c=(o=s==null?void 0:s.filter)==null?void 0:o.call(s,m=>{var d;return((d=m==null?void 0:m.name)!=null?d:m==null?void 0:m.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),u=n&&n!=="all"?(i=c==null?void 0:c.filter)==null?void 0:i.call(c,m=>{var d;return((d=m==null?void 0:m.ownerEntityRef)==null?void 0:d.toLowerCase())===n.toLowerCase()}):c;return a==="default"?u:ko(u!=null?u:[],a)},xo=x(e=>({pagination:{width:"-webkit-fill-available",display:"flex",justifyContent:"center",position:"fixed",bottom:"0",backgroundColor:e.palette.type==="dark"?"#333333":"#F8F8F8",marginRight:"40px"}})),Xa=({response:e,listingsPerPage:a,cursor:n,setCursor:r,prevCursors:l,setPrevCursors:o,labelPerPageDropdown:i,urlRoute:s})=>{var c;const u=xo(),m=e!=null&&e.edges?e==null?void 0:e.edges[(e==null?void 0:e.edges.length)-1]:{cursor:""},[d,g]=C(0),p=()=>{o(y=>[...y,n]),r(m==null?void 0:m.cursor)},v=()=>{r(l[l.length-1]),o(y=>y.slice(0,-1))},f=(y,w)=>{g(N=>(w>N?p():v(),w))},E=y=>{window.open(`/soundcheck/${s!=null?s:"tracks?tracksPerPage="}${y.target.value}`,"_self")};return t.createElement(ca,{className:u.pagination,component:"div",count:(c=e==null?void 0:e.totalCount)!=null?c:-1,rowsPerPage:a!=null?a:10,onPageChange:f,page:d,onRowsPerPageChange:E,labelRowsPerPage:i!=null?i:"Listings per page:",rowsPerPageOptions:[]})},wo=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)}})),No=({checksPerPage:e,currentCursor:a})=>{const n=wo(),[r,l]=C(a),[o,i]=C([]),{data:s,isLoading:c}=Pt(void 0,e,r),{loading:u,allowed:m}=te({permission:fr}),[d,g]=C(s);A(()=>{s&&g(()=>{var T;return{endCursor:s.endCursor,totalCount:s.totalCount,hasNextPage:(T=s==null?void 0:s.hasNextPage)!=null?T:!1,edges:s.edges}})},[s]);const p=d==null?void 0:d.edges.map(T=>T.checker),{setShowAddModal:v}=Y(),[f,E]=C(),[y,w]=C(""),[N,D]=C("default"),[$,X]=C("all"),[we,Z]=C([]),pe=T=>{const V=be({searchTermProp:y,filterAlphaProp:T.target.value,filterOwnerProp:$,checks:p!=null?p:[]});D(T.target.value),E(V)},Ne=T=>{const V=be({searchTermProp:y,filterAlphaProp:N,filterOwnerProp:T.target.value,checks:p!=null?p:[]});X(T.target.value),E(V)};return A(()=>{const T=d==null?void 0:d.edges.map(re=>re.checker),V=Qa(T!=null?T:[]);E(T),Z(V!=null?V:[])},[c,d]),A(()=>{const T=d==null?void 0:d.edges.map(re=>re.checker),V=be({searchTermProp:y,filterAlphaProp:N,filterOwnerProp:$,checks:T!=null?T:[]});E(V)},[y,N,$,d]),t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,className:n.header},t.createElement(Ya,{searchPlaceholder:"Search available checks",isLoading:c,searchTerm:y,setSearchTerm:w,filterAlpha:N,handleAlphabeticalFilterChange:pe,filterOwner:$,handleOwnerFilterChange:Ne,owners:we}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:n.headerButtons},!u&&t.createElement(_,{disabled:!m,variant:"contained",color:"primary",onClick:()=>v(!0)},"Create Check")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},c?t.createElement(yo,null):f==null?void 0:f.map(T=>t.createElement(h,{key:T.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(vo,{check:T})))),((d==null?void 0:d.hasNextPage)||(o==null?void 0:o.length)>0)&&t.createElement(Xa,{response:d,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:o,setPrevCursors:i,labelPerPageDropdown:"Checks Per Page:",urlRoute:"checks?checksPerPage="}))},To=()=>{const{selectedCheck:e}=Y();return t.createElement(Bt,{title:"Check Details",open:!!e,onSave:()=>{}})},Po=x(e=>({checksPageContainer:{padding:e.spacing(3)}})),So=()=>{const e=Po(),[a]=Jt(),n=a.get("checksPerPage"),r=n?parseInt(n,10):9,{selectedCheck:l,showAddModal:o,isReadOnly:i}=Y();return t.createElement("div",{className:e.checksPageContainer},t.createElement(No,{checksPerPage:r}),o&&t.createElement(co,null),l&&!i&&t.createElement(oo,null),l&&i&&t.createElement(To,null))},Lo=()=>t.createElement(sl,null,t.createElement(So,null)),Ro=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Do=({program:e})=>{var a,n,r;const l=Ro(),o=(n=(a=e.levels)==null?void 0:a.length)!=null?n:0,i=(r=e.levels)==null?void 0:r.reduce((s,c)=>s+c.checks.length,0);return t.createElement(oa,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Levels"},t.createElement(fe,null,t.createElement($r,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Checks"},t.createElement(fe,null,t.createElement(Fr,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${i} ${i===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Documentation"},t.createElement(fe,null,t.createElement(Ar,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(Rn,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Owner"},t.createElement(fe,null,t.createElement(Ca,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(kt,{entityRef:e.ownerEntityRef})})))},Io="Error Deleting Track";function Oo(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return se([ce.DeleteProgram],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:(l,o)=>{let i=`Failed to delete track ${o}`;l instanceof Error&&(i=l.message),n({severity:"error",title:Io,message:i})}})}const Ao=({summary:e})=>{const{loading:a,allowed:n}=te({permission:Er,resourceRef:e.id}),{loading:r,allowed:l}=te({permission:vr,resourceRef:e.id}),{showModal:o}=je(),{mutate:i}=Oo(),{setSelectedProgram:s}=ve(),c=j(async()=>{await o({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&i(e.id)},[o,e.id,e.name,i]);return t.createElement(Vt,{title:e.name,description:e.description,children:t.createElement(Do,{program:e}),handleView:()=>{s(e)},handleEdit:e.isEditable&&!a&&n?()=>{s(e)}:void 0,handleDelete:e.isEditable&&!r&&l?c:void 0})},Fo=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385})))),$o=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)}})),Mo=({programsPerPage:e,currentCursor:a})=>{var n;const r=$o(),{loading:l,allowed:o}=te({permission:yr}),{setShowAddModal:i}=ve(),[s,c]=C(a),[u,m]=C([]),{data:d,isLoading:g}=La(void 0,e,s),[p,v]=C(d);A(()=>{d&&v(()=>{var S;return{endCursor:d.endCursor,totalCount:d.totalCount,hasNextPage:(S=d==null?void 0:d.hasNextPage)!=null?S:!1,edges:d.edges}})},[d]);const f=(n=p==null?void 0:p.edges)==null?void 0:n.map(S=>S==null?void 0:S.program),{userEntityRef:E}=_e(),{showAlert:y}=ee(),[w,N]=C(),[D,$]=C(""),[X,we]=C("default"),[Z,pe]=C("all"),[Ne,T]=C([]),V=S=>{const W=be({searchTermProp:D,filterAlphaProp:S.target.value,filterOwnerProp:Z,tracks:f!=null?f:[]});we(S.target.value),N(W)},re=S=>{const W=be({searchTermProp:D,filterAlphaProp:X,filterOwnerProp:S.target.value,tracks:f!=null?f:[]});pe(S.target.value),N(W)};A(()=>{const S=p==null?void 0:p.edges.map(Te=>Te.program),W=Qa(S!=null?S:[]);N(S),T(W!=null?W:[])},[g,p]),A(()=>{const S=p==null?void 0:p.edges.map(Te=>Te.program),W=be({searchTermProp:D,filterAlphaProp:X,filterOwnerProp:Z,tracks:S!=null?S:[]});N(W)},[D,X,Z,p]);const Ge=()=>{E?i(!0):y({severity:"error",title:"User Error",message:"Logged in user has not been found in Catalog. Unable to create a Track at this time"})};return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,className:r.header},t.createElement(Ya,{searchPlaceholder:"Search available tracks",isLoading:g,searchTerm:D,setSearchTerm:$,filterAlpha:X,handleAlphabeticalFilterChange:V,filterOwner:Z,handleOwnerFilterChange:re,owners:Ne}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!l&&t.createElement(_,{disabled:!o,variant:"contained",color:"primary",onClick:()=>Ge()},"Create Track")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"tracks"},g?t.createElement(Fo,null):w==null?void 0:w.map(S=>t.createElement(h,{key:S.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Ao,{summary:S})))),((p==null?void 0:p.hasNextPage)||(u==null?void 0:u.length)>0)&&t.createElement(Xa,{response:p,listingsPerPage:e,cursor:s,setCursor:c,prevCursors:u,setPrevCursors:m,labelPerPageDropdown:"Track Per Page:",urlRoute:"tracks?tracksPerPage="}))},Bo=x(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700}})),Vo=({programName:e,programNameError:a,handleProgramNameChange:n,disabled:r})=>{const l=Bo();return t.createElement(h,{item:!0,xs:12},t.createElement(M,{fullWidth:!0,placeholder:"Untitled track",value:e,onChange:n,disabled:r,className:l.titleInput,variant:"outlined",size:"small",margin:"normal",error:a,helperText:a?"Track name must be at least 1 character and less than 100 characters":""}))},Za=x(e=>{const a=e.palette.type==="dark",n=a?e.palette.common.white:e.palette.common.black,r=a?e.palette.grey[700]:e.palette.common.white,l=a?e.palette.grey[500]:e.palette.grey[300],o=a?e.palette.common.white:e.palette.common.black;return{chip:{width:"100%",height:"36px",color:n,justifyContent:"space-between",background:r,border:`1px solid ${l}`,borderRadius:4,boxShadow:"0px 2px 5px rgba(0, 0, 0, 0.1)",cursor:"move","& *":{fontWeight:700},"&:focus":{background:r,borderColor:o,"& $icon":{color:e.palette.primary.main}}},icon:{},deleteButton:{marginRight:"auto"}}}),zo=({chip:e,disabled:a})=>{var n;const[r,l]=Rr(()=>({type:"chip",item:{id:e.id,label:e.label},collect:i=>({isDragging:i.isDragging()})})),o=Za();return t.createElement(ht,{ref:l,label:e.label,className:o.chip,icon:t.createElement(ka,{"data-testid":"drag-indicator-icon"}),disabled:a,onDelete:()=>{},deleteIcon:t.createElement(oe,{title:(n=e.description)!=null?n:""},t.createElement(Mr,{className:o.icon,"data-testid":"visibility-icon"}))})},Ja=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{color:e.palette.primary.main,fontWeight:"bold"},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),Go=()=>{const e=Ja();return t.createElement(h,{container:!0,className:e.loadingContainer},t.createElement(jn,null))},Ho=({chips:e,disabled:a})=>t.createElement(t.Fragment,null,e.map(n=>t.createElement(zo,{disabled:a,key:n.id,chip:n}))),Wo=()=>t.createElement(b,{variant:"body1",color:"textSecondary"},"There are no matches."),qo=({isLoading:e,chips:a=[],disabled:n})=>{const r=Ja(),[l,o]=C(""),i=a.filter(u=>u.label.toLowerCase().includes(l.toLowerCase())),s=a.length>0||l;let c=null;return e?c=t.createElement(Go,null):i.length>0?c=t.createElement(Ho,{disabled:n!=null?n:!1,chips:i}):s&&(c=t.createElement(Wo,null)),t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:r.columnHeader},t.createElement(b,{className:r.subtitle},"Checks")),t.createElement(h,{item:!0,xs:12},t.createElement(Ka,{searchTerm:l,disabled:e||n,setSearchTerm:o,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(h,{item:!0,className:r.chipContainer,xs:12},c))},_o=x(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),en=({label:e,...a})=>{const n=_o();return t.createElement(_,{className:n.button,...a},e)},Uo=x(e=>({input:{border:`1px solid ${e.palette.grey[600]}`,borderRadius:4,padding:e.spacing(1),minHeight:80},hoverBackground:{background:e.palette.type==="dark"?e.palette.grey[600]:e.palette.grey[200]},normalBackground:{background:e.palette.type==="dark"?e.palette.grey[700]:e.palette.common.white},error:{border:"1px solid red"},chipContainer:{display:"flex",flexDirection:"column",fontWeight:"bold",fontSize:e.typography.pxToRem(16),color:e.palette.grey[600]}})),jo=({chips:e,onDelete:a,onDrop:n,error:r=!1,placeholder:l="",disabled:o})=>{const i=Uo(),s=Za(),[{isOver:c},u]=Dr(()=>({accept:"chip",drop:m=>{n(m)},collect:m=>({isOver:m.isOver()})}));return t.createElement("div",{ref:u,className:`${i.input} ${r?i.error:""} ${c?i.hoverBackground:i.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:i.chipContainer},e!=null&&e.length?e.map(m=>t.createElement(ht,{key:m.id,label:m.label,className:s.chip,icon:t.createElement(ka,null),style:{cursor:"pointer"},onDelete:()=>a(m),disabled:o})):l))},Ko=x(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),Yo=({levelName:e,handleLevelNameChange:a,disabled:n})=>{const r=Ko();return t.createElement(M,{fullWidth:!0,placeholder:"Untitled level",value:e,size:"small",variant:"outlined",onChange:a,label:"Level Name",disabled:n,InputProps:{classes:{input:r.inputBase}}})},Qo=x(e=>({inputBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),Xo=({levelDescription:e,levelNameLabel:a,handleLevelDescriptionChange:n,disabled:r})=>{const l=Qo();return t.createElement(M,{fullWidth:!0,placeholder:"Enter description here",multiline:!0,value:e,size:"small",variant:"outlined",label:`${a} Description`,onChange:n,disabled:r,InputProps:{classes:{input:l.inputBase}}})},Zo=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontWeight:"bold",color:e.palette.primary.main},levelHeader:{display:"flex",alignItems:"center"},removeButton:{minWidth:150}})),Jo=({inputChipsList:e,handleDelete:a,handleDrop:n,addInput:r,removeInput:l,levelsErrors:o,levelNames:i,levelDescriptions:s,handleLevelNameChange:c,handleLevelDescriptionChange:u,disabled:m})=>{const d=Zo();return t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:d.columnHeader},t.createElement(b,{className:d.subtitle},"Levels"),!m&&t.createElement(en,{label:"Add Level",startIcon:t.createElement(Br,null),onClick:r,disabled:m})),t.createElement(h,{container:!0,item:!0,spacing:5},e.map((g,p)=>t.createElement(h,{container:!0,item:!0,xs:12,key:p,spacing:2},t.createElement(h,{item:!0,xs:12,className:d.levelHeader},t.createElement(h,{container:!0,spacing:1},t.createElement(h,{item:!0,xs:!0},t.createElement(Yo,{levelName:i[p],handleLevelNameChange:v=>c(v.target.value,p),disabled:m!=null?m:!1})),e.length>1&&!m&&t.createElement(h,{item:!0,className:d.removeButton},t.createElement(en,{label:"Remove Level",startIcon:t.createElement(Vr,null),onClick:()=>l(p),disabled:m})))),t.createElement(h,{item:!0,xs:12},t.createElement(jo,{chips:g,onDelete:v=>a(v,p),onDrop:v=>n(v,p),error:o[p],placeholder:"Drag and drop checks here to include them in this level",disabled:m})),t.createElement(h,{item:!0,xs:12},t.createElement(Xo,{levelDescription:s[p],levelNameLabel:i[p],handleLevelDescriptionChange:v=>u(v.target.value,p),disabled:m!=null?m:!1}))))))},ei=x(e=>({titleInput:{marginBottom:e.spacing(1)},regularFontSize:{fontSize:e.typography.fontSize},title:{fontWeight:700,fontSize:e.typography.fontSize}})),ti=({programDescription:e,programDescriptionError:a,handleProgramDescriptionChange:n,disabled:r})=>{const l=ei();return t.createElement(h,{item:!0,xs:12},t.createElement(M,{fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:n,disabled:r,className:l.titleInput,minRows:4,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:l.regularFontSize}},error:a,helperText:a?"Track description must be at least 1 character and less than 250 characters":""}))};var ai=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))(ai||{});const ni={programName:"",programNameError:!1},ri=(e,a)=>{switch(a.type){case"SET_NAME":return{...e,programName:a.value};case"VALIDATE_NAME":return{...e,programNameError:a.value};default:return e}},li=(e="")=>{const[a,n]=Zt(ri,{...ni,programName:e}),r=()=>{const i=a.programName.trim().length,s=i>0&&i<=100;return n({type:"VALIDATE_NAME",value:!s}),s},l=i=>{n({type:"SET_NAME",value:i})},o=i=>{l(i.target.value),a.programNameError&&r()};return{programName:a.programName,programNameError:a.programNameError,handleProgramNameChange:o,setProgramName:l,isProgramNameValid:r}};var oi=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(oi||{});const ii={programDescription:"",programDescriptionError:!1},si=(e,a)=>{switch(a.type){case"SET_DESCRIPTION":return{...e,programDescription:a.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:a.value};default:return e}},ci=(e="")=>{const[a,n]=Zt(si,{...ii,programDescription:e}),r=()=>{const i=a.programDescription.trim().length,s=i>0&&i<=250;return n({type:"VALIDATE_DESCRIPTION",value:!s}),s},l=i=>{n({type:"SET_DESCRIPTION",value:i})},o=i=>{l(i.target.value),a.programDescriptionError&&r()};return{programDescription:a.programDescription,programDescriptionError:a.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:l,isProgramDescriptionValid:r}},di=({programName:e,programDescription:a,areInputsValid:n,isProgramNameValid:r,isProgramDescriptionValid:l,inputChipsList:o,checkers:i,onSave:s,programId:c,levelNames:u,levelDescriptions:m,filters:d})=>{const{showModal:g}=je(),{userEntityRef:p}=_e();return async()=>{if(!(r()&&l()&&n())||!await g({title:"Save Track",message:`Are you sure you want to save track: ${e}?`})||!p)return;const v=c!=null?c:fa(),f=Tl(o,u,m,i),E={description:a,id:v,levels:f,name:e,ownerEntityRef:p,filter:Fa(d)};s(E)}},mi=e=>{var a;const n=Tn([]),r=B(()=>e?Sl(e):null,[e]),{chips:l,setChips:o,inputChipsList:i,handleDrop:s,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:g,setInputChipsList:p}=Xr(),{data:v,isLoading:f}=Pt(),E=v==null?void 0:v.edges.map(w=>w.checker),y=(a=E==null?void 0:E.filter(w=>!!w).map(w=>{var N,D,$;return{id:(N=w.id)!=null?N:"",label:(D=w.name)!=null?D:w.id,description:($=w.description)!=null?$:""}}))!=null?a:[];return n.current=y,A(()=>{const{inputChips:w,used:N}=Dl(r,n.current);p(w),o(N)},[y==null?void 0:y.length,r,p,o]),{checkers:E,checkersLoading:f,chips:l,inputChipsList:i,handleDrop:s,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:g}},ui=e=>{const[a,n]=C(e);return{levelNames:a,handleLevelNameChange:(r,l)=>{n(a.map((o,i)=>i===l?r:o))},addLevelName:r=>{n([...a,r])},removeLevelName:r=>{n(a.filter((l,o)=>o!==r))}}},pi=e=>{const[a,n]=C(e);return{levelDescriptions:a,handleLevelDescriptionChange:(r,l)=>{n(a.map((o,i)=>i===l?r:o))},addLevelDescription:r=>{n([...a,r])},removeLevelDescription:r=>{n(a.filter((l,o)=>o!==r))}}},hi=x(e=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)},description:{fontSize:e.typography.fontSize}})),gi=({filters:e,setFilters:a,disabled:n})=>{const r=hi();return t.createElement($e,{title:n?"Filters":"Filters (optional)"},t.createElement(h,{container:!0,item:!0,xs:12,spacing:2},!n&&t.createElement(h,{item:!0},t.createElement(b,{className:r.description},"Apply filters so it's only applicable to relevant entities.")),t.createElement(h,{item:!0,xs:12},t.createElement(Le,null,t.createElement(Mt,{value:e,onChange:a})))))},fi=x(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),tn=({onSave:e,title:a,open:n,handleClose:r})=>{var l,o,i,s;const{selectedProgram:c,isLoading:u,setSelectedProgram:m}=ve(),{checkers:d,checkersLoading:g,chips:p,inputChipsList:v,handleDrop:f,handleDelete:E,addInput:y,removeInput:w,inputErrors:N,areInputsValid:D}=mi(c),{programName:$,programNameError:X,handleProgramNameChange:we,isProgramNameValid:Z}=li(c==null?void 0:c.name),{programDescription:pe,programDescriptionError:Ne,handleProgramDescriptionChange:T,isProgramDescriptionValid:V}=ci(c==null?void 0:c.description),re=(o=c?(l=c.levels)==null?void 0:l.map(q=>{var J;return(J=q.name)!=null?J:`Level ${q.ordinal}`}):v.map((q,J)=>`Level ${J+1}`))!=null?o:[],{levelNames:Ge,handleLevelNameChange:S,addLevelName:W,removeLevelName:Te}=ui(re),vn=(s=c?(i=c.levels)==null?void 0:i.map(q=>{var J;return(J=q.description)!=null?J:""}):v.map((q,J)=>""))!=null?s:[],{levelDescriptions:Yt,handleLevelDescriptionChange:yn,addLevelDescription:bn,removeLevelDescription:Cn}=pi(vn),kn=()=>{y(),W(`Level ${v.length+1}`),bn("")},xn=q=>{w(q),Te(q),Cn(q)},[Qt,wn]=C($a(c==null?void 0:c.filter)),Nn=di({programName:$,programDescription:pe,areInputsValid:D,isProgramNameValid:Z,isProgramDescriptionValid:V,inputChipsList:v,checkers:d,onSave:e,programId:c==null?void 0:c.id,levelNames:Ge,levelDescriptions:Yt,filters:Qt}),ct=fi(),Xt=ja(),le=c?!(c!=null&&c.isEditable):!1;return t.createElement(Lt,{handleClose:r,title:a,open:n},t.createElement(h,{container:!0,spacing:4,className:ct.root},t.createElement(h,{item:!0,xs:12},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:Xt.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(Vo,{disabled:u||le,programName:$,programNameError:X,handleProgramNameChange:we})),t.createElement(h,{item:!0,xs:12},t.createElement(ti,{disabled:u||le,programDescription:pe,programDescriptionError:Ne,handleProgramDescriptionChange:T}))),t.createElement(h,{item:!0,xs:12},t.createElement(gi,{filters:Qt,setFilters:wn})),t.createElement(h,{item:!0,xs:12},t.createElement(h,{container:!0,spacing:4},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:Xt.sectionLabel,style:{margin:0}},"Track Levels"),!le&&t.createElement(b,{className:ct.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!le&&t.createElement(h,{item:!0,xs:5},t.createElement(qo,{chips:p,isLoading:g||u,disabled:le})),t.createElement(h,{item:!0,xs:7},t.createElement(Jo,{inputChipsList:v,handleDelete:E,handleDrop:f,addInput:kn,removeInput:xn,levelsErrors:N,levelNames:Ge,handleLevelNameChange:S,levelDescriptions:Yt,handleLevelDescriptionChange:yn,disabled:le}))))),t.createElement(h,{container:!0,spacing:4,className:ct.root},t.createElement(St,{onCancel:()=>{m(null),r()},saveButtonText:"Save Track",isLoading:u||g,onSave:Nn,disableSave:le})))},Ei=()=>{const{setIsLoading:e,setShowAddModal:a,showAddModal:n}=ve(),{mutateAsync:r,isLoading:l}=Qr();return A(()=>{e(l)},[e,l]),t.createElement(tn,{handleClose:()=>a(!1),title:"Create Track",open:n,onSave:async o=>{await r(o)&&a(!1)}})},vi="Error Updating Track";function yi(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return se([ce.UpdateProgram],r,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),n({severity:"error",title:vi,message:o})}})}const bi=()=>{const{setSelectedProgram:e,setIsLoading:a,selectedProgram:n}=ve(),{mutateAsync:r,isLoading:l}=yi();A(()=>a(l),[a,l]);const o=async i=>{await r(i)&&e(null)};return t.createElement(tn,{handleClose:()=>e(null),title:n!=null&&n.isEditable?"Edit Track":"View Track",open:!!n,onSave:o})},Ci=x(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),ki=()=>{const{selectedProgram:e,showAddModal:a}=ve(),[n]=Jt(),r=n.get("tracksPerPage"),l=r?parseInt(r,10):9,o=Ci(),i="Programs will now be referred to as Tracks throughout the Soundcheck UI.";return t.createElement("div",{className:o.programsPageContainer},t.createElement(Dn,{variant:"info",message:i,id:"programTrackBanner"}),t.createElement(Ir,{backend:Or},t.createElement(Mo,{programsPerPage:l}),a&&t.createElement(Ei,null),e&&t.createElement(bi,null)))},xi=()=>t.createElement(il,null,t.createElement(ki,null)),wi=e=>e?e.palette.type:"",an=e=>wi(e).toLowerCase()==="dark",Q=e=>an(e)?e.palette.grey[200]:e.palette.grey[800],Ze=e=>an(e)?An:Fn;function zt(e,a){return(a?e.minus({days:a}):e).toFormat("MMM dd")}function Me(e){const a=Nt.utc();return e.map((n,r)=>({name:zt(a,e.length-r-1),passRate:n}))}var Ni=(e=>(e.Bar="bar",e.Line="line",e))(Ni||{});const Ti=-25,de=[0,100],nn=85,Gt=25,Je="name",Pi=250,et=.5,rn="circle",ln=8,on="monotone",tt=({children:e})=>t.createElement(xa,{minHeight:Pi,debounce:1},e),Si=G(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",fontWeight:"bold",transform:"translate(-50%, -50%)",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),Li=()=>{const e=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],a=Si();return t.createElement("div",{className:a.container},t.createElement(tt,null,t.createElement(xt,{data:e},t.createElement(Ke,{strokeDasharray:"3 3",vertical:!1,opacity:et}),t.createElement(Oe,{dataKey:"x",stroke:"#ccc",hide:!0}),t.createElement(Ae,{domain:de,stroke:"#ccc",hide:!0}),t.createElement(wt,{type:"monotone",dataKey:"y",stroke:"#ccc",dot:!1}))),t.createElement(b,{className:a.chartMessage},"No Data"))},Ri=x(e=>({legend:{color:Q(e)}})),Ht=({data:e,lines:a})=>{const n=qe(),r=Ze(n),l=Q(n),o=Ri();return e.length?t.createElement(tt,null,t.createElement(xt,{data:e},t.createElement(Ke,{vertical:!1,opacity:et}),t.createElement(Oe,{dataKey:Je,stroke:l}),t.createElement(Ae,{width:Gt,domain:de,stroke:l}),t.createElement(wa,{position:{y:Ti},contentStyle:{backgroundColor:n.palette.background.paper}}),t.createElement(Na,{iconType:rn,iconSize:ln,formatter:i=>t.createElement("span",{className:o.legend},i)}),a.map((i,s)=>t.createElement(wt,{key:i.dataKey,dataKey:i.dataKey,stroke:r[s%r.length],strokeWidth:2,dot:!1,name:i.name,type:on})))):t.createElement(Li,null)},Di=({data:e,lines:a})=>{const n=qe(),r=Ze(n);return t.createElement(xa,{height:50,width:100},t.createElement(xt,{data:e},t.createElement(Oe,{hide:!0,dataKey:Je}),t.createElement(Ae,{width:0,domain:de}),a.map((l,o)=>t.createElement(wt,{key:l.dataKey,dataKey:l.dataKey,stroke:r[o%r.length],strokeWidth:2,dot:!1,name:l.name,type:on}))))},Be=({chartData:e,tableChart:a})=>{const n=[{dataKey:"passRate",name:"Pass rate"}];return a?t.createElement(Di,{data:e,lines:n}):t.createElement(Ht,{data:e,lines:n})};var P=(e=>(e.Entity="Entity",e.EntityOwner="Entity Owner",e.Track="Track",e.Level="Track Level",e.Check="Check",e.CheckOwner="Check Owner",e))(P||{});function Ii(e){var a;const n=L(O),[r,l]=C(null),o=async()=>(await n.getEntityRefsForTechHealthFilter(e)).entityRefsForTechHealthFilter,i=F([R.GetSoftwareEntityRefsForUser,e],o,{retry:!1,onError:l,enabled:e!==null,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1});return{data:(a=i.data)!=null?a:[],isLoading:i.isLoading,error:r}}const Oi=(e,a)=>{var n,r,l,o;const i=[];for(const c of e)i.push({label:(n=c.name)!=null?n:c.id,value:c.id});const s=e.map(c=>c.id);for(const c of a)for(const u of(r=c.levels)!=null?r:[])for(const m of(l=u.checks)!=null?l:[])s.includes(m.id)||(s.push(m.id),i.push({label:(o=m.name)!=null?o:m.id,value:m.id}));return i},Ai=e=>{var a;const n=[];for(const r of e!=null?e:[])for(const l of(a=r.levels)!=null?a:[])n.includes(l.ordinal)||n.push(l.ordinal);return n.sort().map(r=>({label:`Level ${r}`,value:`${r}`}))},Fi=(e,a)=>{const n=new Set(e.filter(r=>r.ownerEntityRef).map(r=>r.ownerEntityRef));return Array.from(n).map(r=>{var l;return{label:(l=a[r])!=null?l:r,value:r}})},$i=()=>{const[e,a]=C(!1),{userEntityRef:n}=_e(),{data:r,isLoading:l}=Ii(n),{data:o,isLoading:i}=tr(),s=B(()=>Ie.mapValues(Ie.keyBy(o!=null?o:[],"ref"),f=>f.name),[o]),{data:c,isLoading:u}=La(void 0,100),m=B(()=>{var f;return(f=c==null?void 0:c.edges.map(E=>E.program))!=null?f:[]},[c]),{data:d,isLoading:g}=Pt(void 0,100),p=B(()=>{var f;return(f=d==null?void 0:d.edges.map(E=>E.checker))!=null?f:[]},[d]),v=B(()=>{var f;return{[P.Entity]:r.map(E=>({label:K(E).name,value:E})),[P.EntityOwner]:(f=o==null?void 0:o.map(E=>({label:E.name,value:E.ref})))!=null?f:[],[P.Track]:m.map(E=>({label:E.name,value:E.id})),[P.Level]:Ai(m),[P.Check]:Oi(p,m),[P.CheckOwner]:Fi(p,s)}},[r,o,s,m,p]);return A(()=>{a(l||i||u||g)},[l,i,u,g]),{facetOptions:v,isLoading:e}},Ce=30,me=2,ke=90,ue=()=>Object.fromEntries(Object.values(P).map(e=>[e,[]])),Mi=(e,a,n)=>{if(a.length)return a.map(r=>({track:r,levels:n.length?n.map(l=>parseInt(l,10)):void 0}));if(n.length)return e.map(r=>({track:r.value,levels:n.map(l=>parseInt(l,10))}))},sn=(e,a,n,r)=>({checkIdFilter:a[P.Check].length?{included:a[P.Check]}:void 0,checkOwnerFilters:a[P.CheckOwner].length?{included:a[P.CheckOwner]}:void 0,entityOwnerFilters:a[P.EntityOwner].length?{included:a[P.EntityOwner]}:void 0,entityRefFilters:a[P.Entity].length?{included:a[P.Entity]}:void 0,trackFilters:Mi(e[P.Track],a[P.Track],a[P.Level]),numberOfDays:n!=null?n:Ce,context:r?{loggedInUser:r}:void 0});function Bi({angle:e,arc:a,direction:n,dist:r,emoji:l,delay:o,fontSize:i,speed:s}){return t.createElement(Tt.div,{style:{position:"absolute",fontSize:i},initial:{top:0,left:"50%",x:"-50%",y:"-100%",rotate:0,originX:`${a*n}px`,originY:`${a}px`},animate:{opacity:[0,1,0,0,0,0],y:`${-r}px`,rotate:e*n},transition:{delay:o,duration:s,ease:[.2,.83,.46,.63],repeat:1/0}},l)}const Vi=["\u{1F4C8}","\u{1F4CA}","\u{1F4C9}","\u{1F680}","\u2B50\uFE0F"],zi=x(()=>({container:{position:"relative"}}));function Gi({angle:e=125,density:a=20,emojis:n=Vi,fontSizeMin:r=6,fontSizeMax:l=24,size:o=300,speed:i=4}){const s=zi(),c=B(()=>Array.from({length:a*n.length}).map((u,m)=>({emoji:n[Math.floor(Math.random()*n.length)],arc:Math.random()*o*.5,delay:Math.random()*i,dist:Math.random()*o,direction:m%2?1:-1,fontSize:Math.random()*(l-r)+r,angle:e,speed:i})),[a,n,i,o,e,l,r]);return t.createElement("div",{className:s.container},t.createElement(b,{variant:"h1"},"\u{1F469}\u200D\u{1F4BB}"),c.map((u,m)=>t.createElement(Bi,{key:`${u.emoji}-${m}`,...u})))}const Hi=x(()=>({container:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,height:"100%"},textContainer:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}}));function xe({title:e,subtitle:a}){const n=Hi();return t.createElement("div",{className:n.container},t.createElement("div",{className:n.textContainer},t.createElement(Gi,null),t.createElement(Tt.div,{animate:{y:0,opacity:1},initial:{y:100,opacity:0}},e&&t.createElement(b,{align:"center",variant:"h6"},e),a&&t.createElement(b,{align:"center",variant:"subtitle2"},a))))}const Wi=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.default,height:"100%",maxWidth:"100%"},tabsPlaceholder:{height:"36.5px",backgroundColor:e.palette.background.paper}})),qi=()=>{const e=Wi();return t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn}),t.createElement("div",{className:e.flexibleColumn},t.createElement("div",{className:e.tabsPlaceholder}),t.createElement(xe,null)))},cn=Pe({facetOptionsLoading:!1,getFacetOptions:()=>[],getFacetOptionLabel:()=>"",facetFilters:ue(),clearAllFilters:()=>{},getSelectedFacetValues:()=>[],setSelectedFacetValues:()=>{},numberOfDays:Ce,setNumberOfDays:()=>{},filter:{},loggedInUser:"Unknown"}),ne=()=>Se(cn),_i=e=>{const{userEntityRef:a}=_e(),{isLoading:n,facetOptions:r}=$i(),[l,o]=Sa("soundcheck.techHealth.facetFilters",ue()),[i,s]=Sa("soundcheck.techHealth.numberOfDays",Ce),[c,u]=C(sn(r,l!=null?l:ue(),i,a));A(()=>{u(sn(r,l!=null?l:ue(),i,a))},[r,l,i,u,a]);const m=()=>{s(Ce),o(ue())},d=E=>r[E].map(y=>y.value),g=(E,y)=>{var w;let N=(w=r[E].find(D=>D.value===y))==null?void 0:w.label;if(!N)try{const D=K(y);N=Tr(D)}catch{}return N!=null?N:y},p=E=>l?l[E]:[],v=(E,y)=>{const w={...l!=null?l:ue()};w[E]=y,o(w)},f={facetOptionsLoading:n,getFacetOptions:d,getFacetOptionLabel:g,facetFilters:l!=null?l:ue(),clearAllFilters:m,getSelectedFacetValues:p,setSelectedFacetValues:v,numberOfDays:i!=null?i:Ce,setNumberOfDays:s,filter:c!=null?c:{},loggedInUser:"Unknown"};return n?t.createElement(qi,null):t.createElement(cn.Provider,{...e,value:f})},Ui={hidden:{height:0,opacity:0,overflow:"hidden"},visible:{height:"auto",opacity:1,overflow:"visible"}};function ji({visible:e,...a}){return t.createElement(Tt.div,{...a,animate:e?"visible":"hidden",initial:"hidden",variants:Ui})}const Ki=x(({palette:e,spacing:a})=>({header:{display:"flex",alignItems:"center",flexDirection:"row",cursor:"pointer"},headerTitle:{flex:"1 1 0%"},chip:{backgroundColor:e.info.dark,textOverflow:"ellipsis",overflow:"hidden"},autoCompleteInput:{"&& input":{margin:a(1,0,0,0),width:"100%"}}})),Yi=({facet:e})=>{const a=Ki(),{getFacetOptions:n,getFacetOptionLabel:r,getSelectedFacetValues:l,setSelectedFacetValues:o}=ne(),[i,s]=C(!!l(e).length),[c,u]=C(!1),[m,d]=C(""),g=()=>{s(f=>!f)},p=f=>{(f.key==="Enter"||f.key===" ")&&g()},v=f=>{if(e===P.Entity&&f[f.length-1]){const E=f[f.length-1];if(!E.includes(":")||!E.includes("/")){u(!0),d("Custom entities require a valid kind and namespace such as: component:default/entity");return}}u(!1),d(""),o(e,f)};return t.createElement(k,null,t.createElement("div",{className:a.header,onClick:g,onKeyDown:p,role:"button",tabIndex:0},t.createElement(k,{className:a.headerTitle},t.createElement(b,{variant:"subtitle2"},e)),t.createElement(k,null,t.createElement(he,{size:"small",onKeyDown:p},i?t.createElement(ha,{fontSize:"small"}):t.createElement(Et,{fontSize:"small"})))),t.createElement(ji,{visible:i},t.createElement(bt,{className:a.autoComplete,fullWidth:!0,multiple:!0,freeSolo:e===P.Entity,popupIcon:null,ChipProps:{color:"primary",className:a.chip,size:"small"},options:n(e),getOptionLabel:f=>r(e,f),value:l(e),onChange:(f,E)=>v(E),renderInput:f=>t.createElement(M,{...f,className:a.autoCompleteInput,margin:"normal",placeholder:`Search for ${e}`,error:c,helperText:m}),renderOption:(f,{selected:E})=>t.createElement(We,{control:t.createElement(Re,{icon:t.createElement(va,{fontSize:"small"}),checkedIcon:t.createElement(Ea,{fontSize:"small"}),checked:E}),label:r(e,f)})})))},Qi=x(({palette:e,spacing:a})=>({root:{padding:({size:n})=>n==="small"?a(1,2):a(2),borderBottom:`1px solid ${e.border}`}}));function Wt(e){const a=Qi(e);return t.createElement(k,{...e,className:a.root})}const Xi=x(e=>({root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing(.25)}}));function Zi(){const e=Xi(),{numberOfDays:a,facetFilters:n,clearAllFilters:r}=ne(),l=Object.keys(P).some(o=>n[P[o]].length)||a!==Ce;return t.createElement(k,{className:e.root},t.createElement(k,null,t.createElement(b,{variant:"h6"},"Filters")),l&&t.createElement(k,null,t.createElement(_,{onClick:r,size:"small"},"Clear all")))}const Ji=x(({palette:e,spacing:a})=>({select:{width:"100%",margin:a(1,0)},chip:{backgroundColor:e.info.dark}})),at=[7,30,90].map(e=>({value:e,label:`Last ${e} days`}));function es(){const e=Ji(),{numberOfDays:a,setNumberOfDays:n}=ne(),r=[...at];at.map(d=>d.value).includes(a)||r.push({value:a,label:`Last ${a} days`});const[l,o]=C(r),[i,s]=C(""),c=()=>{if(i.length){const d=parseInt(i,10);return!isNaN(d)&&(d<me||d>ke)}return!1},u=()=>{const d=parseInt(i,10);if(d<me)return`Minimum of ${me} days`;if(d>ke)return`Maximum of ${ke} days`},m=d=>{if(d.key==="Enter"){const g=parseInt(i,10);g>=me&&g<=ke?(at.map(p=>p.value).includes(g)||o([...at,{value:g,label:`Last ${g} days`}]),n(g),s("")):g<me?s(`${me}`):s(`${ke}`)}};return t.createElement(k,null,t.createElement(k,{marginBottom:2},t.createElement(k,null,l.sort((d,g)=>d.value-g.value).map(({label:d,value:g})=>t.createElement(ht,{key:g,label:d,className:a===g?e.chip:void 0,color:a===g?"primary":void 0,size:"small",onClick:()=>n(g)})))),t.createElement(k,null,t.createElement(M,{fullWidth:!0,placeholder:"Number of days",inputProps:{min:me,max:ke},onKeyDown:m,helperText:u(),value:i,type:"number",error:c(),onChange:d=>s(d.target.value)})))}const ts=x(e=>({filters:{maxWidth:"300px",width:"100%",backgroundColor:e.palette.background.paper}})),as=()=>{const e=ts();return t.createElement(k,{className:e.filters},t.createElement(Wt,null,t.createElement(Zi,null)),t.createElement(Wt,null,t.createElement(es,null)),Object.values(P).map(a=>t.createElement(Wt,{key:a,size:"small"},t.createElement(Yi,{facet:a}))))},dn=Pe({checkPassRateOverview:{data:void 0,isLoading:!0,isError:!1},trackPassRateOverview:{data:void 0,isLoading:!0,isError:!1},entityPassRatesOverview:{data:void 0,isLoading:!0,isError:!1},groupPassRatesOverview:{data:void 0,isLoading:!0,isError:!1}}),Ve=()=>Se(dn),ns=e=>{const{filter:a}=ne(),n=Zr(a),r=el(a),l=al(a),o=rl(a),i=B(()=>({checkPassRateOverview:n,trackPassRateOverview:r,entityPassRatesOverview:l,groupPassRatesOverview:o}),[n,r,l,o]);return n.isLoading||r.isLoading||l.isLoading||o.isLoading?t.createElement(xe,null):t.createElement(dn.Provider,{...e,value:i})},rs=e=>{const a=(e==null?void 0:e.overallTrackPassRate)||[];if(!a.length)return[];const n=Nt.utc();return a.reduce((r,{trendPassRates:l,levelOrdinal:o},i)=>{var s;const c=(s=l==null?void 0:l.map((u,m)=>({name:zt(n,l.length-m-1),[`Level${o}`]:u})))!=null?s:[];return i===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},ls=()=>{var e,a;const{trackPassRateOverview:{data:n,isError:r}}=Ve();if(r)return t.createElement(b,{color:"error"},"Failed to load track data.");const l=rs(n),o=(a=(e=n==null?void 0:n.overallTrackPassRate)==null?void 0:e.map(({levelOrdinal:i})=>({dataKey:`Level${i}`,name:`Level ${i}`})))!=null?a:[];return t.createElement(Ht,{data:l,lines:o})},os=e=>{const a=(e==null?void 0:e.overallEntityPassRates)||[];if(!a.length)return[];const n=Nt.utc();return a.reduce((r,{trendPassRates:l,id:o},i)=>{var s;const c=(s=l==null?void 0:l.map((u,m)=>({name:zt(n,l.length-m-1),[o]:u})))!=null?s:[];return i===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},is=()=>{var e,a;const{entityPassRatesOverview:{data:n}}=Ve(),r=(a=(e=n==null?void 0:n.overallEntityPassRates)==null?void 0:e.map(({id:o})=>({dataKey:o,name:K(o).name})))!=null?a:[],l=os(n);return t.createElement(Ht,{data:l,lines:r})},ss=G(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontWeight:"bold",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),cs=({layout:e,theme:a})=>{const n=e===nt.Vertical,r=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],l=[{x:"A",y:100},{x:"B",y:90},{x:"C",y:80},{x:"C",y:70},{x:"C",y:60}],o=ss();return t.createElement("div",{className:o.container},t.createElement(tt,null,t.createElement(Ta,{data:n?l:r,margin:{left:0},layout:e},t.createElement(Ke,{strokeDasharray:"3 3",vertical:n,horizontal:!n,opacity:et}),t.createElement(Oe,{dataKey:n?void 0:"x",type:n?ze.Number:ze.Category,domain:n?de:void 0,hide:!0}),t.createElement(Ae,{width:n?nn:Gt,dataKey:n?"x":void 0,type:n?ze.Category:ze.Number,domain:n?void 0:de,hide:!0}),t.createElement(Pa,{dataKey:"y",fill:a.palette.divider,barSize:n?mn:un}))),t.createElement(b,{className:o.chartMessage},"No Data"))},ds=x(e=>({legend:{color:Q(e)}}));var nt=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(nt||{});const mn=20,un=50;var ze=(e=>(e.Category="category",e.Number="number",e))(ze||{});const pn={dataKey:"passRate",name:"Pass rate"},hn=Pn(({data:e,layout:a})=>{const n=a==="vertical",r=qe(),l=Ze(r),o=Q(r),i=ds();return e.length?t.createElement(tt,{"aria-label":"Bar chart representing data points."},t.createElement(Ta,{data:e,layout:a},t.createElement(Ke,{vertical:n,horizontal:!n,opacity:et}),t.createElement(Oe,{dataKey:n?void 0:Je,type:n?"number":"category",domain:n?de:void 0,stroke:o}),t.createElement(Ae,{width:n?nn:Gt,dataKey:n?Je:void 0,type:n?"category":"number",domain:n?void 0:de,stroke:o}),t.createElement(wa,{contentStyle:{backgroundColor:r.palette.background.default},itemStyle:{color:Q(r)},cursor:{fill:"transparent"}}),t.createElement(Na,{iconType:rn,iconSize:ln,formatter:s=>t.createElement("span",{className:i.legend},s),payload:e.map(({name:s},c)=>({id:s,value:s,color:l[c%l.length]}))}),t.createElement(Pa,{barSize:n?mn:un,dataKey:pn.dataKey,name:pn.name},e.map(({name:s},c)=>t.createElement(zr,{key:s,fill:l[c%l.length]}))))):t.createElement(cs,{layout:a,theme:r})}),ms=e=>{var a,n;return(n=(a=e==null?void 0:e.overallTrackPassRate)==null?void 0:a.map(({levelOrdinal:r,snapshotPassRate:l})=>({name:`Level ${r}`,passRate:l})))!=null?n:[]},us=()=>{const{trackPassRateOverview:{data:e,isError:a}}=Ve();if(a)return t.createElement(b,{color:"error"},"Failed to load track data.");const n=ms(e);return t.createElement(hn,{data:n,layout:nt.Horizontal})},ps=e=>{var a;return(a=e==null?void 0:e.map(({id:n,groupTitle:r,snapshotPassRate:l})=>({name:r!=null?r:K(n).name,passRate:l})))!=null?a:[]},hs=()=>{var e;const{groupPassRatesOverview:{data:a}}=Ve(),n=(e=a==null?void 0:a.groupPassRates)==null?void 0:e.sort((l,o)=>o.snapshotPassRate-l.snapshotPassRate),r=ps(n);return t.createElement(hn,{data:r,layout:nt.Vertical})},gs=G(e=>({card:{display:"flex",flexDirection:"column",gap:e.spacing(1),border:`1px solid ${e.palette.divider}`,boxShadow:"none",width:"99%"},title:{fontWeight:"bold",fontSize:e.typography.h5.fontSize,lineHeight:`${e.typography.h3.fontSize}px`},subtitle:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.h6.fontSize}px`,color:e.palette.grey[800]},headerRow:{display:"flex",padding:e.spacing(1,2),borderBottom:`1px solid ${e.palette.divider}`,gap:e.spacing(2)},headerSection:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},contentRow:{padding:e.spacing(2.5,2),display:"flex",gap:e.spacing(2)},leftSection:{width:"200px"},summaryCard:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},chartSection:{flex:1,width:"100%",minWidth:"200px"},chartDisplaySummary:{flex:1,display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",justifyContent:"end"}})),rt=({title:e,subtitle:a,summaryCardContent:n,chartSectionContent:r})=>{const l=gs();return t.createElement(pt,{className:l.card},t.createElement(k,{className:l.headerRow},t.createElement(k,{className:l.headerSection},t.createElement(b,{className:l.title},e),t.createElement(b,{variant:"caption"},a))),t.createElement(k,{className:l.contentRow},n&&t.createElement(k,{className:l.leftSection},t.createElement(k,{className:l.summaryCard},n)),t.createElement(k,{className:l.chartSection},r)))},fs=x(e=>({chartHeader:{marginBottom:e.spacing(2)},overallSummaryBox:{display:"flex",flexDirection:"column",height:"100%",color:Q(e),textAlign:"center",gap:e.spacing(2)},percentage:{fontSize:e.typography.pxToRem(65),lineHeight:`${e.typography.pxToRem(88)}px`,fontWeight:"bold"},summaryText:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.pxToRem(14)}px`}})),Es=()=>{var e,a,n;const r=qe(),l=fs(),{checkPassRateOverview:{data:o}}=Ve(),i=(a=(e=o==null?void 0:o.overallCheckPassRates)==null?void 0:e.length)!=null?a:0,s=Me((n=o==null?void 0:o.overallCheckPassRates)!=null?n:[]),c=o!=null&&o.overallCheckPassRates&&i?Math.round(o.overallCheckPassRates[i-1]):0;let u;!(o!=null&&o.overallCheckPassRates)||!i?u="No Data":u=`${c}%`;const m=t.createElement(k,{className:l.overallSummaryBox},t.createElement(Gr,{value:c,text:u,styles:Hr({textColor:Q(r),pathColor:Ze(r)[0],trailColor:r.palette.divider,textSize:i?void 0:8})}),t.createElement(b,{className:l.summaryText},"Current check pass rate"));return t.createElement(rt,{title:"Check pass rate",subtitle:"Aggregate pass rate for checks",summaryCardContent:m,chartSectionContent:t.createElement(Be,{chartData:s})})},vs=()=>t.createElement(rt,{title:"Track pass rate",subtitle:"Aggregate pass rate for tracks",summaryCardContent:t.createElement(us,null),chartSectionContent:t.createElement(ls,null)}),ys=()=>t.createElement(rt,{title:"Entity pass rate",subtitle:"Compare the aggregate pass rate for entities",chartSectionContent:t.createElement(is,null)}),bs=()=>t.createElement(rt,{title:"Team pass rate",subtitle:"Compare the aggregate pass rate for teams",chartSectionContent:t.createElement(hs,null)}),Cs=G(e=>({root:{display:"flex",flexDirection:"column",gap:e.spacing(2),flex:1,background:e.palette.background.default}})),ks=()=>{const e=Cs();return t.createElement(k,{className:e.root},t.createElement(ns,null,t.createElement(Es,null),t.createElement(vs,null),t.createElement(ys,null),t.createElement(bs,null)))},xs=G(e=>({paper:{width:"100%",boxShadow:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius},tableHeaderCell:{fontWeight:"bold"}})),lt=({data:e,columns:a})=>{const n=xs(),[r,l]=C(0),[o,i]=C(10);A(()=>{l(0)},[e.length]);const s=(d,g)=>{l(g)},c=d=>{i(+d.target.value),l(0)},u=r*o,m=u+o;return t.createElement(Le,{className:n.paper},t.createElement(Kn,{size:"small"},t.createElement(Yn,null,t.createElement(da,null,a.map(d=>t.createElement(ma,{key:`header-${d.id}`,className:n.tableHeaderCell},d.label)))),t.createElement(Qn,null,e.slice(u,m).map(d=>t.createElement(da,{key:d.id},a.map(g=>t.createElement(ma,{key:`cell-${g.id}`},g.renderCell?g.renderCell(d):d[g.id])))))),t.createElement(ca,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:s,onRowsPerPageChange:c}))};var ws=(e=>(e.Check="check",e.Track="track",e.Entity="entity",e.Group="group",e))(ws||{});const U=G(e=>({root:{display:"flex",flexDirection:"column",flex:1,background:e.palette.background.default},ownerText:{fontWeight:500,color:Q(e)},flexColumn:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},boldText:{fontWeight:"bold"},descriptionText:{maxWidth:400,color:Q(e),fontSize:e.typography.subtitle2.fontSize,lineHeight:e.typography.subtitle1.fontSize},detailButton:{textTransform:"none",backgroundColor:"transparent","&:hover":{backgroundColor:e.palette.action.hover}}})),ot=({name:e="",description:a=""})=>{const n=U();return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},e),t.createElement(aa,{className:n.descriptionText,content:a!=null?a:""}))},it=({navigateTo:e})=>{const a=U(),n=Sn();return t.createElement(_,{variant:"text",className:a.detailButton,onClick:()=>n(e)},t.createElement(b,{className:a.ownerText},"View detail"))},Ns=e=>{const a=L(ya);return F([R.EntityByRef,e],async()=>a.getEntityByRef(e),{onError:()=>{},enabled:!!e})},Ts=e=>(e==null?void 0:e.kind)==="Group",Ps=e=>(e==null?void 0:e.kind)==="User",qt=({ownerEntityRef:e})=>{var a,n;const{data:r,error:l}=Ns(e!=null?e:void 0);if(r){let o;return Ts(r)||Ps(r)?o=(n=r.metadata.title)!=null?n:(a=r.spec.profile)==null?void 0:a.displayName:o=r.metadata.name,t.createElement(kt,{entityRef:Pr(r),title:o})}else if(l&&e)return t.createElement(oe,{title:"Unable to pull owner reference from Catalog API"},t.createElement(b,{style:{color:"red"},variant:"body2"},(()=>{try{return K(e).name}catch{return e}})()));return null},Ss=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))},Ls=(e,a)=>{const n=Math.min(5,a-e+1);return Array.from({length:n}).map((r,l)=>{const o=e+l;return{label:`LEVEL ${o}`,id:`levels-${l}`,renderCell:i=>{var s;const c=(s=i.levels)==null?void 0:s.find(({levelOrdinal:u})=>u===o);return c?t.createElement(Ss,{row:c}):t.createElement(t.Fragment,null)}}})},Rs=(e,a)=>{const n=e.flatMap(o=>{var i;return((i=o.levels)==null?void 0:i.map(s=>s.levelOrdinal))||[]}),r=Math.min(...n),l=Math.max(...n);return[{label:"NAME",id:"trackName",renderCell:o=>{var i;return t.createElement(ot,{name:(i=o.trackName)!=null?i:o.id,description:o.trackDescription})}},...Ls(r,l),{label:"OWNER",id:"trackOwnerRef",renderCell:o=>{var i;return t.createElement(qt,{ownerEntityRef:(i=o.trackOwnerRef)!=null?i:void 0})}},{label:"ACTION",id:"action",renderCell:o=>t.createElement(it,{navigateTo:a({trackId:o.id})})}]},Ds=()=>{const e=U(),{filter:a}=ne(),n=Ue(ir),{data:r,isLoading:l,isError:o}=tl(a),i=B(()=>{var c;return Rs((c=r==null?void 0:r.individualTrackPassRate)!=null?c:[],n)},[r==null?void 0:r.individualTrackPassRate,n]);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load tracks");const{individualTrackPassRate:s}=r;return s?t.createElement(k,{className:e.root},t.createElement(lt,{data:s,columns:i})):t.createElement(b,{color:"error"},"No available tracks")},Is=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))};function Os(e){return[{label:"NAME",id:"entityName",renderCell:({id:a,entityDescription:n})=>t.createElement(ot,{name:K(a).name,description:n})},{label:"TREND",id:"trend",renderCell:a=>t.createElement(Is,{row:a})},{label:"OWNER",id:"entityOwnerRef",renderCell:({entityOwnerRef:a})=>t.createElement(qt,{ownerEntityRef:a!=null?a:void 0})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(it,{navigateTo:`${e(K(a))}/soundcheck`})}]}const As=()=>{const e=U(),{filter:a}=ne(),n=Ue(ba),{data:r,isLoading:l,isError:o}=nl(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load entities");const{individualEntityPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:Os(n)})):t.createElement(b,{color:"error"},"No available entities")},Fs=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return r.length?t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0})):t.createElement(k,{className:n.flexColumn},t.createElement(b,null,"No data"))};function $s(e){return[{label:"NAME",id:"groupName",renderCell:({groupTitle:a,id:n})=>t.createElement(ot,{name:a!=null?a:K(n).name})},{label:"TREND",id:"trend",renderCell:a=>t.createElement(Fs,{row:a})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(it,{navigateTo:e(K(a))})}]}const Ms=()=>{const e=U(),{filter:a}=ne();a.context=void 0;const n=Ue(ba),{data:r,isLoading:l,isError:o}=ll(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load groups");const{groupPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:$s(n)})):t.createElement(b,{color:"error"},"No available groups")},Bs=({row:e})=>{var a;const n=U(),r=Me((a=e.trendPassRates)!=null?a:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(e.snapshotPassRate),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))};function Vs(e){return[{label:"NAME",id:"checkName",renderCell:a=>{var n;return t.createElement(ot,{name:(n=a.checkName)!=null?n:a.id,description:a.checkDescription})}},{label:"TREND",id:"snapshotPassRate",renderCell:a=>t.createElement(Bs,{row:a})},{label:"OWNER",id:"checkOwner",renderCell:a=>{var n;return t.createElement(qt,{ownerEntityRef:(n=a.checkOwnerRef)!=null?n:void 0})}},{label:"ACTION",id:"action",renderCell:()=>t.createElement(it,{navigateTo:e()})}]}const zs=()=>{const e=U(),{filter:a}=ne(),n=Ue(sr),{data:r,isLoading:l,isError:o}=Jr(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load checks");const{individualCheckPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:Vs(n)})):t.createElement(b,{color:"error"},"No available checks")},Gs=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.paper,height:"100%",maxWidth:"100%"},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%",backgroundColor:e.palette.background.default,"& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto",borderTop:`1px solid ${e.palette.border}`}}})),Hs=()=>{const e=Gs();return t.createElement(_i,null,t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn},t.createElement(as,null)),t.createElement("div",{className:e.flexibleColumn},t.createElement(k,{className:e.pageLayout},t.createElement(ea,null,t.createElement(ta,{path:"/*",element:t.createElement(z,null,t.createElement(z.Route,{title:"Summary",path:"/"},t.createElement(ks,null)),t.createElement(z.Route,{title:"Checks",path:"/checks"},t.createElement(zs,null)),t.createElement(z.Route,{title:"Tracks",path:"/tracks"},t.createElement(Ds,null)),t.createElement(z.Route,{title:"Entities",path:"/entities"},t.createElement(As,null)),t.createElement(z.Route,{title:"Teams",path:"/teams"},t.createElement(Ms,null)))}))))))},gn=Pe({selectedCollector:null,setSelectedCollector:()=>{},showModal:!1,setShowModal:()=>{},hideModal:()=>{}}),Ws=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),o=()=>{n(null),l(!1)};return t.createElement(gn.Provider,{value:{selectedCollector:a,setSelectedCollector:n,showModal:r,setShowModal:l,hideModal:o}},e)},st=()=>Se(gn),qs=({collector:e,children:a})=>{const{description:n,id:r,isEditable:l,name:o}=e,{setSelectedCollector:i}=st(),{loading:s,allowed:c}=te({permission:br}),u=l&&!s&&c;return t.createElement(Vt,{title:o!=null?o:r,description:n,viewLabel:"Configure",editLabel:"Configure",children:a,handleView:void 0,handleEdit:u?()=>i(e):void 0})},_s=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385}))));function Us(e){switch(e){case"catalog":return Wr;case"github":return _r;case"scm":return qr;case"soundcheck":return jr;case"techinsights":return Kr;default:return Ur}}const js=x(e=>({container:{display:"flex",justifyContent:"center",alignItems:"center"},imageContainer:{width:"150px",height:"150px"},image:{width:"100%",height:"100%",objectFit:"contain"}})),Ks=({collector:e})=>{const{id:a}=e,n=js();return t.createElement(t.Fragment,null,t.createElement("div",{className:n.container},t.createElement("div",{className:n.imageContainer},t.createElement("img",{src:Us(a),alt:a,className:n.image}))))},Ys=()=>{const{data:e,isLoading:a}=Aa();return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},a?t.createElement(_s,null):e==null?void 0:e.sort((n,r)=>{var l,o;return((l=n.name)!=null?l:n.id).localeCompare((o=r.name)!=null?o:r.id)}).map(n=>t.createElement(h,{key:n.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(qs,{collector:n},t.createElement(Ks,{collector:n}))))))},fn=()=>({enabled:!1,hasDuration:!1,unit:I.Days,value:1});function _t(e){if(e){const{enabled:a,hasDuration:n}=e;if(a&&n){const{unit:r,value:l}=e;return{duration:{[r]:l}}}return a}}function Ut(e){var a;const n=fn();if(!e)return n;if(typeof e=="boolean")return{...n,enabled:e};if(!Ie.isObject(e)||!("duration"in e))return n;const r=e.duration;if(!Ie.isObject(r))return n;const l=Object.entries(r);if(l.length===0)return n;const[o,i]=l[0];return{...n,enabled:!0,hasDuration:!0,unit:(a=Xe(o))!=null?a:I.Days,value:i}}const Qs=x(e=>({duration:{display:"flex",padding:e.spacing(1),gap:e.spacing(2),alignItems:"flex-start"},checkbox:{margin:e.spacing(-1.5,0)},label:{cursor:"pointer"}})),Xs=({value:e,onChange:a,disabled:n,errors:r})=>{const l=Qs(),[o,i]=C(e),[s,c]=C(`${e.value}`);A(()=>{a&&a(o)},[o,a]);const u=p=>{i({...o,enabled:p.target.checked,hasDuration:p.target.checked&&o.hasDuration})},m=p=>{i({...o,hasDuration:p.target.checked})},d=p=>{c(p.target.value);const v=parseInt(p.target.value,10);i({...o,value:isNaN(v)?0:v})},g=p=>{var v;i({...o,unit:(v=Xe(p.target.value))!=null?v:I.Hours})};return t.createElement(h,{container:!0,direction:"column"},t.createElement(h,{item:!0},t.createElement(h,{container:!0,alignItems:"center"},t.createElement(h,{item:!0},t.createElement(Re,{id:"enableCaching",disabled:n,checked:o.enabled,onChange:u,"data-testid":"enableCaching"})),t.createElement(h,{item:!0},t.createElement("label",{htmlFor:"enableCaching",className:l.label},"Enable caching")))),t.createElement(h,{item:!0},t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,className:l.checkbox},t.createElement(Re,{id:"hasDuration",disabled:n||!o.enabled,checked:o.enabled&&o.hasDuration,onChange:m,"data-testid":"hasDuration"})),t.createElement(h,{item:!0},t.createElement("label",{htmlFor:"hasDuration",className:o.enabled?l.label:""},"Duration")),t.createElement(h,{className:l.duration},t.createElement(h,{item:!0},t.createElement(M,{id:"every",type:"number",label:"For",name:"for",disabled:n||!o.hasDuration,value:s,onChange:d,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,inputProps:{min:Ba,max:Va},"data-testid":"forTextField"})),t.createElement(h,{item:!0},t.createElement(dt,null,t.createElement(mt,{id:"duration-unit"},"Unit"),t.createElement(ut,{labelId:"duration-unit",disabled:n||!o.hasDuration,value:o.unit,onChange:g,"data-testid":"unitSelect"},It.map(p=>t.createElement(ge,{key:p,value:p},p)))))))))},Zs=({enabled:e,hasDuration:a,value:n})=>e&&a?za(n):!0,Js=x(e=>({root:{padding:e.spacing(1)},tabsContainer:{marginRight:16},tab:{height:"64px",textAlign:"left"},contentContainer:{width:"100%",padding:e.spacing(1)},divider:{marginTop:e.spacing(8),marginBottom:e.spacing(8)}})),jt=({name:e,label:a,description:n,control:r,disabled:l,errors:o})=>{const[i,s]=C(0),c=ft({control:r,name:`${e}.enabled`}),u=(d,g)=>{s(g)},m=Js();return t.createElement("div",{className:m.root},t.createElement(H,{name:`${e}.enabled`,control:r,render:({field:d})=>t.createElement(We,{control:t.createElement(Xn,{...d,checked:d.value}),label:t.createElement(k,{display:"flex",flexDirection:"column"},t.createElement(b,{variant:"body1",component:"span"},t.createElement("b",null,`${a}`)),t.createElement(b,{variant:"caption",color:"textSecondary",component:"p"},`${n}`))})}),c&&t.createElement("div",null,t.createElement(Zn,{orientation:"horizontal",variant:"scrollable",value:i,onChange:u,className:m.tabsContainer},t.createElement(gt,{label:"Frequency",className:m.tab}),t.createElement(gt,{label:"Filters",className:m.tab}),t.createElement(gt,{label:"Caching",className:m.tab})),t.createElement("div",{className:m.contentContainer},i===0&&t.createElement("div",null,t.createElement(H,{name:`${e}.frequency`,control:r,rules:{validate:Ua},render:({field:d})=>t.createElement(Ga,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.frequency})})),i===1&&t.createElement("div",null,t.createElement(H,{name:`${e}.filters`,control:r,render:({field:d})=>t.createElement(Mt,{disabled:l,value:d.value,onChange:d.onChange})})),i===2&&t.createElement("div",null,t.createElement(H,{name:`${e}.cacheConfig`,control:r,rules:{validate:Zs},render:({field:d})=>t.createElement(Xs,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.cacheConfig})})))))},Kt=()=>({enabled:!1,filters:{...Ye(),selectedKinds:["Component"]},frequency:Dt(),cacheConfig:fn()}),En=()=>({branchProtections:Kt(),repositoryDetails:Kt(),repositoryLanguages:Kt()});function ec(e){const{branchProtections:a,repositoryDetails:n,repositoryLanguages:r}=e;if(a.enabled||n.enabled||r.enabled){const l={},o=[];if(l.collects=o,a.enabled){const{cacheConfig:i,frequency:s,filters:c}=a;o.push({factName:"branch_protections",type:"BranchProtections",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}if(n.enabled){const{cacheConfig:i,frequency:s,filters:c}=n;o.push({factName:"repository_details",type:"RepositoryDetails",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}if(r.enabled){const{cacheConfig:i,frequency:s,filters:c}=r;o.push({factName:"repository_languages",type:"RepositoryLanguages",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}return l}return[]}function tc(e){var a,n,r,l,o,i;const s=En();if(e){const c=e.collects;if(c)for(const u of vt(c)){const m=u.type;m==="BranchProtections"&&(s.branchProtections={enabled:!0,frequency:At((a=u.frequency)!=null?a:e.frequency),filters:Rt((n=u.filters)!=null?n:e.filters),cacheConfig:Ut(u.cache)}),m==="RepositoryDetails"&&(s.repositoryDetails={enabled:!0,frequency:At((r=u.frequency)!=null?r:e.frequency),filters:Rt((l=u.filters)!=null?l:e.filters),cacheConfig:Ut(u.cache)}),m==="RepositoryLanguages"&&(s.repositoryLanguages={enabled:!0,frequency:At((o=u.frequency)!=null?o:e.frequency),filters:Rt((i=u.filters)!=null?i:e.filters),cacheConfig:Ut(u.cache)})}}return s}const ac="Error Configuring Collector";function nc(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateCollectorConfig(l);if(!o)throw new Error("Failed to update collector configuration.");return o};return se([ce.UpdateCollectorConfig],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetCollectors]})},onError:l=>{let o="Failed to update collector configuration.";l instanceof Error&&(o=l.message),n({severity:"error",title:ac,message:o})}})}const rc=({disabled:e})=>{const{hideModal:a,selectedCollector:n}=st(),{control:r,formState:{errors:l},handleSubmit:o}=pa({defaultValues:n?tc(n.config):En(),mode:"onChange"}),i=!!l.branchProtections||!!l.repositoryDetails||!!l.repositoryLanguages,{mutate:s}=nc(),c=async u=>{const m=ec(u);s({collectorId:"github",config:m}),a()};return t.createElement("form",{onSubmit:o(c)},t.createElement(jt,{name:"branchProtections",label:"Branch Protections",description:"Collects branch protection information from an entity's repository.",control:r,disabled:e,errors:l.branchProtections}),t.createElement(He,null),t.createElement(jt,{name:"repositoryDetails",label:"Repository Details",description:"Collects details about the an entity's repository.",control:r,disabled:e,errors:l.repositoryDetails}),t.createElement(He,null),t.createElement(jt,{name:"repositoryLanguages",label:"Repository Languages",description:"Collects details about the languages used in an entity's repository.",control:r,disabled:e,errors:l.repositoryLanguages}),t.createElement(h,{container:!0,spacing:4},t.createElement(St,{onCancel:a,saveButtonText:"Save",isLoading:!1,onSave:o(c),disableSave:i})))},lc=({title:e,open:a,handleClose:n})=>{const{selectedCollector:r}=st();return t.createElement(Lt,{handleClose:n,title:e,open:a},(r==null?void 0:r.id)==="github"&&t.createElement(rc,null))},oc=x(e=>({container:{padding:e.spacing(3)}})),ic=()=>{var e;const a=oc(),{selectedCollector:n,hideModal:r}=st();return t.createElement("div",{className:a.container},t.createElement(Ys,null),n&&t.createElement(lc,{title:(e=n.name)!=null?e:n.id,open:!!n,handleClose:r}))},sc=()=>t.createElement(Ws,null,t.createElement(ic,null)),cc=x(()=>({tabContent:{margin:0,padding:0},root:{"& > *":{display:"flex",flexDirection:"column",flexGrow:1}},pageContent:{display:"flex",flexDirection:"row",flexGrow:1},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%","& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto"}}})),dc=({title:e="Soundcheck"})=>{const a=cc(),[n,r]=ar(),{group:l}=n,[o,i]=C(void 0),{loading:s,allowed:c}=te({permission:Cr}),u=d=>{d&&r({...n,group:d})},m=Ln();return t.createElement(cr,null,t.createElement(nr,null,t.createElement(dr,null,t.createElement(mr,null,t.createElement(k,{className:a.root},t.createElement(In,{themeId:"tool"},t.createElement($n,{backend:"soundcheck",invalidLicenseMessage:"Submitted facts and check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present."}),t.createElement(On,{title:e},m.pathname.split("/").length-1===1&&t.createElement(rr,{onChange:u,initialValue:l,setError:i})),t.createElement(k,{className:a.pageContent},t.createElement(k,{className:a.pageLayout},t.createElement(ea,null,t.createElement(ta,{path:"/*",element:t.createElement(z,null,t.createElement(z.Route,{title:"Overview",path:"/"},t.createElement("div",{className:a.tabContent},t.createElement(lr,{groupSelectorError:o,searchParams:n,setSearchParams:r}))),t.createElement(z.Route,{title:"Tech Health",path:"/tech-health"},t.createElement(Hs,null)),t.createElement(z.Route,{title:"Checks",path:"/checks"},t.createElement(Lo,null)),t.createElement(z.Route,{title:"Tracks",path:"/tracks"},t.createElement(xi,null)),!s&&c&&t.createElement(z.Route,{title:"Collectors",path:"/collectors"},t.createElement(sc,null)))}))))))))))};export{dc as RoutingPage};
|
|
2
|
+
//# sourceMappingURL=index-0208f72c.esm.js.map
|
|
@@ -384,5 +384,5 @@ ${mt}`,$t=c`
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
${ie}
|
|
387
|
-
${ht}`,Mt=(e,t,r)=>e();function zt(e,t=Mt){return{createCheck(r,n){return t(i=>e.request(gt,r,{...n,...i}),"createCheck","mutation")},createProgram(r,n){return t(i=>e.request(ft,r,{...n,...i}),"createProgram","mutation")},deleteChecker(r,n){return t(i=>e.request(yt,r,{...n,...i}),"deleteChecker","mutation")},deleteProgram(r,n){return t(i=>e.request(kt,r,{...n,...i}),"deleteProgram","mutation")},updateCheck(r,n){return t(i=>e.request(vt,r,{...n,...i}),"updateCheck","mutation")},updateCollectorConfig(r,n){return t(i=>e.request(Rt,r,{...n,...i}),"updateCollectorConfig","mutation")},updateProgram(r,n){return t(i=>e.request(Ct,r,{...n,...i}),"updateProgram","mutation")},getAllCertifications(r,n){return t(i=>e.request(Et,r,{...n,...i}),"getAllCertifications","query")},getAllPrograms(r,n){return t(i=>e.request(Pt,r,{...n,...i}),"getAllPrograms","query")},getCertificationDetails(r,n){return t(i=>e.request(wt,r,{...n,...i}),"getCertificationDetails","query")},getCheckResultDetails(r,n){return t(i=>e.request($t,r,{...n,...i}),"getCheckResultDetails","query")},getCheckers(r,n){return t(i=>e.request(bt,r,{...n,...i}),"getCheckers","query")},getEntityRefsForTechHealthFilter(r,n){return t(i=>e.request(St,r,{...n,...i}),"getEntityRefsForTechHealthFilter","query")},getFacetsForOwner(r,n){return t(i=>e.request(It,r,{...n,...i}),"getFacetsForOwner","query")},getCollectors(r,n){return t(i=>e.request(Ft,r,{...n,...i}),"getCollectors","query")},getFactSchemas(r,n){return t(i=>e.request(Dt,r,{...n,...i}),"getFactSchemas","query")},getIndividualCheckPassRates(r,n){return t(i=>e.request(Ot,r,{...n,...i}),"getIndividualCheckPassRates","query")},getIndividualEntityPassRates(r,n){return t(i=>e.request(Nt,r,{...n,...i}),"getIndividualEntityPassRates","query")},getIndividualGroupPassRates(r,n){return t(i=>e.request(qt,r,{...n,...i}),"getIndividualGroupPassRates","query")},getIndividualTrackPassRate(r,n){return t(i=>e.request(Tt,r,{...n,...i}),"getIndividualTrackPassRate","query")},getOverallCheckPassRates(r,n){return t(i=>e.request(Gt,r,{...n,...i}),"getOverallCheckPassRates","query")},getOverallEntityPassRates(r,n){return t(i=>e.request(Lt,r,{...n,...i}),"getOverallEntityPassRates","query")},getOverallGroupPassRates(r,n){return t(i=>e.request(At,r,{...n,...i}),"getOverallGroupPassRates","query")},getOverallTrackPassRate(r,n){return t(i=>e.request(xt,r,{...n,...i}),"getOverallTrackPassRate","query")},getProgramOverviewForOwner(r,n){return t(i=>e.request(Bt,r,{...n,...i}),"getProgramOverviewForOwner","query")}}}var se=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},s=(e,t,r)=>(se(e,t,"read from private field"),r?r.call(e):t.get(e)),P=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},B=(e,t,r,n)=>(se(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),D,O,o,M,l;const N=Oe({id:"plugin.soundcheck"}),Ut=e=>"response"in e&&"errors"in e.response,Ht=e=>"response"in e&&"message"in e.response;class Wt{constructor(t){P(this,D,void 0),P(this,O,void 0),P(this,o,void 0),P(this,M,n=>{var i,d,u;return Ut(n)?(u=(d=(i=n.response)==null?void 0:i.errors)==null?void 0:d[0].message)!=null?u:`${n}`:Ht(n)?n.response.message:`${n}`}),P(this,l,async n=>{try{return await n()}catch(i){throw new Error(`Error from Soundcheck backend: ${s(this,M).call(this,i)}`)}}),B(this,D,t.fetchApi),B(this,O,t.discoveryApi);const r=new xe("/graphql",{fetch:async(n,i)=>{const d=`${await s(this,O).getBaseUrl("soundcheck")}${n}`;return s(this,D).fetch(d,i)}});B(this,o,zt(r))}async getAllCertifications(t){return s(this,l).call(this,async()=>{const{certifications:r}=await s(this,o).getAllCertifications({entityRef:t});return r})}async getCertificationDetails(t,r){return s(this,l).call(this,async()=>{const{programCertification:n}=await s(this,o).getCertificationDetails({entityRef:t,programId:r});return n})}async getCheckResultDetails(t,r,n){return s(this,l).call(this,async()=>{const{checkResult:i}=await s(this,o).getCheckResultDetails({entityRef:t,programId:r,checkId:n});return i})}async getFacetsForOwner(t){return s(this,l).call(this,async()=>{const{facetsForOwner:r}=await s(this,o).getFacetsForOwner({ownerEntityRef:t});return r})}async getProgramOverviewForOwner(t,r){return s(this,l).call(this,async()=>{const{programOverviewForOwner:n}=await s(this,o).getProgramOverviewForOwner({ownerEntityRef:t,facet:r});return n})}async getAllPrograms(t,r,n){return s(this,l).call(this,async()=>{const{programs:i}=await s(this,o).getAllPrograms({programIds:t,first:r,after:n});return i})}async createProgram(t){return s(this,l).call(this,async()=>{const{program:r}=await s(this,o).createProgram({input:t});return r})}async updateProgram(t){return s(this,l).call(this,async()=>{const{program:r}=await s(this,o).updateProgram({input:t});return r})}async deleteProgram(t){return s(this,l).call(this,async()=>{const{programDeleted:r}=await s(this,o).deleteProgram({programId:t});return r})}async getChecks(t,r,n){return s(this,l).call(this,async()=>{const{checkers:i}=await s(this,o).getCheckers({ids:t,first:r,after:n});return i})}async createCheck(t){return s(this,l).call(this,async()=>{const{check:r}=await s(this,o).createCheck({input:t});return r})}async updateCheck(t){return s(this,l).call(this,async()=>{const{check:r}=await s(this,o).updateCheck({input:t});return r})}async deleteCheck(t){return s(this,l).call(this,async()=>await s(this,o).deleteChecker({checkerId:t}))}async getCollectors(t){return s(this,l).call(this,async()=>{const{collectors:r}=await s(this,o).getCollectors({ids:t});return r})}async getFactSchema(t,r){if(!(!t||!r))return s(this,l).call(this,async()=>{const{factSchema:n}=await s(this,o).getFactSchemas({collectorId:t,factName:r});return n})}async updateCollectorConfig(t){return s(this,l).call(this,async()=>{const{collector:r}=await s(this,o).updateCollectorConfig({input:t});return r})}async getOverallCheckPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallCheckPassRates({filter:t}))}async getIndividualCheckPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualCheckPassRates({filter:t}))}async getOverallTrackPassRate(t){return s(this,l).call(this,async()=>await s(this,o).getOverallTrackPassRate({filter:t}))}async getIndividualTrackPassRate(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualTrackPassRate({filter:t}))}async getOverallEntityPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallEntityPassRates({filter:t}))}async getIndividualEntityPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualEntityPassRates({filter:t}))}async getOverallGroupPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallGroupPassRates({filter:t}))}async getIndividualGroupPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualGroupPassRates({filter:t}))}async getEntityRefsForTechHealthFilter(t){return s(this,l).call(this,async()=>await s(this,o).getEntityRefsForTechHealthFilter({ownerEntityRef:t}))}}D=new WeakMap,O=new WeakMap,o=new WeakMap,M=new WeakMap,l=new WeakMap;const q=$({id:"soundcheck-entity"}),Qt=$({id:"soundcheck-group"}),ce=R({id:"soundcheck-entity-certification-track-redirect",parent:q,path:"/:trackId"}),oe=R({id:"soundcheck-entity-certification",parent:q,path:"/:trackId/:checkId"}),jt=$({id:"soundcheck-overview"}),T=$({id:"soundcheck"}),Vt=R({id:"soundcheck-checks",parent:T,path:"/checks"});R({id:"soundcheck-tracks",parent:T,path:"/tracks"});const Kt=R({id:"soundcheck-track-details",parent:T,path:"/tracks/:trackId"}),k=Ne({id:"soundcheck",apis:[qe({api:N,deps:{discoveryApi:Te,fetchApi:Ge},factory:e=>new Wt(e)})],routes:{entityContent:q}}),_t=k.provide(b({name:"EntitySoundcheckContent",component:()=>import("./EntitySoundcheckContent-592fa779.esm.js").then(e=>e.EntitySoundcheckContent),mountPoint:q})),Jt=k.provide(Le({name:"EntitySoundcheckCard",component:{lazy:()=>import("./index-540b325c.esm.js").then(e=>e.EntitySoundcheckCard)}})),Xt=k.provide(b({name:"GroupSoundcheckContent",component:()=>import("./index-fcd50c7d.esm.js").then(e=>e.FixedGroupOverviewPage),mountPoint:Qt})),Yt=k.provide(b({name:"SoundcheckOverviewPage",component:()=>import("./index-fcd50c7d.esm.js").then(e=>e.OverviewPage),mountPoint:jt})),Zt=k.provide(b({name:"SoundcheckRoutingPage",component:()=>import("./index-100619e3.esm.js").then(e=>e.RoutingPage),mountPoint:T})),er=We(e=>new Ue({defaultOptions:{queries:{refetchInterval:6e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",retry:2,retryDelay:t=>{const r=450+Math.ceil(Math.random()*100);return Math.min(r*2**t,3e4)},onError:t=>e.post(t)}}})),tr=e=>{const t=x(Ae),r=er(t);return a.createElement(He,{client:r},e.children)};function le(e){const t=x(N),r=re(e);return _(["soundcheck/certifications",r],async()=>t.getAllCertifications(r))}function de(e,t){const r=x(N),n=re(e);return _(["soundcheck/certifications",n,t],async()=>r.getCertificationDetails(n,t),{enabled:!!t})}var ue=(e=>(e.GetAllPrograms="soundcheck/programs",e.GetChecks="soundcheck/checks",e.GetCollectors="soundcheck/collectors",e.GetFactSchema="soundcheck/collectors/schema",e.GetEntityFacets="soundcheck/catalog/facets",e.GetSoftwareEntityRefsForUser="soundcheck/entities/softwareEntityRefsForUser",e.GetOverallCheckPassRates="soundcheck/charts/overallCheckPassRates",e.GetIndividualCheckPassRate="soundcheck/charts/getIndividualCheckPassRate",e.GetOverallTrackPassRate="soundcheck/charts/overallTrackPassRate",e.GetIndividualTrackPassRate="soundcheck/charts/individualTrackPassRate",e.GetOverallEntityPassRates="soundcheck/charts/overallEntityPassRates",e.GetIndividualEntityPassRate="soundcheck/charts/individualEntityPassRate",e.GetOverallGroupPassRates="soundcheck/charts/overallGroupPassRates",e.GetIndividualGroupPassRates="soundcheck/charts/individualGroupPassRates",e.EntityByRef="soundcheck/catalog/entityByRef",e))(ue||{}),me=(e=>(e.DeleteCheck="soundcheck/deleteCheck",e.CreateCheck="soundcheck/createCheck",e.UpdateCheck="soundcheck/updateCheck",e.DeleteProgram="soundcheck/deleteProgram",e.CreateProgram="soundcheck/createProgram",e.UpdateProgram="soundcheck/updateProgram",e.UpdateCollectorConfig="soundcheck/updateCollectorConfig",e))(me||{});const rr=p(e=>({root:{padding:e.spacing(3)},icon:{display:"none"},message:{padding:0},type:{fontWeight:700,lineHeight:1.75}})),G=e=>{const{type:t,...r}=rr();return a.createElement(tt,{severity:e.severity,elevation:1,classes:r,onClose:e.onClose},a.createElement(m,{classes:{root:t}},e.title),e.children)},pe=V({}),ar=e=>{const[t,r]=S(),n=C(d=>{r(d)},[]),i=C(()=>{r(null)},[]);return a.createElement(pe.Provider,{value:{showAlert:n,clearAlert:i}},t&&a.createElement(G,{severity:t.severity,title:t.title,onClose:i},t.message),e.children)},nr=()=>K(pe),ir=p(e=>({modalContent:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",padding:"25px",backgroundColor:e.palette.type==="dark"?e.palette.grey[800]:e.palette.grey[200]},modalButtons:{display:"flex",justifyContent:"space-evenly","& button":{width:"40%",maxWidth:"185px"}},modalMessage:{margin:"15px 0 35px"}})),he=V({}),sr=e=>{const t=ir(),[r,n]=S(!1),[i,d]=S(),u=Be(),h=C(({title:w,message:Ie,error:Fe})=>(d({title:w,message:Ie,error:Fe}),n(!0),new Promise(De=>{u.current=De})),[]),v=C(()=>{u.current&&u.current(!0),n(!1)},[]),y=C(()=>{u.current&&u.current(!1),n(!1)},[]);return a.createElement(he.Provider,{value:{showModal:h}},e.children,i&&a.createElement(je,{open:r,onClose:y,"aria-labelledby":"confirmation-modal-title","aria-describedby":"confirmation-modal-description"},a.createElement(J,{className:t.modalContent},a.createElement(m,{id:"confirmation-modal-title",variant:"h6"},i.title),a.createElement(m,{className:t.modalMessage,id:"confirmation-modal-description",variant:"body1"},i.message),a.createElement("div",{className:t.modalButtons},!i.error&&a.createElement(X,{onClick:y,variant:"contained","aria-label":"cancel"},"Cancel"),a.createElement(X,{color:"primary",onClick:v,variant:"contained","aria-label":"confirm"},i.error?"Ok":"Confirm")))))},cr=()=>K(he),ge=24,or=11,z=e=>e==="small"?1:2,lr=p({root:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",borderWidth:"2px",fontWeight:700,width:({size:e})=>`${ge*z(e)}px`,height:({size:e})=>`${ge*z(e)}px`,fontSize:({size:e})=>`${or*z(e)}px`}}),fe=({className:e,label:t,size:r="small"})=>{const n=lr({size:r});return a.createElement("span",{className:F(e,n.root),role:"img","aria-label":`${t} badge`},t)},dr=p(e=>({root:{background:({color:t})=>t,color:e.palette.common.black,borderColor:e.palette.common.black,borderStyle:"solid","&::after":{position:"absolute",display:"block",content:'""',top:0,left:0,width:"100%",height:"100%",borderRadius:"50%",boxShadow:["inset 0 -0.18em 0 0 rgba(0, 0, 0, 0.25)","inset 0px 0.18em 0px 0px rgba(255, 255, 255, 0.5)","inset 0px 1.3em 0px -0.5em rgba(255, 255, 255, 0.2)"].join(",")}}})),U=({className:e,badge:t,size:r="small"})=>{const n=dr({color:t.options.color,size:r});return a.createElement(fe,{className:F(e,n.root),size:r,label:`L${t.options.level}`})},ur=p({root:{borderColor:"currentColor",borderStyle:"dashed"}}),ye=({className:e,size:t="small"})=>{const r=ur();return a.createElement(fe,{className:F(e,r.root),size:t,label:"NL"})},H=p(e=>({description:{padding:0,margin:0,display:"block","& p":{margin:0}},root:{padding:e.spacing(2),margin:0,display:"grid",gridTemplateColumns:"min-content auto",gridGap:e.spacing(2)},title:{fontSize:e.typography.pxToRem(18),fontWeight:700,lineHeight:1.235,marginBottom:"6px"},level:{textTransform:"uppercase",color:e.palette.text.secondary,fontWeight:700,letterSpacing:"1px"}}));function mr({description:e,documentationUrl:t}){const r=H();return t?a.createElement("div",{className:r.description},a.createElement(Y,{content:e}),a.createElement(Z,{to:t},"Learn more")):a.createElement("div",{className:r.description},a.createElement(Y,{content:e}))}const ke=({name:e,level:t,badge:r,description:n,documentationUrl:i})=>{const d=H();return a.createElement("div",{className:d.root},r?a.createElement(U,{size:"large",badge:r}):a.createElement(ye,{size:"large"}),a.createElement("div",null,a.createElement(m,{variant:"caption",className:d.level},t!=null?t:"No Level"),a.createElement(m,{className:d.title},e),n&&a.createElement(mr,{description:n,documentationUrl:i})))},L=({children:e})=>{const[t,r]=S(!1);return Me(()=>{const n=setTimeout(()=>{r(!0)},250);return()=>clearTimeout(n)},[]),a.createElement(Ve,{in:t,timeout:250},e)},W=({hideDescription:e=!1})=>{const t=H();return a.createElement(L,null,a.createElement("div",{className:t.root},a.createElement(f,{width:44,height:44}),a.createElement("div",null,a.createElement(m,{variant:"caption",className:t.level},a.createElement(f,{width:100})),a.createElement(m,{variant:"h4",className:t.title},a.createElement(f,{width:300})),!e&&a.createElement(m,{variant:"body2"},a.createElement(f,null)))))},ve=p(e=>{const t=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{wrapper:{backgroundColor:t,color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.caption.fontSize,minHeight:"auto",borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`,padding:e.spacing(1),display:"grid",gridTemplateAreas:({badge:r})=>[`"${r?"badge":"title"} title"`,`"${r?".":"description"} description"`].join(" "),gridTemplateColumns:"auto 1fr"},title:{gridArea:"title",textTransform:"uppercase",fontWeight:"bold",color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.body2.fontSize,paddingTop:e.spacing(.5),paddingBottom:e.spacing(.5),lineHeight:1},badge:{gridArea:"badge",marginRight:e.spacing(1)},description:{gridArea:"description",color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.subtitle2.fontSize,marginTop:e.spacing(1)}}}),pr=e=>{const t=ve({badge:e.badge});return a.createElement("div",{className:t.wrapper},e.badge?a.createElement(U,{className:t.badge,badge:e.badge}):null,a.createElement(m,{className:t.title},e.title),e.description?a.createElement(m,{className:t.description},e.description):null)},hr=()=>{const e=ve({});return a.createElement(L,null,a.createElement("div",{className:e.wrapper},a.createElement(f,{className:e.title}),a.createElement(m,{className:e.description},a.createElement(f,null))))},gr=p(e=>({root:{display:"inline-flex",alignItems:"center",gap:e.spacing(1)}})),Re=({timestamp:e,description:t})=>{const r=gr(),n=ae.fromISO(e).toLocaleString(ae.DATETIME_FULL),i=Ye(e),d=t?`${t}: ${i}`:void 0;return a.createElement("div",{className:r.root},a.createElement(Ke,{title:n},a.createElement(m,{variant:"caption","aria-label":d},i)),a.createElement(at,null))},fr=e=>({[g.Passed]:"Check passed",[g.NotReported]:"Check not reported",[g.Failed]:"Check failed",[g.NotApplicable]:"Check not applicable"})[e],yr=I(e=>({root:{color:e.palette.success.main}}))(nt),kr=I(e=>({root:{color:e.palette.error.main}}))(it),vr=I(e=>({root:{color:e.palette.info.main}}))(ct),Rr=I(e=>({root:{color:e.palette.text.disabled}}))(st),Ce=({result:e,className:t})=>{const r={className:t,"aria-label":fr(e),"aria-hidden":!1};return e===g.Passed?a.createElement(yr,{...r}):e===g.NotReported?a.createElement(vr,{...r}):e===g.Failed?a.createElement(kr,{...r}):e===g.NotApplicable?a.createElement(Rr,{...r}):null},Ee=p(e=>({root:{display:"grid",width:"100%",gridTemplateColumns:"auto 1fr auto",gridColumnGap:e.spacing(1),padding:e.spacing(1),alignItems:"center","&.selected":{backgroundColor:E(e.palette.primary[e.palette.type],.2)},"&:hover, &:active, &:focus":{backgroundColor:E(e.palette.primary[e.palette.type],.3)}}})),Cr=({className:e,href:t,children:r})=>t?a.createElement(rt,{to:t,className:e},r):a.createElement("div",{className:e},r),Er=({result:e,name:t,timestamp:r,selected:n=!1,href:i})=>{const d=Ee(),u=F(d.root,{selected:n});return a.createElement(Cr,{href:i,className:u},a.createElement(Ce,{result:e}),a.createElement(m,{variant:"body2"},t),r?a.createElement(Re,{timestamp:r}):null)},Q=()=>{const e=Ee();return a.createElement(L,null,a.createElement("div",{className:e.root},a.createElement(f,{width:24,height:24}),a.createElement(m,{variant:"body2"},a.createElement(f,null)),a.createElement(f,{width:100,height:24})))},Pr=()=>{const e=Pe();return a.createElement("div",{className:e.root},a.createElement(W,null),new Array(3).fill(null).map((t,r)=>a.createElement(a.Fragment,{key:`skeleton-level-${r}`},a.createElement(hr,null),a.createElement("ul",{className:e.checks},a.createElement(Q,null),a.createElement(Q,null),a.createElement(Q,null)))))},wr=p(e=>({noChecks:{padding:e.spacing(1)},checks:{padding:0,margin:0,flex:1,listStyle:"none"},checkItem:{borderBottom:`1px solid ${e.palette.divider}`,"&:last-of-type":{borderBottom:"0"}}})),$r=({checks:e,trackId:t,checkId:r})=>{const n=wr(),i=j(oe);return e.length?a.createElement("ul",{className:n.checks},e.map(d=>a.createElement("li",{key:d.id,className:n.checkItem},a.createElement(Er,{...d,selected:d.id===r,href:i({trackId:t,checkId:d.id})})))):a.createElement(m,{variant:"body2",className:n.noChecks},"No applicable checks at this level.")},br=({level:e,checkId:t,trackId:r})=>{var n;return a.createElement(a.Fragment,null,a.createElement(pr,{badge:e.badge,title:e.name,description:e.description}),a.createElement($r,{checks:(n=e.checks)!=null?n:[],trackId:r,checkId:t}))},Pe=p(e=>({root:{borderRight:`1px solid ${e.palette.divider}`},checks:{padding:0,margin:0,flex:1,listStyle:"none"}})),Sr=({trackId:e,checkId:t})=>{var r,n;const i=Pe(),{entity:d}=te(),{data:u,isLoading:h,isError:v}=de(d,e);return v?a.createElement("div",{className:i.root},a.createElement(J,{padding:2},a.createElement(G,{severity:"error",title:"Error loading certification"}))):h||!e?a.createElement(Pr,null):u?a.createElement("div",{className:i.root},a.createElement(ke,{name:u.program.name,level:(r=u.highestLevel)==null?void 0:r.name,badge:(n=u.highestLevel)==null?void 0:n.badge,description:u.program.description,documentationUrl:u.program.documentationURL}),u==null?void 0:u.levels.map(y=>a.createElement(br,{key:y.ordinal,level:y,checkId:t,trackId:e}))):null},Ir=()=>a.createElement(a.Fragment,null,a.createElement(W,{hideDescription:!0}),a.createElement(W,{hideDescription:!0})),we=({className:e,description:t="There are no tracks configured that apply to this entity."})=>a.createElement("div",{className:e},a.createElement(ee,{title:"No certifications available",missing:"data",description:t})),Fr=({ownerEntityRef:e,selectGroupHint:t})=>e?a.createElement(ee,{missing:"data",title:"Missing entities",description:a.createElement(a.Fragment,null,"The group '",Xe(et(e),{defaultKind:"Group"}),"' doesn't own any entities.",t&&a.createElement(a.Fragment,null,a.createElement("br",null),a.createElement("br",null),t))}):null,$e="soundcheck",be="Submitted check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present.",Se=Qe(e=>({certificationWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center"},infoCard:{display:"grid",gridRowGap:e.spacing(2)},emptyState:{"& > div":{backgroundColor:e.palette.background.paper}}})),A=({children:e,title:t})=>{const r=Se();return a.createElement(Je,{title:t},a.createElement("div",{className:r.infoCard},a.createElement(Ze,{inline:!0,backend:$e,invalidLicenseMessage:be}),e))},Dr=({title:e="Soundcheck"})=>{const{entity:t}=te(),r=Se(),{data:n,isError:i,isLoading:d}=le(t),u=j(ce);return i?a.createElement(A,{title:e},a.createElement(G,{severity:"error",title:"Error loading certifications"})):d||!n?a.createElement(A,{title:e},a.createElement(Ir,null)):n.length===0?a.createElement(A,{title:e},a.createElement(we,{className:r.emptyState})):a.createElement(A,{title:e},n.map((h,v)=>{var y,w;return a.createElement(ze,{key:h.program.name},a.createElement("div",{className:r.certificationWrapper,"data-testid":"soundcheck-track-row"},a.createElement(ke,{key:h.program.id,name:h.program.name,badge:(y=h.highestLevel)==null?void 0:y.badge,level:(w=h.highestLevel)==null?void 0:w.name}),a.createElement(Z,{to:u({trackId:h.program.id})},"View Details")),v<n.length-1?a.createElement(_e,null):null)}))};export{G as A,ne as B,Sr as C,_t as E,L as F,Xt as G,U as L,me as M,ye as N,ue as Q,g as R,tr as S,Re as a,le as b,ce as c,we as d,$e as e,oe as f,Dr as g,Ce as h,be as i,Fr as j,nr as k,cr as l,Vt as m,ar as n,k as o,Jt as p,Yt as q,Zt as r,N as s,Kt as t,de as u,sr as w};
|
|
388
|
-
//# sourceMappingURL=index-
|
|
387
|
+
${ht}`,Mt=(e,t,r)=>e();function zt(e,t=Mt){return{createCheck(r,n){return t(i=>e.request(gt,r,{...n,...i}),"createCheck","mutation")},createProgram(r,n){return t(i=>e.request(ft,r,{...n,...i}),"createProgram","mutation")},deleteChecker(r,n){return t(i=>e.request(yt,r,{...n,...i}),"deleteChecker","mutation")},deleteProgram(r,n){return t(i=>e.request(kt,r,{...n,...i}),"deleteProgram","mutation")},updateCheck(r,n){return t(i=>e.request(vt,r,{...n,...i}),"updateCheck","mutation")},updateCollectorConfig(r,n){return t(i=>e.request(Rt,r,{...n,...i}),"updateCollectorConfig","mutation")},updateProgram(r,n){return t(i=>e.request(Ct,r,{...n,...i}),"updateProgram","mutation")},getAllCertifications(r,n){return t(i=>e.request(Et,r,{...n,...i}),"getAllCertifications","query")},getAllPrograms(r,n){return t(i=>e.request(Pt,r,{...n,...i}),"getAllPrograms","query")},getCertificationDetails(r,n){return t(i=>e.request(wt,r,{...n,...i}),"getCertificationDetails","query")},getCheckResultDetails(r,n){return t(i=>e.request($t,r,{...n,...i}),"getCheckResultDetails","query")},getCheckers(r,n){return t(i=>e.request(bt,r,{...n,...i}),"getCheckers","query")},getEntityRefsForTechHealthFilter(r,n){return t(i=>e.request(St,r,{...n,...i}),"getEntityRefsForTechHealthFilter","query")},getFacetsForOwner(r,n){return t(i=>e.request(It,r,{...n,...i}),"getFacetsForOwner","query")},getCollectors(r,n){return t(i=>e.request(Ft,r,{...n,...i}),"getCollectors","query")},getFactSchemas(r,n){return t(i=>e.request(Dt,r,{...n,...i}),"getFactSchemas","query")},getIndividualCheckPassRates(r,n){return t(i=>e.request(Ot,r,{...n,...i}),"getIndividualCheckPassRates","query")},getIndividualEntityPassRates(r,n){return t(i=>e.request(Nt,r,{...n,...i}),"getIndividualEntityPassRates","query")},getIndividualGroupPassRates(r,n){return t(i=>e.request(qt,r,{...n,...i}),"getIndividualGroupPassRates","query")},getIndividualTrackPassRate(r,n){return t(i=>e.request(Tt,r,{...n,...i}),"getIndividualTrackPassRate","query")},getOverallCheckPassRates(r,n){return t(i=>e.request(Gt,r,{...n,...i}),"getOverallCheckPassRates","query")},getOverallEntityPassRates(r,n){return t(i=>e.request(Lt,r,{...n,...i}),"getOverallEntityPassRates","query")},getOverallGroupPassRates(r,n){return t(i=>e.request(At,r,{...n,...i}),"getOverallGroupPassRates","query")},getOverallTrackPassRate(r,n){return t(i=>e.request(xt,r,{...n,...i}),"getOverallTrackPassRate","query")},getProgramOverviewForOwner(r,n){return t(i=>e.request(Bt,r,{...n,...i}),"getProgramOverviewForOwner","query")}}}var se=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},s=(e,t,r)=>(se(e,t,"read from private field"),r?r.call(e):t.get(e)),P=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},B=(e,t,r,n)=>(se(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),D,O,o,M,l;const N=Oe({id:"plugin.soundcheck"}),Ut=e=>"response"in e&&"errors"in e.response,Ht=e=>"response"in e&&"message"in e.response;class Wt{constructor(t){P(this,D,void 0),P(this,O,void 0),P(this,o,void 0),P(this,M,n=>{var i,d,u;return Ut(n)?(u=(d=(i=n.response)==null?void 0:i.errors)==null?void 0:d[0].message)!=null?u:`${n}`:Ht(n)?n.response.message:`${n}`}),P(this,l,async n=>{try{return await n()}catch(i){throw new Error(`Error from Soundcheck backend: ${s(this,M).call(this,i)}`)}}),B(this,D,t.fetchApi),B(this,O,t.discoveryApi);const r=new xe("/graphql",{fetch:async(n,i)=>{const d=`${await s(this,O).getBaseUrl("soundcheck")}${n}`;return s(this,D).fetch(d,i)}});B(this,o,zt(r))}async getAllCertifications(t){return s(this,l).call(this,async()=>{const{certifications:r}=await s(this,o).getAllCertifications({entityRef:t});return r})}async getCertificationDetails(t,r){return s(this,l).call(this,async()=>{const{programCertification:n}=await s(this,o).getCertificationDetails({entityRef:t,programId:r});return n})}async getCheckResultDetails(t,r,n){return s(this,l).call(this,async()=>{const{checkResult:i}=await s(this,o).getCheckResultDetails({entityRef:t,programId:r,checkId:n});return i})}async getFacetsForOwner(t){return s(this,l).call(this,async()=>{const{facetsForOwner:r}=await s(this,o).getFacetsForOwner({ownerEntityRef:t});return r})}async getProgramOverviewForOwner(t,r){return s(this,l).call(this,async()=>{const{programOverviewForOwner:n}=await s(this,o).getProgramOverviewForOwner({ownerEntityRef:t,facet:r});return n})}async getAllPrograms(t,r,n){return s(this,l).call(this,async()=>{const{programs:i}=await s(this,o).getAllPrograms({programIds:t,first:r,after:n});return i})}async createProgram(t){return s(this,l).call(this,async()=>{const{program:r}=await s(this,o).createProgram({input:t});return r})}async updateProgram(t){return s(this,l).call(this,async()=>{const{program:r}=await s(this,o).updateProgram({input:t});return r})}async deleteProgram(t){return s(this,l).call(this,async()=>{const{programDeleted:r}=await s(this,o).deleteProgram({programId:t});return r})}async getChecks(t,r,n){return s(this,l).call(this,async()=>{const{checkers:i}=await s(this,o).getCheckers({ids:t,first:r,after:n});return i})}async createCheck(t){return s(this,l).call(this,async()=>{const{check:r}=await s(this,o).createCheck({input:t});return r})}async updateCheck(t){return s(this,l).call(this,async()=>{const{check:r}=await s(this,o).updateCheck({input:t});return r})}async deleteCheck(t){return s(this,l).call(this,async()=>await s(this,o).deleteChecker({checkerId:t}))}async getCollectors(t){return s(this,l).call(this,async()=>{const{collectors:r}=await s(this,o).getCollectors({ids:t});return r})}async getFactSchema(t,r){if(!(!t||!r))return s(this,l).call(this,async()=>{const{factSchema:n}=await s(this,o).getFactSchemas({collectorId:t,factName:r});return n})}async updateCollectorConfig(t){return s(this,l).call(this,async()=>{const{collector:r}=await s(this,o).updateCollectorConfig({input:t});return r})}async getOverallCheckPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallCheckPassRates({filter:t}))}async getIndividualCheckPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualCheckPassRates({filter:t}))}async getOverallTrackPassRate(t){return s(this,l).call(this,async()=>await s(this,o).getOverallTrackPassRate({filter:t}))}async getIndividualTrackPassRate(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualTrackPassRate({filter:t}))}async getOverallEntityPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallEntityPassRates({filter:t}))}async getIndividualEntityPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualEntityPassRates({filter:t}))}async getOverallGroupPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getOverallGroupPassRates({filter:t}))}async getIndividualGroupPassRates(t){return s(this,l).call(this,async()=>await s(this,o).getIndividualGroupPassRates({filter:t}))}async getEntityRefsForTechHealthFilter(t){return s(this,l).call(this,async()=>await s(this,o).getEntityRefsForTechHealthFilter({ownerEntityRef:t}))}}D=new WeakMap,O=new WeakMap,o=new WeakMap,M=new WeakMap,l=new WeakMap;const q=$({id:"soundcheck-entity"}),Qt=$({id:"soundcheck-group"}),ce=R({id:"soundcheck-entity-certification-track-redirect",parent:q,path:"/:trackId"}),oe=R({id:"soundcheck-entity-certification",parent:q,path:"/:trackId/:checkId"}),jt=$({id:"soundcheck-overview"}),T=$({id:"soundcheck"}),Vt=R({id:"soundcheck-checks",parent:T,path:"/checks"});R({id:"soundcheck-tracks",parent:T,path:"/tracks"});const Kt=R({id:"soundcheck-track-details",parent:T,path:"/tracks/:trackId"}),k=Ne({id:"soundcheck",apis:[qe({api:N,deps:{discoveryApi:Te,fetchApi:Ge},factory:e=>new Wt(e)})],routes:{entityContent:q}}),_t=k.provide(b({name:"EntitySoundcheckContent",component:()=>import("./EntitySoundcheckContent-61aee236.esm.js").then(e=>e.EntitySoundcheckContent),mountPoint:q})),Jt=k.provide(Le({name:"EntitySoundcheckCard",component:{lazy:()=>import("./index-e3458e3b.esm.js").then(e=>e.EntitySoundcheckCard)}})),Xt=k.provide(b({name:"GroupSoundcheckContent",component:()=>import("./index-7f1f7ff1.esm.js").then(e=>e.FixedGroupOverviewPage),mountPoint:Qt})),Yt=k.provide(b({name:"SoundcheckOverviewPage",component:()=>import("./index-7f1f7ff1.esm.js").then(e=>e.OverviewPage),mountPoint:jt})),Zt=k.provide(b({name:"SoundcheckRoutingPage",component:()=>import("./index-0208f72c.esm.js").then(e=>e.RoutingPage),mountPoint:T})),er=We(e=>new Ue({defaultOptions:{queries:{refetchInterval:6e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",retry:2,retryDelay:t=>{const r=450+Math.ceil(Math.random()*100);return Math.min(r*2**t,3e4)},onError:t=>e.post(t)}}})),tr=e=>{const t=x(Ae),r=er(t);return a.createElement(He,{client:r},e.children)};function le(e){const t=x(N),r=re(e);return _(["soundcheck/certifications",r],async()=>t.getAllCertifications(r))}function de(e,t){const r=x(N),n=re(e);return _(["soundcheck/certifications",n,t],async()=>r.getCertificationDetails(n,t),{enabled:!!t})}var ue=(e=>(e.GetAllPrograms="soundcheck/programs",e.GetChecks="soundcheck/checks",e.GetCollectors="soundcheck/collectors",e.GetFactSchema="soundcheck/collectors/schema",e.GetEntityFacets="soundcheck/catalog/facets",e.GetSoftwareEntityRefsForUser="soundcheck/entities/softwareEntityRefsForUser",e.GetOverallCheckPassRates="soundcheck/charts/overallCheckPassRates",e.GetIndividualCheckPassRate="soundcheck/charts/getIndividualCheckPassRate",e.GetOverallTrackPassRate="soundcheck/charts/overallTrackPassRate",e.GetIndividualTrackPassRate="soundcheck/charts/individualTrackPassRate",e.GetOverallEntityPassRates="soundcheck/charts/overallEntityPassRates",e.GetIndividualEntityPassRate="soundcheck/charts/individualEntityPassRate",e.GetOverallGroupPassRates="soundcheck/charts/overallGroupPassRates",e.GetIndividualGroupPassRates="soundcheck/charts/individualGroupPassRates",e.EntityByRef="soundcheck/catalog/entityByRef",e))(ue||{}),me=(e=>(e.DeleteCheck="soundcheck/deleteCheck",e.CreateCheck="soundcheck/createCheck",e.UpdateCheck="soundcheck/updateCheck",e.DeleteProgram="soundcheck/deleteProgram",e.CreateProgram="soundcheck/createProgram",e.UpdateProgram="soundcheck/updateProgram",e.UpdateCollectorConfig="soundcheck/updateCollectorConfig",e))(me||{});const rr=p(e=>({root:{padding:e.spacing(3)},icon:{display:"none"},message:{padding:0},type:{fontWeight:700,lineHeight:1.75}})),G=e=>{const{type:t,...r}=rr();return a.createElement(tt,{severity:e.severity,elevation:1,classes:r,onClose:e.onClose},a.createElement(m,{classes:{root:t}},e.title),e.children)},pe=V({}),ar=e=>{const[t,r]=S(),n=C(d=>{r(d)},[]),i=C(()=>{r(null)},[]);return a.createElement(pe.Provider,{value:{showAlert:n,clearAlert:i}},t&&a.createElement(G,{severity:t.severity,title:t.title,onClose:i},t.message),e.children)},nr=()=>K(pe),ir=p(e=>({modalContent:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",padding:"25px",backgroundColor:e.palette.type==="dark"?e.palette.grey[800]:e.palette.grey[200]},modalButtons:{display:"flex",justifyContent:"space-evenly","& button":{width:"40%",maxWidth:"185px"}},modalMessage:{margin:"15px 0 35px"}})),he=V({}),sr=e=>{const t=ir(),[r,n]=S(!1),[i,d]=S(),u=Be(),h=C(({title:w,message:Ie,error:Fe})=>(d({title:w,message:Ie,error:Fe}),n(!0),new Promise(De=>{u.current=De})),[]),v=C(()=>{u.current&&u.current(!0),n(!1)},[]),y=C(()=>{u.current&&u.current(!1),n(!1)},[]);return a.createElement(he.Provider,{value:{showModal:h}},e.children,i&&a.createElement(je,{open:r,onClose:y,"aria-labelledby":"confirmation-modal-title","aria-describedby":"confirmation-modal-description"},a.createElement(J,{className:t.modalContent},a.createElement(m,{id:"confirmation-modal-title",variant:"h6"},i.title),a.createElement(m,{className:t.modalMessage,id:"confirmation-modal-description",variant:"body1"},i.message),a.createElement("div",{className:t.modalButtons},!i.error&&a.createElement(X,{onClick:y,variant:"contained","aria-label":"cancel"},"Cancel"),a.createElement(X,{color:"primary",onClick:v,variant:"contained","aria-label":"confirm"},i.error?"Ok":"Confirm")))))},cr=()=>K(he),ge=24,or=11,z=e=>e==="small"?1:2,lr=p({root:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",borderWidth:"2px",fontWeight:700,width:({size:e})=>`${ge*z(e)}px`,height:({size:e})=>`${ge*z(e)}px`,fontSize:({size:e})=>`${or*z(e)}px`}}),fe=({className:e,label:t,size:r="small"})=>{const n=lr({size:r});return a.createElement("span",{className:F(e,n.root),role:"img","aria-label":`${t} badge`},t)},dr=p(e=>({root:{background:({color:t})=>t,color:e.palette.common.black,borderColor:e.palette.common.black,borderStyle:"solid","&::after":{position:"absolute",display:"block",content:'""',top:0,left:0,width:"100%",height:"100%",borderRadius:"50%",boxShadow:["inset 0 -0.18em 0 0 rgba(0, 0, 0, 0.25)","inset 0px 0.18em 0px 0px rgba(255, 255, 255, 0.5)","inset 0px 1.3em 0px -0.5em rgba(255, 255, 255, 0.2)"].join(",")}}})),U=({className:e,badge:t,size:r="small"})=>{const n=dr({color:t.options.color,size:r});return a.createElement(fe,{className:F(e,n.root),size:r,label:`L${t.options.level}`})},ur=p({root:{borderColor:"currentColor",borderStyle:"dashed"}}),ye=({className:e,size:t="small"})=>{const r=ur();return a.createElement(fe,{className:F(e,r.root),size:t,label:"NL"})},H=p(e=>({description:{padding:0,margin:0,display:"block","& p":{margin:0}},root:{padding:e.spacing(2),margin:0,display:"grid",gridTemplateColumns:"min-content auto",gridGap:e.spacing(2)},title:{fontSize:e.typography.pxToRem(18),fontWeight:700,lineHeight:1.235,marginBottom:"6px"},level:{textTransform:"uppercase",color:e.palette.text.secondary,fontWeight:700,letterSpacing:"1px"}}));function mr({description:e,documentationUrl:t}){const r=H();return t?a.createElement("div",{className:r.description},a.createElement(Y,{content:e}),a.createElement(Z,{to:t},"Learn more")):a.createElement("div",{className:r.description},a.createElement(Y,{content:e}))}const ke=({name:e,level:t,badge:r,description:n,documentationUrl:i})=>{const d=H();return a.createElement("div",{className:d.root},r?a.createElement(U,{size:"large",badge:r}):a.createElement(ye,{size:"large"}),a.createElement("div",null,a.createElement(m,{variant:"caption",className:d.level},t!=null?t:"No Level"),a.createElement(m,{className:d.title},e),n&&a.createElement(mr,{description:n,documentationUrl:i})))},L=({children:e})=>{const[t,r]=S(!1);return Me(()=>{const n=setTimeout(()=>{r(!0)},250);return()=>clearTimeout(n)},[]),a.createElement(Ve,{in:t,timeout:250},e)},W=({hideDescription:e=!1})=>{const t=H();return a.createElement(L,null,a.createElement("div",{className:t.root},a.createElement(f,{width:44,height:44}),a.createElement("div",null,a.createElement(m,{variant:"caption",className:t.level},a.createElement(f,{width:100})),a.createElement(m,{variant:"h4",className:t.title},a.createElement(f,{width:300})),!e&&a.createElement(m,{variant:"body2"},a.createElement(f,null)))))},ve=p(e=>{const t=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{wrapper:{backgroundColor:t,color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.caption.fontSize,minHeight:"auto",borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`,padding:e.spacing(1),display:"grid",gridTemplateAreas:({badge:r})=>[`"${r?"badge":"title"} title"`,`"${r?".":"description"} description"`].join(" "),gridTemplateColumns:"auto 1fr"},title:{gridArea:"title",textTransform:"uppercase",fontWeight:"bold",color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.body2.fontSize,paddingTop:e.spacing(.5),paddingBottom:e.spacing(.5),lineHeight:1},badge:{gridArea:"badge",marginRight:e.spacing(1)},description:{gridArea:"description",color:E(e.palette.getContrastText(t),.8),fontSize:e.typography.subtitle2.fontSize,marginTop:e.spacing(1)}}}),pr=e=>{const t=ve({badge:e.badge});return a.createElement("div",{className:t.wrapper},e.badge?a.createElement(U,{className:t.badge,badge:e.badge}):null,a.createElement(m,{className:t.title},e.title),e.description?a.createElement(m,{className:t.description},e.description):null)},hr=()=>{const e=ve({});return a.createElement(L,null,a.createElement("div",{className:e.wrapper},a.createElement(f,{className:e.title}),a.createElement(m,{className:e.description},a.createElement(f,null))))},gr=p(e=>({root:{display:"inline-flex",alignItems:"center",gap:e.spacing(1)}})),Re=({timestamp:e,description:t})=>{const r=gr(),n=ae.fromISO(e).toLocaleString(ae.DATETIME_FULL),i=Ye(e),d=t?`${t}: ${i}`:void 0;return a.createElement("div",{className:r.root},a.createElement(Ke,{title:n},a.createElement(m,{variant:"caption","aria-label":d},i)),a.createElement(at,null))},fr=e=>({[g.Passed]:"Check passed",[g.NotReported]:"Check not reported",[g.Failed]:"Check failed",[g.NotApplicable]:"Check not applicable"})[e],yr=I(e=>({root:{color:e.palette.success.main}}))(nt),kr=I(e=>({root:{color:e.palette.error.main}}))(it),vr=I(e=>({root:{color:e.palette.info.main}}))(ct),Rr=I(e=>({root:{color:e.palette.text.disabled}}))(st),Ce=({result:e,className:t})=>{const r={className:t,"aria-label":fr(e),"aria-hidden":!1};return e===g.Passed?a.createElement(yr,{...r}):e===g.NotReported?a.createElement(vr,{...r}):e===g.Failed?a.createElement(kr,{...r}):e===g.NotApplicable?a.createElement(Rr,{...r}):null},Ee=p(e=>({root:{display:"grid",width:"100%",gridTemplateColumns:"auto 1fr auto",gridColumnGap:e.spacing(1),padding:e.spacing(1),alignItems:"center","&.selected":{backgroundColor:E(e.palette.primary[e.palette.type],.2)},"&:hover, &:active, &:focus":{backgroundColor:E(e.palette.primary[e.palette.type],.3)}}})),Cr=({className:e,href:t,children:r})=>t?a.createElement(rt,{to:t,className:e},r):a.createElement("div",{className:e},r),Er=({result:e,name:t,timestamp:r,selected:n=!1,href:i})=>{const d=Ee(),u=F(d.root,{selected:n});return a.createElement(Cr,{href:i,className:u},a.createElement(Ce,{result:e}),a.createElement(m,{variant:"body2"},t),r?a.createElement(Re,{timestamp:r}):null)},Q=()=>{const e=Ee();return a.createElement(L,null,a.createElement("div",{className:e.root},a.createElement(f,{width:24,height:24}),a.createElement(m,{variant:"body2"},a.createElement(f,null)),a.createElement(f,{width:100,height:24})))},Pr=()=>{const e=Pe();return a.createElement("div",{className:e.root},a.createElement(W,null),new Array(3).fill(null).map((t,r)=>a.createElement(a.Fragment,{key:`skeleton-level-${r}`},a.createElement(hr,null),a.createElement("ul",{className:e.checks},a.createElement(Q,null),a.createElement(Q,null),a.createElement(Q,null)))))},wr=p(e=>({noChecks:{padding:e.spacing(1)},checks:{padding:0,margin:0,flex:1,listStyle:"none"},checkItem:{borderBottom:`1px solid ${e.palette.divider}`,"&:last-of-type":{borderBottom:"0"}}})),$r=({checks:e,trackId:t,checkId:r})=>{const n=wr(),i=j(oe);return e.length?a.createElement("ul",{className:n.checks},e.map(d=>a.createElement("li",{key:d.id,className:n.checkItem},a.createElement(Er,{...d,selected:d.id===r,href:i({trackId:t,checkId:d.id})})))):a.createElement(m,{variant:"body2",className:n.noChecks},"No applicable checks at this level.")},br=({level:e,checkId:t,trackId:r})=>{var n;return a.createElement(a.Fragment,null,a.createElement(pr,{badge:e.badge,title:e.name,description:e.description}),a.createElement($r,{checks:(n=e.checks)!=null?n:[],trackId:r,checkId:t}))},Pe=p(e=>({root:{borderRight:`1px solid ${e.palette.divider}`},checks:{padding:0,margin:0,flex:1,listStyle:"none"}})),Sr=({trackId:e,checkId:t})=>{var r,n;const i=Pe(),{entity:d}=te(),{data:u,isLoading:h,isError:v}=de(d,e);return v?a.createElement("div",{className:i.root},a.createElement(J,{padding:2},a.createElement(G,{severity:"error",title:"Error loading certification"}))):h||!e?a.createElement(Pr,null):u?a.createElement("div",{className:i.root},a.createElement(ke,{name:u.program.name,level:(r=u.highestLevel)==null?void 0:r.name,badge:(n=u.highestLevel)==null?void 0:n.badge,description:u.program.description,documentationUrl:u.program.documentationURL}),u==null?void 0:u.levels.map(y=>a.createElement(br,{key:y.ordinal,level:y,checkId:t,trackId:e}))):null},Ir=()=>a.createElement(a.Fragment,null,a.createElement(W,{hideDescription:!0}),a.createElement(W,{hideDescription:!0})),we=({className:e,description:t="There are no tracks configured that apply to this entity."})=>a.createElement("div",{className:e},a.createElement(ee,{title:"No certifications available",missing:"data",description:t})),Fr=({ownerEntityRef:e,selectGroupHint:t})=>e?a.createElement(ee,{missing:"data",title:"Missing entities",description:a.createElement(a.Fragment,null,"The group '",Xe(et(e),{defaultKind:"Group"}),"' doesn't own any entities.",t&&a.createElement(a.Fragment,null,a.createElement("br",null),a.createElement("br",null),t))}):null,$e="soundcheck",be="Submitted check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present.",Se=Qe(e=>({certificationWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center"},infoCard:{display:"grid",gridRowGap:e.spacing(2)},emptyState:{"& > div":{backgroundColor:e.palette.background.paper}}})),A=({children:e,title:t})=>{const r=Se();return a.createElement(Je,{title:t},a.createElement("div",{className:r.infoCard},a.createElement(Ze,{inline:!0,backend:$e,invalidLicenseMessage:be}),e))},Dr=({title:e="Soundcheck"})=>{const{entity:t}=te(),r=Se(),{data:n,isError:i,isLoading:d}=le(t),u=j(ce);return i?a.createElement(A,{title:e},a.createElement(G,{severity:"error",title:"Error loading certifications"})):d||!n?a.createElement(A,{title:e},a.createElement(Ir,null)):n.length===0?a.createElement(A,{title:e},a.createElement(we,{className:r.emptyState})):a.createElement(A,{title:e},n.map((h,v)=>{var y,w;return a.createElement(ze,{key:h.program.name},a.createElement("div",{className:r.certificationWrapper,"data-testid":"soundcheck-track-row"},a.createElement(ke,{key:h.program.id,name:h.program.name,badge:(y=h.highestLevel)==null?void 0:y.badge,level:(w=h.highestLevel)==null?void 0:w.name}),a.createElement(Z,{to:u({trackId:h.program.id})},"View Details")),v<n.length-1?a.createElement(_e,null):null)}))};export{G as A,ne as B,Sr as C,_t as E,L as F,Xt as G,U as L,me as M,ye as N,ue as Q,g as R,tr as S,Re as a,le as b,ce as c,we as d,$e as e,oe as f,Dr as g,Ce as h,be as i,Fr as j,nr as k,cr as l,Vt as m,ar as n,k as o,Jt as p,Yt as q,Zt as r,N as s,Kt as t,de as u,sr as w};
|
|
388
|
+
//# sourceMappingURL=index-7b347cd4.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useState as n}from"react";import{Page as g,Header as f}from"@backstage/core-components";import{SpotifyLicenseBanner as s}from"@spotify/backstage-plugin-core";import{u as h,U as P,G as S,O as c}from"./OverviewPageContent-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import e,{useState as n}from"react";import{Page as g,Header as f}from"@backstage/core-components";import{SpotifyLicenseBanner as s}from"@spotify/backstage-plugin-core";import{u as h,U as P,G as S,O as c}from"./OverviewPageContent-31025374.esm.js";import{S as l,w as y,e as p,i as u}from"./index-7b347cd4.esm.js";import{stringifyEntityRef as k}from"@backstage/catalog-model";import"@backstage/core-plugin-api";import"@tanstack/react-query";import{useEntity as w}from"@backstage/plugin-catalog-react";import{makeStyles as C}from"@material-ui/core";import{Routes as G,Route as L}from"react-router-dom";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-e114bc04.esm.js";import"react-use/lib/useDebounce";import"lodash";import"@material-ui/lab";import"react-window";import"graphql-request";import"graphql-tag";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";const O=C(t=>({overviewContainer:{padding:t.spacing(1,3)}})),b=t=>{const{title:i="Soundcheck"}=t,o=O(),[r,a]=h(),{group:d}=r,[E,v]=n(void 0);return e.createElement(l,null,e.createElement(P,null,e.createElement(y,null,e.createElement(g,{themeId:"website"},e.createElement(s,{backend:p,invalidLicenseMessage:u}),e.createElement(f,{title:i},e.createElement(S,{onChange:m=>{m&&a({...r,group:m})},initialValue:d,setError:v})),e.createElement("div",{className:o.overviewContainer},e.createElement(c,{groupSelectorError:E,searchParams:r,setSearchParams:a}))))))},x=()=>{const{entity:t}=w(),i={group:k(t)},[o,r]=n(i);return e.createElement(l,null,e.createElement(G,null,e.createElement(L,{path:"/*",element:e.createElement(e.Fragment,null,e.createElement(s,{backend:p,invalidLicenseMessage:u,inline:!0}),e.createElement(c,{searchParams:o,setSearchParams:r,isFixedGroup:!0}))})))};export{x as FixedGroupOverviewPage,b as OverviewPage};
|
|
2
|
+
//# sourceMappingURL=index-7f1f7ff1.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"react";import{S as o,g as i}from"./index-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import t from"react";import{S as o,g as i}from"./index-7b347cd4.esm.js";import"@backstage/core-plugin-api";import"graphql-request";import"graphql-tag";import"@tanstack/react-query";import"lodash";import"@material-ui/core/styles/makeStyles";import"@material-ui/core";import"@backstage/core-components";import"@backstage/plugin-catalog-react";import"@spotify/backstage-plugin-core";import"@backstage/catalog-model";import"@material-ui/lab";import"react-router-dom";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";const m=({title:r})=>t.createElement(o,null,t.createElement(i,{title:r}));export{m as EntitySoundcheckCard};
|
|
2
|
+
//# sourceMappingURL=index-e3458e3b.esm.js.map
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as f,E as l,G as q,q as w,r as x,o as O}from"./esm/index-
|
|
1
|
+
import{p as f,E as l,G as q,q as w,r as x,o as O}from"./esm/index-7b347cd4.esm.js";import"react";import"@backstage/core-plugin-api";import"graphql-request";import"graphql-tag";import"@tanstack/react-query";import"lodash";import"@material-ui/core/styles/makeStyles";import"@material-ui/core";import"@backstage/core-components";import"@backstage/plugin-catalog-react";import"@spotify/backstage-plugin-core";import"@backstage/catalog-model";import"@material-ui/lab";import"react-router-dom";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";export{f as EntitySoundcheckCard,l as EntitySoundcheckContent,q as GroupSoundcheckContent,w as SoundcheckOverviewPage,x as SoundcheckRoutingPage,O as soundcheckPlugin};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spotify/backstage-plugin-soundcheck",
|
|
3
3
|
"description": "Ensure quality, reliability and alignment of software development with codified checks and guidance.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.2",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://backstage.spotify.com",
|
|
7
7
|
"main": "dist/index.esm.js",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import t,{useState as C,useCallback as j,createContext as Pe,useContext as Se,useEffect as A,useMemo as B,useReducer as Zt,useRef as Tn,memo as Pn}from"react";import{useSearchParams as Jt,useNavigate as Sn,Routes as ea,Route as ta,useLocation as Ln}from"react-router-dom";import{MarkdownContent as aa,Link as Rn,DismissableBanner as Dn,TabbedLayout as z,Page as In,Header as On}from"@backstage/core-components";import{DATA_VIZ_DARK_THEME as An,DATA_VIZ_LIGHT_THEME as Fn,SpotifyLicenseBanner as $n}from"@spotify/backstage-plugin-core";import{Box as k,Paper as Le,Grid as h,Button as _,Slide as Mn,Dialog as Bn,AppBar as Vn,Toolbar as zn,Typography as b,IconButton as he,TextField as M,Collapse as Gn,makeStyles as x,ButtonGroup as na,Menu as ra,MenuItem as ge,FormControl as dt,InputLabel as mt,Select as ut,RadioGroup as Hn,Radio as la,Divider as He,FormControlLabel as We,Checkbox as Re,Card as pt,ListItemIcon as fe,ListItemText as Ee,withStyles as Wn,CardHeader as qn,CardContent as _n,CardActions as Un,List as oa,ListItem as De,Tooltip as oe,InputAdornment as ia,NativeSelect as sa,TablePagination as ca,Chip as ht,CircularProgress as jn,useTheme as qe,Table as Kn,TableHead as Yn,TableRow as da,TableCell as ma,TableBody as Qn,Switch as Xn,Tabs as Zn,Tab as gt}from"@material-ui/core";import{makeStyles as G,createStyles as Jn}from"@material-ui/core/styles";import{a as er,b as _e,c as tr,u as ar,U as nr,G as rr,O as lr}from"./OverviewPageContent-7cf86a3a.esm.js";import ua from"@material-ui/icons/Close";import{Controller as H,useWatch as ft,useForm as pa}from"react-hook-form";import ha from"@material-ui/icons/ArrowDropUp";import Et from"@material-ui/icons/ArrowDropDown";import ga from"@material-ui/icons/Delete";import{useApi as L,alertApiRef as or,useRouteRef as Ue}from"@backstage/core-plugin-api";import{useQuery as F,useQueryClient as ie,useMutation as se}from"@tanstack/react-query";import{s as O,Q as R,k as ee,M as ce,l as je,t as ir,m as sr,n as cr,S as dr,w as mr}from"./index-95ae147b.esm.js";import{asArray as vt,FrequencySchema as ur,parseFactRef as yt,stringifyFactRef as pr,soundcheckCheckUpdatePermission as hr,soundcheckCheckDeletePermission as gr,soundcheckCheckCreatePermission as fr,soundcheckTrackUpdatePermission as Er,soundcheckTrackDeletePermission as vr,soundcheckTrackCreatePermission as yr,soundcheckCollectorUpdatePermission as br,soundcheckCollectorReadPermission as Cr}from"@spotify/backstage-plugin-soundcheck-common";import kr from"lodash/isObject";import Ie from"lodash";import xr from"cron-validate";import wr from"cronstrue";import{v4 as fa}from"uuid";import{Autocomplete as bt,Skeleton as Ct}from"@material-ui/lab";import Ea from"@material-ui/icons/CheckBox";import va from"@material-ui/icons/CheckBoxOutlineBlank";import Nr from"@material-ui/icons/ExpandMore";import{catalogApiRef as ya,EntityRefLink as kt,humanizeEntityRef as Tr,entityRouteRef as ba}from"@backstage/plugin-catalog-react";import{parseEntityRef as K,stringifyEntityRef as Pr}from"@backstage/catalog-model";import Sr from"@material-ui/icons/MoreVert";import Ca from"@material-ui/icons/Group";import{usePermission as te}from"@backstage/plugin-permission-react";import Lr from"@material-ui/icons/Search";import{useDrag as Rr,useDrop as Dr,DndProvider as Ir}from"react-dnd";import{HTML5Backend as Or}from"react-dnd-html5-backend";import Ar from"@material-ui/icons/OpenInNew";import Fr from"@material-ui/icons/DoneAllRounded";import $r from"@material-ui/icons/Menu";import ka from"@material-ui/icons/DragIndicator";import Mr from"@material-ui/icons/Visibility";import Br from"@material-ui/icons/Add";import Vr from"@material-ui/icons/Remove";import{ResponsiveContainer as xa,LineChart as xt,CartesianGrid as Ke,XAxis as Oe,YAxis as Ae,Line as wt,Tooltip as wa,Legend as Na,BarChart as Ta,Bar as Pa,Cell as zr}from"recharts";import{DateTime as Nt}from"luxon";import{motion as Tt}from"framer-motion";import Sa from"react-use/lib/useLocalStorage";import{CircularProgressbar as Gr,buildStyles as Hr}from"react-circular-progressbar";import"react-circular-progressbar/dist/styles.css";import Wr from"../images/catalog.svg";import qr from"../images/git.svg";import _r from"../images/octocat.svg";import Ur from"../images/settings.svg";import jr from"../images/soundcheck.png";import Kr from"../images/tech_insights.png";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-b042ec49.esm.js";import"react-use/lib/useDebounce";import"react-window";import"graphql-request";import"graphql-tag";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"@material-ui/icons/Check";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function Pt(e,a,n){const r=L(O);return F([R.GetChecks,e,a,n],async()=>r.getChecks(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function La(e,a,n){const r=L(O);return F([R.GetAllPrograms,e,a,n],async()=>r.getAllPrograms(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const Yr="Error Creating Track";function Qr(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return se([ce.CreateProgram],r,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),n({severity:"error",title:Yr,message:o})}})}const Xr=()=>{const[e,a]=C([]),[n,r]=C([[]]),[l,o]=C([!1]),i=j((d,g)=>{r(p=>{const v=[...p];return v[g]=[...v[g],d],v}),a(p=>p==null?void 0:p.filter(v=>v.id!==d.id)),o(p=>{if(p[g]){const v=[...p];return v[g]=!1,v}return p})},[]),s=j((d,g)=>{r(p=>{const v=[...p];return v[g]=v[g].filter(f=>f.id!==d.id),v}),a(p=>[...p!=null?p:[],d])},[]),c=j(()=>{r(d=>[...d,[]]),o(d=>[...d,!1])},[]),u=j(d=>{n.length>1&&r(g=>{const p=[...g],v=p.splice(d,1)[0];return a(f=>[...f!=null?f:[],...v]),p})},[n]),m=j(()=>{const d=n.map(g=>g.length===0);return o(d),!d.some(g=>g)},[n]);return{chips:e,setChips:a,inputChipsList:n,handleDrop:i,handleDelete:s,addInput:c,removeInput:u,inputErrors:l,setInputErrors:o,areInputsValid:m,setInputChipsList:r}},Zr=e=>{const a=L(O);return F([R.GetOverallCheckPassRates,e],async()=>a.getOverallCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Jr=e=>{const a=L(O);return F([R.GetIndividualCheckPassRate,e],async()=>a.getIndividualCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},el=e=>{const a=L(O);return F([R.GetOverallTrackPassRate,e],async()=>a.getOverallTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},tl=e=>{const a=L(O);return F([R.GetIndividualTrackPassRate,e],async()=>a.getIndividualTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},al=e=>{const a=L(O);return F([R.GetOverallEntityPassRates,e],async()=>a.getOverallEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},nl=e=>{const a=L(O);return F([R.GetIndividualEntityPassRate,e],async()=>a.getIndividualEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},rl=e=>{const a=L(O);return F([R.GetOverallGroupPassRates,e],async()=>a.getOverallGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ll=e=>{const a=L(O);return F([R.GetIndividualGroupPassRates,e],async()=>a.getIndividualGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ol=G(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),St=({onCancel:e,saveButtonText:a,isLoading:n,onSave:r,disableSave:l})=>{const o=ol();return t.createElement(k,{className:o.box},t.createElement(Le,{elevation:3,className:o.footer},t.createElement(h,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(h,{item:!0},t.createElement(_,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(h,{item:!0},r&&t.createElement(_,{variant:"contained",color:"primary",disabled:n||l,onClick:r?()=>r():void 0},a)))))},Ra=Pe({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),il=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),[o,i]=C(!1);return t.createElement(Ra.Provider,{value:{selectedProgram:a,setSelectedProgram:n,isLoading:r,setIsLoading:l,showAddModal:o,setShowAddModal:i}},e)},ve=()=>Se(Ra),Da=Pe({selectedCheck:null,setSelectedCheck:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),sl=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),[o,i]=C(!1),[s,c]=C(!1),u=d=>{l(!0),n(d)},m=()=>{n(null),l(!1),c(!1)};return t.createElement(Da.Provider,{value:{selectedCheck:a,setSelectedCheck:n,isLoading:o,setIsLoading:i,showAddModal:s,setShowAddModal:c,isReadOnly:r,showReadOnlyModal:u,hideModal:m}},e)},Y=()=>Se(Da),cl=G(e=>({appBar:{position:"relative"},title:{flex:1,fontSize:e.typography.h6.fontSize},closeIcon:{marginRight:e.spacing(2)},content:{flex:"1 0 auto",padding:e.spacing(2),margin:"0 0 5rem",overflowX:"hidden",overflowY:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),dl=t.forwardRef(function(e,a){return t.createElement(Mn,{direction:"up",ref:a,...e})}),Lt=({open:e,handleClose:a,title:n,children:r})=>{const l=cl();return t.createElement(Bn,{fullScreen:!0,open:e,onClose:a,TransitionComponent:dl},t.createElement(Vn,{className:l.appBar},t.createElement(zn,null,t.createElement(b,{className:l.title},n),t.createElement(he,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",className:l.closeIcon},t.createElement(ua,null)))),t.createElement(k,{className:l.content},r))},Fe=({name:e,control:a,error:n,label:r,placeholder:l,disabled:o,rules:i,messages:s,helperText:c,multiline:u,minRows:m})=>t.createElement(H,{name:e,control:a,defaultValue:"",rules:i,render:({field:d})=>t.createElement(M,{...d,fullWidth:!0,multiline:u,minRows:m,placeholder:l,label:r,disabled:o,variant:"outlined",margin:"normal",error:!!n,helperText:n&&s?s[n.type]:c})}),ml=G(()=>({section:{gap:0}})),ul=({control:e,error:a,isLoading:n,disabled:r})=>{const l=ml();return t.createElement("div",{className:l.section},t.createElement(Fe,{name:"checkName",control:e,error:a,label:"Check Name",placeholder:"Choose a name",disabled:n||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},pl=G(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main,cursor:"pointer"}})),$e=({title:e,children:a})=>{const[n,r]=C(!1),l=pl(),o=()=>{r(!n)};return t.createElement("div",{className:l.root},t.createElement(h,{container:!0,alignItems:"center",spacing:0},t.createElement(h,{item:!0},t.createElement(he,{onClick:o,className:l.button},n?t.createElement(Et,{fontSize:"large"}):t.createElement(ha,{fontSize:"large"}))),t.createElement(h,{item:!0},t.createElement(b,{onClick:o,className:l.title},e))),t.createElement(Gn,{in:n},a))},hl=({control:e,passError:a,failError:n,isLoading:r,disabled:l})=>t.createElement($e,{title:l?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement(Fe,{name:"passMessage",control:e,error:a,label:"Pass Message",placeholder:"Enter pass message...",disabled:r||l}),t.createElement(Fe,{name:"failMessage",control:e,error:n,label:"Fail Message",placeholder:"Enter fail message...",disabled:r||l})),gl=({control:e,error:a,isLoading:n,disabled:r})=>t.createElement(Fe,{name:"description",control:e,error:a,label:"Check Description",disabled:n||r,multiline:!0,minRows:4,placeholder:r?void 0:"Enter a brief description about the check",helperText:r?void 0:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),fl=x(e=>({button:{backgroundColor:e.palette.background.default,color:e.palette.primary.main},label:{paddingRight:e.spacing(2)},icon:{borderLeft:`1px solid ${e.palette.primary.main}`,padding:e.spacing(1,0,0,1)},menu:{marginTop:"52px"}})),El=({onAddCondition:e,onAddExpression:a})=>{const n=fl(),[r,l]=C(null),o=!!r,i=c=>{l(c.currentTarget)},s=()=>{l(null)};return t.createElement(k,null,t.createElement(na,{color:"primary"},t.createElement(_,{id:"add-button",className:n.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:i},t.createElement(k,{className:n.label},"Add"),t.createElement(k,{className:n.icon},t.createElement(Et,null)))),t.createElement(ra,{id:"add-menu",anchorEl:r,open:o,onClose:s,classes:{paper:n.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(ge,{onClick:()=>{e(),s()}},"Add Condition"),t.createElement(ge,{onClick:()=>{a(),s()}},"Add Expression")))},Ia=({name:e,control:a,selectLabel:n,options:r,disabled:l,rules:o})=>t.createElement(H,{name:e,control:a,rules:o,render:({field:i,fieldState:s})=>t.createElement(dt,{variant:"outlined",style:{minWidth:200}},t.createElement(mt,{id:`${e}-select-label`},n),t.createElement(ut,{...i,disabled:l,error:s.invalid,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:n},r.map(({value:c,label:u})=>t.createElement(ge,{key:c,value:c},u))))});var ae=(e=>(e.AllOf="all",e.AnyOf="any",e))(ae||{});const vl={all:"ALL OF",any:"ANY OF"};var Oa=(e=>(e.Equal="equal",e.NotEqual="notEqual",e.Matches="matches",e.LessThan="lessThan",e.LessThanInclusive="lessThanInclusive",e.GreaterThan="greaterThan",e.GreaterThanInclusive="greaterThanInclusive",e.In="in",e.NotIn="notIn",e.Contains="contains",e.DoesNotContain="doesNotContain",e.SemverGt="semverGt",e.SemverGte="semverGte",e.SemverLt="semverLt",e.SemverLte="semverLte",e.SemverEq="semverEq",e.SemverNeq="semverNeq",e.SemverSatisfies="semverSatisfies",e.SemverGtr="semverGtr",e.SemverLtr="semverLtr",e.After="after",e.Before="before",e))(Oa||{});const yl={equal:"Equals",notEqual:"Does Not Equal",matches:"Matches",semverGt:"Version Greater Than",semverGte:"Version Greater Than or Equals",semverLt:"Version Less Than",semverLte:"Version Less Than or Equals",semverEq:"Version Equals",semverNeq:"Version Not Equals",semverSatisfies:"Version Satisfies Range",semverGtr:"Version Greater Than Range",semverLtr:"Version Less Than Range",lessThan:"Less Than",lessThanInclusive:"Less Than or Equals",greaterThan:"Greater Than",greaterThanInclusive:"Greater Than or Equals",in:"In Array",notIn:"Not in Array",contains:"Contains",doesNotContain:"Does Not Contain",after:"DateTime is After",before:"DateTime is Before"},bl=x(e=>({container:{borderLeft:`1px solid ${e.palette.grey[500]}`,marginLeft:e.spacing(2),padding:e.spacing(2,0,2,0),display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(0)},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"45px"},innerContainer:{backgroundColor:e.palette.background.default,border:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"column"},inputsContainer:{padding:e.spacing(2),display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:e.spacing(1)},header:{background:"linear-gradient(90deg, #007DFF 0%, #0057B2 100%)",width:"100%",height:"8px"},deleteButton:{marginLeft:e.spacing(1),width:"45px",height:"45px"},deleteIcon:{color:e.palette.type==="dark"?e.palette.background.default:e.palette.common.black}}));function Aa(e){const a=L(O);return F([R.GetCollectors,e],async()=>a.getCollectors(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Cl(e,a){const n=L(O);return F([R.GetFactSchema,e,a],()=>n.getFactSchema(e,a),{enabled:!!e&&!!a,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const Ye=()=>({selectedKinds:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[],selectedTypes:[]}),kl=[{facet:"kind",label:"Kind",key:"selectedKinds"},{facet:"spec.type",label:"Type",key:"selectedTypes"},{facet:"spec.lifecycle",label:"Lifecycle",key:"selectedLifecycles"},{facet:"spec.owner",label:"Owner",key:"selectedOwners"},{facet:"spec.system",label:"System",key:"selectedSystems"},{facet:"metadata.tags",label:"Tags",key:"selectedTags"}],ye={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},Fa=e=>!e||Object.values(e).every(a=>a.length===0)?void 0:{catalog:Object.entries(e).reduce((a,[n,r])=>{const l=ye[n];return r.length>0&&(a[l]=r),a},{})},$a=e=>Object.keys(ye).reduce((a,n)=>{var r,l;return a[n]=vt((l=(r=e==null?void 0:e.catalog)==null?void 0:r[ye[n]])!=null?l:[]),a},{}),Qe=e=>{if(!e||Object.values(e).every(n=>n.length===0))return;const a={};for(const[n,r]of Object.entries(e))(r==null?void 0:r.length)>0&&(a[ye[n]]=r);return[a]},Rt=e=>{if(e&&Array.isArray(e)&&e.length){const a=e[0];return Object.keys(ye).reduce((n,r)=>{var l;return n[r]=vt((l=a==null?void 0:a[ye[r]])!=null?l:[]),n},{})}return Ye()};var I=(e=>(e.Months="months",e.Weeks="weeks",e.Days="days",e.Hours="hours",e.Minutes="minutes",e.Seconds="seconds",e))(I||{});const Dt=()=>({type:"HumanDuration",unit:I.Hours,value:1,cron:""}),It=[I.Months,I.Weeks,I.Days,I.Hours,I.Minutes,I.Seconds];function xl(e){return It.includes(e)}function Xe(e){switch(e){case"months":return I.Months;case"weeks":return I.Weeks;case"days":return I.Days;case"hours":return I.Hours;case"minutes":return I.Minutes;case"seconds":return I.Seconds;default:return null}}function Ot(e){if(e){const{cron:a,type:n,unit:r,value:l}=e;return n==="HumanDuration"?{[r]:l}:{cron:a}}}function At(e){var a;const n=Dt();if(e&&Ie.isObject(e)){if("cron"in e)return{...n,type:"cron",cron:e.cron};const r=Object.entries(e);if(r.length){const[l,o]=r[0];return{...n,unit:(a=Xe(l))!=null?a:I.Hours,value:o}}}return n}const wl=e=>xr(e).isValid(),Ma=e=>{try{return wr.toString(e)}catch(a){return typeof a=="string"?a.replace(/^Error:\s*/,""):"Invalid cron expression"}},Ba=1,Va=31536e3,za=e=>{if(e){if(isNaN(e))return"Invalid value";if(e<1)return"Minimum of 1";if(e>31536e3)return"Maximum exceeded"}else return"Enter a value";return!0},Nl=x(e=>({divider:{marginTop:e.spacing(3),marginBottom:e.spacing(3)},title:{cursor:"pointer"}})),Ga=({value:e,onChange:a,disabled:n,errors:r})=>{var l;const o=Nl(),[i,s]=C(e),[c,u]=C(`${e.value}`);A(()=>{a&&a(i)},[i,a]);const m=E=>{s({...e,type:E.target.value})},d=E=>{u(E.target.value);const y=parseInt(E.target.value,10);s({...e,value:isNaN(y)?0:y})},g=E=>{var y;s({...i,unit:(y=Xe(E.target.value))!=null?y:I.Hours})},p=E=>{const y=E.target.value;s({...i,cron:y})},v=()=>{s({...i,type:"cron"})},f=()=>{s({...i,type:"HumanDuration"})};return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{item:!0},t.createElement(Hn,{name:"frequencyType",value:i.type,onChange:m},t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(la,{disabled:n,value:"HumanDuration"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:f},"Run on a regular interval"),t.createElement(b,{variant:"caption"},"Run on a regular interval that you define"),i.type==="HumanDuration"&&t.createElement(h,{container:!0,style:{alignItems:"flex-start"}},t.createElement(h,{item:!0},t.createElement(M,{id:"every",type:"number",inputProps:{min:Ba,max:Va},label:"Every",name:"every",disabled:n,value:c,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,onChange:d})),t.createElement(h,{item:!0},t.createElement(dt,null,t.createElement(mt,{id:"frequency-unit"},"Unit"),t.createElement(ut,{labelId:"frequency-unit",disabled:n,value:i.unit,onChange:g},It.map(E=>t.createElement(ge,{key:E,value:E},E)))))))),t.createElement(He,{className:o.divider}),t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(la,{disabled:n,value:"cron"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:v},"Run on a schedule"),t.createElement(b,{variant:"caption"},"Run on a schedule defined via cron expression"),i.type==="cron"&&t.createElement(h,{item:!0},t.createElement(M,{id:"cron-expression","data-testid":"cron-expression",style:{minWidth:250},label:(l=r==null?void 0:r.message)!=null?l:Ma(i.cron),disabled:n,placeholder:"* * * * *",error:!!(r!=null&&r.message),value:i.cron,onChange:p})))))))},Tl=(e,a,n,r)=>{const l={};return r&&r.forEach(o=>{var i,s;o&&(l[o.id]={id:o.id,name:(i=o.name)!=null?i:o.id,description:(s=o.description)!=null?s:""})}),e.map((o,i)=>{const s=o.map(c=>l[c.id]);return{name:a[i],description:n[i],ordinal:i+1,checks:s}})},Pl=e=>e.map(a=>a.checks.map(n=>{var r;return{id:n.id,label:(r=n.name)!=null?r:n.id}})),Sl=e=>{var a;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((a=e.levels)==null?void 0:a.map(n=>({ordinal:n.ordinal,name:n.name||"",description:n.description||"",checks:n.checks.map(r=>({id:r.id,name:r.name,description:r.description}))})))||[],filter:e.filter}},Ll=e=>{var a;if(kr(e)&&"frequency"in e){const n=ur.safeParse(e.frequency);if(n.success){const r=n.data;if("cron"in r)return{enabled:!0,frequency:{type:"cron",unit:I.Hours,value:1,cron:r.cron}};const l=Object.keys(r);if(l.length){const o=l[0];if(xl(o))return{enabled:!0,frequency:{type:"HumanDuration",unit:o,value:(a=r[o])!=null?a:1,cron:""}}}}}return{enabled:!1,frequency:{type:"HumanDuration",unit:I.Hours,value:1,cron:""}}},Rl=(e,a)=>{const{enabled:n,frequency:r}=e;if(n){const{cron:l,type:o,unit:i,value:s}=r;return o==="HumanDuration"?{frequency:{[i]:s},filter:Qe(a)}:{frequency:{cron:l}}}},Dl=(e,a)=>{const n=e?Pl(e.levels):[[]],r=n.flat().map(o=>o.id),l=a.filter(o=>!r.includes(o.id));return{inputChips:n,used:l}},Il=()=>({enabled:!1,frequency:Dt()}),Ft=e=>{var a;if(!e)return{};if(e.expressionType){const n={[e.expressionType]:(a=e.conditions)==null?void 0:a.map(r=>({factRef:r.factRef,path:r.path,operator:r.operator,value:r.value}))};return e.expressions&&e.expressions.forEach(r=>{var l;(l=n[e.expressionType])==null||l.push(Ft(r))}),n}if(e.expressions)return e.expressions.map(Ft);if(e.conditions&&e.conditions.length===1){const n=e.conditions[0];return{factRef:n.factRef,path:n.path,operator:n.operator,value:n.value}}return{}},Ha=(e,a=!0)=>{if(!e)return{conditions:[]};const n=Object.keys(e),r=n.includes("all")||a&&!n.includes("any")?ae.AllOf:ae.AnyOf;if(n.includes(r)||a){const l=e[r]||[e],o=[],i=[];return l.forEach(s=>{const c=Object.keys(s);c.includes("all")||c.includes("any")?i.push(Ha(s,!1)):o.push({factRef:s.factRef,path:s.path,operator:s.operator,value:s.value})}),{expressions:i.length>0?i:void 0,conditions:o,expressionType:r}}return{expressionType:ae.AllOf,conditions:[{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value}]}},Ol=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expressions:Ha(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:$a(e.filter),schedule:Ll(e.schedule)}),Al=(e,a)=>{var n,r,l,o;return{id:a?a.id:fa(),ownerEntityRef:(n=e.teamOwner)!=null?n:void 0,name:e.checkName,description:e.description,passedMessage:(r=e.passMessage)!=null?r:void 0,failedMessage:(l=e.failMessage)!=null?l:void 0,rule:Ft(e.expressions),filter:e.filters?Fa(e.filters):void 0,supportChannel:(o=e.supportChannel)!=null?o:void 0,schedule:Rl(e.schedule,e.filters)}},$t=(e,a="$")=>{const n=[];if(e.type==="object"&&e.properties){const r=e.properties;for(const l in r)if(r.hasOwnProperty(l)){const o=`${a}.${l}`;n.push(o);const i=r[l];n.push(...$t(i,o))}}if(e.type==="array"&&e.items){const r=`${a}[*]`;n.push(r);const l=Array.isArray(e.items)?e.items:[e.items];for(const o of l)n.push(...$t(o,r))}return n},Fl={checkName:"",description:"",teamOwner:"",supportChannel:"",expressions:{expressionType:ae.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:Ye(),schedule:Il()},$l=(e,a)=>{const{data:n,isLoading:r}=Aa(),l=ft({control:a,name:`${e}.factRef`}),[o,i]=C(()=>Wa(l));A(()=>{i(Wa(l))},[l]);const{data:s}=Cl(o==null?void 0:o.source,o==null?void 0:o.name),c=B(()=>s?$t(s.schema):[],[s]),u=B(()=>n==null?void 0:n.flatMap(m=>m.factNames.map(d=>{const g=yt(d,{defaultSource:m.id,defaultScope:"default"});return{label:g.name,value:pr(g)}})),[n]);return{isLoading:r,pathOptions:c,factRefOptions:u}};function Wa(e){if(e)try{return yt(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const qa=({name:e,rules:a,label:n,control:r,options:l,getOptionLabel:o,getOptionValue:i,onChange:s,onInputChange:c,disabled:u})=>t.createElement(H,{name:e,control:r,rules:a,render:({field:m,fieldState:d})=>t.createElement(bt,{...m,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:u,options:l,getOptionLabel:o,renderInput:g=>t.createElement(M,{...g,variant:"outlined",label:n,error:d.invalid,helperText:d.error?d.error.message:null}),onChange:(g,p)=>{const v=i?i(p):p;s==null||s(v),m.onChange(v)},onInputChange:(g,p)=>{const v=i?i(p):p;c==null||c(v),m.onChange(v)}})}),Ml=e=>{try{return yt(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},Bl=({control:e,name:a,handleDelete:n,disabled:r,disableDelete:l,setValue:o,getValues:i})=>{var s;const c=bl(),u=B(()=>Object.values(Oa).map(y=>({value:y,label:yl[y]})),[]),{pathOptions:m,factRefOptions:d,isLoading:g}=$l(a,e),p={required:!0},v=B(()=>{var y;return(y=d==null?void 0:d.map(w=>w.value))!=null?y:[]},[d]),f=(s=i("expressions.conditions"))==null?void 0:s.map(({factRef:y})=>y),E=y=>{y&&!(f!=null&&f.includes(y))&&(o(`${a}.path`,""),o(`${a}.operator`,""),o(`${a}.value`,""))};return t.createElement(k,{className:c.container},t.createElement(k,{className:c.connector}),t.createElement(k,{className:c.innerContainer},t.createElement(k,{className:c.header}),t.createElement(k,{className:c.inputsContainer},d&&t.createElement(qa,{name:`${a}.factRef`,control:e,rules:{...p,maxLength:500,validate:Ml},label:"Fact",options:v,getOptionLabel:y=>{var w,N;return(N=(w=d==null?void 0:d.find(D=>y===D.value))==null?void 0:w.label)!=null?N:y},getOptionValue:y=>{var w,N,D;return(D=(N=(w=d==null?void 0:d.find($=>y===$.label))==null?void 0:w.value)!=null?N:y)!=null?D:""},disabled:r||g,onChange:E,onInputChange:E}),t.createElement(qa,{name:`${a}.path`,label:"Path",rules:p,control:e,disabled:r||g,options:m}),t.createElement(Ia,{name:`${a}.operator`,rules:p,control:e,selectLabel:"Operator",options:u,disabled:r}),t.createElement(H,{name:`${a}.value`,control:e,defaultValue:"",rules:p,render:({field:y,fieldState:w})=>t.createElement(M,{...y,label:"Value",variant:"outlined",placeholder:"Enter a value",error:w.invalid,helperText:w.error?w.error.message:null,disabled:r})}))),!r&&!l&&t.createElement(he,{onClick:n,className:c.deleteButton,"data-test-id":`${a}-delete-button`},t.createElement(ga,{className:c.deleteIcon})))},Vl=({conditions:e,control:a,name:n,handleDelete:r,disabled:l,disableDelete:o,setValue:i,getValues:s,depth:c})=>t.createElement(t.Fragment,null,e.map((u,m)=>t.createElement(h,{item:!0,key:m},t.createElement(Bl,{control:a,name:`${n}.conditions[${m}]`,"data-testid":`${n}-condition-input`,handleDelete:()=>r(m),disabled:l,disableDelete:c===0&&m===0?!0:o,setValue:i,getValues:s})))),zl=({expression:e,control:a,name:n,depth:r,getValues:l,setValue:o,trigger:i,disabled:s})=>e?t.createElement(h,{item:!0},t.createElement(_a,{control:a,name:`${n}`,depth:r+1,getValues:l,setValue:o,trigger:i,disabled:s})):null,Gl=x(e=>({button:{fontWeight:700,backgroundColor:e.palette.background.default,color:e.palette.primary.main,"&:hover":{backgroundColor:"rgba(46, 119, 208, 0.2)"}},selectedButton:{backgroundColor:"rgba(46, 119, 208, 0.15)"}})),Hl=({control:e,name:a,getValues:n,disabled:r})=>{const l=Gl(),o=`${a}`,i=n(o),[s,c]=C(i||ae.AllOf),u=m=>{c(m)};return t.createElement(H,{control:e,name:a,render:({field:{onChange:m}})=>t.createElement(na,{color:"primary"},Object.values(ae).map(d=>t.createElement(_,{key:d,className:s===d?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{u(d),m(d)},disabled:r},vl[d])))})},Wl=(e,a,n,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=a(l),i=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],s=`${e}.conditions`;n(s,i),await r(s)},handleAddExpression:async()=>{const l=`${e}.expressions`,o=a(l)||[];o.push({expressionType:ae.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:""}]}),n(l,o),await r(l)},handleDeleteCondition:async(l,o)=>{const i=o.split("[")[0],s=`${o}.conditions`,c=a(s);if(c.splice(l,1),c.length===0){n(s,void 0);const u=parseInt(o.slice(o.lastIndexOf("[")+1,o.lastIndexOf("]")),10),m=a(i);m.splice(u,1),n(i,m.length>0?m:void 0),await r(i)}else n(s,c),await r(s)}}),ql=G(e=>({root:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100],border:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(2)},inner:{marginLeft:e.spacing(2),paddingBottom:e.spacing(2),borderLeft:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"row",gap:0},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"20px"}})),_a=({control:e,name:a,depth:n,getValues:r,setValue:l,trigger:o,disabled:i})=>{const s=ql(),{handleAddCondition:c,handleAddExpression:u,handleDeleteCondition:m}=Wl(a,r,l,o),d=`${a}`,g=r(d),p=(g==null?void 0:g.conditions)||[],v=g==null?void 0:g.expressions;return t.createElement(k,{className:n>0?s.inner:s.root},n>0&&t.createElement(k,{className:s.connector}),t.createElement(h,{container:!0,spacing:0,direction:"column"},t.createElement(h,{item:!0},t.createElement(Hl,{control:e,disabled:i,name:`${a}.expressionType`,getValues:r})),t.createElement(h,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(Vl,{depth:n,handleDelete:f=>m(f,a),disabled:i,conditions:p,control:e,name:a,setValue:l,getValues:r}),v==null?void 0:v.map((f,E)=>t.createElement(zl,{key:E,expression:f,control:e,name:`${a}.expressions[${E}]`,depth:n,getValues:r,setValue:l,trigger:o,disabled:i}))),!i&&t.createElement(h,{item:!0},t.createElement(El,{onAddCondition:c,onAddExpression:u}))))},_l=({control:e,supportContactError:a,disabled:n,isLoading:r,options:l})=>{var o;return t.createElement($e,{title:n?"Owner Details":"Owner Details (optional)"},t.createElement(Ia,{name:"teamOwner",control:e,selectLabel:"Owner",options:(o=l==null?void 0:l.map(i=>({value:i.ref,label:i.name})))!=null?o:[],disabled:n||r}),t.createElement(Fe,{name:"supportChannel",control:e,error:a,label:"Support channel",placeholder:"Enter a channel or email to get check support",disabled:n||r,rules:{},messages:{}}))},Ul=e=>{const a=L(or),n=L(ya);return F([R.GetEntityFacets,e],async()=>{var r;return((r=(await n.getEntityFacets({facets:[e]})).facets[e])==null?void 0:r.map(l=>l.value).sort())||[]},{onError:()=>{a.post({message:`Failed to load facet: ${e}`,severity:"error"})}})},jl=x({container:{padding:0},formControl:{flexGrow:1}}),Kl=({facet:e,label:a,values:n,onChange:r,disabled:l})=>{var o;const i=jl(),{data:s,isLoading:c,error:u}=Ul(e),m=B(()=>s==null?void 0:s.map(f=>f.toLocaleLowerCase("en-US")),[s]),d=(o=n==null?void 0:n.map(f=>f.toLocaleLowerCase("en-US")))!=null?o:[],g=j((f,E)=>{r(m&&m.every(y=>E.includes(y))?void 0:E)},[m,r]),p=j(()=>{r(n!=null&&n.length?n:void 0)},[n,r]);if(!s||!m||u)return t.createElement(b,{color:"error"},"Failed to load facet: ",e);const v=l||c||!(n!=null&&n.length)&&(!(s!=null&&s.length)||!(m!=null&&m.length));return t.createElement(k,{pb:1,pt:1,className:i.container},t.createElement(b,{variant:"subtitle2"},a),t.createElement(bt,{className:i.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":a,options:m,value:d,getOptionLabel:f=>{var E;return(E=s[m.indexOf(f)])!=null?E:f},onChange:g,onBlur:p,disabled:v,renderOption:(f,{selected:E})=>{var y;return t.createElement(We,{control:t.createElement(Re,{icon:t.createElement(va,{fontSize:"small"}),checkedIcon:t.createElement(Ea,{fontSize:"small"}),checked:E}),label:(y=s[m.indexOf(f)])!=null?y:f})},size:"small",popupIcon:t.createElement(Nr,{"data-testid":"selected-facets-expand"}),renderInput:f=>t.createElement(M,{...f,variant:"outlined"})}))},Yl=x(()=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap"}})),Mt=({value:e,onChange:a,disabled:n})=>{const r=Yl(),l=o=>i=>{a({...e,[o]:i!=null?i:[]})};return t.createElement(h,{container:!0,className:r.filterContainer,spacing:2},kl.map(o=>t.createElement(h,{item:!0,xs:12,sm:6,md:4,key:o.key},t.createElement(Kl,{facet:o.facet,label:o.label,values:e==null?void 0:e[o.key],onChange:l(o.key),disabled:n}))))},Ql=x(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Xl=({control:e,disabled:a})=>{const n=Ql();return t.createElement($e,{title:a?"Filters":"Filters (optional)"},t.createElement(h,{className:n.container,item:!0,xs:12},!a&&t.createElement(b,{variant:"body2"},"Apply filters so it's only applicable to relevant entities."),t.createElement(h,{item:!0,xs:12},t.createElement(Le,null,t.createElement(H,{name:"filters",control:e,render:({field:r})=>{var l;return t.createElement(Mt,{value:(l=r.value)!=null?l:Ye(),onChange:r.onChange})}})))))},Ua=({type:e,cron:a,value:n})=>{if(e==="cron"){if(!wl(a))return Ma(a)}else if(e==="HumanDuration")return za(n);return!0},Zl=x(e=>({container:{padding:e.spacing(0,1.5)}})),Jl=({control:e,disabled:a})=>{const n=Zl(),r=ft({control:e,name:"schedule"});return t.createElement(h,{className:n.container,item:!0,xs:12},t.createElement(h,{item:!0},t.createElement(H,{name:"schedule.enabled",control:e,render:({field:l})=>t.createElement(We,{disabled:a,control:t.createElement(Re,{checked:l.value,onChange:l.onChange}),label:"Schedule check"})})),t.createElement(h,{item:!0},t.createElement(H,{name:"schedule.frequency",control:e,rules:{validate:Ua},render:({field:l})=>t.createElement(Ga,{disabled:a||!r.enabled,value:l.value,onChange:l.onChange})})))},eo=x(e=>({container:{padding:e.spacing(0,1.5)},scheduleContainer:{padding:e.spacing(2)}})),to=({control:e,disabled:a})=>{const n=eo();return t.createElement($e,{title:a?"Schedule":"Schedule (optional)"},t.createElement(h,{className:n.container,item:!0,xs:12},t.createElement(h,{item:!0},t.createElement(b,{variant:"body2"},"By default checks are execute when any fact they depend on is updated. However, you may also schedule a check to run on a schedule.")),t.createElement(h,{item:!0,xs:12},t.createElement(Le,{className:n.scheduleContainer},t.createElement(Jl,{disabled:a,control:e})))))},ao=e=>{const{selectedCheck:a}=Y();let n=Fl;a&&(n=Ol(a));const{control:r,handleSubmit:l,getValues:o,setValue:i,trigger:s,formState:{errors:c}}=pa({defaultValues:n}),{showModal:u}=je();return{control:r,handleSubmit:l,getValues:o,setValue:i,trigger:s,errors:c,onSubmit:async m=>{if(!await u({title:"Save Check",message:`Are you sure you want to save check: ${m.checkName}?`,error:!1}))return;const d=Al(m,a);e(d)}}},no=()=>t.createElement("div",{style:{display:"flex",gap:"10px",flexDirection:"column"}},t.createElement(b,{variant:"h6"},"Creating and managing checks"),t.createElement(b,{variant:"body1"},"Checks are entities created from four components: facts, paths, operators and values. These components are then organized via a boolean calculator in the UI."),t.createElement(b,{variant:"body1"},"To create a check, select the components that you want to use, organize them into rules and give your check a meaningful name and a description."),t.createElement(b,{variant:"body1"},"Once created, you will be able to manage and edit your track on its detail page.")),ja=G(e=>({root:{overflow:"hidden",display:"flex",marginBottom:"53px"},card:{padding:e.spacing(3),display:"flex",gap:e.spacing(2.5)},sectionLabel:{fontWeight:700,margin:e.spacing(2,0),color:e.palette.primary.main}})),Bt=({title:e,open:a,onSave:n})=>{const r=ja(),{hideModal:l,isLoading:o,isReadOnly:i}=Y(),{control:s,handleSubmit:c,getValues:u,setValue:m,trigger:d,errors:g,onSubmit:p}=ao(n),{options:v}=er();return t.createElement(Lt,{handleClose:l,title:e,open:a},t.createElement("form",{onSubmit:c(p)},t.createElement(h,{container:!0,spacing:2,className:r.root},t.createElement(h,{item:!0,xs:9},t.createElement(pt,{className:r.card},t.createElement(b,{className:r.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(ul,{control:s,error:g.checkName,isLoading:o,disabled:i}),t.createElement(gl,{control:s,error:g.description,isLoading:o,disabled:i}),t.createElement(_l,{control:s,disabled:i,isLoading:o,options:v}),t.createElement(b,{className:r.sectionLabel},"Rules"),t.createElement(_a,{control:s,getValues:u,setValue:m,trigger:d,disabled:i,name:"expressions",depth:0}),t.createElement(Xl,{control:s,disabled:i}),t.createElement(hl,{control:s,passError:g.passMessage,failError:g.failMessage,isLoading:o,disabled:i}),t.createElement(to,{control:s,disabled:i}))),t.createElement(h,{item:!0,xs:3},t.createElement(no,null))),t.createElement(h,{container:!0,spacing:4,className:r.root},t.createElement(St,{onCancel:l,saveButtonText:"Save Check",isLoading:o,onSave:i?void 0:c(p)}))))},ro="Error Creating Check";function lo(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return se([ce.UpdateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),n({severity:"error",title:ro,message:o})}})}const oo=()=>{const{selectedCheck:e,hideModal:a}=Y(),{setIsLoading:n}=Y(),{mutateAsync:r,isLoading:l}=lo();return A(()=>{n(l)},[n,l]),t.createElement(Bt,{title:"Edit a Check",open:!!e,onSave:async o=>{await r(o)&&a()}})},io="Error Creating Check";function so(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return se([ce.CreateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),n({severity:"error",title:io,message:o})}})}const co=()=>{const{hideModal:e,showAddModal:a,setIsLoading:n}=Y(),{mutateAsync:r,isLoading:l}=so();return A(()=>{n(l)},[n,l]),t.createElement(Bt,{title:"Create a Check",open:a,onSave:async o=>{await r(o)&&e()}})},mo=({handleDelete:e})=>{const[a,n]=C(null),r=!!a,l=i=>{i.stopPropagation(),n(i.currentTarget)},o=i=>{i.stopPropagation(),n(null)};return t.createElement(t.Fragment,null,t.createElement(he,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":r?"summary-card-action-menu":void 0,"aria-expanded":r?"true":void 0,"aria-haspopup":"true",onClick:l},t.createElement(Sr,null)),t.createElement(ra,{id:"summary-card-action-menu",anchorEl:a,open:r,onClose:o,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e&&t.createElement(ge,{"data-testid":"summary-card-action-delete",onClick:i=>{e(i),o(i)}},t.createElement(fe,null,t.createElement(ga,{fontSize:"small"})),t.createElement(Ee,null,"Delete"))))},uo=Wn(e=>Jn({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(pt),po=x(e=>({root:{position:"relative",height:"100%"},summaryName:{fontSize:e.typography.pxToRem(24),color:e.palette.primary.main,maxHeight:"250px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical","-webkit-line-clamp":4,"-webkit-box-orient":"vertical",wordBreak:"break-word"},summaryDescription:{padding:0,maxHeight:"175px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"},card:{paddingTop:e.spacing(1),paddingBottom:0,paddingLeft:e.spacing(1),paddingRight:e.spacing(1)}})),Vt=({title:e,description:a,viewLabel:n="View",editLabel:r="Edit",children:l,handleDelete:o,handleEdit:i,handleView:s})=>{const c=po();return t.createElement(uo,{className:c.card},t.createElement(qn,{title:e,titleTypographyProps:{className:c.summaryName},subheader:t.createElement(aa,{className:c.summaryDescription,content:a!=null?a:""}),action:o&&t.createElement(mo,{handleDelete:o})}),t.createElement(_n,null,l),t.createElement(He,null),t.createElement(Un,null,t.createElement(_,{size:"medium",color:"primary",role:"link",onClick:i||s,disabled:!s&&!i},i?r:n)))},ho="Error Deleting Check";function go(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return se([ce.DeleteCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetChecks]})},onError:(l,o)=>{let i=`Failed to delete check ${o}`;l instanceof Error&&(i=l.message),n({severity:"error",title:ho,message:i})}})}const fo=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Eo=({check:e})=>{var a;const n=fo();return t.createElement(oa,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(De,{disableGutters:!0,className:n.listItem},t.createElement(oe,{title:"Owner"},t.createElement(fe,null,t.createElement(Ca,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:n.listItemText,primary:t.createElement(kt,{entityRef:(a=e.ownerEntityRef)!=null?a:"No Owner"})})))},vo=({check:e})=>{const{id:a,name:n,description:r,isEditable:l,ownerEntityRef:o}=e,{loading:i,allowed:s}=te({permission:hr,resourceRef:a}),{loading:c,allowed:u}=te({permission:gr,resourceRef:a}),{showModal:m}=je(),{mutate:d}=go(),{showReadOnlyModal:g,setSelectedCheck:p}=Y(),v=j(async()=>{await m({title:"Delete Check",message:`Are you sure you want to delete the check '${n!=null?n:a}'?`})&&d(a)},[m,n,d,a]);return t.createElement(Vt,{title:n!=null?n:a,description:r,children:o&&t.createElement(Eo,{check:e}),handleView:()=>g(e),handleEdit:l&&!i&&s?()=>p(e):void 0,handleDelete:l&&!c&&u?v:void 0})},yo=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385})))),bo=x(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),Ka=({searchTerm:e,setSearchTerm:a,showClear:n=!0,placeholder:r="Search...",...l})=>{const o=bo(),i=c=>{a(c.target.value)},s=()=>{a("")};return t.createElement(M,{...l,fullWidth:!0,placeholder:r,value:e,onChange:i,InputProps:{startAdornment:t.createElement(ia,{position:"start"},t.createElement(Lr,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:n&&e?t.createElement(ia,{position:"end"},t.createElement(he,{edge:"end",onClick:s,className:o.clearButton},t.createElement(ua,null))):null}})},Co=x(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),Ya=({searchPlaceholder:e,isLoading:a,searchTerm:n,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:i,handleOwnerFilterChange:s,owners:c})=>{const u=Co();return t.createElement(h,{item:!0,xs:9,className:u.filters},t.createElement(Ka,{searchTerm:n,disabled:a,setSearchTerm:r,placeholder:e||"Search",variant:"outlined",size:"small",className:u.searchbar}),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Sort by: "),t.createElement(sa,{className:u.selectHolder,value:l,onChange:o},t.createElement("option",{value:"default"},"Default"),t.createElement("option",{value:"ascending"},"Name A-Z"),t.createElement("option",{value:"descending"},"Name Z-A"))),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Filter by owner: "),t.createElement(sa,{className:u.selectHolder,value:i,onChange:s},t.createElement("option",{key:"all",value:"all"},"All"),c==null?void 0:c.map((m,d)=>t.createElement("option",{key:m+d,value:m},m)))))},ko=(e,a)=>e==null?void 0:e.sort((n,r)=>{var l,o,i,s;const c=(o=(l=n==null?void 0:n.name)==null?void 0:l.toLocaleLowerCase())!=null?o:n==null?void 0:n.id.toLocaleLowerCase(),u=(s=(i=r==null?void 0:r.name)==null?void 0:i.toLocaleLowerCase())!=null?s:r==null?void 0:r.id.toLocaleLowerCase();return!c||!u?0:c<u?a==="ascending"?-1:1:c>u?a==="ascending"?1:-1:0}),Qa=e=>{const a=e==null?void 0:e.map(n=>n==null?void 0:n.ownerEntityRef).filter(n=>n!=="");return[...new Set(a)]},be=({searchTermProp:e,filterAlphaProp:a,filterOwnerProp:n,checks:r,tracks:l})=>{var o,i;const s=r||l||[],c=(o=s==null?void 0:s.filter)==null?void 0:o.call(s,m=>{var d;return((d=m==null?void 0:m.name)!=null?d:m==null?void 0:m.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),u=n&&n!=="all"?(i=c==null?void 0:c.filter)==null?void 0:i.call(c,m=>{var d;return((d=m==null?void 0:m.ownerEntityRef)==null?void 0:d.toLowerCase())===n.toLowerCase()}):c;return a==="default"?u:ko(u!=null?u:[],a)},xo=x(e=>({pagination:{width:"-webkit-fill-available",display:"flex",justifyContent:"center",position:"fixed",bottom:"0",backgroundColor:e.palette.type==="dark"?"#333333":"#F8F8F8",marginRight:"40px"}})),Xa=({response:e,listingsPerPage:a,cursor:n,setCursor:r,prevCursors:l,setPrevCursors:o,labelPerPageDropdown:i,urlRoute:s})=>{var c;const u=xo(),m=e!=null&&e.edges?e==null?void 0:e.edges[(e==null?void 0:e.edges.length)-1]:{cursor:""},[d,g]=C(0),p=()=>{o(y=>[...y,n]),r(m==null?void 0:m.cursor)},v=()=>{r(l[l.length-1]),o(y=>y.slice(0,-1))},f=(y,w)=>{g(N=>(w>N?p():v(),w))},E=y=>{window.open(`/soundcheck/${s!=null?s:"tracks?tracksPerPage="}${y.target.value}`,"_self")};return t.createElement(ca,{className:u.pagination,component:"div",count:(c=e==null?void 0:e.totalCount)!=null?c:-1,rowsPerPage:a!=null?a:10,onPageChange:f,page:d,onRowsPerPageChange:E,labelRowsPerPage:i!=null?i:"Listings per page:",rowsPerPageOptions:[]})},wo=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)}})),No=({checksPerPage:e,currentCursor:a})=>{const n=wo(),[r,l]=C(a),[o,i]=C([]),{data:s,isLoading:c}=Pt(void 0,e,r),{loading:u,allowed:m}=te({permission:fr}),[d,g]=C(s);A(()=>{s&&g(()=>{var T;return{endCursor:s.endCursor,totalCount:s.totalCount,hasNextPage:(T=s==null?void 0:s.hasNextPage)!=null?T:!1,edges:s.edges}})},[s]);const p=d==null?void 0:d.edges.map(T=>T.checker),{setShowAddModal:v}=Y(),[f,E]=C(),[y,w]=C(""),[N,D]=C("default"),[$,X]=C("all"),[we,Z]=C([]),pe=T=>{const V=be({searchTermProp:y,filterAlphaProp:T.target.value,filterOwnerProp:$,checks:p!=null?p:[]});D(T.target.value),E(V)},Ne=T=>{const V=be({searchTermProp:y,filterAlphaProp:N,filterOwnerProp:T.target.value,checks:p!=null?p:[]});X(T.target.value),E(V)};return A(()=>{const T=d==null?void 0:d.edges.map(re=>re.checker),V=Qa(T!=null?T:[]);E(T),Z(V!=null?V:[])},[c,d]),A(()=>{const T=d==null?void 0:d.edges.map(re=>re.checker),V=be({searchTermProp:y,filterAlphaProp:N,filterOwnerProp:$,checks:T!=null?T:[]});E(V)},[y,N,$,d]),t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,className:n.header},t.createElement(Ya,{searchPlaceholder:"Search available checks",isLoading:c,searchTerm:y,setSearchTerm:w,filterAlpha:N,handleAlphabeticalFilterChange:pe,filterOwner:$,handleOwnerFilterChange:Ne,owners:we}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:n.headerButtons},!u&&t.createElement(_,{disabled:!m,variant:"contained",color:"primary",onClick:()=>v(!0)},"Create Check")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},c?t.createElement(yo,null):f==null?void 0:f.map(T=>t.createElement(h,{key:T.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(vo,{check:T})))),((d==null?void 0:d.hasNextPage)||(o==null?void 0:o.length)>0)&&t.createElement(Xa,{response:d,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:o,setPrevCursors:i,labelPerPageDropdown:"Checks Per Page:",urlRoute:"checks?checksPerPage="}))},To=()=>{const{selectedCheck:e}=Y();return t.createElement(Bt,{title:"Check Details",open:!!e,onSave:()=>{}})},Po=x(e=>({checksPageContainer:{padding:e.spacing(3)}})),So=()=>{const e=Po(),[a]=Jt(),n=a.get("checksPerPage"),r=n?parseInt(n,10):9,{selectedCheck:l,showAddModal:o,isReadOnly:i}=Y();return t.createElement("div",{className:e.checksPageContainer},t.createElement(No,{checksPerPage:r}),o&&t.createElement(co,null),l&&!i&&t.createElement(oo,null),l&&i&&t.createElement(To,null))},Lo=()=>t.createElement(sl,null,t.createElement(So,null)),Ro=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Do=({program:e})=>{var a,n,r;const l=Ro(),o=(n=(a=e.levels)==null?void 0:a.length)!=null?n:0,i=(r=e.levels)==null?void 0:r.reduce((s,c)=>s+c.checks.length,0);return t.createElement(oa,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Levels"},t.createElement(fe,null,t.createElement($r,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Checks"},t.createElement(fe,null,t.createElement(Fr,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${i} ${i===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Documentation"},t.createElement(fe,null,t.createElement(Ar,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(Rn,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(De,{disableGutters:!0,className:l.listItem},t.createElement(oe,{title:"Owner"},t.createElement(fe,null,t.createElement(Ca,{color:"action",fontSize:"small"}))),t.createElement(Ee,{className:l.listItemText,primary:t.createElement(kt,{entityRef:e.ownerEntityRef})})))},Io="Error Deleting Track";function Oo(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return se([ce.DeleteProgram],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:(l,o)=>{let i=`Failed to delete track ${o}`;l instanceof Error&&(i=l.message),n({severity:"error",title:Io,message:i})}})}const Ao=({summary:e})=>{const{loading:a,allowed:n}=te({permission:Er,resourceRef:e.id}),{loading:r,allowed:l}=te({permission:vr,resourceRef:e.id}),{showModal:o}=je(),{mutate:i}=Oo(),{setSelectedProgram:s}=ve(),c=j(async()=>{await o({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&i(e.id)},[o,e.id,e.name,i]);return t.createElement(Vt,{title:e.name,description:e.description,children:t.createElement(Do,{program:e}),handleView:()=>{s(e)},handleEdit:e.isEditable&&!a&&n?()=>{s(e)}:void 0,handleDelete:e.isEditable&&!r&&l?c:void 0})},Fo=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385})))),$o=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)}})),Mo=({programsPerPage:e,currentCursor:a})=>{var n;const r=$o(),{loading:l,allowed:o}=te({permission:yr}),{setShowAddModal:i}=ve(),[s,c]=C(a),[u,m]=C([]),{data:d,isLoading:g}=La(void 0,e,s),[p,v]=C(d);A(()=>{d&&v(()=>{var S;return{endCursor:d.endCursor,totalCount:d.totalCount,hasNextPage:(S=d==null?void 0:d.hasNextPage)!=null?S:!1,edges:d.edges}})},[d]);const f=(n=p==null?void 0:p.edges)==null?void 0:n.map(S=>S==null?void 0:S.program),{userEntityRef:E}=_e(),{showAlert:y}=ee(),[w,N]=C(),[D,$]=C(""),[X,we]=C("default"),[Z,pe]=C("all"),[Ne,T]=C([]),V=S=>{const W=be({searchTermProp:D,filterAlphaProp:S.target.value,filterOwnerProp:Z,tracks:f!=null?f:[]});we(S.target.value),N(W)},re=S=>{const W=be({searchTermProp:D,filterAlphaProp:X,filterOwnerProp:S.target.value,tracks:f!=null?f:[]});pe(S.target.value),N(W)};A(()=>{const S=p==null?void 0:p.edges.map(Te=>Te.program),W=Qa(S!=null?S:[]);N(S),T(W!=null?W:[])},[g,p]),A(()=>{const S=p==null?void 0:p.edges.map(Te=>Te.program),W=be({searchTermProp:D,filterAlphaProp:X,filterOwnerProp:Z,tracks:S!=null?S:[]});N(W)},[D,X,Z,p]);const Ge=()=>{E?i(!0):y({severity:"error",title:"User Error",message:"Logged in user has not been found in Catalog. Unable to create a Track at this time"})};return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,className:r.header},t.createElement(Ya,{searchPlaceholder:"Search available tracks",isLoading:g,searchTerm:D,setSearchTerm:$,filterAlpha:X,handleAlphabeticalFilterChange:V,filterOwner:Z,handleOwnerFilterChange:re,owners:Ne}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!l&&t.createElement(_,{disabled:!o,variant:"contained",color:"primary",onClick:()=>Ge()},"Create Track")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"tracks"},g?t.createElement(Fo,null):w==null?void 0:w.map(S=>t.createElement(h,{key:S.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Ao,{summary:S})))),((p==null?void 0:p.hasNextPage)||(u==null?void 0:u.length)>0)&&t.createElement(Xa,{response:p,listingsPerPage:e,cursor:s,setCursor:c,prevCursors:u,setPrevCursors:m,labelPerPageDropdown:"Track Per Page:",urlRoute:"tracks?tracksPerPage="}))},Bo=x(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700}})),Vo=({programName:e,programNameError:a,handleProgramNameChange:n,disabled:r})=>{const l=Bo();return t.createElement(h,{item:!0,xs:12},t.createElement(M,{fullWidth:!0,placeholder:"Untitled track",value:e,onChange:n,disabled:r,className:l.titleInput,variant:"outlined",size:"small",margin:"normal",error:a,helperText:a?"Track name must be at least 1 character and less than 100 characters":""}))},Za=x(e=>{const a=e.palette.type==="dark",n=a?e.palette.common.white:e.palette.common.black,r=a?e.palette.grey[700]:e.palette.common.white,l=a?e.palette.grey[500]:e.palette.grey[300],o=a?e.palette.common.white:e.palette.common.black;return{chip:{width:"100%",height:"36px",color:n,justifyContent:"space-between",background:r,border:`1px solid ${l}`,borderRadius:4,boxShadow:"0px 2px 5px rgba(0, 0, 0, 0.1)",cursor:"move","& *":{fontWeight:700},"&:focus":{background:r,borderColor:o,"& $icon":{color:e.palette.primary.main}}},icon:{},deleteButton:{marginRight:"auto"}}}),zo=({chip:e,disabled:a})=>{var n;const[r,l]=Rr(()=>({type:"chip",item:{id:e.id,label:e.label},collect:i=>({isDragging:i.isDragging()})})),o=Za();return t.createElement(ht,{ref:l,label:e.label,className:o.chip,icon:t.createElement(ka,{"data-testid":"drag-indicator-icon"}),disabled:a,onDelete:()=>{},deleteIcon:t.createElement(oe,{title:(n=e.description)!=null?n:""},t.createElement(Mr,{className:o.icon,"data-testid":"visibility-icon"}))})},Ja=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{color:e.palette.primary.main,fontWeight:"bold"},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),Go=()=>{const e=Ja();return t.createElement(h,{container:!0,className:e.loadingContainer},t.createElement(jn,null))},Ho=({chips:e,disabled:a})=>t.createElement(t.Fragment,null,e.map(n=>t.createElement(zo,{disabled:a,key:n.id,chip:n}))),Wo=()=>t.createElement(b,{variant:"body1",color:"textSecondary"},"There are no matches."),qo=({isLoading:e,chips:a=[],disabled:n})=>{const r=Ja(),[l,o]=C(""),i=a.filter(u=>u.label.toLowerCase().includes(l.toLowerCase())),s=a.length>0||l;let c=null;return e?c=t.createElement(Go,null):i.length>0?c=t.createElement(Ho,{disabled:n!=null?n:!1,chips:i}):s&&(c=t.createElement(Wo,null)),t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:r.columnHeader},t.createElement(b,{className:r.subtitle},"Checks")),t.createElement(h,{item:!0,xs:12},t.createElement(Ka,{searchTerm:l,disabled:e||n,setSearchTerm:o,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(h,{item:!0,className:r.chipContainer,xs:12},c))},_o=x(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),en=({label:e,...a})=>{const n=_o();return t.createElement(_,{className:n.button,...a},e)},Uo=x(e=>({input:{border:`1px solid ${e.palette.grey[600]}`,borderRadius:4,padding:e.spacing(1),minHeight:80},hoverBackground:{background:e.palette.type==="dark"?e.palette.grey[600]:e.palette.grey[200]},normalBackground:{background:e.palette.type==="dark"?e.palette.grey[700]:e.palette.common.white},error:{border:"1px solid red"},chipContainer:{display:"flex",flexDirection:"column",fontWeight:"bold",fontSize:e.typography.pxToRem(16),color:e.palette.grey[600]}})),jo=({chips:e,onDelete:a,onDrop:n,error:r=!1,placeholder:l="",disabled:o})=>{const i=Uo(),s=Za(),[{isOver:c},u]=Dr(()=>({accept:"chip",drop:m=>{n(m)},collect:m=>({isOver:m.isOver()})}));return t.createElement("div",{ref:u,className:`${i.input} ${r?i.error:""} ${c?i.hoverBackground:i.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:i.chipContainer},e!=null&&e.length?e.map(m=>t.createElement(ht,{key:m.id,label:m.label,className:s.chip,icon:t.createElement(ka,null),style:{cursor:"pointer"},onDelete:()=>a(m),disabled:o})):l))},Ko=x(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),Yo=({levelName:e,handleLevelNameChange:a,disabled:n})=>{const r=Ko();return t.createElement(M,{fullWidth:!0,placeholder:"Untitled level",value:e,size:"small",variant:"outlined",onChange:a,label:"Level Name",disabled:n,InputProps:{classes:{input:r.inputBase}}})},Qo=x(e=>({inputBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),Xo=({levelDescription:e,levelNameLabel:a,handleLevelDescriptionChange:n,disabled:r})=>{const l=Qo();return t.createElement(M,{fullWidth:!0,placeholder:"Enter description here",multiline:!0,value:e,size:"small",variant:"outlined",label:`${a} Description`,onChange:n,disabled:r,InputProps:{classes:{input:l.inputBase}}})},Zo=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontWeight:"bold",color:e.palette.primary.main},levelHeader:{display:"flex",alignItems:"center"},removeButton:{minWidth:150}})),Jo=({inputChipsList:e,handleDelete:a,handleDrop:n,addInput:r,removeInput:l,levelsErrors:o,levelNames:i,levelDescriptions:s,handleLevelNameChange:c,handleLevelDescriptionChange:u,disabled:m})=>{const d=Zo();return t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:d.columnHeader},t.createElement(b,{className:d.subtitle},"Levels"),!m&&t.createElement(en,{label:"Add Level",startIcon:t.createElement(Br,null),onClick:r,disabled:m})),t.createElement(h,{container:!0,item:!0,spacing:5},e.map((g,p)=>t.createElement(h,{container:!0,item:!0,xs:12,key:p,spacing:2},t.createElement(h,{item:!0,xs:12,className:d.levelHeader},t.createElement(h,{container:!0,spacing:1},t.createElement(h,{item:!0,xs:!0},t.createElement(Yo,{levelName:i[p],handleLevelNameChange:v=>c(v.target.value,p),disabled:m!=null?m:!1})),e.length>1&&!m&&t.createElement(h,{item:!0,className:d.removeButton},t.createElement(en,{label:"Remove Level",startIcon:t.createElement(Vr,null),onClick:()=>l(p),disabled:m})))),t.createElement(h,{item:!0,xs:12},t.createElement(jo,{chips:g,onDelete:v=>a(v,p),onDrop:v=>n(v,p),error:o[p],placeholder:"Drag and drop checks here to include them in this level",disabled:m})),t.createElement(h,{item:!0,xs:12},t.createElement(Xo,{levelDescription:s[p],levelNameLabel:i[p],handleLevelDescriptionChange:v=>u(v.target.value,p),disabled:m!=null?m:!1}))))))},ei=x(e=>({titleInput:{marginBottom:e.spacing(1)},regularFontSize:{fontSize:e.typography.fontSize},title:{fontWeight:700,fontSize:e.typography.fontSize}})),ti=({programDescription:e,programDescriptionError:a,handleProgramDescriptionChange:n,disabled:r})=>{const l=ei();return t.createElement(h,{item:!0,xs:12},t.createElement(M,{fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:n,disabled:r,className:l.titleInput,minRows:4,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:l.regularFontSize}},error:a,helperText:a?"Track description must be at least 1 character and less than 250 characters":""}))};var ai=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))(ai||{});const ni={programName:"",programNameError:!1},ri=(e,a)=>{switch(a.type){case"SET_NAME":return{...e,programName:a.value};case"VALIDATE_NAME":return{...e,programNameError:a.value};default:return e}},li=(e="")=>{const[a,n]=Zt(ri,{...ni,programName:e}),r=()=>{const i=a.programName.trim().length,s=i>0&&i<=100;return n({type:"VALIDATE_NAME",value:!s}),s},l=i=>{n({type:"SET_NAME",value:i})},o=i=>{l(i.target.value),a.programNameError&&r()};return{programName:a.programName,programNameError:a.programNameError,handleProgramNameChange:o,setProgramName:l,isProgramNameValid:r}};var oi=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(oi||{});const ii={programDescription:"",programDescriptionError:!1},si=(e,a)=>{switch(a.type){case"SET_DESCRIPTION":return{...e,programDescription:a.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:a.value};default:return e}},ci=(e="")=>{const[a,n]=Zt(si,{...ii,programDescription:e}),r=()=>{const i=a.programDescription.trim().length,s=i>0&&i<=250;return n({type:"VALIDATE_DESCRIPTION",value:!s}),s},l=i=>{n({type:"SET_DESCRIPTION",value:i})},o=i=>{l(i.target.value),a.programDescriptionError&&r()};return{programDescription:a.programDescription,programDescriptionError:a.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:l,isProgramDescriptionValid:r}},di=({programName:e,programDescription:a,areInputsValid:n,isProgramNameValid:r,isProgramDescriptionValid:l,inputChipsList:o,checkers:i,onSave:s,programId:c,levelNames:u,levelDescriptions:m,filters:d})=>{const{showModal:g}=je(),{userEntityRef:p}=_e();return async()=>{if(!(r()&&l()&&n())||!await g({title:"Save Track",message:`Are you sure you want to save track: ${e}?`})||!p)return;const v=c!=null?c:fa(),f=Tl(o,u,m,i),E={description:a,id:v,levels:f,name:e,ownerEntityRef:p,filter:Fa(d)};s(E)}},mi=e=>{var a;const n=Tn([]),r=B(()=>e?Sl(e):null,[e]),{chips:l,setChips:o,inputChipsList:i,handleDrop:s,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:g,setInputChipsList:p}=Xr(),{data:v,isLoading:f}=Pt(),E=v==null?void 0:v.edges.map(w=>w.checker),y=(a=E==null?void 0:E.filter(w=>!!w).map(w=>{var N,D,$;return{id:(N=w.id)!=null?N:"",label:(D=w.name)!=null?D:w.id,description:($=w.description)!=null?$:""}}))!=null?a:[];return n.current=y,A(()=>{const{inputChips:w,used:N}=Dl(r,n.current);p(w),o(N)},[y==null?void 0:y.length,r,p,o]),{checkers:E,checkersLoading:f,chips:l,inputChipsList:i,handleDrop:s,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:g}},ui=e=>{const[a,n]=C(e);return{levelNames:a,handleLevelNameChange:(r,l)=>{n(a.map((o,i)=>i===l?r:o))},addLevelName:r=>{n([...a,r])},removeLevelName:r=>{n(a.filter((l,o)=>o!==r))}}},pi=e=>{const[a,n]=C(e);return{levelDescriptions:a,handleLevelDescriptionChange:(r,l)=>{n(a.map((o,i)=>i===l?r:o))},addLevelDescription:r=>{n([...a,r])},removeLevelDescription:r=>{n(a.filter((l,o)=>o!==r))}}},hi=x(e=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)},description:{fontSize:e.typography.fontSize}})),gi=({filters:e,setFilters:a,disabled:n})=>{const r=hi();return t.createElement($e,{title:n?"Filters":"Filters (optional)"},t.createElement(h,{container:!0,item:!0,xs:12,spacing:2},!n&&t.createElement(h,{item:!0},t.createElement(b,{className:r.description},"Apply filters so it's only applicable to relevant entities.")),t.createElement(h,{item:!0,xs:12},t.createElement(Le,null,t.createElement(Mt,{value:e,onChange:a})))))},fi=x(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),tn=({onSave:e,title:a,open:n,handleClose:r})=>{var l,o,i,s;const{selectedProgram:c,isLoading:u,setSelectedProgram:m}=ve(),{checkers:d,checkersLoading:g,chips:p,inputChipsList:v,handleDrop:f,handleDelete:E,addInput:y,removeInput:w,inputErrors:N,areInputsValid:D}=mi(c),{programName:$,programNameError:X,handleProgramNameChange:we,isProgramNameValid:Z}=li(c==null?void 0:c.name),{programDescription:pe,programDescriptionError:Ne,handleProgramDescriptionChange:T,isProgramDescriptionValid:V}=ci(c==null?void 0:c.description),re=(o=c?(l=c.levels)==null?void 0:l.map(q=>{var J;return(J=q.name)!=null?J:`Level ${q.ordinal}`}):v.map((q,J)=>`Level ${J+1}`))!=null?o:[],{levelNames:Ge,handleLevelNameChange:S,addLevelName:W,removeLevelName:Te}=ui(re),vn=(s=c?(i=c.levels)==null?void 0:i.map(q=>{var J;return(J=q.description)!=null?J:""}):v.map((q,J)=>""))!=null?s:[],{levelDescriptions:Yt,handleLevelDescriptionChange:yn,addLevelDescription:bn,removeLevelDescription:Cn}=pi(vn),kn=()=>{y(),W(`Level ${v.length+1}`),bn("")},xn=q=>{w(q),Te(q),Cn(q)},[Qt,wn]=C($a(c==null?void 0:c.filter)),Nn=di({programName:$,programDescription:pe,areInputsValid:D,isProgramNameValid:Z,isProgramDescriptionValid:V,inputChipsList:v,checkers:d,onSave:e,programId:c==null?void 0:c.id,levelNames:Ge,levelDescriptions:Yt,filters:Qt}),ct=fi(),Xt=ja(),le=c?!(c!=null&&c.isEditable):!1;return t.createElement(Lt,{handleClose:r,title:a,open:n},t.createElement(h,{container:!0,spacing:4,className:ct.root},t.createElement(h,{item:!0,xs:12},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:Xt.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(Vo,{disabled:u||le,programName:$,programNameError:X,handleProgramNameChange:we})),t.createElement(h,{item:!0,xs:12},t.createElement(ti,{disabled:u||le,programDescription:pe,programDescriptionError:Ne,handleProgramDescriptionChange:T}))),t.createElement(h,{item:!0,xs:12},t.createElement(gi,{filters:Qt,setFilters:wn})),t.createElement(h,{item:!0,xs:12},t.createElement(h,{container:!0,spacing:4},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:Xt.sectionLabel,style:{margin:0}},"Track Levels"),!le&&t.createElement(b,{className:ct.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!le&&t.createElement(h,{item:!0,xs:5},t.createElement(qo,{chips:p,isLoading:g||u,disabled:le})),t.createElement(h,{item:!0,xs:7},t.createElement(Jo,{inputChipsList:v,handleDelete:E,handleDrop:f,addInput:kn,removeInput:xn,levelsErrors:N,levelNames:Ge,handleLevelNameChange:S,levelDescriptions:Yt,handleLevelDescriptionChange:yn,disabled:le}))))),t.createElement(h,{container:!0,spacing:4,className:ct.root},t.createElement(St,{onCancel:()=>{m(null),r()},saveButtonText:"Save Track",isLoading:u||g,onSave:Nn,disableSave:le})))},Ei=()=>{const{setIsLoading:e,setShowAddModal:a,showAddModal:n}=ve(),{mutateAsync:r,isLoading:l}=Qr();return A(()=>{e(l)},[e,l]),t.createElement(tn,{handleClose:()=>a(!1),title:"Create Track",open:n,onSave:async o=>{await r(o)&&a(!1)}})},vi="Error Updating Track";function yi(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return se([ce.UpdateProgram],r,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[R.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),n({severity:"error",title:vi,message:o})}})}const bi=()=>{const{setSelectedProgram:e,setIsLoading:a,selectedProgram:n}=ve(),{mutateAsync:r,isLoading:l}=yi();A(()=>a(l),[a,l]);const o=async i=>{await r(i)&&e(null)};return t.createElement(tn,{handleClose:()=>e(null),title:n!=null&&n.isEditable?"Edit Track":"View Track",open:!!n,onSave:o})},Ci=x(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),ki=()=>{const{selectedProgram:e,showAddModal:a}=ve(),[n]=Jt(),r=n.get("tracksPerPage"),l=r?parseInt(r,10):9,o=Ci(),i="Programs will now be referred to as Tracks throughout the Soundcheck UI.";return t.createElement("div",{className:o.programsPageContainer},t.createElement(Dn,{variant:"info",message:i,id:"programTrackBanner"}),t.createElement(Ir,{backend:Or},t.createElement(Mo,{programsPerPage:l}),a&&t.createElement(Ei,null),e&&t.createElement(bi,null)))},xi=()=>t.createElement(il,null,t.createElement(ki,null)),wi=e=>e?e.palette.type:"",an=e=>wi(e).toLowerCase()==="dark",Q=e=>an(e)?e.palette.grey[200]:e.palette.grey[800],Ze=e=>an(e)?An:Fn;function zt(e,a){return(a?e.minus({days:a}):e).toFormat("MMM dd")}function Me(e){const a=Nt.utc();return e.map((n,r)=>({name:zt(a,e.length-r-1),passRate:n}))}var Ni=(e=>(e.Bar="bar",e.Line="line",e))(Ni||{});const Ti=-25,de=[0,100],nn=85,Gt=25,Je="name",Pi=250,et=.5,rn="circle",ln=8,on="monotone",tt=({children:e})=>t.createElement(xa,{minHeight:Pi,debounce:1},e),Si=G(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",fontWeight:"bold",transform:"translate(-50%, -50%)",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),Li=()=>{const e=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],a=Si();return t.createElement("div",{className:a.container},t.createElement(tt,null,t.createElement(xt,{data:e},t.createElement(Ke,{strokeDasharray:"3 3",vertical:!1,opacity:et}),t.createElement(Oe,{dataKey:"x",stroke:"#ccc",hide:!0}),t.createElement(Ae,{domain:de,stroke:"#ccc",hide:!0}),t.createElement(wt,{type:"monotone",dataKey:"y",stroke:"#ccc",dot:!1}))),t.createElement(b,{className:a.chartMessage},"No Data"))},Ri=x(e=>({legend:{color:Q(e)}})),Ht=({data:e,lines:a})=>{const n=qe(),r=Ze(n),l=Q(n),o=Ri();return e.length?t.createElement(tt,null,t.createElement(xt,{data:e},t.createElement(Ke,{vertical:!1,opacity:et}),t.createElement(Oe,{dataKey:Je,stroke:l}),t.createElement(Ae,{width:Gt,domain:de,stroke:l}),t.createElement(wa,{position:{y:Ti},contentStyle:{backgroundColor:n.palette.background.paper}}),t.createElement(Na,{iconType:rn,iconSize:ln,formatter:i=>t.createElement("span",{className:o.legend},i)}),a.map((i,s)=>t.createElement(wt,{key:i.dataKey,dataKey:i.dataKey,stroke:r[s%r.length],strokeWidth:2,dot:!1,name:i.name,type:on})))):t.createElement(Li,null)},Di=({data:e,lines:a})=>{const n=qe(),r=Ze(n);return t.createElement(xa,{height:50,width:100},t.createElement(xt,{data:e},t.createElement(Oe,{hide:!0,dataKey:Je}),t.createElement(Ae,{width:0,domain:de}),a.map((l,o)=>t.createElement(wt,{key:l.dataKey,dataKey:l.dataKey,stroke:r[o%r.length],strokeWidth:2,dot:!1,name:l.name,type:on}))))},Be=({chartData:e,tableChart:a})=>{const n=[{dataKey:"passRate",name:"Pass rate"}];return a?t.createElement(Di,{data:e,lines:n}):t.createElement(Ht,{data:e,lines:n})};var P=(e=>(e.Entity="Entity",e.EntityOwner="Entity Owner",e.Track="Track",e.Level="Track Level",e.Check="Check",e.CheckOwner="Check Owner",e))(P||{});function Ii(e){var a;const n=L(O),[r,l]=C(null),o=async()=>(await n.getEntityRefsForTechHealthFilter(e)).entityRefsForTechHealthFilter,i=F([R.GetSoftwareEntityRefsForUser,e],o,{retry:!1,onError:l,enabled:e!==null,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1});return{data:(a=i.data)!=null?a:[],isLoading:i.isLoading,error:r}}const Oi=(e,a)=>{var n,r,l,o;const i=[];for(const c of e)i.push({label:(n=c.name)!=null?n:c.id,value:c.id});const s=e.map(c=>c.id);for(const c of a)for(const u of(r=c.levels)!=null?r:[])for(const m of(l=u.checks)!=null?l:[])s.includes(m.id)||(s.push(m.id),i.push({label:(o=m.name)!=null?o:m.id,value:m.id}));return i},Ai=e=>{var a;const n=[];for(const r of e!=null?e:[])for(const l of(a=r.levels)!=null?a:[])n.includes(l.ordinal)||n.push(l.ordinal);return n.sort().map(r=>({label:`Level ${r}`,value:`${r}`}))},Fi=(e,a)=>{const n=new Set(e.filter(r=>r.ownerEntityRef).map(r=>r.ownerEntityRef));return Array.from(n).map(r=>{var l;return{label:(l=a[r])!=null?l:r,value:r}})},$i=()=>{const[e,a]=C(!1),{userEntityRef:n}=_e(),{data:r,isLoading:l}=Ii(n),{data:o,isLoading:i}=tr(),s=B(()=>Ie.mapValues(Ie.keyBy(o!=null?o:[],"ref"),f=>f.name),[o]),{data:c,isLoading:u}=La(void 0,100),m=B(()=>{var f;return(f=c==null?void 0:c.edges.map(E=>E.program))!=null?f:[]},[c]),{data:d,isLoading:g}=Pt(void 0,100),p=B(()=>{var f;return(f=d==null?void 0:d.edges.map(E=>E.checker))!=null?f:[]},[d]),v=B(()=>{var f;return{[P.Entity]:r.map(E=>({label:K(E).name,value:E})),[P.EntityOwner]:(f=o==null?void 0:o.map(E=>({label:E.name,value:E.ref})))!=null?f:[],[P.Track]:m.map(E=>({label:E.name,value:E.id})),[P.Level]:Ai(m),[P.Check]:Oi(p,m),[P.CheckOwner]:Fi(p,s)}},[r,o,s,m,p]);return A(()=>{a(l||i||u||g)},[l,i,u,g]),{facetOptions:v,isLoading:e}},Ce=30,me=2,ke=90,ue=()=>Object.fromEntries(Object.values(P).map(e=>[e,[]])),Mi=(e,a,n)=>{if(a.length)return a.map(r=>({track:r,levels:n.length?n.map(l=>parseInt(l,10)):void 0}));if(n.length)return e.map(r=>({track:r.value,levels:n.map(l=>parseInt(l,10))}))},sn=(e,a,n,r)=>({checkIdFilter:a[P.Check].length?{included:a[P.Check]}:void 0,checkOwnerFilters:a[P.CheckOwner].length?{included:a[P.CheckOwner]}:void 0,entityOwnerFilters:a[P.EntityOwner].length?{included:a[P.EntityOwner]}:void 0,entityRefFilters:a[P.Entity].length?{included:a[P.Entity]}:void 0,trackFilters:Mi(e[P.Track],a[P.Track],a[P.Level]),numberOfDays:n!=null?n:Ce,context:r?{loggedInUser:r}:void 0});function Bi({angle:e,arc:a,direction:n,dist:r,emoji:l,delay:o,fontSize:i,speed:s}){return t.createElement(Tt.div,{style:{position:"absolute",fontSize:i},initial:{top:0,left:"50%",x:"-50%",y:"-100%",rotate:0,originX:`${a*n}px`,originY:`${a}px`},animate:{opacity:[0,1,0,0,0,0],y:`${-r}px`,rotate:e*n},transition:{delay:o,duration:s,ease:[.2,.83,.46,.63],repeat:1/0}},l)}const Vi=["\u{1F4C8}","\u{1F4CA}","\u{1F4C9}","\u{1F680}","\u2B50\uFE0F"],zi=x(()=>({container:{position:"relative"}}));function Gi({angle:e=125,density:a=20,emojis:n=Vi,fontSizeMin:r=6,fontSizeMax:l=24,size:o=300,speed:i=4}){const s=zi(),c=B(()=>Array.from({length:a*n.length}).map((u,m)=>({emoji:n[Math.floor(Math.random()*n.length)],arc:Math.random()*o*.5,delay:Math.random()*i,dist:Math.random()*o,direction:m%2?1:-1,fontSize:Math.random()*(l-r)+r,angle:e,speed:i})),[a,n,i,o,e,l,r]);return t.createElement("div",{className:s.container},t.createElement(b,{variant:"h1"},"\u{1F469}\u200D\u{1F4BB}"),c.map((u,m)=>t.createElement(Bi,{key:`${u.emoji}-${m}`,...u})))}const Hi=x(()=>({container:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,height:"100%"},textContainer:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}}));function xe({title:e,subtitle:a}){const n=Hi();return t.createElement("div",{className:n.container},t.createElement("div",{className:n.textContainer},t.createElement(Gi,null),t.createElement(Tt.div,{animate:{y:0,opacity:1},initial:{y:100,opacity:0}},e&&t.createElement(b,{align:"center",variant:"h6"},e),a&&t.createElement(b,{align:"center",variant:"subtitle2"},a))))}const Wi=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.default,height:"100%",maxWidth:"100%"},tabsPlaceholder:{height:"36.5px",backgroundColor:e.palette.background.paper}})),qi=()=>{const e=Wi();return t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn}),t.createElement("div",{className:e.flexibleColumn},t.createElement("div",{className:e.tabsPlaceholder}),t.createElement(xe,null)))},cn=Pe({facetOptionsLoading:!1,getFacetOptions:()=>[],getFacetOptionLabel:()=>"",facetFilters:ue(),clearAllFilters:()=>{},getSelectedFacetValues:()=>[],setSelectedFacetValues:()=>{},numberOfDays:Ce,setNumberOfDays:()=>{},filter:{},loggedInUser:"Unknown"}),ne=()=>Se(cn),_i=e=>{const{userEntityRef:a}=_e(),{isLoading:n,facetOptions:r}=$i(),[l,o]=Sa("soundcheck.techHealth.facetFilters",ue()),[i,s]=Sa("soundcheck.techHealth.numberOfDays",Ce),[c,u]=C(sn(r,l!=null?l:ue(),i,a));A(()=>{u(sn(r,l!=null?l:ue(),i,a))},[r,l,i,u,a]);const m=()=>{s(Ce),o(ue())},d=E=>r[E].map(y=>y.value),g=(E,y)=>{var w;let N=(w=r[E].find(D=>D.value===y))==null?void 0:w.label;if(!N)try{const D=K(y);N=Tr(D)}catch{}return N!=null?N:y},p=E=>l?l[E]:[],v=(E,y)=>{const w={...l!=null?l:ue()};w[E]=y,o(w)},f={facetOptionsLoading:n,getFacetOptions:d,getFacetOptionLabel:g,facetFilters:l!=null?l:ue(),clearAllFilters:m,getSelectedFacetValues:p,setSelectedFacetValues:v,numberOfDays:i!=null?i:Ce,setNumberOfDays:s,filter:c!=null?c:{},loggedInUser:"Unknown"};return n?t.createElement(qi,null):t.createElement(cn.Provider,{...e,value:f})},Ui={hidden:{height:0,opacity:0,overflow:"hidden"},visible:{height:"auto",opacity:1,overflow:"visible"}};function ji({visible:e,...a}){return t.createElement(Tt.div,{...a,animate:e?"visible":"hidden",initial:"hidden",variants:Ui})}const Ki=x(({palette:e,spacing:a})=>({header:{display:"flex",alignItems:"center",flexDirection:"row",cursor:"pointer"},headerTitle:{flex:"1 1 0%"},chip:{backgroundColor:e.info.dark,textOverflow:"ellipsis",overflow:"hidden"},autoCompleteInput:{"&& input":{margin:a(1,0,0,0),width:"100%"}}})),Yi=({facet:e})=>{const a=Ki(),{getFacetOptions:n,getFacetOptionLabel:r,getSelectedFacetValues:l,setSelectedFacetValues:o}=ne(),[i,s]=C(!!l(e).length),[c,u]=C(!1),[m,d]=C(""),g=()=>{s(f=>!f)},p=f=>{(f.key==="Enter"||f.key===" ")&&g()},v=f=>{if(e===P.Entity&&f[f.length-1]){const E=f[f.length-1];if(!E.includes(":")||!E.includes("/")){u(!0),d("Custom entities require a valid kind and namespace such as: component:default/entity");return}}u(!1),d(""),o(e,f)};return t.createElement(k,null,t.createElement("div",{className:a.header,onClick:g,onKeyDown:p,role:"button",tabIndex:0},t.createElement(k,{className:a.headerTitle},t.createElement(b,{variant:"subtitle2"},e)),t.createElement(k,null,t.createElement(he,{size:"small",onKeyDown:p},i?t.createElement(ha,{fontSize:"small"}):t.createElement(Et,{fontSize:"small"})))),t.createElement(ji,{visible:i},t.createElement(bt,{className:a.autoComplete,fullWidth:!0,multiple:!0,freeSolo:e===P.Entity,popupIcon:null,ChipProps:{color:"primary",className:a.chip,size:"small"},options:n(e),getOptionLabel:f=>r(e,f),value:l(e),onChange:(f,E)=>v(E),renderInput:f=>t.createElement(M,{...f,className:a.autoCompleteInput,margin:"normal",placeholder:`Search for ${e}`,error:c,helperText:m}),renderOption:(f,{selected:E})=>t.createElement(We,{control:t.createElement(Re,{icon:t.createElement(va,{fontSize:"small"}),checkedIcon:t.createElement(Ea,{fontSize:"small"}),checked:E}),label:r(e,f)})})))},Qi=x(({palette:e,spacing:a})=>({root:{padding:({size:n})=>n==="small"?a(1,2):a(2),borderBottom:`1px solid ${e.border}`}}));function Wt(e){const a=Qi(e);return t.createElement(k,{...e,className:a.root})}const Xi=x(e=>({root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing(.25)}}));function Zi(){const e=Xi(),{numberOfDays:a,facetFilters:n,clearAllFilters:r}=ne(),l=Object.keys(P).some(o=>n[P[o]].length)||a!==Ce;return t.createElement(k,{className:e.root},t.createElement(k,null,t.createElement(b,{variant:"h6"},"Filters")),l&&t.createElement(k,null,t.createElement(_,{onClick:r,size:"small"},"Clear all")))}const Ji=x(({palette:e,spacing:a})=>({select:{width:"100%",margin:a(1,0)},chip:{backgroundColor:e.info.dark}})),at=[7,30,90].map(e=>({value:e,label:`Last ${e} days`}));function es(){const e=Ji(),{numberOfDays:a,setNumberOfDays:n}=ne(),r=[...at];at.map(d=>d.value).includes(a)||r.push({value:a,label:`Last ${a} days`});const[l,o]=C(r),[i,s]=C(""),c=()=>{if(i.length){const d=parseInt(i,10);return!isNaN(d)&&(d<me||d>ke)}return!1},u=()=>{const d=parseInt(i,10);if(d<me)return`Minimum of ${me} days`;if(d>ke)return`Maximum of ${ke} days`},m=d=>{if(d.key==="Enter"){const g=parseInt(i,10);g>=me&&g<=ke?(at.map(p=>p.value).includes(g)||o([...at,{value:g,label:`Last ${g} days`}]),n(g),s("")):g<me?s(`${me}`):s(`${ke}`)}};return t.createElement(k,null,t.createElement(k,{marginBottom:2},t.createElement(k,null,l.sort((d,g)=>d.value-g.value).map(({label:d,value:g})=>t.createElement(ht,{key:g,label:d,className:a===g?e.chip:void 0,color:a===g?"primary":void 0,size:"small",onClick:()=>n(g)})))),t.createElement(k,null,t.createElement(M,{fullWidth:!0,placeholder:"Number of days",inputProps:{min:me,max:ke},onKeyDown:m,helperText:u(),value:i,type:"number",error:c(),onChange:d=>s(d.target.value)})))}const ts=x(e=>({filters:{maxWidth:"300px",width:"100%",backgroundColor:e.palette.background.paper}})),as=()=>{const e=ts();return t.createElement(k,{className:e.filters},t.createElement(Wt,null,t.createElement(Zi,null)),t.createElement(Wt,null,t.createElement(es,null)),Object.values(P).map(a=>t.createElement(Wt,{key:a,size:"small"},t.createElement(Yi,{facet:a}))))},dn=Pe({checkPassRateOverview:{data:void 0,isLoading:!0,isError:!1},trackPassRateOverview:{data:void 0,isLoading:!0,isError:!1},entityPassRatesOverview:{data:void 0,isLoading:!0,isError:!1},groupPassRatesOverview:{data:void 0,isLoading:!0,isError:!1}}),Ve=()=>Se(dn),ns=e=>{const{filter:a}=ne(),n=Zr(a),r=el(a),l=al(a),o=rl(a),i=B(()=>({checkPassRateOverview:n,trackPassRateOverview:r,entityPassRatesOverview:l,groupPassRatesOverview:o}),[n,r,l,o]);return n.isLoading||r.isLoading||l.isLoading||o.isLoading?t.createElement(xe,null):t.createElement(dn.Provider,{...e,value:i})},rs=e=>{const a=(e==null?void 0:e.overallTrackPassRate)||[];if(!a.length)return[];const n=Nt.utc();return a.reduce((r,{trendPassRates:l,levelOrdinal:o},i)=>{var s;const c=(s=l==null?void 0:l.map((u,m)=>({name:zt(n,l.length-m-1),[`Level${o}`]:u})))!=null?s:[];return i===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},ls=()=>{var e,a;const{trackPassRateOverview:{data:n,isError:r}}=Ve();if(r)return t.createElement(b,{color:"error"},"Failed to load track data.");const l=rs(n),o=(a=(e=n==null?void 0:n.overallTrackPassRate)==null?void 0:e.map(({levelOrdinal:i})=>({dataKey:`Level${i}`,name:`Level ${i}`})))!=null?a:[];return t.createElement(Ht,{data:l,lines:o})},os=e=>{const a=(e==null?void 0:e.overallEntityPassRates)||[];if(!a.length)return[];const n=Nt.utc();return a.reduce((r,{trendPassRates:l,id:o},i)=>{var s;const c=(s=l==null?void 0:l.map((u,m)=>({name:zt(n,l.length-m-1),[o]:u})))!=null?s:[];return i===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},is=()=>{var e,a;const{entityPassRatesOverview:{data:n}}=Ve(),r=(a=(e=n==null?void 0:n.overallEntityPassRates)==null?void 0:e.map(({id:o})=>({dataKey:o,name:K(o).name})))!=null?a:[],l=os(n);return t.createElement(Ht,{data:l,lines:r})},ss=G(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontWeight:"bold",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),cs=({layout:e,theme:a})=>{const n=e===nt.Vertical,r=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],l=[{x:"A",y:100},{x:"B",y:90},{x:"C",y:80},{x:"C",y:70},{x:"C",y:60}],o=ss();return t.createElement("div",{className:o.container},t.createElement(tt,null,t.createElement(Ta,{data:n?l:r,margin:{left:0},layout:e},t.createElement(Ke,{strokeDasharray:"3 3",vertical:n,horizontal:!n,opacity:et}),t.createElement(Oe,{dataKey:n?void 0:"x",type:n?ze.Number:ze.Category,domain:n?de:void 0,hide:!0}),t.createElement(Ae,{width:n?nn:Gt,dataKey:n?"x":void 0,type:n?ze.Category:ze.Number,domain:n?void 0:de,hide:!0}),t.createElement(Pa,{dataKey:"y",fill:a.palette.divider,barSize:n?mn:un}))),t.createElement(b,{className:o.chartMessage},"No Data"))},ds=x(e=>({legend:{color:Q(e)}}));var nt=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(nt||{});const mn=20,un=50;var ze=(e=>(e.Category="category",e.Number="number",e))(ze||{});const pn={dataKey:"passRate",name:"Pass rate"},hn=Pn(({data:e,layout:a})=>{const n=a==="vertical",r=qe(),l=Ze(r),o=Q(r),i=ds();return e.length?t.createElement(tt,{"aria-label":"Bar chart representing data points."},t.createElement(Ta,{data:e,layout:a},t.createElement(Ke,{vertical:n,horizontal:!n,opacity:et}),t.createElement(Oe,{dataKey:n?void 0:Je,type:n?"number":"category",domain:n?de:void 0,stroke:o}),t.createElement(Ae,{width:n?nn:Gt,dataKey:n?Je:void 0,type:n?"category":"number",domain:n?void 0:de,stroke:o}),t.createElement(wa,{contentStyle:{backgroundColor:r.palette.background.default},itemStyle:{color:Q(r)},cursor:{fill:"transparent"}}),t.createElement(Na,{iconType:rn,iconSize:ln,formatter:s=>t.createElement("span",{className:i.legend},s),payload:e.map(({name:s},c)=>({id:s,value:s,color:l[c%l.length]}))}),t.createElement(Pa,{barSize:n?mn:un,dataKey:pn.dataKey,name:pn.name},e.map(({name:s},c)=>t.createElement(zr,{key:s,fill:l[c%l.length]}))))):t.createElement(cs,{layout:a,theme:r})}),ms=e=>{var a,n;return(n=(a=e==null?void 0:e.overallTrackPassRate)==null?void 0:a.map(({levelOrdinal:r,snapshotPassRate:l})=>({name:`Level ${r}`,passRate:l})))!=null?n:[]},us=()=>{const{trackPassRateOverview:{data:e,isError:a}}=Ve();if(a)return t.createElement(b,{color:"error"},"Failed to load track data.");const n=ms(e);return t.createElement(hn,{data:n,layout:nt.Horizontal})},ps=e=>{var a;return(a=e==null?void 0:e.map(({id:n,groupTitle:r,snapshotPassRate:l})=>({name:r!=null?r:K(n).name,passRate:l})))!=null?a:[]},hs=()=>{var e;const{groupPassRatesOverview:{data:a}}=Ve(),n=(e=a==null?void 0:a.groupPassRates)==null?void 0:e.sort((l,o)=>o.snapshotPassRate-l.snapshotPassRate),r=ps(n);return t.createElement(hn,{data:r,layout:nt.Vertical})},gs=G(e=>({card:{display:"flex",flexDirection:"column",gap:e.spacing(1),border:`1px solid ${e.palette.divider}`,boxShadow:"none",width:"99%"},title:{fontWeight:"bold",fontSize:e.typography.h5.fontSize,lineHeight:`${e.typography.h3.fontSize}px`},subtitle:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.h6.fontSize}px`,color:e.palette.grey[800]},headerRow:{display:"flex",padding:e.spacing(1,2),borderBottom:`1px solid ${e.palette.divider}`,gap:e.spacing(2)},headerSection:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},contentRow:{padding:e.spacing(2.5,2),display:"flex",gap:e.spacing(2)},leftSection:{width:"200px"},summaryCard:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},chartSection:{flex:1,width:"100%",minWidth:"200px"},chartDisplaySummary:{flex:1,display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",justifyContent:"end"}})),rt=({title:e,subtitle:a,summaryCardContent:n,chartSectionContent:r})=>{const l=gs();return t.createElement(pt,{className:l.card},t.createElement(k,{className:l.headerRow},t.createElement(k,{className:l.headerSection},t.createElement(b,{className:l.title},e),t.createElement(b,{variant:"caption"},a))),t.createElement(k,{className:l.contentRow},n&&t.createElement(k,{className:l.leftSection},t.createElement(k,{className:l.summaryCard},n)),t.createElement(k,{className:l.chartSection},r)))},fs=x(e=>({chartHeader:{marginBottom:e.spacing(2)},overallSummaryBox:{display:"flex",flexDirection:"column",height:"100%",color:Q(e),textAlign:"center",gap:e.spacing(2)},percentage:{fontSize:e.typography.pxToRem(65),lineHeight:`${e.typography.pxToRem(88)}px`,fontWeight:"bold"},summaryText:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.pxToRem(14)}px`}})),Es=()=>{var e,a,n;const r=qe(),l=fs(),{checkPassRateOverview:{data:o}}=Ve(),i=(a=(e=o==null?void 0:o.overallCheckPassRates)==null?void 0:e.length)!=null?a:0,s=Me((n=o==null?void 0:o.overallCheckPassRates)!=null?n:[]),c=o!=null&&o.overallCheckPassRates&&i?Math.round(o.overallCheckPassRates[i-1]):0;let u;!(o!=null&&o.overallCheckPassRates)||!i?u="No Data":u=`${c}%`;const m=t.createElement(k,{className:l.overallSummaryBox},t.createElement(Gr,{value:c,text:u,styles:Hr({textColor:Q(r),pathColor:Ze(r)[0],trailColor:r.palette.divider,textSize:i?void 0:8})}),t.createElement(b,{className:l.summaryText},"Current check pass rate"));return t.createElement(rt,{title:"Check pass rate",subtitle:"Aggregate pass rate for checks",summaryCardContent:m,chartSectionContent:t.createElement(Be,{chartData:s})})},vs=()=>t.createElement(rt,{title:"Track pass rate",subtitle:"Aggregate pass rate for tracks",summaryCardContent:t.createElement(us,null),chartSectionContent:t.createElement(ls,null)}),ys=()=>t.createElement(rt,{title:"Entity pass rate",subtitle:"Compare the aggregate pass rate for entities",chartSectionContent:t.createElement(is,null)}),bs=()=>t.createElement(rt,{title:"Team pass rate",subtitle:"Compare the aggregate pass rate for teams",chartSectionContent:t.createElement(hs,null)}),Cs=G(e=>({root:{display:"flex",flexDirection:"column",gap:e.spacing(2),flex:1,background:e.palette.background.default}})),ks=()=>{const e=Cs();return t.createElement(k,{className:e.root},t.createElement(ns,null,t.createElement(Es,null),t.createElement(vs,null),t.createElement(ys,null),t.createElement(bs,null)))},xs=G(e=>({paper:{width:"100%",boxShadow:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius},tableHeaderCell:{fontWeight:"bold"}})),lt=({data:e,columns:a})=>{const n=xs(),[r,l]=C(0),[o,i]=C(10);A(()=>{l(0)},[e.length]);const s=(d,g)=>{l(g)},c=d=>{i(+d.target.value),l(0)},u=r*o,m=u+o;return t.createElement(Le,{className:n.paper},t.createElement(Kn,{size:"small"},t.createElement(Yn,null,t.createElement(da,null,a.map(d=>t.createElement(ma,{key:`header-${d.id}`,className:n.tableHeaderCell},d.label)))),t.createElement(Qn,null,e.slice(u,m).map(d=>t.createElement(da,{key:d.id},a.map(g=>t.createElement(ma,{key:`cell-${g.id}`},g.renderCell?g.renderCell(d):d[g.id])))))),t.createElement(ca,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:s,onRowsPerPageChange:c}))};var ws=(e=>(e.Check="check",e.Track="track",e.Entity="entity",e.Group="group",e))(ws||{});const U=G(e=>({root:{display:"flex",flexDirection:"column",flex:1,background:e.palette.background.default},ownerText:{fontWeight:500,color:Q(e)},flexColumn:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},boldText:{fontWeight:"bold"},descriptionText:{maxWidth:400,color:Q(e),fontSize:e.typography.subtitle2.fontSize,lineHeight:e.typography.subtitle1.fontSize},detailButton:{textTransform:"none",backgroundColor:"transparent","&:hover":{backgroundColor:e.palette.action.hover}}})),ot=({name:e="",description:a=""})=>{const n=U();return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},e),t.createElement(aa,{className:n.descriptionText,content:a!=null?a:""}))},it=({navigateTo:e})=>{const a=U(),n=Sn();return t.createElement(_,{variant:"text",className:a.detailButton,onClick:()=>n(e)},t.createElement(b,{className:a.ownerText},"View detail"))},Ns=e=>{const a=L(ya);return F([R.EntityByRef,e],async()=>a.getEntityByRef(e),{onError:()=>{},enabled:!!e})},Ts=e=>(e==null?void 0:e.kind)==="Group",Ps=e=>(e==null?void 0:e.kind)==="User",qt=({ownerEntityRef:e})=>{var a,n;const{data:r,error:l}=Ns(e!=null?e:void 0);if(r){let o;return Ts(r)||Ps(r)?o=(n=r.metadata.title)!=null?n:(a=r.spec.profile)==null?void 0:a.displayName:o=r.metadata.name,t.createElement(kt,{entityRef:Pr(r),title:o})}else if(l&&e)return t.createElement(oe,{title:"Unable to pull owner reference from Catalog API"},t.createElement(b,{style:{color:"red"},variant:"body2"},(()=>{try{return K(e).name}catch{return e}})()));return null},Ss=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))},Ls=(e,a)=>{const n=Math.min(5,a-e+1);return Array.from({length:n}).map((r,l)=>{const o=e+l;return{label:`LEVEL ${o}`,id:`levels-${l}`,renderCell:i=>{var s;const c=(s=i.levels)==null?void 0:s.find(({levelOrdinal:u})=>u===o);return c?t.createElement(Ss,{row:c}):t.createElement(t.Fragment,null)}}})},Rs=(e,a)=>{const n=e.flatMap(o=>{var i;return((i=o.levels)==null?void 0:i.map(s=>s.levelOrdinal))||[]}),r=Math.min(...n),l=Math.max(...n);return[{label:"NAME",id:"trackName",renderCell:o=>{var i;return t.createElement(ot,{name:(i=o.trackName)!=null?i:o.id,description:o.trackDescription})}},...Ls(r,l),{label:"OWNER",id:"trackOwnerRef",renderCell:o=>{var i;return t.createElement(qt,{ownerEntityRef:(i=o.trackOwnerRef)!=null?i:void 0})}},{label:"ACTION",id:"action",renderCell:o=>t.createElement(it,{navigateTo:a({trackId:o.id})})}]},Ds=()=>{const e=U(),{filter:a}=ne(),n=Ue(ir),{data:r,isLoading:l,isError:o}=tl(a),i=B(()=>{var c;return Rs((c=r==null?void 0:r.individualTrackPassRate)!=null?c:[],n)},[r==null?void 0:r.individualTrackPassRate,n]);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load tracks");const{individualTrackPassRate:s}=r;return s?t.createElement(k,{className:e.root},t.createElement(lt,{data:s,columns:i})):t.createElement(b,{color:"error"},"No available tracks")},Is=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))};function Os(e){return[{label:"NAME",id:"entityName",renderCell:({id:a,entityDescription:n})=>t.createElement(ot,{name:K(a).name,description:n})},{label:"TREND",id:"trend",renderCell:a=>t.createElement(Is,{row:a})},{label:"OWNER",id:"entityOwnerRef",renderCell:({entityOwnerRef:a})=>t.createElement(qt,{ownerEntityRef:a!=null?a:void 0})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(it,{navigateTo:`${e(K(a))}/soundcheck`})}]}const As=()=>{const e=U(),{filter:a}=ne(),n=Ue(ba),{data:r,isLoading:l,isError:o}=nl(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load entities");const{individualEntityPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:Os(n)})):t.createElement(b,{color:"error"},"No available entities")},Fs=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=U(),r=Me(e!=null?e:[]);return r.length?t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Be,{chartData:r,tableChart:!0})):t.createElement(k,{className:n.flexColumn},t.createElement(b,null,"No data"))};function $s(e){return[{label:"NAME",id:"groupName",renderCell:({groupTitle:a,id:n})=>t.createElement(ot,{name:a!=null?a:K(n).name})},{label:"TREND",id:"trend",renderCell:a=>t.createElement(Fs,{row:a})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(it,{navigateTo:e(K(a))})}]}const Ms=()=>{const e=U(),{filter:a}=ne();a.context=void 0;const n=Ue(ba),{data:r,isLoading:l,isError:o}=ll(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load groups");const{groupPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:$s(n)})):t.createElement(b,{color:"error"},"No available groups")},Bs=({row:e})=>{var a;const n=U(),r=Me((a=e.trendPassRates)!=null?a:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(e.snapshotPassRate),"%"),t.createElement(Be,{chartData:r,tableChart:!0}))};function Vs(e){return[{label:"NAME",id:"checkName",renderCell:a=>{var n;return t.createElement(ot,{name:(n=a.checkName)!=null?n:a.id,description:a.checkDescription})}},{label:"TREND",id:"snapshotPassRate",renderCell:a=>t.createElement(Bs,{row:a})},{label:"OWNER",id:"checkOwner",renderCell:a=>{var n;return t.createElement(qt,{ownerEntityRef:(n=a.checkOwnerRef)!=null?n:void 0})}},{label:"ACTION",id:"action",renderCell:()=>t.createElement(it,{navigateTo:e()})}]}const zs=()=>{const e=U(),{filter:a}=ne(),n=Ue(sr),{data:r,isLoading:l,isError:o}=Jr(a);if(l)return t.createElement(xe,null);if(o)return t.createElement(b,{color:"error"},"Failed to load checks");const{individualCheckPassRates:i}=r;return i?t.createElement(k,{className:e.root},t.createElement(lt,{data:i,columns:Vs(n)})):t.createElement(b,{color:"error"},"No available checks")},Gs=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.paper,height:"100%",maxWidth:"100%"},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%",backgroundColor:e.palette.background.default,"& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto",borderTop:`1px solid ${e.palette.border}`}}})),Hs=()=>{const e=Gs();return t.createElement(_i,null,t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn},t.createElement(as,null)),t.createElement("div",{className:e.flexibleColumn},t.createElement(k,{className:e.pageLayout},t.createElement(ea,null,t.createElement(ta,{path:"/*",element:t.createElement(z,null,t.createElement(z.Route,{title:"Summary",path:"/"},t.createElement(ks,null)),t.createElement(z.Route,{title:"Checks",path:"/checks"},t.createElement(zs,null)),t.createElement(z.Route,{title:"Tracks",path:"/tracks"},t.createElement(Ds,null)),t.createElement(z.Route,{title:"Entities",path:"/entities"},t.createElement(As,null)),t.createElement(z.Route,{title:"Teams",path:"/teams"},t.createElement(Ms,null)))}))))))},gn=Pe({selectedCollector:null,setSelectedCollector:()=>{},showModal:!1,setShowModal:()=>{},hideModal:()=>{}}),Ws=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),o=()=>{n(null),l(!1)};return t.createElement(gn.Provider,{value:{selectedCollector:a,setSelectedCollector:n,showModal:r,setShowModal:l,hideModal:o}},e)},st=()=>Se(gn),qs=({collector:e,children:a})=>{const{description:n,id:r,isEditable:l,name:o}=e,{setSelectedCollector:i}=st(),{loading:s,allowed:c}=te({permission:br}),u=l&&!s&&c;return t.createElement(Vt,{title:o!=null?o:r,description:n,viewLabel:"Configure",editLabel:"Configure",children:a,handleView:void 0,handleEdit:u?()=>i(e):void 0})},_s=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,a)=>t.createElement(h,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ct,{variant:"rect",height:385}))));function Us(e){switch(e){case"catalog":return Wr;case"github":return _r;case"scm":return qr;case"soundcheck":return jr;case"techinsights":return Kr;default:return Ur}}const js=x(e=>({container:{display:"flex",justifyContent:"center",alignItems:"center"},imageContainer:{width:"150px",height:"150px"},image:{width:"100%",height:"100%",objectFit:"contain"}})),Ks=({collector:e})=>{const{id:a}=e,n=js();return t.createElement(t.Fragment,null,t.createElement("div",{className:n.container},t.createElement("div",{className:n.imageContainer},t.createElement("img",{src:Us(a),alt:a,className:n.image}))))},Ys=()=>{const{data:e,isLoading:a}=Aa();return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},a?t.createElement(_s,null):e==null?void 0:e.sort((n,r)=>{var l,o;return((l=n.name)!=null?l:n.id).localeCompare((o=r.name)!=null?o:r.id)}).map(n=>t.createElement(h,{key:n.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(qs,{collector:n},t.createElement(Ks,{collector:n}))))))},fn=()=>({enabled:!1,hasDuration:!1,unit:I.Days,value:1});function _t(e){if(e){const{enabled:a,hasDuration:n}=e;if(a&&n){const{unit:r,value:l}=e;return{duration:{[r]:l}}}return a}}function Ut(e){var a;const n=fn();if(!e)return n;if(typeof e=="boolean")return{...n,enabled:e};if(!Ie.isObject(e)||!("duration"in e))return n;const r=e.duration;if(!Ie.isObject(r))return n;const l=Object.entries(r);if(l.length===0)return n;const[o,i]=l[0];return{...n,enabled:!0,hasDuration:!0,unit:(a=Xe(o))!=null?a:I.Days,value:i}}const Qs=x(e=>({duration:{display:"flex",padding:e.spacing(1),gap:e.spacing(2),alignItems:"flex-start"},checkbox:{margin:e.spacing(-1.5,0)},label:{cursor:"pointer"}})),Xs=({value:e,onChange:a,disabled:n,errors:r})=>{const l=Qs(),[o,i]=C(e),[s,c]=C(`${e.value}`);A(()=>{a&&a(o)},[o,a]);const u=p=>{i({...o,enabled:p.target.checked,hasDuration:p.target.checked&&o.hasDuration})},m=p=>{i({...o,hasDuration:p.target.checked})},d=p=>{c(p.target.value);const v=parseInt(p.target.value,10);i({...o,value:isNaN(v)?0:v})},g=p=>{var v;i({...o,unit:(v=Xe(p.target.value))!=null?v:I.Hours})};return t.createElement(h,{container:!0,direction:"column"},t.createElement(h,{item:!0},t.createElement(h,{container:!0,alignItems:"center"},t.createElement(h,{item:!0},t.createElement(Re,{id:"enableCaching",disabled:n,checked:o.enabled,onChange:u,"data-testid":"enableCaching"})),t.createElement(h,{item:!0},t.createElement("label",{htmlFor:"enableCaching",className:l.label},"Enable caching")))),t.createElement(h,{item:!0},t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,className:l.checkbox},t.createElement(Re,{id:"hasDuration",disabled:n||!o.enabled,checked:o.enabled&&o.hasDuration,onChange:m,"data-testid":"hasDuration"})),t.createElement(h,{item:!0},t.createElement("label",{htmlFor:"hasDuration",className:o.enabled?l.label:""},"Duration")),t.createElement(h,{className:l.duration},t.createElement(h,{item:!0},t.createElement(M,{id:"every",type:"number",label:"For",name:"for",disabled:n||!o.hasDuration,value:s,onChange:d,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,inputProps:{min:Ba,max:Va},"data-testid":"forTextField"})),t.createElement(h,{item:!0},t.createElement(dt,null,t.createElement(mt,{id:"duration-unit"},"Unit"),t.createElement(ut,{labelId:"duration-unit",disabled:n||!o.hasDuration,value:o.unit,onChange:g,"data-testid":"unitSelect"},It.map(p=>t.createElement(ge,{key:p,value:p},p)))))))))},Zs=({enabled:e,hasDuration:a,value:n})=>e&&a?za(n):!0,Js=x(e=>({root:{padding:e.spacing(1)},tabsContainer:{marginRight:16},tab:{height:"64px",textAlign:"left"},contentContainer:{width:"100%",padding:e.spacing(1)},divider:{marginTop:e.spacing(8),marginBottom:e.spacing(8)}})),jt=({name:e,label:a,description:n,control:r,disabled:l,errors:o})=>{const[i,s]=C(0),c=ft({control:r,name:`${e}.enabled`}),u=(d,g)=>{s(g)},m=Js();return t.createElement("div",{className:m.root},t.createElement(H,{name:`${e}.enabled`,control:r,render:({field:d})=>t.createElement(We,{control:t.createElement(Xn,{...d,checked:d.value}),label:t.createElement(k,{display:"flex",flexDirection:"column"},t.createElement(b,{variant:"body1",component:"span"},t.createElement("b",null,`${a}`)),t.createElement(b,{variant:"caption",color:"textSecondary",component:"p"},`${n}`))})}),c&&t.createElement("div",null,t.createElement(Zn,{orientation:"horizontal",variant:"scrollable",value:i,onChange:u,className:m.tabsContainer},t.createElement(gt,{label:"Frequency",className:m.tab}),t.createElement(gt,{label:"Filters",className:m.tab}),t.createElement(gt,{label:"Caching",className:m.tab})),t.createElement("div",{className:m.contentContainer},i===0&&t.createElement("div",null,t.createElement(H,{name:`${e}.frequency`,control:r,rules:{validate:Ua},render:({field:d})=>t.createElement(Ga,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.frequency})})),i===1&&t.createElement("div",null,t.createElement(H,{name:`${e}.filters`,control:r,render:({field:d})=>t.createElement(Mt,{disabled:l,value:d.value,onChange:d.onChange})})),i===2&&t.createElement("div",null,t.createElement(H,{name:`${e}.cacheConfig`,control:r,rules:{validate:Zs},render:({field:d})=>t.createElement(Xs,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.cacheConfig})})))))},Kt=()=>({enabled:!1,filters:{...Ye(),selectedKinds:["Component"]},frequency:Dt(),cacheConfig:fn()}),En=()=>({branchProtections:Kt(),repositoryDetails:Kt(),repositoryLanguages:Kt()});function ec(e){const{branchProtections:a,repositoryDetails:n,repositoryLanguages:r}=e;if(a.enabled||n.enabled||r.enabled){const l={},o=[];if(l.collects=o,a.enabled){const{cacheConfig:i,frequency:s,filters:c}=a;o.push({factName:"branch_protections",type:"BranchProtections",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}if(n.enabled){const{cacheConfig:i,frequency:s,filters:c}=n;o.push({factName:"repository_details",type:"RepositoryDetails",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}if(r.enabled){const{cacheConfig:i,frequency:s,filters:c}=r;o.push({factName:"repository_languages",type:"RepositoryLanguages",frequency:Ot(s),filters:Qe(c),cache:_t(i)})}return l}return[]}function tc(e){var a,n,r,l,o,i;const s=En();if(e){const c=e.collects;if(c)for(const u of vt(c)){const m=u.type;m==="BranchProtections"&&(s.branchProtections={enabled:!0,frequency:At((a=u.frequency)!=null?a:e.frequency),filters:Rt((n=u.filters)!=null?n:e.filters),cacheConfig:Ut(u.cache)}),m==="RepositoryDetails"&&(s.repositoryDetails={enabled:!0,frequency:At((r=u.frequency)!=null?r:e.frequency),filters:Rt((l=u.filters)!=null?l:e.filters),cacheConfig:Ut(u.cache)}),m==="RepositoryLanguages"&&(s.repositoryLanguages={enabled:!0,frequency:At((o=u.frequency)!=null?o:e.frequency),filters:Rt((i=u.filters)!=null?i:e.filters),cacheConfig:Ut(u.cache)})}}return s}const ac="Error Configuring Collector";function nc(){const e=L(O),a=ie(),{showAlert:n}=ee(),r=async l=>{const o=await e.updateCollectorConfig(l);if(!o)throw new Error("Failed to update collector configuration.");return o};return se([ce.UpdateCollectorConfig],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[R.GetCollectors]})},onError:l=>{let o="Failed to update collector configuration.";l instanceof Error&&(o=l.message),n({severity:"error",title:ac,message:o})}})}const rc=({disabled:e})=>{const{hideModal:a,selectedCollector:n}=st(),{control:r,formState:{errors:l},handleSubmit:o}=pa({defaultValues:n?tc(n.config):En(),mode:"onChange"}),i=!!l.branchProtections||!!l.repositoryDetails||!!l.repositoryLanguages,{mutate:s}=nc(),c=async u=>{const m=ec(u);s({collectorId:"github",config:m}),a()};return t.createElement("form",{onSubmit:o(c)},t.createElement(jt,{name:"branchProtections",label:"Branch Protections",description:"Collects branch protection information from an entity's repository.",control:r,disabled:e,errors:l.branchProtections}),t.createElement(He,null),t.createElement(jt,{name:"repositoryDetails",label:"Repository Details",description:"Collects details about the an entity's repository.",control:r,disabled:e,errors:l.repositoryDetails}),t.createElement(He,null),t.createElement(jt,{name:"repositoryLanguages",label:"Repository Languages",description:"Collects details about the languages used in an entity's repository.",control:r,disabled:e,errors:l.repositoryLanguages}),t.createElement(h,{container:!0,spacing:4},t.createElement(St,{onCancel:a,saveButtonText:"Save",isLoading:!1,onSave:o(c),disableSave:i})))},lc=({title:e,open:a,handleClose:n})=>{const{selectedCollector:r}=st();return t.createElement(Lt,{handleClose:n,title:e,open:a},(r==null?void 0:r.id)==="github"&&t.createElement(rc,null))},oc=x(e=>({container:{padding:e.spacing(3)}})),ic=()=>{var e;const a=oc(),{selectedCollector:n,hideModal:r}=st();return t.createElement("div",{className:a.container},t.createElement(Ys,null),n&&t.createElement(lc,{title:(e=n.name)!=null?e:n.id,open:!!n,handleClose:r}))},sc=()=>t.createElement(Ws,null,t.createElement(ic,null)),cc=x(()=>({tabContent:{margin:0,padding:0},root:{"& > *":{display:"flex",flexDirection:"column",flexGrow:1}},pageContent:{display:"flex",flexDirection:"row",flexGrow:1},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%","& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto"}}})),dc=({title:e="Soundcheck"})=>{const a=cc(),[n,r]=ar(),{group:l}=n,[o,i]=C(void 0),{loading:s,allowed:c}=te({permission:Cr}),u=d=>{d&&r({...n,group:d})},m=Ln();return t.createElement(cr,null,t.createElement(nr,null,t.createElement(dr,null,t.createElement(mr,null,t.createElement(k,{className:a.root},t.createElement(In,{themeId:"tool"},t.createElement($n,{backend:"soundcheck",invalidLicenseMessage:"Submitted facts and check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present."}),t.createElement(On,{title:e},m.pathname.split("/").length-1===1&&t.createElement(rr,{onChange:u,initialValue:l,setError:i})),t.createElement(k,{className:a.pageContent},t.createElement(k,{className:a.pageLayout},t.createElement(ea,null,t.createElement(ta,{path:"/*",element:t.createElement(z,null,t.createElement(z.Route,{title:"Overview",path:"/"},t.createElement("div",{className:a.tabContent},t.createElement(lr,{groupSelectorError:o,searchParams:n,setSearchParams:r}))),t.createElement(z.Route,{title:"Tech Health",path:"/tech-health"},t.createElement(Hs,null)),t.createElement(z.Route,{title:"Checks",path:"/checks"},t.createElement(Lo,null)),t.createElement(z.Route,{title:"Tracks",path:"/tracks"},t.createElement(xi,null)),!s&&c&&t.createElement(z.Route,{title:"Collectors",path:"/collectors"},t.createElement(sc,null)))}))))))))))};export{dc as RoutingPage};
|
|
2
|
-
//# sourceMappingURL=index-100619e3.esm.js.map
|